nolo-cli 0.1.32 → 0.1.34

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 (234) hide show
  1. package/README.md +4 -10
  2. package/agent-runtime/agentRecordConfig.ts +10 -0
  3. package/agent-runtime/hostAdapter.ts +10 -1
  4. package/agent-runtime/index.ts +9 -20
  5. package/agent-runtime/localLoop.ts +49 -2
  6. package/agent-runtime/localToolPolicy.ts +76 -34
  7. package/agent-runtime/localWorkspaceTools.ts +30 -333
  8. package/agent-runtime/openAiCompatibleProvider.ts +7 -3
  9. package/agent-runtime/openAiCompatibleProviderConfig.ts +15 -26
  10. package/agent-runtime/platformChatProvider.ts +47 -73
  11. package/agent-runtime/providerResolution.ts +244 -0
  12. package/agent-runtime/runtimeToolPolicy.ts +77 -29
  13. package/agent-runtime/shellCommandPolicy.ts +120 -0
  14. package/agentAliases.ts +14 -83
  15. package/agentCommandSupport.ts +3 -6
  16. package/agentInternalCommandEntries.ts +4 -13
  17. package/agentListCommands.ts +18 -27
  18. package/agentMachineCommands.ts +40 -336
  19. package/agentPullCommand.ts +30 -55
  20. package/agentRecordCommands.ts +84 -1
  21. package/agentRecordHelpers.ts +102 -186
  22. package/agentRunCommand.ts +438 -107
  23. package/agentRuntimeLocal.ts +2 -9
  24. package/ai/agent/cliExecutor.ts +19 -323
  25. package/ai/tools/toolNameAliases.ts +70 -0
  26. package/authCommands.ts +2 -36
  27. package/cli/agentAliases.ts +14 -83
  28. package/cli/agentCommandSupport.ts +3 -6
  29. package/cli/agentInternalCommandEntries.ts +4 -13
  30. package/cli/agentListCommands.ts +18 -27
  31. package/cli/agentMachineCommands.ts +40 -336
  32. package/cli/agentPullCommand.ts +30 -55
  33. package/cli/agentRecordCommands.ts +84 -1
  34. package/cli/agentRecordHelpers.ts +102 -186
  35. package/cli/agentRunCommand.ts +438 -107
  36. package/cli/agentRuntimeLocal.ts +2 -9
  37. package/cli/authCommands.ts +2 -36
  38. package/cli/cliCommandDispatch.ts +2 -2
  39. package/cli/cliEnvHelpers.ts +34 -107
  40. package/cli/client/agentRun.ts +854 -57
  41. package/cli/client/localRuntimeAdapter.ts +59 -159
  42. package/cli/client/streamingOutput.ts +3 -1
  43. package/cli/client/taskRunPrompt.ts +24 -7
  44. package/cli/commandRegistry.ts +4 -5
  45. package/cli/connectorRunArtifact.ts +10 -34
  46. package/cli/connectorWebSocketTarget.ts +6 -10
  47. package/cli/internalCommandEntries.ts +0 -8
  48. package/cli/localRuntimeDb.ts +2 -39
  49. package/cli/machineCommands.ts +189 -190
  50. package/cli/machineDaemonCommands.ts +165 -9
  51. package/cli/machineHeartbeatCommands.ts +2 -1
  52. package/cli/machineStatusCommands.ts +13 -5
  53. package/cli/machineWatchCommands.ts +1 -1
  54. package/cli/machineWsRunDispatch.ts +30 -44
  55. package/cli/machineWsSession.ts +0 -2
  56. package/cli/offlineMarxistsAgentCommand.ts +314 -0
  57. package/cli/runtimeDoctorCommands.ts +72 -15
  58. package/cli/scriptCommandEntries.ts +45 -5
  59. package/cli/tableCommands.ts +133 -33
  60. package/cli/taskRunCommand.ts +211 -16
  61. package/cli/tui/session.ts +372 -43
  62. package/cli/workflowInternalCommandEntries.ts +0 -20
  63. package/cliCommandDispatch.ts +2 -2
  64. package/cliEnvHelpers.ts +34 -107
  65. package/client/agentConfigResolver.test.ts +2 -0
  66. package/client/agentRun.test.ts +12 -208
  67. package/client/agentRun.ts +854 -57
  68. package/client/localProviderResolver.test.ts +26 -2
  69. package/client/localRuntimeAdapter.test.ts +296 -171
  70. package/client/localRuntimeAdapter.ts +59 -159
  71. package/client/localToolPolicy.test.ts +4 -28
  72. package/client/streamingOutput.ts +3 -1
  73. package/client/taskRunPrompt.ts +24 -7
  74. package/commandRegistry.ts +4 -5
  75. package/connectorRunArtifact.ts +10 -34
  76. package/connectorWebSocketTarget.ts +6 -10
  77. package/database/server/serverStoreFactory.ts +2 -8
  78. package/internalCommandEntries.ts +0 -8
  79. package/localRuntimeDb.ts +2 -39
  80. package/machineCommands.ts +189 -190
  81. package/machineDaemonCommands.ts +165 -9
  82. package/machineHeartbeatCommands.ts +2 -1
  83. package/machineStatusCommands.ts +13 -5
  84. package/machineWatchCommands.ts +1 -1
  85. package/machineWsRunDispatch.ts +30 -44
  86. package/machineWsSession.ts +0 -2
  87. package/offlineMarxistsAgentCommand.ts +314 -0
  88. package/package.json +52 -188
  89. package/runtimeDoctorCommands.ts +72 -15
  90. package/scriptCommandEntries.ts +45 -5
  91. package/tableCommands.ts +133 -33
  92. package/taskRunCommand.ts +211 -16
  93. package/tui/session.ts +372 -43
  94. package/workflowInternalCommandEntries.ts +0 -20
  95. package/agent-runtime/dialogStatus.ts +0 -139
  96. package/agent-runtime/hostRuntimeConfig.ts +0 -86
  97. package/agentCreateCustomCommands.ts +0 -278
  98. package/agentDialogsCommands.ts +0 -227
  99. package/agentDoctorCommands.ts +0 -203
  100. package/agentRunLocalWorkspace.ts +0 -182
  101. package/agentRunParsing.ts +0 -298
  102. package/agentSuperviseCommands.ts +0 -8
  103. package/agentUnpublishCommands.ts +0 -113
  104. package/ai/agent/agentRunDialogLineage.ts +0 -56
  105. package/ai/policy/types.ts +0 -64
  106. package/ai/skills/skillSummaryMarker.ts +0 -26
  107. package/app/types.ts +0 -358
  108. package/build.ts +0 -16
  109. package/buildPublish.ts +0 -138
  110. package/buildPublishArtifactAssembly.ts +0 -724
  111. package/buildPublishImportAnalysis.ts +0 -242
  112. package/chat/messages/fetchMessages.ts +0 -84
  113. package/chat/messages/types.ts +0 -185
  114. package/cli/agentCreateCustomCommands.ts +0 -278
  115. package/cli/agentDialogsCommands.ts +0 -227
  116. package/cli/agentDoctorCommands.ts +0 -203
  117. package/cli/agentRunLocalWorkspace.ts +0 -182
  118. package/cli/agentRunParsing.ts +0 -298
  119. package/cli/agentSuperviseCommands.ts +0 -8
  120. package/cli/agentUnpublishCommands.ts +0 -113
  121. package/cli/buildPublish.ts +0 -138
  122. package/cli/buildPublishArtifactAssembly.ts +0 -724
  123. package/cli/buildPublishImportAnalysis.ts +0 -242
  124. package/cli/cliIoTypes.ts +0 -3
  125. package/cli/cliRuntimeDoctorReport.ts +0 -193
  126. package/cli/client/agentRunInput.ts +0 -10
  127. package/cli/client/agentRunLocalExecution.ts +0 -124
  128. package/cli/client/agentRunLocalExecutor.ts +0 -179
  129. package/cli/client/agentRunRuntimeSelection.ts +0 -145
  130. package/cli/client/agentRunServerTransport.ts +0 -397
  131. package/cli/client/agentRunTaskRunRecorder.ts +0 -176
  132. package/cli/customCodingAgentFlow.ts +0 -208
  133. package/cli/customCodingAgentRecord.ts +0 -179
  134. package/cli/dialogDataAccess.ts +0 -186
  135. package/cli/dialogInternalCommandEntries.ts +0 -11
  136. package/cli/dialogReadCommands.ts +0 -180
  137. package/cli/dialogReadHelpers.ts +0 -226
  138. package/cli/dialogStatusCommands.ts +0 -123
  139. package/cli/docInternalCommandEntries.ts +0 -20
  140. package/cli/hybridReadHelpers.ts +0 -109
  141. package/cli/machineCommandPrompts.ts +0 -79
  142. package/cli/machineCommandResolution.ts +0 -43
  143. package/cli/noloReadBridgePrompt.ts +0 -16
  144. package/cli/pageCreateCommands.ts +0 -219
  145. package/cli/pageDeleteCommands.ts +0 -167
  146. package/cli/pageReadCommands.ts +0 -151
  147. package/cli/pageUpdateCommands.ts +0 -249
  148. package/cli/pageWriteHelpers.ts +0 -209
  149. package/cli/publishPackage.ts +0 -36
  150. package/cli/runtimeInternalCommandEntries.ts +0 -15
  151. package/cli/runtimePassthroughCommands.ts +0 -22
  152. package/cli/scriptPassthroughHelpers.ts +0 -28
  153. package/cli/secretScanHelpers.ts +0 -31
  154. package/cli/spaceAttachCommands.ts +0 -134
  155. package/cli/spaceCategoryCommands.ts +0 -263
  156. package/cli/spaceCommands.ts +0 -295
  157. package/cli/spaceDeleteCommands.ts +0 -312
  158. package/cli/spaceInternalCommandEntries.ts +0 -21
  159. package/cli/spaceMutationHelpers.ts +0 -135
  160. package/cli/spaceReadCommands.ts +0 -323
  161. package/cli/tableDataOutput.ts +0 -41
  162. package/cli/tableDataSafety.ts +0 -26
  163. package/cli/tableMetaCommands.ts +0 -307
  164. package/cli/tableMutationCommands.ts +0 -266
  165. package/cli/tableQueryParsing.ts +0 -90
  166. package/cli/tableQueryRequest.ts +0 -53
  167. package/cli/taskRunActions.ts +0 -122
  168. package/cli/taskRunParsing.ts +0 -86
  169. package/cli/taskRunPromptShared.ts +0 -55
  170. package/cli/tui/tuiCatalog.ts +0 -22
  171. package/cli/tui/tuiCommandInterpreter.ts +0 -253
  172. package/cli/tui/tuiPresentation.ts +0 -146
  173. package/cliIoTypes.ts +0 -3
  174. package/cliRuntimeDoctorReport.ts +0 -193
  175. package/client/agentRunInput.ts +0 -10
  176. package/client/agentRunLocalExecution.test.ts +0 -123
  177. package/client/agentRunLocalExecution.ts +0 -124
  178. package/client/agentRunLocalExecutor.ts +0 -179
  179. package/client/agentRunRuntimeSelection.test.ts +0 -159
  180. package/client/agentRunRuntimeSelection.ts +0 -145
  181. package/client/agentRunServerTransport.ts +0 -397
  182. package/client/agentRunTaskRunRecorder.ts +0 -176
  183. package/connector-experimental/daemonLauncher.ts +0 -223
  184. package/create/space/spaceKeys.ts +0 -65
  185. package/create/types.ts +0 -21
  186. package/customCodingAgentFlow.ts +0 -208
  187. package/customCodingAgentRecord.ts +0 -179
  188. package/database/keys.ts +0 -765
  189. package/database/tombstones.ts +0 -52
  190. package/database/utils/ulid.ts +0 -1
  191. package/dialogDataAccess.ts +0 -186
  192. package/dialogInternalCommandEntries.ts +0 -11
  193. package/dialogReadCommands.ts +0 -180
  194. package/dialogReadHelpers.ts +0 -226
  195. package/dialogStatusCommands.ts +0 -123
  196. package/docInternalCommandEntries.ts +0 -20
  197. package/hybridReadHelpers.ts +0 -109
  198. package/machineCommandPrompts.ts +0 -79
  199. package/machineCommandResolution.ts +0 -43
  200. package/noloReadBridgePrompt.ts +0 -16
  201. package/pageCreateCommands.ts +0 -219
  202. package/pageDeleteCommands.ts +0 -167
  203. package/pageReadCommands.ts +0 -151
  204. package/pageUpdateCommands.ts +0 -249
  205. package/pageWriteHelpers.ts +0 -209
  206. package/publishPackage.ts +0 -36
  207. package/runtimeInternalCommandEntries.ts +0 -15
  208. package/runtimePassthroughCommands.ts +0 -22
  209. package/scriptPassthroughHelpers.ts +0 -28
  210. package/secretScanHelpers.ts +0 -31
  211. package/share/helpers.ts +0 -302
  212. package/share/keys.ts +0 -243
  213. package/share/types.ts +0 -100
  214. package/spaceAttachCommands.ts +0 -134
  215. package/spaceCategoryCommands.ts +0 -263
  216. package/spaceCommands.ts +0 -295
  217. package/spaceDeleteCommands.ts +0 -312
  218. package/spaceInternalCommandEntries.ts +0 -21
  219. package/spaceMutationHelpers.ts +0 -135
  220. package/spaceReadCommands.ts +0 -323
  221. package/tableDataOutput.ts +0 -41
  222. package/tableDataSafety.ts +0 -26
  223. package/tableMetaCommands.ts +0 -307
  224. package/tableMutationCommands.ts +0 -266
  225. package/tableQueryParsing.ts +0 -90
  226. package/tableQueryRequest.ts +0 -53
  227. package/taskRunActions.ts +0 -122
  228. package/taskRunParsing.ts +0 -86
  229. package/taskRunPromptShared.ts +0 -55
  230. package/tui/tuiCatalog.ts +0 -22
  231. package/tui/tuiCommandInterpreter.test.ts +0 -169
  232. package/tui/tuiCommandInterpreter.ts +0 -253
  233. package/tui/tuiPresentation.test.ts +0 -154
  234. package/tui/tuiPresentation.ts +0 -146
package/share/keys.ts DELETED
@@ -1,243 +0,0 @@
1
- import { createKey, splitKey, isAgentKey } from "../database/keys";
2
- import { DataType } from "../create/types";
3
- import { toSafeAgentKey } from "./helpers";
4
-
5
- const SHARE_PREFIX = "share";
6
- const SHARE_INDEX_PREFIX = "shareidx";
7
- const TIMESTAMP_MAX = 9_999_999_999_999;
8
-
9
- // ── Normalization ───────────────────────────────────────────────────
10
-
11
- const normalizeUserId = (value: unknown): string => {
12
- const text = String(value || "").trim();
13
- return text.startsWith("user:") ? text.slice(5) : text;
14
- };
15
-
16
- const normalizeToken = (value: unknown): string =>
17
- String(value || "").trim();
18
-
19
- const normalizeCreatedAt = (value: unknown): number => {
20
- const parsed = Math.floor(Number(value));
21
- if (!Number.isFinite(parsed) || parsed < 0) return 0;
22
- return Math.min(parsed, TIMESTAMP_MAX);
23
- };
24
-
25
- const toInvertedTimestamp = (value: unknown): string =>
26
- String(TIMESTAMP_MAX - normalizeCreatedAt(value)).padStart(13, "0");
27
-
28
- // ── Community index builders ────────────────────────────────────────
29
-
30
- type CommunityDimension = "creator" | "agent";
31
-
32
- const normalizeDimensionValue = (dim: CommunityDimension, raw: unknown): string =>
33
- dim === "creator" ? normalizeUserId(raw) : toSafeAgentKey(raw);
34
-
35
- const createCommunityIndex = (
36
- dim: CommunityDimension,
37
- rawValue: unknown,
38
- createdAt: unknown,
39
- token: unknown
40
- ): string => {
41
- const value = normalizeDimensionValue(dim, rawValue);
42
- const normalizedToken = normalizeToken(token);
43
- if (!value || !normalizedToken) return "";
44
- return createKey(SHARE_INDEX_PREFIX, "community", dim, value, toInvertedTimestamp(createdAt), normalizedToken);
45
- };
46
-
47
- const createCommunityRange = (dim: CommunityDimension, rawValue: unknown) => {
48
- const value = normalizeDimensionValue(dim, rawValue);
49
- if (!value) return { start: "", end: "" };
50
- const start = createKey(SHARE_INDEX_PREFIX, "community", dim, value, "");
51
- return { start, end: start + "\uffff" };
52
- };
53
-
54
- // ── Global community index (all community shares, time-ordered) ─────
55
-
56
- const createCommunityAllIndex = (
57
- createdAt: unknown,
58
- token: unknown
59
- ): string => {
60
- const normalizedToken = normalizeToken(token);
61
- if (!normalizedToken) return "";
62
- return createKey(SHARE_INDEX_PREFIX, "community", "all", toInvertedTimestamp(createdAt), normalizedToken);
63
- };
64
-
65
- const createCommunityAllRange = () => {
66
- const start = createKey(SHARE_INDEX_PREFIX, "community", "all", "");
67
- return { start, end: start + "\uffff" };
68
- };
69
-
70
- // ── Owner index (all shares regardless of visibility) ───────────────
71
-
72
- const createOwnerIndex = (
73
- rawUserId: unknown,
74
- createdAt: unknown,
75
- token: unknown
76
- ): string => {
77
- const userId = normalizeUserId(rawUserId);
78
- const normalizedToken = normalizeToken(token);
79
- if (!userId || !normalizedToken) return "";
80
- return createKey(SHARE_INDEX_PREFIX, "owner", userId, toInvertedTimestamp(createdAt), normalizedToken);
81
- };
82
-
83
- const createOwnerRange = (rawUserId: unknown) => {
84
- const userId = normalizeUserId(rawUserId);
85
- if (!userId) return { start: "", end: "" };
86
- const start = createKey(SHARE_INDEX_PREFIX, "owner", userId, "");
87
- return { start, end: start + "\uffff" };
88
- };
89
-
90
- // ── Agent key resolution from payload ───────────────────────────────
91
-
92
- const findAgentKeyInArray = (arr: unknown[]): string => {
93
- for (const item of arr) {
94
- const key = toSafeAgentKey(item);
95
- if (key) return key;
96
- }
97
- return "";
98
- };
99
-
100
- const findAgentKeyInMessages = (messages: unknown[]): string => {
101
- for (const raw of messages) {
102
- if (!raw || typeof raw !== "object") continue;
103
- const key = toSafeAgentKey((raw as Record<string, unknown>).cybotKey);
104
- if (key) return key;
105
- }
106
- return "";
107
- };
108
-
109
- const resolveAgentKeyFromPayload = (data: any): string => {
110
- if (!data || typeof data !== "object") return "";
111
-
112
- const meta = data?.meta;
113
- const payload = data?.data;
114
-
115
- const directCandidates: unknown[] = [
116
- meta?.sourceAgentKey, meta?.agentKey,
117
- data?.sourceAgentKey, data?.agentKey, data?.cybotKey,
118
- data?.type === DataType.CYBOT ? (data?.dbKey ?? data?.id) : "",
119
- ];
120
-
121
- for (const c of directCandidates) {
122
- const key = toSafeAgentKey(c);
123
- if (key) return key;
124
- }
125
-
126
- if (payload && typeof payload === "object") {
127
- const payloadCandidates: unknown[] = [
128
- payload?.sourceAgentKey, payload?.agentKey, payload?.cybotKey,
129
- payload?.meta?.sourceAgentKey, payload?.meta?.agentKey,
130
- data?.type === DataType.CYBOT ? (payload?.dbKey ?? payload?.id) : "",
131
- ];
132
- for (const c of payloadCandidates) {
133
- const key = toSafeAgentKey(c);
134
- if (key) return key;
135
- }
136
-
137
- if (Array.isArray(payload?.cybots)) {
138
- const key = findAgentKeyInArray(payload.cybots);
139
- if (key) return key;
140
- }
141
- if (Array.isArray(payload?.messages)) {
142
- const key = findAgentKeyInMessages(payload.messages);
143
- if (key) return key;
144
- }
145
- if (Array.isArray(payload?.history)) {
146
- const key = findAgentKeyInMessages(payload.history);
147
- if (key) return key;
148
- }
149
- }
150
-
151
- return "";
152
- };
153
-
154
- // ── Public API ──────────────────────────────────────────────────────
155
-
156
- export const shareKey = {
157
- create: (token: string) => createKey(SHARE_PREFIX, token),
158
-
159
- range: () => {
160
- const start = createKey(SHARE_PREFIX, "");
161
- return { start, end: start + "\uffff" };
162
- },
163
-
164
- isShareKey: (key: string) => {
165
- const parts = splitKey(key);
166
- return parts.length >= 2 && parts[0] === SHARE_PREFIX;
167
- },
168
-
169
- tokenFromKey: (key: string) => {
170
- if (!shareKey.isShareKey(key)) return "";
171
- return key.slice(`${SHARE_PREFIX}-`.length).trim();
172
- },
173
-
174
- // Creator dimension
175
- communityCreatorIndex: (authorId: string, createdAt: number, token: string) =>
176
- createCommunityIndex("creator", authorId, createdAt, token),
177
-
178
- communityCreatorRange: (authorId: string) =>
179
- createCommunityRange("creator", authorId),
180
-
181
- // Agent dimension
182
- communityAgentIndex: (agentKey: string, createdAt: number, token: string) =>
183
- createCommunityIndex("agent", agentKey, createdAt, token),
184
-
185
- communityAgentRange: (agentKey: string) =>
186
- createCommunityRange("agent", agentKey),
187
-
188
- // Owner dimension (all shares, for "My Shares")
189
- ownerIndex: (userId: string, createdAt: number, token: string) =>
190
- createOwnerIndex(userId, createdAt, token),
191
-
192
- ownerRange: (userId: string) =>
193
- createOwnerRange(userId),
194
-
195
- // Global community feed (all community shares, time-ordered)
196
- communityAllIndex: (createdAt: number, token: string) =>
197
- createCommunityAllIndex(createdAt, token),
198
-
199
- communityAllRange: () =>
200
- createCommunityAllRange(),
201
-
202
- // From existing share data → index keys
203
- communityCreatorIndexFromShare: (dbKey: string, data: any) => {
204
- if (!shareKey.isShareKey(dbKey)) return "";
205
- if (data?.meta?.visibility !== "community") return "";
206
- const token = shareKey.tokenFromKey(dbKey);
207
- return shareKey.communityCreatorIndex(data?.meta?.authorId, data?.meta?.createdAt, token);
208
- },
209
-
210
- communityAgentIndexFromShare: (dbKey: string, data: any) => {
211
- if (!shareKey.isShareKey(dbKey)) return "";
212
- if (data?.meta?.visibility !== "community") return "";
213
- const token = shareKey.tokenFromKey(dbKey);
214
- const agentKey = resolveAgentKeyFromPayload(data);
215
- return shareKey.communityAgentIndex(agentKey, data?.meta?.createdAt, token);
216
- },
217
-
218
- ownerIndexFromShare: (dbKey: string, data: any) => {
219
- if (!shareKey.isShareKey(dbKey)) return "";
220
- const token = shareKey.tokenFromKey(dbKey);
221
- return shareKey.ownerIndex(data?.meta?.authorId, data?.meta?.createdAt, token);
222
- },
223
-
224
- communityAllIndexFromShare: (dbKey: string, data: any) => {
225
- if (!shareKey.isShareKey(dbKey)) return "";
226
- if (data?.meta?.visibility !== "community") return "";
227
- const token = shareKey.tokenFromKey(dbKey);
228
- return shareKey.communityAllIndex(data?.meta?.createdAt, token);
229
- },
230
-
231
- communityIndexKeysFromShare: (dbKey: string, data: any): string[] => {
232
- const all = shareKey.communityAllIndexFromShare(dbKey, data);
233
- const creator = shareKey.communityCreatorIndexFromShare(dbKey, data);
234
- const agent = shareKey.communityAgentIndexFromShare(dbKey, data);
235
- return Array.from(new Set([all, creator, agent].filter(Boolean)));
236
- },
237
-
238
- allIndexKeysFromShare: (dbKey: string, data: any): string[] => {
239
- const owner = shareKey.ownerIndexFromShare(dbKey, data);
240
- const community = shareKey.communityIndexKeysFromShare(dbKey, data);
241
- return Array.from(new Set([owner, ...community].filter(Boolean)));
242
- },
243
- };
package/share/types.ts DELETED
@@ -1,100 +0,0 @@
1
- import { DataType } from "../create/types";
2
-
3
- export type ShareType =
4
- | DataType.DOC
5
- | DataType.DIALOG
6
- | DataType.CYBOT
7
- | DataType.IMAGE
8
- | DataType.APP
9
- | DataType.TABLE;
10
-
11
- export interface ShareMeta {
12
- authorId: string;
13
- authorName?: string;
14
- authorAvatar?: string;
15
- createdAt: number;
16
- updatedAt?: number | string;
17
- visibility: "private" | "community";
18
- title: string;
19
- description?: string;
20
- originalId?: string;
21
- mode?: "live";
22
- coverImage?: string;
23
- sourceAgentKey?: string;
24
- sourceAgentName?: string;
25
- /** Product entitlement source of truth for paid access */
26
- productId?: string;
27
- /** 被导入次数 */
28
- importCount?: number;
29
- /** 当前返回为锁定预览,未包含原始正文 */
30
- previewLocked?: boolean;
31
- /** 当前用户需要购买后才能获取原始内容 */
32
- requiresPurchase?: boolean;
33
- originServer?: string;
34
- tableDbKey?: string;
35
- tableOwnerId?: string;
36
- replicaServers?: string[];
37
- lastReplicationAt?: number;
38
- replicationDirtyAt?: number;
39
- lastReplicationError?: string;
40
- }
41
-
42
- export interface SharedObject {
43
- type: ShareType;
44
- version: number;
45
- data: Record<string, unknown>;
46
- meta: ShareMeta;
47
- createdAt?: number | string;
48
- updatedAt?: number | string;
49
- }
50
-
51
- export interface ShareSummary {
52
- token: string;
53
- type: ShareType;
54
- title: string;
55
- description?: string;
56
- createdAt: number;
57
- authorId: string;
58
- authorName?: string;
59
- authorAvatar?: string;
60
- coverImage?: string;
61
- coverImageUrl?: string;
62
- agentKey?: string;
63
- agentName?: string;
64
- visibility?: "private" | "community";
65
- originalId?: string;
66
- mode?: "live";
67
- originServer?: string;
68
- tableDbKey?: string;
69
- tableOwnerId?: string;
70
- replicaServers?: string[];
71
- lastReplicationAt?: number;
72
- replicationDirtyAt?: number;
73
- lastReplicationError?: string;
74
- /** App URL — populated only for DataType.APP shares */
75
- url?: string;
76
- /** 被导入次数 */
77
- importCount?: number;
78
- /** 更新时间(毫秒时间戳) */
79
- updatedAt?: number;
80
- }
81
-
82
- export const isShareType = (type: unknown): type is ShareType =>
83
- type === DataType.DOC ||
84
- type === DataType.DIALOG ||
85
- type === DataType.CYBOT ||
86
- type === DataType.IMAGE ||
87
- type === DataType.APP ||
88
- type === DataType.TABLE;
89
-
90
- export const SHARE_TYPE_LABELS: Record<ShareType, string> = {
91
- [DataType.DOC]: "文章",
92
- [DataType.DIALOG]: "对话",
93
- [DataType.IMAGE]: "图片",
94
- [DataType.CYBOT]: "AI",
95
- [DataType.APP]: "应用",
96
- [DataType.TABLE]: "表格",
97
- };
98
-
99
- export const getShareTypeLabel = (type: ShareType): string =>
100
- SHARE_TYPE_LABELS[type] ?? "未知";
@@ -1,134 +0,0 @@
1
- import { ContentType } from "./app/types";
2
- import { getReadableCliDb, type AgentCommandDeps } from "./agentCommandSupport";
3
- import { resolveAgentRecordFromHybridStore } from "./agentRecordHelpers";
4
- import {
5
- parseUserIdFromAuthToken,
6
- readOption,
7
- resolveAuthToken,
8
- resolveServerCandidates,
9
- resolveServerUrl,
10
- } from "./cliEnvHelpers";
11
- import {
12
- parseSpaceIdFromInput,
13
- readSpaceRecordWithFallback,
14
- writeSpaceRecord,
15
- } from "./spaceMutationHelpers";
16
-
17
- function usage() {
18
- return [
19
- "Usage:",
20
- " nolo space attach-agent --space <spaceId|spaceKey|spaceUrl> --agent <agentKey|alias|agentUrl>",
21
- "",
22
- ].join("\n");
23
- }
24
-
25
- export async function runSpaceAttachAgentCommand(
26
- args: string[],
27
- deps: AgentCommandDeps = {}
28
- ) {
29
- const env = deps.env ?? process.env;
30
- const output = deps.output ?? process.stdout;
31
-
32
- if (args.includes("--help") || args.includes("-h")) {
33
- output.write(`${usage()}\n`);
34
- return 0;
35
- }
36
-
37
- const rawSpace = readOption(args, "--space");
38
- const rawAgent = readOption(args, "--agent");
39
- if (!rawSpace || !rawAgent) {
40
- output.write(`${usage()}\n`);
41
- return 1;
42
- }
43
-
44
- const authToken = resolveAuthToken(args, env);
45
- const userId = parseUserIdFromAuthToken(authToken);
46
- if (!authToken || !userId) {
47
- output.write("[nolo] space attach-agent requires an auth token with userId. Run `nolo login`.\n");
48
- return 1;
49
- }
50
-
51
- const db = deps.db ?? await getReadableCliDb(output);
52
- const fetchImpl = deps.fetchImpl ?? fetch;
53
- const fallbackFetchImpl = deps.fallbackFetchImpl;
54
- const defaultServerUrl = resolveServerUrl(args, env);
55
- const serverCandidates = resolveServerCandidates(args, env, defaultServerUrl);
56
-
57
- try {
58
- const spaceId = parseSpaceIdFromInput(rawSpace);
59
- const spaceRecord = await readSpaceRecordWithFallback({
60
- authToken,
61
- db,
62
- fallbackFetchImpl,
63
- fetchImpl,
64
- serverCandidates,
65
- spaceId,
66
- });
67
- const resolvedAgent = await resolveAgentRecordFromHybridStore({
68
- agentInput: rawAgent,
69
- cliArgs: args,
70
- env,
71
- db,
72
- fetchImpl,
73
- fallbackFetchImpl,
74
- });
75
- if (!resolvedAgent?.record || typeof resolvedAgent.record !== "object") {
76
- throw new Error(`agent not found: ${rawAgent}`);
77
- }
78
- const agentKey = resolvedAgent.agentKey;
79
-
80
- const title =
81
- typeof resolvedAgent.record.name === "string" && resolvedAgent.record.name.trim()
82
- ? resolvedAgent.record.name.trim()
83
- : agentKey;
84
- const now = Date.now();
85
- const nextSpaceRecord = {
86
- ...spaceRecord,
87
- updatedAt: now,
88
- contents: {
89
- ...(spaceRecord?.contents ?? {}),
90
- [agentKey]: {
91
- ...(spaceRecord?.contents?.[agentKey] ?? {}),
92
- title,
93
- type: ContentType.AGENT,
94
- contentKey: agentKey,
95
- updatedAt: now,
96
- createdAt: spaceRecord?.contents?.[agentKey]?.createdAt ?? now,
97
- },
98
- },
99
- };
100
-
101
- await writeSpaceRecord({
102
- authToken,
103
- db,
104
- fallbackFetchImpl,
105
- fetchImpl,
106
- record: nextSpaceRecord,
107
- serverUrl: defaultServerUrl,
108
- spaceId,
109
- userId,
110
- });
111
-
112
- output.write(
113
- `${JSON.stringify(
114
- {
115
- ok: true,
116
- baseUrl: defaultServerUrl,
117
- spaceId,
118
- agentKey,
119
- title,
120
- },
121
- null,
122
- 2
123
- )}\n`
124
- );
125
- return 0;
126
- } catch (error) {
127
- output.write(
128
- `[nolo] space attach-agent failed: ${
129
- error instanceof Error ? error.message : String(error)
130
- }\n`
131
- );
132
- return 1;
133
- }
134
- }