nolo-cli 0.8.0-alpha.2 → 0.8.0-alpha.21

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.
Files changed (188) hide show
  1. package/README.md +1 -1
  2. package/_executeModel-42U3VOVZ.js +205 -0
  3. package/action-TLI3V62L.js +28 -0
  4. package/addContentAction-57RSIIMR.js +26 -0
  5. package/addDialogAgentAction-G3VWEA6E.js +68 -0
  6. package/agentDeleteCommand-5DD2IM3J.js +327 -0
  7. package/agentEmailCommands-6FACJBU4.js +628 -0
  8. package/agentListCommands-I6KZYCIG.js +223 -0
  9. package/agentMachineCommands-VKLIGMZA.js +425 -0
  10. package/agentPullCommand-O2MTUAFR.js +122 -0
  11. package/agentRecordCommands-7TZICYDT.js +96 -0
  12. package/agentRunCommand-L4OM23KV.js +114 -0
  13. package/agentRunControl-K4VKNEHF.js +57 -0
  14. package/agentRuntimeLocal-ZYEIPTY4.js +104 -0
  15. package/agentSlice-BX7GXSNO.js +42 -0
  16. package/authCommand-EB5JSOX5.js +581 -0
  17. package/authCommands-XPEHTKSM.js +35 -0
  18. package/chunk-25LCXTML.js +175 -0
  19. package/chunk-2ECQG4YX.js +22296 -0
  20. package/chunk-2FTTDCD4.js +675 -0
  21. package/chunk-2JCXITPK.js +1078 -0
  22. package/chunk-3ASDTTEI.js +1774 -0
  23. package/chunk-3EUW3WEO.js +8 -0
  24. package/chunk-3LY4F7SV.js +9293 -0
  25. package/chunk-4CQLVGRV.js +50 -0
  26. package/chunk-4IJYA27C.js +342 -0
  27. package/chunk-4O3CARJ4.js +231 -0
  28. package/chunk-4QEWT7KD.js +933 -0
  29. package/chunk-4SN6J65J.js +38 -0
  30. package/chunk-4VNS5WPM.js +42 -0
  31. package/chunk-4XENYTF5.js +222 -0
  32. package/chunk-4ZDM73SD.js +34 -0
  33. package/chunk-5CS33IBL.js +301 -0
  34. package/chunk-5EFXE3O7.js +138 -0
  35. package/chunk-5KLGBAAR.js +386 -0
  36. package/chunk-5MIDPSSK.js +206 -0
  37. package/chunk-5MMAK75Q.js +15 -0
  38. package/chunk-63W5N6P3.js +150 -0
  39. package/chunk-6HYVJV7B.js +102 -0
  40. package/chunk-6KHNO3SK.js +1948 -0
  41. package/chunk-6WD3OOJS.js +20 -0
  42. package/chunk-7DAJ4AI4.js +191 -0
  43. package/chunk-7GNGZRLZ.js +1939 -0
  44. package/chunk-7KCUSYT2.js +354 -0
  45. package/chunk-7U44LYTR.js +238 -0
  46. package/chunk-AFON4QUU.js +112 -0
  47. package/chunk-AGFH73SK.js +239 -0
  48. package/chunk-AL2KDGR2.js +27339 -0
  49. package/chunk-AS4PVWA4.js +221 -0
  50. package/chunk-ATNTHIZI.js +13 -0
  51. package/chunk-AVMKZHBC.js +85 -0
  52. package/chunk-AZPCASRE.js +36 -0
  53. package/chunk-BBYVOSU2.js +792 -0
  54. package/chunk-C3RUNRHT.js +51 -0
  55. package/chunk-C4FTUXVF.js +146 -0
  56. package/chunk-CF2WZF4N.js +134 -0
  57. package/chunk-CF7PE763.js +10 -0
  58. package/chunk-CKOJQDKR.js +198 -0
  59. package/chunk-CMKUBIGW.js +1550 -0
  60. package/chunk-CWMSB67P.js +34 -0
  61. package/chunk-DCOA4QSN.js +105 -0
  62. package/chunk-DFFIZ25G.js +30 -0
  63. package/chunk-DSZUWUYB.js +478 -0
  64. package/chunk-DWLEOOGR.js +8 -0
  65. package/chunk-DZ3XJVET.js +231 -0
  66. package/chunk-EHLHSX7R.js +1433 -0
  67. package/chunk-ENOG22KJ.js +939 -0
  68. package/chunk-FSO5B7GH.js +171 -0
  69. package/chunk-FVYY6MCS.js +1447 -0
  70. package/chunk-G3SUCT4W.js +8 -0
  71. package/chunk-GAKEBQD6.js +30 -0
  72. package/chunk-GBRG75BQ.js +86 -0
  73. package/chunk-GU3PEVGZ.js +4723 -0
  74. package/chunk-H33743XH.js +25 -0
  75. package/chunk-HNMXYYJR.js +12 -0
  76. package/chunk-HNW7IJSK.js +71 -0
  77. package/chunk-I42VC5KR.js +15 -0
  78. package/chunk-I6XMPTMR.js +113 -0
  79. package/chunk-IDZTNRP2.js +85 -0
  80. package/chunk-ISNCLGUZ.js +146 -0
  81. package/chunk-IWX4UW2E.js +548 -0
  82. package/chunk-JBTJAPUF.js +35 -0
  83. package/chunk-JEXVIMYZ.js +55 -0
  84. package/chunk-JRKKFRAV.js +537 -0
  85. package/chunk-JZPBVBIY.js +94 -0
  86. package/chunk-KKY4B2Q2.js +21 -0
  87. package/chunk-KQHGZWSV.js +63 -0
  88. package/chunk-KUG52IAP.js +8 -0
  89. package/chunk-KX6YBIHG.js +8 -0
  90. package/chunk-LCBAMY2M.js +60 -0
  91. package/chunk-LM6IYQ3F.js +16 -0
  92. package/chunk-LTRXGFMS.js +83 -0
  93. package/chunk-M76ECQRD.js +13658 -0
  94. package/chunk-MRC4Q34M.js +188 -0
  95. package/chunk-MTU75CZ2.js +91 -0
  96. package/chunk-N54XAP77.js +19 -0
  97. package/chunk-O2ZNTTET.js +3272 -0
  98. package/chunk-O4BU24WZ.js +3212 -0
  99. package/chunk-OLZBQWZU.js +6 -0
  100. package/chunk-OOSFSFMA.js +271 -0
  101. package/chunk-OPZYGHUC.js +89 -0
  102. package/chunk-OWOHNGCN.js +50 -0
  103. package/chunk-P3PKED2I.js +962 -0
  104. package/chunk-QSJ3HFEF.js +8 -0
  105. package/chunk-RCSJFQPB.js +9036 -0
  106. package/chunk-RL776AGR.js +190 -0
  107. package/chunk-ROWQEJRP.js +139 -0
  108. package/chunk-S7Z2HMCN.js +25 -0
  109. package/chunk-SDJDLO5W.js +628 -0
  110. package/chunk-SOTZ6RDN.js +69 -0
  111. package/chunk-TILFE6LV.js +381 -0
  112. package/chunk-U4TRT5V4.js +246 -0
  113. package/chunk-U6VC4MU4.js +8 -0
  114. package/chunk-UAD2WT54.js +64 -0
  115. package/chunk-UB6SN4NJ.js +421 -0
  116. package/chunk-URUUZLPA.js +807 -0
  117. package/chunk-UTLZINAP.js +3066 -0
  118. package/chunk-VC6OZXO5.js +298 -0
  119. package/chunk-VF4K2QE6.js +21 -0
  120. package/chunk-VHBWHNVT.js +59 -0
  121. package/chunk-VIDPVFP3.js +20 -0
  122. package/chunk-VP4WJWKW.js +8882 -0
  123. package/chunk-VUW5FBDB.js +573 -0
  124. package/chunk-VVX233PH.js +482 -0
  125. package/chunk-VX3SXJ3N.js +2052 -0
  126. package/chunk-W4NVOSFF.js +37 -0
  127. package/chunk-WWC7I6TA.js +8 -0
  128. package/chunk-WZSRQNQG.js +2587 -0
  129. package/chunk-XBUBEFNX.js +34 -0
  130. package/chunk-XENYHRUE.js +104 -0
  131. package/chunk-Y5GCAMGP.js +9 -0
  132. package/chunk-YPRZSPF3.js +148 -0
  133. package/chunk-Z4NR32XR.js +50 -0
  134. package/chunk-ZNFJWEN4.js +56 -0
  135. package/cliExecutor-K3F7DMRO.js +36 -0
  136. package/clipboardy-BVE3LVEH.js +12001 -0
  137. package/createAgentAutomationAction-RJF3N2QY.js +866 -0
  138. package/createDialogAction-DRSPS6CE.js +55 -0
  139. package/createPageAction-6B2WMNO3.js +172 -0
  140. package/db-HCJ5PRB5.js +271 -0
  141. package/dbSlice-Q3TM2FJV.js +60 -0
  142. package/deleteFile-OW53A6BX.js +41 -0
  143. package/dialogCommands-4IX4XIZE.js +63 -0
  144. package/dialogSlice-3M7KX2TX.js +148 -0
  145. package/docCreateCommands-SIL3NPGT.js +220 -0
  146. package/docDeleteCommands-7IOMLUS4.js +181 -0
  147. package/docReadCommands-FNFXUA5L.js +134 -0
  148. package/docStore-SV7E34D4.js +98 -0
  149. package/docUpdateCommands-X2HNDVUC.js +318 -0
  150. package/fetchMessages-KTNM7QAR.js +17 -0
  151. package/getPricing-3E6UNPKL.js +30 -0
  152. package/handleSendMessageAction-JYETO5RZ.js +185 -0
  153. package/index.js +188 -112958
  154. package/lib-FYYBQIXS.js +19839 -0
  155. package/localDialogRead-2VRI24F4.js +26 -0
  156. package/localFirstLog-DHNOY2NA.js +19 -0
  157. package/localRuntimeAuthority-TEGCOWX4.js +471 -0
  158. package/localRuntimeDb-LGDF6FQP.js +12 -0
  159. package/machineCommands-RIO3RP5Q.js +781 -0
  160. package/machineInfo-M6KB6HZN.js +10 -0
  161. package/machineWsRunDispatch-W7UYLGB5.js +112 -0
  162. package/memoryCommands-O4MIPIWQ.js +476 -0
  163. package/models-4OPOOLFS.js +9 -0
  164. package/offlineMarxistsAgentCommand-BCPJITJL.js +242 -0
  165. package/package.json +4 -24
  166. package/read-GW7ZEI23.js +17 -0
  167. package/readDocTool-HUFU6OCT.js +16 -0
  168. package/readlineWorkspace-27JR7WPW.js +5682 -0
  169. package/removeDialogAgentAction-CXKR4NJI.js +73 -0
  170. package/runAgentClientLoop-HZFAPJHS.js +293 -0
  171. package/runtimeDoctorCommands-LRHLPDRC.js +289 -0
  172. package/setDialogExtraReferencesAction-6RKUSXHX.js +60 -0
  173. package/setPrimaryDialogAgentAction-T3UTBEFG.js +80 -0
  174. package/settingSlice-IVKXJXMG.js +199 -0
  175. package/skillDiscovery-UGSQGX2U.js +16 -0
  176. package/skillSummaryMarker-42HKSXYY.js +9 -0
  177. package/slateToRenderMarkdown-Y5IYN73U.js +7 -0
  178. package/slateUtils-2M7MUTWX.js +19 -0
  179. package/spaceCommands-E7VOF4LO.js +450 -0
  180. package/spaceSlice-TSVROA5U.js +149 -0
  181. package/streamAgentChatTurn-3C5RQZJF.js +4510 -0
  182. package/tableCommands-O7O2LBEG.js +1286 -0
  183. package/toolApiClient-QI3YBNWB.js +26 -0
  184. package/tools-EQDEKR6N.js +87 -0
  185. package/tuiSummaryLlmCaller-RV3THLZF.js +78 -0
  186. package/understanding-3CUQQ6SV.js +271 -0
  187. package/updateCommands-VOSPKXFF.js +31 -0
  188. package/updateDialogTitleAction-3XV7VWSZ.js +188 -0
@@ -0,0 +1,38 @@
1
+ // packages/core/localOrigins.ts
2
+ var DEFAULT_LOCAL_HOST = "127.0.0.1";
3
+ var DEFAULT_LOCAL_API_PORT = "38123";
4
+ var DEFAULT_LOCAL_API_ORIGIN = `http://${DEFAULT_LOCAL_HOST}:${DEFAULT_LOCAL_API_PORT}`;
5
+ var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set([
6
+ "127.0.0.1",
7
+ "localhost",
8
+ "::1"
9
+ ]);
10
+ function isLoopbackHostname(hostname) {
11
+ if (typeof hostname !== "string") return false;
12
+ let normalized = hostname.trim().toLowerCase();
13
+ if (!normalized) return false;
14
+ if (normalized.startsWith("[") && normalized.endsWith("]")) {
15
+ normalized = normalized.slice(1, -1);
16
+ }
17
+ return LOOPBACK_HOSTNAMES.has(normalized);
18
+ }
19
+ function isLoopbackUrl(value) {
20
+ if (typeof value !== "string" || !value.trim()) return false;
21
+ try {
22
+ return isLoopbackHostname(new URL(value).hostname);
23
+ } catch {
24
+ return false;
25
+ }
26
+ }
27
+ var LOCAL_SERVER_URL_PATTERN = /^https?:\/\/(?:(?:\d{1,3}\.){3}\d{1,3}|localhost|nolotus\.local)(?::\d+)?$/i;
28
+ function isLocalServerUrl(value) {
29
+ if (typeof value !== "string") return false;
30
+ return LOCAL_SERVER_URL_PATTERN.test(value.trim());
31
+ }
32
+
33
+ export {
34
+ DEFAULT_LOCAL_API_ORIGIN,
35
+ isLoopbackHostname,
36
+ isLoopbackUrl,
37
+ isLocalServerUrl
38
+ };
@@ -0,0 +1,42 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+
37
+ export {
38
+ __require,
39
+ __commonJS,
40
+ __export,
41
+ __toESM
42
+ };
@@ -0,0 +1,222 @@
1
+ import {
2
+ clearCliLocalRuntimePreparedAgentCache
3
+ } from "./chunk-RCSJFQPB.js";
4
+ import {
5
+ getReadableCliDb
6
+ } from "./chunk-W4NVOSFF.js";
7
+ import {
8
+ buildCreatedAgentRecord,
9
+ buildUpdatedAgentRecord,
10
+ normalizeAgentRecordForOutput,
11
+ parseAgentUpdateArgs,
12
+ resolveAgentRecordFromHybridStore,
13
+ sanitizeAgentRecordForCliOutput,
14
+ writeAgentRecord
15
+ } from "./chunk-SDJDLO5W.js";
16
+ import {
17
+ resolveCliAgentKeyInput
18
+ } from "./chunk-VHBWHNVT.js";
19
+ import {
20
+ parseUserIdFromAuthToken,
21
+ resolveAuthToken
22
+ } from "./chunk-ISNCLGUZ.js";
23
+ import {
24
+ toErrorMessage
25
+ } from "./chunk-HNMXYYJR.js";
26
+
27
+ // packages/cli/agentRecordCommands.ts
28
+ async function runAgentReadCommand(args, deps = {}) {
29
+ const env = deps.env ?? process.env;
30
+ const output = deps.output ?? process.stdout;
31
+ const agentInput = args[0]?.trim();
32
+ if (!agentInput || agentInput === "--help" || agentInput === "-h") {
33
+ output.write("Usage: nolo agent read <agent>\n");
34
+ return agentInput ? 0 : 1;
35
+ }
36
+ const authToken = resolveAuthToken(args, env);
37
+ if (!authToken) {
38
+ output.write("[nolo] agent read requires an auth token. Run `nolo login` or set AUTH_TOKEN.\n");
39
+ return 1;
40
+ }
41
+ const agentKey = resolveCliAgentKeyInput(agentInput);
42
+ const db = deps.db ?? await getReadableCliDb(output);
43
+ const fetchImpl = deps.fetchImpl ?? fetch;
44
+ const fallbackFetchImpl = deps.fallbackFetchImpl;
45
+ try {
46
+ const result = await resolveAgentRecordFromHybridStore({
47
+ agentInput,
48
+ cliArgs: args,
49
+ env,
50
+ db,
51
+ fetchImpl,
52
+ fallbackFetchImpl
53
+ });
54
+ if (!result) {
55
+ throw new Error(`agent not found: ${agentKey}`);
56
+ }
57
+ output.write(JSON.stringify({
58
+ ...normalizeAgentRecordForOutput(result.agentKey, authToken, result.record),
59
+ source: result.source
60
+ }, null, 2));
61
+ output.write("\n");
62
+ return 0;
63
+ } catch (error) {
64
+ output.write(
65
+ `[nolo] agent read failed: ${toErrorMessage(error)}
66
+ `
67
+ );
68
+ return 1;
69
+ }
70
+ }
71
+ async function runAgentUpdateCommand(args, deps = {}) {
72
+ const env = deps.env ?? process.env;
73
+ const output = deps.output ?? process.stdout;
74
+ let parsed;
75
+ try {
76
+ parsed = parseAgentUpdateArgs(args);
77
+ } catch (error) {
78
+ output.write(`[nolo] agent update failed: ${toErrorMessage(error)}
79
+ `);
80
+ return 1;
81
+ }
82
+ if (!parsed) {
83
+ output.write(
84
+ "Usage: nolo agent update <agent> [--model <id>] [--cli-provider <provider>] [--api-source <source>] [--max-concurrent <n>] [--expires-at <iso>] [--prompt <text> | --prompt-file <path> | --prompt-doc <pageKey>] [--tools <json>] [--copy-provider-from <agent>] [--field key=value]\n".replace("[--field key=value]", `[--handle <name>] [--field key=value] (e.g. --field disabledTools='["exa_search"]' to disable default tools)`)
85
+ );
86
+ return args[0] ? 0 : 1;
87
+ }
88
+ const authToken = resolveAuthToken(args, env);
89
+ if (!authToken) {
90
+ output.write("[nolo] agent update requires an auth token. Run `nolo login` or set AUTH_TOKEN.\n");
91
+ return 1;
92
+ }
93
+ const userId = parseUserIdFromAuthToken(authToken);
94
+ if (!userId) {
95
+ output.write("[nolo] agent update could not read userId from AUTH_TOKEN.\n");
96
+ return 1;
97
+ }
98
+ const db = deps.db ?? await getReadableCliDb(output);
99
+ const fetchImpl = deps.fetchImpl ?? fetch;
100
+ const fallbackFetchImpl = deps.fallbackFetchImpl;
101
+ try {
102
+ const built = await buildUpdatedAgentRecord({
103
+ cliArgs: args,
104
+ parsed,
105
+ env,
106
+ db,
107
+ fetchImpl,
108
+ fallbackFetchImpl,
109
+ authToken
110
+ });
111
+ await writeAgentRecord({
112
+ agentKey: built.agentKey,
113
+ authToken,
114
+ fallbackFetchImpl,
115
+ fetchImpl,
116
+ serverUrl: built.serverUrl,
117
+ userId,
118
+ record: built.nextRecord
119
+ });
120
+ await db.put(built.agentKey, {
121
+ ...built.nextRecord,
122
+ dbKey: built.agentKey,
123
+ key: built.nextRecord?.key || built.agentKey,
124
+ serverOrigin: built.serverUrl
125
+ });
126
+ clearCliLocalRuntimePreparedAgentCache();
127
+ output.write(JSON.stringify({
128
+ ok: true,
129
+ agentKey: built.agentKey,
130
+ baseUrl: built.serverUrl,
131
+ updates: sanitizeAgentRecordForCliOutput(built.updates),
132
+ record: sanitizeAgentRecordForCliOutput(built.nextRecord)
133
+ }, null, 2));
134
+ output.write("\n");
135
+ return 0;
136
+ } catch (error) {
137
+ output.write(
138
+ `[nolo] agent update failed: ${toErrorMessage(error)}
139
+ `
140
+ );
141
+ return 1;
142
+ }
143
+ }
144
+ async function runAgentCreateCommand(args, deps = {}) {
145
+ const env = deps.env ?? process.env;
146
+ const output = deps.output ?? process.stdout;
147
+ let parsed;
148
+ try {
149
+ parsed = parseAgentUpdateArgs(args);
150
+ } catch (error) {
151
+ output.write(`[nolo] agent create failed: ${toErrorMessage(error)}
152
+ `);
153
+ return 1;
154
+ }
155
+ if (!parsed) {
156
+ output.write(
157
+ "Usage: nolo agent create <agent> [--model <id>] [--cli-provider <provider>] [--api-source <source>] [--max-concurrent <n>] [--expires-at <iso>] [--prompt <text> | --prompt-file <path> | --prompt-doc <pageKey>] [--tools <json>] [--copy-provider-from <agent>] [--name <name>] [--custom-provider-url <url>] [--provider-api-key <key>] [--field key=value]\n".replace("[--field key=value]", "[--handle <name>] [--field key=value]")
158
+ );
159
+ return args[0] ? 0 : 1;
160
+ }
161
+ const authToken = resolveAuthToken(args, env);
162
+ if (!authToken) {
163
+ output.write("[nolo] agent create requires an auth token. Run `nolo login` or set AUTH_TOKEN.\n");
164
+ return 1;
165
+ }
166
+ const userId = parseUserIdFromAuthToken(authToken);
167
+ if (!userId) {
168
+ output.write("[nolo] agent create could not read userId from AUTH_TOKEN.\n");
169
+ return 1;
170
+ }
171
+ const db = deps.db ?? await getReadableCliDb(output);
172
+ const fetchImpl = deps.fetchImpl ?? fetch;
173
+ const fallbackFetchImpl = deps.fallbackFetchImpl;
174
+ try {
175
+ const built = await buildCreatedAgentRecord({
176
+ cliArgs: args,
177
+ parsed,
178
+ env,
179
+ db,
180
+ fetchImpl,
181
+ fallbackFetchImpl,
182
+ authToken
183
+ });
184
+ await writeAgentRecord({
185
+ agentKey: built.agentKey,
186
+ authToken,
187
+ fallbackFetchImpl,
188
+ fetchImpl,
189
+ serverUrl: built.serverUrl,
190
+ userId,
191
+ record: built.nextRecord
192
+ });
193
+ await db.put(built.agentKey, {
194
+ ...built.nextRecord,
195
+ dbKey: built.agentKey,
196
+ key: built.nextRecord?.key || built.agentKey,
197
+ serverOrigin: built.serverUrl
198
+ });
199
+ clearCliLocalRuntimePreparedAgentCache();
200
+ output.write(JSON.stringify({
201
+ ok: true,
202
+ agentKey: built.agentKey,
203
+ baseUrl: built.serverUrl,
204
+ updates: sanitizeAgentRecordForCliOutput(built.updates),
205
+ record: sanitizeAgentRecordForCliOutput(built.nextRecord)
206
+ }, null, 2));
207
+ output.write("\n");
208
+ return 0;
209
+ } catch (error) {
210
+ output.write(
211
+ `[nolo] agent create failed: ${toErrorMessage(error)}
212
+ `
213
+ );
214
+ return 1;
215
+ }
216
+ }
217
+
218
+ export {
219
+ runAgentReadCommand,
220
+ runAgentUpdateCommand,
221
+ runAgentCreateCommand
222
+ };
@@ -0,0 +1,34 @@
1
+ // packages/chat/dialog/actions/builtinDialogLlm.ts
2
+ var BASE_BUILTIN_DIALOG_LLM_CONFIG = {
3
+ apiSource: "platform",
4
+ useServerProxy: true
5
+ };
6
+ var BUILTIN_TITLE_LLM_CONFIG = {
7
+ ...BASE_BUILTIN_DIALOG_LLM_CONFIG,
8
+ provider: "deepseek",
9
+ id: "builtin-dialog-title-llm",
10
+ name: "Builtin Dialog Title LLM",
11
+ model: "deepseek-v4-flash",
12
+ prompt: "You are a title generator for chat history. \u4F60\u53EA\u505A\u4E00\u4EF6\u4E8B\uFF1A\u6839\u636E\u5BF9\u8BDD\u5185\u5BB9\u8F93\u51FA\u6700\u7EC8\u6807\u9898\u3002\u786C\u6027\u89C4\u5219\uFF1A1) \u53EA\u8F93\u51FA\u6807\u9898\u8FD9\u4E00\u884C\uFF1B\u4E25\u7981\u8F93\u51FA\u63A8\u7406\u3001\u5206\u6790\u3001\u6B65\u9AA4\u3001\u89E3\u91CA\u3001\u524D\u8A00\u3001\u540E\u8BB0\u3001\u7FFB\u8BD1\u3001\u81F4\u6B49\u6216\u4EFB\u4F55\u989D\u5916\u8BF4\u660E\u30022) \u4E0D\u8981\u56DE\u7B54\u7528\u6237\u8BF7\u6C42\uFF0C\u4E0D\u8981\u5199\u6458\u8981\uFF0C\u53EA\u7ED9\u6807\u9898\u7ED3\u679C\u30023) \u6807\u9898\u5C3D\u91CF\u77ED\uFF1A\u901A\u5E38 2-5 \u4E2A\u8BCD\uFF0C\u82F1\u6587\u4E0D\u8D85\u8FC7 6 \u4E2A\u8BCD\u30024) \u4F7F\u7528\u5BF9\u8BDD\u4E3B\u8BED\u8A00\uFF1B\u6DF7\u5408\u8BED\u8A00\u65F6\u4F18\u5148\u7528\u6237\u4E3B\u8981\u8BED\u8A00\u30025) \u4F18\u5148\u590D\u7528\u5BF9\u8BDD\u4E2D\u7684\u5177\u4F53\u4E3B\u9898\u8BCD\uFF0C\u907F\u514D issue\u3001help\u3001discussion\u3001analysis\u3001update \u8FD9\u7C7B\u7A7A\u6CDB\u8BCD\u30026) \u5FFD\u7565 tool JSON\u3001\u51FD\u6570\u540D\u3001branch label\u3001agent \u540D\u3001\u7CFB\u7EDF\u6307\u4EE4\u548C\u7F16\u6392\u75D5\u8FF9\uFF08\u5982 GPT\u3001Claude\u3001Gemini\uFF09\uFF1B\u6807\u9898\u8981\u843D\u5728\u7528\u6237\u771F\u6B63\u8BA8\u8BBA\u7684\u5BF9\u8C61\u6216\u51B3\u7B56\u4E0A\u30027) \u66F4\u504F\u597D\u201C\u5BF9\u8C61 + \u52A8\u4F5C/\u5224\u65AD\u201D\u7684\u77ED\u6807\u9898\uFF0C\u4F8B\u5982\u201CAI \u90AE\u4EF6\u52A9\u624B\u53D6\u820D\u201D\u201C\u4E1C\u4EAC\u56DB\u65E5\u6162\u65C5\u884C\u201D\u201C\u91CD\u590D\u6263\u8D39\u9000\u6B3E\u201D\u30028) \u7EAF\u6587\u672C\uFF0C\u4E0D\u8981\u9879\u76EE\u7B26\u53F7\u3001\u7F16\u53F7\u3001markdown\u3001emoji\u3002\u6700\u7EC8\u53EA\u8FD4\u56DE\u6807\u9898\u6587\u672C\u3002 Output only the title text."
13
+ };
14
+ var BUILTIN_SUMMARY_LLM_CONFIG = {
15
+ ...BASE_BUILTIN_DIALOG_LLM_CONFIG,
16
+ provider: "deepseek",
17
+ id: "builtin-dialog-summary-llm",
18
+ name: "Builtin Dialog Summary LLM",
19
+ model: "deepseek-v4-pro",
20
+ prompt: "\u4F60\u662F\u4E00\u4E2A\u4E13\u4E1A\u7684\u5BF9\u8BDD\u8BB0\u5FC6\u52A9\u7406\u3002\u8BF7\u57FA\u4E8E\u3010\u73B0\u6709\u8BB0\u5FC6\u3011\u548C\u3010\u65B0\u589E\u5BF9\u8BDD\u3011\uFF0C\u8F93\u51FA\u4E00\u4EFD\u66F4\u65B0\u540E\u7684\u5BF9\u8BDD\u8BB0\u5FC6\u6863\u6848\u3002\u4E25\u683C\u53EA\u8F93\u51FA\u4E0B\u9762\u4E24\u90E8\u5206\uFF0C\u6807\u9898\u5FC5\u987B\u5B8C\u5168\u4E00\u81F4\uFF1A\n\u5173\u952E\u4E8B\u5B9E\u6863\u6848\n- ...\n\u5BF9\u8BDD\u5267\u60C5\u6458\u8981\n- ...\n\u8981\u6C42\uFF1A1) \u4F7F\u7528\u5BF9\u8BDD\u4E3B\u8BED\u8A00\uFF1B\u6DF7\u5408\u8BED\u8A00\u65F6\u4F18\u5148\u8DDF\u968F\u7528\u6237\u4E3B\u8981\u8BED\u8A00\uFF0C\u4E13\u6709\u540D\u8BCD\u4FDD\u7559\u539F\u6587\u30022) \u5173\u952E\u4E8B\u5B9E\u6863\u6848\u53EA\u4FDD\u7559\u4E4B\u540E\u7EE7\u7EED\u5BF9\u8BDD\u4ECD\u6709\u4EF7\u503C\u7684\u4FE1\u606F\uFF0C\u4F8B\u5982\u7528\u6237\u504F\u597D\u3001\u76EE\u6807\u3001\u7EA6\u675F\u3001\u6280\u672F\u6808\u3001\u786E\u5B9A\u7684\u6587\u4EF6\u540D/\u53D8\u91CF\u540D\u3001\u6838\u5FC3\u51B3\u7B56\u3001\u5F85\u529E\u4E8B\u9879\u30023) \u5BF9\u8BDD\u5267\u60C5\u6458\u8981\u5148\u6781\u7B80\u6982\u62EC\u65E7\u4E0A\u4E0B\u6587\uFF0C\u518D\u66F4\u8BE6\u7EC6\u8BB0\u5F55\u6700\u8FD1\u65B0\u589E\u7684\u8FDB\u5C55\u3001\u5206\u6B67\u3001\u7ED3\u8BBA\u548C\u4E0B\u4E00\u6B65\u30024) \u5FFD\u7565\u5BD2\u6684\u3001\u91CD\u590D\u5C1D\u8BD5\u3001\u5DF2\u653E\u5F03\u65B9\u6848\u548C\u65E0\u4EF7\u503C\u5E9F\u8BDD\u30025) \u4E0D\u8981\u7F16\u9020\u672A\u51FA\u73B0\u7684\u4FE1\u606F\uFF0C\u4E0D\u8981\u8F93\u51FA\u5F00\u573A\u767D\u3001\u7ED3\u675F\u8BED\u3001markdown \u4EE3\u7801\u5757\u6216\u989D\u5916\u7AE0\u8282\u3002"
21
+ };
22
+ var buildBuiltinSummaryContent = (previousSummary, messagesText) => `
23
+ \u3010\u73B0\u6709\u8BB0\u5FC6\u3011\uFF1A
24
+ ${previousSummary || "(\u65E0)"}
25
+
26
+ \u3010\u65B0\u589E\u5BF9\u8BDD\u3011\uFF1A
27
+ ${messagesText}
28
+ `.trim();
29
+
30
+ export {
31
+ BUILTIN_TITLE_LLM_CONFIG,
32
+ BUILTIN_SUMMARY_LLM_CONFIG,
33
+ buildBuiltinSummaryContent
34
+ };
@@ -0,0 +1,301 @@
1
+ import {
2
+ getCredentialsDir
3
+ } from "./chunk-JZPBVBIY.js";
4
+ import {
5
+ asNonEmptyStringArray
6
+ } from "./chunk-I42VC5KR.js";
7
+ import {
8
+ asTrimmedString
9
+ } from "./chunk-3EUW3WEO.js";
10
+ import {
11
+ asOptionalPositiveFiniteNumber
12
+ } from "./chunk-U6VC4MU4.js";
13
+ import {
14
+ isRecord
15
+ } from "./chunk-KUG52IAP.js";
16
+
17
+ // packages/agent-runtime/fileCredentialBroker.ts
18
+ import {
19
+ chmodSync,
20
+ existsSync,
21
+ mkdirSync,
22
+ readFileSync,
23
+ unlinkSync,
24
+ writeFileSync
25
+ } from "node:fs";
26
+ import { homedir } from "node:os";
27
+ import { join } from "node:path";
28
+
29
+ // packages/agent-runtime/credentialBroker.ts
30
+ function assertCredentialRef(ref) {
31
+ const trimmed = asTrimmedString(ref);
32
+ if (!trimmed) {
33
+ throw new Error("invalid_ref");
34
+ }
35
+ if (trimmed.includes("..") || trimmed.includes("/") || trimmed.includes("\\")) {
36
+ throw new Error("invalid_ref");
37
+ }
38
+ return trimmed;
39
+ }
40
+
41
+ // packages/agent-runtime/fileCredentialBroker.ts
42
+ function getApiKeyCredentialsDir(homeDir = homedir()) {
43
+ return join(getCredentialsDir(homeDir), "keys");
44
+ }
45
+ function credentialRefToFileName(ref) {
46
+ const safe = assertCredentialRef(ref).replace(/[^a-zA-Z0-9._-]+/g, "_");
47
+ if (!safe || safe === "." || safe === "..") {
48
+ throw new Error(`Credential ref is not filesystem-safe: ${ref}`);
49
+ }
50
+ return `${safe}.json`;
51
+ }
52
+ function getApiKeyCredentialPath(ref, homeDir = homedir()) {
53
+ return join(getApiKeyCredentialsDir(homeDir), credentialRefToFileName(ref));
54
+ }
55
+ function ensurePrivateDir(dir) {
56
+ mkdirSync(dir, { recursive: true, mode: 448 });
57
+ try {
58
+ chmodSync(dir, 448);
59
+ } catch {
60
+ }
61
+ }
62
+ function writePrivateFile(path, body) {
63
+ writeFileSync(path, body, { encoding: "utf8", mode: 384 });
64
+ try {
65
+ chmodSync(path, 384);
66
+ } catch {
67
+ }
68
+ }
69
+ function readApiKeyCredential(ref, homeDir = homedir()) {
70
+ const path = getApiKeyCredentialPath(ref, homeDir);
71
+ if (!existsSync(path)) return null;
72
+ try {
73
+ const raw = readFileSync(path, "utf8");
74
+ const parsed = JSON.parse(raw);
75
+ if (typeof parsed?.secret !== "string" || !parsed.secret) return null;
76
+ return parsed.secret;
77
+ } catch {
78
+ return null;
79
+ }
80
+ }
81
+ function writeApiKeyCredential(ref, secret, homeDir = homedir(), now = Date.now()) {
82
+ const trimmedSecret = secret.trim();
83
+ if (!trimmedSecret) {
84
+ throw new Error("Cannot store an empty credential secret.");
85
+ }
86
+ assertCredentialRef(ref);
87
+ const dir = getApiKeyCredentialsDir(homeDir);
88
+ ensurePrivateDir(dir);
89
+ const path = getApiKeyCredentialPath(ref, homeDir);
90
+ const payload = {
91
+ secret: trimmedSecret,
92
+ updatedAt: now
93
+ };
94
+ writePrivateFile(path, `${JSON.stringify(payload, null, 2)}
95
+ `);
96
+ }
97
+ function removeApiKeyCredential(ref, homeDir = homedir()) {
98
+ assertCredentialRef(ref);
99
+ const path = getApiKeyCredentialPath(ref, homeDir);
100
+ if (!existsSync(path)) return;
101
+ unlinkSync(path);
102
+ }
103
+ function hasApiKeyCredential(ref, homeDir = homedir()) {
104
+ return readApiKeyCredential(ref, homeDir) !== null;
105
+ }
106
+ function createFileCredentialBroker(options = {}) {
107
+ const homeDir = options.homeDir ?? homedir();
108
+ const now = options.now ?? Date.now;
109
+ return {
110
+ get(ref) {
111
+ return readApiKeyCredential(ref, homeDir);
112
+ },
113
+ put(ref, secret) {
114
+ writeApiKeyCredential(ref, secret, homeDir, now());
115
+ },
116
+ delete(ref) {
117
+ removeApiKeyCredential(ref, homeDir);
118
+ },
119
+ has(ref) {
120
+ return hasApiKeyCredential(ref, homeDir);
121
+ }
122
+ };
123
+ }
124
+
125
+ // packages/agent-runtime/migrateAgentSecrets.ts
126
+ function buildAgentApiKeyCredentialRef(agentKey) {
127
+ const key = asTrimmedString(agentKey);
128
+ if (!key) throw new Error("agentKey is required to build a credential ref.");
129
+ return `api-key:${key}`;
130
+ }
131
+ function readRawApiKey(agent) {
132
+ return asTrimmedString(agent.apiKey);
133
+ }
134
+ function resolveTargetRef(agent) {
135
+ const fromCredential = asTrimmedString(agent.credentialRef);
136
+ if (fromCredential) return fromCredential;
137
+ const fromApiKeyRef = asTrimmedString(agent.apiKeyRef);
138
+ if (fromApiKeyRef.startsWith("api-key:")) return fromApiKeyRef;
139
+ return buildAgentApiKeyCredentialRef(agent.key);
140
+ }
141
+ async function brokerHas(broker, ref) {
142
+ return Boolean(await broker.has(ref));
143
+ }
144
+ async function brokerPut(broker, ref, secret) {
145
+ await broker.put(ref, secret);
146
+ }
147
+ async function migrateAgentSecrets(args) {
148
+ const { agent, broker } = args;
149
+ const raw = readRawApiKey(agent);
150
+ const migration = asTrimmedString(agent.credentialMigration);
151
+ if (migration === "done" && !raw) {
152
+ const ref = typeof agent.credentialRef === "string" && agent.credentialRef.trim() || (typeof agent.apiKeyRef === "string" && agent.apiKeyRef.startsWith("api-key:") ? agent.apiKeyRef.trim() : "") || void 0;
153
+ return {
154
+ updates: {},
155
+ status: "already-done",
156
+ ...ref ? { credentialRef: ref } : {},
157
+ phase: "complete"
158
+ };
159
+ }
160
+ if (!raw && migration !== "pending") {
161
+ return { updates: {}, status: "noop", phase: "none" };
162
+ }
163
+ const targetRef = resolveTargetRef(agent);
164
+ if (raw) {
165
+ await brokerPut(broker, targetRef, raw);
166
+ const stored2 = await brokerHas(broker, targetRef);
167
+ if (!stored2) {
168
+ return {
169
+ updates: {
170
+ credentialRef: targetRef,
171
+ credentialMigration: "pending"
172
+ },
173
+ status: "resumed-pending",
174
+ credentialRef: targetRef,
175
+ phase: "put"
176
+ };
177
+ }
178
+ return {
179
+ updates: {
180
+ apiKey: null,
181
+ credentialRef: targetRef,
182
+ // Keep apiKeyRef for resolution if not already an OAuth provider name.
183
+ // Prefer explicit credentialRef; set apiKeyRef only when empty so OAuth agents stay intact.
184
+ ...!(typeof agent.apiKeyRef === "string" && agent.apiKeyRef.trim()) ? { apiKeyRef: targetRef } : {},
185
+ credentialMigration: "done"
186
+ },
187
+ status: migration === "pending" ? "resumed-pending" : "migrated",
188
+ credentialRef: targetRef,
189
+ phase: "strip"
190
+ };
191
+ }
192
+ const stored = await brokerHas(broker, targetRef);
193
+ if (stored) {
194
+ return {
195
+ updates: {
196
+ credentialRef: targetRef,
197
+ credentialMigration: "done",
198
+ ...!(typeof agent.apiKeyRef === "string" && agent.apiKeyRef.trim()) ? { apiKeyRef: targetRef } : {}
199
+ },
200
+ status: "resumed-pending",
201
+ credentialRef: targetRef,
202
+ phase: "complete"
203
+ };
204
+ }
205
+ return {
206
+ updates: {
207
+ credentialRef: targetRef,
208
+ credentialMigration: "pending"
209
+ },
210
+ status: "awaiting-secret",
211
+ credentialRef: targetRef,
212
+ phase: "put"
213
+ };
214
+ }
215
+ function applyAgentSecretMigrationUpdates(record, updates) {
216
+ const next = { ...record };
217
+ if ("apiKey" in updates) {
218
+ if (updates.apiKey === null || updates.apiKey === "") {
219
+ delete next.apiKey;
220
+ } else if (typeof updates.apiKey === "string") {
221
+ next.apiKey = updates.apiKey;
222
+ }
223
+ }
224
+ if (updates.apiKeyRef !== void 0) next.apiKeyRef = updates.apiKeyRef;
225
+ if (updates.credentialRef !== void 0) next.credentialRef = updates.credentialRef;
226
+ if (updates.credentialMigration !== void 0) {
227
+ next.credentialMigration = updates.credentialMigration;
228
+ }
229
+ return next;
230
+ }
231
+
232
+ // packages/agent-runtime/runtimeToolPolicy.ts
233
+ function unique(values) {
234
+ return [...new Set(values)];
235
+ }
236
+ function normalizeAgentRuntimeToolPolicy(value) {
237
+ if (!isRecord(value)) return void 0;
238
+ return {
239
+ version: 1,
240
+ ...asNonEmptyStringArray(value.agentTools).length ? { agentTools: unique(asNonEmptyStringArray(value.agentTools)) } : {},
241
+ ...asNonEmptyStringArray(value.runtimeTools).length ? { runtimeTools: unique(asNonEmptyStringArray(value.runtimeTools)) } : {},
242
+ ...isRecord(value.workspace) ? { workspace: { ...value.workspace } } : {},
243
+ ...isRecord(value.shell) ? { shell: { ...value.shell } } : {},
244
+ ...isRecord(value.isolation) ? { isolation: { ...value.isolation } } : {},
245
+ ...isRecord(value.git) ? { git: { ...value.git } } : {},
246
+ ...isRecord(value.budget) ? { budget: { ...value.budget } } : {},
247
+ ...isRecord(value.audit) ? { audit: { ...value.audit } } : {}
248
+ };
249
+ }
250
+ function runtimeBindingRecord(runtimeBinding) {
251
+ return isRecord(runtimeBinding) ? runtimeBinding : void 0;
252
+ }
253
+ function runtimeToolNamesFromPolicy(policy) {
254
+ return asNonEmptyStringArray(policy?.runtimeTools);
255
+ }
256
+ function readPositiveNumber(value) {
257
+ return asOptionalPositiveFiniteNumber(Number(value));
258
+ }
259
+ function resolveRequestedRuntimeToolNames(args) {
260
+ const runtimeBinding = runtimeBindingRecord(args.agentConfig.runtimeBinding);
261
+ const bindingPolicy = normalizeAgentRuntimeToolPolicy(
262
+ runtimeBinding?.runtimeToolPolicy
263
+ );
264
+ const bindingSnapshotPolicy = normalizeAgentRuntimeToolPolicy(
265
+ runtimeBinding?.runtimeToolPolicySnapshot
266
+ );
267
+ return unique([
268
+ ...asNonEmptyStringArray(args.agentConfig.toolNames),
269
+ ...runtimeToolNamesFromPolicy(
270
+ normalizeAgentRuntimeToolPolicy(args.agentConfig.runtimeToolPolicy)
271
+ ),
272
+ ...runtimeToolNamesFromPolicy(bindingPolicy),
273
+ ...runtimeToolNamesFromPolicy(bindingSnapshotPolicy)
274
+ ]);
275
+ }
276
+ function resolveCurrentRunRuntimeToolPolicy(agentConfig) {
277
+ const runtimeBinding = runtimeBindingRecord(agentConfig?.runtimeBinding);
278
+ return normalizeAgentRuntimeToolPolicy(
279
+ runtimeBinding?.runtimeToolPolicySnapshot ?? agentConfig?.runtimeToolPolicy ?? runtimeBinding?.runtimeToolPolicy
280
+ );
281
+ }
282
+ function resolveLocalRuntimeEnvFromPolicy(runtimeEnv, policy) {
283
+ return { ...runtimeEnv };
284
+ }
285
+ function resolveLocalWorkspaceExecutorOptionsFromPolicy(policy) {
286
+ const maxOutputBytes = readPositiveNumber(policy?.shell?.maxOutputBytes);
287
+ return {
288
+ ...maxOutputBytes ? { commandOutputLimit: Math.floor(maxOutputBytes) } : {}
289
+ };
290
+ }
291
+
292
+ export {
293
+ createFileCredentialBroker,
294
+ migrateAgentSecrets,
295
+ applyAgentSecretMigrationUpdates,
296
+ normalizeAgentRuntimeToolPolicy,
297
+ resolveRequestedRuntimeToolNames,
298
+ resolveCurrentRunRuntimeToolPolicy,
299
+ resolveLocalRuntimeEnvFromPolicy,
300
+ resolveLocalWorkspaceExecutorOptionsFromPolicy
301
+ };