byollm 0.1.3 → 0.1.4
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 +1 -1
- package/dist/bin.js +1 -1
- package/dist/{chunk-PXL5HY2O.js → chunk-LGN2DHFP.js} +250 -22
- package/dist/chunk-LGN2DHFP.js.map +1 -0
- package/dist/index.d.ts +40 -6
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-PXL5HY2O.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!-- release-note 0.1.1 -->
|
|
2
|
-
> **`0.1.
|
|
2
|
+
> **`0.1.4` is documentation only — nothing to upgrade.** `PROTOCOL_VERSION`
|
|
3
3
|
> is still `2`, so a 0.1.0 party and a 0.1.1 party talk to each other in both
|
|
4
4
|
> directions. No dependency, schema, wire field or on-disk shape moved.
|
|
5
5
|
>
|
package/dist/bin.js
CHANGED
|
@@ -536,7 +536,19 @@ var CommunityBudget = z.object({
|
|
|
536
536
|
/** Output-size ceiling for one community job. */
|
|
537
537
|
maxOutputBytes: z.number().int().positive().default(256 * 1024),
|
|
538
538
|
/** Payload-size ceiling — stricter than the protocol's absolute limit. */
|
|
539
|
-
maxPayloadChars: z.number().int().positive().default(1e5)
|
|
539
|
+
maxPayloadChars: z.number().int().positive().default(1e5),
|
|
540
|
+
/**
|
|
541
|
+
* Whether a teammate's job on a METERED service you shared counts toward
|
|
542
|
+
* the two job caps above.
|
|
543
|
+
*
|
|
544
|
+
* Off by default, because that work is already bounded by the service's
|
|
545
|
+
* daily spend ceiling, in your own dollars — and counting it twice is how
|
|
546
|
+
* a teammate's writing assistant stopped at twenty jobs an hour on a
|
|
547
|
+
* service that had spent $0.80 of $25.00 (10-22). The payload, wall-clock
|
|
548
|
+
* and output ceilings apply either way, and work on a free service — your
|
|
549
|
+
* GPU, which no dollar ceiling bounds — is always counted.
|
|
550
|
+
*/
|
|
551
|
+
countTeamJobs: z.boolean().default(false)
|
|
540
552
|
}).strict();
|
|
541
553
|
var IngressRetention = z.object({
|
|
542
554
|
/**
|
|
@@ -3455,6 +3467,13 @@ Someone else's terms are not yours to lend.
|
|
|
3455
3467
|
continue;
|
|
3456
3468
|
}
|
|
3457
3469
|
row.capCents = cents;
|
|
3470
|
+
io.out(
|
|
3471
|
+
` Your team's jobs on ${row.name} stop at that amount. They are not
|
|
3472
|
+
also counted against the hourly and daily job caps for other
|
|
3473
|
+
people's work \u2014 to count them too:
|
|
3474
|
+
byollm budget community --count-team-jobs yes
|
|
3475
|
+
`
|
|
3476
|
+
);
|
|
3458
3477
|
}
|
|
3459
3478
|
anyShared = shareable.some((row) => row.shared);
|
|
3460
3479
|
}
|
|
@@ -3872,6 +3891,12 @@ var BudgetFile = z3.object({
|
|
|
3872
3891
|
/** Epoch-ms timestamps of community jobs accepted, newest last. */
|
|
3873
3892
|
accepted: z3.array(z3.number().int().positive())
|
|
3874
3893
|
}).strict();
|
|
3894
|
+
var BudgetRefusal = z3.enum([
|
|
3895
|
+
"hourly-cap",
|
|
3896
|
+
"daily-cap",
|
|
3897
|
+
"payload-too-large",
|
|
3898
|
+
"ledger-untrusted"
|
|
3899
|
+
]);
|
|
3875
3900
|
var Budgets = class {
|
|
3876
3901
|
#path;
|
|
3877
3902
|
#limits;
|
|
@@ -3908,8 +3933,13 @@ var Budgets = class {
|
|
|
3908
3933
|
*
|
|
3909
3934
|
* @param payloadChars - total payload text length, checked against the
|
|
3910
3935
|
* stricter community limit rather than the protocol's absolute ceiling.
|
|
3936
|
+
* @param counted - whether this job counts toward the hourly and daily
|
|
3937
|
+
* caps. `false` only for a teammate's job on a metered service the owner
|
|
3938
|
+
* shared, which the spend ceiling already bounds — see
|
|
3939
|
+
* {@link CommunityBudget}'s `countTeamJobs`. The payload limit applies
|
|
3940
|
+
* either way.
|
|
3911
3941
|
*/
|
|
3912
|
-
check(now, payloadChars) {
|
|
3942
|
+
check(now, payloadChars, counted = true) {
|
|
3913
3943
|
if (!this.#loaded) throw new Error("budgets used before load()");
|
|
3914
3944
|
if (this.#untrusted !== void 0) {
|
|
3915
3945
|
return {
|
|
@@ -3926,6 +3956,7 @@ var Budgets = class {
|
|
|
3926
3956
|
detail: `community jobs are limited to ${String(this.#limits.maxPayloadChars)} characters; this one is ${String(payloadChars)}`
|
|
3927
3957
|
};
|
|
3928
3958
|
}
|
|
3959
|
+
if (!counted) return { ok: true };
|
|
3929
3960
|
const hour = this.#countSince(now - 36e5);
|
|
3930
3961
|
if (hour >= this.#limits.maxJobsPerHour) {
|
|
3931
3962
|
return {
|
|
@@ -4537,7 +4568,20 @@ var OutcomeEntry = z4.object({
|
|
|
4537
4568
|
* reason a log is a log: if an adapter gains a signal in a later release,
|
|
4538
4569
|
* entries written before that should still read as they were true.
|
|
4539
4570
|
*/
|
|
4540
|
-
stopKind: z4.enum(["declared", "unavailable", "unverified"]).optional()
|
|
4571
|
+
stopKind: z4.enum(["declared", "unavailable", "unverified"]).optional(),
|
|
4572
|
+
/**
|
|
4573
|
+
* Which community brake refused this job, when one did — 10-22.
|
|
4574
|
+
*
|
|
4575
|
+
* `detail` already said it in words, and `byollm status` could not tell
|
|
4576
|
+
* the hourly cap from the payload limit without parsing a sentence: Lis
|
|
4577
|
+
* was refused 21 times and the screen said which cap was full only by
|
|
4578
|
+
* arithmetic. The code is what status groups by and names the fix for.
|
|
4579
|
+
*
|
|
4580
|
+
* Optional, like everything added here. A build older than this one reads
|
|
4581
|
+
* a line carrying it as malformed and skips it — one refusal missing from
|
|
4582
|
+
* an older binary's count, which is the cost of a strict reader.
|
|
4583
|
+
*/
|
|
4584
|
+
brake: BudgetRefusal.optional()
|
|
4541
4585
|
}).strict();
|
|
4542
4586
|
var MemoryEntry = z4.object({
|
|
4543
4587
|
type: z4.literal("memory"),
|
|
@@ -4597,7 +4641,8 @@ var IngressLog = class {
|
|
|
4597
4641
|
...input.outputChars === void 0 ? {} : { outputChars: input.outputChars },
|
|
4598
4642
|
...input.detail === void 0 ? {} : { detail: input.detail },
|
|
4599
4643
|
...input.stop === void 0 ? {} : { stop: input.stop },
|
|
4600
|
-
...input.stopKind === void 0 ? {} : { stopKind: input.stopKind }
|
|
4644
|
+
...input.stopKind === void 0 ? {} : { stopKind: input.stopKind },
|
|
4645
|
+
...input.brake === void 0 ? {} : { brake: input.brake }
|
|
4601
4646
|
});
|
|
4602
4647
|
}
|
|
4603
4648
|
/** Record what the memory guard decided — B080. */
|
|
@@ -6555,6 +6600,35 @@ var Runner = class {
|
|
|
6555
6600
|
this.#now()
|
|
6556
6601
|
);
|
|
6557
6602
|
}
|
|
6603
|
+
/**
|
|
6604
|
+
* Does this other person's job count toward the community job caps?
|
|
6605
|
+
*
|
|
6606
|
+
* Not when it is a teammate's job on a metered service the owner shared
|
|
6607
|
+
* with a ceiling, unless the owner set `community.countTeamJobs`: that work
|
|
6608
|
+
* is already counted, in dollars, against a limit the owner chose, and
|
|
6609
|
+
* counting it a second time as a stranger's job is what stopped Lis at
|
|
6610
|
+
* twenty an hour on a service that had spent $0.80 of $25.00 (10-22).
|
|
6611
|
+
*
|
|
6612
|
+
* Everything else is counted, and that is the bound byollm_016 §5 and
|
|
6613
|
+
* byollm_001 lean on: a free service is the owner's GPU, which no dollar
|
|
6614
|
+
* ceiling bounds, so a teammate's runaway loop there still stops at the
|
|
6615
|
+
* hourly cap. An unresolved route counts — the safe direction for a
|
|
6616
|
+
* question asked about somebody else's work.
|
|
6617
|
+
*
|
|
6618
|
+
* "Metered" is the cost class this daemon resolved for the service, and
|
|
6619
|
+
* "team" is a team-scoped service reached under a signed grant — never
|
|
6620
|
+
* anything the job says about itself (owl, #15096). The grant has already
|
|
6621
|
+
* been verified by `#grantAdmits` on every path that reaches here; asking
|
|
6622
|
+
* for it again is what keeps a future caller that skips admission from
|
|
6623
|
+
* inheriting the exemption.
|
|
6624
|
+
*/
|
|
6625
|
+
#countsTowardJobCaps(job, route) {
|
|
6626
|
+
const granted = "grant" in job && job.grant !== void 0;
|
|
6627
|
+
if (route === void 0 || !granted) return true;
|
|
6628
|
+
if (this.#options.loaded.config.community.countTeamJobs) return true;
|
|
6629
|
+
const boundedBySpend = route.cost === "metered" && route.offerScope === "team" && route.spendAcknowledged && route.spendDailyCapCents !== void 0;
|
|
6630
|
+
return !boundedBySpend;
|
|
6631
|
+
}
|
|
6558
6632
|
/**
|
|
6559
6633
|
* The route a job takes — byollm_016 Phase B, both sides of it.
|
|
6560
6634
|
*
|
|
@@ -6818,9 +6892,16 @@ var Runner = class {
|
|
|
6818
6892
|
if (job.owner !== this.#options.owner) {
|
|
6819
6893
|
const decision = this.#options.budgets.check(
|
|
6820
6894
|
this.#now(),
|
|
6821
|
-
sizeClassCeiling(job.sizeClass)
|
|
6895
|
+
sizeClassCeiling(job.sizeClass),
|
|
6896
|
+
this.#countsTowardJobCaps(job, route)
|
|
6822
6897
|
);
|
|
6823
|
-
if (!decision.ok)
|
|
6898
|
+
if (!decision.ok) {
|
|
6899
|
+
return {
|
|
6900
|
+
ok: false,
|
|
6901
|
+
reason: decision.detail,
|
|
6902
|
+
brake: decision.refusal
|
|
6903
|
+
};
|
|
6904
|
+
}
|
|
6824
6905
|
}
|
|
6825
6906
|
if (!this.#served.has(job.site)) {
|
|
6826
6907
|
this.#served.add(job.site);
|
|
@@ -7056,7 +7137,9 @@ var Runner = class {
|
|
|
7056
7137
|
model: route.model,
|
|
7057
7138
|
prompt
|
|
7058
7139
|
});
|
|
7059
|
-
if (community
|
|
7140
|
+
if (community && this.#countsTowardJobCaps(job, route)) {
|
|
7141
|
+
await this.#options.budgets.record(this.#now());
|
|
7142
|
+
}
|
|
7060
7143
|
const backend = this.#backendFor(route);
|
|
7061
7144
|
const gate = await this.#memoryDecision(route, job.id);
|
|
7062
7145
|
const result = gate !== void 0 && !gate.admit ? {
|
|
@@ -7604,7 +7687,7 @@ var Runner = class {
|
|
|
7604
7687
|
}
|
|
7605
7688
|
const admission = this.admit(job);
|
|
7606
7689
|
if (!admission.ok) {
|
|
7607
|
-
await this.#refuseOnOurOwnRules(job, admission.reason);
|
|
7690
|
+
await this.#refuseOnOurOwnRules(job, admission.reason, admission.brake);
|
|
7608
7691
|
return;
|
|
7609
7692
|
}
|
|
7610
7693
|
const fetched = await this.#fetchWhenSealed(job);
|
|
@@ -7653,15 +7736,15 @@ var Runner = class {
|
|
|
7653
7736
|
}
|
|
7654
7737
|
this.#gaveUpFetching.delete(jobKey(job));
|
|
7655
7738
|
const payload = await this.#openPayload(job, fetched.envelope);
|
|
7739
|
+
const resolved = job.grant?.service;
|
|
7740
|
+
const route = this.#routeFor(job.kind, resolved);
|
|
7656
7741
|
if (job.owner !== this.#options.owner) {
|
|
7657
|
-
const refusal = this.#withinCommunityBudget(job, payload);
|
|
7742
|
+
const refusal = this.#withinCommunityBudget(job, payload, route);
|
|
7658
7743
|
if (refusal !== void 0) {
|
|
7659
|
-
await this.#refuseOnOurOwnRules(job, refusal);
|
|
7744
|
+
await this.#refuseOnOurOwnRules(job, refusal.detail, refusal.refusal);
|
|
7660
7745
|
return;
|
|
7661
7746
|
}
|
|
7662
7747
|
}
|
|
7663
|
-
const resolved = job.grant?.service;
|
|
7664
|
-
const route = this.#routeFor(job.kind, resolved);
|
|
7665
7748
|
const { outcome, ran } = await this.runJob({
|
|
7666
7749
|
...job,
|
|
7667
7750
|
payload,
|
|
@@ -7854,7 +7937,7 @@ var Runner = class {
|
|
|
7854
7937
|
* `refused` rather than a lapse, because a lapse means "ask me later" and
|
|
7855
7938
|
* this device's answer will not change.
|
|
7856
7939
|
*/
|
|
7857
|
-
async #refuseOnOurOwnRules(job, reason) {
|
|
7940
|
+
async #refuseOnOurOwnRules(job, reason, brake) {
|
|
7858
7941
|
this.#jobSettled(job);
|
|
7859
7942
|
this.#refused += 1;
|
|
7860
7943
|
await this.#options.ingress.recordOutcome({
|
|
@@ -7862,7 +7945,8 @@ var Runner = class {
|
|
|
7862
7945
|
jobId: job.id,
|
|
7863
7946
|
site: job.site,
|
|
7864
7947
|
outcome: "refused",
|
|
7865
|
-
detail: reason
|
|
7948
|
+
detail: reason,
|
|
7949
|
+
...brake === void 0 ? {} : { brake }
|
|
7866
7950
|
});
|
|
7867
7951
|
this.#options.onEvent?.({ type: "refused", jobId: job.id, reason });
|
|
7868
7952
|
await this.#safely(
|
|
@@ -7878,6 +7962,10 @@ var Runner = class {
|
|
|
7878
7962
|
*
|
|
7879
7963
|
* Returns the refusal to give, or `undefined` to proceed.
|
|
7880
7964
|
*
|
|
7965
|
+
* `route` decides only whether the job caps apply
|
|
7966
|
+
* ({@link ByollmRunner.#countsTowardJobCaps}); the payload is measured
|
|
7967
|
+
* whatever it says.
|
|
7968
|
+
*
|
|
7881
7969
|
* The admission-time call passes `sizeClassCeiling(job.sizeClass)`, a number
|
|
7882
7970
|
* the sender chose. This passes `payloadTextLength` of the opened payload,
|
|
7883
7971
|
* which is the same function the site used to derive that class — so a job
|
|
@@ -7889,15 +7977,16 @@ var Runner = class {
|
|
|
7889
7977
|
* hourly cap has the same answer for this job, and splitting the predicate
|
|
7890
7978
|
* would be a second copy of the rule for the sake of a narrower question.
|
|
7891
7979
|
*/
|
|
7892
|
-
#withinCommunityBudget(job, payload) {
|
|
7980
|
+
#withinCommunityBudget(job, payload, route) {
|
|
7893
7981
|
const decision = this.#options.budgets.check(
|
|
7894
7982
|
this.#now(),
|
|
7895
7983
|
payloadTextLength({
|
|
7896
7984
|
kind: job.kind,
|
|
7897
7985
|
payload
|
|
7898
|
-
})
|
|
7986
|
+
}),
|
|
7987
|
+
this.#countsTowardJobCaps(job, route)
|
|
7899
7988
|
);
|
|
7900
|
-
return decision.ok ? void 0 : decision
|
|
7989
|
+
return decision.ok ? void 0 : decision;
|
|
7901
7990
|
}
|
|
7902
7991
|
async #openPayload(job, envelope) {
|
|
7903
7992
|
const identity = this.#options.identity;
|
|
@@ -8898,6 +8987,7 @@ var USAGE = `byollm \u2014 run an app's LLM jobs on your own models.
|
|
|
8898
8987
|
byollm services manage turn services on and off, and share them
|
|
8899
8988
|
byollm model <svc> <name> check a model answers, then use it
|
|
8900
8989
|
byollm offer <service> <scope> who a service is offered to (private|team)
|
|
8990
|
+
byollm budget community how many jobs other people may run here
|
|
8901
8991
|
byollm sites which sites this device serves
|
|
8902
8992
|
|
|
8903
8993
|
Config lives in ~/.byollm/config.json. Everything this daemon has ever run is
|
|
@@ -9022,7 +9112,9 @@ async function runCli(argv, options = {}) {
|
|
|
9022
9112
|
case "disallow":
|
|
9023
9113
|
return commandRetiredAdmission("disallow", io);
|
|
9024
9114
|
case "offer":
|
|
9025
|
-
return commandOffer(paths, rest, io);
|
|
9115
|
+
return commandOffer(paths, rest, io, service, options.env);
|
|
9116
|
+
case "budget":
|
|
9117
|
+
return commandBudget(paths, rest, io, service, options.env);
|
|
9026
9118
|
case "sites":
|
|
9027
9119
|
return commandSites(paths, io);
|
|
9028
9120
|
case "approve":
|
|
@@ -10350,12 +10442,27 @@ async function commandStatus(paths, io, service) {
|
|
|
10350
10442
|
io.out(" your own jobs on these are not counted here and have no cap.\n");
|
|
10351
10443
|
}
|
|
10352
10444
|
const usage = budgets.usage(now);
|
|
10445
|
+
const entries = await ingress.read();
|
|
10353
10446
|
io.out("\ncommunity work done for others\n");
|
|
10354
10447
|
io.out(
|
|
10355
10448
|
` ${String(usage.hour)} in the last hour (cap ${String(usage.limits.maxJobsPerHour)}), ${String(usage.day)} today (cap ${String(usage.limits.maxJobsPerDay)})
|
|
10356
10449
|
`
|
|
10357
10450
|
);
|
|
10358
|
-
const entries
|
|
10451
|
+
for (const line of brakeLines(entries, now, usage.limits, paths.config)) {
|
|
10452
|
+
io.out(` ${line}
|
|
10453
|
+
`);
|
|
10454
|
+
}
|
|
10455
|
+
if (!loaded.config.community.countTeamJobs) {
|
|
10456
|
+
for (const route of metered) {
|
|
10457
|
+
if (route.offerScope !== "team" || !route.spendAcknowledged || route.spendDailyCapCents === void 0) {
|
|
10458
|
+
continue;
|
|
10459
|
+
}
|
|
10460
|
+
io.out(
|
|
10461
|
+
` your team's jobs on ${route.service} are not counted here \u2014 its daily spend ceiling bounds them
|
|
10462
|
+
`
|
|
10463
|
+
);
|
|
10464
|
+
}
|
|
10465
|
+
}
|
|
10359
10466
|
const prompts = entries.filter((entry) => entry.type === "prompt");
|
|
10360
10467
|
const outcomes = entries.filter((entry) => entry.type === "outcome");
|
|
10361
10468
|
io.out("\nthis device has run\n");
|
|
@@ -10370,6 +10477,23 @@ async function commandStatus(paths, io, service) {
|
|
|
10370
10477
|
);
|
|
10371
10478
|
return 0;
|
|
10372
10479
|
}
|
|
10480
|
+
function brakeLines(entries, now, limits, configPath) {
|
|
10481
|
+
const counts = /* @__PURE__ */ new Map();
|
|
10482
|
+
for (const entry of entries) {
|
|
10483
|
+
if (entry.type !== "outcome" || entry.brake === void 0) continue;
|
|
10484
|
+
if (entry.at < now - 36e5) continue;
|
|
10485
|
+
counts.set(entry.brake, (counts.get(entry.brake) ?? 0) + 1);
|
|
10486
|
+
}
|
|
10487
|
+
const why = {
|
|
10488
|
+
"hourly-cap": `hourly cap (${String(limits.maxJobsPerHour)}) \u2014 raise it: byollm budget community --per-hour N`,
|
|
10489
|
+
"daily-cap": `daily cap (${String(limits.maxJobsPerDay)}) \u2014 raise it: byollm budget community --per-day N`,
|
|
10490
|
+
"payload-too-large": `payload limit (${String(limits.maxPayloadChars)} characters) \u2014 community.maxPayloadChars in ${configPath}`,
|
|
10491
|
+
"ledger-untrusted": 'its record of community work cannot be read \u2014 see "bookkeeping this device cannot read" above'
|
|
10492
|
+
};
|
|
10493
|
+
return [...counts].map(
|
|
10494
|
+
([brake, count]) => `refused ${String(count)} in the last hour: ${why[brake]}`
|
|
10495
|
+
);
|
|
10496
|
+
}
|
|
10373
10497
|
function split(entry) {
|
|
10374
10498
|
const parts = [];
|
|
10375
10499
|
if (entry.spawnMs !== void 0) parts.push(`spawn ${String(entry.spawnMs)}`);
|
|
@@ -10484,7 +10608,7 @@ function offerSummary(input) {
|
|
|
10484
10608
|
narrowedBy: void 0
|
|
10485
10609
|
};
|
|
10486
10610
|
}
|
|
10487
|
-
async function commandOffer(paths, args, io) {
|
|
10611
|
+
async function commandOffer(paths, args, io, serviceIo, env = process.env) {
|
|
10488
10612
|
const [serviceKey, scope, ...rest] = args;
|
|
10489
10613
|
if (serviceKey === void 0 || scope === void 0) {
|
|
10490
10614
|
io.err("usage: byollm offer <service> <private|team> [--cap <cents>]\n");
|
|
@@ -10626,6 +10750,110 @@ Offer ${serviceKey} to your team?`
|
|
|
10626
10750
|
io.out(
|
|
10627
10751
|
`${serviceKey} is now offered to ${scope}` + (written === void 0 || !widening ? "" : `, capped at ${dollars(written)} a day`) + "\n"
|
|
10628
10752
|
);
|
|
10753
|
+
await pickUpTheChange(paths, io, serviceIo, env);
|
|
10754
|
+
return 0;
|
|
10755
|
+
}
|
|
10756
|
+
async function pickUpTheChange(paths, io, serviceIo, env) {
|
|
10757
|
+
const told = tellSupervisor(void 0, env);
|
|
10758
|
+
if (told === "told") {
|
|
10759
|
+
io.out(
|
|
10760
|
+
"\nTold the supervisor \u2014 this device is picking the change up now.\n"
|
|
10761
|
+
);
|
|
10762
|
+
return;
|
|
10763
|
+
}
|
|
10764
|
+
if (told === "gone") {
|
|
10765
|
+
io.out(
|
|
10766
|
+
"\nThis device's supervisor is not answering, so nothing is serving the\nnew configuration yet. Restarting the device picks it up.\n"
|
|
10767
|
+
);
|
|
10768
|
+
return;
|
|
10769
|
+
}
|
|
10770
|
+
if (await serviceIsInstalled(serviceTarget(paths, serviceIo))) {
|
|
10771
|
+
io.out(
|
|
10772
|
+
"\nThe background service is running with the config it started on.\n byollm stop && byollm start pick this up\n"
|
|
10773
|
+
);
|
|
10774
|
+
}
|
|
10775
|
+
}
|
|
10776
|
+
var BUDGET_USAGE = "usage: byollm budget community [--per-hour N] [--per-day N] [--count-team-jobs yes|no]\n";
|
|
10777
|
+
async function commandBudget(paths, args, io, serviceIo, env = process.env) {
|
|
10778
|
+
const [scope, ...flags] = args;
|
|
10779
|
+
if (scope !== "community") {
|
|
10780
|
+
io.err(BUDGET_USAGE);
|
|
10781
|
+
return 2;
|
|
10782
|
+
}
|
|
10783
|
+
const changes = {};
|
|
10784
|
+
for (let i = 0; i < flags.length; i += 2) {
|
|
10785
|
+
const flag = flags[i];
|
|
10786
|
+
const value = flags[i + 1];
|
|
10787
|
+
if (flag === "--per-hour" || flag === "--per-day") {
|
|
10788
|
+
if (value === void 0 || !/^[0-9]+$/.test(value) || Number(value) <= 0) {
|
|
10789
|
+
io.err(
|
|
10790
|
+
`${flag} takes a whole number of jobs, greater than zero` + (value === void 0 ? "" : ` \u2014 not "${value}"`) + "\n"
|
|
10791
|
+
);
|
|
10792
|
+
return 2;
|
|
10793
|
+
}
|
|
10794
|
+
if (flag === "--per-hour") changes.perHour = Number(value);
|
|
10795
|
+
else changes.perDay = Number(value);
|
|
10796
|
+
continue;
|
|
10797
|
+
}
|
|
10798
|
+
if (flag === "--count-team-jobs") {
|
|
10799
|
+
if (value !== "yes" && value !== "no") {
|
|
10800
|
+
io.err("--count-team-jobs takes yes or no\n");
|
|
10801
|
+
return 2;
|
|
10802
|
+
}
|
|
10803
|
+
changes.countTeam = value === "yes";
|
|
10804
|
+
continue;
|
|
10805
|
+
}
|
|
10806
|
+
io.err(`unknown option "${flag ?? ""}"
|
|
10807
|
+
${BUDGET_USAGE}`);
|
|
10808
|
+
return 2;
|
|
10809
|
+
}
|
|
10810
|
+
let raw;
|
|
10811
|
+
try {
|
|
10812
|
+
raw = await readFile14(paths.config, "utf8");
|
|
10813
|
+
} catch {
|
|
10814
|
+
io.err(
|
|
10815
|
+
`no config at ${paths.config} \u2014 nothing to set a budget on yet.
|
|
10816
|
+
Run \`byollm setup\` first.
|
|
10817
|
+
`
|
|
10818
|
+
);
|
|
10819
|
+
return 1;
|
|
10820
|
+
}
|
|
10821
|
+
let parsed;
|
|
10822
|
+
try {
|
|
10823
|
+
parsed = JSON.parse(raw);
|
|
10824
|
+
} catch {
|
|
10825
|
+
io.err(`${paths.config} is not valid JSON \u2014 fix it by hand first
|
|
10826
|
+
`);
|
|
10827
|
+
return 1;
|
|
10828
|
+
}
|
|
10829
|
+
const result = DaemonConfig.safeParse(parsed);
|
|
10830
|
+
if (!result.success) {
|
|
10831
|
+
io.err(`${paths.config} is not a valid byollm config \u2014 fix it first
|
|
10832
|
+
`);
|
|
10833
|
+
return 1;
|
|
10834
|
+
}
|
|
10835
|
+
const community = result.data.community;
|
|
10836
|
+
const changed = Object.keys(changes).length > 0;
|
|
10837
|
+
if (changed) {
|
|
10838
|
+
result.data.community = {
|
|
10839
|
+
...community,
|
|
10840
|
+
...changes.perHour === void 0 ? {} : { maxJobsPerHour: changes.perHour },
|
|
10841
|
+
...changes.perDay === void 0 ? {} : { maxJobsPerDay: changes.perDay },
|
|
10842
|
+
...changes.countTeam === void 0 ? {} : { countTeamJobs: changes.countTeam }
|
|
10843
|
+
};
|
|
10844
|
+
await writeConfig(paths.config, result.data);
|
|
10845
|
+
}
|
|
10846
|
+
const now = result.data.community;
|
|
10847
|
+
io.out(
|
|
10848
|
+
`other people's jobs on this device: up to ${String(now.maxJobsPerHour)} an hour, ${String(now.maxJobsPerDay)} a day
|
|
10849
|
+
` + (now.countTeamJobs ? " your team's jobs on metered services you shared count toward these\n" : " your team's jobs on metered services you shared do not count toward\n these \u2014 the service's daily spend ceiling bounds them\n")
|
|
10850
|
+
);
|
|
10851
|
+
if (!changed) {
|
|
10852
|
+
io.out(`
|
|
10853
|
+
${BUDGET_USAGE.replace("usage: ", "change it: ")}`);
|
|
10854
|
+
return 0;
|
|
10855
|
+
}
|
|
10856
|
+
await pickUpTheChange(paths, io, serviceIo, env);
|
|
10629
10857
|
return 0;
|
|
10630
10858
|
}
|
|
10631
10859
|
async function commandForget(paths, args, io) {
|
|
@@ -10924,7 +11152,7 @@ async function exists(path) {
|
|
|
10924
11152
|
}
|
|
10925
11153
|
|
|
10926
11154
|
// src/index.ts
|
|
10927
|
-
var DAEMON_VERSION = "0.1.
|
|
11155
|
+
var DAEMON_VERSION = "0.1.4";
|
|
10928
11156
|
function daemonVersion() {
|
|
10929
11157
|
return {
|
|
10930
11158
|
daemon: DAEMON_VERSION,
|
|
@@ -10983,4 +11211,4 @@ export {
|
|
|
10983
11211
|
runCli,
|
|
10984
11212
|
main
|
|
10985
11213
|
};
|
|
10986
|
-
//# sourceMappingURL=chunk-
|
|
11214
|
+
//# sourceMappingURL=chunk-LGN2DHFP.js.map
|