nolo-cli 0.6.1 → 0.8.0-alpha.10
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-CPDNUUQV.js +198 -0
- package/action-PAXRPJJF.js +27 -0
- package/addContentAction-CZVWF3QZ.js +25 -0
- package/addDialogAgentAction-CCIDTPHC.js +67 -0
- package/agentDeleteCommand-OSUMJMZM.js +323 -0
- package/agentEmailCommands-OQTJIPQU.js +621 -0
- package/agentListCommands-FATQEUYT.js +219 -0
- package/agentMachineCommands-6LZWF4GL.js +421 -0
- package/agentPullCommand-O2MTUAFR.js +122 -0
- package/agentRecordCommands-TIHFU65Z.js +89 -0
- package/agentRunCommand-R64Y3HCH.js +102 -0
- package/agentRunControl-K4VKNEHF.js +57 -0
- package/agentRuntimeLocal-6PIWAHLQ.js +99 -0
- package/agentSlice-TP4VARJF.js +41 -0
- package/authCommand-WXMD3IPR.js +574 -0
- package/authCommands-X74AFDTC.js +26 -0
- package/chunk-2EISRLRC.js +238 -0
- package/chunk-2FTTDCD4.js +675 -0
- package/chunk-2MALU52L.js +51 -0
- package/chunk-2TPUKEU7.js +1078 -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-4IJYA27C.js +342 -0
- package/chunk-4SN6J65J.js +38 -0
- package/chunk-4VNS5WPM.js +42 -0
- package/chunk-572EKYLF.js +792 -0
- package/chunk-5MIDPSSK.js +206 -0
- package/chunk-5MMAK75Q.js +15 -0
- package/chunk-5VV37AT4.js +222 -0
- package/chunk-63W5N6P3.js +150 -0
- package/chunk-6A5EF6IR.js +929 -0
- package/chunk-6HYVJV7B.js +102 -0
- package/chunk-6P2WX5IA.js +3631 -0
- package/chunk-6WD3OOJS.js +20 -0
- package/chunk-ATNTHIZI.js +13 -0
- package/chunk-AUGHVUFE.js +69 -0
- package/chunk-AVMKZHBC.js +85 -0
- package/chunk-AZPCASRE.js +36 -0
- package/chunk-BNMT7YY5.js +34 -0
- package/chunk-BR2WP3DF.js +548 -0
- package/chunk-BSTNFPHD.js +231 -0
- package/chunk-BU4OPIXC.js +171 -0
- package/chunk-CF2WZF4N.js +134 -0
- package/chunk-CF7PE763.js +10 -0
- package/chunk-CKOJQDKR.js +198 -0
- package/chunk-CM54RSSA.js +206 -0
- package/chunk-CWMSB67P.js +34 -0
- package/chunk-DA2OEKS6.js +27 -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-EYEEHCU4.js +3066 -0
- package/chunk-FQZWM5YX.js +628 -0
- package/chunk-G3SUCT4W.js +8 -0
- package/chunk-G5H7RNFL.js +807 -0
- package/chunk-GAKEBQD6.js +30 -0
- package/chunk-GBRG75BQ.js +86 -0
- package/chunk-H2RMRZJE.js +113 -0
- package/chunk-H33743XH.js +25 -0
- package/chunk-HD63YREL.js +19 -0
- package/chunk-HEIIIZBX.js +104 -0
- package/chunk-HNMXYYJR.js +12 -0
- package/chunk-HOMYP7GZ.js +2152 -0
- package/chunk-HZFOMJRA.js +4300 -0
- package/chunk-IAXBCTTE.js +175 -0
- package/chunk-IDZTNRP2.js +85 -0
- package/chunk-IHHA5Y2S.js +9013 -0
- package/chunk-ISNCLGUZ.js +146 -0
- package/chunk-IYQV26RA.js +138 -0
- package/chunk-J4576WMJ.js +91 -0
- package/chunk-JBTJAPUF.js +35 -0
- package/chunk-JZPBVBIY.js +94 -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-LM25IZBJ.js +902 -0
- package/chunk-LM6IYQ3F.js +16 -0
- package/chunk-M76ECQRD.js +13658 -0
- package/chunk-MRC4Q34M.js +188 -0
- package/chunk-NEMRK4EK.js +944 -0
- package/chunk-NXZGF7F7.js +2878 -0
- package/chunk-OF5H3QWS.js +300 -0
- package/chunk-OLZBQWZU.js +6 -0
- package/chunk-OOYVBFM7.js +191 -0
- package/chunk-OWOHNGCN.js +50 -0
- package/chunk-PN7AFLOK.js +3401 -0
- package/chunk-POCFIDGQ.js +562 -0
- package/chunk-Q6WACBKB.js +1949 -0
- package/chunk-QFV2OAIM.js +421 -0
- package/chunk-QJ6V2NIN.js +1447 -0
- package/chunk-QSJ3HFEF.js +8 -0
- package/chunk-QUWDTOUP.js +190 -0
- package/chunk-QYXLLLGL.js +4519 -0
- package/chunk-ROWQEJRP.js +139 -0
- package/chunk-S7Z2HMCN.js +25 -0
- package/chunk-TDIQFT2F.js +301 -0
- package/chunk-TILFE6LV.js +381 -0
- package/chunk-TKOUBWBO.js +24674 -0
- package/chunk-TYH5JE6N.js +27158 -0
- package/chunk-U4TRT5V4.js +246 -0
- package/chunk-U6VC4MU4.js +8 -0
- package/chunk-UAD2WT54.js +64 -0
- package/chunk-USZMK5UT.js +105 -0
- package/chunk-VEJLAVTC.js +2052 -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-VQ2AJRGD.js +148 -0
- package/chunk-W4NVOSFF.js +37 -0
- package/chunk-WWC7I6TA.js +8 -0
- package/chunk-X7W4TNB4.js +1550 -0
- package/chunk-XDVAYP26.js +537 -0
- package/chunk-XKIMRZO2.js +221 -0
- package/chunk-Y5GCAMGP.js +9 -0
- package/chunk-YWPXYBY7.js +360 -0
- package/chunk-Z4NR32XR.js +50 -0
- package/chunk-ZNFJWEN4.js +56 -0
- package/cliExecutor-DNE7TCC4.js +36 -0
- package/clipboardy-BVE3LVEH.js +12001 -0
- package/createAgentAutomationAction-KLKS2HGU.js +864 -0
- package/createDialogAction-Z33JMBF5.js +52 -0
- package/createPageAction-AQVNOAAI.js +169 -0
- package/db-HCJ5PRB5.js +271 -0
- package/dbSlice-C4UJLRZP.js +59 -0
- package/deleteFile-4SKGPHOZ.js +41 -0
- package/dialogCommands-W5PD6MZU.js +59 -0
- package/dialogSlice-RBJYVSAR.js +146 -0
- package/docCreateCommands-MM34S4Z3.js +215 -0
- package/docDeleteCommands-JJTU722V.js +176 -0
- package/docReadCommands-GLYDMCTU.js +129 -0
- package/docStore-5TYME4DO.js +96 -0
- package/docUpdateCommands-ZCGQ7URR.js +313 -0
- package/fetchMessages-JOCYIFKL.js +16 -0
- package/getPricing-PWPJ6MNV.js +30 -0
- package/handleSendMessageAction-KA2MRW6E.js +183 -0
- package/index.js +184 -112254
- package/lib-FYYBQIXS.js +19839 -0
- package/localDialogRead-D3BELSTF.js +26 -0
- package/localFirstLog-DHNOY2NA.js +19 -0
- package/localRuntimeAuthority-TEGCOWX4.js +471 -0
- package/localRuntimeDb-LGDF6FQP.js +12 -0
- package/machineCommands-ZB5WUSPF.js +774 -0
- package/machineInfo-M6KB6HZN.js +10 -0
- package/machineWsRunDispatch-GWCAPPCM.js +105 -0
- package/memoryCommands-O4MIPIWQ.js +476 -0
- package/models-XLEOET3E.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-FEDY44AA.js +5357 -0
- package/removeDialogAgentAction-CXLST3N6.js +72 -0
- package/runAgentClientLoop-W4NKE64V.js +288 -0
- package/runtimeDoctorCommands-LRHLPDRC.js +289 -0
- package/setDialogExtraReferencesAction-LP6VYGU7.js +59 -0
- package/setPrimaryDialogAgentAction-D3GGH23T.js +79 -0
- package/settingSlice-J4I3Z5H7.js +198 -0
- package/skillSummaryMarker-42HKSXYY.js +9 -0
- package/slateToRenderMarkdown-Y5IYN73U.js +7 -0
- package/slateUtils-2M7MUTWX.js +19 -0
- package/spaceCommands-LC4FDAKE.js +450 -0
- package/spaceSlice-32XOGBEF.js +145 -0
- package/streamAgentChatTurn-YQW32AQH.js +4503 -0
- package/tableCommands-GOFP7QKA.js +1286 -0
- package/toolApiClient-QI3YBNWB.js +26 -0
- package/tools-XGTFRYD7.js +83 -0
- package/understanding-HCSFPE7R.js +318 -0
- package/updateCommands-VOSPKXFF.js +31 -0
- package/updateDialogTitleAction-4LHQDNHQ.js +185 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_AGENT_BASE_POLICY,
|
|
3
|
+
DEFAULT_USER_PREFERENCE_PROFILE
|
|
4
|
+
} from "./chunk-VEJLAVTC.js";
|
|
5
|
+
|
|
6
|
+
// packages/ai/policy/runtimePolicy.ts
|
|
7
|
+
var clampLevel = (value, fallback) => {
|
|
8
|
+
const n = Number(value);
|
|
9
|
+
if (n === 1 || n === 2 || n === 3 || n === 4) {
|
|
10
|
+
return n;
|
|
11
|
+
}
|
|
12
|
+
return fallback;
|
|
13
|
+
};
|
|
14
|
+
var normalizeTonePreset = (value, fallback) => {
|
|
15
|
+
switch (value) {
|
|
16
|
+
case "professional":
|
|
17
|
+
case "friendly":
|
|
18
|
+
case "direct":
|
|
19
|
+
case "pragmatic":
|
|
20
|
+
case "default":
|
|
21
|
+
return value;
|
|
22
|
+
default:
|
|
23
|
+
return fallback;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var normalizeToneResolutionMode = (value, fallback) => {
|
|
27
|
+
switch (value) {
|
|
28
|
+
case "agent_first":
|
|
29
|
+
case "user_first":
|
|
30
|
+
case "blend":
|
|
31
|
+
return value;
|
|
32
|
+
default:
|
|
33
|
+
return fallback;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var normalizeSelfEvolutionMode = (value, fallback) => {
|
|
37
|
+
switch (value) {
|
|
38
|
+
case "none":
|
|
39
|
+
case "knowledge_only":
|
|
40
|
+
case "prompt_and_refs":
|
|
41
|
+
case "full":
|
|
42
|
+
return value;
|
|
43
|
+
default:
|
|
44
|
+
return fallback;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var resolveAgentBasePolicy = (agentConfig) => {
|
|
48
|
+
const raw = agentConfig?.basePolicy ?? {};
|
|
49
|
+
return {
|
|
50
|
+
version: 1,
|
|
51
|
+
tone: {
|
|
52
|
+
preset: normalizeTonePreset(
|
|
53
|
+
raw?.tone?.preset,
|
|
54
|
+
DEFAULT_AGENT_BASE_POLICY.tone?.preset ?? "default"
|
|
55
|
+
),
|
|
56
|
+
resolutionMode: normalizeToneResolutionMode(
|
|
57
|
+
raw?.tone?.resolutionMode,
|
|
58
|
+
DEFAULT_AGENT_BASE_POLICY.tone?.resolutionMode ?? "blend"
|
|
59
|
+
)
|
|
60
|
+
},
|
|
61
|
+
knowledgeCaptureMaxLevel: clampLevel(
|
|
62
|
+
raw?.knowledgeCaptureMaxLevel,
|
|
63
|
+
DEFAULT_AGENT_BASE_POLICY.knowledgeCaptureMaxLevel
|
|
64
|
+
),
|
|
65
|
+
spaceContextMaxLevel: clampLevel(
|
|
66
|
+
raw?.spaceContextMaxLevel,
|
|
67
|
+
DEFAULT_AGENT_BASE_POLICY.spaceContextMaxLevel
|
|
68
|
+
),
|
|
69
|
+
selfEvolutionMode: normalizeSelfEvolutionMode(
|
|
70
|
+
raw?.selfEvolutionMode,
|
|
71
|
+
DEFAULT_AGENT_BASE_POLICY.selfEvolutionMode
|
|
72
|
+
)
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
var resolveUserPreferenceProfile = (settingsRecord) => {
|
|
76
|
+
const fallbackSpaceLevel = settingsRecord?.enableReadCurrentSpace === false ? 1 : DEFAULT_USER_PREFERENCE_PROFILE.spaceContextLevel;
|
|
77
|
+
return {
|
|
78
|
+
version: 1,
|
|
79
|
+
tone: {
|
|
80
|
+
preset: normalizeTonePreset(
|
|
81
|
+
settingsRecord?.userTonePreset,
|
|
82
|
+
DEFAULT_USER_PREFERENCE_PROFILE.tone?.preset ?? "default"
|
|
83
|
+
)
|
|
84
|
+
},
|
|
85
|
+
knowledgeCaptureLevel: clampLevel(
|
|
86
|
+
settingsRecord?.knowledgeCaptureLevel,
|
|
87
|
+
DEFAULT_USER_PREFERENCE_PROFILE.knowledgeCaptureLevel
|
|
88
|
+
),
|
|
89
|
+
spaceContextLevel: clampLevel(
|
|
90
|
+
settingsRecord?.spaceContextLevel,
|
|
91
|
+
fallbackSpaceLevel
|
|
92
|
+
)
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
var containsAny = (text, patterns) => patterns.some((pattern) => text.includes(pattern));
|
|
96
|
+
var inferCaptureIntent = (userInput) => {
|
|
97
|
+
const normalized = userInput.toLowerCase();
|
|
98
|
+
if (containsAny(normalized, [
|
|
99
|
+
"\u4FDD\u5B58",
|
|
100
|
+
"\u5B58\u4E00\u4E0B",
|
|
101
|
+
"\u6C89\u6DC0",
|
|
102
|
+
"\u8BB0\u4F4F",
|
|
103
|
+
"\u5199\u5165\u6587\u6863",
|
|
104
|
+
"\u5EFA\u6587\u6863",
|
|
105
|
+
"\u521B\u5EFA\u6587\u6863",
|
|
106
|
+
"\u5BFC\u5165 skill",
|
|
107
|
+
"\u5BFC\u5165\u8FD9\u4E2A skill",
|
|
108
|
+
"\u786E\u8BA4\u5BFC\u5165",
|
|
109
|
+
"\u786E\u8BA4\u5BFC\u5165\u8FD9\u4E2A skill",
|
|
110
|
+
"\u5BFC\u5165\u8FD9\u4E2A\u6280\u80FD",
|
|
111
|
+
"\u786E\u8BA4\u5BFC\u5165\u8FD9\u4E2A\u6280\u80FD",
|
|
112
|
+
"\u521B\u5EFA skill",
|
|
113
|
+
"\u521B\u5EFA\u8FD9\u4E2A skill",
|
|
114
|
+
"skill \u6587\u6863",
|
|
115
|
+
"\u521B\u5EFA\u8868\u683C",
|
|
116
|
+
"createtable",
|
|
117
|
+
"addtablerow",
|
|
118
|
+
"addtablerows",
|
|
119
|
+
"\u5EFA\u8868",
|
|
120
|
+
"\u5EFA\u4E2A\u8868",
|
|
121
|
+
"\u505A\u4E2A\u8868",
|
|
122
|
+
"\u505A\u4E00\u5F20\u8868",
|
|
123
|
+
"\u5199\u8868",
|
|
124
|
+
"\u5199\u5165\u8868",
|
|
125
|
+
"\u5199\u5165\u4E00\u884C",
|
|
126
|
+
"\u5199\u5165 table",
|
|
127
|
+
"\u653E\u5230 table",
|
|
128
|
+
"\u5B58\u5230 table",
|
|
129
|
+
"\u4FDD\u5B58\u5230 table",
|
|
130
|
+
"\u8BB0\u5F55\u4E0B\u6765",
|
|
131
|
+
"\u91C7\u96C6",
|
|
132
|
+
"\u505A\u6570\u636E\u96C6",
|
|
133
|
+
"\u505A\u6210\u6570\u636E\u96C6",
|
|
134
|
+
"\u6574\u7406\u6210\u6570\u636E\u96C6",
|
|
135
|
+
"\u6574\u7406\u6210\u8868",
|
|
136
|
+
"\u6574\u7406\u6210\u4E00\u5F20\u8868",
|
|
137
|
+
"\u5EFA\u7ACB\u4E00\u4E2A\u8868",
|
|
138
|
+
"\u5EFA\u7ACB\u4E00\u5F20\u8868",
|
|
139
|
+
"\u5EFA\u7ACB\u6210\u8868",
|
|
140
|
+
"\u5EFA\u7ACB\u6210\u4E00\u5F20\u8868",
|
|
141
|
+
"\u521B\u5EFA\u8FD9\u4E2A\u8868\u683C",
|
|
142
|
+
"\u786E\u8BA4\u521B\u5EFA",
|
|
143
|
+
"\u786E\u8BA4\u521B\u5EFA\u8FD9\u5F20\u8868\u683C",
|
|
144
|
+
"create doc",
|
|
145
|
+
"import skill",
|
|
146
|
+
"confirm import",
|
|
147
|
+
"create skill",
|
|
148
|
+
"create table",
|
|
149
|
+
"write table",
|
|
150
|
+
"save to table",
|
|
151
|
+
"dataset",
|
|
152
|
+
"save this",
|
|
153
|
+
"remember this",
|
|
154
|
+
"document this"
|
|
155
|
+
])) {
|
|
156
|
+
return "strong";
|
|
157
|
+
}
|
|
158
|
+
if (containsAny(normalized, [
|
|
159
|
+
"\u603B\u7ED3",
|
|
160
|
+
"\u65B9\u6848",
|
|
161
|
+
"\u8C03\u7814",
|
|
162
|
+
"\u89C4\u8303",
|
|
163
|
+
"\u4F1A\u8BAE\u7EAA\u8981",
|
|
164
|
+
"\u603B\u7ED3\u4E00\u4E0B",
|
|
165
|
+
"research",
|
|
166
|
+
"proposal",
|
|
167
|
+
"spec",
|
|
168
|
+
"summary"
|
|
169
|
+
])) {
|
|
170
|
+
return "possible";
|
|
171
|
+
}
|
|
172
|
+
return "none";
|
|
173
|
+
};
|
|
174
|
+
var resolveTonePreset = (agentTone, userTone, mode) => {
|
|
175
|
+
if (mode === "agent_first") {
|
|
176
|
+
return agentTone === "default" ? userTone : agentTone;
|
|
177
|
+
}
|
|
178
|
+
if (mode === "user_first") {
|
|
179
|
+
return userTone === "default" ? agentTone : userTone;
|
|
180
|
+
}
|
|
181
|
+
if (userTone !== "default") return userTone;
|
|
182
|
+
return agentTone;
|
|
183
|
+
};
|
|
184
|
+
var preloadSummaryCountByLevel = (level) => ({ 1: 0, 2: 0, 3: 8, 4: 16 })[level];
|
|
185
|
+
var preloadBudgetRatioByLevel = (level) => ({ 1: 0, 2: 0.01, 3: 0.04, 4: 0.08 })[level];
|
|
186
|
+
var knowledgeCaptureLevelLabel = (level) => ({
|
|
187
|
+
1: "\u4E0D\u4E3B\u52A8\u521B\u5EFA",
|
|
188
|
+
2: "\u5148\u95EE\u518D\u521B\u5EFA",
|
|
189
|
+
3: "\u56DE\u7B54\u540E\u5EFA\u8BAE\u521B\u5EFA",
|
|
190
|
+
4: "\u9AD8\u4EF7\u503C\u7ED3\u679C\u53EF\u81EA\u52A8\u521B\u5EFA"
|
|
191
|
+
})[level] ?? "\u672A\u77E5\u7EA7\u522B";
|
|
192
|
+
var spaceContextLevelLabel = (level) => ({
|
|
193
|
+
1: "\u4E0D\u81EA\u52A8\u8BFB\u53D6",
|
|
194
|
+
2: "\u53EA\u770B\u7ED3\u6784\u548C\u6807\u9898",
|
|
195
|
+
3: "\u8F7B\u91CF\u8BFB\u53D6",
|
|
196
|
+
4: "\u81EA\u9002\u5E94\u8BFB\u53D6"
|
|
197
|
+
})[level] ?? "\u672A\u77E5\u7EA7\u522B";
|
|
198
|
+
var buildStaticUserPolicyContext = (params) => {
|
|
199
|
+
const agentBasePolicy = resolveAgentBasePolicy(params.agentConfig);
|
|
200
|
+
const userPreferenceProfile = resolveUserPreferenceProfile(params.settingsRecord);
|
|
201
|
+
const tonePreset = resolveTonePreset(
|
|
202
|
+
agentBasePolicy.tone?.preset ?? "default",
|
|
203
|
+
userPreferenceProfile.tone?.preset ?? "default",
|
|
204
|
+
agentBasePolicy.tone?.resolutionMode ?? "blend"
|
|
205
|
+
);
|
|
206
|
+
const knowledgeLevel = Math.min(
|
|
207
|
+
agentBasePolicy.knowledgeCaptureMaxLevel,
|
|
208
|
+
userPreferenceProfile.knowledgeCaptureLevel
|
|
209
|
+
);
|
|
210
|
+
const spaceLevel = Math.min(
|
|
211
|
+
agentBasePolicy.spaceContextMaxLevel,
|
|
212
|
+
userPreferenceProfile.spaceContextLevel
|
|
213
|
+
);
|
|
214
|
+
return [
|
|
215
|
+
`\u7528\u6237\u8BED\u6C14\u504F\u597D\uFF1A${tonePreset}`,
|
|
216
|
+
`\u77E5\u8BC6\u6C89\u6DC0\u7EA7\u522B\uFF1A${knowledgeLevel}\uFF08${knowledgeCaptureLevelLabel(knowledgeLevel)}\uFF09`,
|
|
217
|
+
`\u7A7A\u95F4\u4E0A\u4E0B\u6587\u7EA7\u522B\uFF1A${spaceLevel}\uFF08${spaceContextLevelLabel(spaceLevel)}\uFF09`,
|
|
218
|
+
"\u8BF7\u5C3D\u91CF\u4FDD\u7559 agent \u81EA\u8EAB\u89D2\u8272\u8BBE\u5B9A\uFF0C\u540C\u65F6\u6309\u7528\u6237\u504F\u597D\u8C03\u6574\u8868\u8FBE\u548C\u81EA\u52A8\u5316\u7A0B\u5EA6\u3002"
|
|
219
|
+
].join("\n");
|
|
220
|
+
};
|
|
221
|
+
var resolveSpaceContextPreloadPlan = (level) => ({
|
|
222
|
+
preloadSummaryCount: preloadSummaryCountByLevel(level),
|
|
223
|
+
preloadBudgetRatio: preloadBudgetRatioByLevel(level),
|
|
224
|
+
includeRecentContent: level >= 3
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
export {
|
|
228
|
+
inferCaptureIntent,
|
|
229
|
+
buildStaticUserPolicyContext,
|
|
230
|
+
resolveSpaceContextPreloadPlan
|
|
231
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import {
|
|
2
|
+
i18n_default,
|
|
3
|
+
toolRegistry
|
|
4
|
+
} from "./chunk-TYH5JE6N.js";
|
|
5
|
+
import {
|
|
6
|
+
canonicalizeToolNames
|
|
7
|
+
} from "./chunk-LM25IZBJ.js";
|
|
8
|
+
import {
|
|
9
|
+
asTrimmedLowercaseString
|
|
10
|
+
} from "./chunk-QSJ3HFEF.js";
|
|
11
|
+
import {
|
|
12
|
+
isRecord
|
|
13
|
+
} from "./chunk-KUG52IAP.js";
|
|
14
|
+
|
|
15
|
+
// packages/ai/tools/toolSchemaCompatibility.ts
|
|
16
|
+
var COMPOSITION_KEYS = ["anyOf", "oneOf", "allOf"];
|
|
17
|
+
var LIMITED_JSON_SCHEMA_PROVIDERS = /* @__PURE__ */ new Set([
|
|
18
|
+
"fireworks"
|
|
19
|
+
]);
|
|
20
|
+
var sanitizeSchemaNode = (value) => {
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
return value.map((item) => sanitizeSchemaNode(item));
|
|
23
|
+
}
|
|
24
|
+
if (!isRecord(value)) {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
const next = {};
|
|
28
|
+
for (const [key, child] of Object.entries(value)) {
|
|
29
|
+
if (COMPOSITION_KEYS.includes(key)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
next[key] = sanitizeSchemaNode(child);
|
|
33
|
+
}
|
|
34
|
+
return next;
|
|
35
|
+
};
|
|
36
|
+
var shouldSanitizeProviderSchema = (provider) => LIMITED_JSON_SCHEMA_PROVIDERS.has(asTrimmedLowercaseString(provider));
|
|
37
|
+
var sanitizeToolForProvider = (tool, provider) => {
|
|
38
|
+
if (!shouldSanitizeProviderSchema(provider)) {
|
|
39
|
+
return tool;
|
|
40
|
+
}
|
|
41
|
+
const parameters = tool?.function?.parameters;
|
|
42
|
+
if (!isRecord(parameters)) {
|
|
43
|
+
return tool;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
...tool,
|
|
47
|
+
function: {
|
|
48
|
+
...tool.function,
|
|
49
|
+
parameters: sanitizeSchemaNode(parameters)
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// packages/ai/tools/prepareTools.ts
|
|
55
|
+
var translatedFunctionCache = /* @__PURE__ */ new Map();
|
|
56
|
+
var prepareToolsResultCache = /* @__PURE__ */ new Map();
|
|
57
|
+
var PREPARE_TOOLS_CACHE_LIMIT = 128;
|
|
58
|
+
function getTranslation(keys, defaultVal) {
|
|
59
|
+
for (const key of keys) {
|
|
60
|
+
if (i18n_default.exists(key)) {
|
|
61
|
+
return i18n_default.t(key);
|
|
62
|
+
}
|
|
63
|
+
const aiKey = key.startsWith("ai:") ? key : `ai:${key}`;
|
|
64
|
+
if (i18n_default.exists(aiKey)) {
|
|
65
|
+
return i18n_default.t(aiKey);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return defaultVal;
|
|
69
|
+
}
|
|
70
|
+
function translateSchema(schema) {
|
|
71
|
+
if (!schema || typeof schema !== "object") return schema;
|
|
72
|
+
const nextSchema = JSON.parse(JSON.stringify(schema));
|
|
73
|
+
const toolName = nextSchema.name;
|
|
74
|
+
if (!toolName) return nextSchema;
|
|
75
|
+
const walk = (node, path) => {
|
|
76
|
+
if (!node || typeof node !== "object") return;
|
|
77
|
+
if (typeof node.description === "string") {
|
|
78
|
+
const keysToTry = [
|
|
79
|
+
`${path}.description`,
|
|
80
|
+
`${path}.desc`,
|
|
81
|
+
path,
|
|
82
|
+
node.description
|
|
83
|
+
];
|
|
84
|
+
node.description = getTranslation(keysToTry, node.description);
|
|
85
|
+
}
|
|
86
|
+
if (node.parameters && typeof node.parameters === "object") {
|
|
87
|
+
walk(node.parameters, path);
|
|
88
|
+
}
|
|
89
|
+
if (node.properties && typeof node.properties === "object") {
|
|
90
|
+
for (const [key, child] of Object.entries(node.properties)) {
|
|
91
|
+
const nextPath = path.endsWith(".params") ? `${path}.${key}` : `${path}.params.${key}`;
|
|
92
|
+
walk(child, nextPath);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (node.items && typeof node.items === "object") {
|
|
96
|
+
walk(node.items, path);
|
|
97
|
+
}
|
|
98
|
+
const compositions = ["anyOf", "oneOf", "allOf"];
|
|
99
|
+
for (const comp of compositions) {
|
|
100
|
+
if (Array.isArray(node[comp])) {
|
|
101
|
+
node[comp].forEach((child, idx) => {
|
|
102
|
+
const suffix = child.type === "string" ? "stringDesc" : child.type === "object" ? "objectDesc" : `${idx}`;
|
|
103
|
+
walk(child, `${path}.${suffix}`);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
walk(nextSchema, `tools.${toolName}`);
|
|
109
|
+
return nextSchema;
|
|
110
|
+
}
|
|
111
|
+
function currentI18nLanguage() {
|
|
112
|
+
return typeof i18n_default.language === "string" ? i18n_default.language : "";
|
|
113
|
+
}
|
|
114
|
+
function translateSchemaCached(schema) {
|
|
115
|
+
if (!schema || typeof schema !== "object") return schema;
|
|
116
|
+
const toolName = typeof schema.name === "string" ? schema.name : "";
|
|
117
|
+
if (!toolName) return translateSchema(schema);
|
|
118
|
+
const cacheKey = `${currentI18nLanguage()}\0${toolName}`;
|
|
119
|
+
const hit = translatedFunctionCache.get(cacheKey);
|
|
120
|
+
if (hit) return hit;
|
|
121
|
+
const translated = translateSchema(schema);
|
|
122
|
+
translatedFunctionCache.set(cacheKey, translated);
|
|
123
|
+
return translated;
|
|
124
|
+
}
|
|
125
|
+
function buildPrepareToolsCacheKey(toolNames, disabledToolNames, provider) {
|
|
126
|
+
return [
|
|
127
|
+
currentI18nLanguage(),
|
|
128
|
+
provider ?? "",
|
|
129
|
+
disabledToolNames.join(""),
|
|
130
|
+
toolNames.join("")
|
|
131
|
+
].join("\0");
|
|
132
|
+
}
|
|
133
|
+
function rememberPrepareToolsResult(key, value) {
|
|
134
|
+
if (prepareToolsResultCache.size >= PREPARE_TOOLS_CACHE_LIMIT) {
|
|
135
|
+
const oldest = prepareToolsResultCache.keys().next().value;
|
|
136
|
+
if (oldest !== void 0) {
|
|
137
|
+
prepareToolsResultCache.delete(oldest);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
prepareToolsResultCache.set(key, value);
|
|
141
|
+
}
|
|
142
|
+
var prepareTools = (toolNames, options) => {
|
|
143
|
+
const disabledList = canonicalizeToolNames(options?.disabledToolNames ?? []);
|
|
144
|
+
const disabledToolNames = new Set(disabledList);
|
|
145
|
+
const canonicalNames = canonicalizeToolNames(toolNames).filter(
|
|
146
|
+
(toolName) => !disabledToolNames.has(toolName)
|
|
147
|
+
);
|
|
148
|
+
const cacheKey = buildPrepareToolsCacheKey(
|
|
149
|
+
canonicalNames,
|
|
150
|
+
disabledList,
|
|
151
|
+
options?.provider
|
|
152
|
+
);
|
|
153
|
+
const cached = prepareToolsResultCache.get(cacheKey);
|
|
154
|
+
if (cached) {
|
|
155
|
+
return cached.slice();
|
|
156
|
+
}
|
|
157
|
+
const prepared = canonicalNames.map((toolName) => {
|
|
158
|
+
const regTool = toolRegistry[toolName];
|
|
159
|
+
if (!regTool) return regTool;
|
|
160
|
+
return {
|
|
161
|
+
...regTool,
|
|
162
|
+
function: translateSchemaCached(regTool.function)
|
|
163
|
+
};
|
|
164
|
+
}).map((tool) => sanitizeToolForProvider(tool, options?.provider)).filter(Boolean);
|
|
165
|
+
rememberPrepareToolsResult(cacheKey, prepared);
|
|
166
|
+
return prepared.slice();
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export {
|
|
170
|
+
prepareTools
|
|
171
|
+
};
|
|
@@ -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
|
+
};
|