nolo-cli 0.16.0-alpha.9 → 0.16.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-ABTND4KZ.js → _executeModel-AVCA2NAV.js} +18 -19
- package/{agentDeleteCommand-ARMAV46L.js → agentDeleteCommand-QW5PUMDQ.js} +12 -13
- package/{agentEmailCommands-BKPZP4UP.js → agentEmailCommands-4ORVLGVQ.js} +23 -24
- package/{agentListCommands-5J7RRXUO.js → agentListCommands-YWBYRTYC.js} +14 -15
- package/{agentMachineCommands-VXWJXXPF.js → agentMachineCommands-JSQW4FOA.js} +12 -13
- package/{agentRecordCommands-INDJINPN.js → agentRecordCommands-AASIWOBT.js} +22 -23
- package/{agentRunCommand-KBN6HBY4.js → agentRunCommand-TB5BHXUH.js} +22 -23
- package/{agentRuntimeLocal-AH2RYWGP.js → agentRuntimeLocal-QNPNJRVH.js} +10 -11
- package/{agentSlice-R4PELU57.js → agentSlice-RUNXC62Y.js} +1 -1
- package/{authCommand-QU5BXRBH.js → authCommand-YFTR3347.js} +2 -8
- package/{chunk-ZVC2PCZN.js → chunk-33BJUVK4.js} +2 -2
- package/{chunk-BG7AP3Q7.js → chunk-3663CXZN.js} +11 -38
- package/{chunk-IFPY2BIE.js → chunk-3OIRVWXA.js} +10 -1
- package/{chunk-LSFAWXKC.js → chunk-3WGLLTK4.js} +3 -100
- package/{chunk-5Y5KEB7V.js → chunk-4FX6NVDW.js} +134 -1
- package/{chunk-QLWU2KOT.js → chunk-4IJYA27C.js} +1 -1
- package/{chunk-OELQ67TN.js → chunk-4L2OJPCU.js} +1 -1
- package/{chunk-HSLJ7QER.js → chunk-55NSNCFM.js} +1 -1
- package/{chunk-ZVDRAEZL.js → chunk-6EVITP2G.js} +250 -1
- package/{chunk-AFNJWHKL.js → chunk-7UKFVQ5W.js} +27 -84
- package/{chunk-VK2HVKAO.js → chunk-AUURUT6L.js} +193 -64
- package/{chunk-4N7QA72L.js → chunk-AVVZUXXC.js} +13 -34
- package/{chunk-2XA3QGOH.js → chunk-BEBNFWDU.js} +3 -3
- package/{chunk-4EME3YTO.js → chunk-DGEYDWEZ.js} +3 -3
- package/{chunk-XECKIDGJ.js → chunk-DPAB4FQ7.js} +126 -646
- package/{chunk-J3VQSU5W.js → chunk-EHLHSX7R.js} +2 -9
- package/{chunk-PEDT43JF.js → chunk-FRV6A633.js} +2 -2
- package/{chunk-VAT72PDP.js → chunk-FY233ZFU.js} +12 -13
- package/{chunk-LZYEWFPK.js → chunk-GSINCD4P.js} +4 -8
- package/{chunk-ZPPTWRPT.js → chunk-IGXREZW2.js} +1 -1
- package/{chunk-B4KT7RN2.js → chunk-JTMNCCWF.js} +2 -2
- package/{chunk-ASZ2C44S.js → chunk-LPEUV5RE.js} +2 -2
- package/{chunk-WVDAUR2S.js → chunk-M43KDE25.js} +1 -1
- package/{chunk-GWESD7AS.js → chunk-MR6ISAGB.js} +2 -2
- package/{chunk-LSHKV3S7.js → chunk-NSCHQQPU.js} +9 -9
- package/{chunk-F6JSVFHX.js → chunk-NVEWUJVX.js} +1 -1
- package/{chunk-R6ALN5F5.js → chunk-P3RIAYGG.js} +1 -1
- package/{chunk-FMYTM25W.js → chunk-PCTUYVUM.js} +1 -1
- package/{chunk-BHVBFI6B.js → chunk-S2LXHNHG.js} +3 -3
- package/{chunk-SGRDLYRZ.js → chunk-Z5JQNBNY.js} +1 -1
- package/{chunk-7HECYFOI.js → chunk-ZQBL7LIC.js} +22 -17
- package/{createAgentAutomationAction-3KKRAYGE.js → createAgentAutomationAction-FNHPSKKO.js} +4 -4
- package/{createDialogAction-S7NMQ4TZ.js → createDialogAction-TZCVQ3NU.js} +5 -5
- package/{createPageAction-2EFBT4LQ.js → createPageAction-EIGZ3BKT.js} +4 -4
- package/{dialogCommands-J7XFIQRD.js → dialogCommands-FO77J5DQ.js} +13 -14
- package/{dialogSlice-LNRRBUIC.js → dialogSlice-MM5U4KE2.js} +4 -4
- package/{docCreateCommands-MKO5WB34.js → docCreateCommands-I3BS3AZI.js} +15 -18
- package/{docDeleteCommands-RCBHRKUE.js → docDeleteCommands-Q2OPV52P.js} +14 -17
- package/{docReadCommands-66527P4G.js → docReadCommands-YOOFACYZ.js} +13 -16
- package/{docStore-67MYPX7P.js → docStore-NGYQ2JTR.js} +5 -5
- package/{docUpdateCommands-UT5HSLOJ.js → docUpdateCommands-2B32ITHN.js} +14 -17
- package/{handleSendMessageAction-VZ7226PB.js → handleSendMessageAction-JRZWWBKP.js} +4 -4
- package/index.js +43 -74
- package/{machineCommands-ATA7OSBJ.js → machineCommands-WRWF2ICZ.js} +21 -22
- package/{machineWsRunDispatch-ZDCZ645H.js → machineWsRunDispatch-ZX7Q3TWZ.js} +21 -22
- package/{models-5K5G2CZI.js → models-WQ5N4OJM.js} +1 -1
- package/package.json +1 -1
- package/{readlineWorkspace-UUNABTLB.js → readlineWorkspace-ZTGRGW46.js} +74 -75
- package/{runAgentClientLoop-2A577WBM.js → runAgentClientLoop-JZCOP7LG.js} +14 -15
- package/{spaceCommands-UNZVR2OS.js → spaceCommands-VV4GTPQK.js} +12 -13
- package/{spaceSlice-MC7FYPMZ.js → spaceSlice-DRWWZJP7.js} +4 -4
- package/{streamAgentChatTurn-IEKPNM33.js → streamAgentChatTurn-Y6WGATQR.js} +23 -21
- package/{tools-E6FHKTCF.js → tools-PUNBY3AH.js} +9 -9
- package/{tuiSummaryLlmCaller-QHPDD4WP.js → tuiSummaryLlmCaller-F64WLSAF.js} +3 -4
- package/{updateDialogTitleAction-SQJEEW2K.js → updateDialogTitleAction-YSR4TCMB.js} +4 -4
- package/appDeleteCommands-FRWMPQNS.js +0 -125
- package/appDeployCommands-IRF3T35Z.js +0 -164
- package/appDeployStatusCommands-ADFERYPU.js +0 -145
- package/appGetCommands-FTEOXWMS.js +0 -120
- package/appListCommands-WBY7UWYD.js +0 -123
- package/chunk-G63IH3ZK.js +0 -107
- package/chunk-GFUIQ4RY.js +0 -136
- package/chunk-KFEVY3ST.js +0 -255
- /package/{chunk-RK5NYQEL.js → chunk-XBS2WYJ2.js} +0 -0
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
inlineImageUrlsForCustomProvider,
|
|
6
6
|
prepareTools,
|
|
7
7
|
shouldInlineImageUrlsForAgent
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-FRV6A633.js";
|
|
9
9
|
import {
|
|
10
10
|
performFetchRequest
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-FY233ZFU.js";
|
|
12
12
|
import {
|
|
13
13
|
createSSEParser,
|
|
14
14
|
createToolRunId,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
toolRunSetPending,
|
|
20
20
|
toolRunStarted,
|
|
21
21
|
toolRunSucceeded
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-ZQBL7LIC.js";
|
|
23
23
|
import {
|
|
24
24
|
getPublicImageAgentMode
|
|
25
25
|
} from "./chunk-VIDPVFP3.js";
|
|
@@ -29,25 +29,22 @@ import {
|
|
|
29
29
|
messageStreaming,
|
|
30
30
|
selectCurrentSpaceId,
|
|
31
31
|
updateToolMessage
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-NSCHQQPU.js";
|
|
33
33
|
import {
|
|
34
34
|
streamAgentChatTurn
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-S2LXHNHG.js";
|
|
36
36
|
import {
|
|
37
37
|
EMPTY_ASSISTANT_REPAIR_PROMPT
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-GSINCD4P.js";
|
|
39
39
|
import {
|
|
40
40
|
accumulateToolCallDelta,
|
|
41
41
|
createThinkParserState,
|
|
42
|
-
createToolCallTextParserState,
|
|
43
42
|
flushThinkParser,
|
|
44
|
-
flushToolCallTextParserIntoCallback,
|
|
45
|
-
processContentChunkWithToolCallStripping,
|
|
46
43
|
processThinkChunk
|
|
47
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-3WGLLTK4.js";
|
|
48
45
|
import {
|
|
49
46
|
getModelInfo
|
|
50
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-4L2OJPCU.js";
|
|
51
48
|
import {
|
|
52
49
|
getApiEndpoint
|
|
53
50
|
} from "./chunk-66X4VSRC.js";
|
|
@@ -1108,7 +1105,6 @@ function createInitialStreamState() {
|
|
|
1108
1105
|
accumulatedToolCalls: [],
|
|
1109
1106
|
reasoningBuffer: "",
|
|
1110
1107
|
thinkState: createThinkParserState(),
|
|
1111
|
-
toolCallTextState: createToolCallTextParserState(),
|
|
1112
1108
|
assistantToolCalls: void 0,
|
|
1113
1109
|
hasHandedOff: false,
|
|
1114
1110
|
hasProcessedToolCalls: false,
|
|
@@ -1252,19 +1248,7 @@ function applyDelta(state, delta) {
|
|
|
1252
1248
|
}
|
|
1253
1249
|
const contentChunk = delta.content || "";
|
|
1254
1250
|
if (contentChunk) {
|
|
1255
|
-
const
|
|
1256
|
-
contentChunk,
|
|
1257
|
-
next.toolCallTextState,
|
|
1258
|
-
(name, arguments_) => {
|
|
1259
|
-
next.accumulatedToolCalls = accumulateToolCallChunks(
|
|
1260
|
-
next.accumulatedToolCalls ?? [],
|
|
1261
|
-
[{ index: next.accumulatedToolCalls.length, type: "function", function: { name, arguments: arguments_ } }]
|
|
1262
|
-
);
|
|
1263
|
-
}
|
|
1264
|
-
);
|
|
1265
|
-
next.toolCallTextState = tcState;
|
|
1266
|
-
if (!cleanedContent) return { state: next, hasNewVisibleContent };
|
|
1267
|
-
const parsed = processThinkChunk(cleanedContent, next.thinkState);
|
|
1251
|
+
const parsed = processThinkChunk(contentChunk, next.thinkState);
|
|
1268
1252
|
next.thinkState = parsed.state;
|
|
1269
1253
|
if (parsed.reasoning) {
|
|
1270
1254
|
next.reasoningBuffer = (next.reasoningBuffer || "") + parsed.reasoning;
|
|
@@ -1454,26 +1438,15 @@ async function readStreamChunkWithTimeout(reader, signal) {
|
|
|
1454
1438
|
async function handleStreamCompletion(state, ctx, finalizeCtx) {
|
|
1455
1439
|
let hasHandedOff = false;
|
|
1456
1440
|
let hasPendingInteraction = false;
|
|
1457
|
-
const { residualContent, state: tcFlushState } = flushToolCallTextParserIntoCallback(
|
|
1458
|
-
state.toolCallTextState,
|
|
1459
|
-
(name, arguments_) => {
|
|
1460
|
-
state.accumulatedToolCalls = accumulateToolCallChunks(
|
|
1461
|
-
state.accumulatedToolCalls ?? [],
|
|
1462
|
-
[{ index: state.accumulatedToolCalls.length, type: "function", function: { name, arguments: arguments_ } }]
|
|
1463
|
-
);
|
|
1464
|
-
}
|
|
1465
|
-
);
|
|
1466
|
-
state.toolCallTextState = tcFlushState;
|
|
1467
1441
|
const flushed = flushThinkParser(state.thinkState);
|
|
1468
1442
|
state.thinkState = flushed.state;
|
|
1469
1443
|
if (flushed.reasoning) {
|
|
1470
1444
|
state.reasoningBuffer = (state.reasoningBuffer || "") + flushed.reasoning;
|
|
1471
1445
|
}
|
|
1472
|
-
|
|
1473
|
-
if (combinedFlushContent) {
|
|
1446
|
+
if (flushed.content) {
|
|
1474
1447
|
state = {
|
|
1475
1448
|
...state,
|
|
1476
|
-
contentBuffer: appendTextChunk(state.contentBuffer,
|
|
1449
|
+
contentBuffer: appendTextChunk(state.contentBuffer, flushed.content)
|
|
1477
1450
|
};
|
|
1478
1451
|
}
|
|
1479
1452
|
if (!state.hasProcessedToolCalls && state.accumulatedToolCalls.length > 0) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getModelAbility
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XBS2WYJ2.js";
|
|
4
4
|
|
|
5
5
|
// packages/ai/agent/safeAgentSummary.ts
|
|
6
6
|
function parseTimestamp(val) {
|
|
@@ -103,6 +103,10 @@ function toSafeAgentSummary(record, options) {
|
|
|
103
103
|
const favStatus = resolveFavoriteStatus(record, options);
|
|
104
104
|
const isPublic = record?.isPublic === true || record?.isPublicFlag === true || record?.publicRecordExists === true;
|
|
105
105
|
const updatedAt = safeTimestamp(record?.updatedAt ?? record?.createdAt ?? record?.created);
|
|
106
|
+
const currentUserId = options?.userId;
|
|
107
|
+
const isOwnedByRecord = Boolean(currentUserId) && (typeof record?.userId === "string" && record.userId === currentUserId || typeof record?.ownerId === "string" && record.ownerId === currentUserId);
|
|
108
|
+
const isOwnedByDbKey = Boolean(currentUserId) && typeof record?.dbKey === "string" && record.dbKey.startsWith(`agent-${currentUserId}-`);
|
|
109
|
+
const isOwned = isOwnedByRecord || isOwnedByDbKey;
|
|
106
110
|
return {
|
|
107
111
|
id,
|
|
108
112
|
...publicKey !== void 0 ? { publicKey } : {},
|
|
@@ -120,11 +124,16 @@ function toSafeAgentSummary(record, options) {
|
|
|
120
124
|
isFavorite: favStatus.isFavorite,
|
|
121
125
|
favoritedAt: favStatus.favoritedAt,
|
|
122
126
|
isPublic,
|
|
127
|
+
isOwned,
|
|
123
128
|
updatedAt
|
|
124
129
|
};
|
|
125
130
|
}
|
|
126
131
|
function sortSafeAgentSummaries(agents) {
|
|
127
132
|
return [...agents].sort((left, right) => {
|
|
133
|
+
const leftOwned = left.isOwned === true;
|
|
134
|
+
const rightOwned = right.isOwned === true;
|
|
135
|
+
if (leftOwned && !rightOwned) return -1;
|
|
136
|
+
if (!leftOwned && rightOwned) return 1;
|
|
128
137
|
const leftFav = left.isFavorite === true;
|
|
129
138
|
const rightFav = right.isFavorite === true;
|
|
130
139
|
if (leftFav && !rightFav) return -1;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
// packages/agent-runtime/
|
|
1
|
+
// packages/agent-runtime/thinkTagParser.ts
|
|
2
|
+
var OPEN_TAG = "<think>";
|
|
3
|
+
var CLOSE_TAG = "</think>";
|
|
2
4
|
function longestTagPrefixLength(buffer, tag) {
|
|
3
5
|
const max = Math.min(buffer.length, tag.length - 1);
|
|
4
6
|
for (let len = max; len > 0; len--) {
|
|
@@ -8,10 +10,6 @@ function longestTagPrefixLength(buffer, tag) {
|
|
|
8
10
|
}
|
|
9
11
|
return 0;
|
|
10
12
|
}
|
|
11
|
-
|
|
12
|
-
// packages/agent-runtime/thinkTagParser.ts
|
|
13
|
-
var OPEN_TAG = "<think>";
|
|
14
|
-
var CLOSE_TAG = "</think>";
|
|
15
13
|
function extractThinkContent(content) {
|
|
16
14
|
const regex = new RegExp(`${OPEN_TAG}([\\s\\S]*?)${CLOSE_TAG}`, "g");
|
|
17
15
|
const matches = [...content.matchAll(regex)];
|
|
@@ -83,98 +81,6 @@ function flushThinkParser(state) {
|
|
|
83
81
|
};
|
|
84
82
|
}
|
|
85
83
|
|
|
86
|
-
// packages/agent-runtime/toolCallTextParser.ts
|
|
87
|
-
var OPEN_TAG2 = "<tool_call>";
|
|
88
|
-
var CLOSE_TAG2 = "</tool_call>";
|
|
89
|
-
function createToolCallTextParserState() {
|
|
90
|
-
return { mode: "content", buffer: "" };
|
|
91
|
-
}
|
|
92
|
-
function processToolCallTextChunk(chunk, state) {
|
|
93
|
-
let visible = "";
|
|
94
|
-
let toolCallTexts = [];
|
|
95
|
-
let { mode, buffer } = state;
|
|
96
|
-
buffer += chunk;
|
|
97
|
-
while (true) {
|
|
98
|
-
if (mode === "content") {
|
|
99
|
-
const idx = buffer.indexOf(OPEN_TAG2);
|
|
100
|
-
if (idx === -1) {
|
|
101
|
-
const keep = longestTagPrefixLength(buffer, OPEN_TAG2);
|
|
102
|
-
visible += buffer.slice(0, buffer.length - keep);
|
|
103
|
-
buffer = buffer.slice(buffer.length - keep);
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
visible += buffer.slice(0, idx);
|
|
107
|
-
buffer = buffer.slice(idx + OPEN_TAG2.length);
|
|
108
|
-
mode = "toolcall";
|
|
109
|
-
} else {
|
|
110
|
-
const idx = buffer.indexOf(CLOSE_TAG2);
|
|
111
|
-
if (idx === -1) {
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
toolCallTexts.push(buffer.slice(0, idx));
|
|
115
|
-
buffer = buffer.slice(idx + CLOSE_TAG2.length);
|
|
116
|
-
mode = "content";
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return {
|
|
120
|
-
content: visible,
|
|
121
|
-
toolCallTexts,
|
|
122
|
-
state: { mode, buffer }
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
function flushToolCallTextParser(state) {
|
|
126
|
-
const { mode, buffer } = state;
|
|
127
|
-
if (mode === "toolcall") {
|
|
128
|
-
const keep = longestTagPrefixLength(buffer, CLOSE_TAG2);
|
|
129
|
-
const text = buffer.slice(0, buffer.length - keep);
|
|
130
|
-
return {
|
|
131
|
-
content: "",
|
|
132
|
-
toolCallTexts: text ? [text] : [],
|
|
133
|
-
state: { mode: "content", buffer: "" }
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
return {
|
|
137
|
-
content: buffer,
|
|
138
|
-
toolCallTexts: [],
|
|
139
|
-
state: { mode: "content", buffer: "" }
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
function tryParseToolCallText(text) {
|
|
143
|
-
const trimmed = text.trim();
|
|
144
|
-
if (!trimmed) return null;
|
|
145
|
-
try {
|
|
146
|
-
const parsed = JSON.parse(trimmed);
|
|
147
|
-
if (typeof parsed === "object" && parsed !== null && typeof parsed.name === "string") {
|
|
148
|
-
return {
|
|
149
|
-
name: parsed.name,
|
|
150
|
-
arguments: typeof parsed.arguments === "string" ? parsed.arguments : JSON.stringify(parsed.arguments ?? {})
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
} catch {
|
|
154
|
-
}
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
function processContentChunkWithToolCallStripping(chunk, state, onToolCall) {
|
|
158
|
-
const stripped = processToolCallTextChunk(chunk, state);
|
|
159
|
-
for (const text of stripped.toolCallTexts) {
|
|
160
|
-
const parsedTc = tryParseToolCallText(text);
|
|
161
|
-
if (parsedTc) {
|
|
162
|
-
onToolCall(parsedTc.name, parsedTc.arguments);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return { cleanedContent: stripped.content, state: stripped.state };
|
|
166
|
-
}
|
|
167
|
-
function flushToolCallTextParserIntoCallback(state, onToolCall) {
|
|
168
|
-
const flushed = flushToolCallTextParser(state);
|
|
169
|
-
for (const text of flushed.toolCallTexts) {
|
|
170
|
-
const parsedTc = tryParseToolCallText(text);
|
|
171
|
-
if (parsedTc) {
|
|
172
|
-
onToolCall(parsedTc.name, parsedTc.arguments);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return { residualContent: flushed.content, state: flushed.state };
|
|
176
|
-
}
|
|
177
|
-
|
|
178
84
|
// packages/agent-runtime/toolCallAccumulator.ts
|
|
179
85
|
function createToolCallAccumulator() {
|
|
180
86
|
return { slots: [] };
|
|
@@ -235,9 +141,6 @@ export {
|
|
|
235
141
|
createThinkParserState,
|
|
236
142
|
processThinkChunk,
|
|
237
143
|
flushThinkParser,
|
|
238
|
-
createToolCallTextParserState,
|
|
239
|
-
processContentChunkWithToolCallStripping,
|
|
240
|
-
flushToolCallTextParserIntoCallback,
|
|
241
144
|
createToolCallAccumulator,
|
|
242
145
|
accumulateToolCallDelta,
|
|
243
146
|
finalizeAccumulatedToolCalls
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
readDbRecord,
|
|
3
3
|
writeAgentRecord
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PCTUYVUM.js";
|
|
5
5
|
import {
|
|
6
6
|
buildSkillSummaryMarker
|
|
7
7
|
} from "./chunk-VF4K2QE6.js";
|
|
8
|
+
import {
|
|
9
|
+
buildSkillDocMarkdown
|
|
10
|
+
} from "./chunk-VC6OZXO5.js";
|
|
8
11
|
import {
|
|
9
12
|
parseUserIdFromAuthToken,
|
|
10
13
|
readOption,
|
|
@@ -27,6 +30,128 @@ import {
|
|
|
27
30
|
normalizeServerOrigin
|
|
28
31
|
} from "./chunk-CF7PE763.js";
|
|
29
32
|
|
|
33
|
+
// packages/cli/docPageHelpers.ts
|
|
34
|
+
import { readFileSync } from "node:fs";
|
|
35
|
+
import { ulid } from "ulid";
|
|
36
|
+
function getCliArg(args, flag) {
|
|
37
|
+
const idx = args.indexOf(flag);
|
|
38
|
+
return idx !== -1 ? args[idx + 1] : void 0;
|
|
39
|
+
}
|
|
40
|
+
function readBodyArg(args, fallback = "") {
|
|
41
|
+
const bodyFile = getCliArg(args, "--body-file");
|
|
42
|
+
if (bodyFile !== void 0) {
|
|
43
|
+
return readFileSync(bodyFile, "utf8");
|
|
44
|
+
}
|
|
45
|
+
return getCliArg(args, "--body") ?? fallback;
|
|
46
|
+
}
|
|
47
|
+
function textToSlate(text) {
|
|
48
|
+
return text.split("\n").map((line) => ({
|
|
49
|
+
type: "paragraph",
|
|
50
|
+
children: [{ text: line }]
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
function createPageId() {
|
|
54
|
+
return ulid();
|
|
55
|
+
}
|
|
56
|
+
function buildPageKey(userId, pageId) {
|
|
57
|
+
return `page-${userId}-${pageId}`;
|
|
58
|
+
}
|
|
59
|
+
function buildPageRecord(args) {
|
|
60
|
+
const { dbKey, pageId, title, spaceId, content, existing, meta, slateData } = args;
|
|
61
|
+
const now = Date.now();
|
|
62
|
+
const createdAt = typeof existing?.createdAt === "number" ? existing.createdAt : now;
|
|
63
|
+
const created = typeof existing?.created === "string" ? existing.created : new Date(createdAt).toISOString();
|
|
64
|
+
const nextRecord = {
|
|
65
|
+
...existing ?? {},
|
|
66
|
+
id: existing?.id ?? pageId,
|
|
67
|
+
dbKey,
|
|
68
|
+
type: "page",
|
|
69
|
+
title,
|
|
70
|
+
spaceId,
|
|
71
|
+
content,
|
|
72
|
+
updatedAt: now,
|
|
73
|
+
createdAt,
|
|
74
|
+
created
|
|
75
|
+
};
|
|
76
|
+
if (meta !== void 0) {
|
|
77
|
+
if (meta === null) {
|
|
78
|
+
delete nextRecord.meta;
|
|
79
|
+
} else {
|
|
80
|
+
nextRecord.meta = meta;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (slateData !== void 0) {
|
|
84
|
+
if (slateData === null) {
|
|
85
|
+
delete nextRecord.slateData;
|
|
86
|
+
} else {
|
|
87
|
+
nextRecord.slateData = slateData;
|
|
88
|
+
}
|
|
89
|
+
} else if (!existing?.slateData) {
|
|
90
|
+
nextRecord.slateData = textToSlate(content);
|
|
91
|
+
}
|
|
92
|
+
return nextRecord;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// packages/cli/docSkillHelpers.ts
|
|
96
|
+
function normalizeSkillSeed(input) {
|
|
97
|
+
return input.trim().toLowerCase().replace(/[^a-z0-9\u4e00-\u9fa5]+/g, "-").replace(/^-+|-+$/g, "");
|
|
98
|
+
}
|
|
99
|
+
function deterministicId(prefix, seed) {
|
|
100
|
+
let h = 2166136261;
|
|
101
|
+
for (let i = 0; i < seed.length; i++) {
|
|
102
|
+
h ^= seed.charCodeAt(i);
|
|
103
|
+
h = h * 16777619 >>> 0;
|
|
104
|
+
}
|
|
105
|
+
const suffix = h.toString(36).toUpperCase().padStart(14, "0");
|
|
106
|
+
return (prefix + suffix).slice(0, 26);
|
|
107
|
+
}
|
|
108
|
+
function buildSkillDocId(input) {
|
|
109
|
+
return deterministicId("01SK", normalizeSkillSeed(input) || input);
|
|
110
|
+
}
|
|
111
|
+
function buildSkillPageKey(userId, skillId) {
|
|
112
|
+
return buildPageKey(userId, skillId);
|
|
113
|
+
}
|
|
114
|
+
function buildSkillPageRecord(args) {
|
|
115
|
+
const {
|
|
116
|
+
dbKey,
|
|
117
|
+
skillId,
|
|
118
|
+
title,
|
|
119
|
+
spaceId,
|
|
120
|
+
body,
|
|
121
|
+
skillConfig,
|
|
122
|
+
evalConfig,
|
|
123
|
+
workflowConfig,
|
|
124
|
+
existing
|
|
125
|
+
} = args;
|
|
126
|
+
return {
|
|
127
|
+
...buildPageRecord({
|
|
128
|
+
dbKey,
|
|
129
|
+
pageId: skillId,
|
|
130
|
+
title,
|
|
131
|
+
spaceId,
|
|
132
|
+
content: buildSkillDocMarkdown({
|
|
133
|
+
body,
|
|
134
|
+
skillConfig,
|
|
135
|
+
evalConfig,
|
|
136
|
+
workflowConfig
|
|
137
|
+
}),
|
|
138
|
+
existing,
|
|
139
|
+
meta: {
|
|
140
|
+
...existing?.meta ?? {},
|
|
141
|
+
kind: "skill",
|
|
142
|
+
skillConfig,
|
|
143
|
+
...evalConfig ? { evalConfig } : {},
|
|
144
|
+
...workflowConfig ? { workflowConfig } : {}
|
|
145
|
+
},
|
|
146
|
+
slateData: null
|
|
147
|
+
})
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function parseJsonArg(raw, fallback) {
|
|
151
|
+
if (raw === void 0) return fallback;
|
|
152
|
+
return JSON.parse(raw);
|
|
153
|
+
}
|
|
154
|
+
|
|
30
155
|
// packages/cli/docSpaceHelpers.ts
|
|
31
156
|
async function ensurePageAttachedToSpace(params) {
|
|
32
157
|
const { baseUrl, userId, authToken, spaceId, contentKey, title, skillSummary } = params;
|
|
@@ -208,6 +333,14 @@ function buildSkillSummaryForRecord(record) {
|
|
|
208
333
|
}
|
|
209
334
|
|
|
210
335
|
export {
|
|
336
|
+
readBodyArg,
|
|
337
|
+
createPageId,
|
|
338
|
+
buildPageKey,
|
|
339
|
+
buildPageRecord,
|
|
340
|
+
buildSkillDocId,
|
|
341
|
+
buildSkillPageKey,
|
|
342
|
+
buildSkillPageRecord,
|
|
343
|
+
parseJsonArg,
|
|
211
344
|
removePageFromSpace,
|
|
212
345
|
hasHelpArg,
|
|
213
346
|
hasFlag,
|