@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,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "ui"
|
|
3
|
+
tags: [ui, terminal, colors, ascii-art, core]
|
|
4
|
+
lastTested: null
|
|
5
|
+
lastTestPassed: null
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# ui
|
|
9
|
+
|
|
10
|
+
Terminal UI utilities including colors, ASCII art, gradients, and markdown rendering.
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
The `ui` feature is a core feature, auto-enabled on every container. You can access it directly as a global or via `container.feature('ui')`. It provides chalk-based color styling, figlet-powered ASCII art, color gradient effects, and terminal markdown rendering. Use it to make CLI output readable and visually organized.
|
|
15
|
+
|
|
16
|
+
## Text Colors
|
|
17
|
+
|
|
18
|
+
The `colors` getter provides the full chalk API for coloring and styling terminal text.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const { colors } = ui
|
|
22
|
+
console.log(colors.green('Success: all tests passed'))
|
|
23
|
+
console.log(colors.red('Error: file not found'))
|
|
24
|
+
console.log(colors.yellow('Warning: deprecated API'))
|
|
25
|
+
console.log(colors.bold.cyan('Info: build complete'))
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Colors can be chained with styles like `bold`, `italic`, `underline`, and `dim`.
|
|
29
|
+
|
|
30
|
+
## ASCII Art
|
|
31
|
+
|
|
32
|
+
Use `asciiArt()` to render text in large figlet fonts. Pass the text and a font name.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
const art = ui.asciiArt('LUCA', 'Standard')
|
|
36
|
+
console.log(art)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The `fonts` getter lists all available figlet fonts if you want to explore options.
|
|
40
|
+
|
|
41
|
+
## Banner with Gradient
|
|
42
|
+
|
|
43
|
+
Use `banner()` to combine ASCII art with a color gradient for eye-catching headers.
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
const result = ui.banner('Hello', { font: 'Small', colors: ['cyan', 'blue', 'magenta'] })
|
|
47
|
+
console.log(result)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The gradient is applied automatically across the lines of the ASCII art.
|
|
51
|
+
|
|
52
|
+
## Color Gradients
|
|
53
|
+
|
|
54
|
+
Use `applyGradient()` to apply color transitions to any text. Choose between horizontal (per-character) and vertical (per-line) directions.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
const horizontal = ui.applyGradient('Horizontal gradient across this text', ['red', 'yellow', 'green'], 'horizontal')
|
|
58
|
+
console.log(horizontal)
|
|
59
|
+
|
|
60
|
+
const lines = 'Line one\nLine two\nLine three\nLine four'
|
|
61
|
+
const vertical = ui.applyGradient(lines, ['cyan', 'blue', 'magenta'], 'vertical')
|
|
62
|
+
console.log(vertical)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Horizontal gradients color each character individually. Vertical gradients color each line uniformly.
|
|
66
|
+
|
|
67
|
+
## Markdown Rendering
|
|
68
|
+
|
|
69
|
+
Use `markdown()` to render a markdown string for terminal display with formatting preserved.
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
const md = ui.markdown('## Features\n\n- **Bold** text\n- `inline code`\n- Regular paragraph text\n')
|
|
73
|
+
console.log(md)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
This uses marked-terminal under the hood to produce styled terminal output from markdown source.
|
|
77
|
+
|
|
78
|
+
## Summary
|
|
79
|
+
|
|
80
|
+
This demo covered text coloring with chalk, ASCII art generation with figlet, gradient banners, horizontal and vertical color gradients, and markdown rendering. The `ui` feature handles all the visual polish for terminal applications.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Vault"
|
|
3
|
+
tags: [vault, encryption, security, crypto]
|
|
4
|
+
lastTested: null
|
|
5
|
+
lastTestPassed: null
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# vault
|
|
9
|
+
|
|
10
|
+
AES-256-GCM encryption and decryption for sensitive data. Encrypt strings and get them back with a simple two-method API.
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
The `vault` feature is on-demand. It generates or accepts a secret key and provides `encrypt()` and `decrypt()` methods using AES-256-GCM, an authenticated encryption scheme. Use it to protect sensitive configuration values, tokens, or any data that should not be stored in plaintext.
|
|
15
|
+
|
|
16
|
+
## Enabling the Vault
|
|
17
|
+
|
|
18
|
+
Create a vault instance. It will generate a secret key automatically.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const vault = container.feature('vault')
|
|
22
|
+
console.log('Vault enabled:', vault.state.get('enabled'))
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The vault is ready to use immediately after creation.
|
|
26
|
+
|
|
27
|
+
## Encrypting a String
|
|
28
|
+
|
|
29
|
+
Pass any plaintext string to `encrypt()` and receive an opaque encrypted payload.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
const secret = 'my-database-password-12345'
|
|
33
|
+
const encrypted = vault.encrypt(secret)
|
|
34
|
+
console.log('Original:', secret)
|
|
35
|
+
console.log('Encrypted:', encrypted)
|
|
36
|
+
console.log('Encrypted length:', encrypted.length)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The encrypted output is a base64-encoded string containing the IV, auth tag, and ciphertext. It is safe to store in config files or databases.
|
|
40
|
+
|
|
41
|
+
## Decrypting Back to Plaintext
|
|
42
|
+
|
|
43
|
+
Use `decrypt()` with the same vault instance to recover the original value.
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
const decrypted = vault.decrypt(encrypted)
|
|
47
|
+
console.log('Decrypted:', decrypted)
|
|
48
|
+
console.log('Round-trip matches:', decrypted === secret)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The decrypted value is identical to the original input.
|
|
52
|
+
|
|
53
|
+
## Encrypting Multiple Values
|
|
54
|
+
|
|
55
|
+
Each call to `encrypt()` produces a unique ciphertext, even for the same input, because a fresh IV is generated every time.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
const a = vault.encrypt('same-input')
|
|
59
|
+
const b = vault.encrypt('same-input')
|
|
60
|
+
console.log('Encryption A:', a)
|
|
61
|
+
console.log('Encryption B:', b)
|
|
62
|
+
console.log('Same ciphertext?', a === b)
|
|
63
|
+
console.log('Both decrypt correctly?', vault.decrypt(a) === vault.decrypt(b))
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
This property (semantic security) means an attacker cannot tell if two ciphertexts contain the same plaintext.
|
|
67
|
+
|
|
68
|
+
## Summary
|
|
69
|
+
|
|
70
|
+
This demo covered enabling the vault, encrypting strings, decrypting them back, and verifying that repeated encryption produces unique ciphertexts. The `vault` feature provides straightforward authenticated encryption for any sensitive data your application handles.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "vm"
|
|
3
|
+
tags: [vm, sandbox, evaluation, core]
|
|
4
|
+
lastTested: null
|
|
5
|
+
lastTestPassed: null
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# vm
|
|
9
|
+
|
|
10
|
+
JavaScript VM for evaluating code in isolated contexts with shared or independent state.
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
The `vm` feature is a core feature, auto-enabled on every container. You can access it directly as a global or via `container.feature('vm')`. It provides methods for running JavaScript in sandboxed contexts, passing variables in, and optionally preserving state across multiple runs. Use it for plugin systems, dynamic code evaluation, or testing snippets in isolation.
|
|
15
|
+
|
|
16
|
+
## Simple Expression Evaluation
|
|
17
|
+
|
|
18
|
+
Use `runSync()` to evaluate a JavaScript expression and get the result back immediately.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const sum = vm.runSync('2 + 3 * 4')
|
|
22
|
+
console.log('2 + 3 * 4 =', sum)
|
|
23
|
+
|
|
24
|
+
const greeting = vm.runSync('`Hello ${name}!`', { name: 'Luca' })
|
|
25
|
+
console.log(greeting)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The second argument is an optional context object whose keys become variables in the evaluated code.
|
|
29
|
+
|
|
30
|
+
## Running with Context Variables
|
|
31
|
+
|
|
32
|
+
Use `run()` for async evaluation with injected variables. This is the async equivalent of `runSync()`.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
const result = await vm.run('numbers.reduce((a, b) => a + b, 0)', {
|
|
36
|
+
numbers: [10, 20, 30, 40]
|
|
37
|
+
})
|
|
38
|
+
console.log('Sum of [10, 20, 30, 40]:', result)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Any JavaScript value can be passed through the context -- arrays, objects, functions, and primitives.
|
|
42
|
+
|
|
43
|
+
## Getting the Context Back
|
|
44
|
+
|
|
45
|
+
Use `performSync()` to run code and get both the result and the modified context. This lets you inspect variables that were set during execution.
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
const { result, context } = vm.performSync('x = x * 2; x + 1', { x: 21 })
|
|
49
|
+
console.log('Result:', result)
|
|
50
|
+
console.log('x after execution:', context.x)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The context is mutated in place, so you can see side effects of the evaluated code.
|
|
54
|
+
|
|
55
|
+
## Shared State Across Runs
|
|
56
|
+
|
|
57
|
+
Use `createContext()` to build a persistent context that carries state across multiple evaluations.
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
const ctx = vm.createContext({ counter: 0 })
|
|
61
|
+
vm.runSync('counter += 1', ctx)
|
|
62
|
+
vm.runSync('counter += 1', ctx)
|
|
63
|
+
vm.runSync('counter += 10', ctx)
|
|
64
|
+
console.log('Counter after 3 runs:', vm.runSync('counter', ctx))
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The same context object is reused, so variables accumulate across calls.
|
|
68
|
+
|
|
69
|
+
## Error Handling
|
|
70
|
+
|
|
71
|
+
When evaluated code might throw, wrap the call in a try/catch to handle it gracefully.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
try {
|
|
75
|
+
vm.runSync('undefinedFunction()')
|
|
76
|
+
} catch (err) {
|
|
77
|
+
console.log('Error caught:', err.constructor.name)
|
|
78
|
+
console.log('Message:', err.message)
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
This keeps a bad snippet from crashing the rest of your program.
|
|
83
|
+
|
|
84
|
+
## Summary
|
|
85
|
+
|
|
86
|
+
This demo covered synchronous and async expression evaluation, passing context variables into the sandbox, inspecting mutated context after execution, maintaining shared state across runs, and safe error handling. The `vm` feature is the foundation for dynamic code execution in any Luca application.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Window Manager"
|
|
3
|
+
tags: [windowManager, native, ipc, macos, browser, window]
|
|
4
|
+
lastTested: null
|
|
5
|
+
lastTestPassed: null
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# windowManager
|
|
9
|
+
|
|
10
|
+
Native window control via LucaVoiceLauncher IPC. Communicates with the macOS launcher app over a Unix domain socket using NDJSON to spawn, navigate, screenshot, and manage native browser windows.
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Use the `windowManager` feature when you need to control native browser windows from Luca. It acts as an IPC server that the LucaVoiceLauncher macOS app connects to. Through this connection you can spawn windows with configurable chrome, navigate URLs, evaluate JavaScript, capture screenshots, and record video.
|
|
15
|
+
|
|
16
|
+
Requires the LucaVoiceLauncher native macOS app to be running and connected.
|
|
17
|
+
|
|
18
|
+
## Enabling the Feature
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const wm = container.feature('windowManager', {
|
|
22
|
+
autoListen: false,
|
|
23
|
+
requestTimeoutMs: 10000
|
|
24
|
+
})
|
|
25
|
+
console.log('Window Manager feature created')
|
|
26
|
+
console.log('Listening:', wm.isListening)
|
|
27
|
+
console.log('Client connected:', wm.isClientConnected)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## API Documentation
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
const info = await container.features.describe('windowManager')
|
|
34
|
+
console.log(info)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Spawning Windows
|
|
38
|
+
|
|
39
|
+
Create native browser windows with configurable dimensions and chrome.
|
|
40
|
+
|
|
41
|
+
```ts skip
|
|
42
|
+
const result = await wm.spawn({
|
|
43
|
+
url: 'https://google.com',
|
|
44
|
+
width: 1024,
|
|
45
|
+
height: 768,
|
|
46
|
+
alwaysOnTop: true,
|
|
47
|
+
window: { decorations: 'hiddenTitleBar', shadow: true }
|
|
48
|
+
})
|
|
49
|
+
console.log('Window ID:', result.windowId)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The `spawn()` method sends a dispatch to the native app and waits for acknowledgement. Window options include position, size, transparency, click-through, and title bar style.
|
|
53
|
+
|
|
54
|
+
## Navigation and JavaScript Evaluation
|
|
55
|
+
|
|
56
|
+
Control window content after spawning.
|
|
57
|
+
|
|
58
|
+
```ts skip
|
|
59
|
+
const handle = wm.window(result.windowId)
|
|
60
|
+
await handle.navigate('https://news.ycombinator.com')
|
|
61
|
+
console.log('Navigated')
|
|
62
|
+
|
|
63
|
+
const title = await handle.eval('document.title')
|
|
64
|
+
console.log('Page title:', title)
|
|
65
|
+
|
|
66
|
+
await handle.focus()
|
|
67
|
+
await handle.close()
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The `window()` method returns a `WindowHandle` for chainable operations on a specific window. Use `eval()` to run JavaScript in the window's web view.
|
|
71
|
+
|
|
72
|
+
## Screenshots and Video
|
|
73
|
+
|
|
74
|
+
Capture visual output from windows.
|
|
75
|
+
|
|
76
|
+
```ts skip
|
|
77
|
+
await wm.screengrab({
|
|
78
|
+
windowId: result.windowId,
|
|
79
|
+
path: './screenshot.png'
|
|
80
|
+
})
|
|
81
|
+
console.log('Screenshot saved')
|
|
82
|
+
|
|
83
|
+
await wm.video({
|
|
84
|
+
windowId: result.windowId,
|
|
85
|
+
path: './recording.mp4',
|
|
86
|
+
durationMs: 5000
|
|
87
|
+
})
|
|
88
|
+
console.log('Video recorded')
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Screenshots are saved as PNG. Video recording captures for the specified duration.
|
|
92
|
+
|
|
93
|
+
## Terminal Windows
|
|
94
|
+
|
|
95
|
+
Spawn native terminal windows that render command output with ANSI support.
|
|
96
|
+
|
|
97
|
+
```ts skip
|
|
98
|
+
const tty = await wm.spawnTTY({
|
|
99
|
+
command: 'htop',
|
|
100
|
+
title: 'System Monitor',
|
|
101
|
+
width: 900,
|
|
102
|
+
height: 600,
|
|
103
|
+
cols: 120,
|
|
104
|
+
rows: 40
|
|
105
|
+
})
|
|
106
|
+
console.log('TTY window:', tty.windowId)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Terminal windows are read-only displays of process output. Closing the window terminates the process.
|
|
110
|
+
|
|
111
|
+
## IPC Communication
|
|
112
|
+
|
|
113
|
+
Other features can send arbitrary messages over the socket connection.
|
|
114
|
+
|
|
115
|
+
```ts skip
|
|
116
|
+
wm.listen()
|
|
117
|
+
wm.on('message', (msg) => console.log('App says:', msg))
|
|
118
|
+
wm.send({ id: 'abc', status: 'ready', speech: 'Window manager online' })
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The `message` event fires for any non-windowAck message from the native app.
|
|
122
|
+
|
|
123
|
+
## Summary
|
|
124
|
+
|
|
125
|
+
The `windowManager` feature provides native window control through IPC with the LucaVoiceLauncher app. Spawn browser windows, navigate, evaluate JS, capture screenshots, and record video. Supports terminal windows for command output. Key methods: `spawn()`, `navigate()`, `eval()`, `screengrab()`, `video()`, `spawnTTY()`, `window()`.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "YAML Tree"
|
|
3
|
+
tags: [yamlTree, yaml, files, data-loading]
|
|
4
|
+
lastTested: null
|
|
5
|
+
lastTestPassed: null
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# yamlTree
|
|
9
|
+
|
|
10
|
+
Load YAML files from directory structures into a nested object tree.
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
The `yamlTree` feature is an on-demand feature that recursively scans a directory for `.yml` and `.yaml` files and builds a hierarchical JavaScript object from them. It works identically to `jsonTree` but for YAML content. File paths are converted to camelCased property paths, so `config/database/production.yml` becomes `tree.config.database.production`. This is useful for projects that store configuration, infrastructure definitions, or data in YAML format.
|
|
15
|
+
|
|
16
|
+
## Feature Documentation
|
|
17
|
+
|
|
18
|
+
Let us inspect the feature's built-in documentation.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const desc = container.features.describe('yamlTree')
|
|
22
|
+
console.log(desc)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Like jsonTree, the key method is `loadTree(basePath, key?)` and the data is accessed through the `tree` getter.
|
|
26
|
+
|
|
27
|
+
## Enabling the Feature
|
|
28
|
+
|
|
29
|
+
Enable yamlTree and check its initial state.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
const yamlTree = container.feature('yamlTree', { enable: true })
|
|
33
|
+
console.log('yamlTree enabled:', yamlTree.state.enabled)
|
|
34
|
+
console.log('Initial tree:', JSON.stringify(yamlTree.tree))
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The tree starts empty until you load directories into it.
|
|
38
|
+
|
|
39
|
+
## Loading YAML Files
|
|
40
|
+
|
|
41
|
+
We can attempt to load YAML files from the project. If the project has any `.yml` or `.yaml` files, they will appear in the tree.
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
await yamlTree.loadTree('.', 'root')
|
|
45
|
+
const keys = Object.keys(yamlTree.tree.root || {})
|
|
46
|
+
console.log('Keys loaded under root:', keys.length ? keys.join(', ') : '(no YAML files found)')
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
If no YAML files are found, the tree for that key will be empty. This is expected for projects that do not use YAML.
|
|
50
|
+
|
|
51
|
+
## How It Compares to jsonTree
|
|
52
|
+
|
|
53
|
+
The yamlTree and jsonTree features share the same design pattern:
|
|
54
|
+
|
|
55
|
+
- Both recursively scan directories
|
|
56
|
+
- Both convert file paths to camelCased property paths
|
|
57
|
+
- Both store results in a `tree` getter
|
|
58
|
+
- Both accept a custom key for namespacing
|
|
59
|
+
|
|
60
|
+
The only difference is the file extensions they look for and the parser they use.
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
const comparison = {
|
|
64
|
+
jsonTree: { extensions: ['.json'], parser: 'JSON.parse' },
|
|
65
|
+
yamlTree: { extensions: ['.yml', '.yaml'], parser: 'YAML parser' },
|
|
66
|
+
}
|
|
67
|
+
for (const [name, info] of Object.entries(comparison)) {
|
|
68
|
+
console.log(`${name}: scans ${info.extensions.join(', ')} files, uses ${info.parser}`)
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Path Transformation Rules
|
|
73
|
+
|
|
74
|
+
The same path transformation rules apply as in jsonTree:
|
|
75
|
+
|
|
76
|
+
- Directory names become nested object properties
|
|
77
|
+
- File names (without extension) become leaf properties
|
|
78
|
+
- All names are converted to camelCase
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
const mappings = {
|
|
82
|
+
'infra/k8s/deployment.yml': 'tree.infra.k8s.deployment',
|
|
83
|
+
'config/app-settings.yaml': 'tree.config.appSettings',
|
|
84
|
+
'data/seed/users.yml': 'tree.data.seed.users',
|
|
85
|
+
}
|
|
86
|
+
for (const [file, path] of Object.entries(mappings)) {
|
|
87
|
+
console.log(`${file} => ${path}`)
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Summary
|
|
92
|
+
|
|
93
|
+
This demo covered the `yamlTree` feature, which scans directories for YAML files (.yml and .yaml) and builds a nested object tree. It follows the same pattern as `jsonTree` and is ideal for projects that rely on YAML for configuration, infrastructure definitions, or structured data.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "YAML"
|
|
3
|
+
tags: [yaml, parsing, serialization, config]
|
|
4
|
+
lastTested: null
|
|
5
|
+
lastTestPassed: null
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# yaml
|
|
9
|
+
|
|
10
|
+
Parse YAML strings into JavaScript objects and serialize objects back to YAML. A thin wrapper around js-yaml.
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
The `yaml` feature is on-demand. It provides two methods: `parse()` and `stringify()`. Use it any time you need to read or write YAML configuration files, convert between formats, or work with YAML data in memory.
|
|
15
|
+
|
|
16
|
+
## Parsing a YAML String
|
|
17
|
+
|
|
18
|
+
Start by enabling the feature and parsing some YAML.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const yml = container.feature('yaml')
|
|
22
|
+
const config = yml.parse(`
|
|
23
|
+
name: my-app
|
|
24
|
+
version: 2.1.0
|
|
25
|
+
database:
|
|
26
|
+
host: localhost
|
|
27
|
+
port: 5432
|
|
28
|
+
features:
|
|
29
|
+
- auth
|
|
30
|
+
- logging
|
|
31
|
+
- caching
|
|
32
|
+
`)
|
|
33
|
+
console.log('Parsed name:', config.name)
|
|
34
|
+
console.log('Parsed db host:', config.database.host)
|
|
35
|
+
console.log('Parsed features:', config.features)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The parser handles nested objects, arrays, numbers, and booleans automatically.
|
|
39
|
+
|
|
40
|
+
## Serializing an Object to YAML
|
|
41
|
+
|
|
42
|
+
Use `stringify()` to convert a JavaScript object into a YAML-formatted string.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
const output = yml.stringify({
|
|
46
|
+
server: { host: '0.0.0.0', port: 3000 },
|
|
47
|
+
logging: { level: 'info', pretty: true },
|
|
48
|
+
cors: { origins: ['https://example.com', 'https://app.example.com'] }
|
|
49
|
+
})
|
|
50
|
+
console.log('YAML output:')
|
|
51
|
+
console.log(output)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The output is human-readable and suitable for writing to configuration files.
|
|
55
|
+
|
|
56
|
+
## Round-Trip Conversion
|
|
57
|
+
|
|
58
|
+
A common pattern is reading YAML, modifying data, and writing it back. Here we verify that a round-trip preserves data.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
const original = `
|
|
62
|
+
environment: production
|
|
63
|
+
replicas: 3
|
|
64
|
+
resources:
|
|
65
|
+
cpu: 500m
|
|
66
|
+
memory: 256Mi
|
|
67
|
+
`
|
|
68
|
+
const parsed = yml.parse(original)
|
|
69
|
+
parsed.replicas = 5
|
|
70
|
+
parsed.resources.memory = '512Mi'
|
|
71
|
+
const updated = yml.stringify(parsed)
|
|
72
|
+
console.log('Updated YAML:')
|
|
73
|
+
console.log(updated)
|
|
74
|
+
const reparsed = yml.parse(updated)
|
|
75
|
+
console.log('Replicas after round-trip:', reparsed.replicas)
|
|
76
|
+
console.log('Memory after round-trip:', reparsed.resources.memory)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The data survives the parse-modify-stringify cycle intact.
|
|
80
|
+
|
|
81
|
+
## Working with Complex Structures
|
|
82
|
+
|
|
83
|
+
YAML handles deeply nested and mixed-type structures well.
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
const complex = yml.stringify({
|
|
87
|
+
users: [
|
|
88
|
+
{ name: 'Alice', roles: ['admin', 'editor'], active: true },
|
|
89
|
+
{ name: 'Bob', roles: ['viewer'], active: false },
|
|
90
|
+
],
|
|
91
|
+
settings: {
|
|
92
|
+
maxRetries: 3,
|
|
93
|
+
timeout: null,
|
|
94
|
+
nested: { deep: { value: 42 } }
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
console.log(complex)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Nulls, booleans, numbers, and nested arrays all serialize cleanly.
|
|
101
|
+
|
|
102
|
+
## Summary
|
|
103
|
+
|
|
104
|
+
This demo covered parsing YAML strings, serializing objects to YAML, round-trip conversion, and handling complex nested structures. The `yaml` feature gives you a clean two-method API for all YAML operations.
|