nolo-cli 0.1.32 → 0.1.33
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 +0 -6
- package/agent-runtime/agentRecordConfig.ts +2 -0
- package/agent-runtime/hostAdapter.ts +1 -0
- package/agent-runtime/index.ts +0 -21
- package/agent-runtime/localToolPolicy.ts +6 -13
- package/agent-runtime/localWorkspaceTools.ts +30 -333
- package/agent-runtime/platformChatProvider.ts +1 -4
- package/agent-runtime/runtimeToolPolicy.ts +47 -32
- package/agentAliases.ts +14 -83
- package/agentCommandSupport.ts +3 -6
- package/agentInternalCommandEntries.ts +2 -13
- package/agentListCommands.ts +19 -28
- package/agentMachineCommands.ts +40 -336
- package/agentPullCommand.ts +36 -56
- package/agentRecordCommands.ts +3 -5
- package/agentRecordHelpers.ts +22 -189
- package/agentRunCommand.ts +438 -107
- package/agentRuntimeLocal.ts +0 -10
- package/ai/agent/cliExecutor.ts +19 -323
- package/authCommands.ts +2 -36
- package/cli/agentAliases.ts +14 -83
- package/cli/agentCommandSupport.ts +3 -6
- package/cli/agentInternalCommandEntries.ts +2 -13
- package/cli/agentListCommands.ts +19 -28
- package/cli/agentMachineCommands.ts +40 -336
- package/cli/agentPullCommand.ts +36 -56
- package/cli/agentRecordCommands.ts +3 -5
- package/cli/agentRecordHelpers.ts +22 -189
- package/cli/agentRunCommand.ts +438 -107
- package/cli/agentRuntimeLocal.ts +0 -10
- package/cli/authCommands.ts +2 -36
- package/cli/cliEnvHelpers.ts +21 -162
- package/cli/client/agentRun.ts +853 -57
- package/cli/client/localRuntimeAdapter.ts +22 -159
- package/cli/client/streamingOutput.ts +3 -1
- package/cli/client/taskRunPrompt.ts +24 -7
- package/cli/commandRegistry.ts +2 -3
- 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 +14 -48
- package/cli/machineWsSession.ts +0 -2
- package/cli/offlineMarxistsAgentCommand.ts +314 -0
- package/cli/runtimeDoctorCommands.ts +69 -18
- 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/cliEnvHelpers.ts +21 -162
- package/client/agentConfigResolver.test.ts +2 -0
- package/client/agentRun.test.ts +12 -208
- package/client/agentRun.ts +853 -57
- package/client/localRuntimeAdapter.test.ts +9 -168
- package/client/localRuntimeAdapter.ts +22 -159
- package/client/localToolPolicy.test.ts +4 -28
- package/client/streamingOutput.ts +3 -1
- package/client/taskRunPrompt.ts +24 -7
- package/commandRegistry.ts +2 -3
- package/connectorRunArtifact.ts +10 -34
- package/connectorWebSocketTarget.ts +6 -10
- package/database/server/db.ts +34 -15
- 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 +14 -48
- package/machineWsSession.ts +0 -2
- package/offlineMarxistsAgentCommand.ts +314 -0
- package/package.json +49 -193
- package/runtimeDoctorCommands.ts +69 -18
- 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/server/authorityStoreTypes.ts +0 -31
- package/database/server/legacyServerDb.ts +0 -58
- package/database/server/levelAuthorityStore.ts +0 -75
- package/database/server/memoryAuthorityStore.ts +0 -133
- package/database/server/serverStoreFactory.ts +0 -124
- 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
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export type AuthorityBatchOperation =
|
|
2
|
-
| { type: "put"; key: string; value: unknown }
|
|
3
|
-
| { type: "del"; key: string };
|
|
4
|
-
|
|
5
|
-
export type AuthorityIteratorOptions = {
|
|
6
|
-
gte?: string;
|
|
7
|
-
lte?: string;
|
|
8
|
-
lt?: string;
|
|
9
|
-
reverse?: boolean;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export interface AuthorityBatchWriter {
|
|
13
|
-
put(key: string, value: unknown): void;
|
|
14
|
-
del(key: string): void;
|
|
15
|
-
write(): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface AuthorityStore {
|
|
19
|
-
readonly location?: string;
|
|
20
|
-
readonly status?: string;
|
|
21
|
-
open(): Promise<void>;
|
|
22
|
-
close(): Promise<void>;
|
|
23
|
-
get<T = any>(key: string): Promise<T>;
|
|
24
|
-
put(key: string, value: unknown): Promise<void>;
|
|
25
|
-
del(key: string): Promise<void>;
|
|
26
|
-
batchWrite(ops: AuthorityBatchOperation[]): Promise<void>;
|
|
27
|
-
createBatch(): AuthorityBatchWriter;
|
|
28
|
-
iterator(
|
|
29
|
-
options?: AuthorityIteratorOptions
|
|
30
|
-
): AsyncIterableIterator<[string, unknown]>;
|
|
31
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AuthorityBatchOperation,
|
|
3
|
-
AuthorityBatchWriter,
|
|
4
|
-
AuthorityIteratorOptions,
|
|
5
|
-
AuthorityStore,
|
|
6
|
-
} from "./authorityStoreTypes";
|
|
7
|
-
|
|
8
|
-
export type LegacyServerDb = {
|
|
9
|
-
readonly location?: string;
|
|
10
|
-
readonly status?: string;
|
|
11
|
-
open(): Promise<void>;
|
|
12
|
-
close(): Promise<void>;
|
|
13
|
-
get<T = any>(key: string): Promise<T>;
|
|
14
|
-
put(key: string, value: unknown): Promise<void>;
|
|
15
|
-
del(key: string): Promise<void>;
|
|
16
|
-
batch(ops: AuthorityBatchOperation[]): Promise<void>;
|
|
17
|
-
batch(): AuthorityBatchWriter;
|
|
18
|
-
iterator(
|
|
19
|
-
options?: AuthorityIteratorOptions
|
|
20
|
-
): AsyncIterableIterator<[string, unknown]>;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export function createLegacyServerDb(store: AuthorityStore): LegacyServerDb {
|
|
24
|
-
const batch = (ops?: AuthorityBatchOperation[]) => {
|
|
25
|
-
if (Array.isArray(ops)) {
|
|
26
|
-
return store.batchWrite(ops);
|
|
27
|
-
}
|
|
28
|
-
return store.createBatch();
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
get location() {
|
|
33
|
-
return store.location;
|
|
34
|
-
},
|
|
35
|
-
get status() {
|
|
36
|
-
return store.status;
|
|
37
|
-
},
|
|
38
|
-
async open() {
|
|
39
|
-
await store.open();
|
|
40
|
-
},
|
|
41
|
-
async close() {
|
|
42
|
-
await store.close();
|
|
43
|
-
},
|
|
44
|
-
async get<T = any>(key: string) {
|
|
45
|
-
return store.get<T>(key);
|
|
46
|
-
},
|
|
47
|
-
async put(key: string, value: unknown) {
|
|
48
|
-
await store.put(key, value);
|
|
49
|
-
},
|
|
50
|
-
async del(key: string) {
|
|
51
|
-
await store.del(key);
|
|
52
|
-
},
|
|
53
|
-
batch: batch as LegacyServerDb["batch"],
|
|
54
|
-
iterator(options: AuthorityIteratorOptions = {}) {
|
|
55
|
-
return store.iterator(options);
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AuthorityBatchOperation,
|
|
3
|
-
AuthorityBatchWriter,
|
|
4
|
-
AuthorityIteratorOptions,
|
|
5
|
-
AuthorityStore,
|
|
6
|
-
} from "./authorityStoreTypes";
|
|
7
|
-
|
|
8
|
-
type LevelBatchWriterLike = {
|
|
9
|
-
put(key: string, value: unknown): unknown;
|
|
10
|
-
del(key: string): unknown;
|
|
11
|
-
write(): Promise<void>;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
type LevelLike = {
|
|
15
|
-
readonly location?: string;
|
|
16
|
-
readonly status?: string;
|
|
17
|
-
open?(): Promise<void>;
|
|
18
|
-
close?(): Promise<void>;
|
|
19
|
-
get<T = any>(key: string): Promise<T>;
|
|
20
|
-
put(key: string, value: unknown): Promise<void>;
|
|
21
|
-
del(key: string): Promise<void>;
|
|
22
|
-
batch(ops: AuthorityBatchOperation[]): Promise<void>;
|
|
23
|
-
batch(): LevelBatchWriterLike;
|
|
24
|
-
iterator(
|
|
25
|
-
options?: AuthorityIteratorOptions
|
|
26
|
-
): AsyncIterableIterator<[string, unknown]>;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export function createLevelAuthorityStore(levelDb: LevelLike): AuthorityStore {
|
|
30
|
-
const createBatch = (): AuthorityBatchWriter => {
|
|
31
|
-
const batch = levelDb.batch();
|
|
32
|
-
return {
|
|
33
|
-
put(key: string, value: unknown) {
|
|
34
|
-
batch.put(key, value);
|
|
35
|
-
},
|
|
36
|
-
del(key: string) {
|
|
37
|
-
batch.del(key);
|
|
38
|
-
},
|
|
39
|
-
async write() {
|
|
40
|
-
await batch.write();
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
get location() {
|
|
47
|
-
return levelDb.location;
|
|
48
|
-
},
|
|
49
|
-
get status() {
|
|
50
|
-
return levelDb.status;
|
|
51
|
-
},
|
|
52
|
-
async open() {
|
|
53
|
-
await levelDb.open?.();
|
|
54
|
-
},
|
|
55
|
-
async close() {
|
|
56
|
-
await levelDb.close?.();
|
|
57
|
-
},
|
|
58
|
-
async get<T = any>(key: string) {
|
|
59
|
-
return levelDb.get<T>(key);
|
|
60
|
-
},
|
|
61
|
-
async put(key: string, value: unknown) {
|
|
62
|
-
await levelDb.put(key, value);
|
|
63
|
-
},
|
|
64
|
-
async del(key: string) {
|
|
65
|
-
await levelDb.del(key);
|
|
66
|
-
},
|
|
67
|
-
async batchWrite(ops: AuthorityBatchOperation[]) {
|
|
68
|
-
await levelDb.batch(ops);
|
|
69
|
-
},
|
|
70
|
-
createBatch,
|
|
71
|
-
iterator(options: AuthorityIteratorOptions = {}) {
|
|
72
|
-
return levelDb.iterator(options);
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AuthorityBatchOperation,
|
|
3
|
-
AuthorityBatchWriter,
|
|
4
|
-
AuthorityIteratorOptions,
|
|
5
|
-
AuthorityStore,
|
|
6
|
-
} from "./authorityStoreTypes";
|
|
7
|
-
|
|
8
|
-
type MemoryEntry = {
|
|
9
|
-
key: string;
|
|
10
|
-
value: unknown;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const createNotFoundError = () => {
|
|
14
|
-
const error = new Error("NotFound") as Error & { notFound: true };
|
|
15
|
-
error.notFound = true;
|
|
16
|
-
return error;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
class MemoryAuthorityBacking {
|
|
20
|
-
readonly location: string;
|
|
21
|
-
status: "closed" | "open" = "closed";
|
|
22
|
-
private readonly data = new Map<string, unknown>();
|
|
23
|
-
|
|
24
|
-
constructor(location: string) {
|
|
25
|
-
this.location = location;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async open() {
|
|
29
|
-
this.status = "open";
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async close() {
|
|
33
|
-
this.status = "closed";
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async get<T = any>(key: string): Promise<T> {
|
|
37
|
-
if (!this.data.has(key)) {
|
|
38
|
-
throw createNotFoundError();
|
|
39
|
-
}
|
|
40
|
-
return this.data.get(key) as T;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async put(key: string, value: unknown) {
|
|
44
|
-
this.data.set(key, value);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async del(key: string) {
|
|
48
|
-
this.data.delete(key);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async batchWrite(ops: AuthorityBatchOperation[]) {
|
|
52
|
-
for (const op of ops) {
|
|
53
|
-
if (op.type === "put") {
|
|
54
|
-
this.data.set(op.key, op.value);
|
|
55
|
-
} else {
|
|
56
|
-
this.data.delete(op.key);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
createBatch(): AuthorityBatchWriter {
|
|
62
|
-
const buffered: AuthorityBatchOperation[] = [];
|
|
63
|
-
return {
|
|
64
|
-
put(key: string, value: unknown) {
|
|
65
|
-
buffered.push({ type: "put", key, value });
|
|
66
|
-
},
|
|
67
|
-
del(key: string) {
|
|
68
|
-
buffered.push({ type: "del", key });
|
|
69
|
-
},
|
|
70
|
-
write: async () => {
|
|
71
|
-
await this.batchWrite(buffered);
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async *iterator(
|
|
77
|
-
options: AuthorityIteratorOptions = {}
|
|
78
|
-
): AsyncIterableIterator<[string, unknown]> {
|
|
79
|
-
const entries: MemoryEntry[] = Array.from(this.data.entries())
|
|
80
|
-
.sort(([left], [right]) => left.localeCompare(right))
|
|
81
|
-
.map(([key, value]) => ({ key, value }));
|
|
82
|
-
|
|
83
|
-
if (options.reverse) {
|
|
84
|
-
entries.reverse();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
for (const entry of entries) {
|
|
88
|
-
if (options.gte && entry.key < options.gte) continue;
|
|
89
|
-
if (options.lte && entry.key > options.lte) continue;
|
|
90
|
-
if (options.lt && entry.key >= options.lt) continue;
|
|
91
|
-
yield [entry.key, entry.value];
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function createMemoryAuthorityStore(
|
|
97
|
-
location = ":memory:"
|
|
98
|
-
): AuthorityStore {
|
|
99
|
-
const backing = new MemoryAuthorityBacking(location);
|
|
100
|
-
|
|
101
|
-
return {
|
|
102
|
-
get location() {
|
|
103
|
-
return backing.location;
|
|
104
|
-
},
|
|
105
|
-
get status() {
|
|
106
|
-
return backing.status;
|
|
107
|
-
},
|
|
108
|
-
async open() {
|
|
109
|
-
await backing.open();
|
|
110
|
-
},
|
|
111
|
-
async close() {
|
|
112
|
-
await backing.close();
|
|
113
|
-
},
|
|
114
|
-
async get<T = any>(key: string) {
|
|
115
|
-
return backing.get<T>(key);
|
|
116
|
-
},
|
|
117
|
-
async put(key: string, value: unknown) {
|
|
118
|
-
await backing.put(key, value);
|
|
119
|
-
},
|
|
120
|
-
async del(key: string) {
|
|
121
|
-
await backing.del(key);
|
|
122
|
-
},
|
|
123
|
-
async batchWrite(ops: AuthorityBatchOperation[]) {
|
|
124
|
-
await backing.batchWrite(ops);
|
|
125
|
-
},
|
|
126
|
-
createBatch() {
|
|
127
|
-
return backing.createBatch();
|
|
128
|
-
},
|
|
129
|
-
iterator(options: AuthorityIteratorOptions = {}) {
|
|
130
|
-
return backing.iterator(options);
|
|
131
|
-
},
|
|
132
|
-
};
|
|
133
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { Level } from "level";
|
|
4
|
-
|
|
5
|
-
import type { AuthorityStore } from "./authorityStoreTypes";
|
|
6
|
-
import { createLegacyServerDb, type LegacyServerDb } from "./legacyServerDb";
|
|
7
|
-
import { createLevelAuthorityStore } from "./levelAuthorityStore";
|
|
8
|
-
import { createMemoryAuthorityStore } from "./memoryAuthorityStore";
|
|
9
|
-
|
|
10
|
-
// Keep the storage seam local-first. Cross-process sharing stays in the
|
|
11
|
-
// existing core/proxy runtime layer; this factory is only for embedded drivers.
|
|
12
|
-
export type ServerStoreDriver = "level" | "memory";
|
|
13
|
-
|
|
14
|
-
export type ServerStoreFactoryEnv = {
|
|
15
|
-
NOLO_SERVER_AUTHORITY_DRIVER?: string | undefined;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const safeJsonEncoding = {
|
|
19
|
-
name: "safe-json",
|
|
20
|
-
format: "utf8" as const,
|
|
21
|
-
encode: (data: any) => JSON.stringify(data),
|
|
22
|
-
decode: (data: string) => {
|
|
23
|
-
try {
|
|
24
|
-
return JSON.parse(data);
|
|
25
|
-
} catch {
|
|
26
|
-
console.warn("[LevelDB] Corrupted value:", data?.substring?.(0, 60));
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type ServerStoreRuntime = {
|
|
33
|
-
authorityStore: AuthorityStore;
|
|
34
|
-
serverDb: LegacyServerDb;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export type ServerStoreFactoryOptions = {
|
|
38
|
-
driver?: ServerStoreDriver;
|
|
39
|
-
env?: ServerStoreFactoryEnv;
|
|
40
|
-
globalScope?: Record<string, unknown>;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export function ensureServerDbDirectory(dbPath: string) {
|
|
44
|
-
const dir = path.dirname(dbPath);
|
|
45
|
-
if (!fs.existsSync(dir)) {
|
|
46
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function createLevelBackedAuthorityStore(dbPath: string): AuthorityStore {
|
|
51
|
-
const levelDb = new Level<string, any>(dbPath, {
|
|
52
|
-
valueEncoding: safeJsonEncoding,
|
|
53
|
-
});
|
|
54
|
-
return createLevelAuthorityStore(levelDb);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function resolveServerStoreDriver(
|
|
58
|
-
env: ServerStoreFactoryEnv = process.env
|
|
59
|
-
): ServerStoreDriver {
|
|
60
|
-
const rawDriver = env.NOLO_SERVER_AUTHORITY_DRIVER?.trim().toLowerCase();
|
|
61
|
-
if (!rawDriver) return "level";
|
|
62
|
-
if (rawDriver === "level") return "level";
|
|
63
|
-
if (rawDriver === "memory") return "memory";
|
|
64
|
-
throw new Error(`Unsupported server authority store driver: ${rawDriver}`);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function createAuthorityStoreForDriver(
|
|
68
|
-
driver: ServerStoreDriver,
|
|
69
|
-
dbPath: string,
|
|
70
|
-
env: ServerStoreFactoryEnv = process.env
|
|
71
|
-
): AuthorityStore {
|
|
72
|
-
switch (driver) {
|
|
73
|
-
case "level":
|
|
74
|
-
return createLevelBackedAuthorityStore(dbPath);
|
|
75
|
-
case "memory":
|
|
76
|
-
// Test/dev-only driver that exercises the seam without changing the
|
|
77
|
-
// production single-writer runtime model.
|
|
78
|
-
return createMemoryAuthorityStore(dbPath);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function getOrCreateServerStoreRuntime(
|
|
83
|
-
dbPath: string,
|
|
84
|
-
options: ServerStoreFactoryOptions = {}
|
|
85
|
-
): ServerStoreRuntime {
|
|
86
|
-
const globalScope =
|
|
87
|
-
options.globalScope ?? (globalThis as Record<string, unknown>);
|
|
88
|
-
const driver = options.driver ?? resolveServerStoreDriver(options.env);
|
|
89
|
-
const cachedDriver = globalScope.__serverAuthorityStoreDriver;
|
|
90
|
-
|
|
91
|
-
ensureServerDbDirectory(dbPath);
|
|
92
|
-
|
|
93
|
-
if (
|
|
94
|
-
globalScope.__serverAuthorityStore &&
|
|
95
|
-
typeof cachedDriver === "string" &&
|
|
96
|
-
cachedDriver !== driver
|
|
97
|
-
) {
|
|
98
|
-
throw new Error(
|
|
99
|
-
`Server authority store already initialized with driver ${cachedDriver}, cannot reuse it for ${driver}`
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (!globalScope.__serverAuthorityStore) {
|
|
104
|
-
globalScope.__serverAuthorityStore = createAuthorityStoreForDriver(
|
|
105
|
-
driver,
|
|
106
|
-
dbPath,
|
|
107
|
-
options.env
|
|
108
|
-
);
|
|
109
|
-
globalScope.__serverAuthorityStoreDriver = driver;
|
|
110
|
-
} else if (!cachedDriver) {
|
|
111
|
-
globalScope.__serverAuthorityStoreDriver = driver;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const authorityStore = globalScope.__serverAuthorityStore as AuthorityStore;
|
|
115
|
-
|
|
116
|
-
if (!globalScope.__serverDb) {
|
|
117
|
-
globalScope.__serverDb = createLegacyServerDb(authorityStore);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
authorityStore,
|
|
122
|
-
serverDb: globalScope.__serverDb as LegacyServerDb,
|
|
123
|
-
};
|
|
124
|
-
}
|
package/database/tombstones.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export const getRecordTimestamp = (record: any): number => {
|
|
2
|
-
if (!record || typeof record !== "object") return 0;
|
|
3
|
-
|
|
4
|
-
const candidates = [
|
|
5
|
-
record.updatedAt,
|
|
6
|
-
record.updated_at,
|
|
7
|
-
record.createdAt,
|
|
8
|
-
record.created,
|
|
9
|
-
record?.meta?.createdAt,
|
|
10
|
-
];
|
|
11
|
-
|
|
12
|
-
for (const candidate of candidates) {
|
|
13
|
-
if (typeof candidate === "number" && Number.isFinite(candidate) && candidate > 0) {
|
|
14
|
-
return candidate;
|
|
15
|
-
}
|
|
16
|
-
if (typeof candidate === "string" && candidate.trim()) {
|
|
17
|
-
const timestamp = Date.parse(candidate);
|
|
18
|
-
if (Number.isFinite(timestamp) && timestamp > 0) {
|
|
19
|
-
return timestamp;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return 0;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const isTombstoneRecord = (record: any): boolean => {
|
|
28
|
-
if (!record || typeof record !== "object") return false;
|
|
29
|
-
const deletedAt = record.deletedAt;
|
|
30
|
-
if (typeof deletedAt === "string") return deletedAt.trim().length > 0;
|
|
31
|
-
return Boolean(deletedAt);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const shouldReplaceWithNextRecord = (
|
|
35
|
-
nextRecord: any,
|
|
36
|
-
currentRecord: any
|
|
37
|
-
): boolean => {
|
|
38
|
-
const nextTs = getRecordTimestamp(nextRecord);
|
|
39
|
-
const currentTs = getRecordTimestamp(currentRecord);
|
|
40
|
-
|
|
41
|
-
if (nextTs !== currentTs) return nextTs > currentTs;
|
|
42
|
-
return isTombstoneRecord(nextRecord) && !isTombstoneRecord(currentRecord);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const buildTombstoneRecord = <T extends Record<string, any>>(
|
|
46
|
-
record: T,
|
|
47
|
-
nowIso: string
|
|
48
|
-
): T & { deletedAt: string; updatedAt: string } => ({
|
|
49
|
-
...record,
|
|
50
|
-
deletedAt: nowIso,
|
|
51
|
-
updatedAt: nowIso,
|
|
52
|
-
});
|
package/database/utils/ulid.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ulid } from "ulid";
|
package/dialogDataAccess.ts
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { fetchMessages } from "./chat/messages/fetchMessages";
|
|
2
|
-
import { getReadableCliDb } from "./agentCommandSupport";
|
|
3
|
-
import type { DialogHttpAttempt, DialogReadSource } from "./dialogReadHelpers";
|
|
4
|
-
|
|
5
|
-
export function isLocalBaseUrl(baseUrl: string) {
|
|
6
|
-
try {
|
|
7
|
-
const hostname = new URL(baseUrl).hostname;
|
|
8
|
-
return hostname === "localhost" || hostname === "127.0.0.1";
|
|
9
|
-
} catch {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async function fetchJsonWithFallback(
|
|
15
|
-
url: string,
|
|
16
|
-
init: RequestInit,
|
|
17
|
-
fetchImpl: typeof fetch,
|
|
18
|
-
fallbackFetchImpl?: typeof fetch
|
|
19
|
-
) {
|
|
20
|
-
try {
|
|
21
|
-
return await fetchImpl(url, init);
|
|
22
|
-
} catch (error) {
|
|
23
|
-
if (!fallbackFetchImpl) throw error;
|
|
24
|
-
return fallbackFetchImpl(url, init);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async function readDialogOverHttp(args: {
|
|
29
|
-
authToken: string;
|
|
30
|
-
base: string;
|
|
31
|
-
dialogId: string;
|
|
32
|
-
dialogKey: string;
|
|
33
|
-
fetchImpl: typeof fetch;
|
|
34
|
-
fallbackFetchImpl?: typeof fetch;
|
|
35
|
-
limit: number;
|
|
36
|
-
}) {
|
|
37
|
-
const authHeaders = {
|
|
38
|
-
...(args.authToken ? { Authorization: `Bearer ${args.authToken}` } : {}),
|
|
39
|
-
"Content-Type": "application/json",
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const readViaBridge = async () => {
|
|
43
|
-
const bridgeRes = await fetchJsonWithFallback(
|
|
44
|
-
`${args.base}/api/dialog-read`,
|
|
45
|
-
{
|
|
46
|
-
method: "POST",
|
|
47
|
-
headers: authHeaders,
|
|
48
|
-
body: JSON.stringify({
|
|
49
|
-
dialogKey: args.dialogKey,
|
|
50
|
-
dialogId: args.dialogId,
|
|
51
|
-
limit: args.limit,
|
|
52
|
-
}),
|
|
53
|
-
},
|
|
54
|
-
args.fetchImpl,
|
|
55
|
-
args.fallbackFetchImpl
|
|
56
|
-
);
|
|
57
|
-
if (!bridgeRes.ok) {
|
|
58
|
-
throw Object.assign(new Error(`dialog read bridge failed: HTTP ${bridgeRes.status}`), {
|
|
59
|
-
status: bridgeRes.status,
|
|
60
|
-
base: args.base,
|
|
61
|
-
stage: "bridge",
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
const payload = await bridgeRes.json();
|
|
65
|
-
if (!payload?.ok) {
|
|
66
|
-
throw Object.assign(
|
|
67
|
-
new Error(`dialog read bridge failed: ${payload?.error ?? "unknown error"}`),
|
|
68
|
-
{
|
|
69
|
-
status: 500,
|
|
70
|
-
base: args.base,
|
|
71
|
-
stage: "bridge",
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
meta: payload.meta,
|
|
77
|
-
msgs: payload.msgs,
|
|
78
|
-
source: "http" as DialogReadSource,
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const metaRes = await fetchJsonWithFallback(
|
|
83
|
-
`${args.base}/api/v1/db/read/${encodeURIComponent(args.dialogKey)}`,
|
|
84
|
-
{
|
|
85
|
-
headers: args.authToken ? { Authorization: `Bearer ${args.authToken}` } : {},
|
|
86
|
-
},
|
|
87
|
-
args.fetchImpl,
|
|
88
|
-
args.fallbackFetchImpl
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
if (!metaRes.ok) {
|
|
92
|
-
if (metaRes.status === 401 || metaRes.status === 403) {
|
|
93
|
-
return readViaBridge();
|
|
94
|
-
}
|
|
95
|
-
throw Object.assign(new Error(`read dialog meta failed: HTTP ${metaRes.status}`), {
|
|
96
|
-
status: metaRes.status,
|
|
97
|
-
base: args.base,
|
|
98
|
-
stage: "meta",
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const metaPayload = await metaRes.json().catch(() => ({}));
|
|
103
|
-
const meta = metaPayload?.data ?? metaPayload;
|
|
104
|
-
|
|
105
|
-
const msgsRes = await fetchJsonWithFallback(
|
|
106
|
-
`${args.base}/rpc/getConvMsgs`,
|
|
107
|
-
{
|
|
108
|
-
method: "POST",
|
|
109
|
-
headers: authHeaders,
|
|
110
|
-
body: JSON.stringify({ dialogId: args.dialogId, limit: args.limit }),
|
|
111
|
-
},
|
|
112
|
-
args.fetchImpl,
|
|
113
|
-
args.fallbackFetchImpl
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
if (!msgsRes.ok) {
|
|
117
|
-
if (msgsRes.status === 401 || msgsRes.status === 403) {
|
|
118
|
-
return readViaBridge();
|
|
119
|
-
}
|
|
120
|
-
throw Object.assign(new Error(`read dialog messages failed: HTTP ${msgsRes.status}`), {
|
|
121
|
-
status: msgsRes.status,
|
|
122
|
-
base: args.base,
|
|
123
|
-
stage: "messages",
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const msgs = await msgsRes.json();
|
|
128
|
-
return {
|
|
129
|
-
meta,
|
|
130
|
-
msgs,
|
|
131
|
-
source: "http" as DialogReadSource,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export async function tryHttpDialogCandidates(args: {
|
|
136
|
-
authToken: string;
|
|
137
|
-
bases: string[];
|
|
138
|
-
dialogId: string;
|
|
139
|
-
dialogKey: string;
|
|
140
|
-
fetchImpl: typeof fetch;
|
|
141
|
-
fallbackFetchImpl?: typeof fetch;
|
|
142
|
-
limit: number;
|
|
143
|
-
}) {
|
|
144
|
-
const attempts: DialogHttpAttempt[] = [];
|
|
145
|
-
for (const base of args.bases) {
|
|
146
|
-
try {
|
|
147
|
-
const result = await readDialogOverHttp({
|
|
148
|
-
authToken: args.authToken,
|
|
149
|
-
base,
|
|
150
|
-
dialogId: args.dialogId,
|
|
151
|
-
dialogKey: args.dialogKey,
|
|
152
|
-
fetchImpl: args.fetchImpl,
|
|
153
|
-
fallbackFetchImpl: args.fallbackFetchImpl,
|
|
154
|
-
limit: args.limit,
|
|
155
|
-
});
|
|
156
|
-
attempts.push({ base, ok: true });
|
|
157
|
-
return { ...result, resolvedBase: base, attempts };
|
|
158
|
-
} catch (error) {
|
|
159
|
-
const status =
|
|
160
|
-
typeof error === "object" && error !== null && "status" in error
|
|
161
|
-
? Number((error as any).status)
|
|
162
|
-
: undefined;
|
|
163
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
164
|
-
attempts.push({ base, ok: false, status, message });
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
throw Object.assign(new Error("All HTTP dialog reads failed"), { attempts });
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export async function readDialogFromLocalDb(args: {
|
|
171
|
-
db: Awaited<ReturnType<typeof getReadableCliDb>>;
|
|
172
|
-
dialogId: string;
|
|
173
|
-
dialogKey: string;
|
|
174
|
-
limit: number;
|
|
175
|
-
}) {
|
|
176
|
-
const meta = await args.db.get(args.dialogKey);
|
|
177
|
-
const msgs = await fetchMessages(args.db, args.dialogId, {
|
|
178
|
-
limit: args.limit,
|
|
179
|
-
throwOnError: true,
|
|
180
|
-
});
|
|
181
|
-
return {
|
|
182
|
-
meta,
|
|
183
|
-
msgs,
|
|
184
|
-
source: "local-db-fallback" as DialogReadSource,
|
|
185
|
-
};
|
|
186
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createEnvCommand } from "./cliCommandFactories";
|
|
2
|
-
import type { CommandEntry } from "./cliCommandTypes";
|
|
3
|
-
import { runDialogReadCommand } from "./dialogReadCommands";
|
|
4
|
-
import { runDialogStatusCommand } from "./dialogStatusCommands";
|
|
5
|
-
|
|
6
|
-
export function getDialogInternalCommandEntries(): CommandEntry[] {
|
|
7
|
-
return [
|
|
8
|
-
createEnvCommand(["dialog", "read"], "Read a dialog", runDialogReadCommand),
|
|
9
|
-
createEnvCommand(["dialog", "status"], "Read compact dialog status", runDialogStatusCommand),
|
|
10
|
-
];
|
|
11
|
-
}
|