gnosys 5.9.5 → 5.11.0
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 +91 -771
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +403 -141
- package/dist/index.d.ts +3 -1
- package/dist/index.js +427 -348
- package/dist/lib/archive.d.ts +3 -4
- package/dist/lib/archive.js +0 -1
- package/dist/lib/ask.d.ts +3 -4
- package/dist/lib/ask.js +0 -1
- package/dist/lib/atomicWrite.d.ts +7 -0
- package/dist/lib/atomicWrite.js +46 -0
- package/dist/lib/attachments.d.ts +0 -1
- package/dist/lib/attachments.js +0 -1
- package/dist/lib/audioExtract.d.ts +0 -1
- package/dist/lib/audioExtract.js +0 -1
- package/dist/lib/audit.d.ts +0 -1
- package/dist/lib/audit.js +0 -1
- package/dist/lib/bootstrap.d.ts +1 -2
- package/dist/lib/bootstrap.js +0 -1
- package/dist/lib/centralize.d.ts +20 -0
- package/dist/lib/centralize.js +34 -0
- package/dist/lib/chat/SlashPalette.d.ts +2 -3
- package/dist/lib/chat/SlashPalette.js +0 -1
- package/dist/lib/chat/boot-splash.d.ts +1 -2
- package/dist/lib/chat/boot-splash.js +0 -1
- package/dist/lib/chat/choose.d.ts +0 -1
- package/dist/lib/chat/choose.js +0 -2
- package/dist/lib/chat/commands.d.ts +1 -2
- package/dist/lib/chat/commands.js +0 -1
- package/dist/lib/chat/components/CitationText.d.ts +1 -2
- package/dist/lib/chat/components/CitationText.js +0 -1
- package/dist/lib/chat/components/MarkdownRenderer.d.ts +0 -1
- package/dist/lib/chat/components/MarkdownRenderer.js +0 -1
- package/dist/lib/chat/components/ToolCallCard.d.ts +1 -2
- package/dist/lib/chat/components/ToolCallCard.js +0 -1
- package/dist/lib/chat/focus.d.ts +3 -3
- package/dist/lib/chat/focus.js +0 -1
- package/dist/lib/chat/index.d.ts +3 -4
- package/dist/lib/chat/index.js +2 -2
- package/dist/lib/chat/intent.d.ts +1 -17
- package/dist/lib/chat/intent.js +2 -3
- package/dist/lib/chat/llmTurn.d.ts +5 -6
- package/dist/lib/chat/llmTurn.js +0 -1
- package/dist/lib/chat/recall.d.ts +2 -3
- package/dist/lib/chat/recall.js +1 -2
- package/dist/lib/chat/render.d.ts +2 -3
- package/dist/lib/chat/render.js +0 -1
- package/dist/lib/chat/session.d.ts +0 -1
- package/dist/lib/chat/session.js +0 -1
- package/dist/lib/chat/theme.d.ts +0 -1
- package/dist/lib/chat/theme.js +0 -1
- package/dist/lib/chat/toolFence.d.ts +2 -2
- package/dist/lib/chat/toolFence.js +0 -1
- package/dist/lib/chat/tools.d.ts +0 -1
- package/dist/lib/chat/tools.js +0 -1
- package/dist/lib/chat/types.d.ts +0 -1
- package/dist/lib/chat/types.js +0 -1
- package/dist/lib/chat/write.d.ts +5 -5
- package/dist/lib/chat/write.js +0 -1
- package/dist/lib/chunkSplitter.d.ts +0 -1
- package/dist/lib/chunkSplitter.js +0 -1
- package/dist/lib/cleanup.d.ts +0 -1
- package/dist/lib/cleanup.js +0 -1
- package/dist/lib/config.d.ts +0 -1
- package/dist/lib/config.js +3 -3
- package/dist/lib/dashboard.d.ts +3 -4
- package/dist/lib/dashboard.js +5 -2
- package/dist/lib/db.d.ts +24 -1
- package/dist/lib/db.js +162 -16
- package/dist/lib/dbSearch.d.ts +3 -4
- package/dist/lib/dbSearch.js +0 -1
- package/dist/lib/dbWrite.d.ts +2 -3
- package/dist/lib/dbWrite.js +0 -1
- package/dist/lib/desktopNotify.d.ts +0 -1
- package/dist/lib/desktopNotify.js +0 -1
- package/dist/lib/docxExtract.d.ts +0 -1
- package/dist/lib/docxExtract.js +22 -1
- package/dist/lib/dream.d.ts +2 -3
- package/dist/lib/dream.js +2 -2
- package/dist/lib/embeddings.d.ts +0 -3
- package/dist/lib/embeddings.js +7 -3
- package/dist/lib/export.d.ts +6 -2
- package/dist/lib/export.js +24 -2
- package/dist/lib/exportProject.d.ts +4 -3
- package/dist/lib/exportProject.js +3 -1
- package/dist/lib/federated.d.ts +3 -3
- package/dist/lib/federated.js +6 -4
- package/dist/lib/fileDetect.d.ts +0 -1
- package/dist/lib/fileDetect.js +0 -1
- package/dist/lib/graph.d.ts +4 -4
- package/dist/lib/graph.js +0 -1
- package/dist/lib/heartbeat.d.ts +0 -13
- package/dist/lib/heartbeat.js +1 -2
- package/dist/lib/hybridSearch.d.ts +5 -21
- package/dist/lib/hybridSearch.js +0 -1
- package/dist/lib/idFormat.d.ts +0 -2
- package/dist/lib/idFormat.js +1 -2
- package/dist/lib/imageExtract.d.ts +0 -1
- package/dist/lib/imageExtract.js +0 -1
- package/dist/lib/import.d.ts +6 -5
- package/dist/lib/import.js +3 -33
- package/dist/lib/importProject.d.ts +4 -4
- package/dist/lib/importProject.js +1 -2
- package/dist/lib/ingest.d.ts +3 -4
- package/dist/lib/ingest.js +0 -1
- package/dist/lib/lensing.d.ts +1 -2
- package/dist/lib/lensing.js +0 -1
- package/dist/lib/llm.d.ts +6 -45
- package/dist/lib/llm.js +27 -9
- package/dist/lib/lock.d.ts +0 -1
- package/dist/lib/lock.js +0 -1
- package/dist/lib/log.d.ts +4 -0
- package/dist/lib/log.js +85 -0
- package/dist/lib/machineConfig.d.ts +86 -0
- package/dist/lib/machineConfig.js +157 -0
- package/dist/lib/machineMigrate.d.ts +38 -0
- package/dist/lib/machineMigrate.js +102 -0
- package/dist/lib/maintenance.d.ts +4 -5
- package/dist/lib/maintenance.js +0 -1
- package/dist/lib/mcpClientConfig.d.ts +20 -0
- package/dist/lib/mcpClientConfig.js +62 -0
- package/dist/lib/mcpHttp.d.ts +52 -0
- package/dist/lib/mcpHttp.js +227 -0
- package/dist/lib/migrate.d.ts +1 -2
- package/dist/lib/migrate.js +1 -1
- package/dist/lib/modelValidation.d.ts +0 -1
- package/dist/lib/modelValidation.js +0 -1
- package/dist/lib/multimodalIngest.d.ts +1 -2
- package/dist/lib/multimodalIngest.js +0 -1
- package/dist/lib/packageManager.d.ts +5 -0
- package/dist/lib/packageManager.js +30 -0
- package/dist/lib/paths.d.ts +11 -7
- package/dist/lib/paths.js +14 -2
- package/dist/lib/pdfExtract.d.ts +0 -1
- package/dist/lib/pdfExtract.js +0 -1
- package/dist/lib/portfolio.d.ts +1 -2
- package/dist/lib/portfolio.js +10 -3
- package/dist/lib/portfolioHtml.d.ts +1 -2
- package/dist/lib/portfolioHtml.js +0 -1
- package/dist/lib/preferences.d.ts +6 -2
- package/dist/lib/preferences.js +19 -1
- package/dist/lib/progress.d.ts +2 -2
- package/dist/lib/progress.js +0 -1
- package/dist/lib/projectIdentity.d.ts +1 -2
- package/dist/lib/projectIdentity.js +5 -5
- package/dist/lib/projectPaths.d.ts +60 -0
- package/dist/lib/projectPaths.js +99 -0
- package/dist/lib/projectScan.d.ts +40 -0
- package/dist/lib/projectScan.js +96 -0
- package/dist/lib/recall.d.ts +6 -6
- package/dist/lib/recall.js +0 -1
- package/dist/lib/remote.d.ts +3 -20
- package/dist/lib/remote.js +44 -2
- package/dist/lib/remoteWizard.d.ts +2 -3
- package/dist/lib/remoteWizard.js +0 -1
- package/dist/lib/resolver.d.ts +1 -2
- package/dist/lib/resolver.js +2 -3
- package/dist/lib/retry.d.ts +0 -1
- package/dist/lib/retry.js +1 -2
- package/dist/lib/rulesGen.d.ts +2 -8
- package/dist/lib/rulesGen.js +1 -2
- package/dist/lib/search.d.ts +1 -2
- package/dist/lib/search.js +1 -1
- package/dist/lib/searchTypes.d.ts +18 -0
- package/dist/lib/searchTypes.js +2 -0
- package/dist/lib/setup/coldStart.d.ts +0 -1
- package/dist/lib/setup/coldStart.js +0 -1
- package/dist/lib/setup/configSetRender.d.ts +0 -1
- package/dist/lib/setup/configSetRender.js +0 -1
- package/dist/lib/setup/dreamRender.d.ts +0 -1
- package/dist/lib/setup/dreamRender.js +0 -1
- package/dist/lib/setup/dreamState.d.ts +2 -2
- package/dist/lib/setup/dreamState.js +0 -1
- package/dist/lib/setup/modelsRender.d.ts +0 -1
- package/dist/lib/setup/modelsRender.js +0 -1
- package/dist/lib/setup/remoteRender.d.ts +0 -1
- package/dist/lib/setup/remoteRender.js +0 -1
- package/dist/lib/setup/routingRender.d.ts +0 -1
- package/dist/lib/setup/routingRender.js +0 -1
- package/dist/lib/setup/sections/ides.d.ts +1 -2
- package/dist/lib/setup/sections/ides.js +3 -2
- package/dist/lib/setup/sections/preferences.d.ts +1 -2
- package/dist/lib/setup/sections/preferences.js +3 -2
- package/dist/lib/setup/sections/routing.d.ts +1 -2
- package/dist/lib/setup/sections/routing.js +0 -1
- package/dist/lib/setup/storePath.d.ts +0 -1
- package/dist/lib/setup/storePath.js +0 -1
- package/dist/lib/setup/summary.d.ts +1 -2
- package/dist/lib/setup/summary.js +0 -1
- package/dist/lib/setup/syncProjectsRender.d.ts +0 -1
- package/dist/lib/setup/syncProjectsRender.js +0 -1
- package/dist/lib/setup/ui/diff.d.ts +0 -1
- package/dist/lib/setup/ui/diff.js +0 -1
- package/dist/lib/setup/ui/footer.d.ts +0 -1
- package/dist/lib/setup/ui/footer.js +0 -1
- package/dist/lib/setup/ui/header.d.ts +0 -1
- package/dist/lib/setup/ui/header.js +0 -1
- package/dist/lib/setup/ui/index.d.ts +0 -1
- package/dist/lib/setup/ui/index.js +0 -1
- package/dist/lib/setup/ui/menu.d.ts +0 -1
- package/dist/lib/setup/ui/menu.js +0 -1
- package/dist/lib/setup/ui/panel.d.ts +0 -1
- package/dist/lib/setup/ui/panel.js +0 -1
- package/dist/lib/setup/ui/prompt.d.ts +0 -1
- package/dist/lib/setup/ui/prompt.js +0 -1
- package/dist/lib/setup/ui/safePrompt.d.ts +0 -1
- package/dist/lib/setup/ui/safePrompt.js +0 -1
- package/dist/lib/setup/ui/spinner.d.ts +0 -1
- package/dist/lib/setup/ui/spinner.js +0 -1
- package/dist/lib/setup/ui/status.d.ts +0 -1
- package/dist/lib/setup/ui/status.js +0 -1
- package/dist/lib/setup/ui/table.d.ts +0 -1
- package/dist/lib/setup/ui/table.js +0 -1
- package/dist/lib/setup/ui/title.d.ts +0 -1
- package/dist/lib/setup/ui/title.js +0 -1
- package/dist/lib/setup/ui/tokens.d.ts +0 -1
- package/dist/lib/setup/ui/tokens.js +0 -1
- package/dist/lib/setup.d.ts +2 -31
- package/dist/lib/setup.js +13 -9
- package/dist/lib/staticSearch.d.ts +0 -1
- package/dist/lib/staticSearch.js +0 -1
- package/dist/lib/store.d.ts +0 -1
- package/dist/lib/store.js +0 -1
- package/dist/lib/structuredIngest.d.ts +0 -1
- package/dist/lib/structuredIngest.js +0 -1
- package/dist/lib/tags.d.ts +0 -1
- package/dist/lib/tags.js +0 -1
- package/dist/lib/timeline.d.ts +2 -3
- package/dist/lib/timeline.js +3 -4
- package/dist/lib/trace.d.ts +1 -16
- package/dist/lib/trace.js +0 -1
- package/dist/lib/upgrade.d.ts +0 -1
- package/dist/lib/upgrade.js +0 -1
- package/dist/lib/videoExtract.d.ts +0 -1
- package/dist/lib/videoExtract.js +0 -1
- package/dist/lib/webIndex.d.ts +1 -3
- package/dist/lib/webIndex.js +0 -1
- package/dist/lib/webIngest.d.ts +13 -1
- package/dist/lib/webIngest.js +98 -24
- package/dist/lib/wikilinks.d.ts +3 -3
- package/dist/lib/wikilinks.js +0 -1
- package/dist/postinstall.d.ts +0 -1
- package/dist/postinstall.js +0 -1
- package/dist/sandbox/client.d.ts +0 -1
- package/dist/sandbox/client.js +0 -1
- package/dist/sandbox/helper-template.d.ts +0 -1
- package/dist/sandbox/helper-template.js +0 -1
- package/dist/sandbox/manager.d.ts +0 -9
- package/dist/sandbox/manager.js +2 -3
- package/dist/sandbox/server.d.ts +2 -3
- package/dist/sandbox/server.js +7 -7
- package/docs/logo.svg +25 -0
- package/package.json +18 -6
- package/prompts/synthesize.md +2 -0
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/archive.d.ts.map +0 -1
- package/dist/lib/archive.js.map +0 -1
- package/dist/lib/ask.d.ts.map +0 -1
- package/dist/lib/ask.js.map +0 -1
- package/dist/lib/attachments.d.ts.map +0 -1
- package/dist/lib/attachments.js.map +0 -1
- package/dist/lib/audioExtract.d.ts.map +0 -1
- package/dist/lib/audioExtract.js.map +0 -1
- package/dist/lib/audit.d.ts.map +0 -1
- package/dist/lib/audit.js.map +0 -1
- package/dist/lib/bootstrap.d.ts.map +0 -1
- package/dist/lib/bootstrap.js.map +0 -1
- package/dist/lib/chat/SlashPalette.d.ts.map +0 -1
- package/dist/lib/chat/SlashPalette.js.map +0 -1
- package/dist/lib/chat/boot-splash.d.ts.map +0 -1
- package/dist/lib/chat/boot-splash.js.map +0 -1
- package/dist/lib/chat/choose.d.ts.map +0 -1
- package/dist/lib/chat/choose.js.map +0 -1
- package/dist/lib/chat/commands.d.ts.map +0 -1
- package/dist/lib/chat/commands.js.map +0 -1
- package/dist/lib/chat/components/CitationText.d.ts.map +0 -1
- package/dist/lib/chat/components/CitationText.js.map +0 -1
- package/dist/lib/chat/components/MarkdownRenderer.d.ts.map +0 -1
- package/dist/lib/chat/components/MarkdownRenderer.js.map +0 -1
- package/dist/lib/chat/components/ToolCallCard.d.ts.map +0 -1
- package/dist/lib/chat/components/ToolCallCard.js.map +0 -1
- package/dist/lib/chat/focus.d.ts.map +0 -1
- package/dist/lib/chat/focus.js.map +0 -1
- package/dist/lib/chat/index.d.ts.map +0 -1
- package/dist/lib/chat/index.js.map +0 -1
- package/dist/lib/chat/intent.d.ts.map +0 -1
- package/dist/lib/chat/intent.js.map +0 -1
- package/dist/lib/chat/llmTurn.d.ts.map +0 -1
- package/dist/lib/chat/llmTurn.js.map +0 -1
- package/dist/lib/chat/recall.d.ts.map +0 -1
- package/dist/lib/chat/recall.js.map +0 -1
- package/dist/lib/chat/render.d.ts.map +0 -1
- package/dist/lib/chat/render.js.map +0 -1
- package/dist/lib/chat/session.d.ts.map +0 -1
- package/dist/lib/chat/session.js.map +0 -1
- package/dist/lib/chat/theme.d.ts.map +0 -1
- package/dist/lib/chat/theme.js.map +0 -1
- package/dist/lib/chat/toolFence.d.ts.map +0 -1
- package/dist/lib/chat/toolFence.js.map +0 -1
- package/dist/lib/chat/tools.d.ts.map +0 -1
- package/dist/lib/chat/tools.js.map +0 -1
- package/dist/lib/chat/types.d.ts.map +0 -1
- package/dist/lib/chat/types.js.map +0 -1
- package/dist/lib/chat/write.d.ts.map +0 -1
- package/dist/lib/chat/write.js.map +0 -1
- package/dist/lib/chunkSplitter.d.ts.map +0 -1
- package/dist/lib/chunkSplitter.js.map +0 -1
- package/dist/lib/cleanup.d.ts.map +0 -1
- package/dist/lib/cleanup.js.map +0 -1
- package/dist/lib/config.d.ts.map +0 -1
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/dashboard.d.ts.map +0 -1
- package/dist/lib/dashboard.js.map +0 -1
- package/dist/lib/db.d.ts.map +0 -1
- package/dist/lib/db.js.map +0 -1
- package/dist/lib/dbSearch.d.ts.map +0 -1
- package/dist/lib/dbSearch.js.map +0 -1
- package/dist/lib/dbWrite.d.ts.map +0 -1
- package/dist/lib/dbWrite.js.map +0 -1
- package/dist/lib/desktopNotify.d.ts.map +0 -1
- package/dist/lib/desktopNotify.js.map +0 -1
- package/dist/lib/docxExtract.d.ts.map +0 -1
- package/dist/lib/docxExtract.js.map +0 -1
- package/dist/lib/dream.d.ts.map +0 -1
- package/dist/lib/dream.js.map +0 -1
- package/dist/lib/embeddings.d.ts.map +0 -1
- package/dist/lib/embeddings.js.map +0 -1
- package/dist/lib/export.d.ts.map +0 -1
- package/dist/lib/export.js.map +0 -1
- package/dist/lib/exportProject.d.ts.map +0 -1
- package/dist/lib/exportProject.js.map +0 -1
- package/dist/lib/federated.d.ts.map +0 -1
- package/dist/lib/federated.js.map +0 -1
- package/dist/lib/fileDetect.d.ts.map +0 -1
- package/dist/lib/fileDetect.js.map +0 -1
- package/dist/lib/graph.d.ts.map +0 -1
- package/dist/lib/graph.js.map +0 -1
- package/dist/lib/heartbeat.d.ts.map +0 -1
- package/dist/lib/heartbeat.js.map +0 -1
- package/dist/lib/history.d.ts +0 -39
- package/dist/lib/history.d.ts.map +0 -1
- package/dist/lib/history.js +0 -112
- package/dist/lib/history.js.map +0 -1
- package/dist/lib/hybridSearch.d.ts.map +0 -1
- package/dist/lib/hybridSearch.js.map +0 -1
- package/dist/lib/idFormat.d.ts.map +0 -1
- package/dist/lib/idFormat.js.map +0 -1
- package/dist/lib/imageExtract.d.ts.map +0 -1
- package/dist/lib/imageExtract.js.map +0 -1
- package/dist/lib/import.d.ts.map +0 -1
- package/dist/lib/import.js.map +0 -1
- package/dist/lib/importProject.d.ts.map +0 -1
- package/dist/lib/importProject.js.map +0 -1
- package/dist/lib/ingest.d.ts.map +0 -1
- package/dist/lib/ingest.js.map +0 -1
- package/dist/lib/lensing.d.ts.map +0 -1
- package/dist/lib/lensing.js.map +0 -1
- package/dist/lib/llm.d.ts.map +0 -1
- package/dist/lib/llm.js.map +0 -1
- package/dist/lib/lock.d.ts.map +0 -1
- package/dist/lib/lock.js.map +0 -1
- package/dist/lib/maintenance.d.ts.map +0 -1
- package/dist/lib/maintenance.js.map +0 -1
- package/dist/lib/migrate.d.ts.map +0 -1
- package/dist/lib/migrate.js.map +0 -1
- package/dist/lib/modelValidation.d.ts.map +0 -1
- package/dist/lib/modelValidation.js.map +0 -1
- package/dist/lib/multimodalIngest.d.ts.map +0 -1
- package/dist/lib/multimodalIngest.js.map +0 -1
- package/dist/lib/paths.d.ts.map +0 -1
- package/dist/lib/paths.js.map +0 -1
- package/dist/lib/pdfExtract.d.ts.map +0 -1
- package/dist/lib/pdfExtract.js.map +0 -1
- package/dist/lib/portfolio.d.ts.map +0 -1
- package/dist/lib/portfolio.js.map +0 -1
- package/dist/lib/portfolioHtml.d.ts.map +0 -1
- package/dist/lib/portfolioHtml.js.map +0 -1
- package/dist/lib/preferences.d.ts.map +0 -1
- package/dist/lib/preferences.js.map +0 -1
- package/dist/lib/progress.d.ts.map +0 -1
- package/dist/lib/progress.js.map +0 -1
- package/dist/lib/projectIdentity.d.ts.map +0 -1
- package/dist/lib/projectIdentity.js.map +0 -1
- package/dist/lib/recall.d.ts.map +0 -1
- package/dist/lib/recall.js.map +0 -1
- package/dist/lib/remote.d.ts.map +0 -1
- package/dist/lib/remote.js.map +0 -1
- package/dist/lib/remoteWizard.d.ts.map +0 -1
- package/dist/lib/remoteWizard.js.map +0 -1
- package/dist/lib/resolver.d.ts.map +0 -1
- package/dist/lib/resolver.js.map +0 -1
- package/dist/lib/retry.d.ts.map +0 -1
- package/dist/lib/retry.js.map +0 -1
- package/dist/lib/rulesGen.d.ts.map +0 -1
- package/dist/lib/rulesGen.js.map +0 -1
- package/dist/lib/search.d.ts.map +0 -1
- package/dist/lib/search.js.map +0 -1
- package/dist/lib/setup/coldStart.d.ts.map +0 -1
- package/dist/lib/setup/coldStart.js.map +0 -1
- package/dist/lib/setup/configSetRender.d.ts.map +0 -1
- package/dist/lib/setup/configSetRender.js.map +0 -1
- package/dist/lib/setup/dreamRender.d.ts.map +0 -1
- package/dist/lib/setup/dreamRender.js.map +0 -1
- package/dist/lib/setup/dreamState.d.ts.map +0 -1
- package/dist/lib/setup/dreamState.js.map +0 -1
- package/dist/lib/setup/modelsRender.d.ts.map +0 -1
- package/dist/lib/setup/modelsRender.js.map +0 -1
- package/dist/lib/setup/remoteRender.d.ts.map +0 -1
- package/dist/lib/setup/remoteRender.js.map +0 -1
- package/dist/lib/setup/routingRender.d.ts.map +0 -1
- package/dist/lib/setup/routingRender.js.map +0 -1
- package/dist/lib/setup/sections/ides.d.ts.map +0 -1
- package/dist/lib/setup/sections/ides.js.map +0 -1
- package/dist/lib/setup/sections/preferences.d.ts.map +0 -1
- package/dist/lib/setup/sections/preferences.js.map +0 -1
- package/dist/lib/setup/sections/routing.d.ts.map +0 -1
- package/dist/lib/setup/sections/routing.js.map +0 -1
- package/dist/lib/setup/storePath.d.ts.map +0 -1
- package/dist/lib/setup/storePath.js.map +0 -1
- package/dist/lib/setup/summary.d.ts.map +0 -1
- package/dist/lib/setup/summary.js.map +0 -1
- package/dist/lib/setup/syncProjectsRender.d.ts.map +0 -1
- package/dist/lib/setup/syncProjectsRender.js.map +0 -1
- package/dist/lib/setup/ui/diff.d.ts.map +0 -1
- package/dist/lib/setup/ui/diff.js.map +0 -1
- package/dist/lib/setup/ui/footer.d.ts.map +0 -1
- package/dist/lib/setup/ui/footer.js.map +0 -1
- package/dist/lib/setup/ui/header.d.ts.map +0 -1
- package/dist/lib/setup/ui/header.js.map +0 -1
- package/dist/lib/setup/ui/index.d.ts.map +0 -1
- package/dist/lib/setup/ui/index.js.map +0 -1
- package/dist/lib/setup/ui/menu.d.ts.map +0 -1
- package/dist/lib/setup/ui/menu.js.map +0 -1
- package/dist/lib/setup/ui/panel.d.ts.map +0 -1
- package/dist/lib/setup/ui/panel.js.map +0 -1
- package/dist/lib/setup/ui/prompt.d.ts.map +0 -1
- package/dist/lib/setup/ui/prompt.js.map +0 -1
- package/dist/lib/setup/ui/safePrompt.d.ts.map +0 -1
- package/dist/lib/setup/ui/safePrompt.js.map +0 -1
- package/dist/lib/setup/ui/spinner.d.ts.map +0 -1
- package/dist/lib/setup/ui/spinner.js.map +0 -1
- package/dist/lib/setup/ui/status.d.ts.map +0 -1
- package/dist/lib/setup/ui/status.js.map +0 -1
- package/dist/lib/setup/ui/table.d.ts.map +0 -1
- package/dist/lib/setup/ui/table.js.map +0 -1
- package/dist/lib/setup/ui/title.d.ts.map +0 -1
- package/dist/lib/setup/ui/title.js.map +0 -1
- package/dist/lib/setup/ui/tokens.d.ts.map +0 -1
- package/dist/lib/setup/ui/tokens.js.map +0 -1
- package/dist/lib/setup.d.ts.map +0 -1
- package/dist/lib/setup.js.map +0 -1
- package/dist/lib/staticSearch.d.ts.map +0 -1
- package/dist/lib/staticSearch.js.map +0 -1
- package/dist/lib/store.d.ts.map +0 -1
- package/dist/lib/store.js.map +0 -1
- package/dist/lib/structuredIngest.d.ts.map +0 -1
- package/dist/lib/structuredIngest.js.map +0 -1
- package/dist/lib/tags.d.ts.map +0 -1
- package/dist/lib/tags.js.map +0 -1
- package/dist/lib/timeline.d.ts.map +0 -1
- package/dist/lib/timeline.js.map +0 -1
- package/dist/lib/trace.d.ts.map +0 -1
- package/dist/lib/trace.js.map +0 -1
- package/dist/lib/upgrade.d.ts.map +0 -1
- package/dist/lib/upgrade.js.map +0 -1
- package/dist/lib/videoExtract.d.ts.map +0 -1
- package/dist/lib/videoExtract.js.map +0 -1
- package/dist/lib/webIndex.d.ts.map +0 -1
- package/dist/lib/webIndex.js.map +0 -1
- package/dist/lib/webIngest.d.ts.map +0 -1
- package/dist/lib/webIngest.js.map +0 -1
- package/dist/lib/wikilinks.d.ts.map +0 -1
- package/dist/lib/wikilinks.js.map +0 -1
- package/dist/postinstall.d.ts.map +0 -1
- package/dist/postinstall.js.map +0 -1
- package/dist/sandbox/client.d.ts.map +0 -1
- package/dist/sandbox/client.js.map +0 -1
- package/dist/sandbox/helper-template.d.ts.map +0 -1
- package/dist/sandbox/helper-template.js.map +0 -1
- package/dist/sandbox/index.d.ts +0 -10
- package/dist/sandbox/index.d.ts.map +0 -1
- package/dist/sandbox/index.js +0 -10
- package/dist/sandbox/index.js.map +0 -1
- package/dist/sandbox/manager.d.ts.map +0 -1
- package/dist/sandbox/manager.js.map +0 -1
- package/dist/sandbox/server.d.ts.map +0 -1
- package/dist/sandbox/server.js.map +0 -1
package/dist/lib/llm.d.ts
CHANGED
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
* Supports Anthropic (cloud) and Ollama (local). Clean factory pattern enables
|
|
4
4
|
* future providers (Groq, OpenAI, LM Studio) with zero changes to call sites.
|
|
5
5
|
*/
|
|
6
|
-
import { GnosysConfig, LLMProviderName } from "./config.js";
|
|
7
|
-
|
|
6
|
+
import { type GnosysConfig, type LLMProviderName } from "./config.js";
|
|
7
|
+
/** Strip literal API keys and known key-prefix patterns from provider error text. */
|
|
8
|
+
export declare function redactKey(text: string, apiKey?: string): string;
|
|
9
|
+
interface LLMGenerateOptions {
|
|
8
10
|
system?: string;
|
|
9
11
|
maxTokens?: number;
|
|
10
12
|
stream?: boolean;
|
|
11
13
|
}
|
|
12
|
-
|
|
14
|
+
interface LLMStreamCallbacks {
|
|
13
15
|
onToken: (token: string) => void;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
@@ -35,47 +37,6 @@ export interface LLMProvider {
|
|
|
35
37
|
*/
|
|
36
38
|
testConnection(): Promise<boolean>;
|
|
37
39
|
}
|
|
38
|
-
export declare class AnthropicProvider implements LLMProvider {
|
|
39
|
-
readonly name: LLMProviderName;
|
|
40
|
-
readonly model: string;
|
|
41
|
-
private client;
|
|
42
|
-
private config;
|
|
43
|
-
private apiKey;
|
|
44
|
-
private clientPromise;
|
|
45
|
-
constructor(model: string, apiKey: string, config?: GnosysConfig);
|
|
46
|
-
private getClient;
|
|
47
|
-
generate(prompt: string, options?: LLMGenerateOptions, streamCallbacks?: LLMStreamCallbacks): Promise<string>;
|
|
48
|
-
private streamGenerate;
|
|
49
|
-
generateWithImage(prompt: string, imageBase64: string, mimeType: string, options?: LLMGenerateOptions): Promise<string>;
|
|
50
|
-
testConnection(): Promise<boolean>;
|
|
51
|
-
}
|
|
52
|
-
export declare class OllamaProvider implements LLMProvider {
|
|
53
|
-
readonly name: LLMProviderName;
|
|
54
|
-
readonly model: string;
|
|
55
|
-
private baseUrl;
|
|
56
|
-
private config;
|
|
57
|
-
constructor(model: string, baseUrl: string, config?: GnosysConfig);
|
|
58
|
-
generate(prompt: string, options?: LLMGenerateOptions, streamCallbacks?: LLMStreamCallbacks): Promise<string>;
|
|
59
|
-
private readStream;
|
|
60
|
-
generateWithImage(prompt: string, imageBase64: string, _mimeType: string, options?: LLMGenerateOptions): Promise<string>;
|
|
61
|
-
testConnection(): Promise<boolean>;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Generic OpenAI-compatible provider. Works with any service that implements
|
|
65
|
-
* the OpenAI /v1/chat/completions API: OpenAI, Groq, LM Studio, etc.
|
|
66
|
-
*/
|
|
67
|
-
export declare class OpenAICompatibleProvider implements LLMProvider {
|
|
68
|
-
readonly name: LLMProviderName;
|
|
69
|
-
readonly model: string;
|
|
70
|
-
private baseUrl;
|
|
71
|
-
private apiKey;
|
|
72
|
-
private config;
|
|
73
|
-
constructor(name: LLMProviderName, model: string, baseUrl: string, apiKey: string, config?: GnosysConfig);
|
|
74
|
-
generate(prompt: string, options?: LLMGenerateOptions, streamCallbacks?: LLMStreamCallbacks): Promise<string>;
|
|
75
|
-
private readSSEStream;
|
|
76
|
-
generateWithImage(prompt: string, imageBase64: string, mimeType: string, options?: LLMGenerateOptions): Promise<string>;
|
|
77
|
-
testConnection(): Promise<boolean>;
|
|
78
|
-
}
|
|
79
40
|
/**
|
|
80
41
|
* Create an LLM provider for a specific task.
|
|
81
42
|
* Resolves provider + model from config's taskModels or defaultProvider.
|
|
@@ -93,4 +54,4 @@ export declare function isProviderAvailable(config: GnosysConfig, provider?: LLM
|
|
|
93
54
|
available: boolean;
|
|
94
55
|
error?: string;
|
|
95
56
|
};
|
|
96
|
-
|
|
57
|
+
export {};
|
package/dist/lib/llm.js
CHANGED
|
@@ -5,8 +5,20 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { DEFAULT_CONFIG, resolveTaskModel, getAnthropicApiKey, getOllamaBaseUrl, getGroqApiKey, getOpenAIApiKey, getOpenAIBaseUrl, getLMStudioBaseUrl, getXAIApiKey, getMistralApiKey, getCustomApiKey, getProviderModel, ALL_PROVIDERS, } from "./config.js";
|
|
7
7
|
import { withRetry, isTransientError } from "./retry.js";
|
|
8
|
+
/** Per-request timeout for LLM generation calls (ms). */
|
|
9
|
+
const LLM_TIMEOUT_MS = 60_000;
|
|
10
|
+
/** Shorter timeout for connectivity probes (testConnection, model lists). */
|
|
11
|
+
const PROBE_TIMEOUT_MS = 10_000;
|
|
12
|
+
/** Strip literal API keys and known key-prefix patterns from provider error text. */
|
|
13
|
+
export function redactKey(text, apiKey) {
|
|
14
|
+
let out = text;
|
|
15
|
+
if (apiKey && apiKey.length >= 8) {
|
|
16
|
+
out = out.split(apiKey).join("***");
|
|
17
|
+
}
|
|
18
|
+
return out.replace(/(?:sk-ant-|sk-|gsk_|xai-|Bearer\s+)[^\s"']+/g, "***");
|
|
19
|
+
}
|
|
8
20
|
// ─── Anthropic Provider ──────────────────────────────────────────────────
|
|
9
|
-
|
|
21
|
+
class AnthropicProvider {
|
|
10
22
|
name = "anthropic";
|
|
11
23
|
model;
|
|
12
24
|
client = null; // Anthropic SDK client (lazy-initialized)
|
|
@@ -24,7 +36,7 @@ export class AnthropicProvider {
|
|
|
24
36
|
if (!this.clientPromise) {
|
|
25
37
|
this.clientPromise = import("@anthropic-ai/sdk").then((mod) => {
|
|
26
38
|
const Anthropic = mod.default || mod;
|
|
27
|
-
this.client = new Anthropic({ apiKey: this.apiKey });
|
|
39
|
+
this.client = new Anthropic({ apiKey: this.apiKey, timeout: LLM_TIMEOUT_MS });
|
|
28
40
|
return this.client;
|
|
29
41
|
});
|
|
30
42
|
}
|
|
@@ -111,12 +123,12 @@ export class AnthropicProvider {
|
|
|
111
123
|
catch (err) {
|
|
112
124
|
// Sanitize error message to prevent API key leakage
|
|
113
125
|
const msg = err instanceof Error ? err.message : String(err);
|
|
114
|
-
throw new Error(`Anthropic connection failed: ${msg
|
|
126
|
+
throw new Error(`Anthropic connection failed: ${redactKey(msg, this.apiKey)}`);
|
|
115
127
|
}
|
|
116
128
|
}
|
|
117
129
|
}
|
|
118
130
|
// ─── Ollama Provider ─────────────────────────────────────────────────────
|
|
119
|
-
|
|
131
|
+
class OllamaProvider {
|
|
120
132
|
name = "ollama";
|
|
121
133
|
model;
|
|
122
134
|
baseUrl;
|
|
@@ -147,6 +159,7 @@ export class OllamaProvider {
|
|
|
147
159
|
method: "POST",
|
|
148
160
|
headers: { "Content-Type": "application/json" },
|
|
149
161
|
body: JSON.stringify(body),
|
|
162
|
+
signal: AbortSignal.timeout(LLM_TIMEOUT_MS),
|
|
150
163
|
}), {
|
|
151
164
|
maxAttempts: this.config.llmRetryAttempts,
|
|
152
165
|
baseDelayMs: this.config.llmRetryBaseDelayMs,
|
|
@@ -211,6 +224,7 @@ export class OllamaProvider {
|
|
|
211
224
|
method: "POST",
|
|
212
225
|
headers: { "Content-Type": "application/json" },
|
|
213
226
|
body: JSON.stringify(body),
|
|
227
|
+
signal: AbortSignal.timeout(LLM_TIMEOUT_MS),
|
|
214
228
|
}), {
|
|
215
229
|
maxAttempts: this.config.llmRetryAttempts,
|
|
216
230
|
baseDelayMs: this.config.llmRetryBaseDelayMs,
|
|
@@ -225,7 +239,9 @@ export class OllamaProvider {
|
|
|
225
239
|
}
|
|
226
240
|
async testConnection() {
|
|
227
241
|
try {
|
|
228
|
-
const response = await fetch(`${this.baseUrl}/api/tags
|
|
242
|
+
const response = await fetch(`${this.baseUrl}/api/tags`, {
|
|
243
|
+
signal: AbortSignal.timeout(PROBE_TIMEOUT_MS),
|
|
244
|
+
});
|
|
229
245
|
if (!response.ok) {
|
|
230
246
|
throw new Error(`HTTP ${response.status}`);
|
|
231
247
|
}
|
|
@@ -257,7 +273,7 @@ export class OllamaProvider {
|
|
|
257
273
|
* Generic OpenAI-compatible provider. Works with any service that implements
|
|
258
274
|
* the OpenAI /v1/chat/completions API: OpenAI, Groq, LM Studio, etc.
|
|
259
275
|
*/
|
|
260
|
-
|
|
276
|
+
class OpenAICompatibleProvider {
|
|
261
277
|
name;
|
|
262
278
|
model;
|
|
263
279
|
baseUrl;
|
|
@@ -291,6 +307,7 @@ export class OpenAICompatibleProvider {
|
|
|
291
307
|
...(this.apiKey ? { Authorization: `Bearer ${this.apiKey}` } : {}),
|
|
292
308
|
},
|
|
293
309
|
body: JSON.stringify(body),
|
|
310
|
+
signal: AbortSignal.timeout(LLM_TIMEOUT_MS),
|
|
294
311
|
}), {
|
|
295
312
|
maxAttempts: this.config.llmRetryAttempts,
|
|
296
313
|
baseDelayMs: this.config.llmRetryBaseDelayMs,
|
|
@@ -299,7 +316,7 @@ export class OpenAICompatibleProvider {
|
|
|
299
316
|
if (!response.ok) {
|
|
300
317
|
const errorText = await response.text();
|
|
301
318
|
// Sanitize error text to prevent API key leakage
|
|
302
|
-
const safeText = errorText
|
|
319
|
+
const safeText = redactKey(errorText, this.apiKey);
|
|
303
320
|
throw new Error(`${this.name} request failed (${response.status}): ${safeText}`);
|
|
304
321
|
}
|
|
305
322
|
if (shouldStream && streamCallbacks) {
|
|
@@ -368,6 +385,7 @@ export class OpenAICompatibleProvider {
|
|
|
368
385
|
messages,
|
|
369
386
|
max_tokens: maxTokens,
|
|
370
387
|
}),
|
|
388
|
+
signal: AbortSignal.timeout(LLM_TIMEOUT_MS),
|
|
371
389
|
}), {
|
|
372
390
|
maxAttempts: this.config.llmRetryAttempts,
|
|
373
391
|
baseDelayMs: this.config.llmRetryBaseDelayMs,
|
|
@@ -375,7 +393,7 @@ export class OpenAICompatibleProvider {
|
|
|
375
393
|
});
|
|
376
394
|
if (!response.ok) {
|
|
377
395
|
const errorText = await response.text();
|
|
378
|
-
const safeText = errorText
|
|
396
|
+
const safeText = redactKey(errorText, this.apiKey);
|
|
379
397
|
throw new Error(`${this.name} vision request failed (${response.status}): ${safeText}`);
|
|
380
398
|
}
|
|
381
399
|
const data = (await response.json());
|
|
@@ -387,6 +405,7 @@ export class OpenAICompatibleProvider {
|
|
|
387
405
|
headers: {
|
|
388
406
|
...(this.apiKey ? { Authorization: `Bearer ${this.apiKey}` } : {}),
|
|
389
407
|
},
|
|
408
|
+
signal: AbortSignal.timeout(PROBE_TIMEOUT_MS),
|
|
390
409
|
});
|
|
391
410
|
if (!response.ok) {
|
|
392
411
|
throw new Error(`HTTP ${response.status}`);
|
|
@@ -550,4 +569,3 @@ export function isProviderAvailable(config, provider) {
|
|
|
550
569
|
return { available: false, error: `Unknown provider: ${target}` };
|
|
551
570
|
}
|
|
552
571
|
}
|
|
553
|
-
//# sourceMappingURL=llm.js.map
|
package/dist/lib/lock.d.ts
CHANGED
package/dist/lib/lock.js
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function logError(err: unknown, ctx?: object): void;
|
|
2
|
+
export declare function logWarn(message: string, ctx?: object): void;
|
|
3
|
+
export declare function logInfo(message: string, ctx?: object): void;
|
|
4
|
+
export declare function logDebug(message: string, ctx?: object): void;
|
package/dist/lib/log.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
const LEVEL_ORDER = {
|
|
3
|
+
debug: 10,
|
|
4
|
+
info: 20,
|
|
5
|
+
warn: 30,
|
|
6
|
+
error: 40,
|
|
7
|
+
};
|
|
8
|
+
function configuredLevel() {
|
|
9
|
+
const raw = (process.env.GNOSYS_LOG_LEVEL || "info").toLowerCase();
|
|
10
|
+
if (raw === "debug" || raw === "info" || raw === "warn" || raw === "error")
|
|
11
|
+
return raw;
|
|
12
|
+
return "info";
|
|
13
|
+
}
|
|
14
|
+
function shouldEmit(level) {
|
|
15
|
+
return LEVEL_ORDER[level] >= LEVEL_ORDER[configuredLevel()];
|
|
16
|
+
}
|
|
17
|
+
function normalizeError(err) {
|
|
18
|
+
return err instanceof Error ? err : new Error(String(err));
|
|
19
|
+
}
|
|
20
|
+
function buildRecord(level, message, err, ctx) {
|
|
21
|
+
const record = {
|
|
22
|
+
timestamp: new Date().toISOString(),
|
|
23
|
+
level,
|
|
24
|
+
message,
|
|
25
|
+
...(ctx ?? {}),
|
|
26
|
+
};
|
|
27
|
+
if (err) {
|
|
28
|
+
record.error = {
|
|
29
|
+
name: err.name,
|
|
30
|
+
message: err.message,
|
|
31
|
+
stack: err.stack,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return record;
|
|
35
|
+
}
|
|
36
|
+
function formatText(level, message, err) {
|
|
37
|
+
const prefix = level === "error"
|
|
38
|
+
? message.startsWith("gnosys:")
|
|
39
|
+
? message
|
|
40
|
+
: `gnosys: ${message}`
|
|
41
|
+
: `gnosys: ${level}: ${message}`;
|
|
42
|
+
if (err?.stack && level === "error") {
|
|
43
|
+
return `${prefix}\n${err.stack}\n`;
|
|
44
|
+
}
|
|
45
|
+
return `${prefix}\n`;
|
|
46
|
+
}
|
|
47
|
+
function writeJsonLine(line) {
|
|
48
|
+
const logFile = process.env.GNOSYS_LOG_FILE;
|
|
49
|
+
if (logFile) {
|
|
50
|
+
fs.appendFileSync(logFile, line, "utf8");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function emit(level, message, err, ctx) {
|
|
54
|
+
if (!shouldEmit(level))
|
|
55
|
+
return;
|
|
56
|
+
try {
|
|
57
|
+
const jsonLine = `${JSON.stringify(buildRecord(level, message, err, ctx))}\n`;
|
|
58
|
+
const useJson = process.env.GNOSYS_LOG_FORMAT === "json";
|
|
59
|
+
if (useJson) {
|
|
60
|
+
process.stderr.write(jsonLine);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
process.stderr.write(formatText(level, message, err));
|
|
64
|
+
}
|
|
65
|
+
if (process.env.GNOSYS_LOG_FILE) {
|
|
66
|
+
writeJsonLine(jsonLine);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// Best-effort logging must never throw.
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export function logError(err, ctx) {
|
|
74
|
+
const error = normalizeError(err);
|
|
75
|
+
emit("error", error.message, error, ctx);
|
|
76
|
+
}
|
|
77
|
+
export function logWarn(message, ctx) {
|
|
78
|
+
emit("warn", message, undefined, ctx);
|
|
79
|
+
}
|
|
80
|
+
export function logInfo(message, ctx) {
|
|
81
|
+
emit("info", message, undefined, ctx);
|
|
82
|
+
}
|
|
83
|
+
export function logDebug(message, ctx) {
|
|
84
|
+
emit("debug", message, undefined, ctx);
|
|
85
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Machine-local configuration — `~/.config/gnosys/machine.json`.
|
|
3
|
+
*
|
|
4
|
+
* This is the single home for everything specific to THIS physical machine,
|
|
5
|
+
* and it must NEVER be synced to the shared brain or to other machines:
|
|
6
|
+
*
|
|
7
|
+
* - `machineId` — a stable random UUID identifying this machine. Used to
|
|
8
|
+
* key per-machine rows (e.g. project_locations) so two
|
|
9
|
+
* machines never clobber each other's data.
|
|
10
|
+
* - `roots` — named project roots whose ABSOLUTE paths differ per
|
|
11
|
+
* machine (e.g. { dev: "/Users/edward/MSDev/projects" } on
|
|
12
|
+
* the Studio, "/Users/edward/MBPDev/projects" on the MBP).
|
|
13
|
+
* A project stores a machine-INDEPENDENT `rel_path` + the
|
|
14
|
+
* `root_id`; its absolute path is reconstructed at runtime.
|
|
15
|
+
* - `remote` — the per-machine remote-sync connection (NAS mount path on
|
|
16
|
+
* one machine, a Tailscale URL on another). Previously this
|
|
17
|
+
* lived in the synced `gnosys_meta` table, which is itself
|
|
18
|
+
* the multi-machine bug in miniature — every machine
|
|
19
|
+
* overwrote the others' value.
|
|
20
|
+
*
|
|
21
|
+
* The central DB at `~/.gnosys/gnosys.db` is the synced source of truth;
|
|
22
|
+
* machine.json is its machine-local counterpart. Resolution of a project's
|
|
23
|
+
* absolute path on a given machine is: `join(roots[root_id], rel_path)` (or a
|
|
24
|
+
* per-machine override row for projects that live outside any root).
|
|
25
|
+
*/
|
|
26
|
+
interface MachineRemoteConfig {
|
|
27
|
+
/** Whether remote sync is configured/active on this machine. */
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
/** Absolute path or URL to the remote DB on this machine (NAS mount / Tailscale). */
|
|
30
|
+
path?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface MachineConfig {
|
|
33
|
+
/** Stable random UUID for this machine. Never shared/synced. */
|
|
34
|
+
machineId: string;
|
|
35
|
+
/** os.hostname() at write time — used to detect a synced-in foreign file. */
|
|
36
|
+
hostname: string;
|
|
37
|
+
/** Named root → absolute path on THIS machine. */
|
|
38
|
+
roots: Record<string, string>;
|
|
39
|
+
/** Per-machine remote-sync connection. */
|
|
40
|
+
remote: MachineRemoteConfig;
|
|
41
|
+
schemaVersion: number;
|
|
42
|
+
}
|
|
43
|
+
/** A fresh machine config for the current host. */
|
|
44
|
+
export declare function defaultMachineConfig(): MachineConfig;
|
|
45
|
+
/** Read machine.json, or null if it doesn't exist / is unreadable. */
|
|
46
|
+
export declare function readMachineConfig(): MachineConfig | null;
|
|
47
|
+
/** Persist machine.json (creates the config dir if needed). */
|
|
48
|
+
export declare function writeMachineConfig(cfg: MachineConfig): void;
|
|
49
|
+
export interface EnsureResult {
|
|
50
|
+
config: MachineConfig;
|
|
51
|
+
/** True if a new config was created on disk. */
|
|
52
|
+
created: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* True if the existing config's hostname did not match the current host —
|
|
55
|
+
* a strong signal it was synced in from another machine, so machineId was
|
|
56
|
+
* regenerated to keep machine identities distinct.
|
|
57
|
+
*/
|
|
58
|
+
regenerated: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Load machine.json, creating it on first run. If the persisted config's
|
|
62
|
+
* hostname does not match the current host, it was almost certainly synced in
|
|
63
|
+
* from another machine by mistake; regenerate `machineId` and refresh
|
|
64
|
+
* `hostname` so two machines never share an identity. Named roots and the
|
|
65
|
+
* remote block are preserved (a benign hostname rename keeps them valid; a
|
|
66
|
+
* genuine foreign file gets corrected when the user re-runs `projects scan`).
|
|
67
|
+
*/
|
|
68
|
+
export declare function ensureMachineConfig(): EnsureResult;
|
|
69
|
+
/** Convenience: this machine's stable id (creating machine.json if needed). */
|
|
70
|
+
export declare function getMachineId(): string;
|
|
71
|
+
/**
|
|
72
|
+
* Reconstruct an absolute path on this machine from a (root_id, rel_path)
|
|
73
|
+
* pair, using the machine's named roots. Returns null when the root is not
|
|
74
|
+
* configured on this machine (i.e. the project is "not on this machine").
|
|
75
|
+
*/
|
|
76
|
+
export declare function absPathFromRoot(cfg: MachineConfig, rootId: string | null | undefined, relPath: string | null | undefined): string | null;
|
|
77
|
+
/**
|
|
78
|
+
* Given an absolute path on this machine, find the named root that contains
|
|
79
|
+
* it and return { rootId, relPath }. Picks the deepest (most specific) root
|
|
80
|
+
* when several match. Returns null when no configured root contains the path.
|
|
81
|
+
*/
|
|
82
|
+
export declare function relPathUnderRoot(cfg: MachineConfig, absPath: string): {
|
|
83
|
+
rootId: string;
|
|
84
|
+
relPath: string;
|
|
85
|
+
} | null;
|
|
86
|
+
export {};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Machine-local configuration — `~/.config/gnosys/machine.json`.
|
|
3
|
+
*
|
|
4
|
+
* This is the single home for everything specific to THIS physical machine,
|
|
5
|
+
* and it must NEVER be synced to the shared brain or to other machines:
|
|
6
|
+
*
|
|
7
|
+
* - `machineId` — a stable random UUID identifying this machine. Used to
|
|
8
|
+
* key per-machine rows (e.g. project_locations) so two
|
|
9
|
+
* machines never clobber each other's data.
|
|
10
|
+
* - `roots` — named project roots whose ABSOLUTE paths differ per
|
|
11
|
+
* machine (e.g. { dev: "/Users/edward/MSDev/projects" } on
|
|
12
|
+
* the Studio, "/Users/edward/MBPDev/projects" on the MBP).
|
|
13
|
+
* A project stores a machine-INDEPENDENT `rel_path` + the
|
|
14
|
+
* `root_id`; its absolute path is reconstructed at runtime.
|
|
15
|
+
* - `remote` — the per-machine remote-sync connection (NAS mount path on
|
|
16
|
+
* one machine, a Tailscale URL on another). Previously this
|
|
17
|
+
* lived in the synced `gnosys_meta` table, which is itself
|
|
18
|
+
* the multi-machine bug in miniature — every machine
|
|
19
|
+
* overwrote the others' value.
|
|
20
|
+
*
|
|
21
|
+
* The central DB at `~/.gnosys/gnosys.db` is the synced source of truth;
|
|
22
|
+
* machine.json is its machine-local counterpart. Resolution of a project's
|
|
23
|
+
* absolute path on a given machine is: `join(roots[root_id], rel_path)` (or a
|
|
24
|
+
* per-machine override row for projects that live outside any root).
|
|
25
|
+
*/
|
|
26
|
+
import fs from "fs";
|
|
27
|
+
import os from "os";
|
|
28
|
+
import path from "path";
|
|
29
|
+
import { randomUUID } from "crypto";
|
|
30
|
+
import { getMachineConfigPath } from "./paths.js";
|
|
31
|
+
import { atomicWriteFileSync } from "./atomicWrite.js";
|
|
32
|
+
const MACHINE_CONFIG_VERSION = 1;
|
|
33
|
+
/** A fresh machine config for the current host. */
|
|
34
|
+
export function defaultMachineConfig() {
|
|
35
|
+
return {
|
|
36
|
+
machineId: randomUUID(),
|
|
37
|
+
hostname: os.hostname(),
|
|
38
|
+
roots: {},
|
|
39
|
+
remote: { enabled: false },
|
|
40
|
+
schemaVersion: MACHINE_CONFIG_VERSION,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Coerce an arbitrary parsed object into a well-formed MachineConfig. */
|
|
44
|
+
function normalize(parsed) {
|
|
45
|
+
const base = defaultMachineConfig();
|
|
46
|
+
if (!parsed || typeof parsed !== "object")
|
|
47
|
+
return base;
|
|
48
|
+
const roots = {};
|
|
49
|
+
if (parsed.roots && typeof parsed.roots === "object") {
|
|
50
|
+
for (const [k, v] of Object.entries(parsed.roots)) {
|
|
51
|
+
if (typeof v === "string" && v.length > 0)
|
|
52
|
+
roots[k] = path.resolve(v);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const remote = {
|
|
56
|
+
enabled: Boolean(parsed.remote?.enabled),
|
|
57
|
+
...(typeof parsed.remote?.path === "string" ? { path: parsed.remote.path } : {}),
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
machineId: typeof parsed.machineId === "string" && parsed.machineId ? parsed.machineId : base.machineId,
|
|
61
|
+
hostname: typeof parsed.hostname === "string" && parsed.hostname ? parsed.hostname : base.hostname,
|
|
62
|
+
roots,
|
|
63
|
+
remote,
|
|
64
|
+
schemaVersion: typeof parsed.schemaVersion === "number" ? parsed.schemaVersion : MACHINE_CONFIG_VERSION,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** Read machine.json, or null if it doesn't exist / is unreadable. */
|
|
68
|
+
export function readMachineConfig() {
|
|
69
|
+
try {
|
|
70
|
+
const raw = fs.readFileSync(getMachineConfigPath(), "utf-8");
|
|
71
|
+
return normalize(JSON.parse(raw));
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** Persist machine.json (creates the config dir if needed). */
|
|
78
|
+
export function writeMachineConfig(cfg) {
|
|
79
|
+
const p = getMachineConfigPath();
|
|
80
|
+
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
81
|
+
atomicWriteFileSync(p, JSON.stringify(cfg, null, 2) + "\n");
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Load machine.json, creating it on first run. If the persisted config's
|
|
85
|
+
* hostname does not match the current host, it was almost certainly synced in
|
|
86
|
+
* from another machine by mistake; regenerate `machineId` and refresh
|
|
87
|
+
* `hostname` so two machines never share an identity. Named roots and the
|
|
88
|
+
* remote block are preserved (a benign hostname rename keeps them valid; a
|
|
89
|
+
* genuine foreign file gets corrected when the user re-runs `projects scan`).
|
|
90
|
+
*/
|
|
91
|
+
export function ensureMachineConfig() {
|
|
92
|
+
const override = process.env.GNOSYS_MACHINE_ID?.trim();
|
|
93
|
+
const existing = readMachineConfig();
|
|
94
|
+
const host = os.hostname();
|
|
95
|
+
if (override) {
|
|
96
|
+
const base = existing ?? defaultMachineConfig();
|
|
97
|
+
const cfg = {
|
|
98
|
+
...base,
|
|
99
|
+
machineId: override,
|
|
100
|
+
hostname: host,
|
|
101
|
+
};
|
|
102
|
+
writeMachineConfig(cfg);
|
|
103
|
+
return { config: cfg, created: !existing, regenerated: false };
|
|
104
|
+
}
|
|
105
|
+
if (!existing) {
|
|
106
|
+
const fresh = defaultMachineConfig();
|
|
107
|
+
writeMachineConfig(fresh);
|
|
108
|
+
return { config: fresh, created: true, regenerated: false };
|
|
109
|
+
}
|
|
110
|
+
if (existing.hostname !== host) {
|
|
111
|
+
const regenerated = {
|
|
112
|
+
...existing,
|
|
113
|
+
machineId: randomUUID(),
|
|
114
|
+
hostname: host,
|
|
115
|
+
};
|
|
116
|
+
writeMachineConfig(regenerated);
|
|
117
|
+
return { config: regenerated, created: false, regenerated: true };
|
|
118
|
+
}
|
|
119
|
+
return { config: existing, created: false, regenerated: false };
|
|
120
|
+
}
|
|
121
|
+
/** Convenience: this machine's stable id (creating machine.json if needed). */
|
|
122
|
+
export function getMachineId() {
|
|
123
|
+
return ensureMachineConfig().config.machineId;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Reconstruct an absolute path on this machine from a (root_id, rel_path)
|
|
127
|
+
* pair, using the machine's named roots. Returns null when the root is not
|
|
128
|
+
* configured on this machine (i.e. the project is "not on this machine").
|
|
129
|
+
*/
|
|
130
|
+
export function absPathFromRoot(cfg, rootId, relPath) {
|
|
131
|
+
if (!rootId || !relPath)
|
|
132
|
+
return null;
|
|
133
|
+
const root = cfg.roots[rootId];
|
|
134
|
+
if (!root)
|
|
135
|
+
return null;
|
|
136
|
+
return path.join(root, relPath);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Given an absolute path on this machine, find the named root that contains
|
|
140
|
+
* it and return { rootId, relPath }. Picks the deepest (most specific) root
|
|
141
|
+
* when several match. Returns null when no configured root contains the path.
|
|
142
|
+
*/
|
|
143
|
+
export function relPathUnderRoot(cfg, absPath) {
|
|
144
|
+
const target = path.resolve(absPath);
|
|
145
|
+
let best = null;
|
|
146
|
+
for (const [rootId, rootPath] of Object.entries(cfg.roots)) {
|
|
147
|
+
const root = path.resolve(rootPath);
|
|
148
|
+
const rel = path.relative(root, target);
|
|
149
|
+
// Inside the root iff rel doesn't escape upward and isn't absolute.
|
|
150
|
+
if (rel && !rel.startsWith("..") && !path.isAbsolute(rel)) {
|
|
151
|
+
if (!best || root.length > best.rootLen) {
|
|
152
|
+
best = { rootId, relPath: rel, rootLen: root.length };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return best ? { rootId: best.rootId, relPath: best.relPath } : null;
|
|
157
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v5.11 one-time migration to machine-portable project paths.
|
|
3
|
+
*
|
|
4
|
+
* Run once per machine. It:
|
|
5
|
+
* 1. Ensures machine.json exists (machineId, hostname).
|
|
6
|
+
* 2. Adopts machine-LOCAL values that were wrongly living in the SYNCED
|
|
7
|
+
* gnosys_meta — `machine_id` (for continuity) and `remote_path` — into
|
|
8
|
+
* machine.json, then deletes them from meta so they stop syncing and
|
|
9
|
+
* clobbering other machines.
|
|
10
|
+
* 3. Sets the `dev` root (explicit --root, else derived from the registry).
|
|
11
|
+
* 4. Scans to backfill machine-independent root_id/rel_path on projects.
|
|
12
|
+
*
|
|
13
|
+
* It operates on the LOCAL DB (GnosysDB.openLocal), never a remote, because it
|
|
14
|
+
* moves machine-local state out of the shared store.
|
|
15
|
+
*/
|
|
16
|
+
import type { GnosysDB } from "./db.js";
|
|
17
|
+
import { type ScanResult } from "./projectScan.js";
|
|
18
|
+
export interface MigrateResult {
|
|
19
|
+
machineId: string;
|
|
20
|
+
hostname: string;
|
|
21
|
+
rootsConfigured: Record<string, string>;
|
|
22
|
+
adoptedMachineId: boolean;
|
|
23
|
+
adoptedRemotePath: boolean;
|
|
24
|
+
regeneratedMachineId: boolean;
|
|
25
|
+
scan?: ScanResult;
|
|
26
|
+
}
|
|
27
|
+
export declare function migrateMachine(localDb: GnosysDB, opts?: {
|
|
28
|
+
root?: string;
|
|
29
|
+
rootName?: string;
|
|
30
|
+
scan?: boolean;
|
|
31
|
+
}): Promise<MigrateResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Derive the most likely `dev` root: the directory that is the parent of the
|
|
34
|
+
* most registered projects. Picking the most-common parent (rather than the
|
|
35
|
+
* global common prefix) avoids collapsing to `/Users/<name>` when a few
|
|
36
|
+
* outlier projects live elsewhere.
|
|
37
|
+
*/
|
|
38
|
+
export declare function deriveCommonRoot(): string | null;
|