nolo-cli 0.32.0 → 0.33.0-alpha.11
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 +6 -12
- package/{_executeModel-LTMSIBS4.js → _executeModel-YXWAXPWQ.js} +77 -67
- package/{action-HI3VRQLP.js → action-OQWPNKAH.js} +17 -15
- package/{addContentAction-NCURJ6PK.js → addContentAction-YVINZQTF.js} +14 -13
- package/{addDialogAgentAction-RCY4ECF4.js → addDialogAgentAction-6IOCIEPI.js} +14 -13
- package/{agentDeleteCommand-D3MYZK6E.js → agentDeleteCommand-VGHWJN5T.js} +44 -60
- package/{agentEmailCommands-6BXS574I.js → agentEmailCommands-ZLRF35I3.js} +91 -81
- package/{agentGrantCommands-E7ZZFRHK.js → agentGrantCommands-2LEZDADN.js} +2 -2
- package/{agentListCommands-SF3HEUTT.js → agentListCommands-OHZJ7AFP.js} +75 -79
- package/{agentMachineCommands-YARVXRR6.js → agentMachineCommands-62PHPGTK.js} +43 -59
- package/{agentPullCommand-ARSIDNVC.js → agentPullCommand-TSWAJPS2.js} +5 -5
- package/agentRecordCommands-CW2JWERD.js +113 -0
- package/agentRunCommand-O4HV7YWA.js +131 -0
- package/{agentRuntimeLocal-ATGJY6WC.js → agentRuntimeLocal-4PSBNUOE.js} +37 -51
- package/{agentSlice-4XWW344Y.js → agentSlice-OUTQ5O72.js} +16 -14
- package/{appDeleteCommands-63JO7RXS.js → appDeleteCommands-VTDBVHYR.js} +40 -56
- package/{appDeployCommands-Y7EWYUGM.js → appDeployCommands-WOUP7MDA.js} +40 -56
- package/{appDeployStatusCommands-ZBEY3DWB.js → appDeployStatusCommands-N2NWZKEN.js} +40 -56
- package/{appGetCommands-QSSOSEYL.js → appGetCommands-GYKLWWCA.js} +40 -56
- package/{appListCommands-PH3XWNDX.js → appListCommands-RUWBSEJK.js} +40 -56
- package/{authCommand-BBDHMSO6.js → authCommand-YVXVH25I.js} +21 -20
- package/{authCommands-4UDEKRE6.js → authCommands-WTW6MEYS.js} +10 -10
- package/chatQueueReduxAdapter-2QJAD4KQ.js +181 -0
- package/{chunk-EEF23OOK.js → chunk-266VUBLK.js} +7 -7
- package/{chunk-TEYN42N3.js → chunk-2IVEXF7P.js} +11 -4
- package/{chunk-2HXKAPH7.js → chunk-2QLAVHVK.js} +6 -6
- package/{chunk-WTGCTVJG.js → chunk-2QTEYCR7.js} +3 -6
- package/{chunk-DOISARTV.js → chunk-2UECQ7RE.js} +1 -1
- package/{chunk-E3APEOIM.js → chunk-3GZXL6FM.js} +4 -19
- package/{chunk-KGEVMUMI.js → chunk-3RUW3ONU.js} +11 -11
- package/{chunk-RXVX5LFR.js → chunk-3UG2IIZ3.js} +1 -1
- package/{chunk-O5OMJPPF.js → chunk-3WXRAHCG.js} +6 -5
- package/{chunk-V54H24CQ.js → chunk-4F5M2MW5.js} +3 -3
- package/{chunk-2ZRP5RUG.js → chunk-4OV7DXFJ.js} +12 -11
- package/{chunk-W367V5CH.js → chunk-54BAYVCY.js} +404 -117
- package/{chunk-GAF5X6B7.js → chunk-5QW3O3ET.js} +284 -310
- package/{chunk-DLWCWUNW.js → chunk-64OVNZXE.js} +1197 -757
- package/{chunk-ODS2MVMU.js → chunk-66CWPJK2.js} +19 -303
- package/{chunk-PTHDLIRB.js → chunk-6KOS7ZBZ.js} +1 -1
- package/{chunk-MXFQHRSS.js → chunk-6XIE5ZGI.js} +1 -1
- package/{chunk-ATK5WJOA.js → chunk-6YXDOOSH.js} +4 -4
- package/{chunk-SWYMCHM7.js → chunk-75U775RZ.js} +69 -1
- package/{chunk-UDA3ZYLW.js → chunk-7YYHKBJP.js} +31 -72
- package/chunk-ADLYMQB6.js +642 -0
- package/{chunk-ZWJOGMKH.js → chunk-AETZ7AD6.js} +1 -1
- package/{chunk-43EPBPZ2.js → chunk-ASDXPOJH.js} +2 -2
- package/{chunk-44HACRCK.js → chunk-BANYWEYY.js} +4 -4
- package/chunk-BFPSVRCQ.js +1799 -0
- package/{chunk-TOW4E763.js → chunk-BJIRLHJR.js} +2 -0
- package/{chunk-ZJ2WITOO.js → chunk-BQXOGBFN.js} +2 -2
- package/{chunk-4PNU7W7K.js → chunk-C7H5GMXT.js} +107 -125
- package/chunk-CPYYM4RJ.js +98 -0
- package/{chunk-3GZT3L6F.js → chunk-DDVIBKIB.js} +326 -481
- package/{chunk-2K4NDPT5.js → chunk-DFUPZE6V.js} +20 -12
- package/{chunk-BGTUGS3T.js → chunk-DKMOY3QI.js} +4 -30
- package/chunk-EGRJC4ZN.js +91 -0
- package/{chunk-K6QEHQZ3.js → chunk-EKLRRZIN.js} +1 -1
- package/{chunk-6HYVJV7B.js → chunk-ESHYE7WU.js} +2 -1
- package/{chunk-XFG3BAKN.js → chunk-FMEVI5TG.js} +65 -0
- package/{chunk-U4TRT5V4.js → chunk-GEPHJJW4.js} +1 -1
- package/chunk-GJXRIOLS.js +241 -0
- package/{chunk-VP4WJWKW.js → chunk-GM6PU7B6.js} +431 -345
- package/chunk-HS7MLR74.js +38 -0
- package/{chunk-3AUWC6EM.js → chunk-HUCT7HID.js} +5 -84
- package/chunk-IDAU4UFS.js +437 -0
- package/{chunk-Q76I4SXI.js → chunk-IHEC7VBF.js} +1 -1
- package/{chunk-OWHNFZNW.js → chunk-IKWTTKWG.js} +4 -4
- package/{chunk-3LY4F7SV.js → chunk-INZZJSQF.js} +348 -331
- package/{chunk-ZJH3LKEW.js → chunk-IR6W62Q6.js} +102 -15
- package/{chunk-RH53LMEJ.js → chunk-J44TVX2O.js} +2 -4
- package/{chunk-CF2WZF4N.js → chunk-J6WH4PYZ.js} +0 -8
- package/chunk-KHCLMKZZ.js +3062 -0
- package/{chunk-WHLVPK32.js → chunk-KMSZPTM6.js} +27 -3
- package/{chunk-L3GCUVOH.js → chunk-KSRFVP36.js} +1 -1
- package/{chunk-XDHHF73Q.js → chunk-LUIHOUZC.js} +95 -95
- package/{chunk-UOJRKY5J.js → chunk-M2YMQOLC.js} +44 -53
- package/chunk-M3JEW6N6.js +193 -0
- package/{chunk-MITD7CON.js → chunk-MDIAECHA.js} +1461 -301
- package/{chunk-IXZX5CJK.js → chunk-MQRZ5QUH.js} +1 -1
- package/{chunk-3ASDTTEI.js → chunk-MRWGHF56.js} +2 -0
- package/{chunk-Q3CSL43H.js → chunk-N4XRDM26.js} +1 -1
- package/{chunk-D34RI6NI.js → chunk-NNWHHCVP.js} +75 -1
- package/{chunk-CAENRKNJ.js → chunk-OR2HNLVO.js} +126 -88
- package/chunk-OW765XBU.js +10 -0
- package/{chunk-VMWR7VNI.js → chunk-PRMMCFIN.js} +13 -9
- package/{chunk-JZPBVBIY.js → chunk-QTZD6HBK.js} +18 -8
- package/chunk-RCFIB45Q.js +28 -0
- package/{chunk-7S54ZGF6.js → chunk-RJKIB55Y.js} +256 -12
- package/chunk-RPRRIFXV.js +231 -0
- package/chunk-RQFO3CAF.js +300 -0
- package/chunk-RY57GLGW.js +188 -0
- package/{chunk-YHGHADBQ.js → chunk-SCUETSRP.js} +4 -4
- package/{chunk-TA6EA2A3.js → chunk-TFK3HUNQ.js} +182 -20
- package/{chunk-LAXMH7JY.js → chunk-UM4H3URE.js} +18 -15
- package/{chunk-6YABCOFU.js → chunk-UNHKVD2N.js} +1 -1
- package/{chunk-G5GVZAXF.js → chunk-UNOTBWZZ.js} +15 -19
- package/{chunk-GE6IWA5N.js → chunk-UNZDCI3O.js} +126 -1
- package/chunk-URMS4XY2.js +10 -0
- package/{chunk-SFWZUTCI.js → chunk-VBUQYOX7.js} +2 -2
- package/{chunk-FXFGNOT2.js → chunk-VFVCYIRQ.js} +1 -1
- package/chunk-VIDPVFP3.js +20 -0
- package/{chunk-5RDLGLAP.js → chunk-WJSW43QZ.js} +4 -7
- package/{chunk-CF7S2RYZ.js → chunk-WLH5BAKX.js} +6 -6
- package/{chunk-VVEH6XUE.js → chunk-X2DAEZ3X.js} +1 -1
- package/{chunk-2IJAKBK2.js → chunk-X664KVEV.js} +426 -246
- package/{chunk-3FCNXC2J.js → chunk-XRO5VGQ6.js} +3735 -1394
- package/chunk-Y5GCAMGP.js +9 -0
- package/{chunk-O3JR45Q2.js → chunk-YBMI5JAH.js} +44 -44
- package/{chunk-V42OE5HT.js → chunk-YDTYDA5W.js} +3 -3
- package/chunk-YYLHWIW6.js +48 -0
- package/{chunk-AOS5IN2I.js → chunk-ZHYK3N56.js} +1 -1
- package/{chunk-PJ2DDQQM.js → chunk-ZURFOV5J.js} +2 -2
- package/{chunk-3UGKATZQ.js → chunk-ZWS6DUHX.js} +26 -435
- package/chunk-ZZ2MH7LE.js +84 -0
- package/{cliExecutor-BBUVQU4L.js → cliExecutor-DW3PHGEL.js} +2 -2
- package/{clipboardy-BVE3LVEH.js → clipboardy-MMBYVRLF.js} +166 -372
- package/{codingSkills-V35TRR4Y.js → codingSkills-DY5MINPG.js} +5 -4
- package/{createAgentAutomationAction-WLRNE7C4.js → createAgentAutomationAction-H6ZRPXBR.js} +41 -31
- package/createDialogAction-UJ6LFJYM.js +61 -0
- package/{createPageAction-7YROVZ3W.js → createPageAction-KVPT3IRK.js} +57 -47
- package/{db-6DPSJ6WT.js → db-3H3JECGY.js} +45 -5
- package/{dbSlice-BBL3PEVW.js → dbSlice-UI2VCBLG.js} +13 -12
- package/{deleteFile-RJTEPOT4.js → deleteFile-XQXPBFFB.js} +7 -6
- package/dialogCommands-6ASXJP3H.js +82 -0
- package/{dialogSlice-N4HPG6HM.js → dialogSlice-B7KCGHMY.js} +37 -29
- package/{docCreateCommands-GRA5BHSA.js → docCreateCommands-S4E4MKVC.js} +42 -56
- package/{docDeleteCommands-ONIJM5MD.js → docDeleteCommands-M7XLKWRM.js} +44 -58
- package/{docReadCommands-H55VQ2US.js → docReadCommands-LSCMW2FR.js} +42 -56
- package/{docStore-B5AHDNW5.js → docStore-ZYWZWIRB.js} +40 -30
- package/{docUpdateCommands-ZQIQVGC2.js → docUpdateCommands-OMRBAFOB.js} +45 -59
- package/{fetchMessages-VPPQDDZ4.js → fetchMessages-7QRCCRYK.js} +3 -3
- package/{getPricing-QO5TYNCK.js → getPricing-L2ENXWHV.js} +7 -6
- package/{handleSendMessageAction-IN5XX5U7.js → handleSendMessageAction-Y2XKODRT.js} +39 -31
- package/index.js +74 -74
- package/{lib-FYYBQIXS.js → lib-2ZTNRXR4.js} +432 -183
- package/{localDialogRead-3DBXVYXS.js → localDialogRead-SLMPV5SK.js} +2 -2
- package/{localRuntimeAuthority-NDUA2D7Y.js → localRuntimeAuthority-S77B5QVB.js} +10 -4
- package/{localRuntimeDb-GKYRBWLQ.js → localRuntimeDb-N3H3HQ7G.js} +1 -1
- package/{machineCommands-H3UMKE76.js → machineCommands-62RUZVSW.js} +95 -85
- package/{machineInfo-M6KB6HZN.js → machineInfo-66ZFUMLE.js} +1 -1
- package/machineWsRunDispatch-L3HD3FSF.js +129 -0
- package/{models-WDUTTYFS.js → models-OX2S5C6Q.js} +2 -2
- package/{offlineMarxistsAgentCommand-E6LUG63A.js → offlineMarxistsAgentCommand-GEH6SNNA.js} +1 -1
- package/package.json +1 -4
- package/{read-64OQDO3I.js → read-2VHEHCAN.js} +8 -7
- package/{readDocTool-MXM3T6PE.js → readDocTool-CSWD6NPC.js} +1 -2
- package/{readlineWorkspace-XVJZDCSC.js → readlineWorkspace-3MOJWFM7.js} +3358 -3409
- package/{removeDialogAgentAction-NEKVAMSH.js → removeDialogAgentAction-2T7BPM3T.js} +19 -17
- package/{runAgentClientLoop-H7U53QB6.js → runAgentClientLoop-Y5UW544I.js} +73 -64
- package/{runtimeDoctorCommands-WI2YZUSJ.js → runtimeDoctorCommands-KHGQKT3B.js} +6 -6
- package/{setDialogExtraReferencesAction-WTOHQDIV.js → setDialogExtraReferencesAction-GPT37HTW.js} +15 -14
- package/{setPrimaryDialogAgentAction-LDJOYC4F.js → setPrimaryDialogAgentAction-3746P7IW.js} +19 -17
- package/{settingSlice-4M37TN7V.js → settingSlice-FIFOQ6OR.js} +16 -14
- package/{skillDiscovery-5U6RYAHN.js → skillDiscovery-KLLKXPUO.js} +4 -4
- package/{slateUtils-2M7MUTWX.js → slateUtils-VO2FU36K.js} +1 -1
- package/{spaceCommands-7VVKJBDV.js → spaceCommands-NKSBD5G3.js} +45 -241
- package/{spaceSlice-T6YK6D34.js → spaceSlice-L44CI2QR.js} +39 -61
- package/{streamAgentChatTurn-RQ63QFQ7.js → streamAgentChatTurn-7DU4Z2VJ.js} +1262 -150
- package/{switchDialogAgentAction-XVWGKR2Z.js → switchDialogAgentAction-MQTUTQHL.js} +14 -13
- package/syncMapping-RK2MANUX.js +43 -0
- package/{tableCommands-RJZ3V4TF.js → tableCommands-64FZBAI3.js} +9 -8
- package/{toolApiClient-ARGFDJAG.js → toolApiClient-B2MFXMEG.js} +3 -3
- package/tools-2JI52WJP.js +99 -0
- package/{tuiSummaryLlmCaller-SRZ4QQUP.js → tuiSummaryLlmCaller-EAWQ3IZX.js} +25 -21
- package/{updateCommands-AK2RDOFR.js → updateCommands-MNDUIKN7.js} +2 -2
- package/{updateDialogTitleAction-BBDSWHNG.js → updateDialogTitleAction-HW33OIJI.js} +49 -38
- package/agentRecordCommands-JFZRQJQ4.js +0 -103
- package/agentRunCommand-NOX5FLKO.js +0 -121
- package/chunk-AYMOSAHE.js +0 -3158
- package/chunk-D2BPX6DQ.js +0 -1707
- package/chunk-DCDL3GC4.js +0 -171
- package/chunk-F3MP7CP6.js +0 -73
- package/chunk-WZSRQNQG.js +0 -2587
- package/createDialogAction-Y6YV64QB.js +0 -52
- package/dialogCommands-XLO5CAHZ.js +0 -95
- package/machineWsRunDispatch-HONRUK3R.js +0 -119
- package/tools-KYZX3BGO.js +0 -90
- package/{chunk-Z5MXSEOJ.js → chunk-RQSOAMPJ.js} +2 -2
- package/{chunk-JDSUTNYY.js → chunk-SAQQLJZ5.js} +3 -3
|
@@ -3,7 +3,11 @@ import {
|
|
|
3
3
|
} from "./chunk-T27IEBNQ.js";
|
|
4
4
|
import {
|
|
5
5
|
accumulateToolCallDelta,
|
|
6
|
+
createThinkParserState,
|
|
7
|
+
createToolCallAccumulator,
|
|
8
|
+
createToolCallTextParserState,
|
|
6
9
|
extractThinkContent,
|
|
10
|
+
finalizeAccumulatedToolCalls,
|
|
7
11
|
flushThinkParser,
|
|
8
12
|
flushToolCallTextParserIntoCallback,
|
|
9
13
|
longestTagPrefixLength,
|
|
@@ -14,11 +18,12 @@ import {
|
|
|
14
18
|
convertMessagesToResponsesInput,
|
|
15
19
|
extractTextFromResponseOutput,
|
|
16
20
|
extractToolCallsFromResponseOutput,
|
|
21
|
+
getUsageRequestOptions,
|
|
17
22
|
hasImageParts,
|
|
18
23
|
shouldStripReasoningContentForOutbound,
|
|
19
24
|
toOpenAiCompatibleMessages,
|
|
20
25
|
toResponsesTools
|
|
21
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-NNWHHCVP.js";
|
|
22
27
|
import {
|
|
23
28
|
buildProviderExecutionPlan,
|
|
24
29
|
canUsePlatformChatProvider,
|
|
@@ -27,14 +32,48 @@ import {
|
|
|
27
32
|
resolvePlatformAuthToken,
|
|
28
33
|
resolvePlatformServerUrl,
|
|
29
34
|
resolveProviderTransportDecision
|
|
30
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-7YYHKBJP.js";
|
|
31
36
|
import {
|
|
32
37
|
clipCompactText
|
|
33
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-DKMOY3QI.js";
|
|
34
39
|
import {
|
|
35
40
|
isRecord
|
|
36
41
|
} from "./chunk-KUG52IAP.js";
|
|
37
42
|
|
|
43
|
+
// packages/ai/token/sseUsageExtract.ts
|
|
44
|
+
var TOKEN_FIELDS = [
|
|
45
|
+
"prompt_tokens",
|
|
46
|
+
"completion_tokens",
|
|
47
|
+
"input_tokens",
|
|
48
|
+
"output_tokens",
|
|
49
|
+
"total_tokens"
|
|
50
|
+
];
|
|
51
|
+
function hasUsageTokens(value) {
|
|
52
|
+
if (!value || typeof value !== "object") return false;
|
|
53
|
+
const record = value;
|
|
54
|
+
return TOKEN_FIELDS.some(
|
|
55
|
+
(field) => typeof record[field] === "number" && Number.isFinite(record[field])
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
function extractUsageFromSsePayload(parsed) {
|
|
59
|
+
if (!parsed || typeof parsed !== "object") return void 0;
|
|
60
|
+
const payload = parsed;
|
|
61
|
+
const topLevel = payload.usage;
|
|
62
|
+
if (topLevel && typeof topLevel === "object" && hasUsageTokens(topLevel)) {
|
|
63
|
+
return topLevel;
|
|
64
|
+
}
|
|
65
|
+
if (payload.type === "response.completed") {
|
|
66
|
+
const response = payload.response;
|
|
67
|
+
if (response && typeof response === "object") {
|
|
68
|
+
const nested = response.usage;
|
|
69
|
+
if (nested && typeof nested === "object" && hasUsageTokens(nested)) {
|
|
70
|
+
return nested;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return void 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
38
77
|
// packages/core/chat/providerFailureMessage.ts
|
|
39
78
|
var RAW_BODY_CLIP = 400;
|
|
40
79
|
function describeProviderFailure(args) {
|
|
@@ -147,6 +186,54 @@ function parseDsml(text) {
|
|
|
147
186
|
return { content: chunk.content + tail.content, toolCalls: [...chunk.toolCalls, ...tail.toolCalls] };
|
|
148
187
|
}
|
|
149
188
|
|
|
189
|
+
// packages/agent-runtime/responsesToolCallAccumulator.ts
|
|
190
|
+
function normalizeResponsesToolArguments(value) {
|
|
191
|
+
if (typeof value === "string") return value;
|
|
192
|
+
if (value && typeof value === "object") {
|
|
193
|
+
try {
|
|
194
|
+
return JSON.stringify(value);
|
|
195
|
+
} catch {
|
|
196
|
+
return void 0;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return void 0;
|
|
200
|
+
}
|
|
201
|
+
function createResponsesToolAccumulator() {
|
|
202
|
+
return /* @__PURE__ */ new Map();
|
|
203
|
+
}
|
|
204
|
+
function keyOf(event) {
|
|
205
|
+
return typeof event?.item_id === "string" && event.item_id ? event.item_id : typeof event?.item?.id === "string" && event.item.id ? event.item.id : typeof event?.item?.call_id === "string" && event.item.call_id ? event.item.call_id : typeof event?.call_id === "string" && event.call_id ? event.call_id : "";
|
|
206
|
+
}
|
|
207
|
+
function applyResponsesToolEvent(calls, event) {
|
|
208
|
+
const key = keyOf(event);
|
|
209
|
+
if (!key) return;
|
|
210
|
+
const item = event?.item;
|
|
211
|
+
const id = item?.call_id || item?.id || event?.call_id || key;
|
|
212
|
+
const current = calls.get(key) ?? { id, name: "", arguments: "" };
|
|
213
|
+
if (typeof item?.name === "string" && item.name) current.name = item.name;
|
|
214
|
+
const itemArguments = normalizeResponsesToolArguments(item?.arguments);
|
|
215
|
+
if (itemArguments !== void 0) current.arguments = itemArguments;
|
|
216
|
+
const eventArguments = normalizeResponsesToolArguments(event?.arguments);
|
|
217
|
+
if (eventArguments !== void 0) current.arguments = eventArguments;
|
|
218
|
+
if (typeof event?.delta === "string") current.arguments += event.delta;
|
|
219
|
+
calls.set(key, current);
|
|
220
|
+
}
|
|
221
|
+
function addResponsesToolCall(calls, call) {
|
|
222
|
+
const key = call.id;
|
|
223
|
+
calls.set(key, {
|
|
224
|
+
id: call.id,
|
|
225
|
+
name: call.function.name,
|
|
226
|
+
arguments: call.function.arguments
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
function finalizeResponsesToolCalls(calls) {
|
|
230
|
+
return [...calls.values()].filter((call) => call.name).map((call) => ({
|
|
231
|
+
id: call.id,
|
|
232
|
+
type: "function",
|
|
233
|
+
function: { name: call.name, arguments: call.arguments }
|
|
234
|
+
}));
|
|
235
|
+
}
|
|
236
|
+
|
|
150
237
|
// packages/agent-runtime/processChatCompletionDelta.ts
|
|
151
238
|
function extractChatCompletionStreamError(parsed) {
|
|
152
239
|
const raw = parsed?.error;
|
|
@@ -177,8 +264,9 @@ function applyChatCompletionDelta(parsed, state) {
|
|
|
177
264
|
if (streamError && !state.streamError) {
|
|
178
265
|
state.streamError = streamError;
|
|
179
266
|
}
|
|
180
|
-
|
|
181
|
-
|
|
267
|
+
const extractedUsage = extractUsageFromSsePayload(parsed);
|
|
268
|
+
if (extractedUsage) {
|
|
269
|
+
state.usage = extractedUsage;
|
|
182
270
|
}
|
|
183
271
|
const rawFinishReason = parsed?.choices?.[0]?.finish_reason;
|
|
184
272
|
if (typeof rawFinishReason === "string" && rawFinishReason.length > 0) {
|
|
@@ -260,11 +348,10 @@ async function* readSseFrames(response) {
|
|
|
260
348
|
}
|
|
261
349
|
if (buffer.trim()) yield buffer;
|
|
262
350
|
}
|
|
263
|
-
async function
|
|
351
|
+
async function* streamSseDataValues(response, parse) {
|
|
264
352
|
const reader = response.body?.getReader();
|
|
265
|
-
if (!reader) return
|
|
353
|
+
if (!reader) return;
|
|
266
354
|
const decoder = new TextDecoder();
|
|
267
|
-
const values = [];
|
|
268
355
|
let buffer = "";
|
|
269
356
|
while (true) {
|
|
270
357
|
const { done, value } = await reader.read();
|
|
@@ -274,12 +361,18 @@ async function readSseDataValues(response, parse) {
|
|
|
274
361
|
buffer = lines.pop() ?? "";
|
|
275
362
|
for (const line of lines) {
|
|
276
363
|
const parsed = parse(line);
|
|
277
|
-
if (parsed)
|
|
364
|
+
if (parsed) yield parsed;
|
|
278
365
|
}
|
|
279
366
|
}
|
|
280
367
|
if (buffer.trim()) {
|
|
281
368
|
const parsed = parse(buffer);
|
|
282
|
-
if (parsed)
|
|
369
|
+
if (parsed) yield parsed;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
async function readSseDataValues(response, parse) {
|
|
373
|
+
const values = [];
|
|
374
|
+
for await (const value of streamSseDataValues(response, parse)) {
|
|
375
|
+
values.push(value);
|
|
283
376
|
}
|
|
284
377
|
return values;
|
|
285
378
|
}
|
|
@@ -365,7 +458,7 @@ function buildPlatformChatCompletionRequest(args) {
|
|
|
365
458
|
})
|
|
366
459
|
},
|
|
367
460
|
stream: args.stream ?? false,
|
|
368
|
-
...args.stream ?
|
|
461
|
+
...args.stream ? getUsageRequestOptions(args.providerConfig.provider, { api: "chat-completions" }) : {},
|
|
369
462
|
...requestOptions,
|
|
370
463
|
...args.tools && args.tools.length > 0 ? {
|
|
371
464
|
tools: usesResponsesApi ? toResponsesTools(args.tools) : args.tools,
|
|
@@ -375,6 +468,7 @@ function buildPlatformChatCompletionRequest(args) {
|
|
|
375
468
|
url: args.providerConfig.endpoint,
|
|
376
469
|
provider: args.providerConfig.provider,
|
|
377
470
|
agentKey: args.providerConfig.agentKey,
|
|
471
|
+
...args.dialogId?.trim() ? { dialogId: args.dialogId.trim() } : {},
|
|
378
472
|
...args.providerConfig.apiSource ? { apiSource: args.providerConfig.apiSource } : {},
|
|
379
473
|
...args.providerConfig.apiKey ? { KEY: args.providerConfig.apiKey } : {},
|
|
380
474
|
...args.providerConfig.apiKeyHeader ? { apiKeyHeader: args.providerConfig.apiKeyHeader } : {}
|
|
@@ -442,7 +536,8 @@ function parsePlatformChatCompletionData(raw) {
|
|
|
442
536
|
return objects.find((object) => Array.isArray(object?.choices)) ?? objects[0] ?? {};
|
|
443
537
|
}
|
|
444
538
|
function parsePlatformChatCompletionResponse(args) {
|
|
445
|
-
|
|
539
|
+
const hasCompletionsShape = Array.isArray(args.data?.choices);
|
|
540
|
+
if (!hasCompletionsShape && isResponsesEndpoint(args.providerConfig.endpoint)) {
|
|
446
541
|
const rawContent2 = extractTextFromResponseOutput(args.data);
|
|
447
542
|
const dsml = parseDsml(rawContent2);
|
|
448
543
|
const tool_calls = extractToolCallsFromResponseOutput(args.data);
|
|
@@ -464,18 +559,162 @@ function parsePlatformChatCompletionResponse(args) {
|
|
|
464
559
|
const choiceMessage = args.data?.choices?.[0]?.message ?? {};
|
|
465
560
|
const rawContent = String(choiceMessage?.content ?? "");
|
|
466
561
|
const { content, reasoning } = extractThinkContent(rawContent);
|
|
562
|
+
const rawFinishReason = args.data?.choices?.[0]?.finish_reason;
|
|
467
563
|
return {
|
|
468
564
|
content,
|
|
469
565
|
model: args.providerConfig.model,
|
|
470
566
|
provider: args.providerConfig.provider,
|
|
471
567
|
...Array.isArray(choiceMessage?.tool_calls) ? { tool_calls: choiceMessage.tool_calls } : {},
|
|
472
568
|
...reasoning ? { reasoning_content: reasoning } : typeof choiceMessage?.reasoning_content === "string" && choiceMessage.reasoning_content ? { reasoning_content: choiceMessage.reasoning_content } : {},
|
|
569
|
+
...typeof rawFinishReason === "string" && rawFinishReason.length > 0 ? { finish_reason: rawFinishReason } : {},
|
|
473
570
|
// 非流式:完整的 200 JSON body 即证明调用走完,见 AgentRuntimeResult。
|
|
474
571
|
stream_complete: true,
|
|
475
572
|
usage: args.data?.usage,
|
|
476
573
|
trace: args.trace
|
|
477
574
|
};
|
|
478
575
|
}
|
|
576
|
+
function processPlatformChatSseEvent(event, state) {
|
|
577
|
+
for (const line of event.split("\n")) {
|
|
578
|
+
const trimmed = line.trim();
|
|
579
|
+
if (!trimmed.startsWith("data:")) continue;
|
|
580
|
+
const payload = trimmed.slice(5).trim();
|
|
581
|
+
if (!payload || payload === "[DONE]") continue;
|
|
582
|
+
let parsed;
|
|
583
|
+
try {
|
|
584
|
+
parsed = JSON.parse(payload);
|
|
585
|
+
} catch {
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
588
|
+
if (parsed?.billing && typeof parsed.billing === "object") {
|
|
589
|
+
state.billing = parsed.billing;
|
|
590
|
+
}
|
|
591
|
+
const extractedUsage = extractUsageFromSsePayload(parsed);
|
|
592
|
+
if (extractedUsage) {
|
|
593
|
+
state.usage = extractedUsage;
|
|
594
|
+
} else if (parsed?.usage && typeof parsed.usage === "object" && !hasUsageTokens(parsed.usage)) {
|
|
595
|
+
state.billing = {
|
|
596
|
+
...state.billing ?? {},
|
|
597
|
+
...parsed.usage
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
if (Array.isArray(parsed?.choices)) {
|
|
601
|
+
applyChatCompletionDelta(parsed, state);
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
604
|
+
if (!state.usesResponsesApi) {
|
|
605
|
+
applyChatCompletionDelta(parsed, state);
|
|
606
|
+
continue;
|
|
607
|
+
}
|
|
608
|
+
if (!state.streamError) {
|
|
609
|
+
const responsesError = extractChatCompletionStreamError(parsed);
|
|
610
|
+
if (responsesError) state.streamError = responsesError;
|
|
611
|
+
}
|
|
612
|
+
const eventType = typeof parsed?.type === "string" ? parsed.type : "";
|
|
613
|
+
if (eventType === "response.output_text.delta" && typeof parsed?.delta === "string") {
|
|
614
|
+
const dsml = pushDsmlChunk(parsed.delta, state.dsmlToolCallState);
|
|
615
|
+
for (const [index, call] of dsml.toolCalls.entries()) {
|
|
616
|
+
const id = buildDsmlToolCallId(state.responsesToolCalls.size, index);
|
|
617
|
+
addResponsesToolCall(state.responsesToolCalls, {
|
|
618
|
+
id,
|
|
619
|
+
type: "function",
|
|
620
|
+
function: { name: call.name, arguments: call.arguments }
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
if (dsml.content) {
|
|
624
|
+
state.content += dsml.content;
|
|
625
|
+
state.onTextDelta?.(dsml.content);
|
|
626
|
+
}
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
if (eventType === "response.reasoning_text.delta" && typeof parsed?.delta === "string") {
|
|
630
|
+
state.reasoning += parsed.delta;
|
|
631
|
+
state.onReasoningDelta?.(parsed.delta);
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
634
|
+
if (eventType === "response.output_item.added" || eventType === "response.output_item.done" || eventType === "response.function_call_arguments.delta" || eventType === "response.function_call_arguments.done") {
|
|
635
|
+
applyResponsesToolEvent(state.responsesToolCalls, parsed);
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
if (eventType === "response.completed" && parsed?.response) {
|
|
639
|
+
state.completedResponsesPayload = parsed.response;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
async function readPlatformChatSseCompletion(args) {
|
|
644
|
+
const state = {
|
|
645
|
+
content: "",
|
|
646
|
+
reasoning: "",
|
|
647
|
+
usage: void 0,
|
|
648
|
+
billing: void 0,
|
|
649
|
+
usesResponsesApi: args.usesResponsesApi,
|
|
650
|
+
onTextDelta: args.onTextDelta,
|
|
651
|
+
onReasoningDelta: args.onReasoningDelta,
|
|
652
|
+
completedResponsesPayload: void 0,
|
|
653
|
+
responsesToolCalls: createResponsesToolAccumulator(),
|
|
654
|
+
dsmlToolCallState: createDsmlParserState(),
|
|
655
|
+
streamError: void 0,
|
|
656
|
+
accumulatedToolCalls: createToolCallAccumulator(),
|
|
657
|
+
thinkState: createThinkParserState(),
|
|
658
|
+
toolCallTextState: createToolCallTextParserState(),
|
|
659
|
+
finishReason: void 0
|
|
660
|
+
};
|
|
661
|
+
for await (const frame of readSseFrames(args.response)) {
|
|
662
|
+
processPlatformChatSseEvent(frame, state);
|
|
663
|
+
}
|
|
664
|
+
flushChatCompletionStream(state);
|
|
665
|
+
if (state.usesResponsesApi) {
|
|
666
|
+
const dsml = finishDsml(state.dsmlToolCallState);
|
|
667
|
+
for (const [index, call] of dsml.toolCalls.entries()) {
|
|
668
|
+
const id = buildDsmlToolCallId(state.responsesToolCalls.size, index);
|
|
669
|
+
addResponsesToolCall(state.responsesToolCalls, {
|
|
670
|
+
id,
|
|
671
|
+
type: "function",
|
|
672
|
+
function: { name: call.name, arguments: call.arguments }
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
if (dsml.content) state.content += dsml.content;
|
|
676
|
+
}
|
|
677
|
+
throwIfChatCompletionStreamFailed(state);
|
|
678
|
+
if (state.usesResponsesApi) {
|
|
679
|
+
const response = state.completedResponsesPayload;
|
|
680
|
+
const completedToolCalls = response ? extractToolCallsFromResponseOutput(response) : [];
|
|
681
|
+
const finalContent = response ? extractTextFromResponseOutput(response) : "";
|
|
682
|
+
const normalizedFinal = finalContent ? parseDsml(finalContent) : { content: "", toolCalls: [] };
|
|
683
|
+
const normalizedDsmlCalls = normalizedFinal.toolCalls.map((call, index) => ({
|
|
684
|
+
id: buildDsmlToolCallId(completedToolCalls.length, index),
|
|
685
|
+
type: "function",
|
|
686
|
+
function: { name: call.name, arguments: call.arguments }
|
|
687
|
+
}));
|
|
688
|
+
const completionsToolCalls = finalizeAccumulatedToolCalls(
|
|
689
|
+
state.accumulatedToolCalls
|
|
690
|
+
);
|
|
691
|
+
const tool_calls2 = completedToolCalls.length > 0 ? completedToolCalls : normalizedDsmlCalls.length > 0 ? normalizedDsmlCalls : completionsToolCalls.length > 0 ? completionsToolCalls : finalizeResponsesToolCalls(state.responsesToolCalls);
|
|
692
|
+
const finalUsage2 = mergeBillingIntoUsage(state.usage, state.billing);
|
|
693
|
+
return {
|
|
694
|
+
content: normalizedFinal.content || state.content,
|
|
695
|
+
...state.reasoning ? { reasoning_content: state.reasoning } : {},
|
|
696
|
+
...tool_calls2.length > 0 ? { tool_calls: tool_calls2 } : {},
|
|
697
|
+
...finalUsage2 ? { usage: finalUsage2, stream_complete: true } : {},
|
|
698
|
+
// finish_reason 供 executePlatformChatCompletion 穿透给 localLoop 的
|
|
699
|
+
// 空轮/截断判定;此前 reader 从不回传,流式路径恒缺。
|
|
700
|
+
...state.finishReason ? { finish_reason: state.finishReason } : {}
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
const tool_calls = finalizeAccumulatedToolCalls(state.accumulatedToolCalls);
|
|
704
|
+
const finalUsage = mergeBillingIntoUsage(state.usage, state.billing);
|
|
705
|
+
return {
|
|
706
|
+
content: state.content,
|
|
707
|
+
...state.reasoning ? { reasoning_content: state.reasoning } : {},
|
|
708
|
+
...tool_calls.length > 0 ? { tool_calls } : {},
|
|
709
|
+
...finalUsage ? { usage: finalUsage, stream_complete: true } : {},
|
|
710
|
+
...state.finishReason ? { finish_reason: state.finishReason } : {}
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
function mergeBillingIntoUsage(usage, billing) {
|
|
714
|
+
if (!billing) return usage;
|
|
715
|
+
if (!usage) return billing;
|
|
716
|
+
return { ...usage, ...billing };
|
|
717
|
+
}
|
|
479
718
|
function canUsePlatformChatProvider2(env) {
|
|
480
719
|
return canUsePlatformChatProvider(env);
|
|
481
720
|
}
|
|
@@ -506,11 +745,16 @@ export {
|
|
|
506
745
|
flushChatCompletionStream,
|
|
507
746
|
providerHttpFailure,
|
|
508
747
|
readSseFrames,
|
|
748
|
+
streamSseDataValues,
|
|
509
749
|
readSseDataValues,
|
|
750
|
+
createResponsesToolAccumulator,
|
|
751
|
+
applyResponsesToolEvent,
|
|
752
|
+
finalizeResponsesToolCalls,
|
|
510
753
|
resolvePlatformChatProviderConfig,
|
|
511
754
|
buildPlatformChatCompletionRequest,
|
|
512
755
|
parsePlatformChatCompletionData,
|
|
513
756
|
parsePlatformChatCompletionResponse,
|
|
757
|
+
readPlatformChatSseCompletion,
|
|
514
758
|
canUsePlatformChatProvider2 as canUsePlatformChatProvider,
|
|
515
759
|
hasDirectOpenAiCompatibleProvider2 as hasDirectOpenAiCompatibleProvider,
|
|
516
760
|
shouldUsePlatformChatProvider
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_AGENT_BASE_POLICY,
|
|
3
|
+
DEFAULT_USER_PREFERENCE_PROFILE
|
|
4
|
+
} from "./chunk-UNOTBWZZ.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
|
+
};
|