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,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
trimTrailingSlash
|
|
3
|
+
} from "./chunk-JRKKFRAV.js";
|
|
4
|
+
import {
|
|
5
|
+
asTrimmedLowercaseString
|
|
6
|
+
} from "./chunk-QSJ3HFEF.js";
|
|
7
|
+
import {
|
|
8
|
+
asOptionalTrimmedString
|
|
9
|
+
} from "./chunk-G3SUCT4W.js";
|
|
10
|
+
|
|
11
|
+
// packages/agent-runtime/antigravityOAuth.ts
|
|
12
|
+
var ANTIGRAVITY_CLOUD_CODE_BASE_URL = "https://daily-cloudcode-pa.googleapis.com";
|
|
13
|
+
var ANTIGRAVITY_CLOUD_CODE_HOST = "cloudcode-pa.googleapis.com";
|
|
14
|
+
var ANTIGRAVITY_LEGACY_GENERIC_BASE_RE = /^https?:\/\/cloudcode-pa\.googleapis\.com$/i;
|
|
15
|
+
function getAntigravityUserAgent() {
|
|
16
|
+
const version = process.env.NOLO_ANTIGRAVITY_VERSION || "2.1.4";
|
|
17
|
+
const os = process.platform === "win32" ? "windows" : process.platform;
|
|
18
|
+
const arch = process.arch === "x64" ? "amd64" : process.arch === "ia32" ? "386" : process.arch;
|
|
19
|
+
return `antigravity/hub/${version} ${os}/${arch}`;
|
|
20
|
+
}
|
|
21
|
+
function resolveAntigravityCloudCodeBaseUrl(customProviderUrl) {
|
|
22
|
+
const raw = (customProviderUrl ?? "").trim();
|
|
23
|
+
if (!raw) return ANTIGRAVITY_CLOUD_CODE_BASE_URL;
|
|
24
|
+
const trimmed = trimTrailingSlash(raw);
|
|
25
|
+
if (trimmed.includes(ANTIGRAVITY_CLOUD_CODE_HOST)) {
|
|
26
|
+
const base = trimmed.replace(/\/v1internal:.*$/i, "").replace(/\/$/, "");
|
|
27
|
+
if (ANTIGRAVITY_LEGACY_GENERIC_BASE_RE.test(base)) {
|
|
28
|
+
return ANTIGRAVITY_CLOUD_CODE_BASE_URL;
|
|
29
|
+
}
|
|
30
|
+
return base;
|
|
31
|
+
}
|
|
32
|
+
return ANTIGRAVITY_CLOUD_CODE_BASE_URL;
|
|
33
|
+
}
|
|
34
|
+
function isAntigravityOAuthAgent(agentConfig) {
|
|
35
|
+
if (!agentConfig) return false;
|
|
36
|
+
const apiKeyRef = asTrimmedLowercaseString(agentConfig.apiKeyRef);
|
|
37
|
+
const provider = asTrimmedLowercaseString(agentConfig.provider);
|
|
38
|
+
const url = asTrimmedLowercaseString(agentConfig.customProviderUrl);
|
|
39
|
+
return apiKeyRef === "antigravity" || provider === "google-antigravity" || url.includes(ANTIGRAVITY_CLOUD_CODE_HOST);
|
|
40
|
+
}
|
|
41
|
+
function readAntigravityProjectId(metadata) {
|
|
42
|
+
return asOptionalTrimmedString(metadata?.projectId);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
ANTIGRAVITY_CLOUD_CODE_BASE_URL,
|
|
47
|
+
getAntigravityUserAgent,
|
|
48
|
+
resolveAntigravityCloudCodeBaseUrl,
|
|
49
|
+
isAntigravityOAuthAgent,
|
|
50
|
+
readAntigravityProjectId
|
|
51
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MEMORY_USE_GUIDANCE
|
|
3
|
+
} from "./chunk-KKY4B2Q2.js";
|
|
4
|
+
|
|
5
|
+
// packages/agent-runtime/turnContext.ts
|
|
6
|
+
var DEFAULT_RECENT_CONTENT_LIMIT = 10;
|
|
7
|
+
var asTrimmed = (value) => typeof value === "string" ? value.trim() : "";
|
|
8
|
+
var asFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
9
|
+
var spaceRecordKey = (spaceId) => spaceId.startsWith("space-") ? spaceId : `space-${spaceId}`;
|
|
10
|
+
var makeLayer = (id, content, cacheScope = "turn") => ({ id, owner: "runtime", cacheScope, content });
|
|
11
|
+
var renderSpaceStructure = (spaceRecord, recentLimit) => {
|
|
12
|
+
const categories = spaceRecord.categories ?? {};
|
|
13
|
+
const validCategories = Object.entries(categories).filter((entry) => entry[1] !== null).sort(
|
|
14
|
+
(a, b) => asFiniteNumber(a[1].order) - asFiniteNumber(b[1].order)
|
|
15
|
+
);
|
|
16
|
+
const categoryNameById = /* @__PURE__ */ new Map();
|
|
17
|
+
let struct = "Directory Structure (Categories):\n";
|
|
18
|
+
if (validCategories.length === 0) struct += "(No categories defined)\n";
|
|
19
|
+
validCategories.forEach(([id, category]) => {
|
|
20
|
+
const name = asTrimmed(category.name) || id;
|
|
21
|
+
categoryNameById.set(id, name);
|
|
22
|
+
struct += `- ${name} (ID: ${id})
|
|
23
|
+
`;
|
|
24
|
+
});
|
|
25
|
+
const contents = spaceRecord.contents ?? {};
|
|
26
|
+
const recentContents = recentLimit > 0 ? Object.values(contents).filter((content) => content !== null).sort(
|
|
27
|
+
(a, b) => asFiniteNumber(b.updatedAt) - asFiniteNumber(a.updatedAt)
|
|
28
|
+
).slice(0, recentLimit) : [];
|
|
29
|
+
if (recentContents.length > 0) {
|
|
30
|
+
struct += `
|
|
31
|
+
Recent Contents (Top ${recentLimit}):
|
|
32
|
+
`;
|
|
33
|
+
recentContents.forEach((content) => {
|
|
34
|
+
const categoryId = asTrimmed(content.categoryId);
|
|
35
|
+
const categoryName = categoryId ? categoryNameById.get(categoryId) || "Unknown" : "Uncategorized";
|
|
36
|
+
struct += `- [${asTrimmed(content.type) || "content"}] ${asTrimmed(content.title)} (Category: ${categoryName}, dbKey: ${asTrimmed(content.contentKey)})
|
|
37
|
+
`;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return struct;
|
|
41
|
+
};
|
|
42
|
+
var buildSpaceContextLayer = async (args) => {
|
|
43
|
+
const spaceId = asTrimmed(args.spaceId);
|
|
44
|
+
if (!spaceId) return null;
|
|
45
|
+
const recentLimit = args.recentContentLimit ?? DEFAULT_RECENT_CONTENT_LIMIT;
|
|
46
|
+
let spaceRecord = null;
|
|
47
|
+
let readError = null;
|
|
48
|
+
try {
|
|
49
|
+
spaceRecord = await args.source.readRecord(spaceRecordKey(spaceId));
|
|
50
|
+
} catch (error) {
|
|
51
|
+
readError = error instanceof Error ? error.message : String(error);
|
|
52
|
+
}
|
|
53
|
+
if (!spaceRecord) {
|
|
54
|
+
return makeLayer(
|
|
55
|
+
"space-context",
|
|
56
|
+
[
|
|
57
|
+
"--- \u5F53\u524D\u7A7A\u95F4\uFF08Space\uFF09---",
|
|
58
|
+
`\u672C\u5BF9\u8BDD\u8BB0\u5F55\u58F0\u660E\u5C5E\u4E8E Space ${spaceId}\uFF0C\u4F46\u5F53\u524D\u65E0\u6CD5\u8BFB\u53D6\u8BE5 Space \u7684\u6570\u636E${readError ? `\uFF08${readError}\uFF09` : "\uFF08\u8BB0\u5F55\u4E0D\u5B58\u5728\u6216\u4E0D\u53EF\u8FBE\uFF09"}\u3002`,
|
|
59
|
+
"\u5982\u88AB\u95EE\u53CA\uFF0C\u8BF7\u5982\u5B9E\u8BF4\u660E\u300C\u5BF9\u8BDD\u5C5E\u4E8E\u8BE5 Space \u4F46\u6682\u65F6\u8BFB\u4E0D\u5230\u7A7A\u95F4\u8BE6\u60C5\u300D\uFF0C\u4E0D\u8981\u58F0\u79F0\u5BF9\u8BDD\u4E0D\u5C5E\u4E8E\u4EFB\u4F55\u7A7A\u95F4\u3002"
|
|
60
|
+
].join("\n")
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
const name = asTrimmed(spaceRecord.name);
|
|
64
|
+
const description = asTrimmed(spaceRecord.description);
|
|
65
|
+
const structure = renderSpaceStructure(spaceRecord, recentLimit);
|
|
66
|
+
return makeLayer(
|
|
67
|
+
"space-context",
|
|
68
|
+
[
|
|
69
|
+
"--- \u5F53\u524D\u7A7A\u95F4\uFF08Space\uFF09---",
|
|
70
|
+
"\u672C\u5BF9\u8BDD\u5C5E\u4E8E\u4EE5\u4E0B Space\uFF1A",
|
|
71
|
+
`Space Title: ${name || spaceId}`,
|
|
72
|
+
`Space ID: ${spaceId}`,
|
|
73
|
+
`Description: ${description || "N/A"}`,
|
|
74
|
+
"",
|
|
75
|
+
structure.trimEnd()
|
|
76
|
+
].join("\n")
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
var buildSkillDiscoveryLayer = (skills, boundFolder) => {
|
|
80
|
+
if (skills.length === 0) return null;
|
|
81
|
+
const lines = [
|
|
82
|
+
"--- \u53EF\u7528\u6280\u80FD\uFF08Skills\uFF09---",
|
|
83
|
+
`\u5DE5\u4F5C\u533A ${boundFolder} \u4E2D\u53D1\u73B0\u4E86 ${skills.length} \u4E2A\u6280\u80FD\uFF08SKILL.md\uFF09\uFF1A`,
|
|
84
|
+
"\u6A21\u578B\u53EF\u6309\u9700\u7528 loadSkill \u5DE5\u5177\u6309\u540D\u52A0\u8F7D\uFF0C\u628A SKILL.md \u5168\u6587\u62C9\u8FDB\u4E0A\u4E0B\u6587\u540E\u9075\u5FAA\u5176\u6307\u4EE4\uFF1B",
|
|
85
|
+
"\u5982 loadSkill \u4E0D\u53EF\u7528\u6216\u60F3\u76F4\u63A5\u8BFB\u53D6\u6587\u4EF6\uFF0C\u4E0B\u65B9 path \u4ECD\u53EF\u7528 readFile \u4F5C\u4E3A fallback\uFF1A",
|
|
86
|
+
"",
|
|
87
|
+
...skills.map(
|
|
88
|
+
(s) => `- ${s.name}: ${s.description}
|
|
89
|
+
path: ${s.relativePath}`
|
|
90
|
+
)
|
|
91
|
+
];
|
|
92
|
+
return makeLayer("skill-discovery", lines.join("\n"));
|
|
93
|
+
};
|
|
94
|
+
var buildLinkedSpacesSection = async (args) => {
|
|
95
|
+
const ids = (args.linkedSpaceIds ?? []).filter(
|
|
96
|
+
(id) => typeof id === "string" && id.trim() !== ""
|
|
97
|
+
);
|
|
98
|
+
if (ids.length === 0) return null;
|
|
99
|
+
const lines = [];
|
|
100
|
+
for (const rawId of ids) {
|
|
101
|
+
const spaceId = asTrimmed(rawId);
|
|
102
|
+
let spaceData = null;
|
|
103
|
+
try {
|
|
104
|
+
spaceData = await args.source.readRecord(spaceRecordKey(spaceId));
|
|
105
|
+
} catch {
|
|
106
|
+
spaceData = null;
|
|
107
|
+
}
|
|
108
|
+
if (spaceData) {
|
|
109
|
+
const name = asTrimmed(spaceData.name) || spaceId;
|
|
110
|
+
const desc = asTrimmed(spaceData.description);
|
|
111
|
+
lines.push(`- ${name} (ID: ${spaceId})${desc ? `: ${desc}` : ""}`);
|
|
112
|
+
} else {
|
|
113
|
+
lines.push(`- [\u65E0\u6CD5\u8BBF\u95EE] ${spaceId}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (lines.length === 0) return null;
|
|
117
|
+
return [
|
|
118
|
+
"--- \u5173\u8054\u7A7A\u95F4 (Linked Spaces) ---",
|
|
119
|
+
"\u4EE5\u4E0B\u662F Agent \u53EF\u8BBF\u95EE\u7684\u5176\u4ED6\u5DE5\u4F5C\u7A7A\u95F4\uFF08\u7C97\u7565\u4E0A\u4E0B\u6587\uFF09\uFF1A",
|
|
120
|
+
lines.join("\n"),
|
|
121
|
+
"",
|
|
122
|
+
"\u63D0\u793A\uFF1A\u5982\u9700\u67E5\u8BE2\u8FD9\u4E9B\u7A7A\u95F4\u7684\u8BE6\u7EC6\u5185\u5BB9\uFF0C\u53EF\u4F7F\u7528 read \u5DE5\u5177\u914D\u5408\u5BF9\u5E94\u7684 dbKey\u3002"
|
|
123
|
+
].join("\n");
|
|
124
|
+
};
|
|
125
|
+
var buildMemoryOverlayLayer = (args) => {
|
|
126
|
+
const promptBlock = asTrimmed(args.promptBlock);
|
|
127
|
+
if (!promptBlock) return null;
|
|
128
|
+
return makeLayer("memory-overlay", promptBlock);
|
|
129
|
+
};
|
|
130
|
+
var buildMemoryUseGuidanceLayer = (args) => {
|
|
131
|
+
const promptBlock = asTrimmed(args.promptBlock);
|
|
132
|
+
if (!promptBlock) return null;
|
|
133
|
+
return makeLayer(
|
|
134
|
+
"memory-use-guidance",
|
|
135
|
+
MEMORY_USE_GUIDANCE,
|
|
136
|
+
"session"
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export {
|
|
141
|
+
buildSpaceContextLayer,
|
|
142
|
+
buildSkillDiscoveryLayer,
|
|
143
|
+
buildLinkedSpacesSection,
|
|
144
|
+
buildMemoryOverlayLayer,
|
|
145
|
+
buildMemoryUseGuidanceLayer
|
|
146
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Level
|
|
3
|
+
} from "./chunk-6WD3OOJS.js";
|
|
4
|
+
|
|
5
|
+
// packages/database/levelLockError.ts
|
|
6
|
+
function isLevelLockError(error) {
|
|
7
|
+
if (error == null) return false;
|
|
8
|
+
const text = typeof error === "object" ? `${error.code ?? ""} ${error.message ?? error}` : String(error);
|
|
9
|
+
return /LEVEL_LOCKED|Resource temporarily unavailable|\/LOCK|LOCK:/.test(text);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// packages/database-engine/levelAuthorityStore.ts
|
|
13
|
+
var safeJsonEncoding = {
|
|
14
|
+
name: "safe-json",
|
|
15
|
+
format: "utf8",
|
|
16
|
+
encode: (data) => JSON.stringify(data),
|
|
17
|
+
decode: (data) => {
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(data);
|
|
20
|
+
} catch {
|
|
21
|
+
console.warn("[LevelDB] Corrupted value:", data?.substring?.(0, 60));
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
function createLevelAuthorityStore(source) {
|
|
27
|
+
const levelDb = typeof source === "string" ? new Level(source, { valueEncoding: safeJsonEncoding }) : source;
|
|
28
|
+
const writeBatchOps = async (ops) => {
|
|
29
|
+
const result = levelDb.batch(ops);
|
|
30
|
+
if (result && typeof result.then === "function") {
|
|
31
|
+
await result;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (result && typeof result.write === "function") {
|
|
35
|
+
const writer = result;
|
|
36
|
+
for (const op of ops) {
|
|
37
|
+
if (op.type === "put") {
|
|
38
|
+
writer.put(op.key, op.value);
|
|
39
|
+
} else {
|
|
40
|
+
writer.del(op.key);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
await writer.write();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
throw new Error("Level backing does not support batch writes");
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
get location() {
|
|
50
|
+
return levelDb.location;
|
|
51
|
+
},
|
|
52
|
+
get status() {
|
|
53
|
+
return levelDb.status;
|
|
54
|
+
},
|
|
55
|
+
async open() {
|
|
56
|
+
await levelDb.open();
|
|
57
|
+
},
|
|
58
|
+
async close() {
|
|
59
|
+
await levelDb.close();
|
|
60
|
+
},
|
|
61
|
+
async get(key) {
|
|
62
|
+
return levelDb.get(key);
|
|
63
|
+
},
|
|
64
|
+
async put(key, value) {
|
|
65
|
+
await levelDb.put(key, value);
|
|
66
|
+
},
|
|
67
|
+
async del(key) {
|
|
68
|
+
await levelDb.del(key);
|
|
69
|
+
},
|
|
70
|
+
async batchWrite(ops) {
|
|
71
|
+
await writeBatchOps(ops);
|
|
72
|
+
},
|
|
73
|
+
createBatch() {
|
|
74
|
+
const batch = levelDb.batch();
|
|
75
|
+
return {
|
|
76
|
+
put(key, value) {
|
|
77
|
+
batch.put(key, value);
|
|
78
|
+
},
|
|
79
|
+
del(key) {
|
|
80
|
+
batch.del(key);
|
|
81
|
+
},
|
|
82
|
+
async write() {
|
|
83
|
+
await batch.write();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
iterator(options = {}) {
|
|
88
|
+
return levelDb.iterator(options);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// packages/database-engine/legacyServerDb.ts
|
|
94
|
+
function createLegacyServerDb(store) {
|
|
95
|
+
const batch = (ops) => {
|
|
96
|
+
if (Array.isArray(ops)) {
|
|
97
|
+
return store.batchWrite(ops);
|
|
98
|
+
}
|
|
99
|
+
return store.createBatch();
|
|
100
|
+
};
|
|
101
|
+
return {
|
|
102
|
+
get location() {
|
|
103
|
+
return store.location;
|
|
104
|
+
},
|
|
105
|
+
get status() {
|
|
106
|
+
return store.status;
|
|
107
|
+
},
|
|
108
|
+
async open() {
|
|
109
|
+
await store.open();
|
|
110
|
+
},
|
|
111
|
+
async close() {
|
|
112
|
+
await store.close();
|
|
113
|
+
},
|
|
114
|
+
async get(key) {
|
|
115
|
+
return store.get(key);
|
|
116
|
+
},
|
|
117
|
+
async put(key, value) {
|
|
118
|
+
await store.put(key, value);
|
|
119
|
+
},
|
|
120
|
+
async del(key) {
|
|
121
|
+
await store.del(key);
|
|
122
|
+
},
|
|
123
|
+
batch,
|
|
124
|
+
iterator(options = {}) {
|
|
125
|
+
return store.iterator(options);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export {
|
|
131
|
+
isLevelLockError,
|
|
132
|
+
createLevelAuthorityStore,
|
|
133
|
+
createLegacyServerDb
|
|
134
|
+
};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadProfileConfig
|
|
3
|
+
} from "./chunk-ROWQEJRP.js";
|
|
4
|
+
import {
|
|
5
|
+
resolveDefaultSpawn
|
|
6
|
+
} from "./chunk-IDZTNRP2.js";
|
|
7
|
+
import {
|
|
8
|
+
isCompiledBinary
|
|
9
|
+
} from "./chunk-ISNCLGUZ.js";
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_NOLO_SERVER_URL
|
|
12
|
+
} from "./chunk-OLZBQWZU.js";
|
|
13
|
+
import {
|
|
14
|
+
normalizeServerOrigin
|
|
15
|
+
} from "./chunk-CF7PE763.js";
|
|
16
|
+
|
|
17
|
+
// packages/cli/updateCommands.ts
|
|
18
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
19
|
+
import { dirname, join } from "node:path";
|
|
20
|
+
import { fileURLToPath } from "node:url";
|
|
21
|
+
function resolvePackageJsonPath() {
|
|
22
|
+
if (isCompiledBinary()) {
|
|
23
|
+
const execDir = dirname(process.execPath);
|
|
24
|
+
const candidate2 = join(execDir, "package.json");
|
|
25
|
+
if (existsSync(candidate2)) return candidate2;
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const CLI_DIR = dirname(fileURLToPath(import.meta.url));
|
|
29
|
+
const candidate = join(CLI_DIR, "package.json");
|
|
30
|
+
return existsSync(candidate) ? candidate : null;
|
|
31
|
+
}
|
|
32
|
+
var PACKAGE_JSON_PATH = resolvePackageJsonPath();
|
|
33
|
+
function getCliInstallChannel(serverUrl) {
|
|
34
|
+
const normalized = normalizeServerOrigin(serverUrl);
|
|
35
|
+
if (!normalized) {
|
|
36
|
+
return "latest";
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const hostname = new URL(normalized).hostname.toLowerCase();
|
|
40
|
+
if (hostname === "us.nolo.chat" || hostname.endsWith(".us.nolo.chat")) {
|
|
41
|
+
return "alpha";
|
|
42
|
+
}
|
|
43
|
+
} catch {
|
|
44
|
+
if (/us\.nolo\.chat/i.test(normalized)) {
|
|
45
|
+
return "alpha";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return "latest";
|
|
49
|
+
}
|
|
50
|
+
function renderProgressBar(percent, width = 30) {
|
|
51
|
+
const pct = Math.max(0, Math.min(100, percent));
|
|
52
|
+
const filledLen = Math.round(width * pct / 100);
|
|
53
|
+
const emptyLen = width - filledLen;
|
|
54
|
+
const bar = "#".repeat(filledLen) + " ".repeat(emptyLen);
|
|
55
|
+
const pctText = pct.toFixed(1).padStart(5, " ");
|
|
56
|
+
return `[${bar}] ${pctText}%`;
|
|
57
|
+
}
|
|
58
|
+
function buildNpmSelfUpdateCommand(channel = "latest") {
|
|
59
|
+
return ["npm", "install", "-g", `nolo-cli@${channel}`, "--force", "--progress"];
|
|
60
|
+
}
|
|
61
|
+
function readPackageInfo() {
|
|
62
|
+
if (PACKAGE_JSON_PATH) {
|
|
63
|
+
try {
|
|
64
|
+
const raw = readFileSync(PACKAGE_JSON_PATH, "utf8");
|
|
65
|
+
const parsed = JSON.parse(raw);
|
|
66
|
+
return {
|
|
67
|
+
name: parsed.name || "nolo-cli",
|
|
68
|
+
version: parsed.version || "0.0.0"
|
|
69
|
+
};
|
|
70
|
+
} catch {
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
name: process.env.NOLO_CLI_PACKAGE_NAME || "nolo-cli",
|
|
75
|
+
version: process.env.NOLO_CLI_VERSION || "0.0.0"
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function buildCliVersionText(info) {
|
|
79
|
+
return `${info.name} ${info.version}`;
|
|
80
|
+
}
|
|
81
|
+
function buildSelfUpdateCommand(serverUrl) {
|
|
82
|
+
return buildNpmSelfUpdateCommand(getCliInstallChannel(serverUrl));
|
|
83
|
+
}
|
|
84
|
+
function resolveSelfUpdateServerUrl(env = process.env, override) {
|
|
85
|
+
if (override?.trim()) {
|
|
86
|
+
return normalizeServerOrigin(override);
|
|
87
|
+
}
|
|
88
|
+
const fromEnv = env.NOLO_SERVER || env.BASE_URL;
|
|
89
|
+
if (typeof fromEnv === "string" && fromEnv.trim()) {
|
|
90
|
+
return normalizeServerOrigin(fromEnv);
|
|
91
|
+
}
|
|
92
|
+
const profile = loadProfileConfig();
|
|
93
|
+
const profileUrl = profile?.profiles?.[profile.currentProfile]?.serverUrl;
|
|
94
|
+
if (profileUrl?.trim()) {
|
|
95
|
+
return normalizeServerOrigin(profileUrl);
|
|
96
|
+
}
|
|
97
|
+
return DEFAULT_NOLO_SERVER_URL;
|
|
98
|
+
}
|
|
99
|
+
function buildCliDoctorText(info) {
|
|
100
|
+
return [
|
|
101
|
+
"Nolo CLI doctor",
|
|
102
|
+
"---------------",
|
|
103
|
+
`version ${info.packageName} ${info.version}`,
|
|
104
|
+
`install ${info.installKind}`,
|
|
105
|
+
`channel ${info.updateChannel}`,
|
|
106
|
+
`entry ${info.entrypoint}`,
|
|
107
|
+
`server ${info.serverUrl}`,
|
|
108
|
+
`profile ${info.profileName}`,
|
|
109
|
+
`update nolo update`,
|
|
110
|
+
"",
|
|
111
|
+
"If direct `nolo` differs from repo-local `bun ./packages/cli/index.ts`,",
|
|
112
|
+
"the global install is older than this checkout.",
|
|
113
|
+
"",
|
|
114
|
+
`Manual update: ${buildNpmSelfUpdateCommand(info.updateChannel).join(" ")}`
|
|
115
|
+
].join("\n");
|
|
116
|
+
}
|
|
117
|
+
function isRunSelfUpdateOptions(value) {
|
|
118
|
+
return typeof value === "object" && value !== null && ("output" in value || "spawn" in value || "entrypointPath" in value || "serverUrl" in value || "env" in value);
|
|
119
|
+
}
|
|
120
|
+
async function forwardSpawnOutput(stream, output) {
|
|
121
|
+
if (!stream) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
for await (const chunk of stream) {
|
|
125
|
+
output.write(normalizeSpawnChunk(chunk));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function normalizeSpawnChunk(chunk) {
|
|
129
|
+
if (typeof chunk === "string" || chunk instanceof Uint8Array) {
|
|
130
|
+
return chunk;
|
|
131
|
+
}
|
|
132
|
+
if (chunk instanceof ArrayBuffer) {
|
|
133
|
+
return new Uint8Array(chunk);
|
|
134
|
+
}
|
|
135
|
+
return new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
|
136
|
+
}
|
|
137
|
+
async function runSelfUpdate(outputOrOptions) {
|
|
138
|
+
const options = outputOrOptions === void 0 ? {} : isRunSelfUpdateOptions(outputOrOptions) ? outputOrOptions : { output: outputOrOptions };
|
|
139
|
+
const output = options.output ?? process.stdout;
|
|
140
|
+
const spawn = options.spawn ?? resolveDefaultSpawn();
|
|
141
|
+
const env = options.env ?? process.env;
|
|
142
|
+
const serverUrl = resolveSelfUpdateServerUrl(env, options.serverUrl);
|
|
143
|
+
const channel = getCliInstallChannel(serverUrl);
|
|
144
|
+
const command = buildNpmSelfUpdateCommand(channel);
|
|
145
|
+
output.write(`
|
|
146
|
+
Nolo Agent CLI Installer & Updater
|
|
147
|
+
`);
|
|
148
|
+
output.write(`-----------------------------------------
|
|
149
|
+
`);
|
|
150
|
+
output.write(`\u2713 Target channel: ${channel} (nolo-cli@${channel})
|
|
151
|
+
`);
|
|
152
|
+
output.write(`\u25B8 Downloading and installing package via npm...
|
|
153
|
+
`);
|
|
154
|
+
const useCustomSink = options.output !== void 0;
|
|
155
|
+
const proc = spawn({
|
|
156
|
+
cmd: command,
|
|
157
|
+
stdin: "inherit",
|
|
158
|
+
stdout: useCustomSink ? "pipe" : "inherit",
|
|
159
|
+
stderr: useCustomSink ? "pipe" : "inherit",
|
|
160
|
+
env
|
|
161
|
+
});
|
|
162
|
+
if (!useCustomSink) {
|
|
163
|
+
const exitCode2 = await proc.exited;
|
|
164
|
+
if (exitCode2 === 0) {
|
|
165
|
+
output.write(` ${renderProgressBar(100)}
|
|
166
|
+
`);
|
|
167
|
+
output.write(`\u2713 Update completed successfully!
|
|
168
|
+
|
|
169
|
+
`);
|
|
170
|
+
}
|
|
171
|
+
return exitCode2;
|
|
172
|
+
}
|
|
173
|
+
const [exitCode] = await Promise.all([
|
|
174
|
+
proc.exited,
|
|
175
|
+
forwardSpawnOutput(proc.stdout, output),
|
|
176
|
+
forwardSpawnOutput(proc.stderr, output)
|
|
177
|
+
]);
|
|
178
|
+
if (exitCode === 0) {
|
|
179
|
+
output.write(` ${renderProgressBar(100)}
|
|
180
|
+
`);
|
|
181
|
+
output.write(`\u2713 Update completed successfully!
|
|
182
|
+
|
|
183
|
+
`);
|
|
184
|
+
}
|
|
185
|
+
return exitCode;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export {
|
|
189
|
+
getCliInstallChannel,
|
|
190
|
+
renderProgressBar,
|
|
191
|
+
buildNpmSelfUpdateCommand,
|
|
192
|
+
readPackageInfo,
|
|
193
|
+
buildCliVersionText,
|
|
194
|
+
buildSelfUpdateCommand,
|
|
195
|
+
resolveSelfUpdateServerUrl,
|
|
196
|
+
buildCliDoctorText,
|
|
197
|
+
runSelfUpdate
|
|
198
|
+
};
|