@tyvm/knowhow 0.0.1
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/.vscode/launch.json +14 -0
- package/CONFIG.md +336 -0
- package/README.md +49 -0
- package/autodoc/chat.mdx +20 -0
- package/autodoc/cli.mdx +11 -0
- package/autodoc/plugins/asana.mdx +47 -0
- package/autodoc/plugins/downloader/downloader.mdx +38 -0
- package/autodoc/plugins/downloader/plugin.mdx +37 -0
- package/autodoc/plugins/downloader/types.mdx +42 -0
- package/autodoc/plugins/embedding.mdx +41 -0
- package/autodoc/plugins/figma.mdx +45 -0
- package/autodoc/plugins/github.mdx +40 -0
- package/autodoc/plugins/jira.mdx +46 -0
- package/autodoc/plugins/language.mdx +37 -0
- package/autodoc/plugins/linear.mdx +35 -0
- package/autodoc/plugins/notion.mdx +38 -0
- package/autodoc/plugins/plugins.mdx +59 -0
- package/autodoc/plugins/types.mdx +51 -0
- package/autodoc/plugins/vim.mdx +39 -0
- package/autodoc/tools/addInternalTools.mdx +1 -0
- package/autodoc/tools/agentCall.mdx +1 -0
- package/autodoc/tools/asana/definitions.mdx +10 -0
- package/autodoc/tools/asana/index.mdx +12 -0
- package/autodoc/tools/askHuman.mdx +1 -0
- package/autodoc/tools/callPlugin.mdx +1 -0
- package/autodoc/tools/embeddingSearch.mdx +1 -0
- package/autodoc/tools/execCommand.mdx +1 -0
- package/autodoc/tools/fileSearch.mdx +1 -0
- package/autodoc/tools/finalAnswer.mdx +1 -0
- package/autodoc/tools/github/definitions.mdx +6 -0
- package/autodoc/tools/github/index.mdx +8 -0
- package/autodoc/tools/index.mdx +14 -0
- package/autodoc/tools/lintFile.mdx +7 -0
- package/autodoc/tools/list.mdx +16 -0
- package/autodoc/tools/modifyFile.mdx +7 -0
- package/autodoc/tools/patch.mdx +9 -0
- package/autodoc/tools/readBlocks.mdx +1 -0
- package/autodoc/tools/readFile.mdx +1 -0
- package/autodoc/tools/scanFile.mdx +1 -0
- package/autodoc/tools/textSearch.mdx +6 -0
- package/autodoc/tools/types/fileblock.mdx +1 -0
- package/autodoc/tools/visionTool.mdx +1 -0
- package/autodoc/tools/writeFile.mdx +1 -0
- package/jest.config.js +18 -0
- package/package.json +89 -0
- package/src/agents/base/base.ts +619 -0
- package/src/agents/base/prompt.ts +26 -0
- package/src/agents/configurable/ConfigAgent.ts +23 -0
- package/src/agents/developer/developer.ts +69 -0
- package/src/agents/index.ts +8 -0
- package/src/agents/interface.ts +11 -0
- package/src/agents/patcher/codebase.md +27 -0
- package/src/agents/patcher/patcher.ts +110 -0
- package/src/agents/researcher/researcher.ts +109 -0
- package/src/agents/tools/addInternalTools.ts +21 -0
- package/src/agents/tools/agentCall.ts +18 -0
- package/src/agents/tools/aiClient.ts +36 -0
- package/src/agents/tools/asana/definitions.ts +199 -0
- package/src/agents/tools/asana/index.ts +108 -0
- package/src/agents/tools/askHuman.ts +8 -0
- package/src/agents/tools/callPlugin.ts +4 -0
- package/src/agents/tools/embeddingSearch.ts +5 -0
- package/src/agents/tools/execCommand.ts +26 -0
- package/src/agents/tools/fileSearch.ts +33 -0
- package/src/agents/tools/finalAnswer.ts +4 -0
- package/src/agents/tools/github/definitions.ts +89 -0
- package/src/agents/tools/github/index.ts +67 -0
- package/src/agents/tools/googleSearch.ts +242 -0
- package/src/agents/tools/index.ts +24 -0
- package/src/agents/tools/language/definitions.ts +97 -0
- package/src/agents/tools/language/index.ts +19 -0
- package/src/agents/tools/lintFile.ts +17 -0
- package/src/agents/tools/list.ts +514 -0
- package/src/agents/tools/loadWebpage.ts +129 -0
- package/src/agents/tools/modifyFile.ts +53 -0
- package/src/agents/tools/patch.ts +672 -0
- package/src/agents/tools/readBlocks.ts +41 -0
- package/src/agents/tools/readFile.ts +39 -0
- package/src/agents/tools/scanFile.ts +16 -0
- package/src/agents/tools/textSearch.ts +21 -0
- package/src/agents/tools/types/fileblock.ts +5 -0
- package/src/agents/tools/visionTool.ts +5 -0
- package/src/agents/tools/writeFile.ts +46 -0
- package/src/agents/vim/vim.ts +153 -0
- package/src/ai.ts +167 -0
- package/src/chat.ts +412 -0
- package/src/cli.ts +85 -0
- package/src/clients/anthropic.ts +399 -0
- package/src/clients/gemini.ts +486 -0
- package/src/clients/http.ts +107 -0
- package/src/clients/index.ts +183 -0
- package/src/clients/knowhow.ts +33 -0
- package/src/clients/openai.ts +253 -0
- package/src/clients/types.ts +91 -0
- package/src/clients/xai.ts +132 -0
- package/src/config.ts +211 -0
- package/src/conversion.ts +140 -0
- package/src/dataset/diffs/README.md +12 -0
- package/src/dataset/diffs/debug-errors.ts +29 -0
- package/src/dataset/diffs/debug.ts +64 -0
- package/src/dataset/diffs/generate.ts +71 -0
- package/src/dataset/diffs/jsonl.ts +54 -0
- package/src/dataset/diffs/test.ts +193 -0
- package/src/embeddings.ts +411 -0
- package/src/hashes.ts +67 -0
- package/src/index.ts +376 -0
- package/src/login.ts +78 -0
- package/src/microphone.ts +136 -0
- package/src/modules/index.ts +37 -0
- package/src/modules/types.ts +48 -0
- package/src/plugins/asana.ts +134 -0
- package/src/plugins/downloader/downloader.ts +204 -0
- package/src/plugins/downloader/plugin.ts +85 -0
- package/src/plugins/downloader/types.ts +85 -0
- package/src/plugins/embedding.ts +42 -0
- package/src/plugins/figma.ts +137 -0
- package/src/plugins/github.ts +153 -0
- package/src/plugins/jira.ts +104 -0
- package/src/plugins/language.ts +100 -0
- package/src/plugins/linear.ts +219 -0
- package/src/plugins/notion.ts +170 -0
- package/src/plugins/plugins.ts +56 -0
- package/src/plugins/types.ts +5 -0
- package/src/plugins/url.ts +63 -0
- package/src/plugins/vim.ts +73 -0
- package/src/prompts/BasicCodeDocumenter.ts +1 -0
- package/src/prompts/BasicProjectDocumenter.ts +1 -0
- package/src/prompts/EmbeddingSeachHelper.ts +1 -0
- package/src/prompts/index.ts +9 -0
- package/src/server/index.ts +14 -0
- package/src/services/AgentService.ts +98 -0
- package/src/services/EmbeddingService.ts +410 -0
- package/src/services/EventService.ts +20 -0
- package/src/services/GitHub.ts +60 -0
- package/src/services/KnowhowClient.ts +113 -0
- package/src/services/Mcp.ts +270 -0
- package/src/services/McpServer.ts +119 -0
- package/src/services/McpWebsocketTransport.ts +64 -0
- package/src/services/S3.ts +126 -0
- package/src/services/Tools.ts +65 -0
- package/src/services/flags.ts +52 -0
- package/src/services/index.ts +8 -0
- package/src/types.ts +225 -0
- package/src/utils/index.ts +108 -0
- package/src/worker.ts +80 -0
- package/tests/integration/figma.test.ts +70 -0
- package/tests/integration/fileblocks/readwrite.test.ts +95 -0
- package/tests/integration/patching/input.txt +145 -0
- package/tests/integration/patching/output.txt +145 -0
- package/tests/integration/patching/patch.txt +15 -0
- package/tests/integration/patching/unseen.txt +80 -0
- package/tests/integration/patching.test.ts +136 -0
- package/tests/languagePlugin.test.ts +74 -0
- package/tests/patching/corrupted.test.ts +78 -0
- package/tests/patching/imports.patch.txt +11 -0
- package/tests/patching/imports.test.ts +43 -0
- package/tests/patching/imports.txt +11 -0
- package/tests/patching/interface.patch.txt +15 -0
- package/tests/patching/interface.txt +7 -0
- package/tests/test.spec.ts +132 -0
- package/ts_build/src/agents/base/base.d.ts +88 -0
- package/ts_build/src/agents/base/base.js +464 -0
- package/ts_build/src/agents/base/base.js.map +1 -0
- package/ts_build/src/agents/base/prompt.d.ts +1 -0
- package/ts_build/src/agents/base/prompt.js +30 -0
- package/ts_build/src/agents/base/prompt.js.map +1 -0
- package/ts_build/src/agents/configurable/ConfigAgent.d.ts +10 -0
- package/ts_build/src/agents/configurable/ConfigAgent.js +25 -0
- package/ts_build/src/agents/configurable/ConfigAgent.js.map +1 -0
- package/ts_build/src/agents/configurable/OpenAIAgent.d.ts +0 -0
- package/ts_build/src/agents/configurable/OpenAIAgent.js +1 -0
- package/ts_build/src/agents/configurable/OpenAIAgent.js.map +1 -0
- package/ts_build/src/agents/developer/developer.d.ts +9 -0
- package/ts_build/src/agents/developer/developer.js +69 -0
- package/ts_build/src/agents/developer/developer.js.map +1 -0
- package/ts_build/src/agents/index.d.ts +7 -0
- package/ts_build/src/agents/index.js +38 -0
- package/ts_build/src/agents/index.js.map +1 -0
- package/ts_build/src/agents/interface.d.ts +10 -0
- package/ts_build/src/agents/interface.js +3 -0
- package/ts_build/src/agents/interface.js.map +1 -0
- package/ts_build/src/agents/patcher/patcher.d.ts +9 -0
- package/ts_build/src/agents/patcher/patcher.js +106 -0
- package/ts_build/src/agents/patcher/patcher.js.map +1 -0
- package/ts_build/src/agents/researcher/researcher.d.ts +9 -0
- package/ts_build/src/agents/researcher/researcher.js +107 -0
- package/ts_build/src/agents/researcher/researcher.js.map +1 -0
- package/ts_build/src/agents/tools/addInternalTools.d.ts +5 -0
- package/ts_build/src/agents/tools/addInternalTools.js +18 -0
- package/ts_build/src/agents/tools/addInternalTools.js.map +1 -0
- package/ts_build/src/agents/tools/agentCall.d.ts +1 -0
- package/ts_build/src/agents/tools/agentCall.js +21 -0
- package/ts_build/src/agents/tools/agentCall.js.map +1 -0
- package/ts_build/src/agents/tools/aiClient.d.ts +6 -0
- package/ts_build/src/agents/tools/aiClient.js +25 -0
- package/ts_build/src/agents/tools/aiClient.js.map +1 -0
- package/ts_build/src/agents/tools/asana/definitions.d.ts +202 -0
- package/ts_build/src/agents/tools/asana/definitions.js +197 -0
- package/ts_build/src/agents/tools/asana/definitions.js.map +1 -0
- package/ts_build/src/agents/tools/asana/index.d.ts +8 -0
- package/ts_build/src/agents/tools/asana/index.js +98 -0
- package/ts_build/src/agents/tools/asana/index.js.map +1 -0
- package/ts_build/src/agents/tools/askHuman.d.ts +1 -0
- package/ts_build/src/agents/tools/askHuman.js +15 -0
- package/ts_build/src/agents/tools/askHuman.js.map +1 -0
- package/ts_build/src/agents/tools/callPlugin.d.ts +1 -0
- package/ts_build/src/agents/tools/callPlugin.js +9 -0
- package/ts_build/src/agents/tools/callPlugin.js.map +1 -0
- package/ts_build/src/agents/tools/client.d.ts +5 -0
- package/ts_build/src/agents/tools/client.js +21 -0
- package/ts_build/src/agents/tools/client.js.map +1 -0
- package/ts_build/src/agents/tools/embeddingSearch.d.ts +1 -0
- package/ts_build/src/agents/tools/embeddingSearch.js +9 -0
- package/ts_build/src/agents/tools/embeddingSearch.js.map +1 -0
- package/ts_build/src/agents/tools/execCommand.d.ts +1 -0
- package/ts_build/src/agents/tools/execCommand.js +25 -0
- package/ts_build/src/agents/tools/execCommand.js.map +1 -0
- package/ts_build/src/agents/tools/fileSearch.d.ts +1 -0
- package/ts_build/src/agents/tools/fileSearch.js +31 -0
- package/ts_build/src/agents/tools/fileSearch.js.map +1 -0
- package/ts_build/src/agents/tools/finalAnswer.d.ts +1 -0
- package/ts_build/src/agents/tools/finalAnswer.js +8 -0
- package/ts_build/src/agents/tools/finalAnswer.js.map +1 -0
- package/ts_build/src/agents/tools/github/definitions.d.ts +47 -0
- package/ts_build/src/agents/tools/github/definitions.js +86 -0
- package/ts_build/src/agents/tools/github/definitions.js.map +1 -0
- package/ts_build/src/agents/tools/github/index.d.ts +789 -0
- package/ts_build/src/agents/tools/github/index.js +56 -0
- package/ts_build/src/agents/tools/github/index.js.map +1 -0
- package/ts_build/src/agents/tools/googleSearch.d.ts +93 -0
- package/ts_build/src/agents/tools/googleSearch.js +117 -0
- package/ts_build/src/agents/tools/googleSearch.js.map +1 -0
- package/ts_build/src/agents/tools/googleSearchTypes.d.ts +74 -0
- package/ts_build/src/agents/tools/googleSearchTypes.js +3 -0
- package/ts_build/src/agents/tools/googleSearchTypes.js.map +1 -0
- package/ts_build/src/agents/tools/index.d.ts +24 -0
- package/ts_build/src/agents/tools/index.js +41 -0
- package/ts_build/src/agents/tools/index.js.map +1 -0
- package/ts_build/src/agents/tools/language/definitions.d.ts +89 -0
- package/ts_build/src/agents/tools/language/definitions.js +95 -0
- package/ts_build/src/agents/tools/language/definitions.js.map +1 -0
- package/ts_build/src/agents/tools/language/index.d.ts +4 -0
- package/ts_build/src/agents/tools/language/index.js +22 -0
- package/ts_build/src/agents/tools/language/index.js.map +1 -0
- package/ts_build/src/agents/tools/lintFile.d.ts +1 -0
- package/ts_build/src/agents/tools/lintFile.js +22 -0
- package/ts_build/src/agents/tools/lintFile.js.map +1 -0
- package/ts_build/src/agents/tools/list.d.ts +2 -0
- package/ts_build/src/agents/tools/list.js +505 -0
- package/ts_build/src/agents/tools/list.js.map +1 -0
- package/ts_build/src/agents/tools/loadWebpage.d.ts +8 -0
- package/ts_build/src/agents/tools/loadWebpage.js +97 -0
- package/ts_build/src/agents/tools/loadWebpage.js.map +1 -0
- package/ts_build/src/agents/tools/modifyFile.d.ts +2 -0
- package/ts_build/src/agents/tools/modifyFile.js +74 -0
- package/ts_build/src/agents/tools/modifyFile.js.map +1 -0
- package/ts_build/src/agents/tools/patch.d.ts +21 -0
- package/ts_build/src/agents/tools/patch.js +443 -0
- package/ts_build/src/agents/tools/patch.js.map +1 -0
- package/ts_build/src/agents/tools/readBlocks.d.ts +2 -0
- package/ts_build/src/agents/tools/readBlocks.js +59 -0
- package/ts_build/src/agents/tools/readBlocks.js.map +1 -0
- package/ts_build/src/agents/tools/readFile.d.ts +1 -0
- package/ts_build/src/agents/tools/readFile.js +46 -0
- package/ts_build/src/agents/tools/readFile.js.map +1 -0
- package/ts_build/src/agents/tools/scanFile.d.ts +1 -0
- package/ts_build/src/agents/tools/scanFile.js +36 -0
- package/ts_build/src/agents/tools/scanFile.js.map +1 -0
- package/ts_build/src/agents/tools/textSearch.d.ts +1 -0
- package/ts_build/src/agents/tools/textSearch.js +22 -0
- package/ts_build/src/agents/tools/textSearch.js.map +1 -0
- package/ts_build/src/agents/tools/types/fileblock.d.ts +5 -0
- package/ts_build/src/agents/tools/types/fileblock.js +3 -0
- package/ts_build/src/agents/tools/types/fileblock.js.map +1 -0
- package/ts_build/src/agents/tools/visionTool.d.ts +1 -0
- package/ts_build/src/agents/tools/visionTool.js +9 -0
- package/ts_build/src/agents/tools/visionTool.js.map +1 -0
- package/ts_build/src/agents/tools/writeFile.d.ts +2 -0
- package/ts_build/src/agents/tools/writeFile.js +61 -0
- package/ts_build/src/agents/tools/writeFile.js.map +1 -0
- package/ts_build/src/agents/vim/vim.d.ts +14 -0
- package/ts_build/src/agents/vim/vim.js +171 -0
- package/ts_build/src/agents/vim/vim.js.map +1 -0
- package/ts_build/src/ai.d.ts +10 -0
- package/ts_build/src/ai.js +102 -0
- package/ts_build/src/ai.js.map +1 -0
- package/ts_build/src/chat.d.ts +13 -0
- package/ts_build/src/chat.js +319 -0
- package/ts_build/src/chat.js.map +1 -0
- package/ts_build/src/cli.d.ts +2 -0
- package/ts_build/src/cli.js +98 -0
- package/ts_build/src/cli.js.map +1 -0
- package/ts_build/src/clients/anthropic.d.ts +31 -0
- package/ts_build/src/clients/anthropic.js +344 -0
- package/ts_build/src/clients/anthropic.js.map +1 -0
- package/ts_build/src/clients/gemini.d.ts +20 -0
- package/ts_build/src/clients/gemini.js +347 -0
- package/ts_build/src/clients/gemini.js.map +1 -0
- package/ts_build/src/clients/http.d.ts +12 -0
- package/ts_build/src/clients/http.js +91 -0
- package/ts_build/src/clients/http.js.map +1 -0
- package/ts_build/src/clients/index.d.ts +47 -0
- package/ts_build/src/clients/index.js +143 -0
- package/ts_build/src/clients/index.js.map +1 -0
- package/ts_build/src/clients/knowhow.d.ts +10 -0
- package/ts_build/src/clients/knowhow.js +24 -0
- package/ts_build/src/clients/knowhow.js.map +1 -0
- package/ts_build/src/clients/openai.d.ts +20 -0
- package/ts_build/src/clients/openai.js +221 -0
- package/ts_build/src/clients/openai.js.map +1 -0
- package/ts_build/src/clients/types.d.ts +89 -0
- package/ts_build/src/clients/types.js +3 -0
- package/ts_build/src/clients/types.js.map +1 -0
- package/ts_build/src/clients/xai.d.ts +22 -0
- package/ts_build/src/clients/xai.js +108 -0
- package/ts_build/src/clients/xai.js.map +1 -0
- package/ts_build/src/config.d.ts +9 -0
- package/ts_build/src/config.js +216 -0
- package/ts_build/src/config.js.map +1 -0
- package/ts_build/src/conversion.d.ts +7 -0
- package/ts_build/src/conversion.js +114 -0
- package/ts_build/src/conversion.js.map +1 -0
- package/ts_build/src/dataset/diffs/debug-errors.d.ts +1 -0
- package/ts_build/src/dataset/diffs/debug-errors.js +28 -0
- package/ts_build/src/dataset/diffs/debug-errors.js.map +1 -0
- package/ts_build/src/dataset/diffs/debug.d.ts +1 -0
- package/ts_build/src/dataset/diffs/debug.js +50 -0
- package/ts_build/src/dataset/diffs/debug.js.map +1 -0
- package/ts_build/src/dataset/diffs/generate.d.ts +1 -0
- package/ts_build/src/dataset/diffs/generate.js +70 -0
- package/ts_build/src/dataset/diffs/generate.js.map +1 -0
- package/ts_build/src/dataset/diffs/jsonl.d.ts +1 -0
- package/ts_build/src/dataset/diffs/jsonl.js +47 -0
- package/ts_build/src/dataset/diffs/jsonl.js.map +1 -0
- package/ts_build/src/dataset/diffs/test.d.ts +1 -0
- package/ts_build/src/dataset/diffs/test.js +114 -0
- package/ts_build/src/dataset/diffs/test.js.map +1 -0
- package/ts_build/src/embeddings.d.ts +19 -0
- package/ts_build/src/embeddings.js +322 -0
- package/ts_build/src/embeddings.js.map +1 -0
- package/ts_build/src/hashes.d.ts +6 -0
- package/ts_build/src/hashes.js +78 -0
- package/ts_build/src/hashes.js.map +1 -0
- package/ts_build/src/index.d.ts +14 -0
- package/ts_build/src/index.js +258 -0
- package/ts_build/src/index.js.map +1 -0
- package/ts_build/src/login.d.ts +2 -0
- package/ts_build/src/login.js +63 -0
- package/ts_build/src/login.js.map +1 -0
- package/ts_build/src/microphone.d.ts +9 -0
- package/ts_build/src/microphone.js +131 -0
- package/ts_build/src/microphone.js.map +1 -0
- package/ts_build/src/modules/index.d.ts +3 -0
- package/ts_build/src/modules/index.js +34 -0
- package/ts_build/src/modules/index.js.map +1 -0
- package/ts_build/src/modules/types.d.ts +37 -0
- package/ts_build/src/modules/types.js +3 -0
- package/ts_build/src/modules/types.js.map +1 -0
- package/ts_build/src/plugins/asana.d.ts +16 -0
- package/ts_build/src/plugins/asana.js +114 -0
- package/ts_build/src/plugins/asana.js.map +1 -0
- package/ts_build/src/plugins/downloader/downloader.d.ts +12 -0
- package/ts_build/src/plugins/downloader/downloader.js +174 -0
- package/ts_build/src/plugins/downloader/downloader.js.map +1 -0
- package/ts_build/src/plugins/downloader/index.d.ts +3 -0
- package/ts_build/src/plugins/downloader/index.js +41 -0
- package/ts_build/src/plugins/downloader/index.js.map +1 -0
- package/ts_build/src/plugins/downloader/plugin.d.ts +8 -0
- package/ts_build/src/plugins/downloader/plugin.js +83 -0
- package/ts_build/src/plugins/downloader/plugin.js.map +1 -0
- package/ts_build/src/plugins/downloader/types.d.ts +82 -0
- package/ts_build/src/plugins/downloader/types.js +79 -0
- package/ts_build/src/plugins/downloader/types.js.map +1 -0
- package/ts_build/src/plugins/embedding.d.ts +5 -0
- package/ts_build/src/plugins/embedding.js +28 -0
- package/ts_build/src/plugins/embedding.js.map +1 -0
- package/ts_build/src/plugins/figma.d.ts +20 -0
- package/ts_build/src/plugins/figma.js +94 -0
- package/ts_build/src/plugins/figma.js.map +1 -0
- package/ts_build/src/plugins/github.d.ts +1223 -0
- package/ts_build/src/plugins/github.js +115 -0
- package/ts_build/src/plugins/github.js.map +1 -0
- package/ts_build/src/plugins/jira.d.ts +15 -0
- package/ts_build/src/plugins/jira.js +94 -0
- package/ts_build/src/plugins/jira.js.map +1 -0
- package/ts_build/src/plugins/language.d.ts +8 -0
- package/ts_build/src/plugins/language.js +69 -0
- package/ts_build/src/plugins/language.js.map +1 -0
- package/ts_build/src/plugins/linear.d.ts +23 -0
- package/ts_build/src/plugins/linear.js +184 -0
- package/ts_build/src/plugins/linear.js.map +1 -0
- package/ts_build/src/plugins/notion.d.ts +32 -0
- package/ts_build/src/plugins/notion.js +131 -0
- package/ts_build/src/plugins/notion.js.map +1 -0
- package/ts_build/src/plugins/plugins.d.ts +11 -0
- package/ts_build/src/plugins/plugins.js +51 -0
- package/ts_build/src/plugins/plugins.js.map +1 -0
- package/ts_build/src/plugins/types.d.ts +5 -0
- package/ts_build/src/plugins/types.js +3 -0
- package/ts_build/src/plugins/types.js.map +1 -0
- package/ts_build/src/plugins/url.d.ts +8 -0
- package/ts_build/src/plugins/url.js +50 -0
- package/ts_build/src/plugins/url.js.map +1 -0
- package/ts_build/src/plugins/vim.d.ts +11 -0
- package/ts_build/src/plugins/vim.js +63 -0
- package/ts_build/src/plugins/vim.js.map +1 -0
- package/ts_build/src/prompts/BasicCodeDocumenter.d.ts +2 -0
- package/ts_build/src/prompts/BasicCodeDocumenter.js +4 -0
- package/ts_build/src/prompts/BasicCodeDocumenter.js.map +1 -0
- package/ts_build/src/prompts/BasicProjectDocumenter.d.ts +2 -0
- package/ts_build/src/prompts/BasicProjectDocumenter.js +4 -0
- package/ts_build/src/prompts/BasicProjectDocumenter.js.map +1 -0
- package/ts_build/src/prompts/EmbeddingSeachHelper.d.ts +2 -0
- package/ts_build/src/prompts/EmbeddingSeachHelper.js +4 -0
- package/ts_build/src/prompts/EmbeddingSeachHelper.js.map +1 -0
- package/ts_build/src/prompts/index.d.ts +13 -0
- package/ts_build/src/prompts/index.js +15 -0
- package/ts_build/src/prompts/index.js.map +1 -0
- package/ts_build/src/server/index.d.ts +1 -0
- package/ts_build/src/server/index.js +17 -0
- package/ts_build/src/server/index.js.map +1 -0
- package/ts_build/src/services/AgentService.d.ts +14 -0
- package/ts_build/src/services/AgentService.js +87 -0
- package/ts_build/src/services/AgentService.js.map +1 -0
- package/ts_build/src/services/EmbeddingService.d.ts +39 -0
- package/ts_build/src/services/EmbeddingService.js +307 -0
- package/ts_build/src/services/EmbeddingService.js.map +1 -0
- package/ts_build/src/services/EventService.d.ts +9 -0
- package/ts_build/src/services/EventService.js +20 -0
- package/ts_build/src/services/EventService.js.map +1 -0
- package/ts_build/src/services/GitHub.d.ts +11 -0
- package/ts_build/src/services/GitHub.js +52 -0
- package/ts_build/src/services/GitHub.js.map +1 -0
- package/ts_build/src/services/KnowhowClient.d.ts +18 -0
- package/ts_build/src/services/KnowhowClient.js +85 -0
- package/ts_build/src/services/KnowhowClient.js.map +1 -0
- package/ts_build/src/services/Mcp.d.ts +377 -0
- package/ts_build/src/services/Mcp.js +221 -0
- package/ts_build/src/services/Mcp.js.map +1 -0
- package/ts_build/src/services/McpServer.d.ts +19 -0
- package/ts_build/src/services/McpServer.js +104 -0
- package/ts_build/src/services/McpServer.js.map +1 -0
- package/ts_build/src/services/McpWebsocketTransport.d.ts +13 -0
- package/ts_build/src/services/McpWebsocketTransport.js +59 -0
- package/ts_build/src/services/McpWebsocketTransport.js.map +1 -0
- package/ts_build/src/services/S3.d.ts +9 -0
- package/ts_build/src/services/S3.js +116 -0
- package/ts_build/src/services/S3.js.map +1 -0
- package/ts_build/src/services/Tools.d.ts +19 -0
- package/ts_build/src/services/Tools.js +51 -0
- package/ts_build/src/services/Tools.js.map +1 -0
- package/ts_build/src/services/flags.d.ts +13 -0
- package/ts_build/src/services/flags.js +48 -0
- package/ts_build/src/services/flags.js.map +1 -0
- package/ts_build/src/services/index.d.ts +8 -0
- package/ts_build/src/services/index.js +38 -0
- package/ts_build/src/services/index.js.map +1 -0
- package/ts_build/src/terminal.d.ts +1 -0
- package/ts_build/src/terminal.js +35 -0
- package/ts_build/src/terminal.js.map +1 -0
- package/ts_build/src/types.d.ts +181 -0
- package/ts_build/src/types.js +94 -0
- package/ts_build/src/types.js.map +1 -0
- package/ts_build/src/utils/index.d.ts +24 -0
- package/ts_build/src/utils/index.js +116 -0
- package/ts_build/src/utils/index.js.map +1 -0
- package/ts_build/src/worker.d.ts +1 -0
- package/ts_build/src/worker.js +68 -0
- package/ts_build/src/worker.js.map +1 -0
- package/ts_build/tests/integration/figma.test.d.ts +1 -0
- package/ts_build/tests/integration/figma.test.js +47 -0
- package/ts_build/tests/integration/figma.test.js.map +1 -0
- package/ts_build/tests/integration/fileblocks/readwrite.test.d.ts +1 -0
- package/ts_build/tests/integration/fileblocks/readwrite.test.js +95 -0
- package/ts_build/tests/integration/fileblocks/readwrite.test.js.map +1 -0
- package/ts_build/tests/integration/patching.test.d.ts +1 -0
- package/ts_build/tests/integration/patching.test.js +117 -0
- package/ts_build/tests/integration/patching.test.js.map +1 -0
- package/ts_build/tests/languagePlugin.test.d.ts +1 -0
- package/ts_build/tests/languagePlugin.test.js +78 -0
- package/ts_build/tests/languagePlugin.test.js.map +1 -0
- package/ts_build/tests/patching/corrupted.test.d.ts +1 -0
- package/ts_build/tests/patching/corrupted.test.js +53 -0
- package/ts_build/tests/patching/corrupted.test.js.map +1 -0
- package/ts_build/tests/patching/imports.test.d.ts +1 -0
- package/ts_build/tests/patching/imports.test.js +61 -0
- package/ts_build/tests/patching/imports.test.js.map +1 -0
- package/ts_build/tests/test.spec.d.ts +1 -0
- package/ts_build/tests/test.spec.js +101 -0
- package/ts_build/tests/test.spec.js.map +1 -0
- package/tsconfig.json +31 -0
- package/tslint.json +11 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Plugin } from "./types";
|
|
2
|
+
import { Embeddable, MinimalEmbedding } from "../types";
|
|
3
|
+
|
|
4
|
+
export class AsanaPlugin implements Plugin {
|
|
5
|
+
private asanaClient = require("asana").ApiClient.instance;
|
|
6
|
+
|
|
7
|
+
constructor() {
|
|
8
|
+
this.asanaClient.authentications.token = process.env.ASANA_TOKEN;
|
|
9
|
+
this.asanaClient.defaultHeaders = {
|
|
10
|
+
"Asana-Enable": "new_user_task_lists,new_goal_memberships",
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getTaskString(task: any) {
|
|
15
|
+
return `### Task: ${task.name}\n- Description: ${task.notes}\n- URL: ${task.permalink_url}\n Completed: ${task.completed}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async embed(userPrompt: string): Promise<MinimalEmbedding[]> {
|
|
19
|
+
const urls = this.extractTaskUrls(userPrompt);
|
|
20
|
+
const tasksData = await this.getTasksFromUrls(urls);
|
|
21
|
+
const tasksDataFiltered = tasksData.filter((task) => task !== null);
|
|
22
|
+
|
|
23
|
+
const tasksEmbeddings = tasksDataFiltered.map((task) => {
|
|
24
|
+
return {
|
|
25
|
+
id: task.permalink_url,
|
|
26
|
+
text: this.getTaskString(task),
|
|
27
|
+
metadata: {
|
|
28
|
+
task: JSON.stringify(task),
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const projectUrls = this.extractProjectUrls(userPrompt);
|
|
34
|
+
const projectTasks = await this.getTasksFromProjectUrls(projectUrls);
|
|
35
|
+
const projectTasksFiltered = projectTasks.filter((t) => t !== null);
|
|
36
|
+
|
|
37
|
+
const projectTaskEmbeddings = projectTasksFiltered.map((t) => {
|
|
38
|
+
return {
|
|
39
|
+
id: t.permalink_url,
|
|
40
|
+
text: this.getTaskString(t),
|
|
41
|
+
metadata: {
|
|
42
|
+
task: JSON.stringify(t),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const allTasks = tasksEmbeddings.concat(projectTaskEmbeddings);
|
|
48
|
+
console.log("Found ", allTasks.length, "tasks");
|
|
49
|
+
return allTasks;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
extractProjectUrls(userPrompt: string): string[] {
|
|
53
|
+
const projectUrlRegex = /https:\/\/app\.asana\.com\/0\/(\d+)\/list/g;
|
|
54
|
+
const matches = userPrompt.match(projectUrlRegex);
|
|
55
|
+
return matches || [];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
extractTaskUrls(userPrompt: string): string[] {
|
|
59
|
+
const taskUrlRegex = /https:\/\/app\.asana\.com\/0\/(\d+)\/(\d+)/g;
|
|
60
|
+
const matches = userPrompt.match(taskUrlRegex);
|
|
61
|
+
return matches || [];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async getTasksFromUrls(urls: string[]) {
|
|
65
|
+
const tasks = await Promise.all(
|
|
66
|
+
urls.map(async (url) => {
|
|
67
|
+
return this.getTaskFromUrl(url);
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
|
+
return tasks;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async getTasksFromProjectUrls(urls: string[]) {
|
|
74
|
+
const tasks = await Promise.all(
|
|
75
|
+
urls.map((url) => this.getTasksFromProjectUrl(url))
|
|
76
|
+
);
|
|
77
|
+
return tasks.flat();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async getTasksFromProjectUrl(url: string) {
|
|
81
|
+
const urlParts = url.split("/");
|
|
82
|
+
const projectId = urlParts[4];
|
|
83
|
+
console.log({ projectId });
|
|
84
|
+
if (!projectId) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
let tasks = await this.asanaClient.tasks.findAll({
|
|
88
|
+
project: projectId,
|
|
89
|
+
opt_expand: "notes,assignee,permalink_url,custom_fields,tags,completed",
|
|
90
|
+
});
|
|
91
|
+
const allData = [];
|
|
92
|
+
|
|
93
|
+
do {
|
|
94
|
+
allData.push(...tasks.data);
|
|
95
|
+
tasks = await tasks.nextPage();
|
|
96
|
+
} while (tasks);
|
|
97
|
+
|
|
98
|
+
return allData;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async getTaskFromUrl(url: string) {
|
|
102
|
+
const taskId = url.split("/").pop();
|
|
103
|
+
if (taskId) {
|
|
104
|
+
console.log(`Fetching Asana task ${taskId}`);
|
|
105
|
+
return await this.getTaskData(taskId);
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async getTaskData(taskId: string) {
|
|
111
|
+
try {
|
|
112
|
+
const task = await this.asanaClient.tasks.findById(taskId);
|
|
113
|
+
return task;
|
|
114
|
+
} catch (error) {
|
|
115
|
+
console.error("Error fetching Asana task:", error);
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async call(userPrompt: string): Promise<string> {
|
|
121
|
+
const urls = this.extractTaskUrls(userPrompt);
|
|
122
|
+
const tasksData = await this.getTasksFromUrls(urls);
|
|
123
|
+
const tasksDataFiltered = tasksData.filter((task) => task !== null);
|
|
124
|
+
|
|
125
|
+
if (tasksDataFiltered.length === 0) {
|
|
126
|
+
return "ASANA PLUGIN: No tasks found";
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const markdownTasks = tasksDataFiltered
|
|
130
|
+
.map((task) => this.getTaskString(task))
|
|
131
|
+
.join("\n\n");
|
|
132
|
+
return `ASANA PLUGIN: The following tasks were loaded:\n\n${markdownTasks}`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import ytdl from "youtube-dl-exec";
|
|
4
|
+
import Logger from "progress-estimator";
|
|
5
|
+
import { DownloadInfo, KeyframeInfo } from "./types";
|
|
6
|
+
import { visionTool } from "../../agents/tools/visionTool";
|
|
7
|
+
import { execAsync, fileExists, readFile, mkdir } from "../../utils";
|
|
8
|
+
import { openai } from "../../ai";
|
|
9
|
+
|
|
10
|
+
const logger = Logger();
|
|
11
|
+
|
|
12
|
+
class DownloaderService {
|
|
13
|
+
async download(url: string, outputDir: string) {
|
|
14
|
+
const info = await this.info(url);
|
|
15
|
+
const exists = await fileExists(`${outputDir}/${info.id}.${info.ext}`);
|
|
16
|
+
|
|
17
|
+
if (exists) {
|
|
18
|
+
console.log("File already exists, skipping download");
|
|
19
|
+
return info;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const scrape = ytdl(url, { output: `${outputDir}/%(id)s.%(ext)s` });
|
|
23
|
+
const result = await logger(scrape, `Obtaining ${url}`);
|
|
24
|
+
return info;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async info(url: string) {
|
|
28
|
+
const info = await ytdl(url, {
|
|
29
|
+
dumpSingleJson: true,
|
|
30
|
+
noWarnings: true,
|
|
31
|
+
});
|
|
32
|
+
console.log(info);
|
|
33
|
+
return info;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public async chunk(
|
|
37
|
+
filePath: string,
|
|
38
|
+
outputDir: string,
|
|
39
|
+
CHUNK_LENGTH_SECONDS = 30,
|
|
40
|
+
reuseExistingChunks = true
|
|
41
|
+
) {
|
|
42
|
+
const parsed = path.parse(filePath);
|
|
43
|
+
const fileName = parsed.name;
|
|
44
|
+
const fileExt = parsed.ext;
|
|
45
|
+
console.log({ fileName, fileExt });
|
|
46
|
+
console.log("Chunking file", filePath);
|
|
47
|
+
|
|
48
|
+
// create a temp directory
|
|
49
|
+
const outputDirPath = path.join(outputDir, `${fileName}/chunks`);
|
|
50
|
+
await fs.promises.mkdir(outputDirPath, { recursive: true });
|
|
51
|
+
const existingFolderFiles = await fs.promises.readdir(outputDirPath);
|
|
52
|
+
const existingChunkNames = existingFolderFiles.filter(
|
|
53
|
+
(f) => f.includes("chunk") && f.endsWith(".mp3")
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
if (existingChunkNames.length > 0) {
|
|
57
|
+
if (reuseExistingChunks) {
|
|
58
|
+
console.log("Chunks already exist, skipping");
|
|
59
|
+
return existingFolderFiles.map((chunkName) =>
|
|
60
|
+
path.join(outputDirPath, chunkName)
|
|
61
|
+
);
|
|
62
|
+
} else {
|
|
63
|
+
for (const file of existingFolderFiles) {
|
|
64
|
+
fs.rmSync(path.join(outputDirPath, file), { recursive: true });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const command = `ffmpeg -i "${filePath}" -f segment -segment_time ${CHUNK_LENGTH_SECONDS} -map 0:a:0 -acodec mp3 -vn "${outputDirPath}/chunk%03d.mp3"`;
|
|
70
|
+
await execAsync(command);
|
|
71
|
+
|
|
72
|
+
const folderFiles = await fs.promises.readdir(outputDirPath);
|
|
73
|
+
const chunkNames = folderFiles.filter(
|
|
74
|
+
(f) => f.includes("chunk") && f.endsWith(".mp3")
|
|
75
|
+
);
|
|
76
|
+
console.log("Chunked into", chunkNames.length, "chunks");
|
|
77
|
+
return chunkNames.map((chunkName) => path.join(outputDirPath, chunkName));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public async transcribeChunks(
|
|
81
|
+
files: string[],
|
|
82
|
+
outputPath: string,
|
|
83
|
+
reusePreviousTranscript = true
|
|
84
|
+
) {
|
|
85
|
+
const exists = await fileExists(outputPath);
|
|
86
|
+
if (exists && reusePreviousTranscript) {
|
|
87
|
+
console.log("Transcription already exists, skipping");
|
|
88
|
+
const contents = await readFile(outputPath);
|
|
89
|
+
return JSON.parse(contents.toString()) as string[];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const fullText = [];
|
|
93
|
+
for (const file of files) {
|
|
94
|
+
const chunkName = path.parse(file).name;
|
|
95
|
+
const chunkTranscriptPath = path.join(
|
|
96
|
+
path.dirname(outputPath),
|
|
97
|
+
`/chunks/${chunkName}.txt`
|
|
98
|
+
);
|
|
99
|
+
const chunkExists = await fileExists(chunkTranscriptPath);
|
|
100
|
+
|
|
101
|
+
if (chunkExists && reusePreviousTranscript) {
|
|
102
|
+
console.log("Chunk transcription already exists, skipping");
|
|
103
|
+
const contents = await readFile(chunkTranscriptPath);
|
|
104
|
+
fullText.push(contents.toString());
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
console.log("Transcribing", file);
|
|
109
|
+
const transcript = await openai.audio.transcriptions
|
|
110
|
+
.create({
|
|
111
|
+
file: fs.createReadStream(file),
|
|
112
|
+
model: "whisper-1",
|
|
113
|
+
})
|
|
114
|
+
.catch((e) => {
|
|
115
|
+
console.error("Error transcribing", file, e);
|
|
116
|
+
return { text: "" };
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
await mkdir(path.dirname(chunkTranscriptPath), { recursive: true });
|
|
120
|
+
await fs.promises.writeFile(chunkTranscriptPath, transcript.text);
|
|
121
|
+
|
|
122
|
+
// save chunk transcript to file
|
|
123
|
+
fullText.push(transcript.text);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
await fs.promises.writeFile(outputPath, JSON.stringify(fullText));
|
|
127
|
+
return fullText;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
public async extractKeyframes(
|
|
131
|
+
filePath: string,
|
|
132
|
+
outputPath: string,
|
|
133
|
+
interval: number = 10
|
|
134
|
+
): Promise<KeyframeInfo[]> {
|
|
135
|
+
if (fs.existsSync(outputPath)) {
|
|
136
|
+
console.log("Keyframes already exist, skipping");
|
|
137
|
+
const contents = await readFile(outputPath);
|
|
138
|
+
return JSON.parse(contents.toString()) as KeyframeInfo[];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const parsed = path.parse(filePath);
|
|
142
|
+
const outputDir = path.dirname(outputPath);
|
|
143
|
+
const fileName = parsed.name;
|
|
144
|
+
const keyframesDir = path.join(outputDir, `/keyframes`);
|
|
145
|
+
await fs.promises.mkdir(keyframesDir, { recursive: true });
|
|
146
|
+
|
|
147
|
+
const command = `ffmpeg -i "${filePath}" -vf "fps=1/${interval},scale=640:-1" "${keyframesDir}/frame%04d.jpg"`;
|
|
148
|
+
await execAsync(command);
|
|
149
|
+
|
|
150
|
+
const keyframes = await fs.promises.readdir(keyframesDir);
|
|
151
|
+
const keyframeInfos: KeyframeInfo[] = [];
|
|
152
|
+
|
|
153
|
+
for (const keyframe of keyframes) {
|
|
154
|
+
const keyframePath = path.join(keyframesDir, keyframe);
|
|
155
|
+
const keyframeName = path.parse(keyframe).name;
|
|
156
|
+
const keyframeDescriptionPath = path.join(
|
|
157
|
+
keyframesDir,
|
|
158
|
+
`${keyframeName}.json`
|
|
159
|
+
);
|
|
160
|
+
const descriptionExists = await fileExists(keyframeDescriptionPath);
|
|
161
|
+
|
|
162
|
+
if (descriptionExists) {
|
|
163
|
+
const cached = await readFile(keyframeDescriptionPath);
|
|
164
|
+
const cachedJson = JSON.parse(cached.toString()) as KeyframeInfo;
|
|
165
|
+
keyframeInfos.push(cachedJson);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const description = await this.describeKeyframe(keyframePath);
|
|
170
|
+
const keyframeJson = {
|
|
171
|
+
path: keyframePath,
|
|
172
|
+
description,
|
|
173
|
+
timestamp: this.extractTimestamp(keyframe, interval),
|
|
174
|
+
};
|
|
175
|
+
await fs.promises.writeFile(
|
|
176
|
+
keyframeDescriptionPath,
|
|
177
|
+
JSON.stringify(keyframeJson, null, 2)
|
|
178
|
+
);
|
|
179
|
+
keyframeInfos.push(keyframeJson);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
await fs.promises.writeFile(outputPath, JSON.stringify(keyframeInfos));
|
|
183
|
+
|
|
184
|
+
return keyframeInfos;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private async describeKeyframe(keyframePath: string): Promise<string> {
|
|
188
|
+
const question =
|
|
189
|
+
"Describe this image in detail, focusing on the main elements and actions visible.";
|
|
190
|
+
const base64 = await fs.promises.readFile(keyframePath, {
|
|
191
|
+
encoding: "base64",
|
|
192
|
+
});
|
|
193
|
+
const image = `data:image/jpeg;base64,${base64}`;
|
|
194
|
+
const description = await visionTool(image, question);
|
|
195
|
+
return description;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
private extractTimestamp(keyframeName: string, interval: number): number {
|
|
199
|
+
const frameNumber = parseInt(keyframeName.match(/\d+/)[0], 10);
|
|
200
|
+
return frameNumber * interval;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export const Downloader = new DownloaderService();
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { Plugin } from "../types";
|
|
3
|
+
import { MinimalEmbedding } from "../../types";
|
|
4
|
+
import { convertToText, processVideo } from "../../conversion";
|
|
5
|
+
import { Downloader } from "./downloader";
|
|
6
|
+
|
|
7
|
+
export class DownloaderPlugin implements Plugin {
|
|
8
|
+
skipExt = ["jpg", "jpeg", "png", "gif"];
|
|
9
|
+
|
|
10
|
+
extractUrls(userInput: string): string[] {
|
|
11
|
+
const urlRegex = /https:\/\/[^\s]+/gim;
|
|
12
|
+
const matches = userInput.match(urlRegex) || [];
|
|
13
|
+
return matches;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async call(userInput: string): Promise<string> {
|
|
17
|
+
const urls = this.extractUrls(userInput);
|
|
18
|
+
if (urls.length === 0) {
|
|
19
|
+
return "DOWNLOADER PLUGIN: No URLs found in the input";
|
|
20
|
+
}
|
|
21
|
+
let transcript = "";
|
|
22
|
+
for (const url of urls) {
|
|
23
|
+
if (this.skipExt.includes(url.split(".").pop() || "")) {
|
|
24
|
+
console.log("DOWNLOADER PLUGIN: skipping", url);
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
console.log("DOWNLOADER PLUGIN: attempting", url);
|
|
29
|
+
const downloadDir = ".knowhow/downloads/";
|
|
30
|
+
const fileInfo = await Downloader.download(url, downloadDir);
|
|
31
|
+
const filePath = `${downloadDir}${fileInfo.id}.${fileInfo.ext}`;
|
|
32
|
+
transcript += await convertToText(filePath);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
console.log("DOWNLOADER PLUGIN: cannot download", url);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return "DOWNLOADER PLUGIN: " + transcript;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async embed(userInput: string): Promise<MinimalEmbedding[]> {
|
|
41
|
+
const urls = this.extractUrls(userInput);
|
|
42
|
+
if (urls.length === 0) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const embeddings: MinimalEmbedding[] = [];
|
|
47
|
+
for (const url of urls) {
|
|
48
|
+
const downloadDir = ".knowhow/downloads/";
|
|
49
|
+
const fileInfo = await Downloader.download(url, downloadDir);
|
|
50
|
+
const filePath = `${downloadDir}${fileInfo.id}.${fileInfo.ext}`;
|
|
51
|
+
const processed = await processVideo(filePath);
|
|
52
|
+
|
|
53
|
+
let index = 0;
|
|
54
|
+
for (const chunk of processed) {
|
|
55
|
+
if (chunk.transcription) {
|
|
56
|
+
embeddings.push({
|
|
57
|
+
id: `${url}-audio-${index}`,
|
|
58
|
+
text: chunk.transcription,
|
|
59
|
+
metadata: {
|
|
60
|
+
url,
|
|
61
|
+
description: chunk.frame.description,
|
|
62
|
+
timestamp: `${chunk.frame.timestamp}s`,
|
|
63
|
+
image: fs.readFileSync(chunk.frame.path, "base64"),
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (chunk.frame.description) {
|
|
69
|
+
embeddings.push({
|
|
70
|
+
id: `${url}-video-${index}`,
|
|
71
|
+
text: chunk.frame.description,
|
|
72
|
+
metadata: {
|
|
73
|
+
url,
|
|
74
|
+
timestamp: `${chunk.frame.timestamp}s`,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
index++;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return embeddings;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export class AudioFormat {
|
|
2
|
+
ext: string;
|
|
3
|
+
width: number | null;
|
|
4
|
+
height: number | null;
|
|
5
|
+
tbr: number | null;
|
|
6
|
+
format_id: string;
|
|
7
|
+
url: string;
|
|
8
|
+
vcodec: string;
|
|
9
|
+
http_headers: Record<string, string>;
|
|
10
|
+
protocol: string;
|
|
11
|
+
resolution: string;
|
|
12
|
+
aspect_ratio: number | null;
|
|
13
|
+
audio_ext: string;
|
|
14
|
+
video_ext: string;
|
|
15
|
+
format: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface KeyframeInfo {
|
|
19
|
+
path: string;
|
|
20
|
+
description: string;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class RequestedDownload {
|
|
25
|
+
ext: string;
|
|
26
|
+
format_id: string;
|
|
27
|
+
url: string;
|
|
28
|
+
vcodec: string;
|
|
29
|
+
http_headers: Record<string, string>;
|
|
30
|
+
protocol: string;
|
|
31
|
+
resolution: string;
|
|
32
|
+
audio_ext: string;
|
|
33
|
+
video_ext: string;
|
|
34
|
+
format: string;
|
|
35
|
+
epoch: number;
|
|
36
|
+
_filename: string;
|
|
37
|
+
__write_download_archive: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export class DownloadInfo {
|
|
41
|
+
id: string;
|
|
42
|
+
title: string;
|
|
43
|
+
timestamp: Date | null;
|
|
44
|
+
description: string | null;
|
|
45
|
+
thumbnail: string | null;
|
|
46
|
+
age_limit: number;
|
|
47
|
+
formats: AudioFormat[];
|
|
48
|
+
subtitles: Record<string, string>;
|
|
49
|
+
_old_archive_ids: string[];
|
|
50
|
+
extractor: string;
|
|
51
|
+
extractor_key: string;
|
|
52
|
+
webpage_url: string;
|
|
53
|
+
original_url: string;
|
|
54
|
+
webpage_url_basename: string;
|
|
55
|
+
webpage_url_domain: string;
|
|
56
|
+
playlist: string | null;
|
|
57
|
+
playlist_index: number | null;
|
|
58
|
+
display_id: string;
|
|
59
|
+
fulltitle: string;
|
|
60
|
+
requested_subtitles: Record<string, string> | null;
|
|
61
|
+
_has_drm: boolean | null;
|
|
62
|
+
requested_downloads: RequestedDownload[];
|
|
63
|
+
ext: string;
|
|
64
|
+
width: number | null;
|
|
65
|
+
height: number | null;
|
|
66
|
+
tbr: number | null;
|
|
67
|
+
format_id: string;
|
|
68
|
+
url: string;
|
|
69
|
+
vcodec: string;
|
|
70
|
+
http_headers: Record<string, string>;
|
|
71
|
+
protocol: string;
|
|
72
|
+
resolution: string;
|
|
73
|
+
aspect_ratio: number | null;
|
|
74
|
+
audio_ext: string;
|
|
75
|
+
video_ext: string;
|
|
76
|
+
format: string;
|
|
77
|
+
epoch: number;
|
|
78
|
+
_type: string;
|
|
79
|
+
_version: {
|
|
80
|
+
version: string;
|
|
81
|
+
current_git_head: string | null;
|
|
82
|
+
release_git_head: string;
|
|
83
|
+
repository: string;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getConfig } from "../config";
|
|
2
|
+
import {
|
|
3
|
+
getConfiguredEmbeddings,
|
|
4
|
+
queryEmbedding,
|
|
5
|
+
pruneVector,
|
|
6
|
+
pruneMetadata,
|
|
7
|
+
} from "../embeddings";
|
|
8
|
+
|
|
9
|
+
import { Plugin } from "./types";
|
|
10
|
+
|
|
11
|
+
export class EmbeddingPlugin implements Plugin {
|
|
12
|
+
async embed() {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async call(userPrompt: string): Promise<string> {
|
|
17
|
+
const count = 7;
|
|
18
|
+
const embeddings = await getConfiguredEmbeddings();
|
|
19
|
+
const config = await getConfig();
|
|
20
|
+
const results = await queryEmbedding(
|
|
21
|
+
userPrompt,
|
|
22
|
+
embeddings,
|
|
23
|
+
config.embeddingModel
|
|
24
|
+
);
|
|
25
|
+
const context = results.slice(0, count);
|
|
26
|
+
|
|
27
|
+
pruneVector(context);
|
|
28
|
+
pruneMetadata(context);
|
|
29
|
+
|
|
30
|
+
for (const entry of context) {
|
|
31
|
+
console.log(`EMBEDDING PLUGIN: Reading entry ${entry.id}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const contextLength = JSON.stringify(context).split(" ").length;
|
|
35
|
+
console.log(
|
|
36
|
+
`EMBEDDING PLUGIN: Found ${context.length} entries. Loading ${contextLength} words`
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return `EMBEDDING PLUGIN: Our knowledgebase contains this information which can be used to answer the question:
|
|
40
|
+
${JSON.stringify(context)}`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Client } from "figma-js";
|
|
2
|
+
import qs from "qs"; // Assumed to be installed
|
|
3
|
+
import { Plugin } from "./types";
|
|
4
|
+
import { MinimalEmbedding } from "../types";
|
|
5
|
+
import { askGptVision } from "../ai";
|
|
6
|
+
|
|
7
|
+
interface Node {}
|
|
8
|
+
|
|
9
|
+
interface Component {}
|
|
10
|
+
|
|
11
|
+
interface ComponentSet {}
|
|
12
|
+
|
|
13
|
+
interface Style {}
|
|
14
|
+
|
|
15
|
+
interface FigmaNodeData {
|
|
16
|
+
document: Node;
|
|
17
|
+
components: Map<string, Component>;
|
|
18
|
+
componentSets: Map<string, ComponentSet>;
|
|
19
|
+
schemaVersion: number;
|
|
20
|
+
styles: Map<string, Style>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface FigmaApiResponse {
|
|
24
|
+
name: string;
|
|
25
|
+
role: string;
|
|
26
|
+
lastModified: string;
|
|
27
|
+
editorType: string;
|
|
28
|
+
thumbnailUrl: string;
|
|
29
|
+
err: string;
|
|
30
|
+
nodes: Record<string, FigmaNodeData>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class FigmaPlugin implements Plugin {
|
|
34
|
+
private figmaToken: string;
|
|
35
|
+
private client: ReturnType<typeof Client>;
|
|
36
|
+
|
|
37
|
+
constructor() {
|
|
38
|
+
this.figmaToken = process.env.FIGMA_API_KEY;
|
|
39
|
+
this.client = Client({ personalAccessToken: this.figmaToken });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async loadFigmaData(url: string) {
|
|
43
|
+
const fileId = this.extractFileIdFromUrl(url);
|
|
44
|
+
const nodeIds = this.parseNodeIdsFromUrl(url);
|
|
45
|
+
if (!fileId) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
console.log("Fetching figma data", { fileId, nodeIds });
|
|
50
|
+
const response = await this.client.fileImages(fileId, { ids: nodeIds });
|
|
51
|
+
return { id: fileId, ...response.data };
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error("Error fetching Figma file data:", error);
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
extractFileIdFromUrl(url: string): string | null {
|
|
59
|
+
const match = /https:\/\/www\.figma\.com\/file\/([A-Za-z0-9]+)/.exec(url);
|
|
60
|
+
return match ? match[1] : null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// New utility function for parsing node ids from Figma URL
|
|
64
|
+
parseNodeIdsFromUrl(url: string): string[] | null {
|
|
65
|
+
const queryIndex = url.indexOf("?");
|
|
66
|
+
if (queryIndex === -1) return null;
|
|
67
|
+
const queryStr = url.substring(queryIndex + 1);
|
|
68
|
+
const queryParams = qs.parse(queryStr);
|
|
69
|
+
const nodeParam = queryParams["node-id"];
|
|
70
|
+
let nodeIds = [];
|
|
71
|
+
if (Array.isArray(nodeParam)) {
|
|
72
|
+
nodeIds = nodeParam;
|
|
73
|
+
}
|
|
74
|
+
if (typeof nodeParam === "string") {
|
|
75
|
+
nodeIds = nodeParam.split(",");
|
|
76
|
+
}
|
|
77
|
+
return nodeIds || null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
extractUrls(userPrompt: string): string[] {
|
|
81
|
+
const urlRegex = /https:\/\/www\.figma\.com\/file\/[^\s]+/g;
|
|
82
|
+
const matches = userPrompt.match(urlRegex);
|
|
83
|
+
return matches || [];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async embed(userPrompt: string): Promise<MinimalEmbedding[]> {
|
|
87
|
+
const urls = this.extractUrls(userPrompt);
|
|
88
|
+
const figmaData = await Promise.all(
|
|
89
|
+
urls.map((url) => this.loadFigmaData(url))
|
|
90
|
+
);
|
|
91
|
+
const filteredData = figmaData.filter((data) => data !== null);
|
|
92
|
+
|
|
93
|
+
return filteredData.map((data) => ({
|
|
94
|
+
id: data.id,
|
|
95
|
+
text: this.formatFigmaData(data),
|
|
96
|
+
metadata: {},
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
formatFigmaData(data: any): string {
|
|
101
|
+
return JSON.stringify(data);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async call(userPrompt: string): Promise<string> {
|
|
105
|
+
const urls = this.extractUrls(userPrompt);
|
|
106
|
+
if (!urls || urls.length === 0) {
|
|
107
|
+
return "FIGMA PLUGIN: No Figma files found";
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const figmaData = await Promise.all(
|
|
111
|
+
urls.map((url) => this.loadFigmaData(url))
|
|
112
|
+
);
|
|
113
|
+
const figmaDataFiltered = figmaData.filter((data) => data !== null);
|
|
114
|
+
|
|
115
|
+
if (figmaDataFiltered.length === 0) {
|
|
116
|
+
return "FIGMA PLUGIN: Failed to fetch data for Figma files";
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const responses = [];
|
|
120
|
+
for (const data of figmaDataFiltered) {
|
|
121
|
+
for (const nodeId in data.images) {
|
|
122
|
+
const imageUrl = data.images[nodeId];
|
|
123
|
+
const imageDescription = await askGptVision(
|
|
124
|
+
imageUrl,
|
|
125
|
+
`Describe the image with relavant information for this user question: ${userPrompt}`
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
console.log("FIGMA PLUGIN: Image description", imageDescription);
|
|
129
|
+
responses.push({ nodeId, imageDescription });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return `FIGMA PLUGIN: The following Figma files were loaded:\n\n${JSON.stringify(
|
|
134
|
+
responses
|
|
135
|
+
)}`;
|
|
136
|
+
}
|
|
137
|
+
}
|