pinomad 0.1.1 → 0.2.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 +4 -2
- package/dist/{chunk-9z7echn7.js → chunk-5712fvyp.js} +4 -4
- package/dist/{chunk-y73t2jmc.js → chunk-5h97zxag.js} +119 -41
- package/dist/{chunk-zx77w1nm.js → chunk-d9q0dz8s.js} +2 -2
- package/dist/{chunk-mqbg2cbw.js → chunk-fhtkkcgt.js} +390 -158
- package/dist/{chunk-wgn3cx5q.js → chunk-h35fermn.js} +48 -12
- package/dist/{chunk-tpd3trvd.js → chunk-haycqqp1.js} +1 -1
- package/dist/{chunk-8h3wrn84.js → chunk-n4bvmcy8.js} +4 -4
- package/dist/{chunk-hsdzb73r.js → chunk-q26n39mf.js} +10 -4
- package/dist/{chunk-ne6a5q2j.js → chunk-qdxhqva8.js} +1 -1
- package/dist/{chunk-fpb6f9n5.js → chunk-rkfdsacq.js} +1 -1
- package/dist/pinomad.js +7 -7
- package/package.json +1 -1
- package/web/assets/index-4p91UVoc.js +383 -0
- package/web/assets/index-KwICnYux.css +1 -0
- package/web/index.html +2 -2
- package/web/assets/index-B9yvK0AN.js +0 -383
- package/web/assets/index-t5dAiohJ.css +0 -1
|
@@ -2,19 +2,57 @@
|
|
|
2
2
|
var conversationStream = (id) => `conversation:${id}`;
|
|
3
3
|
var docStream = (kind, id) => `doc:${kind}:${id}`;
|
|
4
4
|
var UNAUTHORIZED_CLOSE_CODE = 4401;
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
var INVALID_FRAME_CLOSE_CODE = 4400;
|
|
6
|
+
var PROTOCOL = { major: 5, minor: 0 };
|
|
7
|
+
function parseClientFrame(value) {
|
|
8
|
+
if (!record(value) || typeof value.type !== "string")
|
|
9
|
+
return { kind: "malformed" };
|
|
9
10
|
if (value.type === "subscribe" || value.type === "unsubscribe") {
|
|
10
11
|
const stream = value.stream;
|
|
11
|
-
|
|
12
|
+
if (typeof stream !== "string")
|
|
13
|
+
return { kind: "malformed" };
|
|
14
|
+
if (isStreamName(stream)) {
|
|
15
|
+
return { kind: "frame", frame: { type: value.type, stream } };
|
|
16
|
+
}
|
|
17
|
+
const prefix = stream.slice(0, stream.indexOf(":") === -1 ? undefined : stream.indexOf(":"));
|
|
18
|
+
if (STREAM_KINDS.has(prefix))
|
|
19
|
+
return { kind: "malformed" };
|
|
20
|
+
return { kind: "unsupportedStream", type: value.type, stream };
|
|
12
21
|
}
|
|
13
|
-
if (value.type !== "call"
|
|
14
|
-
return
|
|
15
|
-
const args = value
|
|
22
|
+
if (value.type !== "call")
|
|
23
|
+
return { kind: "unknownType" };
|
|
24
|
+
const { id, method, args } = value;
|
|
25
|
+
if (typeof id !== "number" || !Number.isSafeInteger(id) || !record(args) || typeof method !== "string") {
|
|
26
|
+
return { kind: "malformed" };
|
|
27
|
+
}
|
|
28
|
+
if (!isCallMethod(method))
|
|
29
|
+
return { kind: "unsupportedCall", id, method };
|
|
30
|
+
return validCallArgs(method, args) ? { kind: "frame", frame: { type: "call", id, method, args } } : { kind: "malformed" };
|
|
31
|
+
}
|
|
32
|
+
var STREAM_KINDS = new Set(["conversation", "doc", "tasks", "conversations", "index", "devices", "mcp"]);
|
|
33
|
+
function isStreamName(stream) {
|
|
34
|
+
return stream === "tasks" || stream === "conversations" || stream === "index" || stream === "devices" || stream === "mcp" || /^(?:conversation:|doc:.+:)[1-9]\d*$/.test(stream);
|
|
35
|
+
}
|
|
36
|
+
var isCallMethod = (method) => CALL_METHODS.includes(method);
|
|
37
|
+
var CALL_METHODS = [
|
|
38
|
+
"addProject",
|
|
39
|
+
"removeProject",
|
|
40
|
+
"createConversation",
|
|
41
|
+
"archive",
|
|
42
|
+
"submit",
|
|
43
|
+
"abort",
|
|
44
|
+
"compact",
|
|
45
|
+
"setModel",
|
|
46
|
+
"setThinkingLevel",
|
|
47
|
+
"fork",
|
|
48
|
+
"answer",
|
|
49
|
+
"changes",
|
|
50
|
+
"createPairing",
|
|
51
|
+
"revokeDevice"
|
|
52
|
+
];
|
|
53
|
+
function validCallArgs(method, args) {
|
|
16
54
|
const conversationId = () => typeof args.conversationId === "number" && Number.isSafeInteger(args.conversationId) && args.conversationId >= 1;
|
|
17
|
-
switch (
|
|
55
|
+
switch (method) {
|
|
18
56
|
case "submit":
|
|
19
57
|
return conversationId() && typeof args.text === "string" && (args.whenBusy === "steer" || args.whenBusy === "followUp") && nonempty(args.requestId);
|
|
20
58
|
case "abort":
|
|
@@ -42,8 +80,6 @@ function isClientFrame(value) {
|
|
|
42
80
|
return Object.keys(args).length === 0;
|
|
43
81
|
case "revokeDevice":
|
|
44
82
|
return nonempty(args.publicKey) && /^[A-Za-z0-9_-]+$/.test(args.publicKey);
|
|
45
|
-
default:
|
|
46
|
-
return false;
|
|
47
83
|
}
|
|
48
84
|
}
|
|
49
85
|
function record(value) {
|
|
@@ -53,4 +89,4 @@ function nonempty(value) {
|
|
|
53
89
|
return typeof value === "string" && value.length > 0;
|
|
54
90
|
}
|
|
55
91
|
|
|
56
|
-
export { conversationStream, docStream, UNAUTHORIZED_CLOSE_CODE,
|
|
92
|
+
export { conversationStream, docStream, UNAUTHORIZED_CLOSE_CODE, INVALID_FRAME_CLOSE_CODE, PROTOCOL, parseClientFrame };
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import {
|
|
3
3
|
restartService,
|
|
4
4
|
serviceManager
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-d9q0dz8s.js";
|
|
6
6
|
import {
|
|
7
7
|
globalPrefixOf,
|
|
8
8
|
packageDir,
|
|
9
9
|
packagedVersion
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import"./chunk-
|
|
12
|
-
import"./chunk-
|
|
10
|
+
} from "./chunk-rkfdsacq.js";
|
|
11
|
+
import"./chunk-5h97zxag.js";
|
|
12
|
+
import"./chunk-h35fermn.js";
|
|
13
13
|
import"./chunk-cjfmfyjb.js";
|
|
14
14
|
import"./chunk-df32avw6.js";
|
|
15
15
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
connectRemoteDurable
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import"./chunk-
|
|
3
|
+
} from "./chunk-5h97zxag.js";
|
|
4
|
+
import"./chunk-h35fermn.js";
|
|
5
5
|
import {
|
|
6
6
|
hostAddress
|
|
7
7
|
} from "./chunk-cjfmfyjb.js";
|
|
@@ -13,8 +13,14 @@ async function printPairing({ url, token }) {
|
|
|
13
13
|
const remote = await connectRemoteDurable({ url, token, reconnectDelayMs: { min: 200, max: 2000 } });
|
|
14
14
|
try {
|
|
15
15
|
const { url: pairing, expiresAt } = await remote.controller.createPairing();
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
if (new URL(pairing).hostname === "127.0.0.1") {
|
|
17
|
+
console.log(pairing);
|
|
18
|
+
console.log("This link only works on this machine — give it to the desktop app.");
|
|
19
|
+
console.log("To pair a phone, restart the host with --remote-port or --relay, then run pair again.");
|
|
20
|
+
} else {
|
|
21
|
+
console.log(renderUnicodeCompact(pairing));
|
|
22
|
+
console.log(pairing);
|
|
23
|
+
}
|
|
18
24
|
console.log(`Expires at ${new Date(expiresAt).toLocaleTimeString()}`);
|
|
19
25
|
} finally {
|
|
20
26
|
remote.close();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// apps/host/src/distribution.ts
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
var packagedVersion = "0.
|
|
3
|
+
var packagedVersion = "0.2.0";
|
|
4
4
|
var webRoot = fileURLToPath(new URL(packagedVersion === undefined ? "../../web/dist" : "../web/", import.meta.url));
|
|
5
5
|
var hostEntry = packagedVersion === undefined ? { script: fileURLToPath(new URL("./main.ts", import.meta.url)), args: [] } : { script: fileURLToPath(new URL("./pinomad.js", import.meta.url)), args: ["host"] };
|
|
6
6
|
var commandHint = (name) => packagedVersion === undefined ? `bun run ${name}` : `pinomad ${name}`;
|
package/dist/pinomad.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
packagedVersion
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-rkfdsacq.js";
|
|
5
5
|
import {
|
|
6
6
|
__require
|
|
7
7
|
} from "./chunk-df32avw6.js";
|
|
8
8
|
|
|
9
9
|
// apps/cli/src/pinomad.ts
|
|
10
10
|
var COMMANDS = {
|
|
11
|
-
host: () => import("./chunk-
|
|
12
|
-
relay: () => import("./chunk-
|
|
13
|
-
service: () => import("./chunk-
|
|
14
|
-
upgrade: () => import("./chunk-
|
|
15
|
-
link: () => import("./chunk-
|
|
16
|
-
pair: () => import("./chunk-
|
|
11
|
+
host: () => import("./chunk-fhtkkcgt.js"),
|
|
12
|
+
relay: () => import("./chunk-qdxhqva8.js"),
|
|
13
|
+
service: () => import("./chunk-5712fvyp.js"),
|
|
14
|
+
upgrade: () => import("./chunk-n4bvmcy8.js"),
|
|
15
|
+
link: () => import("./chunk-haycqqp1.js"),
|
|
16
|
+
pair: () => import("./chunk-q26n39mf.js"),
|
|
17
17
|
"relay-id": () => import("./chunk-7fqn69ys.js")
|
|
18
18
|
};
|
|
19
19
|
var USAGE = `pinomad — PiNomad host, relay, and utilities
|