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.
- package/README.md +4 -10
- package/agent-runtime/agentRecordConfig.ts +10 -0
- package/agent-runtime/hostAdapter.ts +10 -1
- package/agent-runtime/index.ts +9 -20
- package/agent-runtime/localLoop.ts +49 -2
- package/agent-runtime/localToolPolicy.ts +76 -34
- package/agent-runtime/localWorkspaceTools.ts +30 -333
- package/agent-runtime/openAiCompatibleProvider.ts +7 -3
- package/agent-runtime/openAiCompatibleProviderConfig.ts +15 -26
- package/agent-runtime/platformChatProvider.ts +47 -73
- package/agent-runtime/providerResolution.ts +244 -0
- package/agent-runtime/runtimeToolPolicy.ts +77 -29
- package/agent-runtime/shellCommandPolicy.ts +120 -0
- package/agentAliases.ts +14 -83
- package/agentCommandSupport.ts +3 -6
- package/agentInternalCommandEntries.ts +4 -13
- package/agentListCommands.ts +18 -27
- package/agentMachineCommands.ts +40 -336
- package/agentPullCommand.ts +30 -55
- package/agentRecordCommands.ts +84 -1
- package/agentRecordHelpers.ts +102 -186
- package/agentRunCommand.ts +438 -107
- package/agentRuntimeLocal.ts +2 -9
- package/ai/agent/cliExecutor.ts +19 -323
- package/ai/tools/toolNameAliases.ts +70 -0
- package/authCommands.ts +2 -36
- package/cli/agentAliases.ts +14 -83
- package/cli/agentCommandSupport.ts +3 -6
- package/cli/agentInternalCommandEntries.ts +4 -13
- package/cli/agentListCommands.ts +18 -27
- package/cli/agentMachineCommands.ts +40 -336
- package/cli/agentPullCommand.ts +30 -55
- package/cli/agentRecordCommands.ts +84 -1
- package/cli/agentRecordHelpers.ts +102 -186
- package/cli/agentRunCommand.ts +438 -107
- package/cli/agentRuntimeLocal.ts +2 -9
- package/cli/authCommands.ts +2 -36
- package/cli/cliCommandDispatch.ts +2 -2
- package/cli/cliEnvHelpers.ts +34 -107
- package/cli/client/agentRun.ts +854 -57
- package/cli/client/localRuntimeAdapter.ts +59 -159
- package/cli/client/streamingOutput.ts +3 -1
- package/cli/client/taskRunPrompt.ts +24 -7
- package/cli/commandRegistry.ts +4 -5
- package/cli/connectorRunArtifact.ts +10 -34
- package/cli/connectorWebSocketTarget.ts +6 -10
- package/cli/internalCommandEntries.ts +0 -8
- package/cli/localRuntimeDb.ts +2 -39
- package/cli/machineCommands.ts +189 -190
- package/cli/machineDaemonCommands.ts +165 -9
- package/cli/machineHeartbeatCommands.ts +2 -1
- package/cli/machineStatusCommands.ts +13 -5
- package/cli/machineWatchCommands.ts +1 -1
- package/cli/machineWsRunDispatch.ts +30 -44
- package/cli/machineWsSession.ts +0 -2
- package/cli/offlineMarxistsAgentCommand.ts +314 -0
- package/cli/runtimeDoctorCommands.ts +72 -15
- package/cli/scriptCommandEntries.ts +45 -5
- package/cli/tableCommands.ts +133 -33
- package/cli/taskRunCommand.ts +211 -16
- package/cli/tui/session.ts +372 -43
- package/cli/workflowInternalCommandEntries.ts +0 -20
- package/cliCommandDispatch.ts +2 -2
- package/cliEnvHelpers.ts +34 -107
- package/client/agentConfigResolver.test.ts +2 -0
- package/client/agentRun.test.ts +12 -208
- package/client/agentRun.ts +854 -57
- package/client/localProviderResolver.test.ts +26 -2
- package/client/localRuntimeAdapter.test.ts +296 -171
- package/client/localRuntimeAdapter.ts +59 -159
- package/client/localToolPolicy.test.ts +4 -28
- package/client/streamingOutput.ts +3 -1
- package/client/taskRunPrompt.ts +24 -7
- package/commandRegistry.ts +4 -5
- package/connectorRunArtifact.ts +10 -34
- package/connectorWebSocketTarget.ts +6 -10
- package/database/server/serverStoreFactory.ts +2 -8
- package/internalCommandEntries.ts +0 -8
- package/localRuntimeDb.ts +2 -39
- package/machineCommands.ts +189 -190
- package/machineDaemonCommands.ts +165 -9
- package/machineHeartbeatCommands.ts +2 -1
- package/machineStatusCommands.ts +13 -5
- package/machineWatchCommands.ts +1 -1
- package/machineWsRunDispatch.ts +30 -44
- package/machineWsSession.ts +0 -2
- package/offlineMarxistsAgentCommand.ts +314 -0
- package/package.json +52 -188
- package/runtimeDoctorCommands.ts +72 -15
- package/scriptCommandEntries.ts +45 -5
- package/tableCommands.ts +133 -33
- package/taskRunCommand.ts +211 -16
- package/tui/session.ts +372 -43
- package/workflowInternalCommandEntries.ts +0 -20
- package/agent-runtime/dialogStatus.ts +0 -139
- package/agent-runtime/hostRuntimeConfig.ts +0 -86
- package/agentCreateCustomCommands.ts +0 -278
- package/agentDialogsCommands.ts +0 -227
- package/agentDoctorCommands.ts +0 -203
- package/agentRunLocalWorkspace.ts +0 -182
- package/agentRunParsing.ts +0 -298
- package/agentSuperviseCommands.ts +0 -8
- package/agentUnpublishCommands.ts +0 -113
- package/ai/agent/agentRunDialogLineage.ts +0 -56
- package/ai/policy/types.ts +0 -64
- package/ai/skills/skillSummaryMarker.ts +0 -26
- package/app/types.ts +0 -358
- package/build.ts +0 -16
- package/buildPublish.ts +0 -138
- package/buildPublishArtifactAssembly.ts +0 -724
- package/buildPublishImportAnalysis.ts +0 -242
- package/chat/messages/fetchMessages.ts +0 -84
- package/chat/messages/types.ts +0 -185
- package/cli/agentCreateCustomCommands.ts +0 -278
- package/cli/agentDialogsCommands.ts +0 -227
- package/cli/agentDoctorCommands.ts +0 -203
- package/cli/agentRunLocalWorkspace.ts +0 -182
- package/cli/agentRunParsing.ts +0 -298
- package/cli/agentSuperviseCommands.ts +0 -8
- package/cli/agentUnpublishCommands.ts +0 -113
- package/cli/buildPublish.ts +0 -138
- package/cli/buildPublishArtifactAssembly.ts +0 -724
- package/cli/buildPublishImportAnalysis.ts +0 -242
- package/cli/cliIoTypes.ts +0 -3
- package/cli/cliRuntimeDoctorReport.ts +0 -193
- package/cli/client/agentRunInput.ts +0 -10
- package/cli/client/agentRunLocalExecution.ts +0 -124
- package/cli/client/agentRunLocalExecutor.ts +0 -179
- package/cli/client/agentRunRuntimeSelection.ts +0 -145
- package/cli/client/agentRunServerTransport.ts +0 -397
- package/cli/client/agentRunTaskRunRecorder.ts +0 -176
- package/cli/customCodingAgentFlow.ts +0 -208
- package/cli/customCodingAgentRecord.ts +0 -179
- package/cli/dialogDataAccess.ts +0 -186
- package/cli/dialogInternalCommandEntries.ts +0 -11
- package/cli/dialogReadCommands.ts +0 -180
- package/cli/dialogReadHelpers.ts +0 -226
- package/cli/dialogStatusCommands.ts +0 -123
- package/cli/docInternalCommandEntries.ts +0 -20
- package/cli/hybridReadHelpers.ts +0 -109
- package/cli/machineCommandPrompts.ts +0 -79
- package/cli/machineCommandResolution.ts +0 -43
- package/cli/noloReadBridgePrompt.ts +0 -16
- package/cli/pageCreateCommands.ts +0 -219
- package/cli/pageDeleteCommands.ts +0 -167
- package/cli/pageReadCommands.ts +0 -151
- package/cli/pageUpdateCommands.ts +0 -249
- package/cli/pageWriteHelpers.ts +0 -209
- package/cli/publishPackage.ts +0 -36
- package/cli/runtimeInternalCommandEntries.ts +0 -15
- package/cli/runtimePassthroughCommands.ts +0 -22
- package/cli/scriptPassthroughHelpers.ts +0 -28
- package/cli/secretScanHelpers.ts +0 -31
- package/cli/spaceAttachCommands.ts +0 -134
- package/cli/spaceCategoryCommands.ts +0 -263
- package/cli/spaceCommands.ts +0 -295
- package/cli/spaceDeleteCommands.ts +0 -312
- package/cli/spaceInternalCommandEntries.ts +0 -21
- package/cli/spaceMutationHelpers.ts +0 -135
- package/cli/spaceReadCommands.ts +0 -323
- package/cli/tableDataOutput.ts +0 -41
- package/cli/tableDataSafety.ts +0 -26
- package/cli/tableMetaCommands.ts +0 -307
- package/cli/tableMutationCommands.ts +0 -266
- package/cli/tableQueryParsing.ts +0 -90
- package/cli/tableQueryRequest.ts +0 -53
- package/cli/taskRunActions.ts +0 -122
- package/cli/taskRunParsing.ts +0 -86
- package/cli/taskRunPromptShared.ts +0 -55
- package/cli/tui/tuiCatalog.ts +0 -22
- package/cli/tui/tuiCommandInterpreter.ts +0 -253
- package/cli/tui/tuiPresentation.ts +0 -146
- package/cliIoTypes.ts +0 -3
- package/cliRuntimeDoctorReport.ts +0 -193
- package/client/agentRunInput.ts +0 -10
- package/client/agentRunLocalExecution.test.ts +0 -123
- package/client/agentRunLocalExecution.ts +0 -124
- package/client/agentRunLocalExecutor.ts +0 -179
- package/client/agentRunRuntimeSelection.test.ts +0 -159
- package/client/agentRunRuntimeSelection.ts +0 -145
- package/client/agentRunServerTransport.ts +0 -397
- package/client/agentRunTaskRunRecorder.ts +0 -176
- package/connector-experimental/daemonLauncher.ts +0 -223
- package/create/space/spaceKeys.ts +0 -65
- package/create/types.ts +0 -21
- package/customCodingAgentFlow.ts +0 -208
- package/customCodingAgentRecord.ts +0 -179
- package/database/keys.ts +0 -765
- package/database/tombstones.ts +0 -52
- package/database/utils/ulid.ts +0 -1
- package/dialogDataAccess.ts +0 -186
- package/dialogInternalCommandEntries.ts +0 -11
- package/dialogReadCommands.ts +0 -180
- package/dialogReadHelpers.ts +0 -226
- package/dialogStatusCommands.ts +0 -123
- package/docInternalCommandEntries.ts +0 -20
- package/hybridReadHelpers.ts +0 -109
- package/machineCommandPrompts.ts +0 -79
- package/machineCommandResolution.ts +0 -43
- package/noloReadBridgePrompt.ts +0 -16
- package/pageCreateCommands.ts +0 -219
- package/pageDeleteCommands.ts +0 -167
- package/pageReadCommands.ts +0 -151
- package/pageUpdateCommands.ts +0 -249
- package/pageWriteHelpers.ts +0 -209
- package/publishPackage.ts +0 -36
- package/runtimeInternalCommandEntries.ts +0 -15
- package/runtimePassthroughCommands.ts +0 -22
- package/scriptPassthroughHelpers.ts +0 -28
- package/secretScanHelpers.ts +0 -31
- package/share/helpers.ts +0 -302
- package/share/keys.ts +0 -243
- package/share/types.ts +0 -100
- package/spaceAttachCommands.ts +0 -134
- package/spaceCategoryCommands.ts +0 -263
- package/spaceCommands.ts +0 -295
- package/spaceDeleteCommands.ts +0 -312
- package/spaceInternalCommandEntries.ts +0 -21
- package/spaceMutationHelpers.ts +0 -135
- package/spaceReadCommands.ts +0 -323
- package/tableDataOutput.ts +0 -41
- package/tableDataSafety.ts +0 -26
- package/tableMetaCommands.ts +0 -307
- package/tableMutationCommands.ts +0 -266
- package/tableQueryParsing.ts +0 -90
- package/tableQueryRequest.ts +0 -53
- package/taskRunActions.ts +0 -122
- package/taskRunParsing.ts +0 -86
- package/taskRunPromptShared.ts +0 -55
- package/tui/tuiCatalog.ts +0 -22
- package/tui/tuiCommandInterpreter.test.ts +0 -169
- package/tui/tuiCommandInterpreter.ts +0 -253
- package/tui/tuiPresentation.test.ts +0 -154
- 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] ?? "未知";
|
package/spaceAttachCommands.ts
DELETED
|
@@ -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
|
-
}
|