byollm 0.1.2 → 0.1.3

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  <!-- release-note 0.1.1 -->
2
- > **`0.1.2` is documentation only — nothing to upgrade.** `PROTOCOL_VERSION`
2
+ > **`0.1.3` 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
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  main
4
- } from "./chunk-K7QYAF7V.js";
4
+ } from "./chunk-PXL5HY2O.js";
5
5
 
6
6
  // src/bin.ts
7
7
  process.exitCode = await main(process.argv.slice(2));
@@ -194,6 +194,10 @@ function asHttpOrigin(candidate) {
194
194
 
195
195
  // src/local-server.ts
196
196
  import { spawn } from "child_process";
197
+ import {
198
+ BACKEND_IDS,
199
+ backendDescriptor
200
+ } from "@byollm/protocol";
197
201
  function startCommandFor(id) {
198
202
  switch (id) {
199
203
  case "ollama":
@@ -202,6 +206,18 @@ function startCommandFor(id) {
202
206
  return void 0;
203
207
  }
204
208
  }
209
+ function startableAt(origin) {
210
+ for (const id of BACKEND_IDS) {
211
+ if (startCommandFor(id) === void 0) continue;
212
+ const address = backendDescriptor(id).defaultBaseUrl;
213
+ if (address === void 0) continue;
214
+ try {
215
+ if (new URL(address).origin === origin) return id;
216
+ } catch {
217
+ }
218
+ }
219
+ return void 0;
220
+ }
205
221
  function isLoopback(baseUrl) {
206
222
  let host;
207
223
  try {
@@ -360,7 +376,7 @@ import {
360
376
  BackendIdSchema,
361
377
  JobKind,
362
378
  OfferScope,
363
- backendDescriptor,
379
+ backendDescriptor as backendDescriptor2,
364
380
  effectiveOfferScope,
365
381
  classifyCost
366
382
  } from "@byollm/protocol";
@@ -776,7 +792,7 @@ function resolveConfig(config) {
776
792
  }
777
793
  for (const [name, service] of Object.entries(config.services)) {
778
794
  const where = `services.${name}`;
779
- const descriptor = backendDescriptor(service.type);
795
+ const descriptor = backendDescriptor2(service.type);
780
796
  const baseUrl = service.baseUrl ?? descriptor.defaultBaseUrl;
781
797
  if (descriptor.class === "http") {
782
798
  if (baseUrl === void 0) {
@@ -1088,7 +1104,7 @@ function serviceLine(input) {
1088
1104
  }
1089
1105
  case "unstartable":
1090
1106
  return {
1091
- line: `${service} \u2014 ${state.model}, not running, and ${device} cannot start it for you: start it yourself, then it will be offered`
1107
+ line: `${service} \u2014 ${state.model}, not running, and ${device} cannot start it for you: start it yourself, then it will be offered` + (state.startableAs === void 0 ? "" : ` \u2014 or set "type": "${state.startableAs}" on it in ~/.byollm/config.json and byollm will start it for you`)
1092
1108
  };
1093
1109
  case "blocked": {
1094
1110
  const when = state.until === void 0 ? "it needs time, not a fix" : `back around ${clockTime(state.until)}`;
@@ -1395,7 +1411,7 @@ function realUpdateDeps(input) {
1395
1411
  }
1396
1412
 
1397
1413
  // src/backends/index.ts
1398
- import { backendDescriptor as backendDescriptor2 } from "@byollm/protocol";
1414
+ import { backendDescriptor as backendDescriptor3 } from "@byollm/protocol";
1399
1415
 
1400
1416
  // src/backends/claude-cli.ts
1401
1417
  import { execFile as execFile2 } from "child_process";
@@ -2392,7 +2408,7 @@ function stopReasonOf(result) {
2392
2408
 
2393
2409
  // src/backends/index.ts
2394
2410
  function createBackend(id, init) {
2395
- const kind = backendDescriptor2(id).class;
2411
+ const kind = backendDescriptor3(id).class;
2396
2412
  switch (kind) {
2397
2413
  // Process class dispatches by **id**, not by class, and the difference is
2398
2414
  // not stylistic. `case "process": return new ClaudeCliBackend()` was
@@ -4223,11 +4239,7 @@ var TEST_YOUR_DEVICE = "TEST YOUR DEVICE: Visit https://test.byollm.cloud and pr
4223
4239
  // src/diagnose.ts
4224
4240
  import { execFile as execFile4 } from "child_process";
4225
4241
  import { promisify as promisify2 } from "util";
4226
- import {
4227
- BACKEND_IDS,
4228
- backendDescriptor as backendDescriptor3,
4229
- backendName as backendName2
4230
- } from "@byollm/protocol";
4242
+ import { backendName as backendName2 } from "@byollm/protocol";
4231
4243
  var run = promisify2(execFile4);
4232
4244
  var BY_PORT = {
4233
4245
  "11434": {
@@ -4282,18 +4294,6 @@ var whichProbe = async (binary) => {
4282
4294
  return code === 1 || code === "ENOENT" ? false : void 0;
4283
4295
  }
4284
4296
  };
4285
- function startableAt(origin) {
4286
- for (const id of BACKEND_IDS) {
4287
- if (startCommandFor(id) === void 0) continue;
4288
- const address = backendDescriptor3(id).defaultBaseUrl;
4289
- if (address === void 0) continue;
4290
- try {
4291
- if (new URL(address).origin === origin) return id;
4292
- } catch {
4293
- }
4294
- }
4295
- return void 0;
4296
- }
4297
4297
  async function diagnoseRoute(input) {
4298
4298
  const onPath = input.onPath ?? whichProbe;
4299
4299
  const reach = input.reach ?? fetchProbe;
@@ -6446,10 +6446,12 @@ var Runner = class {
6446
6446
  usable = health.healthy && (health.models.length === 0 || modelPresent(health.models, route.model));
6447
6447
  const remedy = backend.signIn === void 0 ? {} : { signIn: backend.signIn };
6448
6448
  if (!health.healthy) {
6449
+ const baseUrl = this.#options.loaded.config.services[route.service]?.baseUrl;
6450
+ const onPath = this.#options.onPath === void 0 ? {} : { onPath: this.#options.onPath };
6449
6451
  const startable = await startability({
6450
6452
  id: route.backendId,
6451
- baseUrl: this.#options.loaded.config.services[route.service]?.baseUrl,
6452
- ...this.#options.onPath === void 0 ? {} : { onPath: this.#options.onPath }
6453
+ baseUrl,
6454
+ ...onPath
6453
6455
  });
6454
6456
  const starts = this.#options.spawnServer !== void 0;
6455
6457
  usable = startable.startable && starts;
@@ -6466,7 +6468,11 @@ var Runner = class {
6466
6468
  * Only `not-installed` is `missing`. The advertising decision is
6467
6469
  * unchanged: nothing here is offered either way.
6468
6470
  */
6469
- state: startable.startable ? { kind: "stopped", model: route.model, starts } : startable.why === "not-installed" ? { kind: "missing" } : { kind: "unstartable", model: route.model },
6471
+ state: startable.startable ? { kind: "stopped", model: route.model, starts } : startable.why === "not-installed" ? { kind: "missing" } : {
6472
+ kind: "unstartable",
6473
+ model: route.model,
6474
+ ...await this.#startableAs(route.backendId, baseUrl)
6475
+ },
6470
6476
  ...remedy
6471
6477
  });
6472
6478
  } else if (options.canary !== true || backend.canary === void 0) {
@@ -6861,6 +6867,33 @@ var Runner = class {
6861
6867
  * too, and none of them should be able to start a model server as a side
6862
6868
  * effect of asking a question.
6863
6869
  */
6870
+ /**
6871
+ * The type that WOULD be started at this address, for the owner's line —
6872
+ * B098's offer, reaching `byollm status`.
6873
+ *
6874
+ * Asks `startableAt`, the one function `byollm diagnose` asks, and then
6875
+ * asks `startability` of THAT type at this address — so the offer is made
6876
+ * only where taking it would actually work: loopback, a start command, and
6877
+ * the binary on PATH. Retyping a service into one that then reads "not
6878
+ * found" is a remedy that moves the problem rather than fixing it.
6879
+ */
6880
+ async #startableAs(configured, baseUrl) {
6881
+ if (baseUrl === void 0 || !isLoopback(baseUrl)) return {};
6882
+ let origin;
6883
+ try {
6884
+ origin = new URL(baseUrl).origin;
6885
+ } catch {
6886
+ return {};
6887
+ }
6888
+ const id = startableAt(origin);
6889
+ if (id === void 0 || id === configured) return {};
6890
+ const would = await startability({
6891
+ id,
6892
+ baseUrl,
6893
+ ...this.#options.onPath === void 0 ? {} : { onPath: this.#options.onPath }
6894
+ });
6895
+ return would.startable ? { startableAs: id } : {};
6896
+ }
6864
6897
  /**
6865
6898
  * Should this machine take a job that loads a model right now — B080.
6866
6899
  *
@@ -8782,6 +8815,7 @@ async function writeUnit(path, contents, encoding) {
8782
8815
 
8783
8816
  // src/service-states.ts
8784
8817
  import { readFile as readFile13, writeFile as writeFile8 } from "fs/promises";
8818
+ import { BackendIdSchema as BackendIdSchema2 } from "@byollm/protocol";
8785
8819
  import { z as z8 } from "zod";
8786
8820
  var Stored = z8.record(
8787
8821
  z8.string(),
@@ -8795,7 +8829,13 @@ var Stored = z8.record(
8795
8829
  z8.object({ kind: z8.literal("missing") }),
8796
8830
  /* B098. Stopped and unstartable is not the same as absent, and the
8797
8831
  file `byollm status` reads has to be able to tell them apart. */
8798
- z8.object({ kind: z8.literal("unstartable"), model: z8.string() }),
8832
+ z8.object({
8833
+ kind: z8.literal("unstartable"),
8834
+ model: z8.string(),
8835
+ /* An id this build does not know degrades to no offer, rather than
8836
+ failing the whole file and blanking every service's line. */
8837
+ startableAs: BackendIdSchema2.optional().catch(void 0)
8838
+ }),
8799
8839
  /**
8800
8840
  * Installed here, not running, and startable — B056.
8801
8841
  *
@@ -10884,7 +10924,7 @@ async function exists(path) {
10884
10924
  }
10885
10925
 
10886
10926
  // src/index.ts
10887
- var DAEMON_VERSION = "0.1.2";
10927
+ var DAEMON_VERSION = "0.1.3";
10888
10928
  function daemonVersion() {
10889
10929
  return {
10890
10930
  daemon: DAEMON_VERSION,
@@ -10943,4 +10983,4 @@ export {
10943
10983
  runCli,
10944
10984
  main
10945
10985
  };
10946
- //# sourceMappingURL=chunk-K7QYAF7V.js.map
10986
+ //# sourceMappingURL=chunk-PXL5HY2O.js.map