gnosys 5.11.4 → 5.12.2
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/dist/cli.js +377 -5162
- package/dist/index.js +542 -244
- package/dist/lib/addCommand.d.ts +9 -0
- package/dist/lib/addCommand.js +102 -0
- package/dist/lib/addStructuredCommand.d.ts +16 -0
- package/dist/lib/addStructuredCommand.js +103 -0
- package/dist/lib/ambiguityCommand.d.ts +4 -0
- package/dist/lib/ambiguityCommand.js +36 -0
- package/dist/lib/apiKeyVault.d.ts +78 -0
- package/dist/lib/apiKeyVault.js +447 -0
- package/dist/lib/archive.js +0 -2
- package/dist/lib/askCommand.d.ts +13 -0
- package/dist/lib/askCommand.js +145 -0
- package/dist/lib/attachCommand.d.ts +17 -0
- package/dist/lib/attachCommand.js +66 -0
- package/dist/lib/attachments.d.ts +43 -2
- package/dist/lib/attachments.js +81 -2
- package/dist/lib/audioExtract.js +4 -1
- package/dist/lib/auditCommand.d.ts +7 -0
- package/dist/lib/auditCommand.js +27 -0
- package/dist/lib/backupCommand.d.ts +6 -0
- package/dist/lib/backupCommand.js +54 -0
- package/dist/lib/bootstrapCommand.d.ts +15 -0
- package/dist/lib/bootstrapCommand.js +51 -0
- package/dist/lib/briefingCommand.d.ts +7 -0
- package/dist/lib/briefingCommand.js +92 -0
- package/dist/lib/centralizeCommand.d.ts +5 -0
- package/dist/lib/centralizeCommand.js +16 -0
- package/dist/lib/chat/choose.js +2 -2
- package/dist/lib/chatCommand.d.ts +12 -0
- package/dist/lib/chatCommand.js +46 -0
- package/dist/lib/checkCommand.d.ts +4 -0
- package/dist/lib/checkCommand.js +133 -0
- package/dist/lib/clientReadOverlay.d.ts +27 -0
- package/dist/lib/clientReadOverlay.js +76 -0
- package/dist/lib/clientReadResolve.d.ts +32 -0
- package/dist/lib/clientReadResolve.js +84 -0
- package/dist/lib/commitContextCommand.d.ts +9 -0
- package/dist/lib/commitContextCommand.js +142 -0
- package/dist/lib/config.d.ts +41 -48
- package/dist/lib/config.js +58 -57
- package/dist/lib/configCommand.d.ts +10 -0
- package/dist/lib/configCommand.js +321 -0
- package/dist/lib/connectCommand.d.ts +8 -0
- package/dist/lib/connectCommand.js +19 -0
- package/dist/lib/db.d.ts +68 -1
- package/dist/lib/db.js +385 -120
- package/dist/lib/dbWrite.d.ts +1 -1
- package/dist/lib/dearchiveCommand.d.ts +7 -0
- package/dist/lib/dearchiveCommand.js +41 -0
- package/dist/lib/discoverCommand.d.ts +9 -0
- package/dist/lib/discoverCommand.js +87 -0
- package/dist/lib/doctorCommand.d.ts +6 -0
- package/dist/lib/doctorCommand.js +256 -0
- package/dist/lib/docxExtract.js +1 -1
- package/dist/lib/dream.d.ts +50 -2
- package/dist/lib/dream.js +324 -30
- package/dist/lib/dreamCommand.d.ts +10 -0
- package/dist/lib/dreamCommand.js +195 -0
- package/dist/lib/dreamLaunchd.d.ts +2 -0
- package/dist/lib/dreamLaunchd.js +72 -0
- package/dist/lib/dreamLogCommand.d.ts +10 -0
- package/dist/lib/dreamLogCommand.js +58 -0
- package/dist/lib/dreamReport.d.ts +7 -0
- package/dist/lib/dreamReport.js +114 -0
- package/dist/lib/dreamRunLog.d.ts +121 -0
- package/dist/lib/dreamRunLog.js +234 -0
- package/dist/lib/embeddings.js +3 -3
- package/dist/lib/exportCommand.d.ts +18 -0
- package/dist/lib/exportCommand.js +101 -0
- package/dist/lib/exportProject.d.ts +3 -2
- package/dist/lib/exportProject.js +2 -1
- package/dist/lib/federated.js +1 -1
- package/dist/lib/fsearchCommand.d.ts +8 -0
- package/dist/lib/fsearchCommand.js +44 -0
- package/dist/lib/graphCommand.d.ts +4 -0
- package/dist/lib/graphCommand.js +68 -0
- package/dist/lib/helperGenerateCommand.d.ts +5 -0
- package/dist/lib/helperGenerateCommand.js +27 -0
- package/dist/lib/historyCommand.d.ts +5 -0
- package/dist/lib/historyCommand.js +51 -0
- package/dist/lib/hybridSearchCommand.d.ts +12 -0
- package/dist/lib/hybridSearchCommand.js +95 -0
- package/dist/lib/importCommand.d.ts +16 -0
- package/dist/lib/importCommand.js +89 -0
- package/dist/lib/importProject.js +2 -1
- package/dist/lib/importProjectCommand.d.ts +6 -0
- package/dist/lib/importProjectCommand.js +43 -0
- package/dist/lib/ingestCommand.d.ts +13 -0
- package/dist/lib/ingestCommand.js +95 -0
- package/dist/lib/installOutput.d.ts +36 -0
- package/dist/lib/installOutput.js +55 -0
- package/dist/lib/lensCommand.d.ts +20 -0
- package/dist/lib/lensCommand.js +61 -0
- package/dist/lib/lensing.d.ts +1 -0
- package/dist/lib/lensing.js +50 -9
- package/dist/lib/linksCommand.d.ts +7 -0
- package/dist/lib/linksCommand.js +48 -0
- package/dist/lib/listCommand.d.ts +8 -0
- package/dist/lib/listCommand.js +74 -0
- package/dist/lib/llm.d.ts +1 -1
- package/dist/lib/llm.js +27 -9
- package/dist/lib/localDiskCheck.d.ts +17 -0
- package/dist/lib/localDiskCheck.js +54 -0
- package/dist/lib/lock.d.ts +1 -1
- package/dist/lib/lock.js +5 -3
- package/dist/lib/machineConfig.d.ts +11 -1
- package/dist/lib/machineConfig.js +16 -0
- package/dist/lib/machineRegistry.d.ts +61 -0
- package/dist/lib/machineRegistry.js +80 -0
- package/dist/lib/maintainCommand.d.ts +8 -0
- package/dist/lib/maintainCommand.js +34 -0
- package/dist/lib/masterLease.d.ts +20 -0
- package/dist/lib/masterLease.js +68 -0
- package/dist/lib/migrate.js +0 -1
- package/dist/lib/migrateCommand.d.ts +7 -0
- package/dist/lib/migrateCommand.js +158 -0
- package/dist/lib/migrateDbCommand.d.ts +9 -0
- package/dist/lib/migrateDbCommand.js +94 -0
- package/dist/lib/modelValidation.d.ts +5 -0
- package/dist/lib/modelValidation.js +27 -0
- package/dist/lib/multimodalIngest.js +1 -1
- package/dist/lib/openrouterTiers.d.ts +29 -0
- package/dist/lib/openrouterTiers.js +113 -0
- package/dist/lib/platform.d.ts +0 -6
- package/dist/lib/platform.js +0 -28
- package/dist/lib/prefCommand.d.ts +10 -0
- package/dist/lib/prefCommand.js +118 -0
- package/dist/lib/projectsCommand.d.ts +8 -0
- package/dist/lib/projectsCommand.js +131 -0
- package/dist/lib/readCommand.d.ts +7 -0
- package/dist/lib/readCommand.js +63 -0
- package/dist/lib/recall.d.ts +3 -0
- package/dist/lib/recall.js +19 -4
- package/dist/lib/recallCommand.d.ts +11 -0
- package/dist/lib/recallCommand.js +112 -0
- package/dist/lib/reflectCommand.d.ts +8 -0
- package/dist/lib/reflectCommand.js +61 -0
- package/dist/lib/reindexCommand.d.ts +4 -0
- package/dist/lib/reindexCommand.js +34 -0
- package/dist/lib/reindexGraphCommand.d.ts +4 -0
- package/dist/lib/reindexGraphCommand.js +12 -0
- package/dist/lib/reinforceCommand.d.ts +8 -0
- package/dist/lib/reinforceCommand.js +40 -0
- package/dist/lib/remote.d.ts +5 -1
- package/dist/lib/remote.js +5 -1
- package/dist/lib/remoteWizard.d.ts +24 -5
- package/dist/lib/remoteWizard.js +308 -319
- package/dist/lib/restoreCommand.d.ts +5 -0
- package/dist/lib/restoreCommand.js +35 -0
- package/dist/lib/rulesGen.d.ts +8 -0
- package/dist/lib/rulesGen.js +16 -0
- package/dist/lib/sandboxStartCommand.d.ts +6 -0
- package/dist/lib/sandboxStartCommand.js +25 -0
- package/dist/lib/sandboxStatusCommand.d.ts +4 -0
- package/dist/lib/sandboxStatusCommand.js +24 -0
- package/dist/lib/sandboxStopCommand.d.ts +4 -0
- package/dist/lib/sandboxStopCommand.js +21 -0
- package/dist/lib/search.d.ts +0 -2
- package/dist/lib/search.js +0 -7
- package/dist/lib/searchCommand.d.ts +9 -0
- package/dist/lib/searchCommand.js +90 -0
- package/dist/lib/semanticSearchCommand.d.ts +8 -0
- package/dist/lib/semanticSearchCommand.js +52 -0
- package/dist/lib/setup/configSetRender.js +2 -0
- package/dist/lib/setup/providerGlyphs.d.ts +19 -0
- package/dist/lib/setup/providerGlyphs.js +42 -0
- package/dist/lib/setup/remoteRender.d.ts +31 -1
- package/dist/lib/setup/remoteRender.js +95 -4
- package/dist/lib/setup/sections/providers.d.ts +17 -0
- package/dist/lib/setup/sections/providers.js +307 -0
- package/dist/lib/setup/sections/routing.d.ts +2 -6
- package/dist/lib/setup/sections/routing.js +67 -82
- package/dist/lib/setup/sections/taskRoutingEditor.d.ts +13 -0
- package/dist/lib/setup/sections/taskRoutingEditor.js +139 -0
- package/dist/lib/setup/summary.d.ts +9 -0
- package/dist/lib/setup/summary.js +51 -37
- package/dist/lib/setup/ui/header.js +0 -1
- package/dist/lib/setup.d.ts +105 -15
- package/dist/lib/setup.js +747 -287
- package/dist/lib/setupKeys.d.ts +42 -0
- package/dist/lib/setupKeys.js +564 -0
- package/dist/lib/setupRemoteCommand.d.ts +4 -0
- package/dist/lib/setupRemoteCommand.js +28 -0
- package/dist/lib/setupRemotePullCommand.d.ts +5 -0
- package/dist/lib/setupRemotePullCommand.js +52 -0
- package/dist/lib/setupRemotePushCommand.d.ts +5 -0
- package/dist/lib/setupRemotePushCommand.js +57 -0
- package/dist/lib/setupRemoteResolveCommand.d.ts +4 -0
- package/dist/lib/setupRemoteResolveCommand.js +48 -0
- package/dist/lib/setupRemoteStatusCommand.d.ts +4 -0
- package/dist/lib/setupRemoteStatusCommand.js +73 -0
- package/dist/lib/setupRemoteSyncCommand.d.ts +6 -0
- package/dist/lib/setupRemoteSyncCommand.js +65 -0
- package/dist/lib/setupSyncProjectsCommand.d.ts +4 -0
- package/dist/lib/setupSyncProjectsCommand.js +292 -0
- package/dist/lib/staleCommand.d.ts +8 -0
- package/dist/lib/staleCommand.js +34 -0
- package/dist/lib/statsCommand.d.ts +6 -0
- package/dist/lib/statsCommand.js +142 -0
- package/dist/lib/statusCommand.d.ts +18 -0
- package/dist/lib/statusCommand.js +250 -0
- package/dist/lib/storesCommand.d.ts +2 -0
- package/dist/lib/storesCommand.js +4 -0
- package/dist/lib/syncClient.d.ts +41 -0
- package/dist/lib/syncClient.js +234 -0
- package/dist/lib/syncCommand.d.ts +6 -0
- package/dist/lib/syncCommand.js +57 -0
- package/dist/lib/syncDoctorCommand.d.ts +5 -0
- package/dist/lib/syncDoctorCommand.js +100 -0
- package/dist/lib/syncIngest.d.ts +30 -0
- package/dist/lib/syncIngest.js +175 -0
- package/dist/lib/syncIngestLaunchd.d.ts +8 -0
- package/dist/lib/syncIngestLaunchd.js +93 -0
- package/dist/lib/syncIngestStartup.d.ts +5 -0
- package/dist/lib/syncIngestStartup.js +29 -0
- package/dist/lib/syncIngestSystemd.d.ts +10 -0
- package/dist/lib/syncIngestSystemd.js +97 -0
- package/dist/lib/syncIngestTimer.d.ts +8 -0
- package/dist/lib/syncIngestTimer.js +27 -0
- package/dist/lib/syncIngestTimerCommand.d.ts +7 -0
- package/dist/lib/syncIngestTimerCommand.js +83 -0
- package/dist/lib/syncLock.d.ts +6 -0
- package/dist/lib/syncLock.js +74 -0
- package/dist/lib/syncSnapshot.d.ts +32 -0
- package/dist/lib/syncSnapshot.js +188 -0
- package/dist/lib/syncStaging.d.ts +79 -0
- package/dist/lib/syncStaging.js +237 -0
- package/dist/lib/tagsAddCommand.d.ts +8 -0
- package/dist/lib/tagsAddCommand.js +18 -0
- package/dist/lib/tagsCommand.d.ts +4 -0
- package/dist/lib/tagsCommand.js +16 -0
- package/dist/lib/timelineCommand.d.ts +7 -0
- package/dist/lib/timelineCommand.js +49 -0
- package/dist/lib/traceCommand.d.ts +6 -0
- package/dist/lib/traceCommand.js +39 -0
- package/dist/lib/traverseCommand.d.ts +6 -0
- package/dist/lib/traverseCommand.js +58 -0
- package/dist/lib/updateCommand.d.ts +13 -0
- package/dist/lib/updateCommand.js +67 -0
- package/dist/lib/updateStatusCommand.d.ts +5 -0
- package/dist/lib/updateStatusCommand.js +38 -0
- package/dist/lib/webAddCommand.d.ts +8 -0
- package/dist/lib/webAddCommand.js +55 -0
- package/dist/lib/webBuildCommand.d.ts +10 -0
- package/dist/lib/webBuildCommand.js +65 -0
- package/dist/lib/webBuildIndexCommand.d.ts +8 -0
- package/dist/lib/webBuildIndexCommand.js +37 -0
- package/dist/lib/webIndex.js +0 -1
- package/dist/lib/webIngestCommand.d.ts +11 -0
- package/dist/lib/webIngestCommand.js +51 -0
- package/dist/lib/webInitCommand.d.ts +9 -0
- package/dist/lib/webInitCommand.js +167 -0
- package/dist/lib/webRemoveCommand.d.ts +5 -0
- package/dist/lib/webRemoveCommand.js +41 -0
- package/dist/lib/webStatusCommand.d.ts +5 -0
- package/dist/lib/webStatusCommand.js +94 -0
- package/dist/lib/webUpdateCommand.d.ts +7 -0
- package/dist/lib/webUpdateCommand.js +72 -0
- package/dist/lib/workingSetCommand.d.ts +6 -0
- package/dist/lib/workingSetCommand.js +37 -0
- package/dist/sandbox/client.js +1 -1
- package/dist/sandbox/manager.js +1 -14
- package/dist/sandbox/server.js +3 -5
- package/package.json +6 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GnosysResolver } from "./resolver.js";
|
|
2
|
+
type GetResolver = () => Promise<GnosysResolver>;
|
|
3
|
+
type ResolveProjectId = (dir?: string) => Promise<string | null>;
|
|
4
|
+
export declare function runAddCommand(getResolver: GetResolver, input: string, opts: {
|
|
5
|
+
author: string;
|
|
6
|
+
authority: string;
|
|
7
|
+
store?: string;
|
|
8
|
+
}, resolveProjectId: ResolveProjectId): Promise<void>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import { GnosysTagRegistry } from "./tags.js";
|
|
4
|
+
import { GnosysDB } from "./db.js";
|
|
5
|
+
export async function runAddCommand(getResolver, input, opts, resolveProjectId) {
|
|
6
|
+
const resolver = await getResolver();
|
|
7
|
+
const writeTarget = resolver.getWriteTarget(opts.store || undefined);
|
|
8
|
+
if (!writeTarget) {
|
|
9
|
+
console.error("No writable store found. Create a .gnosys/ directory or set GNOSYS_PERSONAL.");
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
// Check if input is a file path — if so, route through multimodal ingestion
|
|
13
|
+
if (existsSync(input)) {
|
|
14
|
+
const { ingestFile } = await import("./multimodalIngest.js");
|
|
15
|
+
const storePath = writeTarget.store.getStorePath();
|
|
16
|
+
console.log(`Detected file: ${input}`);
|
|
17
|
+
console.log("Ingesting via multimodal pipeline...");
|
|
18
|
+
const result = await ingestFile({
|
|
19
|
+
filePath: path.resolve(input),
|
|
20
|
+
storePath,
|
|
21
|
+
mode: "llm",
|
|
22
|
+
author: opts.author,
|
|
23
|
+
authority: opts.authority,
|
|
24
|
+
onProgress: (p) => {
|
|
25
|
+
console.log(` [${p.current}/${p.total}] ${p.title || "Processing..."}`);
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
console.log(`\nFile type: ${result.fileType}`);
|
|
29
|
+
console.log(`Memories created: ${result.memories.length}`);
|
|
30
|
+
console.log(`Duration: ${(result.duration / 1000).toFixed(1)}s`);
|
|
31
|
+
for (const mem of result.memories) {
|
|
32
|
+
console.log(` ${mem.id}: ${mem.title}`);
|
|
33
|
+
}
|
|
34
|
+
if (result.errors.length > 0) {
|
|
35
|
+
console.error(`\nErrors (${result.errors.length}):`);
|
|
36
|
+
for (const err of result.errors) {
|
|
37
|
+
console.error(` Chunk ${err.chunk}: ${err.error}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const tagRegistry = new GnosysTagRegistry(writeTarget.store.getStorePath());
|
|
43
|
+
await tagRegistry.load();
|
|
44
|
+
const { GnosysIngestion } = await import("./ingest.js");
|
|
45
|
+
const ingestion = new GnosysIngestion(writeTarget.store, tagRegistry);
|
|
46
|
+
if (!ingestion.isLLMAvailable) {
|
|
47
|
+
console.error("Error: No LLM provider available. Add an API key to ~/.config/gnosys/.env or use a local model: gnosys config set provider ollama");
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
console.log("Structuring memory via LLM...");
|
|
51
|
+
const result = await ingestion.ingest(input);
|
|
52
|
+
let centralDb = null;
|
|
53
|
+
try {
|
|
54
|
+
centralDb = GnosysDB.openCentral();
|
|
55
|
+
const projectId = await resolveProjectId();
|
|
56
|
+
const id = centralDb.getNextId(result.category, projectId || undefined);
|
|
57
|
+
const now = new Date().toISOString();
|
|
58
|
+
const content = `# ${result.title}\n\n${result.content}`;
|
|
59
|
+
const tags = result.tags;
|
|
60
|
+
const tagsJson = Array.isArray(tags)
|
|
61
|
+
? JSON.stringify(tags)
|
|
62
|
+
: JSON.stringify(Object.values(tags).flat());
|
|
63
|
+
centralDb.insertMemory({
|
|
64
|
+
id,
|
|
65
|
+
title: result.title,
|
|
66
|
+
category: result.category,
|
|
67
|
+
content,
|
|
68
|
+
summary: null,
|
|
69
|
+
tags: tagsJson,
|
|
70
|
+
relevance: result.relevance,
|
|
71
|
+
author: opts.author,
|
|
72
|
+
authority: opts.authority,
|
|
73
|
+
confidence: result.confidence,
|
|
74
|
+
reinforcement_count: 0,
|
|
75
|
+
content_hash: "",
|
|
76
|
+
status: "active",
|
|
77
|
+
tier: "active",
|
|
78
|
+
supersedes: null,
|
|
79
|
+
superseded_by: null,
|
|
80
|
+
last_reinforced: null,
|
|
81
|
+
created: now,
|
|
82
|
+
modified: now,
|
|
83
|
+
embedding: null,
|
|
84
|
+
source_path: null,
|
|
85
|
+
project_id: projectId,
|
|
86
|
+
scope: "project",
|
|
87
|
+
});
|
|
88
|
+
console.log(`\nMemory added to [${writeTarget.label}]: ${result.title}`);
|
|
89
|
+
console.log(`ID: ${id}`);
|
|
90
|
+
console.log(`Category: ${result.category}`);
|
|
91
|
+
console.log(`Confidence: ${result.confidence}`);
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
centralDb?.close();
|
|
95
|
+
}
|
|
96
|
+
if (result.proposedNewTags && result.proposedNewTags.length > 0) {
|
|
97
|
+
console.log("\nProposed new tags (not yet in registry):");
|
|
98
|
+
for (const t of result.proposedNewTags) {
|
|
99
|
+
console.log(` ${t.category}:${t.tag}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type AddStructuredOptions = {
|
|
2
|
+
title: string;
|
|
3
|
+
category: string;
|
|
4
|
+
content: string;
|
|
5
|
+
tags: string;
|
|
6
|
+
relevance: string;
|
|
7
|
+
author: string;
|
|
8
|
+
authority: string;
|
|
9
|
+
confidence: string;
|
|
10
|
+
store?: string;
|
|
11
|
+
user?: boolean;
|
|
12
|
+
global?: boolean;
|
|
13
|
+
};
|
|
14
|
+
type ResolveProjectId = (dir?: string) => Promise<string | null>;
|
|
15
|
+
export declare function runAddStructuredCommand(opts: AddStructuredOptions, resolveProjectId: ResolveProjectId): Promise<void>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { GnosysDB } from "./db.js";
|
|
2
|
+
export async function runAddStructuredCommand(opts, resolveProjectId) {
|
|
3
|
+
// ─── Phase 9b: --user / --global route through central DB ─────
|
|
4
|
+
if (opts.user || opts.global) {
|
|
5
|
+
let centralDb = null;
|
|
6
|
+
try {
|
|
7
|
+
centralDb = GnosysDB.openCentral();
|
|
8
|
+
if (!centralDb.isAvailable()) {
|
|
9
|
+
console.error("Central DB not available.");
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
const scope = opts.global ? "global" : "user";
|
|
13
|
+
const now = new Date().toISOString();
|
|
14
|
+
const id = `mem-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
15
|
+
const projectId = opts.global ? null : await resolveProjectId();
|
|
16
|
+
centralDb.insertMemory({
|
|
17
|
+
id,
|
|
18
|
+
title: opts.title,
|
|
19
|
+
category: opts.category,
|
|
20
|
+
content: `# ${opts.title}\n\n${opts.content}`,
|
|
21
|
+
summary: null,
|
|
22
|
+
tags: opts.tags,
|
|
23
|
+
relevance: opts.relevance || opts.content.slice(0, 200),
|
|
24
|
+
author: opts.author,
|
|
25
|
+
authority: opts.authority,
|
|
26
|
+
confidence: parseFloat(opts.confidence),
|
|
27
|
+
reinforcement_count: 0,
|
|
28
|
+
content_hash: "",
|
|
29
|
+
status: "active",
|
|
30
|
+
tier: "active",
|
|
31
|
+
supersedes: null,
|
|
32
|
+
superseded_by: null,
|
|
33
|
+
last_reinforced: null,
|
|
34
|
+
created: now,
|
|
35
|
+
modified: now,
|
|
36
|
+
embedding: null,
|
|
37
|
+
source_path: null,
|
|
38
|
+
project_id: projectId,
|
|
39
|
+
scope,
|
|
40
|
+
});
|
|
41
|
+
console.log(`Memory added (scope: ${scope}): ${opts.title}`);
|
|
42
|
+
console.log(`ID: ${id}`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
console.error(`Error: ${err instanceof Error ? err.message : err}`);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
centralDb?.close();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// ─── DB-only write ────────────────────────────────────────────
|
|
54
|
+
let tags;
|
|
55
|
+
try {
|
|
56
|
+
tags = JSON.parse(opts.tags);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
console.error("Invalid --tags JSON. Example: '{\"domain\":[\"auth\"],\"type\":[\"decision\"]}'");
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
let centralDb = null;
|
|
63
|
+
try {
|
|
64
|
+
centralDb = GnosysDB.openCentral();
|
|
65
|
+
const projectId = await resolveProjectId();
|
|
66
|
+
const id = centralDb.getNextId(opts.category, projectId || undefined);
|
|
67
|
+
const now = new Date().toISOString();
|
|
68
|
+
const content = `# ${opts.title}\n\n${opts.content}`;
|
|
69
|
+
const tagsJson = Array.isArray(tags)
|
|
70
|
+
? JSON.stringify(tags)
|
|
71
|
+
: JSON.stringify(Object.values(tags).flat());
|
|
72
|
+
centralDb.insertMemory({
|
|
73
|
+
id,
|
|
74
|
+
title: opts.title,
|
|
75
|
+
category: opts.category,
|
|
76
|
+
content,
|
|
77
|
+
summary: null,
|
|
78
|
+
tags: tagsJson,
|
|
79
|
+
relevance: opts.relevance || opts.content.slice(0, 200),
|
|
80
|
+
author: opts.author,
|
|
81
|
+
authority: opts.authority,
|
|
82
|
+
confidence: parseFloat(opts.confidence),
|
|
83
|
+
reinforcement_count: 0,
|
|
84
|
+
content_hash: "",
|
|
85
|
+
status: "active",
|
|
86
|
+
tier: "active",
|
|
87
|
+
supersedes: null,
|
|
88
|
+
superseded_by: null,
|
|
89
|
+
last_reinforced: null,
|
|
90
|
+
created: now,
|
|
91
|
+
modified: now,
|
|
92
|
+
embedding: null,
|
|
93
|
+
source_path: null,
|
|
94
|
+
project_id: projectId,
|
|
95
|
+
scope: "project",
|
|
96
|
+
});
|
|
97
|
+
console.log(`Memory added: ${opts.title}`);
|
|
98
|
+
console.log(`ID: ${id}`);
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
centralDb?.close();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { GnosysDB } from "./db.js";
|
|
2
|
+
export async function runAmbiguityCommand(query, opts) {
|
|
3
|
+
let centralDb = null;
|
|
4
|
+
try {
|
|
5
|
+
centralDb = GnosysDB.openCentral();
|
|
6
|
+
if (!centralDb.isAvailable()) {
|
|
7
|
+
console.error("Central DB not available.");
|
|
8
|
+
process.exitCode = 1;
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const { detectAmbiguity } = await import("./federated.js");
|
|
12
|
+
const ambiguity = detectAmbiguity(centralDb, query);
|
|
13
|
+
if (opts.json) {
|
|
14
|
+
console.log(JSON.stringify({ query, ambiguous: !!ambiguity, ...(ambiguity || {}) }, null, 2));
|
|
15
|
+
}
|
|
16
|
+
else if (!ambiguity) {
|
|
17
|
+
console.log(`No ambiguity for "${query}" — matches at most one project.`);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
console.log(ambiguity.message);
|
|
21
|
+
for (const c of ambiguity.candidates) {
|
|
22
|
+
console.log(`\n ${c.projectName} (${c.projectId})`);
|
|
23
|
+
console.log(` Dir: ${c.workingDirectory}`);
|
|
24
|
+
console.log(` Matching memories: ${c.memoryCount}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
console.error(`Error: ${err instanceof Error ? err.message : err}`);
|
|
30
|
+
process.exitCode = 1;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
centralDb?.close();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API key storage and resolution for Gnosys LLM providers.
|
|
3
|
+
*
|
|
4
|
+
* Keychain / env service names (also used as GNOSYS_*_KEY env vars):
|
|
5
|
+
* - Global: GNOSYS_GLOBAL_<PROVIDER>_KEY (one key for all tasks using that provider)
|
|
6
|
+
* - Provider: GNOSYS_<PROVIDER>_KEY (legacy default / fallback)
|
|
7
|
+
*/
|
|
8
|
+
import type { Interface as ReadlineInterface } from "readline/promises";
|
|
9
|
+
import { type GnosysConfig, type LLMProviderName } from "./config.js";
|
|
10
|
+
export type ApiKeyScope = "global" | "provider";
|
|
11
|
+
export type RoutableTask = "structuring" | "synthesis" | "vision" | "transcription" | "chat";
|
|
12
|
+
export type LlmTaskName = RoutableTask | "dream";
|
|
13
|
+
export interface ApiKeyRequirement {
|
|
14
|
+
provider: LLMProviderName;
|
|
15
|
+
scope: ApiKeyScope;
|
|
16
|
+
}
|
|
17
|
+
export declare function providerNeedsApiKey(provider: string): boolean;
|
|
18
|
+
/** Keychain service / env var name for a specific scope. */
|
|
19
|
+
export declare function apiKeyServiceName(provider: LLMProviderName, scope: ApiKeyScope): string;
|
|
20
|
+
/** Lookup order: global → provider default (legacy/generic via readFirstInChain). */
|
|
21
|
+
export declare function apiKeyLookupChain(provider: LLMProviderName): string[];
|
|
22
|
+
/** Read a secret directly from the secure store, ignoring env vars. */
|
|
23
|
+
export declare function readSecureStoreSecret(service: string): string | undefined;
|
|
24
|
+
/** Read a secret from env or secure store by service name. */
|
|
25
|
+
export declare function readStoredSecret(service: string): string | undefined;
|
|
26
|
+
export declare function detectKeyLocation(provider: string): {
|
|
27
|
+
found: boolean;
|
|
28
|
+
location: "keychain" | "env" | "dotenv" | "none";
|
|
29
|
+
serviceName?: string;
|
|
30
|
+
envVarName?: string;
|
|
31
|
+
lastFour?: string;
|
|
32
|
+
};
|
|
33
|
+
/** First non-empty secret in the lookup chain. */
|
|
34
|
+
export declare function readFirstInChain(provider: LLMProviderName): string | undefined;
|
|
35
|
+
/** Mask for display: first 4 + ellipsis + last 4 characters. */
|
|
36
|
+
export declare function maskKeySnippet(key: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Where a secret is stored (Keychain, env var name, gnosys.json, or .env file).
|
|
39
|
+
*/
|
|
40
|
+
export declare function detectSecretSource(service: string, legacyEnv?: string): string;
|
|
41
|
+
export interface StoredKeySlot {
|
|
42
|
+
service: string;
|
|
43
|
+
scope: ApiKeyScope;
|
|
44
|
+
source: string;
|
|
45
|
+
/** Present only when a value exists at this slot */
|
|
46
|
+
preview?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* List every key slot for a provider that currently holds a value.
|
|
50
|
+
*/
|
|
51
|
+
export declare function listStoredKeySlots(config: GnosysConfig, provider: LLMProviderName): StoredKeySlot[];
|
|
52
|
+
/** Delete a secret from Keychain / GNOME Keyring (not process env). */
|
|
53
|
+
export declare function deleteStoredSecret(service: string): boolean;
|
|
54
|
+
/** Resolve API key for a provider. */
|
|
55
|
+
export declare function getApiKeyForProviderFromConfig(config: GnosysConfig, provider: LLMProviderName): string | undefined;
|
|
56
|
+
export declare function writeApiKeyToKeychain(service: string, key: string): boolean;
|
|
57
|
+
export declare function writeApiKeyToSecretTool(service: string, key: string, label: string): boolean;
|
|
58
|
+
export declare function storeApiKeySecret(service: string, key: string, provider: string): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Build key requirements from effective routing — one global key per cloud provider in use.
|
|
61
|
+
*/
|
|
62
|
+
export declare function buildApiKeyRequirementsFromConfig(config: GnosysConfig): ApiKeyRequirement[];
|
|
63
|
+
/**
|
|
64
|
+
* Prompt for missing keys and store in Keychain / GNOME Keyring.
|
|
65
|
+
*/
|
|
66
|
+
export declare function ensureApiKeys(rl: ReadlineInterface, requirements: ApiKeyRequirement[], askInput: (rl: ReadlineInterface, prompt: string) => Promise<string>, opts?: {
|
|
67
|
+
maskKey?: (key: string) => string;
|
|
68
|
+
warn?: string;
|
|
69
|
+
check?: string;
|
|
70
|
+
cross?: string;
|
|
71
|
+
dim?: string;
|
|
72
|
+
reset?: string;
|
|
73
|
+
}): Promise<number>;
|
|
74
|
+
/** Effective routing map used for key collection. */
|
|
75
|
+
export declare function buildEffectiveRouting(config: GnosysConfig): Record<string, {
|
|
76
|
+
provider: LLMProviderName;
|
|
77
|
+
model: string;
|
|
78
|
+
}>;
|