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,226 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MEMORY_USE_GUIDANCE
|
|
3
|
+
} from "./chunk-KKY4B2Q2.js";
|
|
4
|
+
|
|
5
|
+
// packages/agent-runtime/modelLayerOverride.ts
|
|
6
|
+
var MODEL_LAYER_KEYS = [
|
|
7
|
+
"provider",
|
|
8
|
+
"model",
|
|
9
|
+
"apiSource",
|
|
10
|
+
"cliProvider",
|
|
11
|
+
"useServerProxy",
|
|
12
|
+
"apiKey",
|
|
13
|
+
"apiKeyRef",
|
|
14
|
+
"apiKeyHeader",
|
|
15
|
+
"customProviderUrl",
|
|
16
|
+
"credentialRef",
|
|
17
|
+
"credentialSynced",
|
|
18
|
+
"temperature",
|
|
19
|
+
"top_p",
|
|
20
|
+
"frequency_penalty",
|
|
21
|
+
"presence_penalty",
|
|
22
|
+
"max_tokens",
|
|
23
|
+
"reasoning_effort",
|
|
24
|
+
"enableThinking",
|
|
25
|
+
"thinkingBudget"
|
|
26
|
+
];
|
|
27
|
+
function mergeReferences(base, extra) {
|
|
28
|
+
const safeBase = Array.isArray(base) ? base : [];
|
|
29
|
+
const safeExtra = Array.isArray(extra) ? extra : [];
|
|
30
|
+
const seen = /* @__PURE__ */ new Set();
|
|
31
|
+
const merged = [];
|
|
32
|
+
for (const item of [...safeBase, ...safeExtra]) {
|
|
33
|
+
const key = item?.dbKey;
|
|
34
|
+
if (key && seen.has(key)) continue;
|
|
35
|
+
if (key) seen.add(key);
|
|
36
|
+
if (item) merged.push(item);
|
|
37
|
+
}
|
|
38
|
+
return merged;
|
|
39
|
+
}
|
|
40
|
+
var asNonEmptyString = (value) => typeof value === "string" && value.trim().length > 0;
|
|
41
|
+
function buildModelLayerOverride(agent) {
|
|
42
|
+
if (!agent || !asNonEmptyString(agent.provider) || !asNonEmptyString(agent.model)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const override = {
|
|
46
|
+
provider: agent.provider,
|
|
47
|
+
model: agent.model
|
|
48
|
+
};
|
|
49
|
+
for (const key of MODEL_LAYER_KEYS) {
|
|
50
|
+
if (key === "provider" || key === "model") continue;
|
|
51
|
+
const value = agent[key];
|
|
52
|
+
if (value !== void 0) {
|
|
53
|
+
override[key] = value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (Array.isArray(agent.references) && agent.references.length > 0) {
|
|
57
|
+
override.references = agent.references;
|
|
58
|
+
}
|
|
59
|
+
return override;
|
|
60
|
+
}
|
|
61
|
+
function applyModelLayerOverride(base, override) {
|
|
62
|
+
const next = { ...base };
|
|
63
|
+
for (const key of MODEL_LAYER_KEYS) {
|
|
64
|
+
delete next[key];
|
|
65
|
+
}
|
|
66
|
+
for (const key of MODEL_LAYER_KEYS) {
|
|
67
|
+
const value = override[key];
|
|
68
|
+
if (value !== void 0) {
|
|
69
|
+
next[key] = value;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const merged = mergeReferences(
|
|
73
|
+
base.references,
|
|
74
|
+
override.references
|
|
75
|
+
);
|
|
76
|
+
if (merged.length > 0) {
|
|
77
|
+
next.references = merged;
|
|
78
|
+
} else {
|
|
79
|
+
delete next.references;
|
|
80
|
+
}
|
|
81
|
+
return next;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// packages/agent-runtime/turnContext.ts
|
|
85
|
+
var DEFAULT_RECENT_CONTENT_LIMIT = 10;
|
|
86
|
+
var asTrimmed = (value) => typeof value === "string" ? value.trim() : "";
|
|
87
|
+
var asFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
88
|
+
var spaceRecordKey = (spaceId) => spaceId.startsWith("space-") ? spaceId : `space-${spaceId}`;
|
|
89
|
+
var makeLayer = (id, content, cacheScope = "turn") => ({ id, owner: "runtime", cacheScope, content });
|
|
90
|
+
var renderSpaceStructure = (spaceRecord, recentLimit) => {
|
|
91
|
+
const categories = spaceRecord.categories ?? {};
|
|
92
|
+
const validCategories = Object.entries(categories).filter((entry) => entry[1] !== null).sort(
|
|
93
|
+
(a, b) => asFiniteNumber(a[1].order) - asFiniteNumber(b[1].order)
|
|
94
|
+
);
|
|
95
|
+
const categoryNameById = /* @__PURE__ */ new Map();
|
|
96
|
+
let struct = "Directory Structure (Categories):\n";
|
|
97
|
+
if (validCategories.length === 0) struct += "(No categories defined)\n";
|
|
98
|
+
validCategories.forEach(([id, category]) => {
|
|
99
|
+
const name = asTrimmed(category.name) || id;
|
|
100
|
+
categoryNameById.set(id, name);
|
|
101
|
+
struct += `- ${name} (ID: ${id})
|
|
102
|
+
`;
|
|
103
|
+
});
|
|
104
|
+
const contents = spaceRecord.contents ?? {};
|
|
105
|
+
const recentContents = recentLimit > 0 ? Object.values(contents).filter((content) => content !== null).sort(
|
|
106
|
+
(a, b) => asFiniteNumber(b.updatedAt) - asFiniteNumber(a.updatedAt)
|
|
107
|
+
).slice(0, recentLimit) : [];
|
|
108
|
+
if (recentContents.length > 0) {
|
|
109
|
+
struct += `
|
|
110
|
+
Recent Contents (Top ${recentLimit}):
|
|
111
|
+
`;
|
|
112
|
+
recentContents.forEach((content) => {
|
|
113
|
+
const categoryId = asTrimmed(content.categoryId);
|
|
114
|
+
const categoryName = categoryId ? categoryNameById.get(categoryId) || "Unknown" : "Uncategorized";
|
|
115
|
+
struct += `- [${asTrimmed(content.type) || "content"}] ${asTrimmed(content.title)} (Category: ${categoryName}, dbKey: ${asTrimmed(content.contentKey)})
|
|
116
|
+
`;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return struct;
|
|
120
|
+
};
|
|
121
|
+
var buildSpaceContextLayer = async (args) => {
|
|
122
|
+
const spaceId = asTrimmed(args.spaceId);
|
|
123
|
+
if (!spaceId) return null;
|
|
124
|
+
const recentLimit = args.recentContentLimit ?? DEFAULT_RECENT_CONTENT_LIMIT;
|
|
125
|
+
let spaceRecord = null;
|
|
126
|
+
let readError = null;
|
|
127
|
+
try {
|
|
128
|
+
spaceRecord = await args.source.readRecord(spaceRecordKey(spaceId));
|
|
129
|
+
} catch (error) {
|
|
130
|
+
readError = error instanceof Error ? error.message : String(error);
|
|
131
|
+
}
|
|
132
|
+
if (!spaceRecord) {
|
|
133
|
+
return makeLayer(
|
|
134
|
+
"space-context",
|
|
135
|
+
[
|
|
136
|
+
"--- \u5F53\u524D\u7A7A\u95F4\uFF08Space\uFF09---",
|
|
137
|
+
`\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`,
|
|
138
|
+
"\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"
|
|
139
|
+
].join("\n")
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
const name = asTrimmed(spaceRecord.name);
|
|
143
|
+
const description = asTrimmed(spaceRecord.description);
|
|
144
|
+
const structure = renderSpaceStructure(spaceRecord, recentLimit);
|
|
145
|
+
return makeLayer(
|
|
146
|
+
"space-context",
|
|
147
|
+
[
|
|
148
|
+
"--- \u5F53\u524D\u7A7A\u95F4\uFF08Space\uFF09---",
|
|
149
|
+
"\u672C\u5BF9\u8BDD\u5C5E\u4E8E\u4EE5\u4E0B Space\uFF1A",
|
|
150
|
+
`Space Title: ${name || spaceId}`,
|
|
151
|
+
`Space ID: ${spaceId}`,
|
|
152
|
+
`Description: ${description || "N/A"}`,
|
|
153
|
+
"",
|
|
154
|
+
structure.trimEnd()
|
|
155
|
+
].join("\n")
|
|
156
|
+
);
|
|
157
|
+
};
|
|
158
|
+
var buildSkillDiscoveryLayer = (skills, boundFolder) => {
|
|
159
|
+
if (skills.length === 0) return null;
|
|
160
|
+
const lines = [
|
|
161
|
+
"--- \u53EF\u7528\u6280\u80FD\uFF08Skills\uFF09---",
|
|
162
|
+
`\u5DE5\u4F5C\u533A ${boundFolder} \u4E2D\u53D1\u73B0\u4E86 ${skills.length} \u4E2A\u6280\u80FD\uFF08SKILL.md\uFF09\uFF1A`,
|
|
163
|
+
"\u6A21\u578B\u53EF\u6309\u9700\u7528 readFile \u8BFB\u53D6\u4EE5\u4E0B\u6587\u4EF6\u83B7\u53D6\u8BE6\u7EC6\u6307\u4EE4\uFF1A",
|
|
164
|
+
"",
|
|
165
|
+
...skills.map(
|
|
166
|
+
(s) => `- ${s.name}: ${s.description}
|
|
167
|
+
path: ${s.relativePath}`
|
|
168
|
+
)
|
|
169
|
+
];
|
|
170
|
+
return makeLayer("skill-discovery", lines.join("\n"));
|
|
171
|
+
};
|
|
172
|
+
var buildLinkedSpacesSection = async (args) => {
|
|
173
|
+
const ids = (args.linkedSpaceIds ?? []).filter(
|
|
174
|
+
(id) => typeof id === "string" && id.trim() !== ""
|
|
175
|
+
);
|
|
176
|
+
if (ids.length === 0) return null;
|
|
177
|
+
const lines = [];
|
|
178
|
+
for (const rawId of ids) {
|
|
179
|
+
const spaceId = asTrimmed(rawId);
|
|
180
|
+
let spaceData = null;
|
|
181
|
+
try {
|
|
182
|
+
spaceData = await args.source.readRecord(spaceRecordKey(spaceId));
|
|
183
|
+
} catch {
|
|
184
|
+
spaceData = null;
|
|
185
|
+
}
|
|
186
|
+
if (spaceData) {
|
|
187
|
+
const name = asTrimmed(spaceData.name) || spaceId;
|
|
188
|
+
const desc = asTrimmed(spaceData.description);
|
|
189
|
+
lines.push(`- ${name} (ID: ${spaceId})${desc ? `: ${desc}` : ""}`);
|
|
190
|
+
} else {
|
|
191
|
+
lines.push(`- [\u65E0\u6CD5\u8BBF\u95EE] ${spaceId}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (lines.length === 0) return null;
|
|
195
|
+
return [
|
|
196
|
+
"--- \u5173\u8054\u7A7A\u95F4 (Linked Spaces) ---",
|
|
197
|
+
"\u4EE5\u4E0B\u662F Agent \u53EF\u8BBF\u95EE\u7684\u5176\u4ED6\u5DE5\u4F5C\u7A7A\u95F4\uFF08\u7C97\u7565\u4E0A\u4E0B\u6587\uFF09\uFF1A",
|
|
198
|
+
lines.join("\n"),
|
|
199
|
+
"",
|
|
200
|
+
"\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"
|
|
201
|
+
].join("\n");
|
|
202
|
+
};
|
|
203
|
+
var buildMemoryOverlayLayer = (args) => {
|
|
204
|
+
const promptBlock = asTrimmed(args.promptBlock);
|
|
205
|
+
if (!promptBlock) return null;
|
|
206
|
+
return makeLayer("memory-overlay", promptBlock);
|
|
207
|
+
};
|
|
208
|
+
var buildMemoryUseGuidanceLayer = (args) => {
|
|
209
|
+
const promptBlock = asTrimmed(args.promptBlock);
|
|
210
|
+
if (!promptBlock) return null;
|
|
211
|
+
return makeLayer(
|
|
212
|
+
"memory-use-guidance",
|
|
213
|
+
MEMORY_USE_GUIDANCE,
|
|
214
|
+
"session"
|
|
215
|
+
);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export {
|
|
219
|
+
buildModelLayerOverride,
|
|
220
|
+
applyModelLayerOverride,
|
|
221
|
+
buildSpaceContextLayer,
|
|
222
|
+
buildSkillDiscoveryLayer,
|
|
223
|
+
buildLinkedSpacesSection,
|
|
224
|
+
buildMemoryOverlayLayer,
|
|
225
|
+
buildMemoryUseGuidanceLayer
|
|
226
|
+
};
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asOptionalFiniteNumber
|
|
3
|
+
} from "./chunk-WWC7I6TA.js";
|
|
4
|
+
import {
|
|
5
|
+
asTrimmedString
|
|
6
|
+
} from "./chunk-3EUW3WEO.js";
|
|
7
|
+
import {
|
|
8
|
+
asOptionalTrimmedString
|
|
9
|
+
} from "./chunk-G3SUCT4W.js";
|
|
10
|
+
import {
|
|
11
|
+
isRecord
|
|
12
|
+
} from "./chunk-KUG52IAP.js";
|
|
13
|
+
|
|
14
|
+
// packages/agent-runtime/agentRecordConfig.ts
|
|
15
|
+
function stringField(record, key) {
|
|
16
|
+
const value = record[key];
|
|
17
|
+
return typeof value === "string" ? value : void 0;
|
|
18
|
+
}
|
|
19
|
+
function numberField(record, key) {
|
|
20
|
+
return asOptionalFiniteNumber(record[key]);
|
|
21
|
+
}
|
|
22
|
+
function objectField(record, key) {
|
|
23
|
+
const value = record[key];
|
|
24
|
+
return isRecord(value) ? value : void 0;
|
|
25
|
+
}
|
|
26
|
+
function appendUniqueStrings(values, next) {
|
|
27
|
+
if (!Array.isArray(next)) return values;
|
|
28
|
+
const seen = new Set(values);
|
|
29
|
+
for (const value of next) {
|
|
30
|
+
const toolName = typeof value === "string" ? value : isRecord(value) && typeof value.name === "string" ? value.name : isRecord(value) && isRecord(value.function) && typeof value.function.name === "string" ? value.function.name : "";
|
|
31
|
+
if (toolName && !seen.has(toolName)) {
|
|
32
|
+
seen.add(toolName);
|
|
33
|
+
values.push(toolName);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return values;
|
|
37
|
+
}
|
|
38
|
+
function resolveAgentRuntimeToolNames(record) {
|
|
39
|
+
const tools = appendUniqueStrings(
|
|
40
|
+
appendUniqueStrings([], record.toolNames),
|
|
41
|
+
record.tools
|
|
42
|
+
);
|
|
43
|
+
return tools.length > 0 ? tools : void 0;
|
|
44
|
+
}
|
|
45
|
+
function resolveAgentRuntimeConfigFromRecord(key, record) {
|
|
46
|
+
const name = stringField(record, "name");
|
|
47
|
+
const prompt = stringField(record, "prompt");
|
|
48
|
+
const model = stringField(record, "model");
|
|
49
|
+
const apiSource = stringField(record, "apiSource");
|
|
50
|
+
const cliProvider = stringField(record, "cliProvider");
|
|
51
|
+
const customProviderUrl = stringField(record, "customProviderUrl");
|
|
52
|
+
const apiKey = stringField(record, "apiKey");
|
|
53
|
+
const apiKeyHeader = stringField(record, "apiKeyHeader");
|
|
54
|
+
const apiKeyFromAgentKey = stringField(record, "apiKeyFromAgentKey");
|
|
55
|
+
const apiKeyRef = stringField(record, "apiKeyRef");
|
|
56
|
+
const credentialRef = stringField(record, "credentialRef");
|
|
57
|
+
const credentialSynced = record.credentialSynced === true;
|
|
58
|
+
const useServerProxy = record.useServerProxy === true;
|
|
59
|
+
const provider = stringField(record, "provider") ?? stringField(record, "apiSource");
|
|
60
|
+
const toolNames = resolveAgentRuntimeToolNames(record);
|
|
61
|
+
const temperature = numberField(record, "temperature");
|
|
62
|
+
const topP = numberField(record, "top_p");
|
|
63
|
+
const frequencyPenalty = numberField(record, "frequency_penalty");
|
|
64
|
+
const presencePenalty = numberField(record, "presence_penalty");
|
|
65
|
+
const maxTokens = numberField(record, "max_tokens");
|
|
66
|
+
const reasoningEffort = stringField(record, "reasoning_effort") || stringField(record, "reasoningEffort");
|
|
67
|
+
const runtimeBinding = objectField(record, "runtimeBinding");
|
|
68
|
+
const runtimeToolPolicy = objectField(record, "runtimeToolPolicy") ?? objectField(runtimeBinding ?? {}, "runtimeToolPolicy");
|
|
69
|
+
const delegation = objectField(record, "delegation");
|
|
70
|
+
return {
|
|
71
|
+
key,
|
|
72
|
+
...name ? { name } : {},
|
|
73
|
+
...prompt ? { prompt } : {},
|
|
74
|
+
...model ? { model } : {},
|
|
75
|
+
...provider ? { provider } : {},
|
|
76
|
+
...apiSource ? { apiSource } : {},
|
|
77
|
+
...cliProvider ? { cliProvider } : {},
|
|
78
|
+
...customProviderUrl ? { customProviderUrl } : {},
|
|
79
|
+
...apiKey ? { apiKey } : {},
|
|
80
|
+
...apiKeyHeader ? { apiKeyHeader } : {},
|
|
81
|
+
...apiKeyFromAgentKey ? { apiKeyFromAgentKey } : {},
|
|
82
|
+
...apiKeyRef ? { apiKeyRef } : {},
|
|
83
|
+
...credentialRef ? { credentialRef } : {},
|
|
84
|
+
...credentialSynced ? { credentialSynced } : {},
|
|
85
|
+
...useServerProxy ? { useServerProxy } : {},
|
|
86
|
+
...toolNames ? { toolNames } : {},
|
|
87
|
+
...temperature !== void 0 ? { temperature } : {},
|
|
88
|
+
...topP !== void 0 ? { top_p: topP } : {},
|
|
89
|
+
...frequencyPenalty !== void 0 ? { frequency_penalty: frequencyPenalty } : {},
|
|
90
|
+
...presencePenalty !== void 0 ? { presence_penalty: presencePenalty } : {},
|
|
91
|
+
...maxTokens !== void 0 ? { max_tokens: maxTokens } : {},
|
|
92
|
+
...reasoningEffort ? { reasoning_effort: reasoningEffort } : {},
|
|
93
|
+
...runtimeBinding ? { runtimeBinding } : {},
|
|
94
|
+
...runtimeToolPolicy ? { runtimeToolPolicy } : {},
|
|
95
|
+
...delegation ? { delegation } : {},
|
|
96
|
+
rawRecord: record
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// packages/agent-runtime/desktopRequestSnapshot.ts
|
|
101
|
+
var DESKTOP_AGENT_CONFIG_SNAPSHOT_STRING_FIELDS = [
|
|
102
|
+
"name",
|
|
103
|
+
"prompt",
|
|
104
|
+
"provider",
|
|
105
|
+
"model",
|
|
106
|
+
"apiSource",
|
|
107
|
+
"cliProvider",
|
|
108
|
+
"customProviderUrl",
|
|
109
|
+
"credentialRef",
|
|
110
|
+
"apiKeyRef",
|
|
111
|
+
"apiKeyHeader",
|
|
112
|
+
"reasoning_effort",
|
|
113
|
+
"reasoningEffort"
|
|
114
|
+
];
|
|
115
|
+
var DESKTOP_AGENT_CONFIG_SNAPSHOT_NUMBER_FIELDS = [
|
|
116
|
+
"temperature",
|
|
117
|
+
"top_p",
|
|
118
|
+
"frequency_penalty",
|
|
119
|
+
"presence_penalty",
|
|
120
|
+
"max_tokens"
|
|
121
|
+
];
|
|
122
|
+
var DESKTOP_AGENT_CONFIG_SNAPSHOT_OBJECT_FIELDS = [
|
|
123
|
+
"runtimeBinding",
|
|
124
|
+
"runtimeToolPolicy",
|
|
125
|
+
"delegation"
|
|
126
|
+
];
|
|
127
|
+
var DESKTOP_AGENT_CONFIG_SNAPSHOT_FORBIDDEN_KEYS = [
|
|
128
|
+
"apiKey",
|
|
129
|
+
"apiKeyFromAgentKey",
|
|
130
|
+
"token",
|
|
131
|
+
"secret",
|
|
132
|
+
"password",
|
|
133
|
+
"accessToken",
|
|
134
|
+
"refreshToken",
|
|
135
|
+
"authorization",
|
|
136
|
+
"authToken",
|
|
137
|
+
"AUTH_TOKEN",
|
|
138
|
+
"AUTH",
|
|
139
|
+
"clientSecret",
|
|
140
|
+
"privateKey",
|
|
141
|
+
"bearer"
|
|
142
|
+
];
|
|
143
|
+
var DESKTOP_TOOL_CALL_ARGUMENTS_MAX_CHARS = 8192;
|
|
144
|
+
var REDACTED_SECRET_PLACEHOLDER = "[redacted]";
|
|
145
|
+
var FORBIDDEN_KEY_SET = new Set(
|
|
146
|
+
DESKTOP_AGENT_CONFIG_SNAPSHOT_FORBIDDEN_KEYS.map((k) => k.toLowerCase())
|
|
147
|
+
);
|
|
148
|
+
function isForbiddenKey(key) {
|
|
149
|
+
return FORBIDDEN_KEY_SET.has(key.toLowerCase());
|
|
150
|
+
}
|
|
151
|
+
function isDesktopSnapshotSensitivePropertyName(key) {
|
|
152
|
+
return isForbiddenKey(key);
|
|
153
|
+
}
|
|
154
|
+
function redactSensitiveJsonTree(value, depth = 0) {
|
|
155
|
+
if (depth > 6) return null;
|
|
156
|
+
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
157
|
+
return value;
|
|
158
|
+
}
|
|
159
|
+
if (Array.isArray(value)) {
|
|
160
|
+
return value.map((item) => redactSensitiveJsonTree(item, depth + 1));
|
|
161
|
+
}
|
|
162
|
+
if (typeof value !== "object") return null;
|
|
163
|
+
const out = {};
|
|
164
|
+
for (const [key, child] of Object.entries(value)) {
|
|
165
|
+
if (isDesktopSnapshotSensitivePropertyName(key)) {
|
|
166
|
+
out[key] = REDACTED_SECRET_PLACEHOLDER;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
out[key] = redactSensitiveJsonTree(child, depth + 1);
|
|
170
|
+
}
|
|
171
|
+
return out;
|
|
172
|
+
}
|
|
173
|
+
function sanitizeToolCallArguments(raw, maxChars = DESKTOP_TOOL_CALL_ARGUMENTS_MAX_CHARS) {
|
|
174
|
+
const source = typeof raw === "string" ? raw : raw == null ? "{}" : String(raw);
|
|
175
|
+
let candidate = source;
|
|
176
|
+
try {
|
|
177
|
+
const parsed = JSON.parse(source);
|
|
178
|
+
if (parsed && typeof parsed === "object") {
|
|
179
|
+
candidate = JSON.stringify(redactSensitiveJsonTree(parsed));
|
|
180
|
+
}
|
|
181
|
+
} catch {
|
|
182
|
+
}
|
|
183
|
+
if (candidate.length <= maxChars) return candidate;
|
|
184
|
+
return candidate.slice(0, maxChars);
|
|
185
|
+
}
|
|
186
|
+
function stringField2(record, key) {
|
|
187
|
+
return asOptionalTrimmedString(record[key]);
|
|
188
|
+
}
|
|
189
|
+
function numberField2(record, key) {
|
|
190
|
+
return asOptionalFiniteNumber(record[key]);
|
|
191
|
+
}
|
|
192
|
+
function uniqueToolNames(values) {
|
|
193
|
+
if (!Array.isArray(values)) return void 0;
|
|
194
|
+
const names = [];
|
|
195
|
+
const seen = /* @__PURE__ */ new Set();
|
|
196
|
+
for (const value of values) {
|
|
197
|
+
const name = asTrimmedString(value) || asTrimmedString(value?.name) || asTrimmedString(
|
|
198
|
+
value?.function?.name
|
|
199
|
+
);
|
|
200
|
+
if (!name || seen.has(name)) continue;
|
|
201
|
+
seen.add(name);
|
|
202
|
+
names.push(name);
|
|
203
|
+
}
|
|
204
|
+
return names.length > 0 ? names : void 0;
|
|
205
|
+
}
|
|
206
|
+
function sanitizePlainObject(value, depth = 0) {
|
|
207
|
+
if (!isRecord(value)) return void 0;
|
|
208
|
+
if (depth > 4) return void 0;
|
|
209
|
+
const out = {};
|
|
210
|
+
for (const [key, child] of Object.entries(value)) {
|
|
211
|
+
if (isForbiddenKey(key)) continue;
|
|
212
|
+
if (child === null) {
|
|
213
|
+
out[key] = null;
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
if (typeof child === "string" || typeof child === "number" || typeof child === "boolean") {
|
|
217
|
+
out[key] = child;
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
if (Array.isArray(child)) {
|
|
221
|
+
const items = child.map((item) => {
|
|
222
|
+
if (item === null || typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
|
|
223
|
+
return item;
|
|
224
|
+
}
|
|
225
|
+
if (isRecord(item)) {
|
|
226
|
+
return sanitizePlainObject(item, depth + 1);
|
|
227
|
+
}
|
|
228
|
+
return void 0;
|
|
229
|
+
}).filter((item) => item !== void 0);
|
|
230
|
+
out[key] = items;
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (typeof child === "object") {
|
|
234
|
+
const nested = sanitizePlainObject(child, depth + 1);
|
|
235
|
+
if (nested) out[key] = nested;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return out;
|
|
239
|
+
}
|
|
240
|
+
function pickAllowlistedAgentConfigFields(source, dbKey) {
|
|
241
|
+
const snapshot = { dbKey };
|
|
242
|
+
for (const key of DESKTOP_AGENT_CONFIG_SNAPSHOT_STRING_FIELDS) {
|
|
243
|
+
if (key === "reasoningEffort") continue;
|
|
244
|
+
const value = stringField2(source, key);
|
|
245
|
+
if (value !== void 0) {
|
|
246
|
+
snapshot[key] = value;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const reasoningEffort = stringField2(source, "reasoning_effort") || stringField2(source, "reasoningEffort");
|
|
250
|
+
if (reasoningEffort) snapshot.reasoning_effort = reasoningEffort;
|
|
251
|
+
for (const key of DESKTOP_AGENT_CONFIG_SNAPSHOT_NUMBER_FIELDS) {
|
|
252
|
+
const value = numberField2(source, key);
|
|
253
|
+
if (value !== void 0) {
|
|
254
|
+
snapshot[key] = value;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (source.useServerProxy === true) {
|
|
258
|
+
snapshot.useServerProxy = true;
|
|
259
|
+
} else if (source.useServerProxy === false) {
|
|
260
|
+
snapshot.useServerProxy = false;
|
|
261
|
+
}
|
|
262
|
+
const tools = uniqueToolNames(source.tools) ?? uniqueToolNames(source.toolNames);
|
|
263
|
+
if (tools) snapshot.tools = tools;
|
|
264
|
+
for (const key of DESKTOP_AGENT_CONFIG_SNAPSHOT_OBJECT_FIELDS) {
|
|
265
|
+
const value = sanitizePlainObject(source[key]);
|
|
266
|
+
if (value) {
|
|
267
|
+
snapshot[key] = value;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return snapshot;
|
|
271
|
+
}
|
|
272
|
+
function buildDesktopAgentRuntimeAgentConfigSnapshot(source, agentRef) {
|
|
273
|
+
if (!isRecord(source)) return null;
|
|
274
|
+
const ref = asTrimmedString(agentRef);
|
|
275
|
+
if (!ref) return null;
|
|
276
|
+
const claimed = stringField2(source, "dbKey") || stringField2(source, "key");
|
|
277
|
+
if (claimed && claimed !== ref) return null;
|
|
278
|
+
const dbKey = claimed || ref;
|
|
279
|
+
return pickAllowlistedAgentConfigFields(source, dbKey);
|
|
280
|
+
}
|
|
281
|
+
function sanitizeMessageContent(content) {
|
|
282
|
+
if (content === null || content === void 0) return null;
|
|
283
|
+
if (typeof content === "string") return content;
|
|
284
|
+
if (!Array.isArray(content)) return null;
|
|
285
|
+
const parts = [];
|
|
286
|
+
for (const part of content) {
|
|
287
|
+
if (!part || typeof part !== "object") continue;
|
|
288
|
+
const record = part;
|
|
289
|
+
if (record.type === "text" && typeof record.text === "string") {
|
|
290
|
+
parts.push({ type: "text", text: record.text });
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return parts.length > 0 ? parts : null;
|
|
294
|
+
}
|
|
295
|
+
function sanitizeToolCalls(value) {
|
|
296
|
+
if (!Array.isArray(value)) return void 0;
|
|
297
|
+
const calls = [];
|
|
298
|
+
for (const item of value) {
|
|
299
|
+
if (!item || typeof item !== "object") continue;
|
|
300
|
+
const record = item;
|
|
301
|
+
const id = asTrimmedString(record.id);
|
|
302
|
+
const fn = record.function && typeof record.function === "object" ? record.function : null;
|
|
303
|
+
const name = asTrimmedString(fn?.name);
|
|
304
|
+
const rawArgs = typeof fn?.arguments === "string" ? fn.arguments : "{}";
|
|
305
|
+
if (!id || !name) continue;
|
|
306
|
+
calls.push({
|
|
307
|
+
id,
|
|
308
|
+
type: "function",
|
|
309
|
+
function: { name, arguments: sanitizeToolCallArguments(rawArgs) }
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
return calls.length > 0 ? calls : void 0;
|
|
313
|
+
}
|
|
314
|
+
function sanitizeChatMessage(value) {
|
|
315
|
+
if (!isRecord(value)) return null;
|
|
316
|
+
const role = value.role;
|
|
317
|
+
if (role !== "system" && role !== "user" && role !== "assistant" && role !== "tool") {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
const content = sanitizeMessageContent(value.content);
|
|
321
|
+
const message = {
|
|
322
|
+
role,
|
|
323
|
+
content
|
|
324
|
+
};
|
|
325
|
+
const toolCallId = asOptionalTrimmedString(value.tool_call_id) ?? asOptionalTrimmedString(value.toolCallId);
|
|
326
|
+
if (toolCallId) message.tool_call_id = toolCallId;
|
|
327
|
+
const toolCalls = sanitizeToolCalls(value.tool_calls);
|
|
328
|
+
if (toolCalls) message.tool_calls = toolCalls;
|
|
329
|
+
if (typeof value.reasoning_content === "string" && value.reasoning_content) {
|
|
330
|
+
message.reasoning_content = value.reasoning_content;
|
|
331
|
+
}
|
|
332
|
+
return message;
|
|
333
|
+
}
|
|
334
|
+
function buildDesktopAgentRuntimeDialogHistorySnapshot(args) {
|
|
335
|
+
const dialogId = asTrimmedString(args.dialogId);
|
|
336
|
+
if (!dialogId) return null;
|
|
337
|
+
if (!Array.isArray(args.messages)) return null;
|
|
338
|
+
let messages = args.messages.map((item) => sanitizeChatMessage(item)).filter((item) => item !== null);
|
|
339
|
+
messages = messages.filter((msg) => {
|
|
340
|
+
const raw = msg;
|
|
341
|
+
return raw.isStreaming !== true;
|
|
342
|
+
});
|
|
343
|
+
const inputText = normalizeContentToText(args.currentInput);
|
|
344
|
+
if (inputText && messages.length > 0) {
|
|
345
|
+
const last = messages[messages.length - 1];
|
|
346
|
+
if (last.role === "user" && normalizeContentToText(last.content) === inputText) {
|
|
347
|
+
messages = messages.slice(0, -1);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return { dialogId, messages };
|
|
351
|
+
}
|
|
352
|
+
function normalizeContentToText(content) {
|
|
353
|
+
if (typeof content === "string") return content.trim();
|
|
354
|
+
if (!Array.isArray(content)) return "";
|
|
355
|
+
return content.flatMap((part) => part?.type === "text" && part.text ? [part.text] : []).join("\n").trim();
|
|
356
|
+
}
|
|
357
|
+
function assertDesktopAgentRuntimeTurnBodyHasNoRawSecrets(body) {
|
|
358
|
+
if (!body || typeof body !== "object") return;
|
|
359
|
+
const json = JSON.stringify(body);
|
|
360
|
+
const walk = (value, path) => {
|
|
361
|
+
if (!value || typeof value !== "object") return;
|
|
362
|
+
if (Array.isArray(value)) {
|
|
363
|
+
value.forEach((item, index) => walk(item, `${path}[${index}]`));
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
for (const [key, child] of Object.entries(value)) {
|
|
367
|
+
if (isForbiddenKey(key)) {
|
|
368
|
+
throw new Error(`Forbidden secret field in request body at ${path}.${key}`);
|
|
369
|
+
}
|
|
370
|
+
walk(child, path ? `${path}.${key}` : key);
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
walk(body, "");
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export {
|
|
377
|
+
resolveAgentRuntimeConfigFromRecord,
|
|
378
|
+
buildDesktopAgentRuntimeAgentConfigSnapshot,
|
|
379
|
+
buildDesktopAgentRuntimeDialogHistorySnapshot,
|
|
380
|
+
assertDesktopAgentRuntimeTurnBodyHasNoRawSecrets
|
|
381
|
+
};
|