pinomad 0.2.0 → 0.3.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/web/index.html CHANGED
@@ -4,8 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>PiNomad</title>
7
- <script type="module" crossorigin src="/assets/index-4p91UVoc.js"></script>
8
- <link rel="stylesheet" crossorigin href="/assets/index-KwICnYux.css">
7
+ <script type="module" crossorigin src="/assets/index-CBXdQLua.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-CG33GBxM.css">
9
9
  </head>
10
10
  <body>
11
11
  <div id="root"></div>
@@ -1,92 +0,0 @@
1
- // packages/protocol/src/frames.ts
2
- var conversationStream = (id) => `conversation:${id}`;
3
- var docStream = (kind, id) => `doc:${kind}:${id}`;
4
- var UNAUTHORIZED_CLOSE_CODE = 4401;
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" };
10
- if (value.type === "subscribe" || value.type === "unsubscribe") {
11
- const stream = value.stream;
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 };
21
- }
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) {
54
- const conversationId = () => typeof args.conversationId === "number" && Number.isSafeInteger(args.conversationId) && args.conversationId >= 1;
55
- switch (method) {
56
- case "submit":
57
- return conversationId() && typeof args.text === "string" && (args.whenBusy === "steer" || args.whenBusy === "followUp") && nonempty(args.requestId);
58
- case "abort":
59
- return conversationId();
60
- case "setThinkingLevel":
61
- return conversationId() && nonempty(args.level);
62
- case "compact":
63
- return conversationId() && (args.instructions === undefined || typeof args.instructions === "string");
64
- case "setModel":
65
- return conversationId() && record(args.model) && nonempty(args.model.provider) && nonempty(args.model.modelId);
66
- case "fork":
67
- return conversationId() && typeof args.entryId === "string" && /^[1-9]\d*$/.test(args.entryId) && (args.removeTools === undefined || Array.isArray(args.removeTools) && args.removeTools.every(nonempty));
68
- case "answer":
69
- return conversationId() && nonempty(args.kind) && nonempty(args.requestId) && Array.isArray(args.answers) && args.answers.every((answer) => record(answer) && Array.isArray(answer.selected) && answer.selected.every((l) => typeof l === "string") && (answer.other === undefined || typeof answer.other === "string"));
70
- case "changes":
71
- return conversationId();
72
- case "addProject":
73
- case "removeProject":
74
- return nonempty(args.path);
75
- case "createConversation":
76
- return record(args.home) && (args.home.kind === "chat" || args.home.kind === "project" && nonempty(args.home.path)) && nonempty(args.text) && nonempty(args.requestId) && (args.checkout === undefined || args.checkout === "worktree" || args.checkout === "project") && (args.model === undefined || record(args.model) && nonempty(args.model.provider) && nonempty(args.model.modelId)) && (args.thinkingLevel === undefined || nonempty(args.thinkingLevel));
77
- case "archive":
78
- return conversationId() && typeof args.archived === "boolean";
79
- case "createPairing":
80
- return Object.keys(args).length === 0;
81
- case "revokeDevice":
82
- return nonempty(args.publicKey) && /^[A-Za-z0-9_-]+$/.test(args.publicKey);
83
- }
84
- }
85
- function record(value) {
86
- return value !== null && typeof value === "object" && !Array.isArray(value);
87
- }
88
- function nonempty(value) {
89
- return typeof value === "string" && value.length > 0;
90
- }
91
-
92
- export { conversationStream, docStream, UNAUTHORIZED_CLOSE_CODE, INVALID_FRAME_CLOSE_CODE, PROTOCOL, parseClientFrame };