nolo-cli 0.8.0-alpha.2 → 0.8.0-alpha.20
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 +1 -1
- package/_executeModel-WRUCQIV5.js +205 -0
- package/action-R4M4ORGA.js +28 -0
- package/addContentAction-UYFFTEWJ.js +26 -0
- package/addDialogAgentAction-OT4XZAVP.js +68 -0
- package/agentDeleteCommand-5DD2IM3J.js +327 -0
- package/agentEmailCommands-IASM2YBQ.js +628 -0
- package/agentListCommands-I6KZYCIG.js +223 -0
- package/agentMachineCommands-OUP3YQP7.js +425 -0
- package/agentPullCommand-O2MTUAFR.js +122 -0
- package/agentRecordCommands-QKGE2JTA.js +96 -0
- package/agentRunCommand-TVZXUBQ5.js +114 -0
- package/agentRunControl-K4VKNEHF.js +57 -0
- package/agentRuntimeLocal-ZYEIPTY4.js +104 -0
- package/agentSlice-T4PMW7W6.js +42 -0
- package/authCommand-EB5JSOX5.js +581 -0
- package/authCommands-XPEHTKSM.js +35 -0
- package/chunk-2EHX7F5G.js +1948 -0
- package/chunk-2FTTDCD4.js +675 -0
- package/chunk-3ASDTTEI.js +1774 -0
- package/chunk-3EUW3WEO.js +8 -0
- package/chunk-3LY4F7SV.js +9293 -0
- package/chunk-4CQLVGRV.js +50 -0
- package/chunk-4FBRSEV4.js +573 -0
- package/chunk-4IJYA27C.js +342 -0
- package/chunk-4QEWT7KD.js +933 -0
- package/chunk-4SN6J65J.js +38 -0
- package/chunk-4VNS5WPM.js +42 -0
- package/chunk-4ZDM73SD.js +34 -0
- package/chunk-5CS33IBL.js +301 -0
- package/chunk-5KLGBAAR.js +386 -0
- package/chunk-5MIDPSSK.js +206 -0
- package/chunk-5MMAK75Q.js +15 -0
- package/chunk-5W3VUFOX.js +34 -0
- package/chunk-63W5N6P3.js +150 -0
- package/chunk-6HYVJV7B.js +102 -0
- package/chunk-6WD3OOJS.js +20 -0
- package/chunk-7DAJ4AI4.js +191 -0
- package/chunk-7KCUSYT2.js +354 -0
- package/chunk-7T5PWAZN.js +171 -0
- package/chunk-AFON4QUU.js +112 -0
- package/chunk-AGFH73SK.js +239 -0
- package/chunk-ATNTHIZI.js +13 -0
- package/chunk-AVMKZHBC.js +85 -0
- package/chunk-AZPCASRE.js +36 -0
- package/chunk-BBYVOSU2.js +792 -0
- package/chunk-BCIOM4NZ.js +1078 -0
- package/chunk-C3RUNRHT.js +51 -0
- package/chunk-C4FTUXVF.js +146 -0
- package/chunk-CF2WZF4N.js +134 -0
- package/chunk-CF7PE763.js +10 -0
- package/chunk-CKOJQDKR.js +198 -0
- package/chunk-CMKUBIGW.js +1550 -0
- package/chunk-CWMSB67P.js +34 -0
- package/chunk-DCOA4QSN.js +105 -0
- package/chunk-DFFIZ25G.js +30 -0
- package/chunk-DWLEOOGR.js +8 -0
- package/chunk-DZ3XJVET.js +231 -0
- package/chunk-EHLHSX7R.js +1433 -0
- package/chunk-FM5IVZXO.js +4723 -0
- package/chunk-FVYY6MCS.js +1447 -0
- package/chunk-G3SUCT4W.js +8 -0
- package/chunk-GAKEBQD6.js +30 -0
- package/chunk-GBRG75BQ.js +86 -0
- package/chunk-GLYVN7EQ.js +238 -0
- package/chunk-H33743XH.js +25 -0
- package/chunk-HNMXYYJR.js +12 -0
- package/chunk-HNW7IJSK.js +71 -0
- package/chunk-I42VC5KR.js +15 -0
- package/chunk-IDZTNRP2.js +85 -0
- package/chunk-IHBCLYEE.js +22310 -0
- package/chunk-IJGXKGXW.js +421 -0
- package/chunk-ISNCLGUZ.js +146 -0
- package/chunk-IWX4UW2E.js +548 -0
- package/chunk-JBTJAPUF.js +35 -0
- package/chunk-JEXVIMYZ.js +55 -0
- package/chunk-JRKKFRAV.js +537 -0
- package/chunk-JZPBVBIY.js +94 -0
- package/chunk-K6BPOQLF.js +2052 -0
- package/chunk-K777STIO.js +478 -0
- package/chunk-KKY4B2Q2.js +21 -0
- package/chunk-KQHGZWSV.js +63 -0
- package/chunk-KUG52IAP.js +8 -0
- package/chunk-KX6YBIHG.js +8 -0
- package/chunk-LCBAMY2M.js +60 -0
- package/chunk-LM6IYQ3F.js +16 -0
- package/chunk-LTRXGFMS.js +83 -0
- package/chunk-M76ECQRD.js +13658 -0
- package/chunk-MNJDFJND.js +222 -0
- package/chunk-MRC4Q34M.js +188 -0
- package/chunk-MTU75CZ2.js +91 -0
- package/chunk-N54XAP77.js +19 -0
- package/chunk-O2ZNTTET.js +3272 -0
- package/chunk-O4BU24WZ.js +3212 -0
- package/chunk-OLZBQWZU.js +6 -0
- package/chunk-OPZYGHUC.js +89 -0
- package/chunk-OWOHNGCN.js +50 -0
- package/chunk-P3PKED2I.js +962 -0
- package/chunk-PFTAG6DY.js +1939 -0
- package/chunk-PMKQGGGM.js +221 -0
- package/chunk-PP4S6RTL.js +175 -0
- package/chunk-QJ7FZNYN.js +939 -0
- package/chunk-QSJ3HFEF.js +8 -0
- package/chunk-RGIM3WLT.js +113 -0
- package/chunk-RL776AGR.js +190 -0
- package/chunk-ROWQEJRP.js +139 -0
- package/chunk-S7Z2HMCN.js +25 -0
- package/chunk-SDJDLO5W.js +628 -0
- package/chunk-SOTZ6RDN.js +69 -0
- package/chunk-TILFE6LV.js +381 -0
- package/chunk-TIMLUWQA.js +231 -0
- package/chunk-TISCADJH.js +807 -0
- package/chunk-U4TRT5V4.js +246 -0
- package/chunk-U6VC4MU4.js +8 -0
- package/chunk-UAD2WT54.js +64 -0
- package/chunk-VC6OZXO5.js +298 -0
- package/chunk-VF4K2QE6.js +21 -0
- package/chunk-VHBWHNVT.js +59 -0
- package/chunk-VIDPVFP3.js +20 -0
- package/chunk-VP4WJWKW.js +8882 -0
- package/chunk-VVX233PH.js +482 -0
- package/chunk-W4NVOSFF.js +37 -0
- package/chunk-WI4XWASA.js +208 -0
- package/chunk-WWC7I6TA.js +8 -0
- package/chunk-WZSRQNQG.js +2587 -0
- package/chunk-XBROXIGL.js +3066 -0
- package/chunk-XENYHRUE.js +104 -0
- package/chunk-Y5GCAMGP.js +9 -0
- package/chunk-YN4XDB7B.js +9036 -0
- package/chunk-YPRZSPF3.js +148 -0
- package/chunk-Z4NR32XR.js +50 -0
- package/chunk-Z6EKEXJW.js +138 -0
- package/chunk-ZDRZMLKO.js +27339 -0
- package/chunk-ZNFJWEN4.js +56 -0
- package/cliExecutor-K3F7DMRO.js +36 -0
- package/clipboardy-BVE3LVEH.js +12001 -0
- package/createAgentAutomationAction-CCABEOM6.js +866 -0
- package/createDialogAction-YPKF5ITI.js +55 -0
- package/createPageAction-YEZ7EK5F.js +172 -0
- package/db-HCJ5PRB5.js +271 -0
- package/dbSlice-QPVZHBOE.js +60 -0
- package/deleteFile-SV5MS23W.js +41 -0
- package/dialogCommands-4IX4XIZE.js +63 -0
- package/dialogSlice-OVTO7QGW.js +148 -0
- package/docCreateCommands-SIL3NPGT.js +220 -0
- package/docDeleteCommands-7IOMLUS4.js +181 -0
- package/docReadCommands-FNFXUA5L.js +134 -0
- package/docStore-ZAYLW2HN.js +98 -0
- package/docUpdateCommands-X2HNDVUC.js +318 -0
- package/fetchMessages-KTNM7QAR.js +17 -0
- package/getPricing-3E6UNPKL.js +30 -0
- package/handleSendMessageAction-TZMZ4EP5.js +185 -0
- package/index.js +188 -112958
- package/lib-FYYBQIXS.js +19839 -0
- package/localDialogRead-2VRI24F4.js +26 -0
- package/localFirstLog-DHNOY2NA.js +19 -0
- package/localRuntimeAuthority-TEGCOWX4.js +471 -0
- package/localRuntimeDb-LGDF6FQP.js +12 -0
- package/machineCommands-M4ZJZIMS.js +781 -0
- package/machineInfo-M6KB6HZN.js +10 -0
- package/machineWsRunDispatch-TPJAUGLP.js +112 -0
- package/memoryCommands-O4MIPIWQ.js +476 -0
- package/models-4OPOOLFS.js +9 -0
- package/offlineMarxistsAgentCommand-BCPJITJL.js +242 -0
- package/package.json +4 -23
- package/read-EBMWX4Z6.js +17 -0
- package/readDocTool-2MWHSTQE.js +16 -0
- package/readlineWorkspace-OMCIU3WT.js +5682 -0
- package/removeDialogAgentAction-SNZ662NP.js +73 -0
- package/runAgentClientLoop-H6NGOUAM.js +293 -0
- package/runtimeDoctorCommands-LRHLPDRC.js +289 -0
- package/setDialogExtraReferencesAction-XDI2KM2N.js +60 -0
- package/setPrimaryDialogAgentAction-PYEC4N4Z.js +80 -0
- package/settingSlice-NOWHY2FK.js +199 -0
- package/skillDiscovery-UGSQGX2U.js +16 -0
- package/skillSummaryMarker-42HKSXYY.js +9 -0
- package/slateToRenderMarkdown-Y5IYN73U.js +7 -0
- package/slateUtils-2M7MUTWX.js +19 -0
- package/spaceCommands-E7VOF4LO.js +450 -0
- package/spaceSlice-QHBPICA2.js +149 -0
- package/streamAgentChatTurn-3XTBA2HN.js +4510 -0
- package/tableCommands-R5UCM63M.js +1286 -0
- package/toolApiClient-QI3YBNWB.js +26 -0
- package/tools-GHLZ3XD6.js +87 -0
- package/tuiSummaryLlmCaller-RV3THLZF.js +78 -0
- package/understanding-3CUQQ6SV.js +271 -0
- package/updateCommands-VOSPKXFF.js +31 -0
- package/updateDialogTitleAction-XA2OZTLP.js +188 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// packages/create/editor/transforms/slateToRenderMarkdown.ts
|
|
2
|
+
function renderTextNode(node) {
|
|
3
|
+
if (!node || typeof node.text !== "string") return "";
|
|
4
|
+
let text = node.text;
|
|
5
|
+
if (!text) return "";
|
|
6
|
+
if (node.bold) text = `**${text}**`;
|
|
7
|
+
if (node.italic) text = `*${text}*`;
|
|
8
|
+
if (node.strikethrough) text = `~~${text}~~`;
|
|
9
|
+
return text;
|
|
10
|
+
}
|
|
11
|
+
function renderPlainText(node, options = {}) {
|
|
12
|
+
if (!node) return "";
|
|
13
|
+
if (typeof node.text === "string") return renderTextNode(node);
|
|
14
|
+
if (!Array.isArray(node.children)) return "";
|
|
15
|
+
return node.children.map((child) => renderPlainText(child, options)).join("");
|
|
16
|
+
}
|
|
17
|
+
function renderTable(node, options) {
|
|
18
|
+
const rows = Array.isArray(node.children) ? node.children : [];
|
|
19
|
+
if (rows.length === 0) return "";
|
|
20
|
+
const alignments = Array.isArray(node.columns) ? node.columns.map((column) => column?.align || "left") : [];
|
|
21
|
+
const renderedRows = rows.map(
|
|
22
|
+
(row) => (Array.isArray(row?.children) ? row.children : []).map((cell) => {
|
|
23
|
+
const content = renderPlainText(cell, options).replace(/\n+/g, " ").trim();
|
|
24
|
+
return content || " ";
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
const header = renderedRows[0] || [];
|
|
28
|
+
const divider = header.map((_, index) => {
|
|
29
|
+
const align = alignments[index];
|
|
30
|
+
if (align === "center") return ":---:";
|
|
31
|
+
if (align === "right") return "---:";
|
|
32
|
+
return "---";
|
|
33
|
+
});
|
|
34
|
+
const body = renderedRows.slice(1);
|
|
35
|
+
return [header, divider, ...body].map((cells) => `| ${cells.join(" | ")} |`).join("\n") + "\n\n";
|
|
36
|
+
}
|
|
37
|
+
function renderListItem(node, listDepth, ordered, start, index, options = {}) {
|
|
38
|
+
const indentation = " ".repeat(listDepth);
|
|
39
|
+
const marker = node.checked === true ? "- [x]" : node.checked === false ? "- [ ]" : ordered ? `${start + index}.` : "-";
|
|
40
|
+
const segments = Array.isArray(node.children) ? node.children : [];
|
|
41
|
+
const renderedSegments = segments.flatMap((child) => {
|
|
42
|
+
const rendered = renderNode(child, listDepth + 1, options).trimEnd();
|
|
43
|
+
return rendered ? [rendered] : [];
|
|
44
|
+
});
|
|
45
|
+
if (renderedSegments.length === 0) {
|
|
46
|
+
return `${indentation}${marker}
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
49
|
+
const [first, ...rest] = renderedSegments;
|
|
50
|
+
const lines = first.split("\n");
|
|
51
|
+
const firstLine = lines.shift() || "";
|
|
52
|
+
const restFirst = lines.map((line) => `${indentation} ${line}`).join("\n");
|
|
53
|
+
const restBlocks = rest.map((block) => `${indentation} ${block}`).join("\n");
|
|
54
|
+
return [
|
|
55
|
+
`${indentation}${marker} ${firstLine}`,
|
|
56
|
+
restFirst,
|
|
57
|
+
restBlocks
|
|
58
|
+
].filter(Boolean).join("\n") + "\n";
|
|
59
|
+
}
|
|
60
|
+
function renderNode(node, listDepth = 0, options = {}) {
|
|
61
|
+
if (!node) return "";
|
|
62
|
+
switch (node.type) {
|
|
63
|
+
case "heading-one":
|
|
64
|
+
return `# ${node.children.map((n) => renderNode(n, listDepth, options)).join("")}
|
|
65
|
+
|
|
66
|
+
`;
|
|
67
|
+
case "heading-two":
|
|
68
|
+
return `## ${node.children.map((n) => renderNode(n, listDepth, options)).join("")}
|
|
69
|
+
|
|
70
|
+
`;
|
|
71
|
+
case "heading-three":
|
|
72
|
+
return `### ${node.children.map((n) => renderNode(n, listDepth, options)).join("")}
|
|
73
|
+
|
|
74
|
+
`;
|
|
75
|
+
case "heading-four":
|
|
76
|
+
return `#### ${node.children.map((n) => renderNode(n, listDepth, options)).join("")}
|
|
77
|
+
|
|
78
|
+
`;
|
|
79
|
+
case "heading-five":
|
|
80
|
+
return `##### ${node.children.map((n) => renderNode(n, listDepth, options)).join("")}
|
|
81
|
+
|
|
82
|
+
`;
|
|
83
|
+
case "heading-six":
|
|
84
|
+
return `###### ${node.children.map((n) => renderNode(n, listDepth, options)).join("")}
|
|
85
|
+
|
|
86
|
+
`;
|
|
87
|
+
case "paragraph":
|
|
88
|
+
return `${node.children.map((n) => renderNode(n, listDepth, options)).join("")}
|
|
89
|
+
|
|
90
|
+
`;
|
|
91
|
+
case "list":
|
|
92
|
+
return node.children.map(
|
|
93
|
+
(item, index) => renderListItem(item, listDepth, !!node.ordered, node.start || 1, index, options)
|
|
94
|
+
).join("");
|
|
95
|
+
case "list-item":
|
|
96
|
+
return renderListItem(node, listDepth, false, 1, 0, options);
|
|
97
|
+
case "quote": {
|
|
98
|
+
const content = node.children.map((n) => renderNode(n, listDepth, options)).join("").trim();
|
|
99
|
+
return `> ${content.replace(/\n/g, "\n> ")}
|
|
100
|
+
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
103
|
+
case "code-block": {
|
|
104
|
+
const code = node.children.map(
|
|
105
|
+
(line) => (line.children || []).map((text) => text.text).join("")
|
|
106
|
+
).join("\n");
|
|
107
|
+
return "```" + (node.language || "") + "\n" + code + "\n```\n\n";
|
|
108
|
+
}
|
|
109
|
+
case "link": {
|
|
110
|
+
const linkText = node.children.map((n) => renderNode(n, listDepth, options)).join("");
|
|
111
|
+
return `[${linkText}](${node.url})`;
|
|
112
|
+
}
|
|
113
|
+
case "table":
|
|
114
|
+
return renderTable(node, options);
|
|
115
|
+
case "code-inline":
|
|
116
|
+
return `\`${node.children.map((n) => renderNode(n, listDepth, options)).join("")}\``;
|
|
117
|
+
case "mention": {
|
|
118
|
+
if (options.mentionResolver) {
|
|
119
|
+
return options.mentionResolver(node);
|
|
120
|
+
}
|
|
121
|
+
const label = node.label || node.resourceId || "mention";
|
|
122
|
+
const resourceType = node.resourceType || "unknown";
|
|
123
|
+
const resourceId = node.resourceId || "unknown";
|
|
124
|
+
return `@[${resourceType}:${resourceId}|${label}]`;
|
|
125
|
+
}
|
|
126
|
+
case "image": {
|
|
127
|
+
const alt = node.alt || "";
|
|
128
|
+
const title = node.title ? ` "${node.title}"` : "";
|
|
129
|
+
return ``;
|
|
130
|
+
}
|
|
131
|
+
case "html-inline":
|
|
132
|
+
return typeof node.html === "string" ? node.html : "";
|
|
133
|
+
case "html-block":
|
|
134
|
+
return typeof node.html === "string" ? `${node.html}
|
|
135
|
+
|
|
136
|
+
` : "";
|
|
137
|
+
case "thematic-break":
|
|
138
|
+
return "---\n\n";
|
|
139
|
+
default:
|
|
140
|
+
return renderTextNode(node) || (node.children ? node.children.map((child) => renderNode(child, listDepth, options)).join("") : "");
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function slateToRenderMarkdown(nodes, options = {}) {
|
|
144
|
+
if (!nodes || nodes.length === 0) return "";
|
|
145
|
+
return nodes.map((node) => renderNode(node, 0, options)).join("").trim() + "\n";
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export {
|
|
149
|
+
slateToRenderMarkdown
|
|
150
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveLaunchableCodexCommand
|
|
3
|
+
} from "./chunk-JBTJAPUF.js";
|
|
4
|
+
|
|
5
|
+
// packages/connector-experimental/machineInfo.ts
|
|
6
|
+
import { existsSync as existsSync2, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
7
|
+
import { dirname, join as join2 } from "node:path";
|
|
8
|
+
import { arch, hostname, homedir, platform } from "node:os";
|
|
9
|
+
import { randomUUID } from "node:crypto";
|
|
10
|
+
|
|
11
|
+
// packages/connector-experimental/capabilities.ts
|
|
12
|
+
import { spawnSync } from "node:child_process";
|
|
13
|
+
import { existsSync } from "node:fs";
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
var COMMAND_CAPABILITIES = [
|
|
16
|
+
[[{ command: "codex", args: ["--version"] }], ["codex-cli"]],
|
|
17
|
+
[[{ command: "claude", args: ["--version"] }], ["claude-code"]],
|
|
18
|
+
[
|
|
19
|
+
[
|
|
20
|
+
{ command: "gh", args: ["--version"] },
|
|
21
|
+
{ command: "gh", args: ["copilot", "--", "--help"] }
|
|
22
|
+
],
|
|
23
|
+
["copilot-cli"]
|
|
24
|
+
],
|
|
25
|
+
[[{ command: "gemini", args: ["--version"] }], ["gemini-cli"]],
|
|
26
|
+
[[{ command: "kimi", args: ["--version"] }], ["kimi-cli"]],
|
|
27
|
+
[[{ command: "agy", args: ["--help"] }], ["agy-cli"]],
|
|
28
|
+
[[{ command: "qoder", args: ["--version"] }], ["qoder-cli"]],
|
|
29
|
+
[[{ command: "opencode", args: ["--version"] }], ["opencode-cli"]],
|
|
30
|
+
[[{ command: "grok", args: ["--version"] }], ["grok-cli"]]
|
|
31
|
+
];
|
|
32
|
+
function defaultCommandExists(command) {
|
|
33
|
+
const pathEntries = (process.env.PATH ?? "").split(process.platform === "win32" ? ";" : ":");
|
|
34
|
+
const extensions = process.platform === "win32" ? [".exe", ".cmd", ".bat", ""] : [""];
|
|
35
|
+
return pathEntries.some(
|
|
36
|
+
(entry) => extensions.some((extension) => existsSync(join(entry, `${command}${extension}`)))
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
function defaultCommandLaunchable(command, args) {
|
|
40
|
+
const executable = command === "codex" ? resolveLaunchableCodexCommand() : command;
|
|
41
|
+
const result = spawnSync(executable, args, {
|
|
42
|
+
stdio: "pipe",
|
|
43
|
+
timeout: 3e3,
|
|
44
|
+
windowsHide: true
|
|
45
|
+
});
|
|
46
|
+
return !result.error && result.status === 0;
|
|
47
|
+
}
|
|
48
|
+
function detectRuntimeCapabilities(options = {}) {
|
|
49
|
+
const commandExists = options.commandExists ?? defaultCommandExists;
|
|
50
|
+
const commandLaunchable = options.commandLaunchable ?? defaultCommandLaunchable;
|
|
51
|
+
const env = options.env ?? process.env;
|
|
52
|
+
const capabilities = [];
|
|
53
|
+
for (const [probes, detectedCapabilities] of COMMAND_CAPABILITIES) {
|
|
54
|
+
if (!probes.every((probe) => commandExists(probe.command))) continue;
|
|
55
|
+
if (options.probeLaunchable && !probes.every((probe) => commandLaunchable(probe.command, probe.args))) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
capabilities.push(...detectedCapabilities);
|
|
59
|
+
}
|
|
60
|
+
if (env.NOLO_LOCAL_LLM_ENDPOINT || env.LLAMA_SERVER_URL) {
|
|
61
|
+
capabilities.push("local-llm");
|
|
62
|
+
}
|
|
63
|
+
return capabilities;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// packages/connector-experimental/machineInfo.ts
|
|
67
|
+
var CONNECTOR_VERSION = "0.1.0-experimental";
|
|
68
|
+
function defaultMachineIdPath() {
|
|
69
|
+
return join2(homedir(), ".nolo", "machine-id");
|
|
70
|
+
}
|
|
71
|
+
function resolveMachineId(path = defaultMachineIdPath()) {
|
|
72
|
+
try {
|
|
73
|
+
if (existsSync2(path)) {
|
|
74
|
+
const existing = readFileSync(path, "utf8").trim();
|
|
75
|
+
if (existing) return existing;
|
|
76
|
+
}
|
|
77
|
+
const next = `machine-${randomUUID()}`;
|
|
78
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
79
|
+
writeFileSync(path, `${next}
|
|
80
|
+
`, "utf8");
|
|
81
|
+
return next;
|
|
82
|
+
} catch {
|
|
83
|
+
return `machine-${hostname().toLowerCase()}`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function detectMachineInfo(overrides) {
|
|
87
|
+
return {
|
|
88
|
+
machineId: overrides?.machineId ?? resolveMachineId(),
|
|
89
|
+
name: overrides?.name ?? hostname(),
|
|
90
|
+
platform: platform(),
|
|
91
|
+
arch: arch(),
|
|
92
|
+
connectorVersion: CONNECTOR_VERSION,
|
|
93
|
+
capabilities: overrides?.capabilities ?? detectRuntimeCapabilities({
|
|
94
|
+
probeLaunchable: overrides?.probeLaunchable
|
|
95
|
+
})
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
resolveMachineId,
|
|
101
|
+
detectMachineInfo
|
|
102
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// packages/cli/levelLazyShim.mjs
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
var _require = createRequire(import.meta.url);
|
|
4
|
+
var _RealLevel;
|
|
5
|
+
function ensureLevel() {
|
|
6
|
+
if (!_RealLevel) {
|
|
7
|
+
_RealLevel = _require("level").Level;
|
|
8
|
+
}
|
|
9
|
+
return _RealLevel;
|
|
10
|
+
}
|
|
11
|
+
var Level = class {
|
|
12
|
+
constructor(...args) {
|
|
13
|
+
const RealLevel = ensureLevel();
|
|
14
|
+
return new RealLevel(...args);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
Level
|
|
20
|
+
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import {
|
|
2
|
+
listUserRecordsFromServers,
|
|
3
|
+
readLiveDbRecordAfterTombstoneMerge
|
|
4
|
+
} from "./chunk-RL776AGR.js";
|
|
5
|
+
import {
|
|
6
|
+
agentRecordHasConfiguredCredential
|
|
7
|
+
} from "./chunk-SDJDLO5W.js";
|
|
8
|
+
|
|
9
|
+
// packages/cli/agentListHelpers.ts
|
|
10
|
+
function parseAgentRecordId(privateKey, explicitId) {
|
|
11
|
+
if (explicitId) return explicitId;
|
|
12
|
+
const agentMatch = privateKey.match(/^agent-[^-]+-(.+)$/i);
|
|
13
|
+
return agentMatch?.[1] ?? "";
|
|
14
|
+
}
|
|
15
|
+
function buildCompanionKeys(rawId, userId) {
|
|
16
|
+
return {
|
|
17
|
+
privateKey: `agent-${userId}-${rawId}`,
|
|
18
|
+
publicKey: `agent-pub-${rawId}`
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function normalizeListedAgent(record) {
|
|
22
|
+
const privateKey = typeof record?.dbKey === "string" ? record.dbKey : "";
|
|
23
|
+
const explicitId = typeof record?.id === "string" && record.id ? record.id : void 0;
|
|
24
|
+
const ownerUserId = typeof record?.userId === "string" ? record.userId : "";
|
|
25
|
+
const rawId = explicitId || (ownerUserId && privateKey.startsWith(`agent-${ownerUserId}-`) ? privateKey.slice(`agent-${ownerUserId}-`.length) : parseAgentRecordId(privateKey, explicitId));
|
|
26
|
+
if (!privateKey || !rawId || !ownerUserId) return null;
|
|
27
|
+
const keys = buildCompanionKeys(rawId, ownerUserId);
|
|
28
|
+
const credentialConfigured = agentRecordHasConfiguredCredential(record);
|
|
29
|
+
const credentialRef = typeof record?.credentialRef === "string" && record.credentialRef ? record.credentialRef : void 0;
|
|
30
|
+
const apiKeyRef = typeof record?.apiKeyRef === "string" && record.apiKeyRef ? record.apiKeyRef : void 0;
|
|
31
|
+
return {
|
|
32
|
+
id: rawId,
|
|
33
|
+
privateKey,
|
|
34
|
+
publicKey: keys.publicKey,
|
|
35
|
+
name: typeof record?.name === "string" && record.name ? record.name : "(unnamed)",
|
|
36
|
+
model: typeof record?.model === "string" && record.model ? record.model : "-",
|
|
37
|
+
updatedAt: typeof record?.updatedAt === "string" || typeof record?.updatedAt === "number" ? record.updatedAt : typeof record?.createdAt === "string" || typeof record?.createdAt === "number" ? record.createdAt : typeof record?.created === "string" || typeof record?.created === "number" ? record.created : null,
|
|
38
|
+
isPublicFlag: !!record?.isPublic,
|
|
39
|
+
publicRecordExists: false,
|
|
40
|
+
type: typeof record?.type === "string" ? record.type : null,
|
|
41
|
+
tools: Array.isArray(record?.tools) ? record.tools.filter((tool) => typeof tool === "string") : [],
|
|
42
|
+
credentialConfigured,
|
|
43
|
+
credentialRef,
|
|
44
|
+
apiKeyRef,
|
|
45
|
+
...typeof record?.apiSource === "string" && record.apiSource ? { apiSource: record.apiSource } : {},
|
|
46
|
+
...typeof record?.cliProvider === "string" && record.cliProvider ? { cliProvider: record.cliProvider } : {}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function sortListedAgents(agents) {
|
|
50
|
+
agents.sort((a, b) => {
|
|
51
|
+
const ta = a.updatedAt == null ? 0 : new Date(a.updatedAt).getTime();
|
|
52
|
+
const tb = b.updatedAt == null ? 0 : new Date(b.updatedAt).getTime();
|
|
53
|
+
return tb - ta;
|
|
54
|
+
});
|
|
55
|
+
return agents;
|
|
56
|
+
}
|
|
57
|
+
function parseAgentListArgs(args) {
|
|
58
|
+
return {
|
|
59
|
+
wantJson: args.includes("--json"),
|
|
60
|
+
publicOnly: args.includes("--public-only"),
|
|
61
|
+
idsOnly: args.includes("--ids-only")
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async function listLocalCachedAgents(args) {
|
|
65
|
+
const privateRecords = /* @__PURE__ */ new Map();
|
|
66
|
+
const publicKeys = /* @__PURE__ */ new Set();
|
|
67
|
+
for await (const [key, value] of args.db.iterator({ gte: "", lte: "\uFFFF" })) {
|
|
68
|
+
if (typeof key !== "string" || !value || typeof value !== "object") continue;
|
|
69
|
+
if (key.startsWith(`agent-${args.userId}-`)) {
|
|
70
|
+
privateRecords.set(key, { ...value, dbKey: key });
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (key.startsWith("agent-pub-")) {
|
|
74
|
+
publicKeys.add(key);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const agents = sortListedAgents(
|
|
78
|
+
[...privateRecords.values()].map((record) => normalizeListedAgent(record)).filter((agent) => agent != null)
|
|
79
|
+
);
|
|
80
|
+
for (const agent of agents) {
|
|
81
|
+
agent.publicRecordExists = publicKeys.has(agent.publicKey);
|
|
82
|
+
}
|
|
83
|
+
return agents;
|
|
84
|
+
}
|
|
85
|
+
async function hasReadableRecord(args) {
|
|
86
|
+
try {
|
|
87
|
+
await args.readDbRecord(args);
|
|
88
|
+
return true;
|
|
89
|
+
} catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function listRemoteAgents(args) {
|
|
94
|
+
const recordGroups = [await args.queryUserRecords({ ...args, type: "agent" })];
|
|
95
|
+
const agents = sortListedAgents(
|
|
96
|
+
recordGroups.flat().map((record) => normalizeListedAgent(record)).filter((agent) => agent != null)
|
|
97
|
+
);
|
|
98
|
+
await Promise.all(
|
|
99
|
+
agents.map(async (agent) => {
|
|
100
|
+
agent.publicRecordExists = await hasReadableRecord({
|
|
101
|
+
authToken: args.authToken,
|
|
102
|
+
dbKey: agent.publicKey,
|
|
103
|
+
fallbackFetchImpl: args.fallbackFetchImpl,
|
|
104
|
+
fetchImpl: args.fetchImpl,
|
|
105
|
+
serverUrl: args.serverUrl,
|
|
106
|
+
readDbRecord: args.readDbRecord
|
|
107
|
+
});
|
|
108
|
+
})
|
|
109
|
+
);
|
|
110
|
+
return agents;
|
|
111
|
+
}
|
|
112
|
+
async function listRemoteAgentsAcrossServers(args) {
|
|
113
|
+
const remoteResult = await listUserRecordsFromServers({
|
|
114
|
+
authToken: args.authToken,
|
|
115
|
+
fallbackFetchImpl: args.fallbackFetchImpl,
|
|
116
|
+
fetchImpl: args.fetchImpl,
|
|
117
|
+
label: "agent query",
|
|
118
|
+
serverUrls: args.serverUrls,
|
|
119
|
+
type: "agent",
|
|
120
|
+
userId: args.userId
|
|
121
|
+
});
|
|
122
|
+
const agents = sortListedAgents(
|
|
123
|
+
remoteResult.records.map((record) => normalizeListedAgent(record)).filter((agent) => agent != null)
|
|
124
|
+
);
|
|
125
|
+
return { agents, failures: remoteResult.failures };
|
|
126
|
+
}
|
|
127
|
+
async function listFavoriteAgentIdsAcrossServers(args) {
|
|
128
|
+
const favoritedAtByKey = {};
|
|
129
|
+
await Promise.all(
|
|
130
|
+
args.serverUrls.map(async (serverUrl) => {
|
|
131
|
+
try {
|
|
132
|
+
const res = await args.fetchImpl(`${serverUrl}/rpc/listFavorites`, {
|
|
133
|
+
method: "POST",
|
|
134
|
+
headers: {
|
|
135
|
+
"Content-Type": "application/json",
|
|
136
|
+
Authorization: `Bearer ${args.authToken}`
|
|
137
|
+
},
|
|
138
|
+
body: JSON.stringify({ targetType: "agent" })
|
|
139
|
+
});
|
|
140
|
+
if (!res.ok) return;
|
|
141
|
+
const data = await res.json().catch(() => ({}));
|
|
142
|
+
const items = Array.isArray(data?.items) ? data.items : [];
|
|
143
|
+
for (const item of items) {
|
|
144
|
+
const id = typeof item?.id === "string" ? item.id : "";
|
|
145
|
+
if (!id) continue;
|
|
146
|
+
const at = Number(item?.favoritedAt) || 0;
|
|
147
|
+
favoritedAtByKey[id] = Math.max(
|
|
148
|
+
favoritedAtByKey[id] ?? 0,
|
|
149
|
+
at || Date.now()
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
const ids = Array.isArray(data?.ids) ? data.ids : [];
|
|
153
|
+
for (const id of ids) {
|
|
154
|
+
if (typeof id === "string" && id && !(id in favoritedAtByKey)) {
|
|
155
|
+
favoritedAtByKey[id] = 1;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
} catch {
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
);
|
|
162
|
+
return favoritedAtByKey;
|
|
163
|
+
}
|
|
164
|
+
async function decorateAgentsWithPublicStatusAcrossServers(args) {
|
|
165
|
+
await Promise.all(
|
|
166
|
+
args.agents.map(async (agent) => {
|
|
167
|
+
try {
|
|
168
|
+
const result = await readLiveDbRecordAfterTombstoneMerge({
|
|
169
|
+
authToken: args.authToken,
|
|
170
|
+
dbKey: agent.publicKey,
|
|
171
|
+
fallbackFetchImpl: args.fallbackFetchImpl,
|
|
172
|
+
fetchImpl: args.fetchImpl,
|
|
173
|
+
serverUrls: args.serverUrls
|
|
174
|
+
});
|
|
175
|
+
agent.publicRecordExists = result.record?.isPublic === true;
|
|
176
|
+
} catch {
|
|
177
|
+
agent.publicRecordExists = false;
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
);
|
|
181
|
+
return args.agents;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export {
|
|
185
|
+
parseAgentListArgs,
|
|
186
|
+
listLocalCachedAgents,
|
|
187
|
+
listRemoteAgents,
|
|
188
|
+
listRemoteAgentsAcrossServers,
|
|
189
|
+
listFavoriteAgentIdsAcrossServers,
|
|
190
|
+
decorateAgentsWithPublicStatusAcrossServers
|
|
191
|
+
};
|