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
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
cliApiRequest,
|
|
3
|
-
formatFields,
|
|
4
|
-
outputResult,
|
|
5
|
-
pickDefined,
|
|
6
|
-
printCliError,
|
|
7
|
-
resolveCliContext
|
|
8
|
-
} from "./chunk-G63IH3ZK.js";
|
|
9
|
-
import {
|
|
10
|
-
hasFlag,
|
|
11
|
-
hasHelpArg
|
|
12
|
-
} from "./chunk-5Y5KEB7V.js";
|
|
13
|
-
import "./chunk-FMYTM25W.js";
|
|
14
|
-
import "./chunk-WVDAUR2S.js";
|
|
15
|
-
import "./chunk-VHBWHNVT.js";
|
|
16
|
-
import "./chunk-VF4K2QE6.js";
|
|
17
|
-
import "./chunk-AFNJWHKL.js";
|
|
18
|
-
import "./chunk-4N7QA72L.js";
|
|
19
|
-
import "./chunk-ZNFJWEN4.js";
|
|
20
|
-
import "./chunk-OIQPORYI.js";
|
|
21
|
-
import "./chunk-LZYEWFPK.js";
|
|
22
|
-
import "./chunk-LSFAWXKC.js";
|
|
23
|
-
import "./chunk-ASZ2C44S.js";
|
|
24
|
-
import "./chunk-KFEVY3ST.js";
|
|
25
|
-
import "./chunk-ZVDRAEZL.js";
|
|
26
|
-
import "./chunk-B4KT7RN2.js";
|
|
27
|
-
import "./chunk-OELQ67TN.js";
|
|
28
|
-
import "./chunk-5MMAK75Q.js";
|
|
29
|
-
import "./chunk-66X4VSRC.js";
|
|
30
|
-
import "./chunk-5CS33IBL.js";
|
|
31
|
-
import "./chunk-JZPBVBIY.js";
|
|
32
|
-
import "./chunk-ZHXJ6M7T.js";
|
|
33
|
-
import "./chunk-QLUFR47U.js";
|
|
34
|
-
import "./chunk-KKY4B2Q2.js";
|
|
35
|
-
import "./chunk-DWLEOOGR.js";
|
|
36
|
-
import "./chunk-HNMXYYJR.js";
|
|
37
|
-
import "./chunk-IDZTNRP2.js";
|
|
38
|
-
import {
|
|
39
|
-
readOption
|
|
40
|
-
} from "./chunk-A7GB5UGH.js";
|
|
41
|
-
import "./chunk-OLZBQWZU.js";
|
|
42
|
-
import "./chunk-RK5NYQEL.js";
|
|
43
|
-
import "./chunk-O6W2O2DA.js";
|
|
44
|
-
import "./chunk-KX6YBIHG.js";
|
|
45
|
-
import "./chunk-IWLUTMYX.js";
|
|
46
|
-
import "./chunk-3S2VOMIF.js";
|
|
47
|
-
import "./chunk-O4BU24WZ.js";
|
|
48
|
-
import "./chunk-I42VC5KR.js";
|
|
49
|
-
import "./chunk-WWC7I6TA.js";
|
|
50
|
-
import "./chunk-JTINRTBT.js";
|
|
51
|
-
import "./chunk-QSJ3HFEF.js";
|
|
52
|
-
import "./chunk-XPC5C7BK.js";
|
|
53
|
-
import "./chunk-DVRHHFEA.js";
|
|
54
|
-
import "./chunk-OOSFSFMA.js";
|
|
55
|
-
import "./chunk-GBRG75BQ.js";
|
|
56
|
-
import "./chunk-3EUW3WEO.js";
|
|
57
|
-
import "./chunk-U6VC4MU4.js";
|
|
58
|
-
import "./chunk-KUG52IAP.js";
|
|
59
|
-
import "./chunk-LCBAMY2M.js";
|
|
60
|
-
import "./chunk-4SN6J65J.js";
|
|
61
|
-
import "./chunk-CF7PE763.js";
|
|
62
|
-
import "./chunk-G3SUCT4W.js";
|
|
63
|
-
import "./chunk-4VNS5WPM.js";
|
|
64
|
-
|
|
65
|
-
// packages/cli/appListCommands.ts
|
|
66
|
-
function printAppListUsage() {
|
|
67
|
-
process.stdout.write(`Usage:
|
|
68
|
-
nolo app list [--scope owned|accessible] [--space-id <id>]
|
|
69
|
-
|
|
70
|
-
Options:
|
|
71
|
-
--scope <type> owned (default) or accessible
|
|
72
|
-
--space-id <id> List apps under a space
|
|
73
|
-
--json Print machine-readable JSON
|
|
74
|
-
--server <url> Server to query
|
|
75
|
-
--token <jwt> Auth token. Required for reads.
|
|
76
|
-
`);
|
|
77
|
-
}
|
|
78
|
-
async function runAppListCommand(args, deps) {
|
|
79
|
-
if (hasHelpArg(args)) {
|
|
80
|
-
printAppListUsage();
|
|
81
|
-
return 0;
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
const { serverUrl, authToken } = resolveCliContext(args, deps.env);
|
|
85
|
-
const body = pickDefined({
|
|
86
|
-
scope: readOption(args, "--scope"),
|
|
87
|
-
spaceId: readOption(args, "--space-id")
|
|
88
|
-
});
|
|
89
|
-
const data = await cliApiRequest({ serverUrl, authToken, path: "/api/app/list", body });
|
|
90
|
-
const workers = data.workers ?? [];
|
|
91
|
-
outputResult(data, hasFlag(args, "--json"), () => {
|
|
92
|
-
if (workers.length === 0) {
|
|
93
|
-
process.stdout.write("\u6CA1\u6709\u5E94\u7528\n");
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
process.stdout.write(`\u5E94\u7528\u5217\u8868 (${workers.length})
|
|
97
|
-
|
|
98
|
-
`);
|
|
99
|
-
for (const app of workers) {
|
|
100
|
-
process.stdout.write(` ${app.userFriendlyName ?? "(unnamed)"}
|
|
101
|
-
`);
|
|
102
|
-
const fields = [
|
|
103
|
-
["appId", app.appId],
|
|
104
|
-
["appKey", app.appKey],
|
|
105
|
-
["url", app.url],
|
|
106
|
-
["framework", app.framework],
|
|
107
|
-
["visibility", app.visibility]
|
|
108
|
-
];
|
|
109
|
-
if (app.customUrl) fields.push(["customUrl", app.customUrl]);
|
|
110
|
-
if (app.modifiedOn) fields.push(["modified", app.modifiedOn]);
|
|
111
|
-
process.stdout.write(formatFields(fields, " "));
|
|
112
|
-
process.stdout.write("\n\n");
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
return 0;
|
|
116
|
-
} catch (error) {
|
|
117
|
-
printCliError(error);
|
|
118
|
-
return 1;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
export {
|
|
122
|
-
runAppListCommand
|
|
123
|
-
};
|
package/chunk-G63IH3ZK.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
requireTokenUser
|
|
3
|
-
} from "./chunk-5Y5KEB7V.js";
|
|
4
|
-
import {
|
|
5
|
-
resolveServerUrl
|
|
6
|
-
} from "./chunk-A7GB5UGH.js";
|
|
7
|
-
|
|
8
|
-
// packages/cli/cliApiClient.ts
|
|
9
|
-
var CliApiError = class extends Error {
|
|
10
|
-
code;
|
|
11
|
-
status;
|
|
12
|
-
constructor(message, code, status) {
|
|
13
|
-
super(message);
|
|
14
|
-
this.code = code;
|
|
15
|
-
this.status = status;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
async function cliApiRequest(args) {
|
|
19
|
-
const method = args.method ?? "POST";
|
|
20
|
-
let url = `${args.serverUrl.replace(/\/$/, "")}${args.path}`;
|
|
21
|
-
if (args.query) {
|
|
22
|
-
const params = new URLSearchParams(args.query);
|
|
23
|
-
url += `?${params.toString()}`;
|
|
24
|
-
}
|
|
25
|
-
const headers = {
|
|
26
|
-
"Content-Type": "application/json",
|
|
27
|
-
Authorization: `Bearer ${args.authToken}`
|
|
28
|
-
};
|
|
29
|
-
const init = { method, headers };
|
|
30
|
-
if (args.body !== void 0 && args.body !== null && method !== "GET") {
|
|
31
|
-
init.body = JSON.stringify(args.body);
|
|
32
|
-
}
|
|
33
|
-
let response;
|
|
34
|
-
try {
|
|
35
|
-
response = await fetch(url, init);
|
|
36
|
-
} catch (error) {
|
|
37
|
-
throw new CliApiError(`\u8BF7\u6C42\u5931\u8D25: ${error.message}`, "NETWORK_ERROR", 0);
|
|
38
|
-
}
|
|
39
|
-
let data;
|
|
40
|
-
try {
|
|
41
|
-
data = await response.json();
|
|
42
|
-
} catch {
|
|
43
|
-
throw new CliApiError(
|
|
44
|
-
`\u670D\u52A1\u7AEF\u8FD4\u56DE\u975E JSON \u54CD\u5E94 (HTTP ${response.status})`,
|
|
45
|
-
"INVALID_RESPONSE",
|
|
46
|
-
response.status
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
if (!response.ok || data.success !== true) {
|
|
50
|
-
const errorObj = data.error ?? {};
|
|
51
|
-
const message = errorObj.message || data.message || `\u8BF7\u6C42\u5931\u8D25 (HTTP ${response.status})`;
|
|
52
|
-
const code = errorObj.code || `HTTP_${response.status}`;
|
|
53
|
-
throw new CliApiError(message, code, response.status);
|
|
54
|
-
}
|
|
55
|
-
return data;
|
|
56
|
-
}
|
|
57
|
-
function printCliError(error) {
|
|
58
|
-
if (error instanceof CliApiError) {
|
|
59
|
-
process.stderr.write(`\u9519\u8BEF [${error.code}]: ${error.message}
|
|
60
|
-
`);
|
|
61
|
-
} else if (error instanceof Error) {
|
|
62
|
-
process.stderr.write(`\u9519\u8BEF: ${error.message}
|
|
63
|
-
`);
|
|
64
|
-
} else {
|
|
65
|
-
process.stderr.write(`\u9519\u8BEF: ${String(error)}
|
|
66
|
-
`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
function resolveCliContext(args, env) {
|
|
70
|
-
const serverUrl = resolveServerUrl(args, env);
|
|
71
|
-
const { authToken, userId } = requireTokenUser(args, env, false);
|
|
72
|
-
return { serverUrl, authToken, userId };
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// packages/cli/cliOutputHelpers.ts
|
|
76
|
-
function pickDefined(obj) {
|
|
77
|
-
const result = {};
|
|
78
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
79
|
-
if (value !== void 0 && value !== null) result[key] = value;
|
|
80
|
-
}
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
function formatFields(fields, indent = "") {
|
|
84
|
-
const maxKeyLen = fields.reduce((max, [k]) => Math.max(max, k.length), 0);
|
|
85
|
-
const lines = fields.map(([key, value]) => {
|
|
86
|
-
const display = value === void 0 || value === null ? "-" : String(value);
|
|
87
|
-
return `${indent}${key.padEnd(maxKeyLen)}: ${display}`;
|
|
88
|
-
});
|
|
89
|
-
return lines.join("\n");
|
|
90
|
-
}
|
|
91
|
-
function outputResult(data, shouldOutputJson, formatter, output = process.stdout) {
|
|
92
|
-
if (shouldOutputJson) {
|
|
93
|
-
output.write(`${JSON.stringify(data, null, 2)}
|
|
94
|
-
`);
|
|
95
|
-
} else {
|
|
96
|
-
formatter();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export {
|
|
101
|
-
cliApiRequest,
|
|
102
|
-
printCliError,
|
|
103
|
-
resolveCliContext,
|
|
104
|
-
pickDefined,
|
|
105
|
-
formatFields,
|
|
106
|
-
outputResult
|
|
107
|
-
};
|
package/chunk-GFUIQ4RY.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildSkillDocMarkdown
|
|
3
|
-
} from "./chunk-VC6OZXO5.js";
|
|
4
|
-
|
|
5
|
-
// packages/cli/docPageHelpers.ts
|
|
6
|
-
import { readFileSync } from "node:fs";
|
|
7
|
-
import { ulid } from "ulid";
|
|
8
|
-
function getCliArg(args, flag) {
|
|
9
|
-
const idx = args.indexOf(flag);
|
|
10
|
-
return idx !== -1 ? args[idx + 1] : void 0;
|
|
11
|
-
}
|
|
12
|
-
function readBodyArg(args, fallback = "") {
|
|
13
|
-
const bodyFile = getCliArg(args, "--body-file");
|
|
14
|
-
if (bodyFile !== void 0) {
|
|
15
|
-
return readFileSync(bodyFile, "utf8");
|
|
16
|
-
}
|
|
17
|
-
return getCliArg(args, "--body") ?? fallback;
|
|
18
|
-
}
|
|
19
|
-
function textToSlate(text) {
|
|
20
|
-
return text.split("\n").map((line) => ({
|
|
21
|
-
type: "paragraph",
|
|
22
|
-
children: [{ text: line }]
|
|
23
|
-
}));
|
|
24
|
-
}
|
|
25
|
-
function createPageId() {
|
|
26
|
-
return ulid();
|
|
27
|
-
}
|
|
28
|
-
function buildPageKey(userId, pageId) {
|
|
29
|
-
return `page-${userId}-${pageId}`;
|
|
30
|
-
}
|
|
31
|
-
function buildPageRecord(args) {
|
|
32
|
-
const { dbKey, pageId, title, spaceId, content, existing, meta, slateData } = args;
|
|
33
|
-
const now = Date.now();
|
|
34
|
-
const createdAt = typeof existing?.createdAt === "number" ? existing.createdAt : now;
|
|
35
|
-
const created = typeof existing?.created === "string" ? existing.created : new Date(createdAt).toISOString();
|
|
36
|
-
const nextRecord = {
|
|
37
|
-
...existing ?? {},
|
|
38
|
-
id: existing?.id ?? pageId,
|
|
39
|
-
dbKey,
|
|
40
|
-
type: "page",
|
|
41
|
-
title,
|
|
42
|
-
spaceId,
|
|
43
|
-
content,
|
|
44
|
-
updatedAt: now,
|
|
45
|
-
createdAt,
|
|
46
|
-
created
|
|
47
|
-
};
|
|
48
|
-
if (meta !== void 0) {
|
|
49
|
-
if (meta === null) {
|
|
50
|
-
delete nextRecord.meta;
|
|
51
|
-
} else {
|
|
52
|
-
nextRecord.meta = meta;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (slateData !== void 0) {
|
|
56
|
-
if (slateData === null) {
|
|
57
|
-
delete nextRecord.slateData;
|
|
58
|
-
} else {
|
|
59
|
-
nextRecord.slateData = slateData;
|
|
60
|
-
}
|
|
61
|
-
} else if (!existing?.slateData) {
|
|
62
|
-
nextRecord.slateData = textToSlate(content);
|
|
63
|
-
}
|
|
64
|
-
return nextRecord;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// packages/cli/docSkillHelpers.ts
|
|
68
|
-
function normalizeSkillSeed(input) {
|
|
69
|
-
return input.trim().toLowerCase().replace(/[^a-z0-9\u4e00-\u9fa5]+/g, "-").replace(/^-+|-+$/g, "");
|
|
70
|
-
}
|
|
71
|
-
function deterministicId(prefix, seed) {
|
|
72
|
-
let h = 2166136261;
|
|
73
|
-
for (let i = 0; i < seed.length; i++) {
|
|
74
|
-
h ^= seed.charCodeAt(i);
|
|
75
|
-
h = h * 16777619 >>> 0;
|
|
76
|
-
}
|
|
77
|
-
const suffix = h.toString(36).toUpperCase().padStart(14, "0");
|
|
78
|
-
return (prefix + suffix).slice(0, 26);
|
|
79
|
-
}
|
|
80
|
-
function buildSkillDocId(input) {
|
|
81
|
-
return deterministicId("01SK", normalizeSkillSeed(input) || input);
|
|
82
|
-
}
|
|
83
|
-
function buildSkillPageKey(userId, skillId) {
|
|
84
|
-
return buildPageKey(userId, skillId);
|
|
85
|
-
}
|
|
86
|
-
function buildSkillPageRecord(args) {
|
|
87
|
-
const {
|
|
88
|
-
dbKey,
|
|
89
|
-
skillId,
|
|
90
|
-
title,
|
|
91
|
-
spaceId,
|
|
92
|
-
body,
|
|
93
|
-
skillConfig,
|
|
94
|
-
evalConfig,
|
|
95
|
-
workflowConfig,
|
|
96
|
-
existing
|
|
97
|
-
} = args;
|
|
98
|
-
return {
|
|
99
|
-
...buildPageRecord({
|
|
100
|
-
dbKey,
|
|
101
|
-
pageId: skillId,
|
|
102
|
-
title,
|
|
103
|
-
spaceId,
|
|
104
|
-
content: buildSkillDocMarkdown({
|
|
105
|
-
body,
|
|
106
|
-
skillConfig,
|
|
107
|
-
evalConfig,
|
|
108
|
-
workflowConfig
|
|
109
|
-
}),
|
|
110
|
-
existing,
|
|
111
|
-
meta: {
|
|
112
|
-
...existing?.meta ?? {},
|
|
113
|
-
kind: "skill",
|
|
114
|
-
skillConfig,
|
|
115
|
-
...evalConfig ? { evalConfig } : {},
|
|
116
|
-
...workflowConfig ? { workflowConfig } : {}
|
|
117
|
-
},
|
|
118
|
-
slateData: null
|
|
119
|
-
})
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
function parseJsonArg(raw, fallback) {
|
|
123
|
-
if (raw === void 0) return fallback;
|
|
124
|
-
return JSON.parse(raw);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export {
|
|
128
|
-
readBodyArg,
|
|
129
|
-
createPageId,
|
|
130
|
-
buildPageKey,
|
|
131
|
-
buildPageRecord,
|
|
132
|
-
buildSkillDocId,
|
|
133
|
-
buildSkillPageKey,
|
|
134
|
-
buildSkillPageRecord,
|
|
135
|
-
parseJsonArg
|
|
136
|
-
};
|
package/chunk-KFEVY3ST.js
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isRecord
|
|
3
|
-
} from "./chunk-KUG52IAP.js";
|
|
4
|
-
import {
|
|
5
|
-
asOptionalTrimmedString
|
|
6
|
-
} from "./chunk-G3SUCT4W.js";
|
|
7
|
-
|
|
8
|
-
// packages/agent-runtime/openAiCompatibleMessages.ts
|
|
9
|
-
function preserveAgentStateFields(source, target, options) {
|
|
10
|
-
const mutableTarget = target;
|
|
11
|
-
if (source.role === "assistant") {
|
|
12
|
-
if (!options?.stripReasoningContent && typeof source.reasoning_content === "string") {
|
|
13
|
-
mutableTarget.reasoning_content = source.reasoning_content;
|
|
14
|
-
}
|
|
15
|
-
if (Array.isArray(source.tool_calls)) {
|
|
16
|
-
mutableTarget.tool_calls = source.tool_calls;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (source.role === "tool") {
|
|
20
|
-
const toolCallId = typeof source.tool_call_id === "string" ? source.tool_call_id.trim() : typeof source.toolCallId === "string" ? source.toolCallId.trim() : "";
|
|
21
|
-
if (toolCallId) mutableTarget.tool_call_id = toolCallId;
|
|
22
|
-
}
|
|
23
|
-
return target;
|
|
24
|
-
}
|
|
25
|
-
function toOpenAiCompatibleMessages(messages, options) {
|
|
26
|
-
return messages.map(
|
|
27
|
-
(message) => preserveAgentStateFields(message, {
|
|
28
|
-
role: message.role,
|
|
29
|
-
content: message.content ?? ""
|
|
30
|
-
}, options)
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
function shouldStripReasoningContentForOutbound(provider, model) {
|
|
34
|
-
const p = provider?.trim().toLowerCase();
|
|
35
|
-
const m = model?.trim().toLowerCase();
|
|
36
|
-
if (!p || !m) return false;
|
|
37
|
-
if (p === "deepseek" || p === "nolo") return m === "deepseek-v4-flash";
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// packages/integrations/openai/responsesHelpers.ts
|
|
42
|
-
var RESPONSES_TOP_LEVEL_SCHEMA_KEYS = ["anyOf", "oneOf", "allOf", "enum", "not"];
|
|
43
|
-
var sanitizeResponsesParameters = (parameters) => {
|
|
44
|
-
if (!isRecord(parameters)) {
|
|
45
|
-
return parameters;
|
|
46
|
-
}
|
|
47
|
-
const next = { ...parameters };
|
|
48
|
-
for (const key of RESPONSES_TOP_LEVEL_SCHEMA_KEYS) {
|
|
49
|
-
delete next[key];
|
|
50
|
-
}
|
|
51
|
-
return next;
|
|
52
|
-
};
|
|
53
|
-
var appendTextPart = (parts, text, role) => {
|
|
54
|
-
if (!text) return;
|
|
55
|
-
const last = parts.at(-1);
|
|
56
|
-
const textType = role === "assistant" ? "output_text" : "input_text";
|
|
57
|
-
if (last?.type === textType) {
|
|
58
|
-
last.text += text;
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
parts.push({ type: textType, text });
|
|
62
|
-
};
|
|
63
|
-
var normalizeMessageParts = (content, role) => {
|
|
64
|
-
if (typeof content === "string") {
|
|
65
|
-
if (!content) return [];
|
|
66
|
-
return [
|
|
67
|
-
{
|
|
68
|
-
type: role === "assistant" ? "output_text" : "input_text",
|
|
69
|
-
text: content
|
|
70
|
-
}
|
|
71
|
-
];
|
|
72
|
-
}
|
|
73
|
-
const parts = [];
|
|
74
|
-
for (const part of content ?? []) {
|
|
75
|
-
const typedPart = part;
|
|
76
|
-
if (typedPart?.type === "text" && typeof typedPart.text === "string") {
|
|
77
|
-
appendTextPart(parts, typedPart.text, role);
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
if (typedPart?.type === "image_url" && typeof typedPart.image_url?.url === "string" && typedPart.image_url.url) {
|
|
81
|
-
if (role === "assistant") continue;
|
|
82
|
-
parts.push({
|
|
83
|
-
type: "input_image",
|
|
84
|
-
image_url: typedPart.image_url.url,
|
|
85
|
-
detail: typedPart.image_url.detail
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return parts;
|
|
90
|
-
};
|
|
91
|
-
var normalizeToolOutput = (content) => {
|
|
92
|
-
if (typeof content === "string") return content;
|
|
93
|
-
return JSON.stringify(content ?? "");
|
|
94
|
-
};
|
|
95
|
-
var toResponsesTools = (tools) => {
|
|
96
|
-
if (!Array.isArray(tools) || tools.length === 0) return void 0;
|
|
97
|
-
return tools.map((tool) => {
|
|
98
|
-
const fn = tool?.function;
|
|
99
|
-
if (!fn?.name) return null;
|
|
100
|
-
return {
|
|
101
|
-
type: "function",
|
|
102
|
-
name: fn.name,
|
|
103
|
-
description: fn.description,
|
|
104
|
-
parameters: sanitizeResponsesParameters(fn.parameters),
|
|
105
|
-
strict: fn.strict
|
|
106
|
-
};
|
|
107
|
-
}).filter(Boolean);
|
|
108
|
-
};
|
|
109
|
-
var convertMessagesToResponsesInput = (messages, options) => {
|
|
110
|
-
const input = [];
|
|
111
|
-
for (const message of messages) {
|
|
112
|
-
if (!message?.role) continue;
|
|
113
|
-
if (message.role === "tool") {
|
|
114
|
-
if (!message.tool_call_id) continue;
|
|
115
|
-
input.push({
|
|
116
|
-
type: "function_call_output",
|
|
117
|
-
call_id: message.tool_call_id,
|
|
118
|
-
output: normalizeToolOutput(message.content)
|
|
119
|
-
});
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
const role = message.role;
|
|
123
|
-
if (role === "assistant" && !options?.stripReasoningContent && typeof message.reasoning_content === "string" && message.reasoning_content) {
|
|
124
|
-
input.push({ type: "reasoning", content: message.reasoning_content });
|
|
125
|
-
}
|
|
126
|
-
const contentParts = normalizeMessageParts(message.content, role);
|
|
127
|
-
if (contentParts.length > 0) {
|
|
128
|
-
input.push({
|
|
129
|
-
type: "message",
|
|
130
|
-
role,
|
|
131
|
-
content: contentParts
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
if (role === "assistant" && Array.isArray(message.content)) {
|
|
135
|
-
const replayImages = message.content.map((part) => part).filter(
|
|
136
|
-
(part) => part?.type === "image_url" && typeof part.image_url?.url === "string" && Boolean(part.image_url.url)
|
|
137
|
-
).map((part) => ({
|
|
138
|
-
type: "input_image",
|
|
139
|
-
image_url: part.image_url.url,
|
|
140
|
-
detail: part.image_url.detail
|
|
141
|
-
}));
|
|
142
|
-
if (replayImages.length > 0) {
|
|
143
|
-
input.push({
|
|
144
|
-
type: "message",
|
|
145
|
-
role: "user",
|
|
146
|
-
content: replayImages
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
if (role === "assistant" && Array.isArray(message.tool_calls)) {
|
|
151
|
-
for (const toolCall of message.tool_calls) {
|
|
152
|
-
if (!toolCall?.id || !toolCall.function?.name) continue;
|
|
153
|
-
input.push({
|
|
154
|
-
type: "function_call",
|
|
155
|
-
call_id: toolCall.id,
|
|
156
|
-
name: toolCall.function.name,
|
|
157
|
-
arguments: typeof toolCall.function.arguments === "string" ? toolCall.function.arguments : JSON.stringify(toolCall.function.arguments ?? {})
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return input;
|
|
163
|
-
};
|
|
164
|
-
var extractTextFromResponseOutput = (response) => {
|
|
165
|
-
const parts = [];
|
|
166
|
-
for (const item of response?.output ?? []) {
|
|
167
|
-
if (item?.type !== "message") continue;
|
|
168
|
-
for (const content of item.content ?? []) {
|
|
169
|
-
if (content?.type === "output_text" && typeof content.text === "string") {
|
|
170
|
-
parts.push(content.text);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return parts.join("");
|
|
175
|
-
};
|
|
176
|
-
var toDataUrl = (base64Data, mimeType) => {
|
|
177
|
-
const normalizedMimeType = asOptionalTrimmedString(mimeType) ?? "image/png";
|
|
178
|
-
return `data:${normalizedMimeType};base64,${base64Data}`;
|
|
179
|
-
};
|
|
180
|
-
var extractImagePartsFromResponseOutput = (response) => {
|
|
181
|
-
const images = [];
|
|
182
|
-
for (const item of response?.output ?? []) {
|
|
183
|
-
if (item?.type === "image_generation_call") {
|
|
184
|
-
const result = asOptionalTrimmedString(item.result);
|
|
185
|
-
if (result) {
|
|
186
|
-
const outputFormat = asOptionalTrimmedString(item.output_format);
|
|
187
|
-
images.push({
|
|
188
|
-
type: "image_url",
|
|
189
|
-
image_url: {
|
|
190
|
-
url: toDataUrl(
|
|
191
|
-
result,
|
|
192
|
-
outputFormat ? `image/${outputFormat}` : void 0
|
|
193
|
-
)
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
if (item?.type !== "message") continue;
|
|
200
|
-
for (const content of item.content ?? []) {
|
|
201
|
-
const result = asOptionalTrimmedString(content?.result);
|
|
202
|
-
if (content?.type === "output_image" && result) {
|
|
203
|
-
images.push({
|
|
204
|
-
type: "image_url",
|
|
205
|
-
image_url: {
|
|
206
|
-
url: toDataUrl(
|
|
207
|
-
result,
|
|
208
|
-
content.mime_type ?? content.mimeType ?? null
|
|
209
|
-
)
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
return images;
|
|
216
|
-
};
|
|
217
|
-
var extractToolCallsFromResponseOutput = (response) => {
|
|
218
|
-
const calls = [];
|
|
219
|
-
for (const item of response?.output ?? []) {
|
|
220
|
-
if (item?.type !== "function_call") continue;
|
|
221
|
-
if (!item.call_id || !item.name) continue;
|
|
222
|
-
calls.push({
|
|
223
|
-
id: item.call_id,
|
|
224
|
-
type: "function",
|
|
225
|
-
function: {
|
|
226
|
-
name: item.name,
|
|
227
|
-
arguments: typeof item.arguments === "string" ? item.arguments : JSON.stringify(item.arguments ?? {})
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
return calls;
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
// packages/core/chat/imageParts.ts
|
|
235
|
-
function isImageUrlPart(part) {
|
|
236
|
-
return isRecord(part) && part.type === "image_url";
|
|
237
|
-
}
|
|
238
|
-
function hasImageParts(messages) {
|
|
239
|
-
return messages.some(
|
|
240
|
-
(message) => Array.isArray(message.content) && message.content.some(isImageUrlPart)
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
export {
|
|
245
|
-
isImageUrlPart,
|
|
246
|
-
hasImageParts,
|
|
247
|
-
preserveAgentStateFields,
|
|
248
|
-
toOpenAiCompatibleMessages,
|
|
249
|
-
shouldStripReasoningContentForOutbound,
|
|
250
|
-
toResponsesTools,
|
|
251
|
-
convertMessagesToResponsesInput,
|
|
252
|
-
extractTextFromResponseOutput,
|
|
253
|
-
extractImagePartsFromResponseOutput,
|
|
254
|
-
extractToolCallsFromResponseOutput
|
|
255
|
-
};
|
|
File without changes
|