nolo-cli 0.29.2 → 0.30.0-alpha.2
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-BFVTGZXE.js → _executeModel-VBHHG7LT.js} +62 -68
- package/{action-LG32A6DJ.js → action-FENWPT3C.js} +14 -15
- package/{addContentAction-MPGMBJTQ.js → addContentAction-Z5S5ZQ7I.js} +12 -12
- package/{addDialogAgentAction-ZH23WDID.js → addDialogAgentAction-VUNVD2XR.js} +11 -11
- package/{agentDeleteCommand-4S4STG42.js → agentDeleteCommand-LLGZXUYJ.js} +60 -39
- package/{agentEmailCommands-3F4IP4DI.js → agentEmailCommands-LC2FPN6G.js} +76 -81
- package/{agentGrantCommands-JNDE4RWR.js → agentGrantCommands-E7ZZFRHK.js} +2 -1
- package/{agentListCommands-JCRV2XF6.js → agentListCommands-A6OBQ3QX.js} +57 -40
- package/{agentMachineCommands-KYXPYSFP.js → agentMachineCommands-4O4Q5B5X.js} +53 -35
- package/{agentPullCommand-ZZGU5KOY.js → agentPullCommand-4V36XNGV.js} +4 -3
- package/{agentRecordCommands-UADUPIXO.js → agentRecordCommands-W22RIQRV.js} +73 -78
- package/{agentRunCommand-MJWSR53W.js → agentRunCommand-V4OBU4FB.js} +77 -82
- package/{agentRunControl-SNUKXN6J.js → agentRunControl-AKBN2366.js} +13 -1
- package/{agentRuntimeLocal-PC5RRRPT.js → agentRuntimeLocal-I57YSGH4.js} +48 -30
- package/{agentSlice-C5OYLNBT.js → agentSlice-3ZHY7RAO.js} +12 -13
- package/{appDeleteCommands-ZXODZ5AD.js → appDeleteCommands-DJJF466K.js} +53 -35
- package/{appDeployCommands-AWC6JPZH.js → appDeployCommands-WJZGIOEZ.js} +53 -35
- package/{appDeployStatusCommands-74NXMDAI.js → appDeployStatusCommands-ICYXUJNO.js} +53 -35
- package/{appGetCommands-6YGIAP5L.js → appGetCommands-UOCWYJPV.js} +53 -35
- package/{appListCommands-DZWBHMNK.js → appListCommands-EOKWTXPW.js} +53 -35
- package/{authCommand-XMQHBK5L.js → authCommand-H5KE7K7K.js} +16 -16
- package/{authCommands-JSOG2H4E.js → authCommands-CXJ6PI2O.js} +7 -7
- package/{chunk-OEWEE4VW.js → chunk-2XM5KUNE.js} +4 -2
- package/{chunk-7H3UTGPM.js → chunk-3AUWC6EM.js} +82 -3
- package/{chunk-HEXXIS77.js → chunk-3RIWR23B.js} +1 -1
- package/{chunk-R7LOFGRE.js → chunk-446VANPP.js} +18 -14
- package/{chunk-RZNYL4LW.js → chunk-4SAV7BD7.js} +65 -1
- package/{chunk-QC6ZWDSV.js → chunk-56IUA7RU.js} +3 -3
- package/{chunk-R3JSTDQO.js → chunk-66O5MZYH.js} +1 -1
- package/{chunk-PSK2RUHV.js → chunk-7CD24PU4.js} +360 -2
- package/{chunk-G2BZ43DV.js → chunk-A4JDTA5T.js} +13 -13
- package/{chunk-DZ3XJVET.js → chunk-AOS5IN2I.js} +1 -1
- package/{chunk-SKDNBYZK.js → chunk-BOL2D2JW.js} +1 -1
- package/{chunk-YTA2QOEE.js → chunk-CAENRKNJ.js} +15 -0
- package/{chunk-2TYLTEAH.js → chunk-CV6I4HBA.js} +1 -1
- package/chunk-DCDL3GC4.js +171 -0
- package/{chunk-FVOSIYXM.js → chunk-DCWBP2O7.js} +42 -393
- package/{chunk-OLWMGSW2.js → chunk-DI6MXJK5.js} +37 -37
- package/{chunk-HRPWRVBI.js → chunk-DKRT67FG.js} +11 -11
- package/{chunk-L6RBX4L4.js → chunk-DWQNDGO7.js} +20 -8
- package/{chunk-VKBTAQWT.js → chunk-FS5TTXPS.js} +6 -6
- package/chunk-G5JHHUAK.js +73 -0
- package/{chunk-TOGGHWHI.js → chunk-G6VITLCZ.js} +3 -3
- package/{chunk-RJBTU7AS.js → chunk-GAGUBI42.js} +302 -14
- package/{chunk-NXMJ55RU.js → chunk-GVKTKT3O.js} +3 -3
- package/{chunk-5ZXNLOAG.js → chunk-HI7QZNWX.js} +17 -10
- package/{chunk-DF7SMWEV.js → chunk-HLG6GAUD.js} +1 -1
- package/{chunk-MQRZ5QUH.js → chunk-IXZX5CJK.js} +1 -1
- package/{chunk-IC7W63RM.js → chunk-IZ3CBMD5.js} +3 -3
- package/{chunk-VHBWHNVT.js → chunk-K6QEHQZ3.js} +8 -4
- package/chunk-KW47OSRJ.js +3246 -0
- package/{chunk-Q5RXHXKU.js → chunk-KWKD3BCC.js} +189 -122
- package/{chunk-L65QKSVJ.js → chunk-L3GCUVOH.js} +1 -1
- package/{chunk-4BDPDTJU.js → chunk-L3VQOVKK.js} +8 -8
- package/{chunk-HALKDXKP.js → chunk-MEUZFIAJ.js} +8 -4
- package/{chunk-H5S4XUGI.js → chunk-MMCVBEAD.js} +174 -149
- package/{chunk-XOIF2TNF.js → chunk-OB6FBSH3.js} +13 -0
- package/chunk-OYK7PA5U.js +1707 -0
- package/{chunk-6HTWA77J.js → chunk-Q24P6TUS.js} +1 -1
- package/{chunk-GMJS5AYP.js → chunk-QLV2GKU5.js} +16 -178
- package/{chunk-WMB7GVPN.js → chunk-SWOTB2TX.js} +134 -1166
- package/{chunk-GC34RRTQ.js → chunk-SWYMCHM7.js} +1 -69
- package/{chunk-BBGRJB5E.js → chunk-SZ5CBYMZ.js} +4 -4
- package/chunk-T27IEBNQ.js +149 -0
- package/{chunk-WX3ZOSTL.js → chunk-T3Y5EMJS.js} +24 -26
- package/{chunk-UFL6WHHJ.js → chunk-THTAR67C.js} +1056 -137
- package/{chunk-2FX23RGA.js → chunk-TJYWZ3LO.js} +4 -4
- package/{chunk-KEF5OBOZ.js → chunk-UKC5HU2C.js} +33 -27
- package/{chunk-HRJEPMZY.js → chunk-UTQZ73QQ.js} +2 -2
- package/{chunk-GT3GG2H7.js → chunk-VSTUQGLT.js} +1 -1
- package/{chunk-32ZM6HVI.js → chunk-W2YKDXT7.js} +95 -95
- package/{chunk-L3QFIBZG.js → chunk-WTGCTVJG.js} +1 -1
- package/{chunk-XS7UPVR7.js → chunk-XD5NQEOH.js} +5 -5
- package/{chunk-WSQLK2KR.js → chunk-XFGM5PJP.js} +6 -6
- package/{chunk-JSB4N6NU.js → chunk-YLADSPDU.js} +3 -3
- package/{chunk-FRN5QOKN.js → chunk-YWGSCF37.js} +19 -4
- package/{codingSkills-EN6Z6G6U.js → codingSkills-V35TRR4Y.js} +1 -2
- package/{createAgentAutomationAction-BK4UZJKU.js → createAgentAutomationAction-3GMH6ORX.js} +30 -37
- package/{createDialogAction-MJJUI2MK.js → createDialogAction-R5MCL4RE.js} +32 -38
- package/{createPageAction-YMZ7K363.js → createPageAction-QYTG656R.js} +43 -50
- package/{dbSlice-6QJYQUBV.js → dbSlice-OBV7VFCF.js} +11 -11
- package/{deleteFile-WDZ3VM7B.js → deleteFile-AC45HYSM.js} +5 -5
- package/{dialogCommands-OKH45ASS.js → dialogCommands-NUQGIXVZ.js} +53 -37
- package/{dialogSlice-UDOKNDHB.js → dialogSlice-CFDECXEU.js} +27 -34
- package/{docCreateCommands-MCLMR4TE.js → docCreateCommands-UNFCXB5N.js} +52 -36
- package/{docDeleteCommands-ONDHI7JV.js → docDeleteCommands-NG5IVKE5.js} +54 -38
- package/{docReadCommands-FCXBMISW.js → docReadCommands-6J7MUUX6.js} +52 -36
- package/{docStore-N66O4CGH.js → docStore-MZZWJM4F.js} +28 -35
- package/{docUpdateCommands-T3XN6XOX.js → docUpdateCommands-6AW3VZOX.js} +55 -39
- package/{fetchMessages-W4IKHPCS.js → fetchMessages-VPPQDDZ4.js} +3 -3
- package/{getPricing-X6I23RN6.js → getPricing-XQYSSVV6.js} +6 -7
- package/{handleSendMessageAction-KC4AYUZP.js → handleSendMessageAction-IU2QNTLM.js} +30 -37
- package/index.js +72 -72
- package/{localDialogRead-UFLBS6OT.js → localDialogRead-P72W2U2R.js} +1 -1
- package/{machineCommands-DIMRFA3Y.js → machineCommands-Z2QEWTHZ.js} +76 -81
- package/{machineWsRunDispatch-2DYJZI6Z.js → machineWsRunDispatch-SJTYHZHN.js} +71 -76
- package/{models-YT32CTT5.js → models-WDUTTYFS.js} +2 -2
- package/{offlineMarxistsAgentCommand-5OOWZLJI.js → offlineMarxistsAgentCommand-E6LUG63A.js} +6 -2
- package/package.json +1 -1
- package/{read-C7Y6LSBM.js → read-QK7ZRX6G.js} +6 -6
- package/{readDocTool-TOHRYJHP.js → readDocTool-EYDMVRBL.js} +2 -1
- package/{readlineWorkspace-HUPHMLDG.js → readlineWorkspace-BGKPABK4.js} +208 -183
- package/{removeDialogAgentAction-WZXPOH5S.js → removeDialogAgentAction-TBW3UZJW.js} +15 -16
- package/{runAgentClientLoop-5TGSUKHV.js → runAgentClientLoop-N3YDLTMS.js} +61 -66
- package/{setDialogExtraReferencesAction-INZY2ENI.js → setDialogExtraReferencesAction-Q3ANF2NR.js} +12 -12
- package/{setPrimaryDialogAgentAction-WCVLPYCF.js → setPrimaryDialogAgentAction-FQ5R3EFJ.js} +15 -16
- package/{settingSlice-IDUM4LWU.js → settingSlice-JKKV2T7O.js} +13 -14
- package/{skillDiscovery-ITA7BI7A.js → skillDiscovery-I3QRA7NE.js} +2 -2
- package/{spaceCommands-XSSDB3YK.js → spaceCommands-R6AEQNLG.js} +57 -40
- package/{spaceSlice-BXDCO6PT.js → spaceSlice-MCH7RLLP.js} +27 -34
- package/{streamAgentChatTurn-HRFMVSVC.js → streamAgentChatTurn-Q4U2CVMI.js} +130 -1300
- package/{switchDialogAgentAction-YBFFCBOD.js → switchDialogAgentAction-QQGVE4SL.js} +11 -11
- package/{toolApiClient-WVTUYOFM.js → toolApiClient-ARGFDJAG.js} +2 -2
- package/{tools-5V6FHWQU.js → tools-Y3UBLLYW.js} +50 -56
- package/{tuiSummaryLlmCaller-GCUPULOV.js → tuiSummaryLlmCaller-4474IBTI.js} +12 -12
- package/{updateDialogTitleAction-W62C4W4K.js → updateDialogTitleAction-3J7GH67I.js} +35 -43
- package/chunk-5CS33IBL.js +0 -301
- package/chunk-5MMAK75Q.js +0 -15
- package/chunk-HYSJHRWD.js +0 -669
- package/chunk-MRC4Q34M.js +0 -188
- package/chunk-SIZQB7BD.js +0 -91
- package/chunk-UEOPA6MV.js +0 -641
- package/chunk-VIDPVFP3.js +0 -20
- package/chunk-W2LZV5GE.js +0 -231
- package/chunk-Y5GCAMGP.js +0 -9
- package/chunk-YYLHWIW6.js +0 -48
- package/chunk-Z54ZAZZC.js +0 -1791
- package/chunk-ZZ2MH7LE.js +0 -84
- package/{chunk-OMP5L5NF.js → chunk-44HACRCK.js} +3 -3
- package/{chunk-ZVZMT3EA.js → chunk-KWCLUYGQ.js} +3 -3
- package/{chunk-NRY4GCKJ.js → chunk-WHLVPK32.js} +3 -3
- package/{chunk-RQSOAMPJ.js → chunk-Z5MXSEOJ.js} +2 -2
- package/{chunk-XMLRJUU5.js → chunk-ZFTCLBEX.js} +9 -9
- package/{runtimeDoctorCommands-HSU632DY.js → runtimeDoctorCommands-E2OUORHK.js} +3 -3
- package/{tableCommands-QSZILI7I.js → tableCommands-PRJNWN6Q.js} +6 -6
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
toErrorMessage
|
|
3
|
-
} from "./chunk-HNMXYYJR.js";
|
|
4
|
-
|
|
5
1
|
// packages/create/editor/transforms/slateToSimplifiedMarkdown.ts
|
|
6
2
|
function renderTextNode(node) {
|
|
7
3
|
if (!node || typeof node.text !== "string") return "";
|
|
@@ -152,70 +148,6 @@ function slateToSimplifiedMarkdown(nodes, options = {}) {
|
|
|
152
148
|
return nodes.map((node) => renderNode(node, 0, options)).join("").trim() + "\n";
|
|
153
149
|
}
|
|
154
150
|
|
|
155
|
-
// packages/ai/tools/readDocTool.ts
|
|
156
|
-
var readDocFunctionSchema = {
|
|
157
|
-
name: "readDoc",
|
|
158
|
-
description: [
|
|
159
|
-
"\u8BFB\u53D6\u6307\u5B9A\u9875\u9762\u7684\u5185\u5BB9\uFF0C\u5E76\u5C06\u7ED3\u6784\u5316\u7684\u6570\u636E\u8F6C\u6362\u4E3A Markdown \u683C\u5F0F\u8FD4\u56DE\u3002",
|
|
160
|
-
"\u5982\u679C\u4F60\u62FF\u5230\u4E86\u9875\u9762\u7684 dbKey\uFF08\u5982 page-xxx\uFF09\uFF0C\u8BF7\u4F7F\u7528\u6B64\u5DE5\u5177\u67E5\u770B\u9875\u9762\u5185\u5BB9\u3002"
|
|
161
|
-
].join("\n"),
|
|
162
|
-
parameters: {
|
|
163
|
-
type: "object",
|
|
164
|
-
properties: {
|
|
165
|
-
id: {
|
|
166
|
-
type: "string",
|
|
167
|
-
description: "\u9875\u9762/\u6587\u6863\u7684\u6570\u636E\u5E93\u952E\uFF08dbKey\uFF09\uFF0C\u4F8B\u5982 page-xxx\u3002"
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
required: ["id"]
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
var readPageFunctionSchema = {
|
|
174
|
-
...readDocFunctionSchema,
|
|
175
|
-
name: "readPage"
|
|
176
|
-
};
|
|
177
|
-
var buildReadDocResult = (pageData) => {
|
|
178
|
-
const markdownContent = slateToSimplifiedMarkdown(pageData.slateData || []);
|
|
179
|
-
const rawData = {
|
|
180
|
-
success: true,
|
|
181
|
-
id: pageData.dbKey,
|
|
182
|
-
title: pageData.title,
|
|
183
|
-
content: markdownContent,
|
|
184
|
-
metadata: {
|
|
185
|
-
spaceId: pageData.spaceId,
|
|
186
|
-
created: pageData.created
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
const displayData = `\u5DF2\u6210\u529F\u8BFB\u53D6\u9875\u9762\u300A${pageData.title}\u300B\u3002
|
|
190
|
-
|
|
191
|
-
\u5185\u5BB9\u5982\u4E0B\uFF1A
|
|
192
|
-
|
|
193
|
-
${markdownContent}`;
|
|
194
|
-
return { rawData, displayData };
|
|
195
|
-
};
|
|
196
|
-
async function readDocFunc(args, thunkApi) {
|
|
197
|
-
const id = args.id ?? args.doc ?? args.docKey ?? args.pageKey ?? args.key;
|
|
198
|
-
if (!id || !id.toLowerCase().startsWith("page-")) {
|
|
199
|
-
throw new Error(`\u65E0\u6548\u7684\u9875\u9762 ID: ${id}\u3002\u9875\u9762 ID \u901A\u5E38\u4EE5 "page-" \u5F00\u5934\u3002`);
|
|
200
|
-
}
|
|
201
|
-
try {
|
|
202
|
-
const { readAction } = await import("./read-C7Y6LSBM.js");
|
|
203
|
-
const pageData = await readAction({ dbKey: id }, thunkApi);
|
|
204
|
-
if (!pageData) {
|
|
205
|
-
throw new Error(`\u672A\u627E\u5230 ID \u4E3A ${id} \u7684\u9875\u9762\u3002`);
|
|
206
|
-
}
|
|
207
|
-
return buildReadDocResult(pageData);
|
|
208
|
-
} catch (error) {
|
|
209
|
-
throw new Error(`\u8BFB\u53D6\u9875\u9762\u65F6\u51FA\u9519: ${toErrorMessage(error)}`);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
var readPageFunc = readDocFunc;
|
|
213
|
-
|
|
214
151
|
export {
|
|
215
|
-
slateToSimplifiedMarkdown
|
|
216
|
-
readDocFunctionSchema,
|
|
217
|
-
readPageFunctionSchema,
|
|
218
|
-
buildReadDocResult,
|
|
219
|
-
readDocFunc,
|
|
220
|
-
readPageFunc
|
|
152
|
+
slateToSimplifiedMarkdown
|
|
221
153
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
readDbRecord,
|
|
3
3
|
writeAgentRecord
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-56IUA7RU.js";
|
|
5
|
+
import {
|
|
6
|
+
createSpaceKey
|
|
7
|
+
} from "./chunk-YLADSPDU.js";
|
|
5
8
|
import {
|
|
6
9
|
buildSkillSummaryMarker
|
|
7
10
|
} from "./chunk-VF4K2QE6.js";
|
|
@@ -11,9 +14,6 @@ import {
|
|
|
11
14
|
resolveAuthToken,
|
|
12
15
|
resolveServerUrl
|
|
13
16
|
} from "./chunk-A7GB5UGH.js";
|
|
14
|
-
import {
|
|
15
|
-
createSpaceKey
|
|
16
|
-
} from "./chunk-JSB4N6NU.js";
|
|
17
17
|
import {
|
|
18
18
|
asTrimmedLowercaseString
|
|
19
19
|
} from "./chunk-QSJ3HFEF.js";
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// packages/agent-runtime/declaredToolNames.ts
|
|
2
|
+
function extractDeclaredToolNames(tools) {
|
|
3
|
+
if (!Array.isArray(tools)) return void 0;
|
|
4
|
+
const names = /* @__PURE__ */ new Set();
|
|
5
|
+
for (const t of tools) {
|
|
6
|
+
const fn = t?.function;
|
|
7
|
+
if (fn && typeof fn.name === "string" && fn.name) names.add(fn.name);
|
|
8
|
+
}
|
|
9
|
+
return names;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// packages/agent-runtime/outboundHistorySanitize.ts
|
|
13
|
+
function sanitizeForOutbound(messages, tools) {
|
|
14
|
+
return sanitizeOutboundHistory(messages, {
|
|
15
|
+
declaredToolNames: extractDeclaredToolNames(tools)
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function stableToolCallId(assistantIndex, callIndex) {
|
|
19
|
+
return `call_sanitize_${assistantIndex}_${callIndex}`;
|
|
20
|
+
}
|
|
21
|
+
function isString(v) {
|
|
22
|
+
return typeof v === "string";
|
|
23
|
+
}
|
|
24
|
+
function isNonEmptyString(v) {
|
|
25
|
+
return typeof v === "string" && v.length > 0;
|
|
26
|
+
}
|
|
27
|
+
function joinLines(...parts) {
|
|
28
|
+
return parts.filter(isNonEmptyString).join("\n");
|
|
29
|
+
}
|
|
30
|
+
function jsonStringifyArguments(args) {
|
|
31
|
+
if (typeof args === "string") return args;
|
|
32
|
+
try {
|
|
33
|
+
return JSON.stringify(args ?? "");
|
|
34
|
+
} catch {
|
|
35
|
+
return "";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function renderToolCallAsText(call) {
|
|
39
|
+
const name = call?.function?.name ?? "unknown";
|
|
40
|
+
const rawArgs = call?.function?.arguments;
|
|
41
|
+
const args = jsonStringifyArguments(rawArgs);
|
|
42
|
+
return `[tool_call: ${name}(${args})]`;
|
|
43
|
+
}
|
|
44
|
+
function renderToolResultAsText(message) {
|
|
45
|
+
const name = isNonEmptyString(message.toolName) ? message.toolName : "tool";
|
|
46
|
+
const body = typeof message.content === "string" ? message.content : "";
|
|
47
|
+
return `[tool_result: ${name}: ${body}]`;
|
|
48
|
+
}
|
|
49
|
+
function normalizeToolCall(call, assistantIndex, callIndex) {
|
|
50
|
+
if (!call || typeof call !== "object") return null;
|
|
51
|
+
const c = call;
|
|
52
|
+
const fn = c.function;
|
|
53
|
+
if (!fn || typeof fn !== "object" || !isString(fn.name)) return null;
|
|
54
|
+
const id = isNonEmptyString(c.id) ? c.id : stableToolCallId(assistantIndex, callIndex);
|
|
55
|
+
return {
|
|
56
|
+
id,
|
|
57
|
+
type: isString(c.type) && c.type ? c.type : "function",
|
|
58
|
+
function: { name: fn.name, arguments: jsonStringifyArguments(fn.arguments) },
|
|
59
|
+
...typeof c.thought_signature === "string" ? { thought_signature: c.thought_signature } : {}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function sanitizeOutboundHistory(messages, options) {
|
|
63
|
+
if (!Array.isArray(messages) || messages.length === 0) return messages;
|
|
64
|
+
const declared = options?.declaredToolNames;
|
|
65
|
+
const candidateCallIds = /* @__PURE__ */ new Set();
|
|
66
|
+
for (let i = 0; i < messages.length; i++) {
|
|
67
|
+
const m = messages[i];
|
|
68
|
+
if (m.role !== "assistant" || !Array.isArray(m.tool_calls)) continue;
|
|
69
|
+
m.tool_calls.forEach((call, callIndex) => {
|
|
70
|
+
const name = call?.function?.name;
|
|
71
|
+
const declaredAllows = !declared || isString(name) && declared.has(name);
|
|
72
|
+
if (!declaredAllows) return;
|
|
73
|
+
const id = isNonEmptyString(call?.id) ? call.id : stableToolCallId(i, callIndex);
|
|
74
|
+
candidateCallIds.add(id);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const resultIds = /* @__PURE__ */ new Set();
|
|
78
|
+
for (const m of messages) {
|
|
79
|
+
if (m.role === "tool" && isNonEmptyString(m.tool_call_id)) {
|
|
80
|
+
resultIds.add(m.tool_call_id);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const keepCallIds = /* @__PURE__ */ new Set();
|
|
84
|
+
for (const id of candidateCallIds) {
|
|
85
|
+
if (resultIds.has(id)) keepCallIds.add(id);
|
|
86
|
+
}
|
|
87
|
+
const out = [];
|
|
88
|
+
for (let i = 0; i < messages.length; i++) {
|
|
89
|
+
const m = messages[i];
|
|
90
|
+
if (m.role === "assistant") {
|
|
91
|
+
let toolCalls;
|
|
92
|
+
const downgradedLines = [];
|
|
93
|
+
if (Array.isArray(m.tool_calls) && m.tool_calls.length > 0) {
|
|
94
|
+
const kept = [];
|
|
95
|
+
m.tool_calls.forEach((call, callIndex) => {
|
|
96
|
+
const name = call?.function?.name;
|
|
97
|
+
const declaredAllows = !declared || isString(name) && declared.has(name);
|
|
98
|
+
const id = isNonEmptyString(call?.id) ? call.id : stableToolCallId(i, callIndex);
|
|
99
|
+
const keepStructural = declaredAllows && keepCallIds.has(id);
|
|
100
|
+
if (keepStructural) {
|
|
101
|
+
const normalized = normalizeToolCall(call, i, callIndex);
|
|
102
|
+
if (normalized) kept.push(normalized);
|
|
103
|
+
} else {
|
|
104
|
+
downgradedLines.push(renderToolCallAsText(call));
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
toolCalls = kept.length > 0 ? kept : void 0;
|
|
108
|
+
}
|
|
109
|
+
const downgradedText = joinLines(...downgradedLines);
|
|
110
|
+
const contentWithDowngrade = downgradedText.length > 0 ? combineContentWithText(m.content, downgradedText) : m.content;
|
|
111
|
+
const sanitizedAssistant = {
|
|
112
|
+
...m,
|
|
113
|
+
content: contentWithDowngrade,
|
|
114
|
+
tool_calls: toolCalls
|
|
115
|
+
};
|
|
116
|
+
if (!toolCalls) delete sanitizedAssistant.tool_calls;
|
|
117
|
+
out.push(sanitizedAssistant);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (m.role === "tool") {
|
|
121
|
+
const id = isNonEmptyString(m.tool_call_id) ? m.tool_call_id : "";
|
|
122
|
+
if (id && keepCallIds.has(id)) {
|
|
123
|
+
out.push({ ...m, content: m.content ?? "", tool_call_id: id });
|
|
124
|
+
} else {
|
|
125
|
+
out.push({
|
|
126
|
+
role: "assistant",
|
|
127
|
+
content: renderToolResultAsText(m)
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
out.push({ ...m });
|
|
133
|
+
}
|
|
134
|
+
return out;
|
|
135
|
+
}
|
|
136
|
+
function combineContentWithText(base, extra) {
|
|
137
|
+
if (typeof base === "string") {
|
|
138
|
+
return base ? `${base}
|
|
139
|
+
${extra}` : extra;
|
|
140
|
+
}
|
|
141
|
+
if (Array.isArray(base)) {
|
|
142
|
+
return [...base, { type: "text", text: extra }];
|
|
143
|
+
}
|
|
144
|
+
return extra;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export {
|
|
148
|
+
sanitizeForOutbound
|
|
149
|
+
};
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
getAntigravityUserAgent,
|
|
12
12
|
normalizeAntigravityTokenPayload,
|
|
13
13
|
refreshAntigravityToken
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-TJYWZ3LO.js";
|
|
15
15
|
import {
|
|
16
16
|
writeOAuthCredential
|
|
17
17
|
} from "./chunk-JZPBVBIY.js";
|
|
@@ -142,27 +142,6 @@ async function startCallbackServer(options) {
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
// packages/cli/oauth/pkce.ts
|
|
146
|
-
import { createHash, randomBytes } from "node:crypto";
|
|
147
|
-
var PKCE_VERIFIER_LENGTH = 64;
|
|
148
|
-
function generatePkceVerifier(length = PKCE_VERIFIER_LENGTH) {
|
|
149
|
-
if (length < 43 || length > 128) {
|
|
150
|
-
throw new Error("PKCE verifier length must be between 43 and 128 characters.");
|
|
151
|
-
}
|
|
152
|
-
return randomBytes(length).toString("base64url").slice(0, length);
|
|
153
|
-
}
|
|
154
|
-
function computePkceChallenge(verifier) {
|
|
155
|
-
return createHash("sha256").update(verifier).digest("base64url");
|
|
156
|
-
}
|
|
157
|
-
function generatePkcePair(length = PKCE_VERIFIER_LENGTH) {
|
|
158
|
-
const verifier = generatePkceVerifier(length);
|
|
159
|
-
return {
|
|
160
|
-
verifier,
|
|
161
|
-
challenge: computePkceChallenge(verifier),
|
|
162
|
-
method: "S256"
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
145
|
// packages/cli/oauth/flows/antigravity.ts
|
|
167
146
|
var TIER_LEGACY = "legacy-tier";
|
|
168
147
|
var PROJECT_ONBOARD_MAX_ATTEMPTS = 5;
|
|
@@ -312,7 +291,6 @@ async function runAntigravityOAuthLogin(deps = {}) {
|
|
|
312
291
|
}
|
|
313
292
|
try {
|
|
314
293
|
const state = generateState();
|
|
315
|
-
const pkce = await generatePkcePair();
|
|
316
294
|
const authParams = new URLSearchParams({
|
|
317
295
|
client_id: ANTIGRAVITY_CLIENT_ID,
|
|
318
296
|
response_type: "code",
|
|
@@ -345,8 +323,7 @@ async function runAntigravityOAuthLogin(deps = {}) {
|
|
|
345
323
|
client_secret: ANTIGRAVITY_CLIENT_SECRET,
|
|
346
324
|
code: callback.code,
|
|
347
325
|
grant_type: "authorization_code",
|
|
348
|
-
redirect_uri: redirectUri
|
|
349
|
-
code_verifier: pkce.verifier
|
|
326
|
+
redirect_uri: redirectUri
|
|
350
327
|
})
|
|
351
328
|
});
|
|
352
329
|
if (!tokenResponse.ok) {
|
|
@@ -506,6 +483,27 @@ async function refreshOpenAiCodexToken(credential, deps = {}) {
|
|
|
506
483
|
});
|
|
507
484
|
}
|
|
508
485
|
|
|
486
|
+
// packages/cli/oauth/pkce.ts
|
|
487
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
488
|
+
var PKCE_VERIFIER_LENGTH = 64;
|
|
489
|
+
function generatePkceVerifier(length = PKCE_VERIFIER_LENGTH) {
|
|
490
|
+
if (length < 43 || length > 128) {
|
|
491
|
+
throw new Error("PKCE verifier length must be between 43 and 128 characters.");
|
|
492
|
+
}
|
|
493
|
+
return randomBytes(length).toString("base64url").slice(0, length);
|
|
494
|
+
}
|
|
495
|
+
function computePkceChallenge(verifier) {
|
|
496
|
+
return createHash("sha256").update(verifier).digest("base64url");
|
|
497
|
+
}
|
|
498
|
+
function generatePkcePair(length = PKCE_VERIFIER_LENGTH) {
|
|
499
|
+
const verifier = generatePkceVerifier(length);
|
|
500
|
+
return {
|
|
501
|
+
verifier,
|
|
502
|
+
challenge: computePkceChallenge(verifier),
|
|
503
|
+
method: "S256"
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
|
|
509
507
|
// packages/cli/oauth/flows/openai-codex.ts
|
|
510
508
|
var AUTHORIZATION_CODE_GRANT_TYPE = "authorization_code";
|
|
511
509
|
var DEVICE_CODE_DEFAULT_INTERVAL_MS = 5e3;
|
|
@@ -1116,9 +1114,9 @@ var cursorRefresh = refreshCursorToken;
|
|
|
1116
1114
|
|
|
1117
1115
|
export {
|
|
1118
1116
|
startCallbackServer,
|
|
1119
|
-
generatePkcePair,
|
|
1120
1117
|
runAntigravityOAuthLogin,
|
|
1121
1118
|
refreshAntigravityOAuthToken,
|
|
1119
|
+
generatePkcePair,
|
|
1122
1120
|
runOpenAiCodexDeviceCode,
|
|
1123
1121
|
runOpenAiCodexBrowserPkce,
|
|
1124
1122
|
refreshOpenAiCodexToken2 as refreshOpenAiCodexToken,
|