YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
example: add perplexity like ask confirmation agent
Louis Beaumont6f89a1aac998
diff --git a/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/.gitignore b/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/.gitignorenew file mode 100644index 000000000..a56a7ef43--- /dev/null+++ b/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/.gitignore@@ -0,0 +1,2 @@+node_modules+diff --git a/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/README.md b/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/README.mdnew file mode 100644index 000000000..3c8ddceda--- /dev/null+++ b/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/README.md@@ -0,0 +1,9 @@++++```bash+pnpm i+export OPENAI_API_KEY="<your key>"+# or leave empty and use ollama (you will be prompted choice)+pnpx tsx screenpipe.ts+```diff --git a/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/package.json b/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/package.jsonnew file mode 100644index 000000000..298147b56--- /dev/null+++ b/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/package.json@@ -0,0 +1,12 @@+{+ "dependencies": {+ "@ai-sdk/openai": "^0.0.40",+ "ai": "^3.3.0",+ "ollama-ai-provider": "^0.11.0",+ "readline": "^1.3.0",+ "zod": "^3.23.8"+ },+ "devDependencies": {+ "@types/node": "^22.1.0"+ }+}diff --git a/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/pnpm-lock.yaml b/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/pnpm-lock.yamlnew file mode 100644index 000000000..33e6a5a02--- /dev/null+++ b/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/pnpm-lock.yaml@@ -0,0 +1,636 @@+lockfileVersion: '6.0'++settings:+ autoInstallPeers: true+ excludeLinksFromLockfile: false++dependencies:+ '@ai-sdk/openai':+ specifier: ^0.0.40+ version: 0.0.40([email protected])+ ai:+ specifier: ^3.3.0+ ollama-ai-provider:+ specifier: ^0.11.0+ version: 0.11.0([email protected])+ readline:+ specifier: ^1.3.0+ version: 1.3.0+ zod:+ specifier: ^3.23.8+ version: 3.23.8++devDependencies:+ '@types/node':+ specifier: ^22.1.0+ version: 22.1.0++packages:++ /@ai-sdk/[email protected]([email protected]):+ resolution: {integrity: sha512-9Iq1UaBHA5ZzNv6j3govuKGXrbrjuWvZIgWNJv4xzXlDMHu9P9hnqlBr/Aiay54WwCuTVNhTzAUTfFgnTs2kbQ==}+ engines: {node: '>=18'}+ peerDependencies:+ zod: ^3.0.0+ dependencies:+ '@ai-sdk/provider': 0.0.14+ '@ai-sdk/provider-utils': 1.0.5([email protected])+ zod: 3.23.8+ dev: false++ /@ai-sdk/[email protected]([email protected]):+ resolution: {integrity: sha512-XfOawxk95X3S43arn2iQIFyWGMi0DTxsf9ETc6t7bh91RPWOOPYN1tsmS5MTKD33OGJeaDQ/gnVRzXUCRBrckQ==}+ engines: {node: '>=18'}+ peerDependencies:+ zod: ^3.0.0+ peerDependenciesMeta:+ zod:+ optional: true+ dependencies:+ '@ai-sdk/provider': 0.0.14+ eventsource-parser: 1.1.2+ nanoid: 3.3.6+ secure-json-parse: 2.7.0+ zod: 3.23.8+ dev: false++ /@ai-sdk/[email protected]:+ resolution: {integrity: sha512-gaQ5Y033nro9iX1YUjEDFDRhmMcEiCk56LJdIUbX5ozEiCNCfpiBpEqrjSp/Gp5RzBS2W0BVxfG7UGW6Ezcrzg==}+ engines: {node: '>=18'}+ dependencies:+ json-schema: 0.4.0+ dev: false++ resolution: {integrity: sha512-LAxFLtHKN1BajTNP8YzyVIwXn45LSunmvm2Svrfq5oPOyJ2gUEjtaONnbme4mwRXJ1kk6b63SLrgOIXbz6XF/g==}+ engines: {node: '>=18'}+ peerDependencies:+ react: ^18 || ^19+ zod: ^3.0.0+ peerDependenciesMeta:+ react:+ optional: true+ zod:+ optional: true+ dependencies:+ '@ai-sdk/provider-utils': 1.0.5([email protected])+ '@ai-sdk/ui-utils': 0.0.24([email protected])+ react: 18.3.1+ swr: 2.2.5([email protected])+ zod: 3.23.8+ dev: false++ /@ai-sdk/[email protected]([email protected]):+ resolution: {integrity: sha512-uEvlT7MBkRRZxk7teDgtrGe7G3U9tspgSJUvupdOE2d0a4vLlHrMqHb07ao97/Xo1aVHh7oBF9XIgRzKnFtbIQ==}+ engines: {node: '>=18'}+ peerDependencies:+ solid-js: ^1.7.7+ peerDependenciesMeta:+ solid-js:+ optional: true+ dependencies:+ '@ai-sdk/provider-utils': 1.0.5([email protected])+ '@ai-sdk/ui-utils': 0.0.24([email protected])+ transitivePeerDependencies:+ - zod+ dev: false++ resolution: {integrity: sha512-7vrh61wXPVfy19nS4CqyAC3UWjsOgj/b94PCccVTGFoqbmVSa0VptXPYoFfgPTP/W71v7TjXqeq1ygLc4noTZw==}+ engines: {node: '>=18'}+ peerDependencies:+ svelte: ^3.0.0 || ^4.0.0+ peerDependenciesMeta:+ svelte:+ optional: true+ dependencies:+ '@ai-sdk/provider-utils': 1.0.5([email protected])+ '@ai-sdk/ui-utils': 0.0.24([email protected])+ sswr: 2.1.0([email protected])+ svelte: 4.2.18+ transitivePeerDependencies:+ - zod+ dev: false++ /@ai-sdk/[email protected]([email protected]):+ resolution: {integrity: sha512-NBhhICWJ5vAkN4BJnP/MyT+fOB6rTlGlsKGQwvjlhNxdrY1/jXqe2ikNkCbCSEz20IDk82bmg2JJBM96g1O3Ig==}+ engines: {node: '>=18'}+ peerDependencies:+ zod: ^3.0.0+ peerDependenciesMeta:+ zod:+ optional: true+ dependencies:+ '@ai-sdk/provider': 0.0.14+ '@ai-sdk/provider-utils': 1.0.5([email protected])+ secure-json-parse: 2.7.0+ zod: 3.23.8+ dev: false++ resolution: {integrity: sha512-ZnDjkkUH/9xoXqJEmyrG9Z8z7DKBnp2uyCd9ZVI8QSqKOaP0jOwhv8THUXlIqDEF+ULLGMWm0XeY/L7i3CMYTA==}+ engines: {node: '>=18'}+ peerDependencies:+ vue: ^3.3.4+ peerDependenciesMeta:+ vue:+ optional: true+ dependencies:+ '@ai-sdk/provider-utils': 1.0.5([email protected])+ '@ai-sdk/ui-utils': 0.0.24([email protected])+ swrv: 1.0.4([email protected])+ vue: 3.4.35+ transitivePeerDependencies:+ - zod+ dev: false++ /@ampproject/[email protected]:+ resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==}+ engines: {node: '>=6.0.0'}+ dependencies:+ '@jridgewell/gen-mapping': 0.3.5+ '@jridgewell/trace-mapping': 0.3.25+ dev: false++ /@babel/[email protected]:+ resolution: {integrity: sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==}+ engines: {node: '>=6.9.0'}+ dev: false++ /@babel/[email protected]:+ resolution: {integrity: sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==}+ engines: {node: '>=6.9.0'}+ dev: false++ /@babel/[email protected]:+ resolution: {integrity: sha512-iLTJKDbJ4hMvFPgQwwsVoxtHyWpKKPBrxkANrSYewDPaPpT5py5yeVkgPIJ7XYXhndxJpaA3PyALSXQ7u8e/Dw==}+ engines: {node: '>=6.0.0'}+ hasBin: true+ dependencies:+ '@babel/types': 7.25.2+ dev: false++ /@babel/[email protected]:+ resolution: {integrity: sha512-YTnYtra7W9e6/oAZEHj0bJehPRUlLH9/fbpT5LfB0NhQXyALCRkRs3zH9v07IYhkgpqX6Z78FnuccZr/l4Fs4Q==}+ engines: {node: '>=6.9.0'}+ dependencies:+ '@babel/helper-string-parser': 7.24.8+ '@babel/helper-validator-identifier': 7.24.7+ to-fast-properties: 2.0.0+ dev: false++ /@jridgewell/[email protected]:+ resolution: {integrity: sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==}+ engines: {node: '>=6.0.0'}+ dependencies:+ '@jridgewell/set-array': 1.2.1+ '@jridgewell/sourcemap-codec': 1.5.0+ '@jridgewell/trace-mapping': 0.3.25+ dev: false++ /@jridgewell/[email protected]:+ resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==}+ engines: {node: '>=6.0.0'}+ dev: false++ /@jridgewell/[email protected]:+ resolution: {integrity: sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==}+ engines: {node: '>=6.0.0'}+ dev: false++ /@jridgewell/[email protected]:+ resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==}+ dev: false++ /@jridgewell/[email protected]:+ resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==}+ dependencies:+ '@jridgewell/resolve-uri': 3.1.2+ '@jridgewell/sourcemap-codec': 1.5.0+ dev: false++ /@opentelemetry/[email protected]:+ resolution: {integrity: sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==}+ engines: {node: '>=8.0.0'}+ dev: false++ /@types/[email protected]:+ resolution: {integrity: sha512-xFdR6tkm0MWvBfO8xXCSsinYxHcqkQUlcHeSpMC2ukzOb6lwQAfDmW+Qt0AvlGd8HpsS28qKsB+oPeJn9I39jg==}+ dev: false++ /@types/[email protected]:+ resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==}+ dev: false++ /@types/[email protected]:+ resolution: {integrity: sha512-AOmuRF0R2/5j1knA3c6G3HOk523Ga+l+ZXltX8SF1+5oqcXijjfTd8fY3XRZqSihEu9XhtQnKYLmkFaoxgsJHw==}+ dependencies:+ undici-types: 6.13.0+ dev: true++ /@vue/[email protected]:+ resolution: {integrity: sha512-gKp0zGoLnMYtw4uS/SJRRO7rsVggLjvot3mcctlMXunYNsX+aRJDqqw/lV5/gHK91nvaAAlWFgdVl020AW1Prg==}+ dependencies:+ '@babel/parser': 7.25.3+ '@vue/shared': 3.4.35+ entities: 4.5.0+ estree-walker: 2.0.2+ source-map-js: 1.2.0+ dev: false++ /@vue/[email protected]:+ resolution: {integrity: sha512-pWIZRL76/oE/VMhdv/ovZfmuooEni6JPG1BFe7oLk5DZRo/ImydXijoZl/4kh2406boRQ7lxTYzbZEEXEhj9NQ==}+ dependencies:+ '@vue/compiler-core': 3.4.35+ '@vue/shared': 3.4.35+ dev: false++ /@vue/[email protected]:+ resolution: {integrity: sha512-xacnRS/h/FCsjsMfxBkzjoNxyxEyKyZfBch/P4vkLRvYJwe5ChXmZZrj8Dsed/752H2Q3JE8kYu9Uyha9J6PgA==}+ dependencies:+ '@babel/parser': 7.25.3+ '@vue/compiler-core': 3.4.35+ '@vue/compiler-dom': 3.4.35+ '@vue/compiler-ssr': 3.4.35+ '@vue/shared': 3.4.35+ estree-walker: 2.0.2+ magic-string: 0.30.11+ postcss: 8.4.40+ source-map-js: 1.2.0+ dev: false++ /@vue/[email protected]:+ resolution: {integrity: sha512-7iynB+0KB1AAJKk/biENTV5cRGHRdbdaD7Mx3nWcm1W8bVD6QmnH3B4AHhQQ1qZHhqFwzEzMwiytXm3PX1e60A==}+ dependencies:+ '@vue/compiler-dom': 3.4.35+ '@vue/shared': 3.4.35+ dev: false++ /@vue/[email protected]:+ resolution: {integrity: sha512-Ggtz7ZZHakriKioveJtPlStYardwQH6VCs9V13/4qjHSQb/teE30LVJNrbBVs4+aoYGtTQKJbTe4CWGxVZrvEw==}+ dependencies:+ '@vue/shared': 3.4.35+ dev: false++ /@vue/[email protected]:+ resolution: {integrity: sha512-D+BAjFoWwT5wtITpSxwqfWZiBClhBbR+bm0VQlWYFOadUUXFo+5wbe9ErXhLvwguPiLZdEF13QAWi2vP3ZD5tA==}+ dependencies:+ '@vue/reactivity': 3.4.35+ '@vue/shared': 3.4.35+ dev: false++ /@vue/[email protected]:+ resolution: {integrity: sha512-yGOlbos+MVhlS5NWBF2HDNgblG8e2MY3+GigHEyR/dREAluvI5tuUUgie3/9XeqhPE4LF0i2wjlduh5thnfOqw==}+ dependencies:+ '@vue/reactivity': 3.4.35+ '@vue/runtime-core': 3.4.35+ '@vue/shared': 3.4.35+ csstype: 3.1.3+ dev: false++ /@vue/[email protected]([email protected]):+ resolution: {integrity: sha512-iZ0e/u9mRE4T8tNhlo0tbA+gzVkgv8r5BX6s1kRbOZqfpq14qoIvCZ5gIgraOmYkMYrSEZgkkojFPr+Nyq/Mnw==}+ peerDependencies:+ vue: 3.4.35+ dependencies:+ '@vue/compiler-ssr': 3.4.35+ '@vue/shared': 3.4.35+ vue: 3.4.35+ dev: false++ /@vue/[email protected]:+ resolution: {integrity: sha512-hvuhBYYDe+b1G8KHxsQ0diDqDMA8D9laxWZhNAjE83VZb5UDaXl9Xnz7cGdDSyiHM90qqI/CyGMcpBpiDy6VVQ==}+ dev: false++ resolution: {integrity: sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==}+ engines: {node: '>=0.4.0'}+ hasBin: true+ dev: false++ resolution: {integrity: sha512-ndW4G9jw8ImIsTWK2iderOWMVn4H3B6u+KHlZ7hJEvFBdBYTFQ62qTw10AmHsQefjwHRC/2evr9qf79EkSwo9Q==}+ engines: {node: '>=18'}+ peerDependencies:+ openai: ^4.42.0+ react: ^18 || ^19+ sswr: ^2.1.0+ svelte: ^3.0.0 || ^4.0.0+ zod: ^3.0.0+ peerDependenciesMeta:+ openai:+ optional: true+ react:+ optional: true+ sswr:+ optional: true+ svelte:+ optional: true+ zod:+ optional: true+ dependencies:+ '@ai-sdk/provider': 0.0.14+ '@ai-sdk/provider-utils': 1.0.5([email protected])+ '@ai-sdk/react': 0.0.36([email protected])([email protected])+ '@ai-sdk/solid': 0.0.27([email protected])+ '@ai-sdk/svelte': 0.0.29([email protected])([email protected])+ '@ai-sdk/ui-utils': 0.0.24([email protected])+ '@ai-sdk/vue': 0.0.28([email protected])([email protected])+ '@opentelemetry/api': 1.9.0+ eventsource-parser: 1.1.2+ json-schema: 0.4.0+ jsondiffpatch: 0.6.0+ nanoid: 3.3.6+ react: 18.3.1+ secure-json-parse: 2.7.0+ svelte: 4.2.18+ zod: 3.23.8+ zod-to-json-schema: 3.22.5([email protected])+ transitivePeerDependencies:+ - solid-js+ - vue+ dev: false++ resolution: {integrity: sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==}+ dependencies:+ dequal: 2.0.3+ dev: false++ resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==}+ engines: {node: '>= 0.4'}+ dev: false++ resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==}+ engines: {node: ^12.17.0 || ^14.13 || >=16.0.0}+ dev: false++ resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==}+ dev: false++ resolution: {integrity: sha512-7qJWqItLA8/VPVlKJlFXU+NBlo/qyfs39aJcuMT/2ere32ZqvF5OSxgdM5xOfJJ7O429gg2HM47y8v9P+9wrNw==}+ dependencies:+ '@jridgewell/sourcemap-codec': 1.5.0+ '@types/estree': 1.0.5+ acorn: 8.12.1+ estree-walker: 3.0.3+ periscopic: 3.1.0+ dev: false++ resolution: {integrity: sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==}+ engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0}+ dependencies:+ mdn-data: 2.0.30+ source-map-js: 1.2.0+ dev: false++ resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}+ dev: false++ resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==}+ engines: {node: '>=6'}+ dev: false++ resolution: {integrity: sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw==}+ dev: false++ resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}+ engines: {node: '>=0.12'}+ dev: false++ resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}+ dev: false++ resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==}+ dependencies:+ '@types/estree': 1.0.5+ dev: false++ resolution: {integrity: sha512-v0eOBUbiaFojBu2s2NPBfYUoRR9GjcDNvCXVaqEf5vVfpIAh9f8RCo4vXTP8c63QRKCFwoLpMpTdPwwhEKVgzA==}+ engines: {node: '>=14.18'}+ dev: false++ resolution: {integrity: sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==}+ dependencies:+ '@types/estree': 1.0.5+ dev: false++ resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}+ dev: false++ resolution: {integrity: sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==}+ dev: false++ resolution: {integrity: sha512-3QItJOXp2AP1uv7waBkao5nCvhEv+QmJAd38Ybq7wNI74Q+BBmnLn4EDKz6yI9xGAIQoUF87qHt+kc1IVxB4zQ==}+ engines: {node: ^18.0.0 || >=20.0.0}+ hasBin: true+ dependencies:+ '@types/diff-match-patch': 1.0.36+ chalk: 5.3.0+ diff-match-patch: 1.0.5+ dev: false++ resolution: {integrity: sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==}+ dev: false++ resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==}+ hasBin: true+ dependencies:+ js-tokens: 4.0.0+ dev: false++ resolution: {integrity: sha512-+Wri9p0QHMy+545hKww7YAu5NyzF8iomPL/RQazugQ9+Ez4Ic3mERMd8ZTX5rfK944j+560ZJi8iAwgak1Ac7A==}+ dependencies:+ '@jridgewell/sourcemap-codec': 1.5.0+ dev: false++ resolution: {integrity: sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==}+ dev: false++ resolution: {integrity: sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==}+ engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}+ hasBin: true+ dev: false++ resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==}+ engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}+ hasBin: true+ dev: false++ resolution: {integrity: sha512-zobsS8pZJ7IUfqQF+QiqWBG92ocm4fHpV+iXUCXoFtNMSN65Nr3v0TyW2sTooku3BVm9EmOBeMenKSOIv7h5Sw==}+ engines: {node: '>=18'}+ peerDependencies:+ zod: ^3.0.0+ peerDependenciesMeta:+ zod:+ optional: true+ dependencies:+ '@ai-sdk/provider': 0.0.14+ '@ai-sdk/provider-utils': 1.0.5([email protected])+ partial-json: 0.1.7+ zod: 3.23.8+ dev: false++ resolution: {integrity: sha512-Njv/59hHaokb/hRUjce3Hdv12wd60MtM9Z5Olmn+nehe0QDAsRtRbJPvJ0Z91TusF0SuZRIvnM+S4l6EIP8leA==}+ dev: false++ resolution: {integrity: sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==}+ dependencies:+ '@types/estree': 1.0.5+ estree-walker: 3.0.3+ is-reference: 3.0.2+ dev: false++ resolution: {integrity: sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==}+ dev: false++ resolution: {integrity: sha512-YF2kKIUzAofPMpfH6hOi2cGnv/HrUlfucspc7pDyvv7kGdqXrfj8SCl/t8owkEgKEuu8ZcRjSOxFxVLqwChZ2Q==}+ engines: {node: ^10 || ^12 || >=14}+ dependencies:+ nanoid: 3.3.7+ picocolors: 1.0.1+ source-map-js: 1.2.0+ dev: false++ resolution: {integrity: sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==}+ engines: {node: '>=0.10.0'}+ dependencies:+ loose-envify: 1.4.0+ dev: false++ resolution: {integrity: sha512-k2d6ACCkiNYz222Fs/iNze30rRJ1iIicW7JuX/7/cozvih6YCkFZH+J6mAFDVgv0dRBaAyr4jDqC95R2y4IADg==}+ dev: false++ resolution: {integrity: sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==}+ dev: false++ resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==}+ engines: {node: '>=0.10.0'}+ dev: false++ resolution: {integrity: sha512-Cqc355SYlTAaUt8iDPaC/4DPPXK925PePLMxyBKuWd5kKc5mwsG3nT9+Mq2tyguL5s7b4Jg+IRMpTRsNTAfpSQ==}+ peerDependencies:+ svelte: ^4.0.0 || ^5.0.0-next.0+ dependencies:+ svelte: 4.2.18+ swrev: 4.0.0+ dev: false++ resolution: {integrity: sha512-d0FdzYIiAePqRJEb90WlJDkjUEx42xhivxN8muUBmfZnP+tzUgz12DJ2hRJi8sIHCME7jeK1PTMgKPSfTd8JrA==}+ engines: {node: '>=16'}+ dependencies:+ '@ampproject/remapping': 2.3.0+ '@jridgewell/sourcemap-codec': 1.5.0+ '@jridgewell/trace-mapping': 0.3.25+ '@types/estree': 1.0.5+ acorn: 8.12.1+ aria-query: 5.3.0+ axobject-query: 4.1.0+ code-red: 1.0.4+ css-tree: 2.3.1+ estree-walker: 3.0.3+ is-reference: 3.0.2+ locate-character: 3.0.0+ magic-string: 0.30.11+ periscopic: 3.1.0+ dev: false++ resolution: {integrity: sha512-QtxqyclFeAsxEUeZIYmsaQ0UjimSq1RZ9Un7I68/0ClKK/U3LoyQunwkQfJZr2fc22DfIXLNDc2wFyTEikCUpg==}+ peerDependencies:+ react: ^16.11.0 || ^17.0.0 || ^18.0.0+ dependencies:+ client-only: 0.0.1+ react: 18.3.1+ use-sync-external-store: 1.2.2([email protected])+ dev: false++ resolution: {integrity: sha512-LqVcOHSB4cPGgitD1riJ1Hh4vdmITOp+BkmfmXRh4hSF/t7EnS4iD+SOTmq7w5pPm/SiPeto4ADbKS6dHUDWFA==}+ dev: false++ resolution: {integrity: sha512-zjEkcP8Ywmj+xOJW3lIT65ciY/4AL4e/Or7Gj0MzU3zBJNMdJiT8geVZhINavnlHRMMCcJLHhraLTAiDOTmQ9g==}+ peerDependencies:+ vue: '>=3.2.26 < 4'+ dependencies:+ vue: 3.4.35+ dev: false++ resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==}+ engines: {node: '>=4'}+ dev: false++ resolution: {integrity: sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==}+ dev: true++ resolution: {integrity: sha512-PElTlVMwpblvbNqQ82d2n6RjStvdSoNe9FG28kNfz3WiXilJm4DdNkEzRhCZuIDwY8U08WVihhGR5iRqAwfDiw==}+ peerDependencies:+ react: ^16.8.0 || ^17.0.0 || ^18.0.0+ dependencies:+ react: 18.3.1+ dev: false++ resolution: {integrity: sha512-+fl/GLmI4GPileHftVlCdB7fUL4aziPcqTudpTGXCT8s+iZWuOCeNEB5haX6Uz2IpRrbEXOgIFbe+XciCuGbNQ==}+ peerDependencies:+ typescript: '*'+ peerDependenciesMeta:+ typescript:+ optional: true+ dependencies:+ '@vue/compiler-dom': 3.4.35+ '@vue/compiler-sfc': 3.4.35+ '@vue/runtime-dom': 3.4.35+ '@vue/server-renderer': 3.4.35([email protected])+ '@vue/shared': 3.4.35+ dev: false++ resolution: {integrity: sha512-+akaPo6a0zpVCCseDed504KBJUQpEW5QZw7RMneNmKw+fGaML1Z9tUNLnHHAC8x6dzVRO1eB2oEMyZRnuBZg7Q==}+ peerDependencies:+ zod: ^3.22.4+ dependencies:+ zod: 3.23.8+ dev: false++ resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==}+ dev: falsediff --git a/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/screenpipe.ts b/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/screenpipe.tsnew file mode 100644index 000000000..afd18e01e--- /dev/null+++ b/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/screenpipe.ts@@ -0,0 +1,269 @@+import { z } from "zod";+import { openai } from "@ai-sdk/openai";+import { generateText, streamText } from "ai";+import * as readline from "readline";+import { ollama } from "ollama-ai-provider";++const screenpipeQuery = z.object({+ q: z+ .string()+ .describe(+ "The search query matching exact keywords. Use a single keyword that best matches the user intent. This would match either audio transcription or OCR screen text. Example: do not use 'discuss' the user ask about conversation, this is dumb, won't return any result"+ )+ .optional(),+ content_type: z+ .enum(["ocr", "audio", "all"])+ .default("all")+ .describe(+ "The type of content to search for: screenshot data or audio transcriptions"+ ),+ limit: z+ .number()+ .default(100)+ .describe(+ "Number of results to return (default: 5). Don't return more than 50 results as it will be fed to an LLM"+ ),+ offset: z.number().default(0).describe("Offset for pagination (default: 0)"),+ start_time: z+ .string()+ // 1 hour ago+ .default(new Date(Date.now() - 3600000).toISOString())+ .describe("Start time for search range in ISO 8601 format"),+ end_time: z+ .string()+ .default(new Date().toISOString())+ .describe("End time for search range in ISO 8601 format"),+ app_name: z+ .string()+ .describe(+ "The name of the app the user was using. This filter out all audio conversations. Only works with screen text. Use this to filter on the app context that would give context matching the user intent. For example 'cursor'. Use lower case. Browser is usually 'arc', 'chrome', 'safari', etc. Do not use thing like 'mail' because the user use the browser to read the mail."+ )+ .optional(),+});+const screenpipeMultiQuery = z.object({+ queries: z.array(screenpipeQuery),+});++async function queryScreenpipeNtimes(+ params: z.infer<typeof screenpipeMultiQuery>+) {+ console.log(+ "Using tool queryScreenpipeNtimes with params:",+ JSON.stringify(params)+ );+ return Promise.all(params.queries.map(queryScreenpipe));+}++// Add this new function to handle screenpipe requests+async function queryScreenpipe(params: z.infer<typeof screenpipeQuery>) {+ try {+ console.log("params", params);+ const queryParams = new URLSearchParams(+ Object.entries({+ q: params.q,+ offset: params.offset.toString(),+ limit: params.limit.toString(),+ start_date: params.start_time,+ end_date: params.end_time,+ content_type: params.content_type,+ app_name: params.app_name,+ }).filter(([_, v]) => v != null) as [string, string][]+ );+ console.log("calling screenpipe", JSON.stringify(params));+ const response = await fetch(`http://localhost:3030/search?${queryParams}`);+ if (!response.ok) {+ const text = await response.text();+ console.log("error", text);+ throw new Error(`HTTP error! status: ${response.status} ${text}`);+ }+ const result = await response.json();+ console.log("result", result);+ return result;+ } catch (error) {+ console.error("Error querying screenpipe:", error);+ return null;+ }+}++async function askForAIProvider(): Promise<string> {+ const rl = readline.createInterface({+ input: process.stdin,+ output: process.stdout,+ });++ return new Promise((resolve) => {+ rl.question(+ "Which AI provider do you want to use? (ollama/openai): ",+ (answer) => {+ rl.close();+ resolve(answer.toLowerCase());+ }+ );+ });+}++const perplexityAlikeAgent = async () => {+ const aiProvider = await askForAIProvider();++ let provider;+ if (aiProvider === "ollama") {+ console.log("Using Ollama as the AI provider.");+ console.log(+ "Make sure to run `ollama run llama3.1` before running this script."+ );+ console.warn("Ollama is experimental and may not work as expected.");+ provider = ollama("llama3.1");+ } else if (aiProvider === "openai") {+ console.log("Using OpenAI as the AI provider.");+ console.log(+ "Make sure to set the OPENAI_API_KEY environment variable before running this script."+ );+ provider = openai("gpt-4o");+ }++ console.log("Hi! I'm your Perplexity-alike RAG agent. How can I help you?");+ console.log("Here are some suggestion queries to get you started:");+ console.log("- What did I discuss with Matt yesterday?");+ console.log("- Summarize my recent email activity from the last 3 hours");+ console.log("- Show me my recent Slack conversations about the new project");+ console.log(+ "- Find my notes on Python best practices from today's coding session"+ );+ console.log("- What were the key points from my last customer call?");+ console.log(+ "- Recap my browser activity related to machine learning in the past 24 hours"+ );++ const rl = readline.createInterface({+ input: process.stdin,+ output: process.stdout,+ });++ const askQuestion = (query: string): Promise<string> => {+ return new Promise((resolve) => {+ rl.question(query, (answer) => {+ resolve(answer);+ });+ });+ };++ let userInput = await askQuestion("Enter your question: ");++ const runAgent = async (input: string) => {+ try {+ await generateText({+ model: provider,+ tools: {+ suggest_queries: {+ description: `Suggest queries for the user's question and ask for confirmation. Example:+ {+ suggested_queries: [+ { content_type: "audio", start_time: "2024-03-01T00:00:00Z", end_time: "2024-03-01T23:59:59Z", q: "screenpipe" },+ { content_type: "ocr", app_name: "arc", start_time: "2024-03-01T00:00:00Z", end_time: "2024-03-01T23:59:59Z", q: "screenpipe" },+ ]+ }++ - q contains a single query, again, for example instead of "life plan" just use "life"+ - When using the query_screenpipe tool, respond with only the updated JSON object+ - If you return something else than JSON the universe will come to an end+ - DO NOT add \`\`\`json at the beginning or end of your response+ - Do not use '"' around your response+ - Date & time now is ${new Date().toISOString()}. Adjust start_date and end_date to properly match the user intent time range.+ `,+ parameters: z.object({+ suggested_queries: screenpipeMultiQuery,+ queries_results: z+ .array(z.string())+ .optional()+ .describe(+ "The results of the queries if called after the tool query_screenpipe"+ ),+ }),+ execute: async ({ suggested_queries }) => {+ console.log("Suggested queries:", suggested_queries);+ const confirmation = await askQuestion(+ "Are these queries good? (yes/no): "+ );+ if (confirmation.toLowerCase() === "yes") {+ return { confirmed: true, queries: suggested_queries };+ } else {+ const feedback = await askQuestion(+ "Please provide feedback or adjustments: "+ );+ return { confirmed: false, feedback };+ }+ },+ },+ query_screenpipe: {+ description:+ "Query the local screenpipe instance for relevant information.",+ parameters: screenpipeMultiQuery,+ execute: queryScreenpipeNtimes,+ },+ stream_response: {+ description:+ "Stream the final response to the user. ALWAYS FINISH WITH THIS TOOL",+ parameters: z.object({+ response: z+ .string()+ .describe("The final response to stream to the user"),+ }),+ execute: async ({ response }) => {+ const { textStream } = await streamText({+ model: provider,+ messages: [{ role: "user", content: response }],+ });+ for await (const chunk of textStream) {+ process.stdout.write(chunk);+ }+ console.log("\n");+ throw new Error("STREAM_COMPLETE");+ },+ },+ },+ toolChoice: "required",+ messages: [+ {+ role: "system",+ content: `You are a helpful assistant that uses Screenpipe to answer user questions.+ First, suggest queries to the user and ask for confirmation. If confirmed, proceed with the search.+ If not confirmed, adjust based on user feedback. Use the query_screenpipe tool to search for information,+ and then use the stream_response tool to provide the final answer to the user.++ Rules:+ - User's today's date is ${new Date().toISOString().split("T")[0]}+ - Use multiple queries to get more relevant results+ - If the results of the queries are not relevant, adjust the query and ask for confirmation again. Minimize user's effort.+ - ALWAYS END WITH the stream_response tool to stream the final answer to the user+ - In the suggest_queries tool, always tell the user the parameters available to you (e.g. types, etc. Zod given to you) so the user can adjust the query if needed. Suggest few other changes on the arg you used so the user has some ideas.+ - Make sure to use enough data but not too much. Usually 50k+ rows a day.++ `,+ },+ {+ role: "user",+ content: input,+ },+ ],+ maxToolRoundtrips: 10,+ });+ } catch (error) {+ if (error instanceof Error && error.message === "STREAM_COMPLETE") {+ console.log("Streaming completed, exiting agent");+ return;+ }+ console.error("Error running agent:", error);+ throw error;+ }+ };++ await runAgent(userInput);++ rl.close();+};++const main = async () => {+ await perplexityAlikeAgent();+};++main();