nolo-cli 0.8.0-alpha.7 → 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-XIGO7HW5.js → _executeModel-UD44KGZ4.js} +33 -28
- package/{action-PAXRPJJF.js → action-ZJWE3Y5S.js} +5 -4
- package/{addContentAction-CZVWF3QZ.js → addContentAction-TVDBNJM5.js} +4 -3
- package/{addDialogAgentAction-CCIDTPHC.js → addDialogAgentAction-EKH774VT.js} +3 -2
- package/{agentDeleteCommand-47B24JYG.js → agentDeleteCommand-TCPEFJTF.js} +15 -11
- package/{agentEmailCommands-D4FC6OZJ.js → agentEmailCommands-CZ3UILZ4.js} +36 -31
- package/{agentListCommands-UFET7CC4.js → agentListCommands-SJKO2FFB.js} +16 -12
- package/{agentMachineCommands-LH7QDQPP.js → agentMachineCommands-PSNABISZ.js} +15 -11
- package/{agentRecordCommands-CWS2B5IA.js → agentRecordCommands-MH2JKFHS.js} +36 -31
- package/{agentRunCommand-3FRPISLG.js → agentRunCommand-4KH6MIZR.js} +42 -34
- package/{agentRuntimeLocal-JNQQC2WG.js → agentRuntimeLocal-SKHJUWSS.js} +20 -15
- package/{agentSlice-XDFSELFJ.js → agentSlice-3WXXN4VK.js} +5 -4
- package/{authCommand-WXMD3IPR.js → authCommand-PXFX6JDT.js} +8 -1
- package/{authCommands-X74AFDTC.js → authCommands-356AYWEK.js} +10 -1
- package/{chunk-E5HMHIKL.js → chunk-2K2ECKSG.js} +4 -4
- package/{chunk-364VYAX2.js → chunk-2PUGVR6E.js} +1 -1
- package/chunk-3TZDXYSF.js +71 -0
- package/{chunk-YIJFUVKA.js → chunk-3WYQEUBI.js} +1 -1
- package/{chunk-543C7RDK.js → chunk-4K2KKCSD.js} +23 -8
- package/chunk-4ZDM73SD.js +34 -0
- package/{chunk-TDIQFT2F.js → chunk-5CS33IBL.js} +1 -1
- package/chunk-5KLGBAAR.js +386 -0
- package/{chunk-YD43KPCK.js → chunk-5PJ3VWCS.js} +3 -3
- package/{chunk-IAXBCTTE.js → chunk-63SLEOLK.js} +2 -2
- package/{chunk-BSTNFPHD.js → chunk-6GANEXVO.js} +1 -1
- package/{chunk-6PWWWMI7.js → chunk-7OOXPE3N.js} +2 -2
- package/{chunk-KK6SWS5B.js → chunk-7QRKCBOP.js} +5 -5
- package/{chunk-LM25IZBJ.js → chunk-AUQ747NZ.js} +2 -2
- package/{chunk-572EKYLF.js → chunk-BBYVOSU2.js} +1 -1
- package/{chunk-2MALU52L.js → chunk-C3RUNRHT.js} +1 -1
- package/{chunk-G5H7RNFL.js → chunk-COMXDWNM.js} +2 -2
- package/{chunk-2LMT6K6N.js → chunk-CPB2YM4D.js} +2 -2
- package/{chunk-USZMK5UT.js → chunk-DCOA4QSN.js} +1 -1
- package/{chunk-OF5H3QWS.js → chunk-EXTIQUCI.js} +182 -0
- package/{chunk-B76D3JJK.js → chunk-G43KEVSC.js} +4 -4
- package/{chunk-USZDUWOV.js → chunk-GG4AJPSR.js} +2 -2
- package/chunk-I42VC5KR.js +15 -0
- package/{chunk-BR2WP3DF.js → chunk-IWX4UW2E.js} +9 -9
- package/chunk-JEXVIMYZ.js +55 -0
- package/{chunk-XDVAYP26.js → chunk-JRKKFRAV.js} +1 -1
- package/{chunk-DA2OEKS6.js → chunk-KKY4B2Q2.js} +2 -8
- package/{chunk-A3X4Y7MO.js → chunk-KOCA5FCS.js} +482 -26
- package/{chunk-IYQV26RA.js → chunk-KTVVPRJS.js} +2 -2
- package/{chunk-V2F4OGYM.js → chunk-LARL2V6G.js} +22 -18
- package/{chunk-H2RMRZJE.js → chunk-MGOJ5R6J.js} +1 -1
- package/{chunk-UVPF33PW.js → chunk-MKMWT7SA.js} +63 -19862
- package/chunk-OPZYGHUC.js +89 -0
- package/chunk-PAKN26FP.js +239 -0
- package/{chunk-OVGXXUVI.js → chunk-PCWC3JTN.js} +2 -2
- package/{chunk-AR7ZSGDI.js → chunk-PG5PNA7Y.js} +16 -6
- package/{chunk-HEIIIZBX.js → chunk-Q2YZULBH.js} +1 -1
- package/{chunk-2JHWPW5B.js → chunk-SBR32ZZS.js} +77 -303
- package/{chunk-PN7AFLOK.js → chunk-SH2CFQOH.js} +3 -13
- package/{chunk-CM54RSSA.js → chunk-SL35K7AH.js} +21 -1
- package/{chunk-VEJLAVTC.js → chunk-TSS3XJY4.js} +4 -4
- package/{chunk-IECI4YHR.js → chunk-UUJDGGAK.js} +3 -3
- package/{chunk-GEKCOPTN.js → chunk-WKM6FH35.js} +1 -1
- package/{chunk-SL3EPWB4.js → chunk-XE635NI4.js} +21 -22
- package/{chunk-NE3E3XJ2.js → chunk-XS466O7S.js} +96 -99
- package/{chunk-5XH3NZ4T.js → chunk-YBWOP46I.js} +20 -379
- package/{chunk-VQ2AJRGD.js → chunk-YPRZSPF3.js} +1 -1
- package/{chunk-AUGHVUFE.js → chunk-YYUCRDOK.js} +1 -1
- package/{chunk-KTI2WDDG.js → chunk-ZIG5LJ7X.js} +357 -266
- package/{chunk-NXZGF7F7.js → chunk-ZQ2UM4KG.js} +1 -1
- package/{createAgentAutomationAction-3QTGNYJC.js → createAgentAutomationAction-63OIP6X5.js} +15 -13
- package/{createDialogAction-5YX3ARBK.js → createDialogAction-ZLYZDYBB.js} +18 -16
- package/{createPageAction-EQNQQRCW.js → createPageAction-AL5FSDCK.js} +16 -14
- package/{dbSlice-C4UJLRZP.js → dbSlice-PR44QPXY.js} +3 -2
- package/{dialogCommands-AOQS23FV.js → dialogCommands-F6YI5742.js} +17 -13
- package/{dialogSlice-GZE3NCMC.js → dialogSlice-JSBNZRLR.js} +15 -13
- package/{docCreateCommands-GVOQVJON.js → docCreateCommands-4CTO7ERT.js} +16 -12
- package/{docDeleteCommands-GEB7YAUZ.js → docDeleteCommands-VBWERDRG.js} +17 -13
- package/{docReadCommands-XYKI2DF2.js → docReadCommands-KNP4MFYB.js} +16 -12
- package/{docStore-MLM5AME5.js → docStore-ADP5VYY4.js} +16 -14
- package/{docUpdateCommands-4L3RAMHZ.js → docUpdateCommands-4BCBJQHA.js} +16 -12
- package/{fetchMessages-JOCYIFKL.js → fetchMessages-U6ZHN56A.js} +3 -2
- package/{getPricing-PWPJ6MNV.js → getPricing-3E6UNPKL.js} +3 -3
- package/{handleSendMessageAction-WG2GKTGZ.js → handleSendMessageAction-IJDQ6ARA.js} +15 -13
- package/index.js +60 -56
- package/lib-FYYBQIXS.js +19839 -0
- package/{localDialogRead-D3BELSTF.js → localDialogRead-Z5UTAJPU.js} +1 -1
- package/{machineCommands-ZNXKLH6Q.js → machineCommands-EA3M4XTN.js} +38 -33
- package/{machineWsRunDispatch-7WRG6HNV.js → machineWsRunDispatch-NAPKE5ZA.js} +34 -29
- package/{models-XLEOET3E.js → models-4OPOOLFS.js} +2 -2
- package/package.json +1 -1
- package/{readlineWorkspace-AQURUDN4.js → readlineWorkspace-KMWT4T4S.js} +196 -44
- package/{removeDialogAgentAction-CXLST3N6.js → removeDialogAgentAction-GJQJNDW6.js} +5 -4
- package/{runAgentClientLoop-VQUEKGA5.js → runAgentClientLoop-U5Q6NDTJ.js} +28 -25
- package/{setDialogExtraReferencesAction-LP6VYGU7.js → setDialogExtraReferencesAction-M7OQG54N.js} +3 -2
- package/{setPrimaryDialogAgentAction-D3GGH23T.js → setPrimaryDialogAgentAction-46UNFJDL.js} +5 -4
- package/{settingSlice-J4I3Z5H7.js → settingSlice-FVUUH4JA.js} +4 -3
- package/{spaceCommands-R2RXD5UY.js → spaceCommands-E2CFRPZJ.js} +15 -11
- package/{spaceSlice-5UT4JNIN.js → spaceSlice-L3R6IMXE.js} +15 -13
- package/{streamAgentChatTurn-NRWSQKFN.js → streamAgentChatTurn-UBDAOQWE.js} +60 -35
- package/{tableCommands-66XEWHAK.js → tableCommands-GOFP7QKA.js} +1 -1
- package/{tools-TNMUDDRK.js → tools-TMJXZTCA.js} +22 -20
- package/tuiSummaryLlmCaller-RV3THLZF.js +78 -0
- package/{understanding-HCSFPE7R.js → understanding-GQKNDDWM.js} +7 -54
- package/{updateDialogTitleAction-IXOKAVX3.js → updateDialogTitleAction-ZTWRDXI2.js} +17 -14
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveMachineId
|
|
3
|
+
} from "./chunk-6HYVJV7B.js";
|
|
1
4
|
import {
|
|
2
5
|
buildCliRuntimeEnv,
|
|
3
6
|
clearProfileAuthToken,
|
|
@@ -12,6 +15,21 @@ import {
|
|
|
12
15
|
import {
|
|
13
16
|
DEFAULT_NOLO_SERVER_URL
|
|
14
17
|
} from "./chunk-OLZBQWZU.js";
|
|
18
|
+
import {
|
|
19
|
+
getDefaultCliLocalRuntimeDb
|
|
20
|
+
} from "./chunk-H33743XH.js";
|
|
21
|
+
import {
|
|
22
|
+
createMemoryKey,
|
|
23
|
+
createMemoryOwnerIndexKey,
|
|
24
|
+
createMemorySubjectKindIndexKey,
|
|
25
|
+
memoryOwnerRange
|
|
26
|
+
} from "./chunk-SH2CFQOH.js";
|
|
27
|
+
import {
|
|
28
|
+
asTrimmedNonEmptyStringArray
|
|
29
|
+
} from "./chunk-I42VC5KR.js";
|
|
30
|
+
import {
|
|
31
|
+
asTrimmedString
|
|
32
|
+
} from "./chunk-3EUW3WEO.js";
|
|
15
33
|
import {
|
|
16
34
|
normalizeServerOrigin
|
|
17
35
|
} from "./chunk-CF7PE763.js";
|
|
@@ -20,6 +38,151 @@ import {
|
|
|
20
38
|
import { createInterface } from "node:readline/promises";
|
|
21
39
|
import { stdin as input, stdout as output } from "node:process";
|
|
22
40
|
import { spawn } from "node:child_process";
|
|
41
|
+
|
|
42
|
+
// packages/ai/memory/delete.ts
|
|
43
|
+
var normalizeSet = (values) => {
|
|
44
|
+
if (!Array.isArray(values) || values.length === 0) return null;
|
|
45
|
+
const normalized = asTrimmedNonEmptyStringArray(values);
|
|
46
|
+
return normalized.length > 0 ? new Set(normalized) : null;
|
|
47
|
+
};
|
|
48
|
+
var matchesFilters = (item, filters) => {
|
|
49
|
+
const idSet = normalizeSet(filters.ids);
|
|
50
|
+
if (idSet && !idSet.has(item.id)) return false;
|
|
51
|
+
const kindSet = normalizeSet(filters.kinds);
|
|
52
|
+
if (kindSet && !kindSet.has(item.kind)) return false;
|
|
53
|
+
const facetSet = normalizeSet(filters.facets);
|
|
54
|
+
if (facetSet && (!item.facet || !facetSet.has(item.facet))) return false;
|
|
55
|
+
if (filters.subjectType && item.subjectType !== filters.subjectType) return false;
|
|
56
|
+
if (filters.subjectId && item.subjectId !== filters.subjectId) return false;
|
|
57
|
+
const prefix = asTrimmedString(filters.patternKeyPrefix);
|
|
58
|
+
if (prefix && !(item.patternKey ?? "").startsWith(prefix)) return false;
|
|
59
|
+
if (filters.sourceDialogId && item.sourceDialogId !== filters.sourceDialogId) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const tagSet = normalizeSet(filters.tags);
|
|
63
|
+
if (tagSet) {
|
|
64
|
+
const itemTags = new Set(asTrimmedNonEmptyStringArray(item.tags));
|
|
65
|
+
for (const tag of tagSet) {
|
|
66
|
+
if (!itemTags.has(tag)) return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return true;
|
|
70
|
+
};
|
|
71
|
+
var deleteMemoryItemWithIndexesInBatch = (batch, item) => {
|
|
72
|
+
batch.del(createMemoryKey(item.ownerType, item.ownerId, item.id));
|
|
73
|
+
batch.del(
|
|
74
|
+
createMemoryOwnerIndexKey(
|
|
75
|
+
item.ownerType,
|
|
76
|
+
item.ownerId,
|
|
77
|
+
item.createdAt,
|
|
78
|
+
item.id
|
|
79
|
+
)
|
|
80
|
+
);
|
|
81
|
+
batch.del(
|
|
82
|
+
createMemorySubjectKindIndexKey(
|
|
83
|
+
item.subjectType,
|
|
84
|
+
item.subjectId,
|
|
85
|
+
item.kind,
|
|
86
|
+
item.createdAt,
|
|
87
|
+
item.id
|
|
88
|
+
)
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
var deleteMemoriesForOwnerFromDb = async (db, owner, filters = {}) => {
|
|
92
|
+
const range = memoryOwnerRange(owner.ownerType, owner.ownerId);
|
|
93
|
+
const matchedItems = [];
|
|
94
|
+
const limit = typeof filters.limit === "number" && filters.limit > 0 ? filters.limit : Number.POSITIVE_INFINITY;
|
|
95
|
+
for await (const [, value] of db.iterator({
|
|
96
|
+
gte: range.start,
|
|
97
|
+
lte: range.end,
|
|
98
|
+
reverse: true
|
|
99
|
+
})) {
|
|
100
|
+
const memoryId = typeof value?.memoryId === "string" ? value.memoryId : "";
|
|
101
|
+
if (!memoryId) continue;
|
|
102
|
+
const item = await db.get(createMemoryKey(owner.ownerType, owner.ownerId, memoryId)).catch(() => null);
|
|
103
|
+
if (!item) continue;
|
|
104
|
+
if (!matchesFilters(item, filters)) continue;
|
|
105
|
+
matchedItems.push(item);
|
|
106
|
+
if (matchedItems.length >= limit) break;
|
|
107
|
+
}
|
|
108
|
+
if (matchedItems.length === 0) {
|
|
109
|
+
return { deletedCount: 0, deletedIds: [], matchedItems: [] };
|
|
110
|
+
}
|
|
111
|
+
const batch = db.batch();
|
|
112
|
+
for (const item of matchedItems) {
|
|
113
|
+
deleteMemoryItemWithIndexesInBatch(batch, item);
|
|
114
|
+
}
|
|
115
|
+
await batch.write();
|
|
116
|
+
return {
|
|
117
|
+
deletedCount: matchedItems.length,
|
|
118
|
+
deletedIds: matchedItems.map((item) => item.id),
|
|
119
|
+
matchedItems
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// packages/cli/client/memoryRekey.ts
|
|
124
|
+
async function scanLocalMemoryItems(localDb, machineId) {
|
|
125
|
+
const range = memoryOwnerRange("user", machineId);
|
|
126
|
+
const refs = [];
|
|
127
|
+
for await (const [, value] of localDb.iterator({
|
|
128
|
+
gte: range.start,
|
|
129
|
+
lte: range.end,
|
|
130
|
+
reverse: true
|
|
131
|
+
})) {
|
|
132
|
+
refs.push(value ?? {});
|
|
133
|
+
}
|
|
134
|
+
const items = await Promise.all(
|
|
135
|
+
refs.map(
|
|
136
|
+
(ref) => typeof ref?.memoryId === "string" ? localDb.get(createMemoryKey("user", machineId, ref.memoryId)).catch(() => null) : Promise.resolve(null)
|
|
137
|
+
)
|
|
138
|
+
);
|
|
139
|
+
return items.filter((item) => !!item);
|
|
140
|
+
}
|
|
141
|
+
async function performLocalMemoryRekey(args) {
|
|
142
|
+
const { localDb, authToken, serverUrl, machineId } = args;
|
|
143
|
+
const fetchImpl = args.fetchImpl ?? fetch;
|
|
144
|
+
const items = await scanLocalMemoryItems(localDb, machineId);
|
|
145
|
+
if (items.length === 0) {
|
|
146
|
+
return { migrated: 0, merged: 0 };
|
|
147
|
+
}
|
|
148
|
+
const snapshotIds = items.map((item) => item.id);
|
|
149
|
+
const response = await fetchImpl(`${serverUrl}/api/memory/rekey`, {
|
|
150
|
+
method: "POST",
|
|
151
|
+
headers: {
|
|
152
|
+
Authorization: `Bearer ${authToken}`,
|
|
153
|
+
"Content-Type": "application/json"
|
|
154
|
+
},
|
|
155
|
+
body: JSON.stringify({ items }),
|
|
156
|
+
signal: AbortSignal?.timeout?.(3e4)
|
|
157
|
+
}).catch((e) => {
|
|
158
|
+
if (e?.name === "TimeoutError" || e?.name === "AbortError") {
|
|
159
|
+
throw new Error("memory rekey upload timed out (30s)");
|
|
160
|
+
}
|
|
161
|
+
throw e;
|
|
162
|
+
});
|
|
163
|
+
if (!response.ok) {
|
|
164
|
+
let detail = "";
|
|
165
|
+
try {
|
|
166
|
+
const body2 = await response.json();
|
|
167
|
+
detail = body2?.error?.message ?? "";
|
|
168
|
+
} catch {
|
|
169
|
+
}
|
|
170
|
+
throw new Error(
|
|
171
|
+
`memory rekey upload failed (HTTP ${response.status})${detail ? `: ${detail}` : ""}`
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
const body = await response.json().catch(() => ({}));
|
|
175
|
+
const migrated = typeof body?.migratedCount === "number" ? body.migratedCount : 0;
|
|
176
|
+
const merged = typeof body?.mergedCount === "number" ? body.mergedCount : 0;
|
|
177
|
+
await deleteMemoriesForOwnerFromDb(
|
|
178
|
+
localDb,
|
|
179
|
+
{ ownerType: "user", ownerId: machineId },
|
|
180
|
+
{ ids: snapshotIds }
|
|
181
|
+
);
|
|
182
|
+
return { migrated, merged };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// packages/cli/authCommands.ts
|
|
23
186
|
var LOGIN_HELP_TEXT = `Log in to Nolo and save a local profile.
|
|
24
187
|
|
|
25
188
|
Usage:
|
|
@@ -106,6 +269,25 @@ async function saveTokenLogin(args) {
|
|
|
106
269
|
authToken: args.authToken.trim()
|
|
107
270
|
});
|
|
108
271
|
args.output.log(`Saved profile default -> ${args.serverUrl}`);
|
|
272
|
+
try {
|
|
273
|
+
const localDb = await getDefaultCliLocalRuntimeDb();
|
|
274
|
+
const machineId = resolveMachineId();
|
|
275
|
+
const result = await performLocalMemoryRekey({
|
|
276
|
+
localDb,
|
|
277
|
+
authToken: args.authToken.trim(),
|
|
278
|
+
serverUrl: args.serverUrl,
|
|
279
|
+
machineId
|
|
280
|
+
});
|
|
281
|
+
if (result.migrated > 0 || result.merged > 0) {
|
|
282
|
+
args.output.log(
|
|
283
|
+
`[nolo] Migrated ${result.migrated} local memor${result.migrated === 1 ? "y" : "ies"} to your account` + (result.merged > 0 ? ` (${result.merged} merged with existing)` : "") + "."
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
} catch (error) {
|
|
287
|
+
args.error.error(
|
|
288
|
+
`[nolo] Local memory migration skipped: ${error instanceof Error ? error.message : String(error)}`
|
|
289
|
+
);
|
|
290
|
+
}
|
|
109
291
|
return 0;
|
|
110
292
|
}
|
|
111
293
|
async function runWebLogin(args) {
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
listUserRecordsFromServers,
|
|
8
8
|
readDbRecordFromServers,
|
|
9
9
|
readLiveDbRecordAfterTombstoneMerge
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-WKM6FH35.js";
|
|
11
11
|
import {
|
|
12
12
|
buildDialogAttachmentPlan,
|
|
13
13
|
extractFileContentIds
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-PCWC3JTN.js";
|
|
15
15
|
import {
|
|
16
16
|
parseUserIdFromAuthToken,
|
|
17
17
|
readOption,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
import {
|
|
33
33
|
asNonEmptyStringArray,
|
|
34
34
|
asTrimmedNonEmptyStringArray
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-I42VC5KR.js";
|
|
36
36
|
import {
|
|
37
37
|
asTrimmedString
|
|
38
38
|
} from "./chunk-3EUW3WEO.js";
|
|
@@ -625,7 +625,7 @@ async function tryHttpDialogCandidates(args) {
|
|
|
625
625
|
throw Object.assign(new Error("All HTTP dialog reads failed"), { attempts });
|
|
626
626
|
}
|
|
627
627
|
async function readDialogFromLocalDb(dialogKey, dialogId, limit) {
|
|
628
|
-
const { readDialogFromLocalDb: readLocalDialog } = await import("./localDialogRead-
|
|
628
|
+
const { readDialogFromLocalDb: readLocalDialog } = await import("./localDialogRead-Z5UTAJPU.js");
|
|
629
629
|
const result = await readLocalDialog({ dialogKey, dialogId, limit });
|
|
630
630
|
return {
|
|
631
631
|
...result,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
listUserRecordsFromServers,
|
|
3
3
|
readLiveDbRecordAfterTombstoneMerge
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WKM6FH35.js";
|
|
5
5
|
import {
|
|
6
6
|
agentRecordHasConfiguredCredential
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-7OOXPE3N.js";
|
|
8
8
|
|
|
9
9
|
// packages/cli/agentListHelpers.ts
|
|
10
10
|
function parseAgentRecordId(privateKey, explicitId) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// packages/core/stringArray.ts
|
|
2
|
+
function asNonEmptyStringArray(value) {
|
|
3
|
+
if (!Array.isArray(value)) return [];
|
|
4
|
+
return value.filter(
|
|
5
|
+
(item) => typeof item === "string" && !!item.trim()
|
|
6
|
+
);
|
|
7
|
+
}
|
|
8
|
+
function asTrimmedNonEmptyStringArray(value) {
|
|
9
|
+
return asNonEmptyStringArray(value).map((item) => item.trim());
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
asNonEmptyStringArray,
|
|
14
|
+
asTrimmedNonEmptyStringArray
|
|
15
|
+
};
|
|
@@ -277,19 +277,19 @@ var GPT_5_6_SOL_LONG_CONTEXT_PRICE = {
|
|
|
277
277
|
inputCacheHit: 1 * 8
|
|
278
278
|
};
|
|
279
279
|
var GPT_5_6_TERRA_STANDARD_PRICE = {
|
|
280
|
-
input: 2
|
|
281
|
-
output:
|
|
282
|
-
inputCacheHit: 0.
|
|
280
|
+
input: 2 * 8,
|
|
281
|
+
output: 12 * 8,
|
|
282
|
+
inputCacheHit: 0.2 * 8
|
|
283
283
|
};
|
|
284
284
|
var GPT_5_6_TERRA_LONG_CONTEXT_PRICE = {
|
|
285
|
-
input:
|
|
286
|
-
output:
|
|
287
|
-
inputCacheHit: 0.
|
|
285
|
+
input: 4 * 8,
|
|
286
|
+
output: 18 * 8,
|
|
287
|
+
inputCacheHit: 0.4 * 8
|
|
288
288
|
};
|
|
289
289
|
var GPT_5_6_LUNA_PRICE = {
|
|
290
|
-
input:
|
|
291
|
-
output:
|
|
292
|
-
inputCacheHit: 0.
|
|
290
|
+
input: 0.2 * 8,
|
|
291
|
+
output: 1.2 * 8,
|
|
292
|
+
inputCacheHit: 0.02 * 8
|
|
293
293
|
};
|
|
294
294
|
var openAIModels = [
|
|
295
295
|
{
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// packages/core/clipHeadAndTail.ts
|
|
2
|
+
import { writeFileSync, mkdirSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
function clipHeadAndTail(rawContent, options = {}) {
|
|
6
|
+
const maxHeadBytes = options.maxHeadBytes ?? 1e3;
|
|
7
|
+
const maxTailBytes = options.maxTailBytes ?? 2500;
|
|
8
|
+
const maxTotalBytes = options.maxTotalBytes ?? 4e3;
|
|
9
|
+
const originalBytes = Buffer.byteLength(rawContent, "utf8");
|
|
10
|
+
if (originalBytes <= maxTotalBytes) {
|
|
11
|
+
return { content: rawContent, clipped: false, originalBytes };
|
|
12
|
+
}
|
|
13
|
+
const buf = Buffer.from(rawContent, "utf8");
|
|
14
|
+
let headEnd = Math.min(maxHeadBytes, buf.length);
|
|
15
|
+
while (headEnd > 0 && (buf[headEnd] & 192) === 128) {
|
|
16
|
+
headEnd--;
|
|
17
|
+
}
|
|
18
|
+
let tailStart = Math.max(0, buf.length - maxTailBytes);
|
|
19
|
+
while (tailStart < buf.length && (buf[tailStart] & 192) === 128) {
|
|
20
|
+
tailStart++;
|
|
21
|
+
}
|
|
22
|
+
if (tailStart < headEnd) {
|
|
23
|
+
tailStart = headEnd;
|
|
24
|
+
}
|
|
25
|
+
const headStr = buf.toString("utf8", 0, headEnd);
|
|
26
|
+
const tailStr = buf.toString("utf8", tailStart, buf.length);
|
|
27
|
+
const elidedBytes = Math.max(0, originalBytes - headEnd - (buf.length - tailStart));
|
|
28
|
+
let logPath = void 0;
|
|
29
|
+
if (options.saveTempLog !== false) {
|
|
30
|
+
try {
|
|
31
|
+
const dir = join(tmpdir(), "nolo-tool-logs");
|
|
32
|
+
mkdirSync(dir, { recursive: true });
|
|
33
|
+
const safeId = (options.toolCallId || `tool-${Date.now()}`).replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
34
|
+
logPath = join(dir, `${safeId}.log`);
|
|
35
|
+
writeFileSync(logPath, rawContent, "utf8");
|
|
36
|
+
} catch {
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const logHint = logPath ? ` Full output saved to ${logPath}` : "";
|
|
40
|
+
const notice = `
|
|
41
|
+
|
|
42
|
+
[... truncated ${elidedBytes} bytes.${logHint}]
|
|
43
|
+
|
|
44
|
+
`;
|
|
45
|
+
return {
|
|
46
|
+
content: `${headStr}${notice}${tailStr}`,
|
|
47
|
+
clipped: true,
|
|
48
|
+
logPath,
|
|
49
|
+
originalBytes
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
clipHeadAndTail
|
|
55
|
+
};
|
|
@@ -3,14 +3,8 @@ var wrapHistoricalSummaryWithReplayGuard = (summary) => {
|
|
|
3
3
|
const trimmed = summary.trim();
|
|
4
4
|
if (!trimmed) return "";
|
|
5
5
|
return [
|
|
6
|
-
"\u3010\u5386\u53F2\u53C2\u8003\uFF0C\u975E\u6D3B\u6307\u4EE4\u3011",
|
|
7
|
-
|
|
8
|
-
"\u5176\u4E2D\u7684\u4EFB\u52A1\u63CF\u8FF0\u3001skill \u8C03\u7528\u3001ARGUMENTS \u8F7D\u8377\u9ED8\u8BA4\u5DF2\u8FC7\u671F\uFF08STALE-BY-DEFAULT\uFF09\uFF0C",
|
|
9
|
-
"\u5728\u6CA1\u6709\u5F53\u524D\u4F1A\u8BDD\u663E\u5F0F\u7528\u6237\u8BF7\u6C42\u65F6\u4E0D\u5F97\u91CD\u65B0\u6267\u884C\uFF1B\u6267\u884C\u524D\u5148\u5BF9\u7167\u5B9E\u9645\u5DE5\u4F5C\u72B6\u6001\u786E\u8BA4\u3002",
|
|
10
|
-
"",
|
|
11
|
-
"--- \u5386\u53F2\u6458\u8981\u5F00\u59CB ---",
|
|
12
|
-
trimmed,
|
|
13
|
-
"--- \u5386\u53F2\u6458\u8981\u7ED3\u675F ---"
|
|
6
|
+
"\u3010\u5386\u53F2\u53C2\u8003\uFF0C\u975E\u6D3B\u6307\u4EE4\u3011\u4EE5\u4E0B\u4E3A\u51BB\u7ED3\u6458\u8981\uFF0C\u5176\u4E2D\u7684\u4EFB\u52A1/skill/ARGUMENTS \u9ED8\u8BA4\u5DF2\u8FC7\u671F\uFF0C\u4E0D\u5F97\u91CD\u65B0\u6267\u884C\u3002",
|
|
7
|
+
trimmed
|
|
14
8
|
].join("\n");
|
|
15
9
|
};
|
|
16
10
|
|