pinomad 0.5.0 → 0.6.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.
@@ -7,7 +7,7 @@ import {
7
7
  signRelayChallenge,
8
8
  signRelayChallengeV2,
9
9
  toBase64Url
10
- } from "./chunk-kmbh44dt.js";
10
+ } from "./chunk-7qb9tq54.js";
11
11
 
12
12
  // apps/host/src/cli/server-ops.ts
13
13
  import { WebSocket } from "ws";
@@ -18,7 +18,10 @@ async function probeAccounts(origin, fetchImpl = fallbackFetch) {
18
18
  const timeout = new AbortController;
19
19
  const timer = setTimeout(() => timeout.abort(), 5000);
20
20
  try {
21
- const response = await fetchImpl(`${origin.replace(/\/+$/, "")}/api/me`, { signal: timeout.signal });
21
+ const response = await fetchImpl(`${origin.replace(/\/+$/, "")}/api/me`, {
22
+ signal: timeout.signal,
23
+ redirect: "manual"
24
+ });
22
25
  if (response.status === 401)
23
26
  return "enabled";
24
27
  if (response.status === 200) {
@@ -46,7 +49,8 @@ function isSecureServerOrigin(origin) {
46
49
  return false;
47
50
  }
48
51
  const host = url.hostname;
49
- const loopback = host === "localhost" || host.endsWith(".localhost") || host.startsWith("127.") || host === "::1" || host === "[::1]";
52
+ const ipv4Loopback = /^127(?:\.\d{1,3}){3}$/.test(host);
53
+ const loopback = host === "localhost" || host.endsWith(".localhost") || ipv4Loopback || host === "::1" || host === "[::1]";
50
54
  return url.protocol === "https:" || url.protocol === "http:" && loopback;
51
55
  }
52
56
 
@@ -0,0 +1,33 @@
1
+ // packages/protocol/src/settings.ts
2
+ var HOST_SETTING_KEY_SET = {
3
+ defaultModel: true,
4
+ defaultThinkingLevel: true,
5
+ steeringMode: true,
6
+ followUpMode: true,
7
+ acceptAccountDevices: true,
8
+ hostName: true
9
+ };
10
+ var HOST_SETTING_KEYS = Object.keys(HOST_SETTING_KEY_SET);
11
+ var THINKING_LEVEL_KEYS = { off: true, minimal: true, low: true, medium: true, high: true, xhigh: true, max: true };
12
+ var THINKING_LEVELS = Object.keys(THINKING_LEVEL_KEYS);
13
+ var isThinkingLevel = (value) => typeof value === "string" && Object.prototype.hasOwnProperty.call(THINKING_LEVEL_KEYS, value);
14
+ var isQueueMode = (value) => value === "all" || value === "one-at-a-time";
15
+ var HOST_NAME_FALLBACK = "pinomad";
16
+ var HOST_NAME_MAX_UNITS = 64;
17
+ var isHostNameControl = (code) => code < 32 || code >= 127 && code <= 159;
18
+ function cleanHostName(name) {
19
+ let cleaned = name;
20
+ for (;; ) {
21
+ const local = cleaned.endsWith(".local") ? cleaned.slice(0, -".local".length) : cleaned;
22
+ const next = [...local.trim()].filter((c) => !isHostNameControl(c.codePointAt(0))).join("").slice(0, HOST_NAME_MAX_UNITS);
23
+ if (next === cleaned)
24
+ return next;
25
+ cleaned = next;
26
+ }
27
+ }
28
+ function normalizeHostName(name) {
29
+ const cleaned = cleanHostName(name);
30
+ return cleaned === "" ? HOST_NAME_FALLBACK : cleaned;
31
+ }
32
+
33
+ export { HOST_SETTING_KEYS, THINKING_LEVELS, isThinkingLevel, isQueueMode, HOST_NAME_MAX_UNITS, cleanHostName, normalizeHostName };
package/dist/pinomad.js CHANGED
@@ -1,28 +1,35 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ isParseArgsError,
4
+ reportParseArgsError
5
+ } from "./chunk-kzbzacz9.js";
2
6
  import {
3
7
  packagedVersion
4
- } from "./chunk-1d9sppj0.js";
8
+ } from "./chunk-c8nxym2z.js";
5
9
  import {
6
10
  __require
7
11
  } from "./chunk-df32avw6.js";
8
12
 
9
13
  // apps/cli/src/pinomad.ts
10
14
  var COMMANDS = {
11
- host: () => import("./chunk-d4wdt5qs.js"),
12
- server: () => import("./chunk-4by4x5c4.js"),
13
- relay: () => import("./chunk-4by4x5c4.js"),
14
- service: () => import("./chunk-5ng86fmy.js"),
15
- upgrade: () => import("./chunk-crv3dqzp.js"),
16
- link: () => import("./chunk-gqr7ahv4.js"),
17
- pair: () => import("./chunk-zttf1hvh.js"),
18
- join: () => import("./chunk-9d59jjmt.js"),
19
- leave: () => import("./chunk-f0v3sht0.js")
15
+ host: () => import("./chunk-4btj08we.js"),
16
+ server: () => import("./chunk-wqvp1fwh.js"),
17
+ relay: () => import("./chunk-wqvp1fwh.js"),
18
+ service: () => import("./chunk-ggb1taqy.js"),
19
+ upgrade: () => import("./chunk-jn7y815x.js"),
20
+ link: () => import("./chunk-367n9je8.js"),
21
+ pair: () => import("./chunk-7s1f4z4g.js"),
22
+ join: () => import("./chunk-k2s1hfq5.js"),
23
+ leave: () => import("./chunk-3dnnaz4j.js")
20
24
  };
21
25
  var USAGE = `pinomad — PiNomad host, server, and utilities
22
26
 
23
27
  usage: pinomad <command> [args…]
24
28
 
25
- host [host args…] run the host in the foreground
29
+ host [--data-dir DIR] [--port 7420] [--project DIR]… run the host in the foreground
30
+ host --remote-port PORT [--public-url URL] remote access, LAN (ADR-0008)
31
+ host --relay URL remote access via relay (ADR-0015)
32
+ host --faux "answer" [--faux-tps 40] no real model, for tests
26
33
  server --public-origin O [--data-dir D] [--trust-proxy] run the server
27
34
  server passwd [--data-dir D] [--user U] change the account password (stdin)
28
35
  relay … old name of server
@@ -34,6 +41,13 @@ usage: pinomad <command> [args…]
34
41
  leave [--data-dir D] leave the server account
35
42
  --version, -v print the version
36
43
  `;
44
+ function usageFor(command) {
45
+ const rows = USAGE.split(`
46
+ `).filter((line) => line.startsWith(` ${command} `));
47
+ return `usage: pinomad ${command} [args…]
48
+ ${rows.join(`
49
+ `)}`;
50
+ }
37
51
  async function main(argv) {
38
52
  const [command, ...rest] = argv;
39
53
  if (command === "--version" || command === "-v") {
@@ -51,7 +65,17 @@ async function main(argv) {
51
65
  process.exitCode = 1;
52
66
  return;
53
67
  }
54
- await (await load()).main(rest);
68
+ if (rest.includes("--help") || rest.includes("-h")) {
69
+ console.log(usageFor(command));
70
+ return;
71
+ }
72
+ try {
73
+ await (await load()).main(rest);
74
+ } catch (error) {
75
+ if (!isParseArgsError(error))
76
+ throw error;
77
+ reportParseArgsError(`pinomad ${command}`, error);
78
+ }
55
79
  }
56
80
  if (__require.main == __require.module)
57
81
  await main(process.argv.slice(2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinomad",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "PiNomad — self-hosted coding agent: host, relay, and web client in one package",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",