nolo-cli 0.8.0 → 0.9.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/_executeModel-UD44KGZ4.js +203 -0
- package/action-ZJWE3Y5S.js +28 -0
- package/addContentAction-TVDBNJM5.js +26 -0
- package/addDialogAgentAction-EKH774VT.js +68 -0
- package/agentDeleteCommand-TCPEFJTF.js +327 -0
- package/agentEmailCommands-CZ3UILZ4.js +626 -0
- package/agentListCommands-SJKO2FFB.js +223 -0
- package/agentMachineCommands-PSNABISZ.js +425 -0
- package/agentPullCommand-O2MTUAFR.js +122 -0
- package/agentRecordCommands-MH2JKFHS.js +94 -0
- package/agentRunCommand-4KH6MIZR.js +110 -0
- package/agentRunControl-K4VKNEHF.js +57 -0
- package/agentRuntimeLocal-SKHJUWSS.js +104 -0
- package/agentSlice-3WXXN4VK.js +42 -0
- package/authCommand-PXFX6JDT.js +581 -0
- package/authCommands-356AYWEK.js +35 -0
- package/chunk-2EISRLRC.js +238 -0
- package/chunk-2FTTDCD4.js +675 -0
- package/chunk-2K2ECKSG.js +222 -0
- package/chunk-2PUGVR6E.js +19 -0
- package/chunk-3ASDTTEI.js +1774 -0
- package/chunk-3EUW3WEO.js +8 -0
- package/chunk-3LY4F7SV.js +9293 -0
- package/chunk-3TZDXYSF.js +71 -0
- package/chunk-3WYQEUBI.js +34 -0
- package/chunk-4CQLVGRV.js +50 -0
- package/chunk-4IJYA27C.js +342 -0
- package/chunk-4K2KKCSD.js +577 -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-5PJ3VWCS.js +360 -0
- package/chunk-63SLEOLK.js +175 -0
- package/chunk-63W5N6P3.js +150 -0
- package/chunk-6GANEXVO.js +231 -0
- package/chunk-6HYVJV7B.js +102 -0
- package/chunk-6WD3OOJS.js +20 -0
- package/chunk-7OOXPE3N.js +628 -0
- package/chunk-7QRKCBOP.js +1078 -0
- package/chunk-ATNTHIZI.js +13 -0
- package/chunk-AUQ747NZ.js +902 -0
- package/chunk-AVMKZHBC.js +85 -0
- package/chunk-AZPCASRE.js +36 -0
- package/chunk-BBYVOSU2.js +792 -0
- package/chunk-C3RUNRHT.js +51 -0
- package/chunk-CF2WZF4N.js +134 -0
- package/chunk-CF7PE763.js +10 -0
- package/chunk-CKOJQDKR.js +198 -0
- package/chunk-COMXDWNM.js +807 -0
- package/chunk-CPB2YM4D.js +171 -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-ELRRLDWI.js +478 -0
- package/chunk-EXTIQUCI.js +482 -0
- package/chunk-EYEEHCU4.js +3066 -0
- package/chunk-G3SUCT4W.js +8 -0
- package/chunk-G43KEVSC.js +1447 -0
- package/chunk-GAKEBQD6.js +30 -0
- package/chunk-GBRG75BQ.js +86 -0
- package/chunk-GG4AJPSR.js +191 -0
- package/chunk-H33743XH.js +25 -0
- package/chunk-HNMXYYJR.js +12 -0
- package/chunk-I42VC5KR.js +15 -0
- package/chunk-IDZTNRP2.js +85 -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-KKY4B2Q2.js +21 -0
- package/chunk-KOCA5FCS.js +4750 -0
- package/chunk-KQHGZWSV.js +63 -0
- package/chunk-KTVVPRJS.js +138 -0
- package/chunk-KUG52IAP.js +8 -0
- package/chunk-KX6YBIHG.js +8 -0
- package/chunk-LARL2V6G.js +9017 -0
- package/chunk-LCBAMY2M.js +60 -0
- package/chunk-LM6IYQ3F.js +16 -0
- package/chunk-M76ECQRD.js +13658 -0
- package/chunk-MGOJ5R6J.js +113 -0
- package/chunk-MKMWT7SA.js +27196 -0
- package/chunk-MRC4Q34M.js +188 -0
- package/chunk-OLZBQWZU.js +6 -0
- package/chunk-OPZYGHUC.js +89 -0
- package/chunk-OWOHNGCN.js +50 -0
- package/chunk-PAKN26FP.js +239 -0
- package/chunk-PCWC3JTN.js +91 -0
- package/chunk-PG5PNA7Y.js +939 -0
- package/chunk-Q2YZULBH.js +104 -0
- package/chunk-QSJ3HFEF.js +8 -0
- package/chunk-QYXLLLGL.js +4519 -0
- package/chunk-ROWQEJRP.js +139 -0
- package/chunk-S7Z2HMCN.js +25 -0
- package/chunk-SBR32ZZS.js +1901 -0
- package/chunk-SH2CFQOH.js +3391 -0
- package/chunk-SL35K7AH.js +226 -0
- package/chunk-TILFE6LV.js +381 -0
- package/chunk-TSS3XJY4.js +2052 -0
- package/chunk-U4TRT5V4.js +246 -0
- package/chunk-U6VC4MU4.js +8 -0
- package/chunk-UAD2WT54.js +64 -0
- package/chunk-UUJDGGAK.js +421 -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-W4NVOSFF.js +37 -0
- package/chunk-WKM6FH35.js +190 -0
- package/chunk-WWC7I6TA.js +8 -0
- package/chunk-X7W4TNB4.js +1550 -0
- package/chunk-XE635NI4.js +1948 -0
- package/chunk-XKIMRZO2.js +221 -0
- package/chunk-XS466O7S.js +933 -0
- package/chunk-Y5GCAMGP.js +9 -0
- package/chunk-YBWOP46I.js +3272 -0
- package/chunk-YPRZSPF3.js +148 -0
- package/chunk-YYUCRDOK.js +69 -0
- package/chunk-Z4NR32XR.js +50 -0
- package/chunk-ZIG5LJ7X.js +24765 -0
- package/chunk-ZNFJWEN4.js +56 -0
- package/chunk-ZQ2UM4KG.js +2878 -0
- package/cliExecutor-DNE7TCC4.js +36 -0
- package/clipboardy-BVE3LVEH.js +12001 -0
- package/createAgentAutomationAction-63OIP6X5.js +866 -0
- package/createDialogAction-ZLYZDYBB.js +54 -0
- package/createPageAction-AL5FSDCK.js +171 -0
- package/db-HCJ5PRB5.js +271 -0
- package/dbSlice-PR44QPXY.js +60 -0
- package/deleteFile-4SKGPHOZ.js +41 -0
- package/dialogCommands-F6YI5742.js +63 -0
- package/dialogSlice-JSBNZRLR.js +148 -0
- package/docCreateCommands-4CTO7ERT.js +219 -0
- package/docDeleteCommands-VBWERDRG.js +180 -0
- package/docReadCommands-KNP4MFYB.js +133 -0
- package/docStore-ADP5VYY4.js +98 -0
- package/docUpdateCommands-4BCBJQHA.js +317 -0
- package/fetchMessages-U6ZHN56A.js +17 -0
- package/getPricing-3E6UNPKL.js +30 -0
- package/handleSendMessageAction-IJDQ6ARA.js +185 -0
- package/index.js +188 -112943
- package/lib-FYYBQIXS.js +19839 -0
- package/localDialogRead-Z5UTAJPU.js +26 -0
- package/localFirstLog-DHNOY2NA.js +19 -0
- package/localRuntimeAuthority-TEGCOWX4.js +471 -0
- package/localRuntimeDb-LGDF6FQP.js +12 -0
- package/machineCommands-EA3M4XTN.js +779 -0
- package/machineInfo-M6KB6HZN.js +10 -0
- package/machineWsRunDispatch-NAPKE5ZA.js +110 -0
- package/memoryCommands-O4MIPIWQ.js +476 -0
- package/models-4OPOOLFS.js +9 -0
- package/offlineMarxistsAgentCommand-BCPJITJL.js +242 -0
- package/package.json +3 -25
- package/read-RIJCIVKX.js +17 -0
- package/readDocTool-GZD2N3LO.js +16 -0
- package/readlineWorkspace-KMWT4T4S.js +5509 -0
- package/removeDialogAgentAction-GJQJNDW6.js +73 -0
- package/runAgentClientLoop-U5Q6NDTJ.js +291 -0
- package/runtimeDoctorCommands-LRHLPDRC.js +289 -0
- package/setDialogExtraReferencesAction-M7OQG54N.js +60 -0
- package/setPrimaryDialogAgentAction-46UNFJDL.js +80 -0
- package/settingSlice-FVUUH4JA.js +199 -0
- package/skillSummaryMarker-42HKSXYY.js +9 -0
- package/slateToRenderMarkdown-Y5IYN73U.js +7 -0
- package/slateUtils-2M7MUTWX.js +19 -0
- package/spaceCommands-E2CFRPZJ.js +454 -0
- package/spaceSlice-L3R6IMXE.js +147 -0
- package/streamAgentChatTurn-UBDAOQWE.js +4528 -0
- package/tableCommands-GOFP7QKA.js +1286 -0
- package/toolApiClient-QI3YBNWB.js +26 -0
- package/tools-TMJXZTCA.js +85 -0
- package/tuiSummaryLlmCaller-RV3THLZF.js +78 -0
- package/understanding-GQKNDDWM.js +271 -0
- package/updateCommands-VOSPKXFF.js +31 -0
- package/updateDialogTitleAction-ZTWRDXI2.js +188 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// packages/core/retryAfterMs.ts
|
|
2
|
+
function normalizeNonNegativeMs(value, fallbackMs) {
|
|
3
|
+
const parsed = Number(value);
|
|
4
|
+
return Number.isFinite(parsed) && parsed >= 0 ? Math.round(parsed) : Math.round(Number(fallbackMs)) || 0;
|
|
5
|
+
}
|
|
6
|
+
function parseRetryAfterHeaderMs(value, nowMs = Date.now()) {
|
|
7
|
+
if (typeof value !== "string" || !value.trim()) return null;
|
|
8
|
+
const trimmed = value.trim();
|
|
9
|
+
const seconds = Number(trimmed);
|
|
10
|
+
if (Number.isFinite(seconds)) {
|
|
11
|
+
if (seconds < 0) return null;
|
|
12
|
+
return Math.round(seconds * 1e3);
|
|
13
|
+
}
|
|
14
|
+
const parsedDateMs = Date.parse(trimmed);
|
|
15
|
+
if (Number.isFinite(parsedDateMs)) {
|
|
16
|
+
return Math.max(0, parsedDateMs - nowMs);
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// packages/core/gatewayHttpStatus.ts
|
|
22
|
+
function isGatewayHttpStatus(status) {
|
|
23
|
+
return status === 502 || status === 503 || status === 504;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
normalizeNonNegativeMs,
|
|
28
|
+
parseRetryAfterHeaderMs,
|
|
29
|
+
isGatewayHttpStatus
|
|
30
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asOptionalPositiveFiniteNumber
|
|
3
|
+
} from "./chunk-U6VC4MU4.js";
|
|
4
|
+
|
|
5
|
+
// packages/database/tombstones.ts
|
|
6
|
+
var TOMBSTONE_DETAIL_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
|
|
7
|
+
var isRecord = (value) => value !== null && typeof value === "object";
|
|
8
|
+
var readRecord = (value) => isRecord(value) ? value : null;
|
|
9
|
+
var parseTimestamp = (value) => {
|
|
10
|
+
const asNumber = asOptionalPositiveFiniteNumber(value);
|
|
11
|
+
if (asNumber !== void 0) return asNumber;
|
|
12
|
+
if (typeof value === "string" && value.trim()) {
|
|
13
|
+
return asOptionalPositiveFiniteNumber(Date.parse(value)) ?? 0;
|
|
14
|
+
}
|
|
15
|
+
return 0;
|
|
16
|
+
};
|
|
17
|
+
var getRecordTimestamp = (record) => {
|
|
18
|
+
const value = readRecord(record);
|
|
19
|
+
if (!value) return 0;
|
|
20
|
+
const candidates = [
|
|
21
|
+
value.updatedAt,
|
|
22
|
+
value.updated_at,
|
|
23
|
+
value.createdAt,
|
|
24
|
+
value.created,
|
|
25
|
+
isRecord(value.meta) ? value.meta.createdAt : void 0
|
|
26
|
+
];
|
|
27
|
+
for (const candidate of candidates) {
|
|
28
|
+
const timestamp = parseTimestamp(candidate);
|
|
29
|
+
if (timestamp > 0) return timestamp;
|
|
30
|
+
}
|
|
31
|
+
return 0;
|
|
32
|
+
};
|
|
33
|
+
var getTombstoneTimestamp = (record) => {
|
|
34
|
+
const value = readRecord(record);
|
|
35
|
+
if (!value) return 0;
|
|
36
|
+
return parseTimestamp(value.deletedAt) || getRecordTimestamp(value);
|
|
37
|
+
};
|
|
38
|
+
var getRestoreTimestamp = (record) => {
|
|
39
|
+
const value = readRecord(record);
|
|
40
|
+
if (!value) return 0;
|
|
41
|
+
return parseTimestamp(value.restoredAt);
|
|
42
|
+
};
|
|
43
|
+
var isTombstoneRecord = (record) => {
|
|
44
|
+
const value = readRecord(record);
|
|
45
|
+
if (!value) return false;
|
|
46
|
+
const deletedAt = value.deletedAt;
|
|
47
|
+
if (typeof deletedAt === "string") return deletedAt.trim().length > 0;
|
|
48
|
+
return Boolean(deletedAt);
|
|
49
|
+
};
|
|
50
|
+
var isRestoredAfterTombstone = (activeRecord, tombstoneRecord) => {
|
|
51
|
+
if (isTombstoneRecord(activeRecord) || !isTombstoneRecord(tombstoneRecord)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const restoreTs = getRestoreTimestamp(activeRecord);
|
|
55
|
+
const tombstoneTs = getTombstoneTimestamp(tombstoneRecord);
|
|
56
|
+
return restoreTs > 0 && tombstoneTs > 0 && restoreTs > tombstoneTs;
|
|
57
|
+
};
|
|
58
|
+
var shouldReplaceWithNextRecord = (nextRecord, currentRecord) => {
|
|
59
|
+
const nextIsTombstone = isTombstoneRecord(nextRecord);
|
|
60
|
+
const currentIsTombstone = isTombstoneRecord(currentRecord);
|
|
61
|
+
if (currentIsTombstone && !nextIsTombstone) {
|
|
62
|
+
return isRestoredAfterTombstone(nextRecord, currentRecord);
|
|
63
|
+
}
|
|
64
|
+
if (nextIsTombstone && !currentIsTombstone) {
|
|
65
|
+
return !isRestoredAfterTombstone(currentRecord, nextRecord);
|
|
66
|
+
}
|
|
67
|
+
const nextTs = nextIsTombstone ? getTombstoneTimestamp(nextRecord) : getRecordTimestamp(nextRecord);
|
|
68
|
+
const currentTs = currentIsTombstone ? getTombstoneTimestamp(currentRecord) : getRecordTimestamp(currentRecord);
|
|
69
|
+
if (nextTs !== currentTs) return nextTs > currentTs;
|
|
70
|
+
return nextIsTombstone && !currentIsTombstone;
|
|
71
|
+
};
|
|
72
|
+
var buildTombstoneRecord = (record, nowIso) => {
|
|
73
|
+
const { restoredAt: _restoredAt, ...baseRecord } = record;
|
|
74
|
+
return {
|
|
75
|
+
...baseRecord,
|
|
76
|
+
deletedAt: nowIso,
|
|
77
|
+
updatedAt: nowIso
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export {
|
|
82
|
+
getRecordTimestamp,
|
|
83
|
+
isTombstoneRecord,
|
|
84
|
+
shouldReplaceWithNextRecord,
|
|
85
|
+
buildTombstoneRecord
|
|
86
|
+
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import {
|
|
2
|
+
listUserRecordsFromServers,
|
|
3
|
+
readLiveDbRecordAfterTombstoneMerge
|
|
4
|
+
} from "./chunk-WKM6FH35.js";
|
|
5
|
+
import {
|
|
6
|
+
agentRecordHasConfiguredCredential
|
|
7
|
+
} from "./chunk-7OOXPE3N.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
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveNoloHome
|
|
3
|
+
} from "./chunk-LM6IYQ3F.js";
|
|
4
|
+
|
|
5
|
+
// packages/cli/localRuntimeDb.ts
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
function resolveCliLocalRuntimeDbPath(options = {}) {
|
|
8
|
+
return path.join(resolveNoloHome(options), "data", "leveldb");
|
|
9
|
+
}
|
|
10
|
+
function buildCliLocalRuntimeDbEnv(env = process.env) {
|
|
11
|
+
return {
|
|
12
|
+
...env,
|
|
13
|
+
NOLO_SERVER_DB_PATH: env.NOLO_SERVER_DB_PATH?.trim() || resolveCliLocalRuntimeDbPath({ env })
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
async function getDefaultCliLocalRuntimeDb(options = {}) {
|
|
17
|
+
const { getDefaultCliLocalRuntimeDb: getAuthorityBackedDb } = await import("./localRuntimeAuthority-TEGCOWX4.js");
|
|
18
|
+
return getAuthorityBackedDb(options);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
resolveCliLocalRuntimeDbPath,
|
|
23
|
+
buildCliLocalRuntimeDbEnv,
|
|
24
|
+
getDefaultCliLocalRuntimeDb
|
|
25
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// packages/core/errorMessage.ts
|
|
2
|
+
function toErrorMessage(error) {
|
|
3
|
+
if (error instanceof Error) return error.message;
|
|
4
|
+
if (error !== null && typeof error === "object" && "message" in error && typeof error.message === "string") {
|
|
5
|
+
return error.message;
|
|
6
|
+
}
|
|
7
|
+
return String(error);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
toErrorMessage
|
|
12
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// packages/core/stringArray.ts
|
|
2
|
+
function asNonEmptyStringArray(value) {
|
|
3
|
+
if (!Array.isArray(value)) return [];
|
|
4
|
+
return value.filter(
|
|
5
|
+
(item) => typeof item === "string" && !!item.trim()
|
|
6
|
+
);
|
|
7
|
+
}
|
|
8
|
+
function asTrimmedNonEmptyStringArray(value) {
|
|
9
|
+
return asNonEmptyStringArray(value).map((item) => item.trim());
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
asNonEmptyStringArray,
|
|
14
|
+
asTrimmedNonEmptyStringArray
|
|
15
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// packages/cli/processSpawn.ts
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
function spawnProcess(options) {
|
|
4
|
+
let [command, ...args] = options.cmd;
|
|
5
|
+
if (process.platform === "win32") {
|
|
6
|
+
const lower = command.toLowerCase();
|
|
7
|
+
if ((lower === "npm" || lower === "npx" || lower === "pnpm" || lower === "yarn" || lower === "nolo") && !lower.endsWith(".cmd") && !lower.endsWith(".exe") && !lower.endsWith(".bat")) {
|
|
8
|
+
command = `${command}.cmd`;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
let child;
|
|
12
|
+
try {
|
|
13
|
+
child = spawn(command, args, {
|
|
14
|
+
cwd: options.cwd,
|
|
15
|
+
env: options.env,
|
|
16
|
+
stdio: [
|
|
17
|
+
options.stdin ?? "pipe",
|
|
18
|
+
options.stdout ?? "pipe",
|
|
19
|
+
options.stderr ?? "pipe"
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
} catch {
|
|
23
|
+
return {
|
|
24
|
+
exited: Promise.resolve(127),
|
|
25
|
+
stdin: null,
|
|
26
|
+
stdout: null,
|
|
27
|
+
stderr: null
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const exited = new Promise((resolve) => {
|
|
31
|
+
child.on("exit", (code) => resolve(code ?? 1));
|
|
32
|
+
child.on("error", () => resolve(127));
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
exited,
|
|
36
|
+
stdin: child.stdin,
|
|
37
|
+
stdout: child.stdout,
|
|
38
|
+
stderr: child.stderr
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async function readPipeText(stream) {
|
|
42
|
+
if (!stream) return "";
|
|
43
|
+
const anyStream = stream;
|
|
44
|
+
if (typeof anyStream.setEncoding !== "function" && typeof anyStream[Symbol.asyncIterator] === "function") {
|
|
45
|
+
const chunks = [];
|
|
46
|
+
for await (const chunk of anyStream) {
|
|
47
|
+
if (typeof chunk === "string") chunks.push(chunk);
|
|
48
|
+
else if (chunk instanceof Uint8Array) chunks.push(Buffer.from(chunk).toString("utf8"));
|
|
49
|
+
else if (Buffer.isBuffer(chunk)) chunks.push(chunk.toString("utf8"));
|
|
50
|
+
else chunks.push(String(chunk ?? ""));
|
|
51
|
+
}
|
|
52
|
+
return chunks.join("");
|
|
53
|
+
}
|
|
54
|
+
return new Promise((resolve) => {
|
|
55
|
+
let data = "";
|
|
56
|
+
let done = false;
|
|
57
|
+
const finish = () => {
|
|
58
|
+
if (done) return;
|
|
59
|
+
done = true;
|
|
60
|
+
resolve(data);
|
|
61
|
+
};
|
|
62
|
+
if (typeof anyStream.setEncoding === "function") {
|
|
63
|
+
anyStream.setEncoding("utf8");
|
|
64
|
+
}
|
|
65
|
+
stream.on("data", (chunk) => {
|
|
66
|
+
data += typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8");
|
|
67
|
+
});
|
|
68
|
+
stream.on("end", finish);
|
|
69
|
+
stream.on("close", finish);
|
|
70
|
+
stream.on("error", finish);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function resolveDefaultSpawn() {
|
|
74
|
+
const bunSpawn = globalThis.Bun?.spawn;
|
|
75
|
+
if (typeof bunSpawn === "function") {
|
|
76
|
+
return bunSpawn;
|
|
77
|
+
}
|
|
78
|
+
return spawnProcess;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export {
|
|
82
|
+
spawnProcess,
|
|
83
|
+
readPipeText,
|
|
84
|
+
resolveDefaultSpawn
|
|
85
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_NOLO_SERVER_URL
|
|
3
|
+
} from "./chunk-OLZBQWZU.js";
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_LOCAL_API_ORIGIN
|
|
6
|
+
} from "./chunk-4SN6J65J.js";
|
|
7
|
+
import {
|
|
8
|
+
NOLO_CLUSTER_SERVERS
|
|
9
|
+
} from "./chunk-LCBAMY2M.js";
|
|
10
|
+
import {
|
|
11
|
+
normalizeServerOrigin
|
|
12
|
+
} from "./chunk-CF7PE763.js";
|
|
13
|
+
import {
|
|
14
|
+
asOptionalTrimmedString
|
|
15
|
+
} from "./chunk-G3SUCT4W.js";
|
|
16
|
+
|
|
17
|
+
// packages/cli/cliEnvHelpers.ts
|
|
18
|
+
import { dirname, extname, join } from "node:path";
|
|
19
|
+
import { fileURLToPath } from "node:url";
|
|
20
|
+
function resolveServerUrlFromEnv(env) {
|
|
21
|
+
return normalizeServerOrigin(
|
|
22
|
+
env.NOLO_SERVER || env.BASE_URL || DEFAULT_NOLO_SERVER_URL
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
function isCliArgs(value) {
|
|
26
|
+
return Array.isArray(value);
|
|
27
|
+
}
|
|
28
|
+
function buildServerCandidates(values) {
|
|
29
|
+
return [...new Set(
|
|
30
|
+
values.filter((value) => typeof value === "string" && value.trim().length > 0).map((value) => normalizeServerOrigin(value))
|
|
31
|
+
)];
|
|
32
|
+
}
|
|
33
|
+
function resolveServerUrl(input, env) {
|
|
34
|
+
if (isCliArgs(input)) {
|
|
35
|
+
const explicit = readOption(input, "--server-url") || readOption(input, "--server");
|
|
36
|
+
return normalizeServerOrigin(explicit) || resolveServerUrlFromEnv(env ?? {});
|
|
37
|
+
}
|
|
38
|
+
return resolveServerUrlFromEnv(input);
|
|
39
|
+
}
|
|
40
|
+
function resolveServerCandidates(input, envOrPreferred, preferred) {
|
|
41
|
+
if (isCliArgs(input)) {
|
|
42
|
+
const env2 = envOrPreferred ?? {};
|
|
43
|
+
const explicitServer = resolveServerUrl(input, env2);
|
|
44
|
+
return buildServerCandidates([
|
|
45
|
+
explicitServer,
|
|
46
|
+
preferred?.trim(),
|
|
47
|
+
env2.NOLO_SERVER,
|
|
48
|
+
env2.BASE_URL,
|
|
49
|
+
env2.NOLO_SERVER_URL,
|
|
50
|
+
DEFAULT_NOLO_SERVER_URL,
|
|
51
|
+
...NOLO_CLUSTER_SERVERS
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
const env = input;
|
|
55
|
+
return buildServerCandidates([
|
|
56
|
+
asOptionalTrimmedString(envOrPreferred),
|
|
57
|
+
env.NOLO_SERVER,
|
|
58
|
+
env.BASE_URL,
|
|
59
|
+
env.NOLO_SERVER_URL,
|
|
60
|
+
DEFAULT_NOLO_SERVER_URL,
|
|
61
|
+
...NOLO_CLUSTER_SERVERS
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
64
|
+
function resolveDeleteServerCandidatesFromEnv(env, ...preferredValues) {
|
|
65
|
+
return buildServerCandidates([
|
|
66
|
+
...preferredValues,
|
|
67
|
+
env.NOLO_SERVER,
|
|
68
|
+
env.BASE_URL,
|
|
69
|
+
env.NOLO_SERVER_URL,
|
|
70
|
+
env.READ_DIALOG_BASE,
|
|
71
|
+
DEFAULT_NOLO_SERVER_URL,
|
|
72
|
+
...NOLO_CLUSTER_SERVERS,
|
|
73
|
+
DEFAULT_LOCAL_API_ORIGIN
|
|
74
|
+
]);
|
|
75
|
+
}
|
|
76
|
+
function resolveDeleteServerCandidates(input, envOrPreferred, preferred) {
|
|
77
|
+
if (isCliArgs(input)) {
|
|
78
|
+
const env2 = envOrPreferred ?? {};
|
|
79
|
+
const explicitServer = resolveServerUrl(input, env2);
|
|
80
|
+
return resolveDeleteServerCandidatesFromEnv(env2, explicitServer, preferred?.trim());
|
|
81
|
+
}
|
|
82
|
+
const env = input;
|
|
83
|
+
return resolveDeleteServerCandidatesFromEnv(
|
|
84
|
+
env,
|
|
85
|
+
asOptionalTrimmedString(envOrPreferred)
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
function resolveAuthTokenFromEnv(env, extraEnvKeys = []) {
|
|
89
|
+
for (const key of ["AUTH_TOKEN", "AUTH", ...extraEnvKeys]) {
|
|
90
|
+
const value = env[key];
|
|
91
|
+
if (typeof value === "string" && value.trim()) return value;
|
|
92
|
+
}
|
|
93
|
+
return "";
|
|
94
|
+
}
|
|
95
|
+
function resolveAuthToken(input, envOrExtraEnvKeys, extraEnvKeys = []) {
|
|
96
|
+
if (isCliArgs(input)) {
|
|
97
|
+
const env = envOrExtraEnvKeys ?? {};
|
|
98
|
+
return readOption(input, "--token") || readOption(input, "--machine-key") || resolveAuthTokenFromEnv(env, extraEnvKeys);
|
|
99
|
+
}
|
|
100
|
+
return resolveAuthTokenFromEnv(input, envOrExtraEnvKeys ?? []);
|
|
101
|
+
}
|
|
102
|
+
function parseUserIdFromAuthToken(token) {
|
|
103
|
+
const parts = token.trim().split(".").filter(Boolean);
|
|
104
|
+
const payloadCandidates = parts.length >= 3 ? [parts[1], parts[0]] : [parts[0]];
|
|
105
|
+
for (const payload of payloadCandidates) {
|
|
106
|
+
if (!payload) continue;
|
|
107
|
+
try {
|
|
108
|
+
const parsed = JSON.parse(Buffer.from(payload, "base64").toString("utf8"));
|
|
109
|
+
if (typeof parsed?.userId === "string") return parsed.userId;
|
|
110
|
+
} catch {
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return "";
|
|
114
|
+
}
|
|
115
|
+
function readOption(args, flag) {
|
|
116
|
+
const index = args.indexOf(flag);
|
|
117
|
+
return index >= 0 ? args[index + 1] : void 0;
|
|
118
|
+
}
|
|
119
|
+
function isCompiledBinary() {
|
|
120
|
+
try {
|
|
121
|
+
const url = import.meta.url;
|
|
122
|
+
return url.startsWith("file:///$bunfs/root/") || url.startsWith("/$bunfs/root/");
|
|
123
|
+
} catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function resolveCliEntrypointPath(fromModuleUrl = import.meta.url) {
|
|
128
|
+
if (isCompiledBinary()) {
|
|
129
|
+
return process.execPath;
|
|
130
|
+
}
|
|
131
|
+
const sourcePath = fileURLToPath(fromModuleUrl);
|
|
132
|
+
const ext = extname(sourcePath) || ".ts";
|
|
133
|
+
return join(dirname(sourcePath), "..", `index${ext}`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export {
|
|
137
|
+
resolveServerUrl,
|
|
138
|
+
resolveServerCandidates,
|
|
139
|
+
resolveDeleteServerCandidates,
|
|
140
|
+
resolveAuthTokenFromEnv,
|
|
141
|
+
resolveAuthToken,
|
|
142
|
+
parseUserIdFromAuthToken,
|
|
143
|
+
readOption,
|
|
144
|
+
isCompiledBinary,
|
|
145
|
+
resolveCliEntrypointPath
|
|
146
|
+
};
|