nolo-cli 0.8.0-alpha.2 → 0.8.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/_executeModel-WRUCQIV5.js +205 -0
- package/action-R4M4ORGA.js +28 -0
- package/addContentAction-UYFFTEWJ.js +26 -0
- package/addDialogAgentAction-OT4XZAVP.js +68 -0
- package/agentDeleteCommand-5DD2IM3J.js +327 -0
- package/agentEmailCommands-IASM2YBQ.js +628 -0
- package/agentListCommands-I6KZYCIG.js +223 -0
- package/agentMachineCommands-OUP3YQP7.js +425 -0
- package/agentPullCommand-O2MTUAFR.js +122 -0
- package/agentRecordCommands-QKGE2JTA.js +96 -0
- package/agentRunCommand-TVZXUBQ5.js +114 -0
- package/agentRunControl-K4VKNEHF.js +57 -0
- package/agentRuntimeLocal-ZYEIPTY4.js +104 -0
- package/agentSlice-T4PMW7W6.js +42 -0
- package/authCommand-EB5JSOX5.js +581 -0
- package/authCommands-XPEHTKSM.js +35 -0
- package/chunk-2EHX7F5G.js +1948 -0
- package/chunk-2FTTDCD4.js +675 -0
- package/chunk-3ASDTTEI.js +1774 -0
- package/chunk-3EUW3WEO.js +8 -0
- package/chunk-3LY4F7SV.js +9293 -0
- package/chunk-4CQLVGRV.js +50 -0
- package/chunk-4FBRSEV4.js +573 -0
- package/chunk-4IJYA27C.js +342 -0
- package/chunk-4QEWT7KD.js +933 -0
- package/chunk-4SN6J65J.js +38 -0
- package/chunk-4VNS5WPM.js +42 -0
- package/chunk-4ZDM73SD.js +34 -0
- package/chunk-5CS33IBL.js +301 -0
- package/chunk-5KLGBAAR.js +386 -0
- package/chunk-5MIDPSSK.js +206 -0
- package/chunk-5MMAK75Q.js +15 -0
- package/chunk-5W3VUFOX.js +34 -0
- package/chunk-63W5N6P3.js +150 -0
- package/chunk-6HYVJV7B.js +102 -0
- package/chunk-6WD3OOJS.js +20 -0
- package/chunk-7DAJ4AI4.js +191 -0
- package/chunk-7KCUSYT2.js +354 -0
- package/chunk-7T5PWAZN.js +171 -0
- package/chunk-AFON4QUU.js +112 -0
- package/chunk-AGFH73SK.js +239 -0
- package/chunk-ATNTHIZI.js +13 -0
- package/chunk-AVMKZHBC.js +85 -0
- package/chunk-AZPCASRE.js +36 -0
- package/chunk-BBYVOSU2.js +792 -0
- package/chunk-BCIOM4NZ.js +1078 -0
- package/chunk-C3RUNRHT.js +51 -0
- package/chunk-C4FTUXVF.js +146 -0
- package/chunk-CF2WZF4N.js +134 -0
- package/chunk-CF7PE763.js +10 -0
- package/chunk-CKOJQDKR.js +198 -0
- package/chunk-CMKUBIGW.js +1550 -0
- package/chunk-CWMSB67P.js +34 -0
- package/chunk-DCOA4QSN.js +105 -0
- package/chunk-DFFIZ25G.js +30 -0
- package/chunk-DWLEOOGR.js +8 -0
- package/chunk-DZ3XJVET.js +231 -0
- package/chunk-EHLHSX7R.js +1433 -0
- package/chunk-FM5IVZXO.js +4723 -0
- package/chunk-FVYY6MCS.js +1447 -0
- package/chunk-G3SUCT4W.js +8 -0
- package/chunk-GAKEBQD6.js +30 -0
- package/chunk-GBRG75BQ.js +86 -0
- package/chunk-GLYVN7EQ.js +238 -0
- package/chunk-H33743XH.js +25 -0
- package/chunk-HNMXYYJR.js +12 -0
- package/chunk-HNW7IJSK.js +71 -0
- package/chunk-I42VC5KR.js +15 -0
- package/chunk-IDZTNRP2.js +85 -0
- package/chunk-IHBCLYEE.js +22310 -0
- package/chunk-IJGXKGXW.js +421 -0
- package/chunk-ISNCLGUZ.js +146 -0
- package/chunk-IWX4UW2E.js +548 -0
- package/chunk-JBTJAPUF.js +35 -0
- package/chunk-JEXVIMYZ.js +55 -0
- package/chunk-JRKKFRAV.js +537 -0
- package/chunk-JZPBVBIY.js +94 -0
- package/chunk-K6BPOQLF.js +2052 -0
- package/chunk-K777STIO.js +478 -0
- package/chunk-KKY4B2Q2.js +21 -0
- package/chunk-KQHGZWSV.js +63 -0
- package/chunk-KUG52IAP.js +8 -0
- package/chunk-KX6YBIHG.js +8 -0
- package/chunk-LCBAMY2M.js +60 -0
- package/chunk-LM6IYQ3F.js +16 -0
- package/chunk-LTRXGFMS.js +83 -0
- package/chunk-M76ECQRD.js +13658 -0
- package/chunk-MNJDFJND.js +222 -0
- package/chunk-MRC4Q34M.js +188 -0
- package/chunk-MTU75CZ2.js +91 -0
- package/chunk-N54XAP77.js +19 -0
- package/chunk-O2ZNTTET.js +3272 -0
- package/chunk-O4BU24WZ.js +3212 -0
- package/chunk-OLZBQWZU.js +6 -0
- package/chunk-OPZYGHUC.js +89 -0
- package/chunk-OWOHNGCN.js +50 -0
- package/chunk-P3PKED2I.js +962 -0
- package/chunk-PFTAG6DY.js +1939 -0
- package/chunk-PMKQGGGM.js +221 -0
- package/chunk-PP4S6RTL.js +175 -0
- package/chunk-QJ7FZNYN.js +939 -0
- package/chunk-QSJ3HFEF.js +8 -0
- package/chunk-RGIM3WLT.js +113 -0
- package/chunk-RL776AGR.js +190 -0
- package/chunk-ROWQEJRP.js +139 -0
- package/chunk-S7Z2HMCN.js +25 -0
- package/chunk-SDJDLO5W.js +628 -0
- package/chunk-SOTZ6RDN.js +69 -0
- package/chunk-TILFE6LV.js +381 -0
- package/chunk-TIMLUWQA.js +231 -0
- package/chunk-TISCADJH.js +807 -0
- package/chunk-U4TRT5V4.js +246 -0
- package/chunk-U6VC4MU4.js +8 -0
- package/chunk-UAD2WT54.js +64 -0
- package/chunk-VC6OZXO5.js +298 -0
- package/chunk-VF4K2QE6.js +21 -0
- package/chunk-VHBWHNVT.js +59 -0
- package/chunk-VIDPVFP3.js +20 -0
- package/chunk-VP4WJWKW.js +8882 -0
- package/chunk-VVX233PH.js +482 -0
- package/chunk-W4NVOSFF.js +37 -0
- package/chunk-WI4XWASA.js +208 -0
- package/chunk-WWC7I6TA.js +8 -0
- package/chunk-WZSRQNQG.js +2587 -0
- package/chunk-XBROXIGL.js +3066 -0
- package/chunk-XENYHRUE.js +104 -0
- package/chunk-Y5GCAMGP.js +9 -0
- package/chunk-YN4XDB7B.js +9036 -0
- package/chunk-YPRZSPF3.js +148 -0
- package/chunk-Z4NR32XR.js +50 -0
- package/chunk-Z6EKEXJW.js +138 -0
- package/chunk-ZDRZMLKO.js +27339 -0
- package/chunk-ZNFJWEN4.js +56 -0
- package/cliExecutor-K3F7DMRO.js +36 -0
- package/clipboardy-BVE3LVEH.js +12001 -0
- package/createAgentAutomationAction-CCABEOM6.js +866 -0
- package/createDialogAction-YPKF5ITI.js +55 -0
- package/createPageAction-YEZ7EK5F.js +172 -0
- package/db-HCJ5PRB5.js +271 -0
- package/dbSlice-QPVZHBOE.js +60 -0
- package/deleteFile-SV5MS23W.js +41 -0
- package/dialogCommands-4IX4XIZE.js +63 -0
- package/dialogSlice-OVTO7QGW.js +148 -0
- package/docCreateCommands-SIL3NPGT.js +220 -0
- package/docDeleteCommands-7IOMLUS4.js +181 -0
- package/docReadCommands-FNFXUA5L.js +134 -0
- package/docStore-ZAYLW2HN.js +98 -0
- package/docUpdateCommands-X2HNDVUC.js +318 -0
- package/fetchMessages-KTNM7QAR.js +17 -0
- package/getPricing-3E6UNPKL.js +30 -0
- package/handleSendMessageAction-TZMZ4EP5.js +185 -0
- package/index.js +188 -112958
- package/lib-FYYBQIXS.js +19839 -0
- package/localDialogRead-2VRI24F4.js +26 -0
- package/localFirstLog-DHNOY2NA.js +19 -0
- package/localRuntimeAuthority-TEGCOWX4.js +471 -0
- package/localRuntimeDb-LGDF6FQP.js +12 -0
- package/machineCommands-M4ZJZIMS.js +781 -0
- package/machineInfo-M6KB6HZN.js +10 -0
- package/machineWsRunDispatch-TPJAUGLP.js +112 -0
- package/memoryCommands-O4MIPIWQ.js +476 -0
- package/models-4OPOOLFS.js +9 -0
- package/offlineMarxistsAgentCommand-BCPJITJL.js +242 -0
- package/package.json +4 -23
- package/read-EBMWX4Z6.js +17 -0
- package/readDocTool-2MWHSTQE.js +16 -0
- package/readlineWorkspace-OMCIU3WT.js +5682 -0
- package/removeDialogAgentAction-SNZ662NP.js +73 -0
- package/runAgentClientLoop-H6NGOUAM.js +293 -0
- package/runtimeDoctorCommands-LRHLPDRC.js +289 -0
- package/setDialogExtraReferencesAction-XDI2KM2N.js +60 -0
- package/setPrimaryDialogAgentAction-PYEC4N4Z.js +80 -0
- package/settingSlice-NOWHY2FK.js +199 -0
- package/skillDiscovery-UGSQGX2U.js +16 -0
- package/skillSummaryMarker-42HKSXYY.js +9 -0
- package/slateToRenderMarkdown-Y5IYN73U.js +7 -0
- package/slateUtils-2M7MUTWX.js +19 -0
- package/spaceCommands-E7VOF4LO.js +450 -0
- package/spaceSlice-QHBPICA2.js +149 -0
- package/streamAgentChatTurn-3XTBA2HN.js +4510 -0
- package/tableCommands-R5UCM63M.js +1286 -0
- package/toolApiClient-QI3YBNWB.js +26 -0
- package/tools-GHLZ3XD6.js +87 -0
- package/tuiSummaryLlmCaller-RV3THLZF.js +78 -0
- package/understanding-3CUQQ6SV.js +271 -0
- package/updateCommands-VOSPKXFF.js +31 -0
- package/updateDialogTitleAction-XA2OZTLP.js +188 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveNoloHome
|
|
3
|
+
} from "./chunk-LM6IYQ3F.js";
|
|
4
|
+
|
|
5
|
+
// packages/database-engine/cliAuthorityBrokerClient.ts
|
|
6
|
+
import { createConnection } from "node:net";
|
|
7
|
+
var DEFAULT_ITERATOR_PAGE_SIZE = 200;
|
|
8
|
+
var CliAuthorityBrokerUnavailableError = class extends Error {
|
|
9
|
+
reason = "cli_authority_broker_unavailable";
|
|
10
|
+
status = 503;
|
|
11
|
+
endpoint;
|
|
12
|
+
constructor(endpoint, cause) {
|
|
13
|
+
super(`CLI authority broker unavailable at ${endpoint}. Start the local authority broker and retry.`);
|
|
14
|
+
this.name = "CliAuthorityBrokerUnavailableError";
|
|
15
|
+
this.endpoint = endpoint;
|
|
16
|
+
if (cause !== void 0) {
|
|
17
|
+
this.cause = cause;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var CliAuthorityBrokerProtocolError = class extends Error {
|
|
22
|
+
code;
|
|
23
|
+
retryable;
|
|
24
|
+
constructor(error) {
|
|
25
|
+
super(error.message);
|
|
26
|
+
this.name = "CliAuthorityBrokerProtocolError";
|
|
27
|
+
this.code = error.code;
|
|
28
|
+
this.retryable = error.retryable === true;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
function isCliAuthorityBrokerUnavailableError(error) {
|
|
32
|
+
return error instanceof CliAuthorityBrokerUnavailableError || typeof error === "object" && error !== null && error.reason === "cli_authority_broker_unavailable" && error.status === 503;
|
|
33
|
+
}
|
|
34
|
+
function isCliAuthorityBrokerProtocolError(error) {
|
|
35
|
+
return error instanceof CliAuthorityBrokerProtocolError;
|
|
36
|
+
}
|
|
37
|
+
function resolveBrokerSocketTarget(endpoint) {
|
|
38
|
+
if (endpoint.startsWith("unix://")) {
|
|
39
|
+
return { kind: "unix", path: endpoint.slice("unix://".length) };
|
|
40
|
+
}
|
|
41
|
+
if (endpoint.startsWith("tcp://")) {
|
|
42
|
+
const url = new URL(endpoint);
|
|
43
|
+
return {
|
|
44
|
+
kind: "tcp",
|
|
45
|
+
host: url.hostname,
|
|
46
|
+
port: Number(url.port)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
throw new Error(`Unsupported CLI authority broker endpoint: ${endpoint}`);
|
|
50
|
+
}
|
|
51
|
+
function createCliAuthorityBrokerSocketInvoker(options) {
|
|
52
|
+
const target = resolveBrokerSocketTarget(options.endpoint);
|
|
53
|
+
return async (request) => {
|
|
54
|
+
return await new Promise((resolve, reject) => {
|
|
55
|
+
const socket = target.kind === "unix" ? createConnection(target.path) : createConnection({ host: target.host, port: target.port });
|
|
56
|
+
let responseBuffer = "";
|
|
57
|
+
let settled = false;
|
|
58
|
+
const timeout = setTimeout(() => {
|
|
59
|
+
finish(() => {
|
|
60
|
+
socket.destroy();
|
|
61
|
+
reject(new Error(`CLI authority broker request at ${options.endpoint} timed out after 5000ms`));
|
|
62
|
+
});
|
|
63
|
+
}, 5e3);
|
|
64
|
+
const finish = (fn) => {
|
|
65
|
+
if (settled) return;
|
|
66
|
+
settled = true;
|
|
67
|
+
clearTimeout(timeout);
|
|
68
|
+
fn();
|
|
69
|
+
};
|
|
70
|
+
socket.setEncoding("utf8");
|
|
71
|
+
socket.on("connect", () => {
|
|
72
|
+
socket.write(`${JSON.stringify(request)}
|
|
73
|
+
`);
|
|
74
|
+
});
|
|
75
|
+
socket.on("data", (chunk) => {
|
|
76
|
+
responseBuffer += chunk;
|
|
77
|
+
});
|
|
78
|
+
socket.on("end", () => {
|
|
79
|
+
finish(() => {
|
|
80
|
+
const payload = responseBuffer.trim();
|
|
81
|
+
if (!payload) {
|
|
82
|
+
reject(new Error(`CLI authority broker at ${options.endpoint} returned no response`));
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
resolve(JSON.parse(payload));
|
|
87
|
+
} catch (error) {
|
|
88
|
+
reject(error);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
socket.on("error", (error) => {
|
|
93
|
+
finish(() => reject(error));
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async function invokeBrokerRequest(options, request) {
|
|
99
|
+
try {
|
|
100
|
+
const response = await options.invoke(request);
|
|
101
|
+
if (response.ok) return response.result;
|
|
102
|
+
if (response.error.code === "BROKER_UNAVAILABLE") {
|
|
103
|
+
throw new CliAuthorityBrokerUnavailableError(options.endpoint, response.error);
|
|
104
|
+
}
|
|
105
|
+
throw new CliAuthorityBrokerProtocolError(response.error);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (isCliAuthorityBrokerUnavailableError(error)) throw error;
|
|
108
|
+
if (isCliAuthorityBrokerProtocolError(error)) throw error;
|
|
109
|
+
throw new CliAuthorityBrokerUnavailableError(options.endpoint, error);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function createCliAuthorityBrokerClient(options) {
|
|
113
|
+
const pageSize = options.iteratorPageSize ?? DEFAULT_ITERATOR_PAGE_SIZE;
|
|
114
|
+
return {
|
|
115
|
+
get location() {
|
|
116
|
+
return options.location ?? options.endpoint;
|
|
117
|
+
},
|
|
118
|
+
get status() {
|
|
119
|
+
return options.status ?? "broker";
|
|
120
|
+
},
|
|
121
|
+
async open() {
|
|
122
|
+
await invokeBrokerRequest(options, { type: "status" });
|
|
123
|
+
},
|
|
124
|
+
async close() {
|
|
125
|
+
},
|
|
126
|
+
async get(key) {
|
|
127
|
+
const result = await invokeBrokerRequest(options, { type: "get", key });
|
|
128
|
+
if (result.type !== "get") {
|
|
129
|
+
throw new Error(`CLI authority broker protocol mismatch for get at ${options.endpoint}`);
|
|
130
|
+
}
|
|
131
|
+
return result.value;
|
|
132
|
+
},
|
|
133
|
+
async put(key, value) {
|
|
134
|
+
await invokeBrokerRequest(options, { type: "put", key, value });
|
|
135
|
+
},
|
|
136
|
+
async del(key) {
|
|
137
|
+
await invokeBrokerRequest(options, { type: "del", key });
|
|
138
|
+
},
|
|
139
|
+
async batchWrite(ops) {
|
|
140
|
+
await invokeBrokerRequest(options, { type: "batchWrite", ops });
|
|
141
|
+
},
|
|
142
|
+
createBatch() {
|
|
143
|
+
const ops = [];
|
|
144
|
+
return {
|
|
145
|
+
put(key, value) {
|
|
146
|
+
ops.push({ type: "put", key, value });
|
|
147
|
+
},
|
|
148
|
+
del(key) {
|
|
149
|
+
ops.push({ type: "del", key });
|
|
150
|
+
},
|
|
151
|
+
async write() {
|
|
152
|
+
await invokeBrokerRequest(options, { type: "batchWrite", ops });
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
iterator(iteratorOptions = {}) {
|
|
157
|
+
return async function* iterate() {
|
|
158
|
+
let cursor = void 0;
|
|
159
|
+
while (true) {
|
|
160
|
+
const result = await invokeBrokerRequest(options, {
|
|
161
|
+
type: "iterator",
|
|
162
|
+
options: iteratorOptions,
|
|
163
|
+
cursor,
|
|
164
|
+
limit: pageSize
|
|
165
|
+
});
|
|
166
|
+
if (result.type !== "iterator") {
|
|
167
|
+
throw new Error(
|
|
168
|
+
`CLI authority broker protocol mismatch for iterator at ${options.endpoint}`
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
for (const entry of result.page.entries) {
|
|
172
|
+
yield entry;
|
|
173
|
+
}
|
|
174
|
+
if (result.page.done || !result.page.nextCursor) return;
|
|
175
|
+
cursor = result.page.nextCursor;
|
|
176
|
+
}
|
|
177
|
+
}();
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// packages/database-engine/cliAuthorityStoreDriver.ts
|
|
183
|
+
import path from "node:path";
|
|
184
|
+
function readCliAuthorityDriver(env) {
|
|
185
|
+
const value = env.NOLO_CLI_AUTHORITY_DRIVER?.trim();
|
|
186
|
+
if (value === "broker") {
|
|
187
|
+
return { driver: "broker", invalidDriver: null };
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
driver: "broker",
|
|
191
|
+
invalidDriver: value ? value : null
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function resolveCliAuthorityRunDir(options = {}) {
|
|
195
|
+
return path.join(resolveNoloHome({
|
|
196
|
+
...options,
|
|
197
|
+
env: options.env ?? {}
|
|
198
|
+
}), "run");
|
|
199
|
+
}
|
|
200
|
+
function hashString(value) {
|
|
201
|
+
let hash = 0;
|
|
202
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
203
|
+
hash = (hash << 5) - hash + value.charCodeAt(index) | 0;
|
|
204
|
+
}
|
|
205
|
+
return Math.abs(hash);
|
|
206
|
+
}
|
|
207
|
+
function resolveCliAuthorityBrokerPort(options = {}) {
|
|
208
|
+
const envPort = options.env?.NOLO_CLI_AUTHORITY_BROKER_PORT?.trim();
|
|
209
|
+
if (envPort) {
|
|
210
|
+
const port = Number(envPort);
|
|
211
|
+
if (Number.isInteger(port) && port > 0 && port < 65536) return port;
|
|
212
|
+
}
|
|
213
|
+
const noloHome = resolveNoloHome({
|
|
214
|
+
...options,
|
|
215
|
+
env: options.env ?? {}
|
|
216
|
+
});
|
|
217
|
+
return 47e3 + hashString(noloHome) % 2e3;
|
|
218
|
+
}
|
|
219
|
+
function resolveCliAuthorityStoreDriver(options = {}) {
|
|
220
|
+
return readCliAuthorityDriver(options.env ?? {}).driver;
|
|
221
|
+
}
|
|
222
|
+
function resolveCliAuthorityBrokerSocketPath(options) {
|
|
223
|
+
return path.join(resolveCliAuthorityRunDir(options), "authority-store-broker.sock");
|
|
224
|
+
}
|
|
225
|
+
function resolveCliAuthorityBrokerEndpoint(options) {
|
|
226
|
+
if (options.transport === "tcp") {
|
|
227
|
+
return `tcp://127.0.0.1:${resolveCliAuthorityBrokerPort(options)}`;
|
|
228
|
+
}
|
|
229
|
+
return `unix://${resolveCliAuthorityBrokerSocketPath(options)}`;
|
|
230
|
+
}
|
|
231
|
+
function resolveCliAuthorityBrokerMetadataPath(options) {
|
|
232
|
+
return path.join(resolveCliAuthorityRunDir(options), "authority-store-broker.json");
|
|
233
|
+
}
|
|
234
|
+
function resolveCliAuthorityBrokerHealthPath(options) {
|
|
235
|
+
return path.join(resolveCliAuthorityRunDir(options), "authority-store-broker.health.json");
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export {
|
|
239
|
+
isCliAuthorityBrokerUnavailableError,
|
|
240
|
+
createCliAuthorityBrokerSocketInvoker,
|
|
241
|
+
createCliAuthorityBrokerClient,
|
|
242
|
+
resolveCliAuthorityStoreDriver,
|
|
243
|
+
resolveCliAuthorityBrokerEndpoint,
|
|
244
|
+
resolveCliAuthorityBrokerMetadataPath,
|
|
245
|
+
resolveCliAuthorityBrokerHealthPath
|
|
246
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// packages/create/space/spaceKeys.ts
|
|
2
|
+
var SEPARATOR = "-";
|
|
3
|
+
var SPACE_PREFIX = "space";
|
|
4
|
+
var SPACE_PREFIX_WITH_SEPARATOR = `${SPACE_PREFIX}${SEPARATOR}`;
|
|
5
|
+
var normalizeSpaceId = (spaceId) => {
|
|
6
|
+
if (!spaceId) return spaceId;
|
|
7
|
+
return spaceId.startsWith(SPACE_PREFIX_WITH_SEPARATOR) ? spaceId.slice(SPACE_PREFIX_WITH_SEPARATOR.length) : spaceId;
|
|
8
|
+
};
|
|
9
|
+
var createSpaceKey = {
|
|
10
|
+
// 空间基础信息的key
|
|
11
|
+
space: (spaceId) => {
|
|
12
|
+
return [SPACE_PREFIX, normalizeSpaceId(spaceId)].join(SEPARATOR);
|
|
13
|
+
},
|
|
14
|
+
// 空间成员的key
|
|
15
|
+
member: (userId, spaceId) => {
|
|
16
|
+
return [SPACE_PREFIX, "member", userId, normalizeSpaceId(spaceId)].join(
|
|
17
|
+
SEPARATOR
|
|
18
|
+
);
|
|
19
|
+
},
|
|
20
|
+
// 查询用户所在的所有空间的范围
|
|
21
|
+
memberRange: (userId) => {
|
|
22
|
+
return {
|
|
23
|
+
start: [SPACE_PREFIX, "member", userId, ""].join(SEPARATOR),
|
|
24
|
+
end: [SPACE_PREFIX, "member", userId, "\uFFFF"].join(SEPARATOR)
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* 预留:未来若出现“按用户、按空间、且必须跨设备同步”的空间级偏好,
|
|
29
|
+
* 统一使用这个 key family。当前产品主链不要依赖它。
|
|
30
|
+
*/
|
|
31
|
+
setting: (userId, spaceId) => {
|
|
32
|
+
return [SPACE_PREFIX, "setting", userId, normalizeSpaceId(spaceId)].join(
|
|
33
|
+
SEPARATOR
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* 预留:未来如确实需要批量读取空间级远端偏好,再使用这个范围。
|
|
38
|
+
*/
|
|
39
|
+
settingRange: (userId) => {
|
|
40
|
+
return {
|
|
41
|
+
start: [SPACE_PREFIX, "setting", userId, ""].join(SEPARATOR),
|
|
42
|
+
end: [SPACE_PREFIX, "setting", userId, "\uFFFF"].join(SEPARATOR)
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
// 从成员key中提取空间key
|
|
46
|
+
// 成员 key 格式: space-member-{userId}-{spaceId}
|
|
47
|
+
// userId 是单段(无连字符),spaceId 是 ULID(无连字符)
|
|
48
|
+
spaceFromMember: (memberKey) => {
|
|
49
|
+
const parts = memberKey.split(SEPARATOR);
|
|
50
|
+
if (parts.length < 4) return "";
|
|
51
|
+
const spaceId = parts[parts.length - 1];
|
|
52
|
+
return [SPACE_PREFIX, spaceId].join(SEPARATOR);
|
|
53
|
+
},
|
|
54
|
+
// 从成员key中提取空间ID
|
|
55
|
+
spaceIdFromMember: (memberKey) => {
|
|
56
|
+
const parts = memberKey.split(SEPARATOR);
|
|
57
|
+
return parts.length >= 4 ? parts[parts.length - 1] : "";
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
normalizeSpaceId,
|
|
63
|
+
createSpaceKey
|
|
64
|
+
};
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import {
|
|
2
|
+
dump,
|
|
3
|
+
load
|
|
4
|
+
} from "./chunk-WZSRQNQG.js";
|
|
5
|
+
import {
|
|
6
|
+
asTrimmedNonEmptyStringArray
|
|
7
|
+
} from "./chunk-I42VC5KR.js";
|
|
8
|
+
import {
|
|
9
|
+
asOptionalTrimmedString
|
|
10
|
+
} from "./chunk-G3SUCT4W.js";
|
|
11
|
+
|
|
12
|
+
// packages/ai/skills/skillDocProtocol.ts
|
|
13
|
+
var SKILL_DOC_ENUMS = {
|
|
14
|
+
triggerMode: ["explicit", "required", "recommended"],
|
|
15
|
+
budgetTier: ["low", "medium", "high"],
|
|
16
|
+
modality: ["text", "image", "video", "audio", "3d"],
|
|
17
|
+
docKind: ["knowledge", "instruction", "skill"]
|
|
18
|
+
};
|
|
19
|
+
var SKILL_CONFIG_BLOCK = "skill-config";
|
|
20
|
+
var EVAL_CONFIG_BLOCK = "eval-config";
|
|
21
|
+
var WORKFLOW_CONFIG_BLOCK = "workflow-config";
|
|
22
|
+
var normalizeStringArray = (value) => {
|
|
23
|
+
if (!Array.isArray(value)) return void 0;
|
|
24
|
+
const items = [...new Set(asTrimmedNonEmptyStringArray(value))];
|
|
25
|
+
return items.length > 0 ? items : void 0;
|
|
26
|
+
};
|
|
27
|
+
var normalizeBoolean = (value) => typeof value === "boolean" ? value : void 0;
|
|
28
|
+
var normalizeSkillEnumValue = (key, value) => typeof value === "string" && SKILL_DOC_ENUMS[key].includes(value) ? value : void 0;
|
|
29
|
+
var normalizeSkillBudgetTier = (value) => normalizeSkillEnumValue("budgetTier", value);
|
|
30
|
+
var normalizeSkillModalities = (value) => {
|
|
31
|
+
const raw = normalizeStringArray(value);
|
|
32
|
+
if (!raw) return void 0;
|
|
33
|
+
const filtered = raw.flatMap((item) => {
|
|
34
|
+
const modality = normalizeSkillEnumValue("modality", item);
|
|
35
|
+
return modality ? [modality] : [];
|
|
36
|
+
});
|
|
37
|
+
return filtered.length > 0 ? Array.from(new Set(filtered)) : void 0;
|
|
38
|
+
};
|
|
39
|
+
var normalizeSkillConfig = (value, fallbackTools) => {
|
|
40
|
+
if (!value || typeof value !== "object") return void 0;
|
|
41
|
+
const record = value;
|
|
42
|
+
const name = asOptionalTrimmedString(record.name) ?? "";
|
|
43
|
+
const description = asOptionalTrimmedString(record.description) ?? "";
|
|
44
|
+
if (!name || !description) return void 0;
|
|
45
|
+
const triggerMode = normalizeSkillEnumValue("triggerMode", record.triggerMode);
|
|
46
|
+
const budgetTier = normalizeSkillEnumValue("budgetTier", record.budgetTier);
|
|
47
|
+
const modalities = normalizeSkillModalities(record.modalities);
|
|
48
|
+
const toolNames = normalizeStringArray(record.toolNames) ?? normalizeStringArray(fallbackTools) ?? void 0;
|
|
49
|
+
const discover = record.discover && typeof record.discover === "object" ? {
|
|
50
|
+
keywords: normalizeStringArray(
|
|
51
|
+
record.discover.keywords
|
|
52
|
+
),
|
|
53
|
+
examples: normalizeStringArray(
|
|
54
|
+
record.discover.examples
|
|
55
|
+
)
|
|
56
|
+
} : void 0;
|
|
57
|
+
return {
|
|
58
|
+
version: "0.1",
|
|
59
|
+
kind: "skill",
|
|
60
|
+
id: asOptionalTrimmedString(record.id),
|
|
61
|
+
name,
|
|
62
|
+
description,
|
|
63
|
+
triggerMode,
|
|
64
|
+
toolNames,
|
|
65
|
+
preferredAgents: normalizeStringArray(record.preferredAgents),
|
|
66
|
+
budgetTier,
|
|
67
|
+
dispatchPreferred: normalizeBoolean(record.dispatchPreferred),
|
|
68
|
+
modalities,
|
|
69
|
+
requiredSkills: normalizeStringArray(record.requiredSkills),
|
|
70
|
+
recommendedSkills: normalizeStringArray(record.recommendedSkills),
|
|
71
|
+
promptPatch: asOptionalTrimmedString(record.promptPatch),
|
|
72
|
+
discover: discover?.keywords || discover?.examples ? discover : void 0
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
var normalizeEvalConfig = (value) => {
|
|
76
|
+
if (!value || typeof value !== "object") return void 0;
|
|
77
|
+
const record = value;
|
|
78
|
+
if (!Array.isArray(record.cases)) return void 0;
|
|
79
|
+
const cases = [];
|
|
80
|
+
for (const item of record.cases) {
|
|
81
|
+
if (!item || typeof item !== "object") continue;
|
|
82
|
+
const testCase = item;
|
|
83
|
+
const input = asOptionalTrimmedString(testCase.input) ?? "";
|
|
84
|
+
if (!input) continue;
|
|
85
|
+
cases.push({
|
|
86
|
+
input,
|
|
87
|
+
expectedTools: normalizeStringArray(testCase.expectedTools),
|
|
88
|
+
expectedSignals: normalizeStringArray(testCase.expectedSignals),
|
|
89
|
+
forbiddenSignals: normalizeStringArray(testCase.forbiddenSignals)
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return cases.length > 0 ? {
|
|
93
|
+
version: "0.1",
|
|
94
|
+
cases
|
|
95
|
+
} : void 0;
|
|
96
|
+
};
|
|
97
|
+
var normalizeWorkflowConfig = (value) => {
|
|
98
|
+
if (!value || typeof value !== "object") return void 0;
|
|
99
|
+
const record = value;
|
|
100
|
+
const name = asOptionalTrimmedString(record.name) ?? "";
|
|
101
|
+
const description = asOptionalTrimmedString(record.description) ?? "";
|
|
102
|
+
if (!name || !description) return void 0;
|
|
103
|
+
const budgetTier = normalizeSkillEnumValue("budgetTier", record.budgetTier);
|
|
104
|
+
return {
|
|
105
|
+
version: "0.1",
|
|
106
|
+
kind: "workflow",
|
|
107
|
+
id: asOptionalTrimmedString(record.id),
|
|
108
|
+
name,
|
|
109
|
+
description,
|
|
110
|
+
defaultAgent: asOptionalTrimmedString(record.defaultAgent),
|
|
111
|
+
inputs: normalizeStringArray(record.inputs),
|
|
112
|
+
recommendedTools: normalizeStringArray(record.recommendedTools),
|
|
113
|
+
requiredTools: normalizeStringArray(record.requiredTools),
|
|
114
|
+
requiredOutputs: normalizeStringArray(record.requiredOutputs),
|
|
115
|
+
gates: normalizeStringArray(record.gates),
|
|
116
|
+
budgetTier,
|
|
117
|
+
contextStrategy: asOptionalTrimmedString(record.contextStrategy),
|
|
118
|
+
failureProtocol: asOptionalTrimmedString(record.failureProtocol)
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
var normalizePageSkillMetadata = (value, fallbackTools) => {
|
|
122
|
+
if (!value || typeof value !== "object") return void 0;
|
|
123
|
+
const record = value;
|
|
124
|
+
const kind = normalizeSkillEnumValue("docKind", record.kind);
|
|
125
|
+
const meta = {
|
|
126
|
+
kind,
|
|
127
|
+
requiredSkills: normalizeStringArray(record.requiredSkills),
|
|
128
|
+
recommendedSkills: normalizeStringArray(record.recommendedSkills),
|
|
129
|
+
skillConfig: normalizeSkillConfig(record.skillConfig, fallbackTools),
|
|
130
|
+
evalConfig: normalizeEvalConfig(record.evalConfig),
|
|
131
|
+
workflowConfig: normalizeWorkflowConfig(record.workflowConfig)
|
|
132
|
+
};
|
|
133
|
+
if (meta.skillConfig && !meta.kind) {
|
|
134
|
+
meta.kind = "skill";
|
|
135
|
+
}
|
|
136
|
+
if (meta.workflowConfig && !meta.kind) {
|
|
137
|
+
meta.kind = "instruction";
|
|
138
|
+
}
|
|
139
|
+
return meta.kind || meta.requiredSkills || meta.recommendedSkills || meta.skillConfig || meta.evalConfig || meta.workflowConfig ? meta : void 0;
|
|
140
|
+
};
|
|
141
|
+
var extractCommentBlock = (markdown, blockName) => {
|
|
142
|
+
if (!markdown) return void 0;
|
|
143
|
+
const matcher = new RegExp(
|
|
144
|
+
`<!--\\s*${blockName}\\s*\\n([\\s\\S]*?)-->`,
|
|
145
|
+
"i"
|
|
146
|
+
);
|
|
147
|
+
const match = markdown.match(matcher);
|
|
148
|
+
return asOptionalTrimmedString(match?.[1]);
|
|
149
|
+
};
|
|
150
|
+
var removeCommentBlock = (markdown, blockName) => markdown.replace(
|
|
151
|
+
new RegExp(`\\n?<!--\\s*${blockName}\\s*\\n[\\s\\S]*?-->\\s*`, "gi"),
|
|
152
|
+
"\n\n"
|
|
153
|
+
);
|
|
154
|
+
var parseYamlObject = (raw) => {
|
|
155
|
+
if (!raw) return void 0;
|
|
156
|
+
try {
|
|
157
|
+
const parsed = load(raw);
|
|
158
|
+
return parsed && typeof parsed === "object" ? parsed : void 0;
|
|
159
|
+
} catch {
|
|
160
|
+
return void 0;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
var parseSkillDocProtocol = (markdown, existingMeta, fallbackTools) => {
|
|
164
|
+
const source = typeof markdown === "string" ? markdown : "";
|
|
165
|
+
const skillBlock = parseYamlObject(extractCommentBlock(source, SKILL_CONFIG_BLOCK));
|
|
166
|
+
const evalBlock = parseYamlObject(extractCommentBlock(source, EVAL_CONFIG_BLOCK));
|
|
167
|
+
const workflowBlock = parseYamlObject(extractCommentBlock(source, WORKFLOW_CONFIG_BLOCK));
|
|
168
|
+
const cleanedContent = removeCommentBlock(
|
|
169
|
+
removeCommentBlock(
|
|
170
|
+
removeCommentBlock(source, SKILL_CONFIG_BLOCK),
|
|
171
|
+
EVAL_CONFIG_BLOCK
|
|
172
|
+
),
|
|
173
|
+
WORKFLOW_CONFIG_BLOCK
|
|
174
|
+
).replace(/\n{3,}/g, "\n\n").trim();
|
|
175
|
+
const parsedMeta = normalizePageSkillMetadata(
|
|
176
|
+
{
|
|
177
|
+
...existingMeta ?? {},
|
|
178
|
+
...skillBlock ? {
|
|
179
|
+
kind: existingMeta?.kind === "skill" || skillBlock.kind === "skill" ? "skill" : existingMeta?.kind,
|
|
180
|
+
requiredSkills: skillBlock.requiredSkills ?? existingMeta?.requiredSkills,
|
|
181
|
+
recommendedSkills: skillBlock.recommendedSkills ?? existingMeta?.recommendedSkills,
|
|
182
|
+
skillConfig: skillBlock
|
|
183
|
+
} : {},
|
|
184
|
+
...evalBlock ? { evalConfig: evalBlock } : {},
|
|
185
|
+
...workflowBlock ? { workflowConfig: workflowBlock } : {}
|
|
186
|
+
},
|
|
187
|
+
fallbackTools
|
|
188
|
+
);
|
|
189
|
+
return {
|
|
190
|
+
content: cleanedContent,
|
|
191
|
+
meta: parsedMeta
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
var resolvePageSkillMetadata = (page) => {
|
|
195
|
+
if (!page) return void 0;
|
|
196
|
+
const existingMeta = normalizePageSkillMetadata(page.meta, page.tools);
|
|
197
|
+
return parseSkillDocProtocol(page.content ?? "", existingMeta, page.tools).meta;
|
|
198
|
+
};
|
|
199
|
+
var yamlBlock = (value) => dump(value, { lineWidth: 120, noRefs: true }).trim();
|
|
200
|
+
var buildSkillConfigComment = (config) => {
|
|
201
|
+
const payload = {
|
|
202
|
+
version: config.version,
|
|
203
|
+
kind: config.kind,
|
|
204
|
+
...config.id ? { id: config.id } : {},
|
|
205
|
+
name: config.name,
|
|
206
|
+
description: config.description,
|
|
207
|
+
...config.triggerMode ? { triggerMode: config.triggerMode } : {},
|
|
208
|
+
...config.requiredSkills?.length ? { requiredSkills: config.requiredSkills } : {},
|
|
209
|
+
...config.recommendedSkills?.length ? { recommendedSkills: config.recommendedSkills } : {},
|
|
210
|
+
...config.toolNames?.length ? { toolNames: config.toolNames } : {},
|
|
211
|
+
...config.preferredAgents?.length ? { preferredAgents: config.preferredAgents } : {},
|
|
212
|
+
...config.budgetTier ? { budgetTier: config.budgetTier } : {},
|
|
213
|
+
...typeof config.dispatchPreferred === "boolean" ? { dispatchPreferred: config.dispatchPreferred } : {},
|
|
214
|
+
...config.modalities?.length ? { modalities: config.modalities } : {},
|
|
215
|
+
...config.discover?.keywords?.length || config.discover?.examples?.length ? {
|
|
216
|
+
discover: {
|
|
217
|
+
...config.discover?.keywords?.length ? { keywords: config.discover.keywords } : {},
|
|
218
|
+
...config.discover?.examples?.length ? { examples: config.discover.examples } : {}
|
|
219
|
+
}
|
|
220
|
+
} : {},
|
|
221
|
+
...config.promptPatch ? { promptPatch: config.promptPatch } : {}
|
|
222
|
+
};
|
|
223
|
+
return `<!-- ${SKILL_CONFIG_BLOCK}
|
|
224
|
+
${yamlBlock(payload)}
|
|
225
|
+
-->`;
|
|
226
|
+
};
|
|
227
|
+
var buildEvalConfigComment = (config) => `<!-- ${EVAL_CONFIG_BLOCK}
|
|
228
|
+
${yamlBlock({
|
|
229
|
+
version: config.version,
|
|
230
|
+
cases: config.cases
|
|
231
|
+
})}
|
|
232
|
+
-->`;
|
|
233
|
+
var buildWorkflowConfigComment = (config) => `<!-- ${WORKFLOW_CONFIG_BLOCK}
|
|
234
|
+
${yamlBlock({
|
|
235
|
+
version: config.version,
|
|
236
|
+
kind: config.kind,
|
|
237
|
+
...config.id ? { id: config.id } : {},
|
|
238
|
+
name: config.name,
|
|
239
|
+
description: config.description,
|
|
240
|
+
...config.defaultAgent ? { defaultAgent: config.defaultAgent } : {},
|
|
241
|
+
...config.inputs?.length ? { inputs: config.inputs } : {},
|
|
242
|
+
...config.recommendedTools?.length ? { recommendedTools: config.recommendedTools } : {},
|
|
243
|
+
...config.requiredTools?.length ? { requiredTools: config.requiredTools } : {},
|
|
244
|
+
...config.requiredOutputs?.length ? { requiredOutputs: config.requiredOutputs } : {},
|
|
245
|
+
...config.gates?.length ? { gates: config.gates } : {},
|
|
246
|
+
...config.budgetTier ? { budgetTier: config.budgetTier } : {},
|
|
247
|
+
...config.contextStrategy ? { contextStrategy: config.contextStrategy } : {},
|
|
248
|
+
...config.failureProtocol ? { failureProtocol: config.failureProtocol } : {}
|
|
249
|
+
})}
|
|
250
|
+
-->`;
|
|
251
|
+
var buildSkillDocMarkdown = (options) => {
|
|
252
|
+
const sections = [
|
|
253
|
+
asOptionalTrimmedString(options.body) ?? "",
|
|
254
|
+
buildSkillConfigComment(options.skillConfig),
|
|
255
|
+
options.evalConfig ? buildEvalConfigComment(options.evalConfig) : "",
|
|
256
|
+
options.workflowConfig ? buildWorkflowConfigComment(options.workflowConfig) : ""
|
|
257
|
+
].filter(Boolean);
|
|
258
|
+
return sections.join("\n\n").trim();
|
|
259
|
+
};
|
|
260
|
+
var extractFrontmatter = (markdown) => {
|
|
261
|
+
const match = markdown.match(/^\s*---\s*\n([\s\S]*?)\n\s*---\s*\n?/);
|
|
262
|
+
if (!match) return { body: markdown.trim() };
|
|
263
|
+
const frontmatter = parseYamlObject(match[1]);
|
|
264
|
+
const body = markdown.slice(match[0].length).trim();
|
|
265
|
+
return { frontmatter, body };
|
|
266
|
+
};
|
|
267
|
+
var normalizeAllowedTools = (value) => {
|
|
268
|
+
if (Array.isArray(value)) {
|
|
269
|
+
return normalizeStringArray(value) ?? [];
|
|
270
|
+
}
|
|
271
|
+
if (typeof value === "string") {
|
|
272
|
+
return value.split(/\s+/).map((item) => item.trim()).filter(Boolean);
|
|
273
|
+
}
|
|
274
|
+
return [];
|
|
275
|
+
};
|
|
276
|
+
var parseExternalSkillMarkdown = (markdown) => {
|
|
277
|
+
const { frontmatter, body } = extractFrontmatter(markdown);
|
|
278
|
+
return {
|
|
279
|
+
name: asOptionalTrimmedString(frontmatter?.name),
|
|
280
|
+
description: asOptionalTrimmedString(frontmatter?.description),
|
|
281
|
+
compatibility: asOptionalTrimmedString(frontmatter?.compatibility),
|
|
282
|
+
allowedTools: normalizeAllowedTools(frontmatter?.["allowed-tools"]),
|
|
283
|
+
metadata: frontmatter?.metadata && typeof frontmatter.metadata === "object" ? Object.fromEntries(
|
|
284
|
+
Object.entries(frontmatter.metadata).filter(([, value]) => typeof value === "string").map(([key, value]) => [key, String(value)])
|
|
285
|
+
) : void 0,
|
|
286
|
+
body
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
export {
|
|
291
|
+
normalizeStringArray,
|
|
292
|
+
normalizeSkillBudgetTier,
|
|
293
|
+
normalizeSkillModalities,
|
|
294
|
+
parseSkillDocProtocol,
|
|
295
|
+
resolvePageSkillMetadata,
|
|
296
|
+
buildSkillDocMarkdown,
|
|
297
|
+
parseExternalSkillMarkdown
|
|
298
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// packages/ai/skills/skillSummaryMarker.ts
|
|
2
|
+
var buildSkillSummaryMarker = (meta) => {
|
|
3
|
+
const skillConfig = meta?.skillConfig;
|
|
4
|
+
if (meta?.kind !== "skill" && !skillConfig) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return {
|
|
8
|
+
isSkill: true,
|
|
9
|
+
...skillConfig?.id ? { skillId: skillConfig.id } : {},
|
|
10
|
+
...skillConfig?.name ? { name: skillConfig.name } : {},
|
|
11
|
+
...skillConfig?.description ? { description: skillConfig.description } : {},
|
|
12
|
+
...skillConfig?.toolNames?.length ? { toolNames: skillConfig.toolNames } : {},
|
|
13
|
+
...skillConfig?.triggerMode ? { triggerMode: skillConfig.triggerMode } : {}
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
var isSkillSummaryMarker = (value) => Boolean(value?.isSkill);
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
buildSkillSummaryMarker,
|
|
20
|
+
isSkillSummaryMarker
|
|
21
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asTrimmedLowercaseString
|
|
3
|
+
} from "./chunk-QSJ3HFEF.js";
|
|
4
|
+
|
|
5
|
+
// packages/cli/agentAliases.ts
|
|
6
|
+
var CURRENT_OPERATOR_USER_ID = "0e95801d90";
|
|
7
|
+
var NOLO_DEFAULT_AGENT_ID = "01NOLOAPPBLD000000019KCKT0";
|
|
8
|
+
var NOLO_DEFAULT_AGENT_KEY = `agent-pub-${NOLO_DEFAULT_AGENT_ID}`;
|
|
9
|
+
var NOLO_PROJECT_MANAGER_AGENT_ID = "01NOLOPROJMGR00000000MSVGG";
|
|
10
|
+
var NOLO_PROJECT_MANAGER_AGENT_KEY = `agent-${CURRENT_OPERATOR_USER_ID}-${NOLO_PROJECT_MANAGER_AGENT_ID}`;
|
|
11
|
+
var NOLO_FRONTEND_AGENT_ID = "01FRONTENDAG0000000115N4E1";
|
|
12
|
+
var NOLO_FRONTEND_AGENT_KEY = `agent-${CURRENT_OPERATOR_USER_ID}-${NOLO_FRONTEND_AGENT_ID}`;
|
|
13
|
+
var LOCAL_CODEX_AGENT_ID = "01LOCALCODEXCLI000000NEW";
|
|
14
|
+
var LOCAL_CODEX_AGENT_KEY = `agent-${CURRENT_OPERATOR_USER_ID}-${LOCAL_CODEX_AGENT_ID}`;
|
|
15
|
+
var AGENT_ALIAS_TO_KEY = {
|
|
16
|
+
nolo: NOLO_DEFAULT_AGENT_KEY,
|
|
17
|
+
default: NOLO_DEFAULT_AGENT_KEY,
|
|
18
|
+
"default-nolo": NOLO_DEFAULT_AGENT_KEY,
|
|
19
|
+
// Product implementation & coordination aliases
|
|
20
|
+
"frontend-implementer": NOLO_FRONTEND_AGENT_KEY,
|
|
21
|
+
"frontend-agent": NOLO_FRONTEND_AGENT_KEY,
|
|
22
|
+
frontend: NOLO_FRONTEND_AGENT_KEY,
|
|
23
|
+
"frontend agent": NOLO_FRONTEND_AGENT_KEY,
|
|
24
|
+
"\u524D\u7AEFagent": NOLO_FRONTEND_AGENT_KEY,
|
|
25
|
+
"\u524D\u7AEF agent": NOLO_FRONTEND_AGENT_KEY,
|
|
26
|
+
"project-manager": NOLO_PROJECT_MANAGER_AGENT_KEY,
|
|
27
|
+
pm: NOLO_PROJECT_MANAGER_AGENT_KEY,
|
|
28
|
+
// Explicit local CLI agents. These are ordinary private agent records that
|
|
29
|
+
// run through the current computer local runtime when unbound.
|
|
30
|
+
"local-codex": LOCAL_CODEX_AGENT_KEY,
|
|
31
|
+
"codex-local": LOCAL_CODEX_AGENT_KEY,
|
|
32
|
+
"local codex": LOCAL_CODEX_AGENT_KEY,
|
|
33
|
+
"minimax-m3": "agent-0e95801d90-minimax-m3",
|
|
34
|
+
minimax: "agent-0e95801d90-minimax-m3"
|
|
35
|
+
};
|
|
36
|
+
function parseAgentKeyFromInput(raw) {
|
|
37
|
+
const trimmed = raw.trim();
|
|
38
|
+
if (trimmed.startsWith("http://") || trimmed.startsWith("https://")) {
|
|
39
|
+
const url = new URL(trimmed);
|
|
40
|
+
return url.pathname.replace(/^\/+/, "");
|
|
41
|
+
}
|
|
42
|
+
return trimmed;
|
|
43
|
+
}
|
|
44
|
+
function resolveCliAgentKeyInput(raw) {
|
|
45
|
+
return AGENT_ALIAS_TO_KEY[asTrimmedLowercaseString(raw)] ?? parseAgentKeyFromInput(raw);
|
|
46
|
+
}
|
|
47
|
+
function isLocalCliAgentKey(agentKey) {
|
|
48
|
+
return agentKey === LOCAL_CODEX_AGENT_KEY;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
NOLO_DEFAULT_AGENT_ID,
|
|
53
|
+
NOLO_DEFAULT_AGENT_KEY,
|
|
54
|
+
NOLO_PROJECT_MANAGER_AGENT_KEY,
|
|
55
|
+
LOCAL_CODEX_AGENT_ID,
|
|
56
|
+
LOCAL_CODEX_AGENT_KEY,
|
|
57
|
+
resolveCliAgentKeyInput,
|
|
58
|
+
isLocalCliAgentKey
|
|
59
|
+
};
|