@parcha/agentrun-serve 0.1.0-beta.57 → 0.1.0-beta.58
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/CHANGELOG.md +52 -0
- package/README.md +64 -33
- package/dist/api-only.d.ts +2 -4
- package/dist/api-only.js +2 -4
- package/dist/box-paths.d.ts +4 -3
- package/dist/box-paths.js +7 -4
- package/dist/claude-login-token.d.ts +117 -0
- package/dist/claude-login-token.js +737 -0
- package/dist/claude-login.d.ts +52 -12
- package/dist/claude-login.js +164 -39
- package/dist/cli.js +7 -41
- package/dist/computer-attach.d.ts +35 -17
- package/dist/computer-attach.js +301 -49
- package/dist/computers.d.ts +10 -10
- package/dist/computers.js +5 -5
- package/dist/console/assets/{backend-DVhHzJX2.js → backend-CSAWUqtZ.js} +1 -1
- package/dist/console/assets/index-DPh29cyz.js +747 -0
- package/dist/console/index.html +1 -1
- package/dist/dial-relay.d.ts +25 -4
- package/dist/dial-relay.js +129 -1
- package/dist/env-switch.d.ts +1 -3
- package/dist/env-switch.js +1 -3
- package/dist/fal-price.d.ts +1 -3
- package/dist/fal-price.js +77 -26
- package/dist/learn/ledger.d.ts +170 -0
- package/dist/learn/ledger.js +218 -0
- package/dist/learn/promote.d.ts +3 -3
- package/dist/learn/promote.js +1 -1
- package/dist/learning-cost.d.ts +22 -20
- package/dist/learning-cost.js +15 -21
- package/dist/live-reach.d.ts +2 -0
- package/dist/live-reach.js +2 -0
- package/dist/mcp-api-only-origins.d.ts +8 -3
- package/dist/mcp-api-only-origins.js +17 -17
- package/dist/micro.d.ts +2 -0
- package/dist/micro.js +2 -0
- package/dist/model.d.ts +5 -4
- package/dist/model.js +7 -6
- package/dist/monid.d.ts +14 -1
- package/dist/monid.js +103 -26
- package/dist/openapi.js +34 -12
- package/dist/place-offers.d.ts +4 -0
- package/dist/place-offers.js +7 -4
- package/dist/provider.d.ts +2 -2
- package/dist/provider.js +9 -5
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-view.d.ts +1 -2
- package/dist/run-view.js +2 -1
- package/dist/runner/adapter-loop.js +3 -16
- package/dist/runner/adapter-run-spec.d.ts +20 -13
- package/dist/runner/adapter-run-spec.js +57 -48
- package/dist/runner/beside.d.ts +9 -2
- package/dist/runner/beside.js +24 -7
- package/dist/runner/claim-secrets.d.ts +17 -15
- package/dist/runner/claim-secrets.js +32 -34
- package/dist/runner/cli-run-spec.js +21 -9
- package/dist/runner/held.d.ts +16 -4
- package/dist/runner/main.d.ts +11 -6
- package/dist/runner/main.js +12 -7
- package/dist/runner/mcp-claim.js +3 -2
- package/dist/runner/mcp-run.d.ts +3 -6
- package/dist/runner/mcp-run.js +3 -4
- package/dist/runner/presence.d.ts +11 -1
- package/dist/runner/presence.js +7 -0
- package/dist/runner/reflect-hook.js +1 -1
- package/dist/runner/run-child-host.d.ts +19 -8
- package/dist/runner/run-child-host.js +80 -34
- package/dist/runner/runner.d.ts +3 -0
- package/dist/runner/runner.js +1 -1
- package/dist/runner/save-slots.js +2 -1
- package/dist/runner/subagent.d.ts +11 -0
- package/dist/runner/subagent.js +17 -3
- package/dist/runner/workflow-first.d.ts +27 -14
- package/dist/runner/workflow-first.js +29 -22
- package/dist/runner/workflow-spec.js +1 -1
- package/dist/server.d.ts +18 -7
- package/dist/server.js +150 -64
- package/dist/slots.d.ts +9 -0
- package/dist/slots.js +45 -0
- package/dist/store/postgres/migrations/0028_learning_ledger.sql +44 -0
- package/dist/store/schema.d.ts +17 -0
- package/dist/store/schema.js +47 -1
- package/dist/store/sqlite/run-patch.d.ts +11 -1
- package/dist/store/sqlite/run-patch.js +29 -1
- package/dist/store/sqlite/store.js +72 -9
- package/dist/store/store.d.ts +14 -0
- package/dist/store-reads/learning.d.ts +81 -124
- package/dist/store-reads/learning.js +207 -286
- package/dist/template-eval.d.ts +19 -0
- package/dist/template-eval.js +92 -43
- package/dist/template-import.d.ts +0 -10
- package/dist/template-import.js +5 -10
- package/dist/timeline/web-calls.d.ts +12 -14
- package/dist/timeline/web-calls.js +14 -30
- package/dist/web-save.d.ts +4 -9
- package/dist/web-save.js +4 -43
- package/dist/workspace/attached-computers.d.ts +32 -9
- package/dist/workspace/attached-computers.js +77 -13
- package/dist/workspace/computer-deps.d.ts +6 -1
- package/dist/workspace/computer-deps.js +1 -1
- package/dist/workspace/computer-for-claim.js +6 -3
- package/dist/workspace/paired-route.d.ts +91 -0
- package/dist/workspace/paired-route.js +153 -0
- package/dist/wrapped.d.ts +8 -2
- package/dist/wrapped.js +21 -6
- package/package.json +12 -12
- package/templates/README.md +3 -3
- package/dist/console/assets/index-okP-y8PK.js +0 -747
package/dist/console/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="color-scheme" content="light dark" />
|
|
7
7
|
<title>AgentRun</title>
|
|
8
8
|
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' fill='%23ff8000'/%3E%3Cpath d='M12 9l11 7-11 7z' fill='%23000'/%3E%3C/svg%3E" />
|
|
9
|
-
<script type="module" crossorigin src="./assets/index-
|
|
9
|
+
<script type="module" crossorigin src="./assets/index-DPh29cyz.js"></script>
|
|
10
10
|
<link rel="stylesheet" crossorigin href="./assets/index-Bwn1oTem.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
package/dist/dial-relay.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { type HostedDial } from "@parcha/agentrun-computer";
|
|
1
|
+
import { AttachHub, type HostedDial } from "@parcha/agentrun-computer";
|
|
2
2
|
import { type AttachTiming } from "./computer-attach.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type Presence } from "./runner/presence.js";
|
|
4
4
|
import type { Store } from "./store/index.js";
|
|
5
|
-
|
|
5
|
+
import { type PairedRelay } from "./workspace/attached-computers.js";
|
|
6
|
+
/** A runner's relay: its HostedDial for its providers, the paired computers' bring and let-go, where its listener
|
|
7
|
+
* answers, and its close. */
|
|
6
8
|
export interface RunnerRelay {
|
|
7
9
|
readonly dial: HostedDial;
|
|
10
|
+
readonly paired: PairedRelay;
|
|
8
11
|
readonly incarnation: string;
|
|
9
12
|
readonly host: string;
|
|
10
13
|
readonly port: number;
|
|
@@ -12,7 +15,7 @@ export interface RunnerRelay {
|
|
|
12
15
|
close(): Promise<void>;
|
|
13
16
|
}
|
|
14
17
|
export interface RunnerRelayOptions {
|
|
15
|
-
readonly store: Pick<Store, "mintedTokens" | "pairedComputers">;
|
|
18
|
+
readonly store: Pick<Store, "mintedTokens" | "pairedComputers" | "settings" | "runners" | "runs">;
|
|
16
19
|
readonly sealKey: Buffer;
|
|
17
20
|
/** The runner's name, as its claims and its row carry it. */
|
|
18
21
|
readonly runner: string;
|
|
@@ -29,5 +32,23 @@ export interface RunnerRelayOptions {
|
|
|
29
32
|
}
|
|
30
33
|
/** The server's public address as this runner's environment names it (cli.ts reads the same two), or undefined. */
|
|
31
34
|
export declare function publicUrlOf(env: NodeJS.ProcessEnv): string | undefined;
|
|
35
|
+
/** What pairedRelayOn needs: the store's routes, runners and runs; the hub the box is brought to; the runner (and its
|
|
36
|
+
* incarnation) the routes name; where a route it could not drop is said; the clock. */
|
|
37
|
+
export interface PairedRelayOnOptions {
|
|
38
|
+
readonly store: Pick<Store, "settings" | "runners" | "runs">;
|
|
39
|
+
readonly hub: AttachHub;
|
|
40
|
+
readonly runner: string;
|
|
41
|
+
readonly incarnation: string;
|
|
42
|
+
readonly log?: (line: string) => void;
|
|
43
|
+
readonly now?: () => number;
|
|
44
|
+
}
|
|
45
|
+
/** The paired computers' bring and let-go over `hub` for runner `runner` of incarnation `incarnation`: a runner apart's
|
|
46
|
+
* own hub (startRunnerRelay), or the server's for the runner beside it in its process (runner/beside.ts). `left` is
|
|
47
|
+
* told when a box's socket leaves the hub; `stop` ends the sweep of the routes it brought. */
|
|
48
|
+
export declare function pairedRelayOn(options: PairedRelayOnOptions): {
|
|
49
|
+
readonly paired: PairedRelay;
|
|
50
|
+
left(id: string): Promise<void>;
|
|
51
|
+
stop(): void;
|
|
52
|
+
};
|
|
32
53
|
/** The runner's relay, started: undefined where its environment names no public address of the server's. */
|
|
33
54
|
export declare function startRunnerRelay(options: RunnerRelayOptions): Promise<RunnerRelay | undefined>;
|
package/dist/dial-relay.js
CHANGED
|
@@ -16,17 +16,136 @@
|
|
|
16
16
|
//
|
|
17
17
|
// A runner with no public address keeps no relay: its dial providers still refuse (hosted/provider.ts), and the server's
|
|
18
18
|
// Settings → Computers still says so (computers.ts runs_refused).
|
|
19
|
+
//
|
|
20
|
+
// A paired computer reaches a run on this runner the same way (`paired`): the run's claim routes the box here
|
|
21
|
+
// (workspace/paired-route.ts takeRoute, under the run's claim) and waits until the server has moved its socket onto this
|
|
22
|
+
// hub (bring), and the run's release lets it go (letGo) once its hold ended, every remove or KILL it sent answered. The
|
|
23
|
+
// listener takes a paired computer's token only while its route names this runner and incarnation. A route this runner
|
|
24
|
+
// brought whose hold ended (released, or at its deadline) with no bring in flight is dropped at the next sweep
|
|
25
|
+
// (PRESENCE_RENEW_MS); and when the box's socket leaves this hub for a route that names another runner (the run resumed
|
|
26
|
+
// there), this runner's hold of it ends.
|
|
27
|
+
//
|
|
28
|
+
// The runner beside a server, in its process, brings and lets go of a paired box the same way (pairedRelayOn over the
|
|
29
|
+
// server's own hub, runner/beside.ts): its run's claim takes the box's route under that runner's name and incarnation,
|
|
30
|
+
// so a runner apart's take for another run is refused while the hold lasts, and the server's tick, which knows that
|
|
31
|
+
// runner (Serve.beside), keeps the box in its own hub.
|
|
19
32
|
import { createServer } from "node:http";
|
|
33
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
20
34
|
import { ATTACH_PATH, AttachHub } from "@parcha/agentrun-computer";
|
|
21
35
|
import { bearerOf, createAttachRoutes, sha256Hex } from "./computer-attach.js";
|
|
22
36
|
import { LOOPBACK, relayKeyOf, relayProofs, runnerLiveOf } from "./live-reach.js";
|
|
23
37
|
import { logLine } from "./print.js";
|
|
38
|
+
import { PRESENCE_RENEW_MS } from "./runner/presence.js";
|
|
39
|
+
import { PAIRED_ID_PREFIX } from "./workspace/attached-computers.js";
|
|
40
|
+
import { dropRoute, lateWords, PAIRED_BRING_MS, PAIRED_BRING_POLL_MS, readRoute, takeRoute } from "./workspace/paired-route.js";
|
|
41
|
+
/** A claim's failure to have its paired computer here, in words: the claim fails computer_unavailable with them. */
|
|
42
|
+
const unavailable = (words) => Object.assign(new Error(words), { code: "computer_unavailable" });
|
|
43
|
+
/** A bring whose claim was cancelled (its create's signal aborted) before the box reached runner `runner`. */
|
|
44
|
+
const cancelledWords = (name, runner) => `${name} was not brought to runner ${runner}: this run's claim was cancelled while it waited for the box, and its route was let go`;
|
|
24
45
|
/** The server's public address as this runner's environment names it (cli.ts reads the same two), or undefined. */
|
|
25
46
|
export function publicUrlOf(env) {
|
|
26
47
|
const given = env.AGENTRUN_PUBLIC_URL || env.RENDER_EXTERNAL_URL;
|
|
27
48
|
const parsed = given && URL.canParse(given) ? new URL(given) : undefined;
|
|
28
49
|
return parsed && /^https?:$/.test(parsed.protocol) ? parsed.href.replace(/\/+$/, "") : undefined;
|
|
29
50
|
}
|
|
51
|
+
/** The paired computers' bring and let-go over `hub` for runner `runner` of incarnation `incarnation`: a runner apart's
|
|
52
|
+
* own hub (startRunnerRelay), or the server's for the runner beside it in its process (runner/beside.ts). `left` is
|
|
53
|
+
* told when a box's socket leaves the hub; `stop` ends the sweep of the routes it brought. */
|
|
54
|
+
export function pairedRelayOn(options) {
|
|
55
|
+
const { store, hub, runner, incarnation, now = Date.now } = options;
|
|
56
|
+
const log = options.log ?? (() => { });
|
|
57
|
+
const mine = { runner, incarnation };
|
|
58
|
+
/** The routes this process brought, by computer: the run, when it was taken, and whether a hold was seen on it. */
|
|
59
|
+
const held = new Map();
|
|
60
|
+
/** The bring in flight per computer, by its run. */
|
|
61
|
+
const bringing = new Map();
|
|
62
|
+
/** When the box's socket leaves this hub: a route that now names another runner (or another process of this one)
|
|
63
|
+
* ends this runner's hold of it (the run resumed there); a route still here keeps it, for the box's redial. */
|
|
64
|
+
const left = async (id) => {
|
|
65
|
+
const route = await readRoute(store.settings, id);
|
|
66
|
+
if (route.runner === runner && route.incarnation === incarnation)
|
|
67
|
+
return;
|
|
68
|
+
const hold = hub.hold(id);
|
|
69
|
+
if (hold !== undefined)
|
|
70
|
+
await hub.unclaim(id, hold);
|
|
71
|
+
held.delete(id);
|
|
72
|
+
};
|
|
73
|
+
const paired = {
|
|
74
|
+
hub,
|
|
75
|
+
async bring(row, { run, until, claim, signal }) {
|
|
76
|
+
// A claim cancelled before its bring takes nothing.
|
|
77
|
+
if (signal?.aborted)
|
|
78
|
+
throw unavailable(cancelledWords(row.name, runner));
|
|
79
|
+
bringing.set(row.id, run);
|
|
80
|
+
try {
|
|
81
|
+
const took = await takeRoute({ settings: store.settings, runners: store.runners, runs: store.runs }, row.id, { ...mine, run, until }, { ...(claim ? { claim } : {}), name: row.name });
|
|
82
|
+
if (!took.taken)
|
|
83
|
+
throw unavailable(took.why);
|
|
84
|
+
held.set(row.id, { run, since: now(), seenHold: false });
|
|
85
|
+
const end = now() + PAIRED_BRING_MS;
|
|
86
|
+
for (;;) {
|
|
87
|
+
// The claim was cancelled while it waited: its route goes (the row removed while it is still this run's), and
|
|
88
|
+
// the claim fails in words at once, never waiting out PAIRED_BRING_MS.
|
|
89
|
+
if (signal?.aborted) {
|
|
90
|
+
await dropRoute(store.settings, row.id, { ...mine, run }).catch(() => undefined);
|
|
91
|
+
held.delete(row.id);
|
|
92
|
+
throw unavailable(cancelledWords(row.name, runner));
|
|
93
|
+
}
|
|
94
|
+
if (hub.online(row.id))
|
|
95
|
+
return;
|
|
96
|
+
const route = await readRoute(store.settings, row.id);
|
|
97
|
+
const ours = route.runner === runner && route.incarnation === incarnation && route.run === run;
|
|
98
|
+
// The server noted why the box can't come (not attached now, its relay refused), or the time is up: the route
|
|
99
|
+
// goes, its words kept on the row, and the claim fails in them. Never a hang.
|
|
100
|
+
const why = !ours ? (route.refused ?? `${row.name}'s route went to another run while this run waited for it: its next claim tries again`) : (route.refused ?? (now() >= end ? lateWords(row.name, runner) : undefined));
|
|
101
|
+
if (why !== undefined) {
|
|
102
|
+
if (ours)
|
|
103
|
+
await dropRoute(store.settings, row.id, { ...mine, run }, why).catch(() => undefined);
|
|
104
|
+
held.delete(row.id);
|
|
105
|
+
throw unavailable(why);
|
|
106
|
+
}
|
|
107
|
+
// A cancel wakes the wait at once; the loop's top answers it.
|
|
108
|
+
await sleep(PAIRED_BRING_POLL_MS, undefined, signal ? { signal } : undefined).catch(() => undefined);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
if (bringing.get(row.id) === run)
|
|
113
|
+
bringing.delete(row.id);
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
async letGo(computer, hold, run) {
|
|
117
|
+
// Its hold ends first: unclaim waits for every remove or KILL it sent. A route stays while a hold is left here, or
|
|
118
|
+
// while another run's bring is in flight here.
|
|
119
|
+
if (hold !== undefined)
|
|
120
|
+
await hub.unclaim(computer, hold);
|
|
121
|
+
if (hub.hold(computer) !== undefined)
|
|
122
|
+
return;
|
|
123
|
+
const bring = bringing.get(computer);
|
|
124
|
+
if (bring !== undefined && bring !== run)
|
|
125
|
+
return;
|
|
126
|
+
held.delete(computer);
|
|
127
|
+
await dropRoute(store.settings, computer, { ...mine, ...(run !== undefined ? { run } : {}) });
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
// The sweep of the routes this process brought: one whose hold ended (released, or at its deadline), or that no hold
|
|
131
|
+
// took within PAIRED_BRING_MS, with no bring in flight, goes.
|
|
132
|
+
const sweep = setInterval(() => {
|
|
133
|
+
for (const [id, at] of held) {
|
|
134
|
+
if (bringing.has(id))
|
|
135
|
+
continue;
|
|
136
|
+
if (hub.hold(id) !== undefined) {
|
|
137
|
+
at.seenHold = true;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (!at.seenHold && now() - at.since < PAIRED_BRING_MS)
|
|
141
|
+
continue;
|
|
142
|
+
held.delete(id);
|
|
143
|
+
void dropRoute(store.settings, id, { ...mine, run: at.run }).catch((error) => log(logLine("computer_route_undropped", { computer: id, run: at.run, error: error instanceof Error ? error.message : String(error) })));
|
|
144
|
+
}
|
|
145
|
+
}, PRESENCE_RENEW_MS);
|
|
146
|
+
sweep.unref();
|
|
147
|
+
return { paired, left, stop: () => clearInterval(sweep) };
|
|
148
|
+
}
|
|
30
149
|
/** The runner's relay, started: undefined where its environment names no public address of the server's. */
|
|
31
150
|
export async function startRunnerRelay(options) {
|
|
32
151
|
const url = publicUrlOf(options.env);
|
|
@@ -38,9 +157,16 @@ export async function startRunnerRelay(options) {
|
|
|
38
157
|
const live = runnerLiveOf(options.env, options.sealKey);
|
|
39
158
|
const host = live?.host ?? LOOPBACK;
|
|
40
159
|
const hub = new AttachHub();
|
|
160
|
+
const mine = { runner, incarnation };
|
|
161
|
+
const relayed = pairedRelayOn({ store, hub, runner, incarnation, log, now });
|
|
162
|
+
const { paired } = relayed;
|
|
41
163
|
const routes = createAttachRoutes({
|
|
42
|
-
store, hub,
|
|
164
|
+
store, hub, owner: mine, now,
|
|
43
165
|
log: (event, fields) => log(logLine(event, fields)),
|
|
166
|
+
onSocket: (computer, ws) => {
|
|
167
|
+
if (computer.startsWith(PAIRED_ID_PREFIX))
|
|
168
|
+
ws.once("close", () => void relayed.left(computer).catch(() => undefined));
|
|
169
|
+
},
|
|
44
170
|
...(options.timing ? { timing: options.timing } : {}),
|
|
45
171
|
});
|
|
46
172
|
const proven = relayProofs(relayKeyOf(options.sealKey), now);
|
|
@@ -65,6 +191,7 @@ export async function startRunnerRelay(options) {
|
|
|
65
191
|
});
|
|
66
192
|
const port = server.address().port;
|
|
67
193
|
const shut = async () => {
|
|
194
|
+
relayed.stop();
|
|
68
195
|
await routes.close();
|
|
69
196
|
server.closeAllConnections();
|
|
70
197
|
await new Promise((resolve) => server.close(() => resolve()));
|
|
@@ -80,6 +207,7 @@ export async function startRunnerRelay(options) {
|
|
|
80
207
|
let closing;
|
|
81
208
|
return {
|
|
82
209
|
dial: { url, tokens: routes.machineTokens, hub },
|
|
210
|
+
paired,
|
|
83
211
|
incarnation,
|
|
84
212
|
host,
|
|
85
213
|
port,
|
package/dist/env-switch.d.ts
CHANGED
|
@@ -11,9 +11,7 @@ declare const MEANS: {
|
|
|
11
11
|
* in words that say what each means (a TypeError), so a typo never leaves the console open on a server meant to be
|
|
12
12
|
* API-only. */
|
|
13
13
|
export declare function switchFrom(name: keyof typeof MEANS, env?: NodeJS.ProcessEnv): boolean;
|
|
14
|
-
/** The
|
|
15
|
-
* per_run MCP server at through the generic save. A plain setting, not a secret. Unset or blank, that save is refused
|
|
16
|
-
* as any route outside api-only.ts API_ONLY_ROUTES. AGENTRUN_MCP_ALLOW_LOOPBACK still decides whether a loopback origin is saved. */
|
|
14
|
+
/** The MCP origins an API-only server's token may save a per_run MCP server at: the serve README's API-only section. */
|
|
17
15
|
export declare const API_ONLY_MCP_ORIGINS_ENV = "AGENTRUN_API_ONLY_MCP_ORIGINS";
|
|
18
16
|
/** The origins `value` (API_ONLY_MCP_ORIGINS_ENV) names, each once, in its order: none when unset or blank. An entry
|
|
19
17
|
* that is not an http or https origin alone (a path, query, fragment, user or password, or no URL at all) is refused
|
package/dist/env-switch.js
CHANGED
|
@@ -21,9 +21,7 @@ export function switchFrom(name, env = process.env) {
|
|
|
21
21
|
const [on, off] = MEANS[name];
|
|
22
22
|
throw new TypeError(`${name} is 1 (${on}) or 0${off === undefined ? "" : ` (${off})`}, not ${JSON.stringify(env[name])}`);
|
|
23
23
|
}
|
|
24
|
-
/** The
|
|
25
|
-
* per_run MCP server at through the generic save. A plain setting, not a secret. Unset or blank, that save is refused
|
|
26
|
-
* as any route outside api-only.ts API_ONLY_ROUTES. AGENTRUN_MCP_ALLOW_LOOPBACK still decides whether a loopback origin is saved. */
|
|
24
|
+
/** The MCP origins an API-only server's token may save a per_run MCP server at: the serve README's API-only section. */
|
|
27
25
|
export const API_ONLY_MCP_ORIGINS_ENV = "AGENTRUN_API_ONLY_MCP_ORIGINS";
|
|
28
26
|
/** The origins `value` (API_ONLY_MCP_ORIGINS_ENV) names, each once, in its order: none when unset or blank. An entry
|
|
29
27
|
* that is not an http or https origin alone (a path, query, fragment, user or password, or no URL at all) is refused
|
package/dist/fal-price.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export declare function decidedRates(): {
|
|
|
56
56
|
};
|
|
57
57
|
/** The rate a job of `endpoint` is billed at, against get_pricing's (in `unit`): `ratio`, its tier's rate over the rate
|
|
58
58
|
* get_pricing states (RATE_TIERS), `perUnitUsd` a charge added to each unit's price, and `words` the settings they came from (none at
|
|
59
|
-
* get_pricing's own rate); or `unknown`, why it can't be known. 1 and nothing for an endpoint with one rate; unknown for
|
|
59
|
+
* get_pricing's own rate); or `unknown`, why it can't be known (get_pricing stating it in another unit than its tiers' among them). 1 and nothing for an endpoint with one rate; unknown for
|
|
60
60
|
* an endpoint in a family fal bills by its settings whose rate is not decided here (TIERED_FAMILIES). */
|
|
61
61
|
export declare function rateOf(endpoint: string, unit: string, input: unknown): {
|
|
62
62
|
ratio: number;
|
|
@@ -87,8 +87,6 @@ export type MediaReader = (url: string, signal: AbortSignal, read?: MediaRead) =
|
|
|
87
87
|
/** A MediaReader over the public-host guard web_fetch and web_save download through (`guard`: their fetch options),
|
|
88
88
|
* within web_save's size cap and download slots. */
|
|
89
89
|
export declare const publicMedia: (guard: () => Promise<Omit<PublicFetchOptions, "maxBytes" | "signal" | "httpsOnly" | "maxRedirects">>, slots?: SaveSlots) => MediaReader;
|
|
90
|
-
/** The longest submission_key an agent can send fal in a run: fal's KEY_MAX less the run's KEY_TAIL. */
|
|
91
|
-
export declare const KEY_ROOM: number;
|
|
92
90
|
/** The submission keys of one run on fal's hosted server (McpMeter.keys). fal's journal is per account, so the same key
|
|
93
91
|
* from two runs (a model makes the same key for the same task) would bind the second run's request to the first's and be
|
|
94
92
|
* refused. Each key leaves as the agent's key and `.<16 hex of the run>`: the same run's key leaves the same each time,
|
package/dist/fal-price.js
CHANGED
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
import { createHash } from "node:crypto";
|
|
16
16
|
import { mediaSeconds, voiceSeconds } from "./media-duration.js";
|
|
17
17
|
import { SAVE_MAX_BYTES, SERVER_SLOTS } from "./web-save.js";
|
|
18
|
-
|
|
19
|
-
const usd = (dollars) => Math.round(dollars * 1e6) / 1e6;
|
|
18
|
+
import { micro } from "./micro.js";
|
|
20
19
|
/** The host of fal's hosted MCP server (its key endpoint /mcp and its sign-in endpoint /mcp-relay). */
|
|
21
20
|
export const FAL_MCP_HOST = "mcp.fal.ai";
|
|
22
21
|
/** A pin's `meter` for a fal server. */
|
|
@@ -144,8 +143,9 @@ function settingOf(input, field, named, fallback) {
|
|
|
144
143
|
return { value, words: `${field} ${JSON.stringify(value)}${given === undefined ? ", its default" : ""}` };
|
|
145
144
|
}
|
|
146
145
|
/** A rate set by one setting: `rates` by value. */
|
|
147
|
-
const byOne = (field, base, rates, fallback) => ({
|
|
146
|
+
const byOne = (unit, field, base, rates, fallback) => ({
|
|
148
147
|
base,
|
|
148
|
+
unit,
|
|
149
149
|
rate: (input) => {
|
|
150
150
|
const setting = settingOf(input, field, [...rates.keys()], fallback);
|
|
151
151
|
return "why" in setting ? setting : { rate: rates.get(setting.value), words: setting.words };
|
|
@@ -157,6 +157,7 @@ const audio = (off, on) => ({ off, on });
|
|
|
157
157
|
* audio (on by default). */
|
|
158
158
|
const veo = (base, rates) => ({
|
|
159
159
|
base,
|
|
160
|
+
unit: "seconds",
|
|
160
161
|
rate: (input) => {
|
|
161
162
|
const sound = settingOf(input, "generate_audio", [true, false], true);
|
|
162
163
|
if ("why" in sound)
|
|
@@ -176,6 +177,7 @@ const VEO31_LITE = veo(0.05, { "720p": audio(0.03, 0.05), "1080p": audio(0.05, 0
|
|
|
176
177
|
* no rate for voice control. */
|
|
177
178
|
const kling = (base, page, floor = 0) => ({
|
|
178
179
|
base,
|
|
180
|
+
unit: "seconds",
|
|
179
181
|
rate: (input) => {
|
|
180
182
|
const sound = settingOf(input, "generate_audio", [true, false], true);
|
|
181
183
|
if ("why" in sound)
|
|
@@ -195,17 +197,17 @@ const kling = (base, page, floor = 0) => ({
|
|
|
195
197
|
return { rate: held(sound.value ? page.on : page.off), words: sound.words };
|
|
196
198
|
},
|
|
197
199
|
});
|
|
198
|
-
const IDEOGRAM_V3 = byOne("rendering_speed", 0.03, new Map([["TURBO", 0.03], ["BALANCED", 0.06], ["QUALITY", 0.09]]), "BALANCED");
|
|
200
|
+
const IDEOGRAM_V3 = byOne("images", "rendering_speed", 0.03, new Map([["TURBO", 0.03], ["BALANCED", 0.06], ["QUALITY", 0.09]]), "BALANCED");
|
|
199
201
|
/** A web search's charge, per unit: $0.015 when enable_web_search is true (its default is false). */
|
|
200
202
|
const webSearch = (input) => {
|
|
201
203
|
const search = settingOf(input, "enable_web_search", [true, false], false);
|
|
202
204
|
return "why" in search ? search : search.value ? { usd: 0.015, words: "a web search" } : undefined;
|
|
203
205
|
};
|
|
204
|
-
const NANO_BANANA_PRO = { ...byOne("resolution", 0.15, new Map([["1K", 0.15], ["2K", 0.15], ["4K", 0.3]]), "1K"), perUnitUsd: webSearch };
|
|
206
|
+
const NANO_BANANA_PRO = { ...byOne("images", "resolution", 0.15, new Map([["1K", 0.15], ["2K", 0.15], ["4K", 0.3]]), "1K"), perUnitUsd: webSearch };
|
|
205
207
|
/** Nano Banana 2: by its resolution, plus a web search's charge and high thinking's ($0.002, thinking_level "high"; none
|
|
206
208
|
* for "minimal" or none, its default), each per unit. */
|
|
207
209
|
const NANO_BANANA_2 = {
|
|
208
|
-
...byOne("resolution", 0.08, new Map([["0.5K", 0.06], ["1K", 0.08], ["2K", 0.12], ["4K", 0.16]]), "1K"),
|
|
210
|
+
...byOne("images", "resolution", 0.08, new Map([["0.5K", 0.06], ["1K", 0.08], ["2K", 0.12], ["4K", 0.16]]), "1K"),
|
|
209
211
|
perUnitUsd: (input) => {
|
|
210
212
|
const search = webSearch(input);
|
|
211
213
|
if (search && "why" in search)
|
|
@@ -214,15 +216,15 @@ const NANO_BANANA_2 = {
|
|
|
214
216
|
if ("why" in thinking)
|
|
215
217
|
return thinking;
|
|
216
218
|
const added = [...(search ? [search] : []), ...(thinking.value === "high" ? [{ usd: 0.002, words: "high thinking" }] : [])];
|
|
217
|
-
return added.length ? { usd:
|
|
219
|
+
return added.length ? { usd: micro(added.reduce((sum, one) => sum + one.usd, 0)), words: added.map((one) => one.words).join(" and ") } : undefined;
|
|
218
220
|
},
|
|
219
221
|
};
|
|
220
222
|
const KLING_PRO = kling(0.14, { off: 0.112, on: 0.168, voice: 0.196 }, 0.14);
|
|
221
223
|
const KLING_STANDARD = kling(0.14, { off: 0.084, on: 0.126, voice: 0.154 }, 0.14);
|
|
222
|
-
const FABRIC = byOne("resolution", 0.08, new Map([["480p", 0.08], ["720p", 0.15]]));
|
|
224
|
+
const FABRIC = byOne("seconds", "resolution", 0.08, new Map([["480p", 0.08], ["720p", 0.15]]));
|
|
223
225
|
const RATE_TIERS = new Map([
|
|
224
226
|
...["", "/edit", "/remix", "/reframe", "/replace-background", "/generate-transparent"].map((variant) => [`fal-ai/ideogram/v3${variant}`, IDEOGRAM_V3]),
|
|
225
|
-
...["", "/edit", "/remix"].map((variant) => [`fal-ai/ideogram/character${variant}`, byOne("rendering_speed", 0.05, new Map([["TURBO", 0.1], ["BALANCED", 0.15], ["QUALITY", 0.2]]), "BALANCED")]),
|
|
227
|
+
...["", "/edit", "/remix"].map((variant) => [`fal-ai/ideogram/character${variant}`, byOne("images", "rendering_speed", 0.05, new Map([["TURBO", 0.1], ["BALANCED", 0.15], ["QUALITY", 0.2]]), "BALANCED")]),
|
|
226
228
|
...["", "/image-to-video", "/first-last-frame-to-video", "/reference-to-video"].map((variant) => [`fal-ai/veo3.1${variant}`, VEO31]),
|
|
227
229
|
["fal-ai/veo3.1/extend-video", veo(0.4, { "720p": audio(0.2, 0.4) })],
|
|
228
230
|
...["/fast", "/fast/image-to-video", "/fast/first-last-frame-to-video", "/fast/reference-to-video"].map((variant) => [`fal-ai/veo3.1${variant}`, VEO31_FAST]),
|
|
@@ -235,7 +237,7 @@ const RATE_TIERS = new Map([
|
|
|
235
237
|
["fal-ai/kling-video/v3/standard/image-to-video", KLING_STANDARD],
|
|
236
238
|
["fal-ai/kling-video/v3/standard/text-to-video", KLING_STANDARD],
|
|
237
239
|
["fal-ai/kling-video/v3/4k/image-to-video", kling(0.42, { off: 0.42, on: 0.42 })],
|
|
238
|
-
["fal-ai/sync-lipsync/v2", byOne("model", 3, new Map([["lipsync-2", 3], ["lipsync-2-pro", 5]]), "lipsync-2")],
|
|
240
|
+
["fal-ai/sync-lipsync/v2", byOne("minutes", "model", 3, new Map([["lipsync-2", 3], ["lipsync-2-pro", 5]]), "lipsync-2")],
|
|
239
241
|
["fal-ai/nano-banana-pro", NANO_BANANA_PRO],
|
|
240
242
|
["fal-ai/nano-banana-pro/edit", NANO_BANANA_PRO],
|
|
241
243
|
["fal-ai/gemini-3-pro-image-preview", NANO_BANANA_PRO],
|
|
@@ -243,7 +245,7 @@ const RATE_TIERS = new Map([
|
|
|
243
245
|
...["fal-ai/nano-banana-2", "fal-ai/nano-banana-2/edit", "fal-ai/gemini-3.1-flash-image-preview", "fal-ai/gemini-3.1-flash-image-preview/edit"].map((endpoint) => [endpoint, NANO_BANANA_2]),
|
|
244
246
|
["veed/fabric-1.0", FABRIC],
|
|
245
247
|
["veed/fabric-1.0/text", FABRIC],
|
|
246
|
-
["veed/fabric-1.0/fast", byOne("resolution", 0.1, new Map([["480p", 0.1], ["720p", 0.2]]))],
|
|
248
|
+
["veed/fabric-1.0/fast", byOne("seconds", "resolution", 0.1, new Map([["480p", 0.1], ["720p", 0.2]]))],
|
|
247
249
|
]);
|
|
248
250
|
/** The families fal bills by their settings: an endpoint is in one when it is the family's id or under it. Ideogram v4's
|
|
249
251
|
* pages (read 2026-11-23 13:13Z) bill by rendering_speed and megapixels, and get_pricing (13:20:43Z) states most of
|
|
@@ -274,7 +276,7 @@ export function decidedRates() {
|
|
|
274
276
|
}
|
|
275
277
|
/** The rate a job of `endpoint` is billed at, against get_pricing's (in `unit`): `ratio`, its tier's rate over the rate
|
|
276
278
|
* get_pricing states (RATE_TIERS), `perUnitUsd` a charge added to each unit's price, and `words` the settings they came from (none at
|
|
277
|
-
* get_pricing's own rate); or `unknown`, why it can't be known. 1 and nothing for an endpoint with one rate; unknown for
|
|
279
|
+
* get_pricing's own rate); or `unknown`, why it can't be known (get_pricing stating it in another unit than its tiers' among them). 1 and nothing for an endpoint with one rate; unknown for
|
|
278
280
|
* an endpoint in a family fal bills by its settings whose rate is not decided here (TIERED_FAMILIES). */
|
|
279
281
|
export function rateOf(endpoint, unit, input) {
|
|
280
282
|
const tiers = RATE_TIERS.get(endpoint);
|
|
@@ -285,6 +287,9 @@ export function rateOf(endpoint, unit, input) {
|
|
|
285
287
|
return { unknown: `fal bills ${family} by its settings and ${endpoint} has no rate decided here` };
|
|
286
288
|
return { ratio: 1, perUnitUsd: 0, words: [] };
|
|
287
289
|
}
|
|
290
|
+
// The ratios and the model page's rates hold only in the unit they were decided in: per second, minute or image.
|
|
291
|
+
if (unit !== tiers.unit)
|
|
292
|
+
return { unknown: `get_pricing states ${endpoint} per ${oneOf(unit)}, and its rates were decided per ${oneOf(tiers.unit)}` };
|
|
288
293
|
if (!isObject(input))
|
|
289
294
|
return { ratio: 1, perUnitUsd: 0, words: [] };
|
|
290
295
|
const bills = `fal bills ${endpoint} per ${oneOf(unit)} at a rate`;
|
|
@@ -411,7 +416,7 @@ function bodyOf(result) {
|
|
|
411
416
|
return undefined;
|
|
412
417
|
}
|
|
413
418
|
}
|
|
414
|
-
const shown = (n) => String(
|
|
419
|
+
const shown = (n) => String(micro(n));
|
|
415
420
|
/** A MediaReader over the public-host guard web_fetch and web_save download through (`guard`: their fetch options),
|
|
416
421
|
* within web_save's size cap and download slots. */
|
|
417
422
|
export const publicMedia = (guard, slots = SERVER_SLOTS) => async (url, signal, read = {}) => {
|
|
@@ -456,7 +461,7 @@ function chargeOfJob(quote, item) {
|
|
|
456
461
|
const after = item.status === "completed" ? unitsAfter(quote.unit, item.result) : undefined;
|
|
457
462
|
if (after === undefined)
|
|
458
463
|
return quote.holdUsd;
|
|
459
|
-
return
|
|
464
|
+
return micro(quote.unitPrice * (quote.step ? roundedUp(after, quote.unit, quote.step) : after));
|
|
460
465
|
}
|
|
461
466
|
/** `units` of `unit` (seconds or minutes) rounded up to a whole `step` of seconds, in `unit`. Rounded to the
|
|
462
467
|
* microsecond first, so a length a float sum or a conversion leaves a hair over a whole step (125 frames of 0.024 s)
|
|
@@ -473,7 +478,7 @@ const hex16 = (text) => createHash("sha256").update(text).digest("hex").slice(0,
|
|
|
473
478
|
/** What a run adds to each key: `.` and 16 hex. */
|
|
474
479
|
const KEY_TAIL = 17;
|
|
475
480
|
/** The longest submission_key an agent can send fal in a run: fal's KEY_MAX less the run's KEY_TAIL. */
|
|
476
|
-
|
|
481
|
+
const KEY_ROOM = KEY_MAX - KEY_TAIL;
|
|
477
482
|
/** The submission keys of a call of fal's `tool`: its own, and for submit_jobs each request's. */
|
|
478
483
|
const keysOf = (tool, args) => [args.submission_key, ...(tool === "submit_jobs" && Array.isArray(args.requests) ? args.requests.map((one) => (isObject(one) ? one.submission_key : undefined)) : [])];
|
|
479
484
|
/** The submission keys of one run on fal's hosted server (McpMeter.keys). fal's journal is per account, so the same key
|
|
@@ -509,12 +514,15 @@ export function falKeys(run) {
|
|
|
509
514
|
* `media` reads an input media file (none: such a job is unpriceable); `now`, the clock. */
|
|
510
515
|
export function falMeter({ media, now = Date.now } = {}) {
|
|
511
516
|
const prices = new Map();
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
const answer = await ask("get_pricing", { endpoint_id: endpoint });
|
|
517
|
+
/** The reads under way, by endpoint: calls sent together share one get_pricing call rather than each sending its own.
|
|
518
|
+
* `signal` is the signal of the call that sent it. */
|
|
519
|
+
const reading = new Map();
|
|
520
|
+
const readPrice = async (endpoint, ask) => {
|
|
517
521
|
const unread = (why) => ({ why: `fal's price for ${endpoint} could not be read (its get_pricing ${why})` });
|
|
522
|
+
// get_pricing reads a price and runs no job: an error or no answer is asked once more, never kept as the price.
|
|
523
|
+
let answer = await ask("get_pricing", { endpoint_id: endpoint });
|
|
524
|
+
if (!answer || answer.isError === true)
|
|
525
|
+
answer = await ask("get_pricing", { endpoint_id: endpoint });
|
|
518
526
|
if (!answer)
|
|
519
527
|
return unread("did not answer");
|
|
520
528
|
if (answer.isError === true)
|
|
@@ -522,10 +530,44 @@ export function falMeter({ media, now = Date.now } = {}) {
|
|
|
522
530
|
const price = priceIn(bodyOf(answer), endpoint);
|
|
523
531
|
if (!price)
|
|
524
532
|
return unread("lists no USD price for it");
|
|
533
|
+
// fal bills its jobs: a rate of $0 is no price, so the job is unpriceable (refused under a cap, booked as unknown).
|
|
534
|
+
if (price.unitPrice === 0)
|
|
535
|
+
return unread(`states $0 per ${oneOf(price.unit)} for it, which is no price`);
|
|
525
536
|
const read = { ...price, at: now() };
|
|
526
537
|
prices.set(endpoint, read);
|
|
527
538
|
return read;
|
|
528
539
|
};
|
|
540
|
+
const unitPrice = async (endpoint, ask, signal) => {
|
|
541
|
+
for (;;) {
|
|
542
|
+
const kept = prices.get(endpoint);
|
|
543
|
+
if (kept && now() - kept.at < PRICE_TTL_MS)
|
|
544
|
+
return kept;
|
|
545
|
+
const shared = reading.get(endpoint);
|
|
546
|
+
if (!shared)
|
|
547
|
+
break;
|
|
548
|
+
try {
|
|
549
|
+
const read = await shared.read;
|
|
550
|
+
// A read whose call stopped (its deadline, its run's abort) got no answer from fal, which says nothing of the
|
|
551
|
+
// price: a call still live reads again, with its own ask. A read that failed while its call was live stands.
|
|
552
|
+
if (!("why" in read) || !shared.signal.aborted || signal.aborted)
|
|
553
|
+
return read;
|
|
554
|
+
}
|
|
555
|
+
catch {
|
|
556
|
+
// The call that sent it threw: this one reads with its own ask.
|
|
557
|
+
}
|
|
558
|
+
if (reading.get(endpoint) === shared)
|
|
559
|
+
reading.delete(endpoint);
|
|
560
|
+
}
|
|
561
|
+
const mine = { read: readPrice(endpoint, ask), signal };
|
|
562
|
+
reading.set(endpoint, mine);
|
|
563
|
+
try {
|
|
564
|
+
return await mine.read;
|
|
565
|
+
}
|
|
566
|
+
finally {
|
|
567
|
+
if (reading.get(endpoint) === mine)
|
|
568
|
+
reading.delete(endpoint);
|
|
569
|
+
}
|
|
570
|
+
};
|
|
529
571
|
/** The longest of the media at `urls`, in seconds by `measure`, or the URL whose length could not be read. */
|
|
530
572
|
const longest = async (urls, signal, read, measure = mediaSeconds) => {
|
|
531
573
|
const lengths = await Promise.all([...new Set(urls)].map(async (url) => {
|
|
@@ -541,7 +583,7 @@ export function falMeter({ media, now = Date.now } = {}) {
|
|
|
541
583
|
const quoteJob = async (job, ask, signal) => {
|
|
542
584
|
if (!job.endpoint)
|
|
543
585
|
return { job, why: "this job names no endpoint_id to price" };
|
|
544
|
-
const price = await unitPrice(job.endpoint, ask);
|
|
586
|
+
const price = await unitPrice(job.endpoint, ask, signal);
|
|
545
587
|
if ("why" in price)
|
|
546
588
|
return { job, why: price.why };
|
|
547
589
|
// The rate its settings are billed at, before any media is read for a job that can't be priced.
|
|
@@ -567,9 +609,18 @@ export function falMeter({ media, now = Date.now } = {}) {
|
|
|
567
609
|
const step = price.unit === "seconds" || price.unit === "minutes" ? BILLING_STEP.get(job.endpoint) : undefined;
|
|
568
610
|
if (step)
|
|
569
611
|
units = { units: roundedUp(units.units, price.unit, step), from: `${units.from}, in whole ${step === 60 ? "minutes" : "seconds"}` };
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
612
|
+
// The ratios were decided against get_pricing's rate as it stood (page.base). When fal states another, the scaled
|
|
613
|
+
// rate can fall under what its model page bills this tier, and the hold and the booking (the same unitPrice) with it:
|
|
614
|
+
// the job is held at the higher of the two.
|
|
615
|
+
const scaled = price.unitPrice * rate.ratio;
|
|
616
|
+
const base = RATE_TIERS.get(job.endpoint)?.base;
|
|
617
|
+
// The tier's rate on the model page: the ratio was decided as that rate over base (rateOf).
|
|
618
|
+
const page = base === undefined ? undefined : micro(base * rate.ratio);
|
|
619
|
+
const moved = base !== undefined && page !== undefined && price.unitPrice !== base && page > scaled;
|
|
620
|
+
const rated = (moved ? page : scaled) + rate.perUnitUsd;
|
|
621
|
+
const drift = moved ? [`(get_pricing states $${price.unitPrice}, not the $${base} its rates were decided at: held at the model page's $${page} per ${oneOf(price.unit)})`] : [];
|
|
622
|
+
const words = [`fal's price for ${job.endpoint}: $${price.unitPrice} per ${oneOf(price.unit)}`, ...rate.words, ...drift, `× ${shown(units.units)} (${units.from})`].join(" ");
|
|
623
|
+
return { job, holdUsd: micro(rated * units.units), unitPrice: rated, unit: price.unit, at: price.at, words, ...(step ? { step } : {}) };
|
|
573
624
|
};
|
|
574
625
|
return {
|
|
575
626
|
bills: falBills,
|
|
@@ -581,7 +632,7 @@ export function falMeter({ media, now = Date.now } = {}) {
|
|
|
581
632
|
const priced = quotes.filter((quote) => "holdUsd" in quote);
|
|
582
633
|
const unpriced = quotes.find((quote) => "why" in quote);
|
|
583
634
|
const basis = priced.length ? `${priced.map((quote) => quote.words).join("; ")}, from get_pricing at ${new Date(Math.min(...priced.map((quote) => quote.at))).toISOString()}` : "fal's price for it could not be worked out";
|
|
584
|
-
const holdUsd =
|
|
635
|
+
const holdUsd = micro(priced.reduce((sum, quote) => sum + quote.holdUsd, 0));
|
|
585
636
|
return {
|
|
586
637
|
holdUsd,
|
|
587
638
|
basis: unpriced && priced.length ? `${basis}; not counting what could not be priced` : basis,
|
|
@@ -606,7 +657,7 @@ export function falMeter({ media, now = Date.now } = {}) {
|
|
|
606
657
|
return null;
|
|
607
658
|
total += charge;
|
|
608
659
|
}
|
|
609
|
-
return
|
|
660
|
+
return micro(total);
|
|
610
661
|
},
|
|
611
662
|
};
|
|
612
663
|
},
|