@soederpop/luca 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +71 -0
- package/README.md +78 -0
- package/bun.lock +2928 -0
- package/bunfig.toml +3 -0
- package/commands/audit-docs.ts +740 -0
- package/commands/build-scaffolds.ts +154 -0
- package/commands/generate-api-docs.ts +114 -0
- package/commands/update-introspection.ts +67 -0
- package/docs/CLI.md +335 -0
- package/docs/README.md +88 -0
- package/docs/TABLE-OF-CONTENTS.md +157 -0
- package/docs/apis/clients/elevenlabs.md +84 -0
- package/docs/apis/clients/graph.md +56 -0
- package/docs/apis/clients/openai.md +69 -0
- package/docs/apis/clients/rest.md +41 -0
- package/docs/apis/clients/websocket.md +107 -0
- package/docs/apis/features/agi/assistant.md +471 -0
- package/docs/apis/features/agi/assistants-manager.md +154 -0
- package/docs/apis/features/agi/claude-code.md +602 -0
- package/docs/apis/features/agi/conversation-history.md +352 -0
- package/docs/apis/features/agi/conversation.md +333 -0
- package/docs/apis/features/agi/docs-reader.md +121 -0
- package/docs/apis/features/agi/openai-codex.md +318 -0
- package/docs/apis/features/agi/openapi.md +138 -0
- package/docs/apis/features/agi/semantic-search.md +387 -0
- package/docs/apis/features/agi/skills-library.md +216 -0
- package/docs/apis/features/node/container-link.md +133 -0
- package/docs/apis/features/node/content-db.md +313 -0
- package/docs/apis/features/node/disk-cache.md +379 -0
- package/docs/apis/features/node/dns.md +651 -0
- package/docs/apis/features/node/docker.md +705 -0
- package/docs/apis/features/node/downloader.md +81 -0
- package/docs/apis/features/node/esbuild.md +59 -0
- package/docs/apis/features/node/file-manager.md +182 -0
- package/docs/apis/features/node/fs.md +581 -0
- package/docs/apis/features/node/git.md +330 -0
- package/docs/apis/features/node/google-auth.md +174 -0
- package/docs/apis/features/node/google-calendar.md +187 -0
- package/docs/apis/features/node/google-docs.md +151 -0
- package/docs/apis/features/node/google-drive.md +225 -0
- package/docs/apis/features/node/google-sheets.md +179 -0
- package/docs/apis/features/node/grep.md +290 -0
- package/docs/apis/features/node/helpers.md +135 -0
- package/docs/apis/features/node/ink.md +334 -0
- package/docs/apis/features/node/ipc-socket.md +260 -0
- package/docs/apis/features/node/json-tree.md +86 -0
- package/docs/apis/features/node/launcher-app-command-listener.md +145 -0
- package/docs/apis/features/node/networking.md +281 -0
- package/docs/apis/features/node/nlp.md +133 -0
- package/docs/apis/features/node/opener.md +97 -0
- package/docs/apis/features/node/os.md +118 -0
- package/docs/apis/features/node/package-finder.md +402 -0
- package/docs/apis/features/node/postgres.md +212 -0
- package/docs/apis/features/node/proc.md +430 -0
- package/docs/apis/features/node/process-manager.md +210 -0
- package/docs/apis/features/node/python.md +278 -0
- package/docs/apis/features/node/repl.md +88 -0
- package/docs/apis/features/node/runpod.md +673 -0
- package/docs/apis/features/node/secure-shell.md +169 -0
- package/docs/apis/features/node/semantic-search.md +401 -0
- package/docs/apis/features/node/sqlite.md +211 -0
- package/docs/apis/features/node/telegram.md +254 -0
- package/docs/apis/features/node/tts.md +118 -0
- package/docs/apis/features/node/ui.md +703 -0
- package/docs/apis/features/node/vault.md +64 -0
- package/docs/apis/features/node/vm.md +84 -0
- package/docs/apis/features/node/window-manager.md +337 -0
- package/docs/apis/features/node/yaml-tree.md +85 -0
- package/docs/apis/features/node/yaml.md +176 -0
- package/docs/apis/features/web/asset-loader.md +47 -0
- package/docs/apis/features/web/container-link.md +133 -0
- package/docs/apis/features/web/esbuild.md +59 -0
- package/docs/apis/features/web/helpers.md +135 -0
- package/docs/apis/features/web/network.md +30 -0
- package/docs/apis/features/web/speech.md +55 -0
- package/docs/apis/features/web/vault.md +64 -0
- package/docs/apis/features/web/vm.md +84 -0
- package/docs/apis/features/web/voice.md +67 -0
- package/docs/apis/servers/express.md +127 -0
- package/docs/apis/servers/mcp.md +213 -0
- package/docs/apis/servers/websocket.md +99 -0
- package/docs/documentation-audit.md +134 -0
- package/docs/examples/content-db.md +77 -0
- package/docs/examples/disk-cache.md +83 -0
- package/docs/examples/docker.md +101 -0
- package/docs/examples/downloader.md +70 -0
- package/docs/examples/esbuild.md +80 -0
- package/docs/examples/file-manager.md +82 -0
- package/docs/examples/fs.md +83 -0
- package/docs/examples/git.md +85 -0
- package/docs/examples/google-auth.md +88 -0
- package/docs/examples/google-calendar.md +94 -0
- package/docs/examples/google-docs.md +82 -0
- package/docs/examples/google-drive.md +96 -0
- package/docs/examples/google-sheets.md +95 -0
- package/docs/examples/grep.md +85 -0
- package/docs/examples/ink-blocks.md +75 -0
- package/docs/examples/ink-renderer.md +41 -0
- package/docs/examples/ink.md +103 -0
- package/docs/examples/ipc-socket.md +103 -0
- package/docs/examples/json-tree.md +91 -0
- package/docs/examples/launcher-app-command-listener.md +120 -0
- package/docs/examples/networking.md +58 -0
- package/docs/examples/nlp.md +91 -0
- package/docs/examples/opener.md +78 -0
- package/docs/examples/os.md +72 -0
- package/docs/examples/package-finder.md +89 -0
- package/docs/examples/port-exposer.md +89 -0
- package/docs/examples/postgres.md +91 -0
- package/docs/examples/proc.md +81 -0
- package/docs/examples/process-manager.md +79 -0
- package/docs/examples/python.md +91 -0
- package/docs/examples/repl.md +93 -0
- package/docs/examples/runpod.md +119 -0
- package/docs/examples/secure-shell.md +92 -0
- package/docs/examples/sqlite.md +86 -0
- package/docs/examples/telegram.md +77 -0
- package/docs/examples/tts.md +86 -0
- package/docs/examples/ui.md +80 -0
- package/docs/examples/vault.md +70 -0
- package/docs/examples/vm.md +86 -0
- package/docs/examples/window-manager.md +125 -0
- package/docs/examples/yaml-tree.md +93 -0
- package/docs/examples/yaml.md +104 -0
- package/docs/ideas/class-registration-refactor-possibilities.md +197 -0
- package/docs/ideas/container-use-api.md +9 -0
- package/docs/ideas/easy-auth-for-express-servers-and-luca-serve.md +0 -0
- package/docs/ideas/feature-stacks.md +22 -0
- package/docs/ideas/luca-cli-self-sufficiency-demo.md +23 -0
- package/docs/ideas/mcp-design.md +9 -0
- package/docs/ideas/web-container-debugging-feature.md +13 -0
- package/docs/introspection-audit.md +49 -0
- package/docs/introspection.md +154 -0
- package/docs/mcp/readme.md +162 -0
- package/docs/models.ts +38 -0
- package/docs/philosophy.md +85 -0
- package/docs/principles.md +7 -0
- package/docs/prompts/audit-codebase-for-failures-to-use-the-container.md +34 -0
- package/docs/prompts/mcp-test-easy-command.md +27 -0
- package/docs/reports/assistant-bugs.md +38 -0
- package/docs/reports/attach-pattern-usage.md +18 -0
- package/docs/reports/code-audit-results.md +391 -0
- package/docs/reports/introspection-audit-tasks.md +378 -0
- package/docs/reports/luca-mcp-improvements.md +128 -0
- package/docs/scaffolds/client.md +140 -0
- package/docs/scaffolds/command.md +106 -0
- package/docs/scaffolds/endpoint.md +176 -0
- package/docs/scaffolds/feature.md +148 -0
- package/docs/scaffolds/server.md +187 -0
- package/docs/tasks/web-container-helper-discovery.md +71 -0
- package/docs/todos.md +1 -0
- package/docs/tutorials/01-getting-started.md +106 -0
- package/docs/tutorials/02-container.md +210 -0
- package/docs/tutorials/03-scripts.md +194 -0
- package/docs/tutorials/04-features-overview.md +196 -0
- package/docs/tutorials/05-state-and-events.md +171 -0
- package/docs/tutorials/06-servers.md +157 -0
- package/docs/tutorials/07-endpoints.md +198 -0
- package/docs/tutorials/08-commands.md +171 -0
- package/docs/tutorials/09-clients.md +162 -0
- package/docs/tutorials/10-creating-features.md +198 -0
- package/docs/tutorials/11-contentbase.md +191 -0
- package/docs/tutorials/12-assistants.md +215 -0
- package/docs/tutorials/13-introspection.md +147 -0
- package/docs/tutorials/14-type-system.md +174 -0
- package/docs/tutorials/15-project-patterns.md +222 -0
- package/docs/tutorials/16-google-features.md +534 -0
- package/docs/tutorials/17-tui-blocks.md +530 -0
- package/docs/tutorials/18-semantic-search.md +334 -0
- package/index.ts +1 -0
- package/luca.console.ts +9 -0
- package/main.py +6 -0
- package/package.json +154 -0
- package/pyproject.toml +7 -0
- package/scripts/animations/chrome-glitch.ts +55 -0
- package/scripts/animations/index.ts +16 -0
- package/scripts/animations/neon-pulse.ts +64 -0
- package/scripts/animations/types.ts +6 -0
- package/scripts/build-web.ts +28 -0
- package/scripts/examples/ask-luca-expert.ts +42 -0
- package/scripts/examples/assistant-questions.ts +12 -0
- package/scripts/examples/excalidraw-expert.ts +75 -0
- package/scripts/examples/expert-chat.ts +0 -0
- package/scripts/examples/file-manager.ts +14 -0
- package/scripts/examples/ideas.ts +12 -0
- package/scripts/examples/interactive-chat.ts +20 -0
- package/scripts/examples/openai-tool-calls.ts +113 -0
- package/scripts/examples/opening-a-web-browser.ts +5 -0
- package/scripts/examples/telegram-bot.ts +79 -0
- package/scripts/examples/telegram-ink-ui.ts +302 -0
- package/scripts/examples/using-assistant-with-mcp.ts +560 -0
- package/scripts/examples/using-claude-code.ts +10 -0
- package/scripts/examples/using-contentdb.ts +35 -0
- package/scripts/examples/using-conversations.ts +35 -0
- package/scripts/examples/using-disk-cache.ts +10 -0
- package/scripts/examples/using-docker-shell.ts +75 -0
- package/scripts/examples/using-elevenlabs.ts +25 -0
- package/scripts/examples/using-google-calendar.ts +57 -0
- package/scripts/examples/using-google-docs.ts +74 -0
- package/scripts/examples/using-google-drive.ts +74 -0
- package/scripts/examples/using-google-sheets.ts +89 -0
- package/scripts/examples/using-nlp.ts +55 -0
- package/scripts/examples/using-ollama.ts +10 -0
- package/scripts/examples/using-openai-codex.ts +23 -0
- package/scripts/examples/using-postgres.ts +55 -0
- package/scripts/examples/using-runpod.ts +32 -0
- package/scripts/examples/using-tts.ts +40 -0
- package/scripts/examples/vm-loading-esm-modules.ts +16 -0
- package/scripts/scaffold.ts +391 -0
- package/scripts/scratch.ts +15 -0
- package/scripts/test-command-listener.ts +123 -0
- package/scripts/test-window-manager-lifecycle.ts +86 -0
- package/scripts/test-window-manager.ts +43 -0
- package/scripts/update-introspection-data.ts +58 -0
- package/src/agi/README.md +14 -0
- package/src/agi/container.server.ts +114 -0
- package/src/agi/endpoints/ask.ts +60 -0
- package/src/agi/endpoints/conversations/[id].ts +45 -0
- package/src/agi/endpoints/conversations.ts +31 -0
- package/src/agi/endpoints/experts.ts +37 -0
- package/src/agi/features/assistant.ts +767 -0
- package/src/agi/features/assistants-manager.ts +260 -0
- package/src/agi/features/claude-code.ts +1111 -0
- package/src/agi/features/conversation-history.ts +497 -0
- package/src/agi/features/conversation.ts +799 -0
- package/src/agi/features/openai-codex.ts +631 -0
- package/src/agi/features/openapi.ts +438 -0
- package/src/agi/features/skills-library.ts +425 -0
- package/src/agi/index.ts +6 -0
- package/src/agi/lib/token-counter.ts +122 -0
- package/src/browser.ts +25 -0
- package/src/bus.ts +100 -0
- package/src/cli/cli.ts +70 -0
- package/src/client.ts +461 -0
- package/src/clients/civitai/index.ts +541 -0
- package/src/clients/client-template.ts +41 -0
- package/src/clients/comfyui/index.ts +597 -0
- package/src/clients/elevenlabs/index.ts +291 -0
- package/src/clients/openai/index.ts +451 -0
- package/src/clients/supabase/index.ts +366 -0
- package/src/command.ts +164 -0
- package/src/commands/chat.ts +182 -0
- package/src/commands/console.ts +192 -0
- package/src/commands/describe.ts +433 -0
- package/src/commands/eval.ts +116 -0
- package/src/commands/help.ts +214 -0
- package/src/commands/index.ts +14 -0
- package/src/commands/mcp.ts +64 -0
- package/src/commands/prompt.ts +807 -0
- package/src/commands/run.ts +257 -0
- package/src/commands/sandbox-mcp.ts +439 -0
- package/src/commands/scaffold.ts +79 -0
- package/src/commands/serve.ts +172 -0
- package/src/container.ts +781 -0
- package/src/endpoint.ts +340 -0
- package/src/feature.ts +75 -0
- package/src/hash-object.ts +97 -0
- package/src/helper.ts +543 -0
- package/src/introspection/generated.agi.ts +23388 -0
- package/src/introspection/generated.node.ts +18899 -0
- package/src/introspection/generated.web.ts +2021 -0
- package/src/introspection/index.ts +256 -0
- package/src/introspection/scan.ts +912 -0
- package/src/node/container.ts +354 -0
- package/src/node/feature.ts +13 -0
- package/src/node/features/container-link.ts +558 -0
- package/src/node/features/content-db.ts +475 -0
- package/src/node/features/disk-cache.ts +382 -0
- package/src/node/features/dns.ts +655 -0
- package/src/node/features/docker.ts +912 -0
- package/src/node/features/downloader.ts +92 -0
- package/src/node/features/esbuild.ts +68 -0
- package/src/node/features/file-manager.ts +357 -0
- package/src/node/features/fs.ts +534 -0
- package/src/node/features/git.ts +492 -0
- package/src/node/features/google-auth.ts +502 -0
- package/src/node/features/google-calendar.ts +300 -0
- package/src/node/features/google-docs.ts +404 -0
- package/src/node/features/google-drive.ts +339 -0
- package/src/node/features/google-sheets.ts +279 -0
- package/src/node/features/grep.ts +406 -0
- package/src/node/features/helpers.ts +374 -0
- package/src/node/features/ink.ts +490 -0
- package/src/node/features/ipc-socket.ts +459 -0
- package/src/node/features/json-tree.ts +188 -0
- package/src/node/features/launcher-app-command-listener.ts +388 -0
- package/src/node/features/networking.ts +925 -0
- package/src/node/features/nlp.ts +211 -0
- package/src/node/features/opener.ts +166 -0
- package/src/node/features/os.ts +157 -0
- package/src/node/features/package-finder.ts +539 -0
- package/src/node/features/port-exposer.ts +342 -0
- package/src/node/features/postgres.ts +273 -0
- package/src/node/features/proc.ts +502 -0
- package/src/node/features/process-manager.ts +542 -0
- package/src/node/features/python.ts +444 -0
- package/src/node/features/repl.ts +194 -0
- package/src/node/features/runpod.ts +802 -0
- package/src/node/features/secure-shell.ts +248 -0
- package/src/node/features/semantic-search.ts +924 -0
- package/src/node/features/sqlite.ts +289 -0
- package/src/node/features/telegram.ts +342 -0
- package/src/node/features/tts.ts +184 -0
- package/src/node/features/ui.ts +857 -0
- package/src/node/features/vault.ts +164 -0
- package/src/node/features/vm.ts +312 -0
- package/src/node/features/window-manager.ts +804 -0
- package/src/node/features/yaml-tree.ts +149 -0
- package/src/node/features/yaml.ts +132 -0
- package/src/node.ts +70 -0
- package/src/react/index.ts +175 -0
- package/src/registry.ts +199 -0
- package/src/scaffolds/generated.ts +1613 -0
- package/src/scaffolds/template.ts +37 -0
- package/src/schemas/base.ts +255 -0
- package/src/server.ts +135 -0
- package/src/servers/express.ts +209 -0
- package/src/servers/mcp.ts +805 -0
- package/src/servers/socket.ts +120 -0
- package/src/state.ts +101 -0
- package/src/web/clients/socket.ts +82 -0
- package/src/web/container.ts +74 -0
- package/src/web/extension.ts +30 -0
- package/src/web/feature.ts +12 -0
- package/src/web/features/asset-loader.ts +64 -0
- package/src/web/features/container-link.ts +385 -0
- package/src/web/features/esbuild.ts +79 -0
- package/src/web/features/helpers.ts +267 -0
- package/src/web/features/network.ts +61 -0
- package/src/web/features/speech.ts +87 -0
- package/src/web/features/vault.ts +189 -0
- package/src/web/features/vm.ts +78 -0
- package/src/web/features/voice-recognition.ts +129 -0
- package/src/web/shims/isomorphic-vm.ts +149 -0
- package/test/bus.test.ts +134 -0
- package/test/clients-servers.test.ts +216 -0
- package/test/container-link.test.ts +274 -0
- package/test/features.test.ts +160 -0
- package/test/integration.test.ts +787 -0
- package/test/node-container.test.ts +121 -0
- package/test/rate-limit.test.ts +272 -0
- package/test/semantic-search.test.ts +550 -0
- package/test/state.test.ts +121 -0
- package/test-integration/assistant.test.ts +138 -0
- package/test-integration/assistants-manager.test.ts +123 -0
- package/test-integration/claude-code.test.ts +98 -0
- package/test-integration/conversation-history.test.ts +205 -0
- package/test-integration/conversation.test.ts +137 -0
- package/test-integration/elevenlabs.test.ts +55 -0
- package/test-integration/google-services.test.ts +80 -0
- package/test-integration/helpers.ts +89 -0
- package/test-integration/openai-codex.test.ts +93 -0
- package/test-integration/runpod.test.ts +58 -0
- package/test-integration/server-endpoints.test.ts +97 -0
- package/test-integration/skills-library.test.ts +157 -0
- package/test-integration/telegram.test.ts +46 -0
- package/tsconfig.json +58 -0
- package/uv.lock +8 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Python"
|
|
3
|
+
tags: [python, scripting, virtualenv, integration]
|
|
4
|
+
lastTested: null
|
|
5
|
+
lastTestPassed: null
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# python
|
|
9
|
+
|
|
10
|
+
Python virtual machine feature for executing Python code, managing environments, and installing dependencies. Automatically detects uv, conda, venv, or system Python.
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
The `python` feature provides a bridge between Luca and the Python ecosystem. It auto-detects the best available Python environment (uv, conda, venv, system), can install project dependencies, and execute Python code with variable injection and local variable capture. Requires Python to be installed on the host.
|
|
15
|
+
|
|
16
|
+
## Enabling the Feature
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
const python = container.feature('python', { enable: true })
|
|
20
|
+
console.log('Python feature enabled:', python.state.get('enabled'))
|
|
21
|
+
console.log('Python ready:', python.state.get('isReady'))
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Exploring the API
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
const docs = container.features.describe('python')
|
|
28
|
+
console.log(docs)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Environment Detection
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
const python = container.feature('python')
|
|
35
|
+
await python.detectEnvironment()
|
|
36
|
+
console.log('Environment type:', python.state.get('environmentType'))
|
|
37
|
+
console.log('Python path:', python.state.get('pythonPath'))
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Running Inline Code
|
|
41
|
+
|
|
42
|
+
Execute Python code directly and capture the output.
|
|
43
|
+
|
|
44
|
+
```ts skip
|
|
45
|
+
const result = await python.execute('print("Hello from Python!")')
|
|
46
|
+
console.log('stdout:', result.stdout)
|
|
47
|
+
console.log('exit code:', result.exitCode)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
You can also pass variables into the Python context and capture locals after execution.
|
|
51
|
+
|
|
52
|
+
```ts skip
|
|
53
|
+
const result = await python.execute(
|
|
54
|
+
'greeting = f"Hello {name}, you are {age}!";\nprint(greeting)',
|
|
55
|
+
{ name: 'Alice', age: 30 },
|
|
56
|
+
{ captureLocals: true }
|
|
57
|
+
)
|
|
58
|
+
console.log('stdout:', result.stdout)
|
|
59
|
+
console.log('locals:', result.locals)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The `captureLocals` option serializes all local variables from the script back to JavaScript as JSON.
|
|
63
|
+
|
|
64
|
+
## Running a Script File
|
|
65
|
+
|
|
66
|
+
Execute an existing `.py` file and capture its output.
|
|
67
|
+
|
|
68
|
+
```ts skip
|
|
69
|
+
const result = await python.executeFile('/path/to/analysis.py')
|
|
70
|
+
console.log('stdout:', result.stdout)
|
|
71
|
+
console.log('stderr:', result.stderr)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Creating a Virtual Environment
|
|
75
|
+
|
|
76
|
+
Install project dependencies using the auto-detected package manager.
|
|
77
|
+
|
|
78
|
+
```ts skip
|
|
79
|
+
const python = container.feature('python', {
|
|
80
|
+
dir: '/path/to/python-project',
|
|
81
|
+
installCommand: 'pip install -r requirements.txt'
|
|
82
|
+
})
|
|
83
|
+
const result = await python.installDependencies()
|
|
84
|
+
console.log('Install exit code:', result.exitCode)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
When no `installCommand` is provided, the feature infers the correct command from the detected environment type (e.g., `uv sync` for uv, `pip install -e .` for venv).
|
|
88
|
+
|
|
89
|
+
## Summary
|
|
90
|
+
|
|
91
|
+
The `python` feature bridges Luca and Python by auto-detecting environments, managing dependencies, and providing inline code execution with variable injection. It supports uv, conda, venv, and system Python installations.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "REPL"
|
|
3
|
+
tags: [repl, interactive, debugging, console]
|
|
4
|
+
lastTested: null
|
|
5
|
+
lastTestPassed: null
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# repl
|
|
9
|
+
|
|
10
|
+
Interactive read-eval-print loop with tab completion, history, and full container access.
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
The `repl` feature is an on-demand feature that launches an interactive REPL session inside a VM context populated with the container and all its helpers. It supports tab completion for dot-notation property access, command history persistence, and top-level await. Since it is interactive, it cannot run inside a markdown code block -- instead, the typical workflow is to run `luca run somefile.md --console` which executes all code blocks first and then drops into a REPL with the accumulated context.
|
|
15
|
+
|
|
16
|
+
## Feature Documentation
|
|
17
|
+
|
|
18
|
+
Let us inspect the feature's built-in documentation.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const desc = container.features.describe('repl')
|
|
22
|
+
console.log(desc)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The main method is `start(options?)` which begins the interactive session. It accepts an optional context object and history path.
|
|
26
|
+
|
|
27
|
+
## Enabling the Feature
|
|
28
|
+
|
|
29
|
+
We can enable the feature and inspect its state without starting the interactive session.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
const repl = container.feature('repl', { enable: true })
|
|
33
|
+
console.log('REPL enabled:', repl.state.enabled)
|
|
34
|
+
console.log('REPL started:', repl.state.started)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The feature is enabled but not started. Starting it would block execution waiting for interactive input, which is not suitable for a markdown runner context.
|
|
38
|
+
|
|
39
|
+
## Configuration Options
|
|
40
|
+
|
|
41
|
+
The REPL feature accepts several options for customization.
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
const options = {
|
|
45
|
+
prompt: 'Custom prompt string displayed before each input line',
|
|
46
|
+
historyPath: 'Path to a file where command history is persisted between sessions',
|
|
47
|
+
context: 'Additional variables injected into the VM evaluation context',
|
|
48
|
+
}
|
|
49
|
+
for (const [key, desc] of Object.entries(options)) {
|
|
50
|
+
console.log(` ${key}: ${desc}`)
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
When you provide a `context` object to `start()`, those variables become globally available in the REPL session alongside the container and its helpers.
|
|
55
|
+
|
|
56
|
+
## How to Use the REPL
|
|
57
|
+
|
|
58
|
+
The recommended way to use the REPL is through the `--console` flag on `luca run`.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
console.log('Usage patterns:')
|
|
62
|
+
console.log('')
|
|
63
|
+
console.log(' luca run script.md --console')
|
|
64
|
+
console.log(' Run all code blocks, then drop into REPL with accumulated context')
|
|
65
|
+
console.log('')
|
|
66
|
+
console.log(' luca run setup.md --console')
|
|
67
|
+
console.log(' Execute setup code, then explore interactively')
|
|
68
|
+
console.log('')
|
|
69
|
+
console.log('Inside the REPL:')
|
|
70
|
+
console.log(' - Tab completion works on all container properties')
|
|
71
|
+
console.log(' - Top-level await is supported')
|
|
72
|
+
console.log(' - Type .exit or exit to quit')
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
This is especially powerful when combined with runnable markdown files: you define your setup and data loading in code blocks, then explore the results interactively in the REPL.
|
|
76
|
+
|
|
77
|
+
## REPL Context
|
|
78
|
+
|
|
79
|
+
When launched via `--console`, the REPL inherits everything from the markdown execution context. This means all variables, enabled features, and loaded data carry over.
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
console.log('The REPL context automatically includes:')
|
|
83
|
+
const globals = ['container', 'fs', 'git', 'proc', 'grep', 'os', 'networking', 'ui', 'vm', 'esbuild', 'console']
|
|
84
|
+
for (const name of globals) {
|
|
85
|
+
console.log(` ${name}`)
|
|
86
|
+
}
|
|
87
|
+
console.log('')
|
|
88
|
+
console.log('Plus any variables defined in preceding code blocks.')
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Summary
|
|
92
|
+
|
|
93
|
+
This demo covered the `repl` feature, which provides an interactive REPL with tab completion, history, and async support. Since it is interactive by nature, it is best used via `luca run somefile.md --console` to combine scripted setup with interactive exploration. The REPL inherits the full container context plus any variables accumulated during markdown execution.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "RunPod GPU Cloud"
|
|
3
|
+
tags: [runpod, gpu, cloud, pods, ssh, infrastructure]
|
|
4
|
+
lastTested: null
|
|
5
|
+
lastTestPassed: null
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# runpod
|
|
9
|
+
|
|
10
|
+
GPU cloud pod management via the RunPod REST API and CLI. Provision GPU instances, manage network volumes, SSH into pods, and transfer files.
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Use the `runpod` feature when you need to manage GPU cloud infrastructure. It provides a complete interface for creating and managing RunPod GPU pods, including template selection, volume management, SSH access, file transfers, and lifecycle operations (start, stop, remove). Integrates with the `secureShell` feature for remote command execution.
|
|
15
|
+
|
|
16
|
+
Requires a `RUNPOD_API_KEY` environment variable or an `apiKey` option.
|
|
17
|
+
|
|
18
|
+
## Enabling the Feature
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const runpod = container.feature('runpod', {
|
|
22
|
+
dataCenterId: 'US-TX-3'
|
|
23
|
+
})
|
|
24
|
+
console.log('RunPod feature created')
|
|
25
|
+
console.log('Data center:', runpod.dataCenterId)
|
|
26
|
+
console.log('API key configured:', !!runpod.apiKey)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## API Documentation
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
const info = await container.features.describe('runpod')
|
|
33
|
+
console.log(info)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Listing Pods and GPUs
|
|
37
|
+
|
|
38
|
+
Query your existing pods and available GPU types.
|
|
39
|
+
|
|
40
|
+
```ts skip
|
|
41
|
+
const pods = await runpod.getpods()
|
|
42
|
+
pods.forEach(p => console.log(`${p.name}: ${p.desiredStatus} - $${p.costPerHr}/hr`))
|
|
43
|
+
|
|
44
|
+
const gpus = await runpod.listSecureGPUs()
|
|
45
|
+
gpus.forEach(g => console.log(`${g.gpuType}: $${g.ondemandPrice}/hr`))
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Use `getpods()` for detailed REST API data including port mappings and public IP, or `listPods()` for a quick summary via the CLI.
|
|
49
|
+
|
|
50
|
+
## Creating and Managing Pods
|
|
51
|
+
|
|
52
|
+
Provision a new GPU pod and manage its lifecycle.
|
|
53
|
+
|
|
54
|
+
```ts skip
|
|
55
|
+
const pod = await runpod.createPod({
|
|
56
|
+
name: 'my-training-pod',
|
|
57
|
+
gpuTypeId: 'NVIDIA RTX 4090',
|
|
58
|
+
templateId: 'abc123',
|
|
59
|
+
volumeInGb: 50,
|
|
60
|
+
containerDiskInGb: 50,
|
|
61
|
+
ports: ['8888/http', '22/tcp']
|
|
62
|
+
})
|
|
63
|
+
console.log(`Pod ${pod.id} created`)
|
|
64
|
+
|
|
65
|
+
const ready = await runpod.waitForPod(pod.id, 'RUNNING', { timeout: 120000 })
|
|
66
|
+
console.log('Pod is running:', ready.desiredStatus)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
After creation, use `waitForPod()` to poll until the pod reaches the desired status.
|
|
70
|
+
|
|
71
|
+
## Pod Lifecycle
|
|
72
|
+
|
|
73
|
+
```ts skip
|
|
74
|
+
await runpod.stopPod('pod-abc123')
|
|
75
|
+
console.log('Pod stopped')
|
|
76
|
+
|
|
77
|
+
await runpod.startPod('pod-abc123')
|
|
78
|
+
console.log('Pod restarted')
|
|
79
|
+
|
|
80
|
+
await runpod.removePod('pod-abc123')
|
|
81
|
+
console.log('Pod permanently deleted')
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Stopping a pod preserves its disk; removing it is permanent.
|
|
85
|
+
|
|
86
|
+
## SSH and Remote Execution
|
|
87
|
+
|
|
88
|
+
Connect to a running pod and execute commands remotely.
|
|
89
|
+
|
|
90
|
+
```ts skip
|
|
91
|
+
const shell = await runpod.getShell('pod-abc123')
|
|
92
|
+
const output = await shell.exec('nvidia-smi')
|
|
93
|
+
console.log(output)
|
|
94
|
+
|
|
95
|
+
const ls = await shell.exec('ls /workspace')
|
|
96
|
+
console.log('Workspace files:', ls)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The `getShell()` method uses REST API data for reliable SSH connections. Use it over `createRemoteShell()` which depends on the CLI.
|
|
100
|
+
|
|
101
|
+
## Network Volumes
|
|
102
|
+
|
|
103
|
+
Manage persistent storage that survives pod restarts.
|
|
104
|
+
|
|
105
|
+
```ts skip
|
|
106
|
+
const vol = await runpod.createVolume({ name: 'my-models', size: 100 })
|
|
107
|
+
console.log(`Created volume ${vol.id}`)
|
|
108
|
+
|
|
109
|
+
const volumes = await runpod.listVolumes()
|
|
110
|
+
volumes.forEach(v => console.log(`${v.name}: ${v.size}GB`))
|
|
111
|
+
|
|
112
|
+
await runpod.removeVolume('vol-abc123')
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Attach network volumes to pods via the `networkVolumeId` option in `createPod()`.
|
|
116
|
+
|
|
117
|
+
## Summary
|
|
118
|
+
|
|
119
|
+
The `runpod` feature provides complete GPU cloud management. Create pods from templates, manage lifecycle (start/stop/remove), SSH into running pods, and manage network storage volumes. Supports polling for readiness and file transfer operations. Key methods: `createPod()`, `getpods()`, `waitForPod()`, `getShell()`, `listVolumes()`, `createVolume()`.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Secure Shell"
|
|
3
|
+
tags: [secureShell, ssh, scp, remote, deployment]
|
|
4
|
+
lastTested: null
|
|
5
|
+
lastTestPassed: null
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# secureShell
|
|
9
|
+
|
|
10
|
+
SSH command execution and SCP file transfers. Uses the system `ssh` and `scp` binaries to run commands on remote hosts and transfer files securely.
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
The `secureShell` feature provides an SSH client for executing commands on remote machines and transferring files via SCP. It supports both key-based and password-based authentication. All operations require a reachable SSH target host, so the actual connection and command examples use skip blocks.
|
|
15
|
+
|
|
16
|
+
## Enabling the Feature
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
const ssh = container.feature('secureShell', {
|
|
20
|
+
host: 'example.com',
|
|
21
|
+
username: 'deploy',
|
|
22
|
+
key: '~/.ssh/id_ed25519',
|
|
23
|
+
enable: true
|
|
24
|
+
})
|
|
25
|
+
console.log('SSH enabled:', ssh.state.get('enabled'))
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Exploring the API
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
const docs = container.features.describe('secureShell')
|
|
32
|
+
console.log(docs)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Feature Options
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
const ssh = container.feature('secureShell', {
|
|
39
|
+
host: '192.168.1.100',
|
|
40
|
+
port: 22,
|
|
41
|
+
username: 'admin',
|
|
42
|
+
key: '~/.ssh/id_rsa'
|
|
43
|
+
})
|
|
44
|
+
console.log('Host configured:', ssh.options.host)
|
|
45
|
+
console.log('Port:', ssh.options.port || 22)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Testing the Connection
|
|
49
|
+
|
|
50
|
+
Verify that the SSH target is reachable before running commands.
|
|
51
|
+
|
|
52
|
+
```ts skip
|
|
53
|
+
const ok = await ssh.testConnection()
|
|
54
|
+
console.log('Connection OK:', ok)
|
|
55
|
+
console.log('State connected:', ssh.state.get('connected'))
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The `testConnection` method runs a simple echo command on the remote host. If it succeeds, `state.connected` is set to `true`.
|
|
59
|
+
|
|
60
|
+
## Executing a Remote Command
|
|
61
|
+
|
|
62
|
+
Run a shell command on the remote host and capture its output.
|
|
63
|
+
|
|
64
|
+
```ts skip
|
|
65
|
+
const uptime = await ssh.exec('uptime')
|
|
66
|
+
console.log('Remote uptime:', uptime)
|
|
67
|
+
|
|
68
|
+
const listing = await ssh.exec('ls -la /var/log')
|
|
69
|
+
console.log(listing)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The `exec` method returns the command's stdout as a string. It uses the configured host, username, and authentication credentials.
|
|
73
|
+
|
|
74
|
+
## Uploading and Downloading Files
|
|
75
|
+
|
|
76
|
+
Transfer files between the local machine and the remote host using SCP.
|
|
77
|
+
|
|
78
|
+
```ts skip
|
|
79
|
+
await ssh.upload('./build/app.tar.gz', '/opt/releases/app.tar.gz')
|
|
80
|
+
console.log('Upload complete')
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```ts skip
|
|
84
|
+
await ssh.download('/var/log/app.log', './logs/app.log')
|
|
85
|
+
console.log('Download complete')
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Both methods use the same authentication credentials configured on the feature instance. Paths on the remote side are absolute or relative to the user's home directory.
|
|
89
|
+
|
|
90
|
+
## Summary
|
|
91
|
+
|
|
92
|
+
The `secureShell` feature wraps the system `ssh` and `scp` commands to provide remote command execution and file transfers. It supports key-based and password-based authentication, connection testing, and maintains connection state on the feature instance.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "SQLite"
|
|
3
|
+
tags: [sqlite, database, sql, storage]
|
|
4
|
+
lastTested: null
|
|
5
|
+
lastTestPassed: null
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# sqlite
|
|
9
|
+
|
|
10
|
+
In-process SQLite database via Bun's native binding. Create tables, insert rows, and query data with parameterized SQL or tagged templates.
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
The `sqlite` feature is on-demand. Pass `{ path: ':memory:' }` for an in-memory database or a file path for persistence. It supports parameterized queries to prevent SQL injection and a convenient tagged-template syntax for inline SQL.
|
|
15
|
+
|
|
16
|
+
## Creating an In-Memory Database
|
|
17
|
+
|
|
18
|
+
Enable the feature with an in-memory path. No files are created on disk.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const db = container.feature('sqlite', { path: ':memory:' })
|
|
22
|
+
console.log('SQLite enabled:', db.state.get('enabled'))
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The database is ready for queries immediately.
|
|
26
|
+
|
|
27
|
+
## Creating a Table
|
|
28
|
+
|
|
29
|
+
Use `execute()` for DDL and write statements.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
await db.execute(`
|
|
33
|
+
CREATE TABLE users (
|
|
34
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
35
|
+
name TEXT NOT NULL,
|
|
36
|
+
email TEXT NOT NULL UNIQUE,
|
|
37
|
+
active INTEGER DEFAULT 1
|
|
38
|
+
)
|
|
39
|
+
`)
|
|
40
|
+
console.log('Table created')
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The `execute()` method returns metadata including the number of changes and the last inserted row ID.
|
|
44
|
+
|
|
45
|
+
## Inserting Rows
|
|
46
|
+
|
|
47
|
+
Insert data using parameterized queries to keep values safe.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
await db.execute('INSERT INTO users (name, email) VALUES (?, ?)', ['Alice', 'alice@example.com'])
|
|
51
|
+
await db.execute('INSERT INTO users (name, email) VALUES (?, ?)', ['Bob', 'bob@example.com'])
|
|
52
|
+
const result = await db.execute('INSERT INTO users (name, email, active) VALUES (?, ?, ?)', ['Charlie', 'charlie@example.com', 0])
|
|
53
|
+
console.log('Last insert ID:', result.lastInsertRowid)
|
|
54
|
+
console.log('Changes:', result.changes)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Each `?` placeholder is bound to the corresponding value in the array, preventing SQL injection.
|
|
58
|
+
|
|
59
|
+
## Querying Rows
|
|
60
|
+
|
|
61
|
+
Use `query()` for SELECT statements that return result rows.
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
const users = await db.query('SELECT * FROM users WHERE active = ?', [1])
|
|
65
|
+
console.log('Active users:')
|
|
66
|
+
users.forEach(u => console.log(` ${u.id}: ${u.name} <${u.email}>`))
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Results come back as an array of plain objects with column names as keys.
|
|
70
|
+
|
|
71
|
+
## Tagged Template Queries
|
|
72
|
+
|
|
73
|
+
The `sql` tagged template lets you write queries with inline interpolation that is still safely parameterized.
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
const emailDomain = '%example.com'
|
|
77
|
+
const rows = await db.sql`SELECT name, email FROM users WHERE email LIKE ${emailDomain}`
|
|
78
|
+
console.log('Users matching domain:')
|
|
79
|
+
rows.forEach(r => console.log(` ${r.name}: ${r.email}`))
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Interpolated values become bound parameters automatically. This combines readability with safety.
|
|
83
|
+
|
|
84
|
+
## Summary
|
|
85
|
+
|
|
86
|
+
This demo covered creating an in-memory SQLite database, defining tables, inserting rows with parameterized queries, reading data back, and using the tagged-template SQL syntax. The `sqlite` feature gives you a full relational database with zero setup.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Telegram Bot"
|
|
3
|
+
tags: [telegram, bot, messaging, grammy]
|
|
4
|
+
lastTested: null
|
|
5
|
+
lastTestPassed: null
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# telegram
|
|
9
|
+
|
|
10
|
+
Telegram bot feature powered by grammY. Supports long-polling and webhook modes, with the full grammY Bot instance exposed for direct API access. Events bridge to Luca's event bus.
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Use the `telegram` feature when you need to build a Telegram bot. It wraps the grammY library and handles bot lifecycle (start, stop, polling, webhooks) while bridging Telegram events into Luca's event system.
|
|
15
|
+
|
|
16
|
+
Requires a `TELEGRAM_BOT_TOKEN` environment variable or a `token` option from [@BotFather](https://t.me/BotFather).
|
|
17
|
+
|
|
18
|
+
## Enabling the Feature
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const tg = container.feature('telegram', {
|
|
22
|
+
mode: 'polling',
|
|
23
|
+
dropPendingUpdates: true
|
|
24
|
+
})
|
|
25
|
+
console.log('Telegram feature created, mode:', tg.mode)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The feature reads `TELEGRAM_BOT_TOKEN` from the environment automatically. You can also pass `token` explicitly as an option.
|
|
29
|
+
|
|
30
|
+
## API Documentation
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
const info = await container.features.describe('telegram')
|
|
34
|
+
console.log(info)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Registering Commands
|
|
38
|
+
|
|
39
|
+
Bot commands are registered with `.command()` and also emit events on Luca's event bus.
|
|
40
|
+
|
|
41
|
+
```ts skip
|
|
42
|
+
tg.command('start', (ctx) => ctx.reply('Welcome! I am your Luca bot.'))
|
|
43
|
+
tg.command('help', (ctx) => ctx.reply('Available: /start, /help, /ping'))
|
|
44
|
+
tg.command('ping', (ctx) => ctx.reply('Pong!'))
|
|
45
|
+
console.log('Registered commands:', tg.state.commandsRegistered)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
If the bot were running with a valid token, sending `/start` in Telegram would reply with "Welcome! I am your Luca bot." and the `command` event would fire on the Luca event bus.
|
|
49
|
+
|
|
50
|
+
## Handling Messages
|
|
51
|
+
|
|
52
|
+
Use `.handle()` to register grammY update handlers for any filter query.
|
|
53
|
+
|
|
54
|
+
```ts skip
|
|
55
|
+
tg.handle('message:text', (ctx) => {
|
|
56
|
+
ctx.reply(`Echo: ${ctx.message.text}`)
|
|
57
|
+
})
|
|
58
|
+
tg.handle('callback_query:data', (ctx) => {
|
|
59
|
+
ctx.answerCallbackQuery('Button clicked!')
|
|
60
|
+
})
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The `.handle()` method maps directly to grammY's `bot.on()` and supports all grammY filter queries like `message:photo`, `edited_message`, and `callback_query:data`.
|
|
64
|
+
|
|
65
|
+
## Starting the Bot
|
|
66
|
+
|
|
67
|
+
```ts skip
|
|
68
|
+
await tg.start()
|
|
69
|
+
console.log('Bot is running:', tg.isRunning)
|
|
70
|
+
console.log('Mode:', tg.mode)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Once started in polling mode, the bot continuously fetches updates from Telegram. Call `await tg.stop()` to shut down gracefully. The `started` and `stopped` events fire on the Luca event bus.
|
|
74
|
+
|
|
75
|
+
## Summary
|
|
76
|
+
|
|
77
|
+
The `telegram` feature provides a complete Telegram bot lifecycle manager. Register commands and handlers, then start polling or set up a webhook. All Telegram events are bridged to Luca's event bus for integration with other features. Key methods: `command()`, `handle()`, `start()`, `stop()`, `setupWebhook()`.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Text-to-Speech"
|
|
3
|
+
tags: [tts, speech, audio, runpod, chatterbox]
|
|
4
|
+
lastTested: null
|
|
5
|
+
lastTestPassed: null
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# tts
|
|
9
|
+
|
|
10
|
+
Text-to-speech feature that synthesizes audio files via RunPod's Chatterbox Turbo endpoint. Supports 20 preset voices and voice cloning from a reference audio URL.
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Use the `tts` feature when you need to generate speech audio from text. It calls the Chatterbox Turbo public endpoint on RunPod, downloads the resulting audio, and saves it locally. Choose from 20 preset voices or clone any voice by providing a reference audio URL.
|
|
15
|
+
|
|
16
|
+
Requires a `RUNPOD_API_KEY` environment variable or an `apiKey` option.
|
|
17
|
+
|
|
18
|
+
## Enabling the Feature
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const tts = container.feature('tts', {
|
|
22
|
+
voice: 'lucy',
|
|
23
|
+
format: 'wav',
|
|
24
|
+
outputDir: '/tmp/tts-output'
|
|
25
|
+
})
|
|
26
|
+
console.log('TTS feature created')
|
|
27
|
+
console.log('Default voice:', tts.options.voice)
|
|
28
|
+
console.log('Output format:', tts.options.format)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## API Documentation
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
const info = await container.features.describe('tts')
|
|
35
|
+
console.log(info)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Available Voices
|
|
39
|
+
|
|
40
|
+
List all 20 preset voice names.
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
console.log('Available voices:', tts.voices.join(', '))
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Generating Speech
|
|
47
|
+
|
|
48
|
+
Synthesize text with a preset voice.
|
|
49
|
+
|
|
50
|
+
```ts skip
|
|
51
|
+
const path = await tts.synthesize('Good morning! Here is your daily briefing.', {
|
|
52
|
+
voice: 'ethan'
|
|
53
|
+
})
|
|
54
|
+
console.log('Audio saved to:', path)
|
|
55
|
+
console.log('Last generated file:', tts.state.lastFile)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The synthesize method sends the text to RunPod, waits for generation, downloads the audio, and saves it to the output directory. The `synthesized` event fires with the file path on completion.
|
|
59
|
+
|
|
60
|
+
## Voice Cloning
|
|
61
|
+
|
|
62
|
+
Clone any voice by providing a reference audio URL.
|
|
63
|
+
|
|
64
|
+
```ts skip
|
|
65
|
+
const path = await tts.synthesize('Hello world, this is a cloned voice.', {
|
|
66
|
+
voiceUrl: 'https://example.com/reference-voice.wav'
|
|
67
|
+
})
|
|
68
|
+
console.log('Cloned voice audio saved to:', path)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The reference audio should be a clear recording of the voice you want to clone. The Chatterbox Turbo model uses it to match the voice characteristics.
|
|
72
|
+
|
|
73
|
+
## Output Formats
|
|
74
|
+
|
|
75
|
+
```ts skip
|
|
76
|
+
const wav = await tts.synthesize('WAV format', { format: 'wav' })
|
|
77
|
+
const flac = await tts.synthesize('FLAC format', { format: 'flac' })
|
|
78
|
+
const ogg = await tts.synthesize('OGG format', { format: 'ogg' })
|
|
79
|
+
console.log('Generated files:', wav, flac, ogg)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Three output formats are supported: WAV (default, uncompressed), FLAC (lossless compressed), and OGG (lossy compressed).
|
|
83
|
+
|
|
84
|
+
## Summary
|
|
85
|
+
|
|
86
|
+
The `tts` feature generates speech audio via RunPod's Chatterbox Turbo. Choose from 20 preset voices or clone a custom voice with a reference URL. Supports WAV, FLAC, and OGG output formats. Key methods: `synthesize()`. Key getters: `voices`, `outputDir`.
|