pinomad 0.5.0 → 0.7.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.
- package/README.md +2 -2
- package/dist/{chunk-f0v3sht0.js → chunk-07769pqx.js} +10 -8
- package/dist/{chunk-ebfaf3k2.js → chunk-0xh6cy9v.js} +1 -1
- package/dist/{chunk-aqj4wg33.js → chunk-12kaxggg.js} +29 -12
- package/dist/{chunk-d4wdt5qs.js → chunk-1nyzr0mg.js} +2282 -1027
- package/dist/chunk-1t58fh0k.js +16 -0
- package/dist/{chunk-4by4x5c4.js → chunk-6ysezfy5.js} +44 -14
- package/dist/{chunk-kmbh44dt.js → chunk-7qb9tq54.js} +42 -6
- package/dist/{chunk-gqr7ahv4.js → chunk-8yme2wep.js} +2 -2
- package/dist/chunk-b1h374jr.js +159 -0
- package/dist/{chunk-hsp12cjt.js → chunk-e4ahjbmz.js} +212 -50
- package/dist/{chunk-9d59jjmt.js → chunk-fbkd73zr.js} +36 -10
- package/dist/chunk-kzbzacz9.js +12 -0
- package/dist/{chunk-zttf1hvh.js → chunk-m4c5gvce.js} +4 -3
- package/dist/{chunk-cjfmfyjb.js → chunk-ngf1zatm.js} +7 -6
- package/dist/{chunk-1d9sppj0.js → chunk-rtwxjb90.js} +1 -1
- package/dist/{chunk-m4q9wafw.js → chunk-sj7rnvh4.js} +118 -6
- package/dist/chunk-sz3rzk55.js +79 -0
- package/dist/{chunk-26d04z02.js → chunk-ywmm63ks.js} +7 -3
- package/dist/chunk-znhn8af7.js +33 -0
- package/dist/pinomad.js +36 -12
- package/package.json +1 -1
- package/web/assets/index-C0rwAo0H.css +1 -0
- package/web/assets/index-DGee2kNU.js +394 -0
- package/web/index.html +2 -2
- package/dist/chunk-5ng86fmy.js +0 -14
- package/dist/chunk-crv3dqzp.js +0 -63
- package/web/assets/index-BkF0-im5.css +0 -1
- package/web/assets/index-D4lgm3Y4.js +0 -383
- package/web/assets/montserrat-latin-ext-wght-normal-BsZE-iaG.woff2 +0 -0
- package/web/assets/montserrat-latin-wght-normal-l_AIctKy.woff2 +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HOST_STREAM_NAMES,
|
|
3
3
|
INVALID_FRAME_CLOSE_CODE,
|
|
4
|
+
MAX_ATTACHMENTS_PER_MESSAGE,
|
|
4
5
|
PROTOCOL,
|
|
5
6
|
UNAUTHORIZED_CLOSE_CODE,
|
|
6
7
|
checkoutOf,
|
|
@@ -11,7 +12,7 @@ import {
|
|
|
11
12
|
hostSupportsCall,
|
|
12
13
|
hostSupportsFeature,
|
|
13
14
|
organize
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-e4ahjbmz.js";
|
|
15
16
|
|
|
16
17
|
// packages/protocol/src/remote-durable.ts
|
|
17
18
|
import { applyImmutable } from "@earendil-works/chord/delta";
|
|
@@ -59,6 +60,13 @@ class ProtocolMismatchError extends Error {
|
|
|
59
60
|
this.direction = direction;
|
|
60
61
|
}
|
|
61
62
|
}
|
|
63
|
+
function needsImageRefs(images) {
|
|
64
|
+
return images.some((image) => {
|
|
65
|
+
const data = "data" in image ? image.data : "";
|
|
66
|
+
const ref = "ref" in image ? image.ref : "";
|
|
67
|
+
return data === "" && ref !== "";
|
|
68
|
+
});
|
|
69
|
+
}
|
|
62
70
|
|
|
63
71
|
class RemoteClient {
|
|
64
72
|
ready;
|
|
@@ -79,6 +87,7 @@ class RemoteClient {
|
|
|
79
87
|
#nextCall = 1;
|
|
80
88
|
#nextNotice = 1;
|
|
81
89
|
#hostMinor = 0;
|
|
90
|
+
#helloReceived = false;
|
|
82
91
|
#helloModels = [];
|
|
83
92
|
#helloDefaults = {};
|
|
84
93
|
#hostVersion;
|
|
@@ -98,6 +107,7 @@ class RemoteClient {
|
|
|
98
107
|
this.#open();
|
|
99
108
|
}
|
|
100
109
|
#open() {
|
|
110
|
+
this.#helloReceived = false;
|
|
101
111
|
const connection = this.#transport.open({
|
|
102
112
|
message: (data) => {
|
|
103
113
|
if (this.#connection === connection)
|
|
@@ -173,6 +183,7 @@ class RemoteClient {
|
|
|
173
183
|
}
|
|
174
184
|
const hostMinor = announced !== null && typeof announced === "object" && typeof announced.minor === "number" ? announced.minor : 0;
|
|
175
185
|
this.#hostMinor = hostMinor;
|
|
186
|
+
this.#helloReceived = true;
|
|
176
187
|
this.#attempt = 0;
|
|
177
188
|
this.#docs = frame.docs;
|
|
178
189
|
this.#toolPresentations = frame.toolPresentations;
|
|
@@ -197,7 +208,7 @@ class RemoteClient {
|
|
|
197
208
|
for (const stream of this.#conversationStreams(this.#side))
|
|
198
209
|
this.#wanted.add(stream);
|
|
199
210
|
for (const stream of this.#wanted)
|
|
200
|
-
this.#
|
|
211
|
+
this.#subscribe(stream);
|
|
201
212
|
if (this.#state !== undefined) {
|
|
202
213
|
this.#update({
|
|
203
214
|
session: frame.session,
|
|
@@ -286,7 +297,8 @@ class RemoteClient {
|
|
|
286
297
|
const shown = Promise.all([...missing, ...stale].map((stream) => this.#snapshot(stream)));
|
|
287
298
|
for (const stream of missing) {
|
|
288
299
|
this.#wanted.add(stream);
|
|
289
|
-
this.#
|
|
300
|
+
if (this.#helloReceived)
|
|
301
|
+
this.#subscribe(stream);
|
|
290
302
|
}
|
|
291
303
|
await shown;
|
|
292
304
|
}
|
|
@@ -301,6 +313,10 @@ class RemoteClient {
|
|
|
301
313
|
this.#send({ type: "unsubscribe", stream });
|
|
302
314
|
}
|
|
303
315
|
}
|
|
316
|
+
#subscribe(stream) {
|
|
317
|
+
const refs = stream.startsWith("conversation:") && hostSupportsFeature(this.#hostMinor, "imageRefs");
|
|
318
|
+
this.#send({ type: "subscribe", stream, ...refs ? { images: "ref" } : {} });
|
|
319
|
+
}
|
|
304
320
|
#host(name) {
|
|
305
321
|
return this.#values.get(name);
|
|
306
322
|
}
|
|
@@ -380,6 +396,9 @@ class RemoteClient {
|
|
|
380
396
|
listener();
|
|
381
397
|
});
|
|
382
398
|
}
|
|
399
|
+
#boundSkills(skills) {
|
|
400
|
+
return skills === undefined || !hostSupportsFeature(this.#hostMinor, "boundSkills") ? {} : { skills };
|
|
401
|
+
}
|
|
383
402
|
#notice(level, message) {
|
|
384
403
|
if (this.#state === undefined)
|
|
385
404
|
return;
|
|
@@ -440,6 +459,16 @@ class RemoteClient {
|
|
|
440
459
|
if (images.length > 0 && !hostSupportsFeature(this.#hostMinor, "images")) {
|
|
441
460
|
throw new Error("The host is too old for images (needs protocol 5.5); run `pinomad upgrade` on the host");
|
|
442
461
|
}
|
|
462
|
+
if (needsImageRefs(images) && !hostSupportsFeature(this.#hostMinor, "imageRefs")) {
|
|
463
|
+
throw new Error("The host is too old for image refs (needs protocol 5.15); run `pinomad upgrade` on the host");
|
|
464
|
+
}
|
|
465
|
+
const attachments = options?.attachments ?? [];
|
|
466
|
+
if (attachments.length > MAX_ATTACHMENTS_PER_MESSAGE) {
|
|
467
|
+
throw new Error(`At most ${MAX_ATTACHMENTS_PER_MESSAGE} attachments per message`);
|
|
468
|
+
}
|
|
469
|
+
if (attachments.length > 0 && !hostSupportsFeature(this.#hostMinor, "attachments")) {
|
|
470
|
+
throw new Error("The host is too old for attachments (needs protocol 5.19); run `pinomad upgrade` on the host");
|
|
471
|
+
}
|
|
443
472
|
if (options?.agent !== undefined && !hostSupportsFeature(this.#hostMinor, "agentConversations")) {
|
|
444
473
|
throw new Error("The host is too old for named agents (needs protocol 5.10); run `pinomad upgrade` on the host");
|
|
445
474
|
}
|
|
@@ -451,7 +480,9 @@ class RemoteClient {
|
|
|
451
480
|
...options?.model === undefined ? {} : { model: options.model },
|
|
452
481
|
...options?.thinkingLevel === undefined ? {} : { thinkingLevel: options.thinkingLevel },
|
|
453
482
|
...options?.agent === undefined ? {} : { agent: options.agent },
|
|
454
|
-
...images.length === 0 ? {} : { images }
|
|
483
|
+
...images.length === 0 ? {} : { images },
|
|
484
|
+
...this.#boundSkills(options?.skills),
|
|
485
|
+
...attachments.length === 0 ? {} : { attachments }
|
|
455
486
|
});
|
|
456
487
|
await this.#switch(conversationId2);
|
|
457
488
|
}),
|
|
@@ -467,15 +498,37 @@ class RemoteClient {
|
|
|
467
498
|
if (images.length > 0 && !hostSupportsFeature(this.#hostMinor, "images")) {
|
|
468
499
|
throw new Error("The host is too old for images (needs protocol 5.5); run `pinomad upgrade` on the host");
|
|
469
500
|
}
|
|
501
|
+
if (needsImageRefs(images) && !hostSupportsFeature(this.#hostMinor, "imageRefs")) {
|
|
502
|
+
throw new Error("The host is too old for image refs (needs protocol 5.15); run `pinomad upgrade` on the host");
|
|
503
|
+
}
|
|
504
|
+
const attachments = options?.attachments ?? [];
|
|
505
|
+
if (attachments.length > MAX_ATTACHMENTS_PER_MESSAGE) {
|
|
506
|
+
throw new Error(`At most ${MAX_ATTACHMENTS_PER_MESSAGE} attachments per message`);
|
|
507
|
+
}
|
|
508
|
+
if (attachments.length > 0 && !hostSupportsFeature(this.#hostMinor, "attachments")) {
|
|
509
|
+
throw new Error("The host is too old for attachments (needs protocol 5.19); run `pinomad upgrade` on the host");
|
|
510
|
+
}
|
|
470
511
|
return this.#call("submit", {
|
|
471
512
|
conversationId: options?.target ?? conversationId(),
|
|
472
513
|
text,
|
|
473
514
|
whenBusy,
|
|
474
515
|
requestId: options?.requestId ?? newRequestId(),
|
|
475
|
-
...images.length === 0 ? {} : { images }
|
|
516
|
+
...images.length === 0 ? {} : { images },
|
|
517
|
+
...this.#boundSkills(options?.skills),
|
|
518
|
+
...attachments.length === 0 ? {} : { attachments }
|
|
476
519
|
});
|
|
477
520
|
}),
|
|
478
521
|
compact: (instructions) => this.#command(() => this.#call("compact", { conversationId: conversationId(), ...instructions === undefined ? {} : { instructions } })),
|
|
522
|
+
runCommand: (name, args, target) => this.#command(() => {
|
|
523
|
+
if (!hostSupportsCall(this.#hostMinor, "runCommand")) {
|
|
524
|
+
throw new Error("The host is too old for this (needs protocol 5.17); run `pinomad upgrade` on the host");
|
|
525
|
+
}
|
|
526
|
+
return this.#call("runCommand", {
|
|
527
|
+
conversationId: target ?? conversationId(),
|
|
528
|
+
name,
|
|
529
|
+
...args === undefined ? {} : { args }
|
|
530
|
+
});
|
|
531
|
+
}),
|
|
479
532
|
abort: (target) => {
|
|
480
533
|
const targetConversation = target ?? this.#current;
|
|
481
534
|
if (targetConversation === undefined) {
|
|
@@ -484,8 +537,34 @@ class RemoteClient {
|
|
|
484
537
|
}
|
|
485
538
|
return this.#call("abort", { conversationId: targetConversation }).then(() => {}, (error) => this.#notice("error", error instanceof Error ? error.message : String(error)));
|
|
486
539
|
},
|
|
540
|
+
withdrawQueued: (submissionId, target) => this.#request(async () => {
|
|
541
|
+
if (!hostSupportsCall(this.#hostMinor, "withdrawQueued")) {
|
|
542
|
+
throw new Error("The host is too old for this (needs protocol 5.14); run `pinomad upgrade` on the host");
|
|
543
|
+
}
|
|
544
|
+
const { outcome } = await this.#call("withdrawQueued", {
|
|
545
|
+
conversationId: target ?? conversationId(),
|
|
546
|
+
submissionId
|
|
547
|
+
});
|
|
548
|
+
return outcome;
|
|
549
|
+
}),
|
|
550
|
+
steerQueued: (submissionId, target) => this.#request(async () => {
|
|
551
|
+
if (!hostSupportsCall(this.#hostMinor, "steerQueued")) {
|
|
552
|
+
throw new Error("The host is too old for this (needs protocol 5.14); run `pinomad upgrade` on the host");
|
|
553
|
+
}
|
|
554
|
+
const { outcome } = await this.#call("steerQueued", {
|
|
555
|
+
conversationId: target ?? conversationId(),
|
|
556
|
+
submissionId
|
|
557
|
+
});
|
|
558
|
+
return outcome;
|
|
559
|
+
}),
|
|
487
560
|
setThinkingLevel: (level) => this.#command(() => this.#call("setThinkingLevel", { conversationId: conversationId(), level })),
|
|
488
561
|
setModel: (model) => this.#command(() => this.#call("setModel", { conversationId: conversationId(), model })),
|
|
562
|
+
setAgent: (agent) => this.#command(() => {
|
|
563
|
+
if (!hostSupportsCall(this.#hostMinor, "setAgent")) {
|
|
564
|
+
throw new Error("The host is too old for this (needs protocol 5.18); run `pinomad upgrade` on the host");
|
|
565
|
+
}
|
|
566
|
+
return this.#call("setAgent", { conversationId: conversationId(), agent });
|
|
567
|
+
}),
|
|
489
568
|
toggleTasks: () => this.#command(async () => {
|
|
490
569
|
if (this.#wanted.delete("tasks")) {
|
|
491
570
|
this.#send({ type: "unsubscribe", stream: "tasks" });
|
|
@@ -520,6 +599,36 @@ class RemoteClient {
|
|
|
520
599
|
}
|
|
521
600
|
return this.#call("listFiles", { scope, query });
|
|
522
601
|
},
|
|
602
|
+
beginAttachment: (name, size) => {
|
|
603
|
+
if (!hostSupportsCall(this.#hostMinor, "beginAttachment")) {
|
|
604
|
+
return Promise.reject(new Error("The host is too old for attachments (needs protocol 5.19); run `pinomad upgrade` on the host"));
|
|
605
|
+
}
|
|
606
|
+
return this.#call("beginAttachment", { name, size }).then(({ attachmentId }) => attachmentId);
|
|
607
|
+
},
|
|
608
|
+
appendAttachment: (attachmentId, offset, data) => {
|
|
609
|
+
if (!hostSupportsCall(this.#hostMinor, "appendAttachment")) {
|
|
610
|
+
return Promise.reject(new Error("The host is too old for attachments (needs protocol 5.19); run `pinomad upgrade` on the host"));
|
|
611
|
+
}
|
|
612
|
+
return this.#call("appendAttachment", { attachmentId, offset, data });
|
|
613
|
+
},
|
|
614
|
+
image: (ref) => {
|
|
615
|
+
if (!hostSupportsCall(this.#hostMinor, "image")) {
|
|
616
|
+
return Promise.reject(new Error("The host is too old for this (needs protocol 5.15); run `pinomad upgrade` on the host"));
|
|
617
|
+
}
|
|
618
|
+
return this.#call("image", { ref });
|
|
619
|
+
},
|
|
620
|
+
listSkills: (scope) => {
|
|
621
|
+
if (!hostSupportsCall(this.#hostMinor, "listSkills")) {
|
|
622
|
+
return Promise.reject(new Error("The host is too old for this (needs protocol 5.13); run `pinomad upgrade` on the host"));
|
|
623
|
+
}
|
|
624
|
+
return this.#call("listSkills", { scope });
|
|
625
|
+
},
|
|
626
|
+
listCommands: (id) => {
|
|
627
|
+
if (!hostSupportsCall(this.#hostMinor, "listCommands")) {
|
|
628
|
+
return Promise.reject(new Error("The host is too old for this (needs protocol 5.17); run `pinomad upgrade` on the host"));
|
|
629
|
+
}
|
|
630
|
+
return this.#call("listCommands", { conversationId: id });
|
|
631
|
+
},
|
|
523
632
|
createPairing: () => this.#request(() => this.#call("createPairing", {})),
|
|
524
633
|
revokeDevice: (publicKey) => this.#command(() => this.#call("revokeDevice", { publicKey })),
|
|
525
634
|
logout: (providerId) => this.#command(() => {
|
|
@@ -535,6 +644,9 @@ class RemoteClient {
|
|
|
535
644
|
if (patch.acceptAccountDevices !== undefined && !hostSupportsFeature(this.#hostMinor, "acceptAccountDevices")) {
|
|
536
645
|
throw new Error("The host is too old for this (needs protocol 5.8); run `pinomad upgrade` on the host");
|
|
537
646
|
}
|
|
647
|
+
if (patch.hostName !== undefined && !hostSupportsFeature(this.#hostMinor, "hostName")) {
|
|
648
|
+
throw new Error("The host is too old for this (needs protocol 5.12); run `pinomad upgrade` on the host");
|
|
649
|
+
}
|
|
538
650
|
return this.#call("updateSettings", { patch });
|
|
539
651
|
}),
|
|
540
652
|
createAgent: (role) => this.#request(async () => {
|
|
@@ -604,4 +716,4 @@ class RemoteClient {
|
|
|
604
716
|
}
|
|
605
717
|
}
|
|
606
718
|
|
|
607
|
-
export { connectRemoteDurable };
|
|
719
|
+
export { connectRemoteDurable, ProtocolMismatchError };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
restartService,
|
|
4
|
+
serviceManager
|
|
5
|
+
} from "./chunk-12kaxggg.js";
|
|
6
|
+
import"./chunk-kzbzacz9.js";
|
|
7
|
+
import {
|
|
8
|
+
globalPrefixOf,
|
|
9
|
+
packageDir,
|
|
10
|
+
packagedVersion
|
|
11
|
+
} from "./chunk-rtwxjb90.js";
|
|
12
|
+
import"./chunk-sj7rnvh4.js";
|
|
13
|
+
import"./chunk-e4ahjbmz.js";
|
|
14
|
+
import"./chunk-znhn8af7.js";
|
|
15
|
+
import {
|
|
16
|
+
hostAddressOptions
|
|
17
|
+
} from "./chunk-ngf1zatm.js";
|
|
18
|
+
import"./chunk-df32avw6.js";
|
|
19
|
+
|
|
20
|
+
// apps/host/src/cli/upgrade.ts
|
|
21
|
+
import { execFile, spawn } from "node:child_process";
|
|
22
|
+
import { fileURLToPath } from "node:url";
|
|
23
|
+
import { parseArgs, promisify } from "node:util";
|
|
24
|
+
var exec = promisify(execFile);
|
|
25
|
+
var repoRoot = fileURLToPath(new URL("../../../../", import.meta.url));
|
|
26
|
+
var step = (command, args) => new Promise((resolve) => {
|
|
27
|
+
spawn(command, [...args], { cwd: repoRoot, stdio: "inherit" }).once("exit", (code) => resolve(code ?? 1));
|
|
28
|
+
});
|
|
29
|
+
var serviceInstalled = () => Promise.resolve().then(() => serviceManager().state()).then((state) => state.installed, () => false);
|
|
30
|
+
async function main(argv, deps = {}) {
|
|
31
|
+
const { values } = parseArgs({
|
|
32
|
+
args: [...argv],
|
|
33
|
+
options: { force: { type: "boolean", default: false }, ...hostAddressOptions }
|
|
34
|
+
});
|
|
35
|
+
const run = deps.run ?? ((command, args) => exec(command, args, { cwd: repoRoot }));
|
|
36
|
+
const runStep = deps.step ?? step;
|
|
37
|
+
const restart = deps.restart ?? restartService;
|
|
38
|
+
if (packagedVersion === undefined) {
|
|
39
|
+
const { stdout } = await run("git", ["status", "--porcelain"]);
|
|
40
|
+
if (stdout.trim() !== "") {
|
|
41
|
+
console.error("upgrade: the checkout has uncommitted changes; commit or stash them first");
|
|
42
|
+
process.exitCode = 1;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
for (const [command, args] of [
|
|
46
|
+
["git", ["pull", "--ff-only"]],
|
|
47
|
+
["bun", ["install"]],
|
|
48
|
+
["bun", ["run", "build"]]
|
|
49
|
+
]) {
|
|
50
|
+
const code = await runStep(command, args);
|
|
51
|
+
if (code !== 0) {
|
|
52
|
+
process.exitCode = code;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
const prefix = globalPrefixOf(packageDir);
|
|
58
|
+
if (prefix === undefined) {
|
|
59
|
+
console.error(`upgrade: pinomad isn't a global npm install (${packageDir}); upgrade it the way it was installed`);
|
|
60
|
+
process.exitCode = 1;
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const code = await runStep("npm", ["install", "-g", "--prefix", prefix, "pinomad@latest"]);
|
|
64
|
+
if (code !== 0) {
|
|
65
|
+
process.exitCode = code;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!await (deps.serviceInstalled ?? serviceInstalled)()) {
|
|
70
|
+
console.log("service not installed; upgrade done, nothing restarted");
|
|
71
|
+
process.exitCode = 0;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
(deps.exit ?? process.exit)(await restart({ force: values.force, argv: argv.filter((arg) => arg !== "--force") }));
|
|
75
|
+
}
|
|
76
|
+
if (false) {}
|
|
77
|
+
export {
|
|
78
|
+
main
|
|
79
|
+
};
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
signRelayChallenge,
|
|
8
8
|
signRelayChallengeV2,
|
|
9
9
|
toBase64Url
|
|
10
|
-
} from "./chunk-
|
|
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`, {
|
|
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
|
|
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-
|
|
8
|
+
} from "./chunk-rtwxjb90.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-
|
|
12
|
-
server: () => import("./chunk-
|
|
13
|
-
relay: () => import("./chunk-
|
|
14
|
-
service: () => import("./chunk-
|
|
15
|
-
upgrade: () => import("./chunk-
|
|
16
|
-
link: () => import("./chunk-
|
|
17
|
-
pair: () => import("./chunk-
|
|
18
|
-
join: () => import("./chunk-
|
|
19
|
-
leave: () => import("./chunk-
|
|
15
|
+
host: () => import("./chunk-1nyzr0mg.js"),
|
|
16
|
+
server: () => import("./chunk-6ysezfy5.js"),
|
|
17
|
+
relay: () => import("./chunk-6ysezfy5.js"),
|
|
18
|
+
service: () => import("./chunk-1t58fh0k.js"),
|
|
19
|
+
upgrade: () => import("./chunk-sz3rzk55.js"),
|
|
20
|
+
link: () => import("./chunk-8yme2wep.js"),
|
|
21
|
+
pair: () => import("./chunk-m4c5gvce.js"),
|
|
22
|
+
join: () => import("./chunk-fbkd73zr.js"),
|
|
23
|
+
leave: () => import("./chunk-07769pqx.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 [
|
|
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
|
-
|
|
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));
|