@soederpop/luca 0.1.1 → 0.1.3
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 +2 -0
- package/assistants/codingAssistant/hooks.ts +3 -0
- package/assistants/inkbot/CORE.md +69 -0
- package/assistants/inkbot/hooks.ts +14 -0
- package/assistants/inkbot/tools.ts +47 -0
- package/commands/inkbot.ts +353 -0
- package/dist/agi/container.server.d.ts +63 -0
- package/dist/agi/container.server.d.ts.map +1 -0
- package/dist/agi/endpoints/ask.d.ts +20 -0
- package/dist/agi/endpoints/ask.d.ts.map +1 -0
- package/dist/agi/endpoints/conversations/[id].d.ts +27 -0
- package/dist/agi/endpoints/conversations/[id].d.ts.map +1 -0
- package/dist/agi/endpoints/conversations.d.ts +18 -0
- package/dist/agi/endpoints/conversations.d.ts.map +1 -0
- package/dist/agi/endpoints/experts.d.ts +8 -0
- package/dist/agi/endpoints/experts.d.ts.map +1 -0
- package/dist/agi/feature.d.ts +9 -0
- package/dist/agi/feature.d.ts.map +1 -0
- package/dist/agi/features/assistant.d.ts +509 -0
- package/dist/agi/features/assistant.d.ts.map +1 -0
- package/dist/agi/features/assistants-manager.d.ts +236 -0
- package/dist/agi/features/assistants-manager.d.ts.map +1 -0
- package/dist/agi/features/autonomous-assistant.d.ts +281 -0
- package/dist/agi/features/autonomous-assistant.d.ts.map +1 -0
- package/dist/agi/features/browser-use.d.ts +479 -0
- package/dist/agi/features/browser-use.d.ts.map +1 -0
- package/dist/agi/features/claude-code.d.ts +824 -0
- package/dist/agi/features/claude-code.d.ts.map +1 -0
- package/dist/agi/features/conversation-history.d.ts +245 -0
- package/dist/agi/features/conversation-history.d.ts.map +1 -0
- package/dist/agi/features/conversation.d.ts +464 -0
- package/dist/agi/features/conversation.d.ts.map +1 -0
- package/dist/agi/features/docs-reader.d.ts +72 -0
- package/dist/agi/features/docs-reader.d.ts.map +1 -0
- package/dist/agi/features/file-tools.d.ts +110 -0
- package/dist/agi/features/file-tools.d.ts.map +1 -0
- package/dist/agi/features/luca-coder.d.ts +323 -0
- package/dist/agi/features/luca-coder.d.ts.map +1 -0
- package/dist/agi/features/openai-codex.d.ts +381 -0
- package/dist/agi/features/openai-codex.d.ts.map +1 -0
- package/dist/agi/features/openapi.d.ts +200 -0
- package/dist/agi/features/openapi.d.ts.map +1 -0
- package/dist/agi/features/skills-library.d.ts +167 -0
- package/dist/agi/features/skills-library.d.ts.map +1 -0
- package/dist/agi/index.d.ts +5 -0
- package/dist/agi/index.d.ts.map +1 -0
- package/dist/agi/lib/interceptor-chain.d.ts +44 -0
- package/dist/agi/lib/interceptor-chain.d.ts.map +1 -0
- package/dist/agi/lib/token-counter.d.ts +13 -0
- package/dist/agi/lib/token-counter.d.ts.map +1 -0
- package/dist/bootstrap/generated.d.ts +5 -0
- package/dist/bootstrap/generated.d.ts.map +1 -0
- package/dist/browser.d.ts +12 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/bus.d.ts +29 -0
- package/dist/bus.d.ts.map +1 -0
- package/dist/cli/build-info.d.ts +4 -0
- package/dist/cli/build-info.d.ts.map +1 -0
- package/dist/cli/cli.d.ts +3 -0
- package/dist/cli/cli.d.ts.map +1 -0
- package/dist/client.d.ts +60 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/clients/civitai/index.d.ts +472 -0
- package/dist/clients/civitai/index.d.ts.map +1 -0
- package/dist/clients/client-template.d.ts +30 -0
- package/dist/clients/client-template.d.ts.map +1 -0
- package/dist/clients/comfyui/index.d.ts +281 -0
- package/dist/clients/comfyui/index.d.ts.map +1 -0
- package/dist/clients/elevenlabs/index.d.ts +197 -0
- package/dist/clients/elevenlabs/index.d.ts.map +1 -0
- package/dist/clients/graph.d.ts +64 -0
- package/dist/clients/graph.d.ts.map +1 -0
- package/dist/clients/openai/index.d.ts +247 -0
- package/dist/clients/openai/index.d.ts.map +1 -0
- package/dist/clients/rest.d.ts +92 -0
- package/dist/clients/rest.d.ts.map +1 -0
- package/dist/clients/supabase/index.d.ts +176 -0
- package/dist/clients/supabase/index.d.ts.map +1 -0
- package/dist/clients/websocket.d.ts +127 -0
- package/dist/clients/websocket.d.ts.map +1 -0
- package/dist/command.d.ts +163 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/commands/bootstrap.d.ts +20 -0
- package/dist/commands/bootstrap.d.ts.map +1 -0
- package/dist/commands/chat.d.ts +37 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/code.d.ts +28 -0
- package/dist/commands/code.d.ts.map +1 -0
- package/dist/commands/console.d.ts +22 -0
- package/dist/commands/console.d.ts.map +1 -0
- package/dist/commands/describe.d.ts +50 -0
- package/dist/commands/describe.d.ts.map +1 -0
- package/dist/commands/eval.d.ts +23 -0
- package/dist/commands/eval.d.ts.map +1 -0
- package/dist/commands/help.d.ts +25 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/index.d.ts +18 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/introspect.d.ts +24 -0
- package/dist/commands/introspect.d.ts.map +1 -0
- package/dist/commands/mcp.d.ts +35 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/prompt.d.ts +38 -0
- package/dist/commands/prompt.d.ts.map +1 -0
- package/dist/commands/run.d.ts +24 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/sandbox-mcp.d.ts +34 -0
- package/dist/commands/sandbox-mcp.d.ts.map +1 -0
- package/dist/commands/save-api-docs.d.ts +21 -0
- package/dist/commands/save-api-docs.d.ts.map +1 -0
- package/dist/commands/scaffold.d.ts +24 -0
- package/dist/commands/scaffold.d.ts.map +1 -0
- package/dist/commands/select.d.ts +22 -0
- package/dist/commands/select.d.ts.map +1 -0
- package/dist/commands/serve.d.ts +29 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/container-describer.d.ts +144 -0
- package/dist/container-describer.d.ts.map +1 -0
- package/dist/container.d.ts +451 -0
- package/dist/container.d.ts.map +1 -0
- package/dist/endpoint.d.ts +113 -0
- package/dist/endpoint.d.ts.map +1 -0
- package/dist/feature.d.ts +47 -0
- package/dist/feature.d.ts.map +1 -0
- package/dist/graft.d.ts +29 -0
- package/dist/graft.d.ts.map +1 -0
- package/dist/hash-object.d.ts +8 -0
- package/dist/hash-object.d.ts.map +1 -0
- package/dist/helper.d.ts +209 -0
- package/dist/helper.d.ts.map +1 -0
- package/dist/introspection/generated.node.d.ts +44623 -0
- package/dist/introspection/generated.node.d.ts.map +1 -0
- package/dist/introspection/generated.web.d.ts +1412 -0
- package/dist/introspection/generated.web.d.ts.map +1 -0
- package/dist/introspection/index.d.ts +156 -0
- package/dist/introspection/index.d.ts.map +1 -0
- package/dist/introspection/scan.d.ts +147 -0
- package/dist/introspection/scan.d.ts.map +1 -0
- package/dist/node/container.d.ts +256 -0
- package/dist/node/container.d.ts.map +1 -0
- package/dist/node/feature.d.ts +9 -0
- package/dist/node/feature.d.ts.map +1 -0
- package/dist/node/features/container-link.d.ts +213 -0
- package/dist/node/features/container-link.d.ts.map +1 -0
- package/dist/node/features/content-db.d.ts +354 -0
- package/dist/node/features/content-db.d.ts.map +1 -0
- package/dist/node/features/disk-cache.d.ts +236 -0
- package/dist/node/features/disk-cache.d.ts.map +1 -0
- package/dist/node/features/dns.d.ts +511 -0
- package/dist/node/features/dns.d.ts.map +1 -0
- package/dist/node/features/docker.d.ts +485 -0
- package/dist/node/features/docker.d.ts.map +1 -0
- package/dist/node/features/downloader.d.ts +73 -0
- package/dist/node/features/downloader.d.ts.map +1 -0
- package/dist/node/features/figlet-fonts.d.ts +4 -0
- package/dist/node/features/figlet-fonts.d.ts.map +1 -0
- package/dist/node/features/file-manager.d.ts +177 -0
- package/dist/node/features/file-manager.d.ts.map +1 -0
- package/dist/node/features/fs.d.ts +635 -0
- package/dist/node/features/fs.d.ts.map +1 -0
- package/dist/node/features/git.d.ts +329 -0
- package/dist/node/features/git.d.ts.map +1 -0
- package/dist/node/features/google-auth.d.ts +200 -0
- package/dist/node/features/google-auth.d.ts.map +1 -0
- package/dist/node/features/google-calendar.d.ts +194 -0
- package/dist/node/features/google-calendar.d.ts.map +1 -0
- package/dist/node/features/google-docs.d.ts +138 -0
- package/dist/node/features/google-docs.d.ts.map +1 -0
- package/dist/node/features/google-drive.d.ts +202 -0
- package/dist/node/features/google-drive.d.ts.map +1 -0
- package/dist/node/features/google-mail.d.ts +221 -0
- package/dist/node/features/google-mail.d.ts.map +1 -0
- package/dist/node/features/google-sheets.d.ts +157 -0
- package/dist/node/features/google-sheets.d.ts.map +1 -0
- package/dist/node/features/grep.d.ts +207 -0
- package/dist/node/features/grep.d.ts.map +1 -0
- package/dist/node/features/helpers.d.ts +236 -0
- package/dist/node/features/helpers.d.ts.map +1 -0
- package/dist/node/features/ink.d.ts +332 -0
- package/dist/node/features/ink.d.ts.map +1 -0
- package/dist/node/features/ipc-socket.d.ts +298 -0
- package/dist/node/features/ipc-socket.d.ts.map +1 -0
- package/dist/node/features/json-tree.d.ts +140 -0
- package/dist/node/features/json-tree.d.ts.map +1 -0
- package/dist/node/features/networking.d.ts +373 -0
- package/dist/node/features/networking.d.ts.map +1 -0
- package/dist/node/features/nlp.d.ts +125 -0
- package/dist/node/features/nlp.d.ts.map +1 -0
- package/dist/node/features/opener.d.ts +93 -0
- package/dist/node/features/opener.d.ts.map +1 -0
- package/dist/node/features/os.d.ts +168 -0
- package/dist/node/features/os.d.ts.map +1 -0
- package/dist/node/features/package-finder.d.ts +419 -0
- package/dist/node/features/package-finder.d.ts.map +1 -0
- package/dist/node/features/postgres.d.ts +173 -0
- package/dist/node/features/postgres.d.ts.map +1 -0
- package/dist/node/features/proc.d.ts +285 -0
- package/dist/node/features/proc.d.ts.map +1 -0
- package/dist/node/features/process-manager.d.ts +427 -0
- package/dist/node/features/process-manager.d.ts.map +1 -0
- package/dist/node/features/python.d.ts +477 -0
- package/dist/node/features/python.d.ts.map +1 -0
- package/dist/node/features/redis.d.ts +247 -0
- package/dist/node/features/redis.d.ts.map +1 -0
- package/dist/node/features/repl.d.ts +84 -0
- package/dist/node/features/repl.d.ts.map +1 -0
- package/dist/node/features/runpod.d.ts +527 -0
- package/dist/node/features/runpod.d.ts.map +1 -0
- package/dist/node/features/secure-shell.d.ts +145 -0
- package/dist/node/features/secure-shell.d.ts.map +1 -0
- package/dist/node/features/semantic-search.d.ts +207 -0
- package/dist/node/features/semantic-search.d.ts.map +1 -0
- package/dist/node/features/sqlite.d.ts +180 -0
- package/dist/node/features/sqlite.d.ts.map +1 -0
- package/dist/node/features/telegram.d.ts +173 -0
- package/dist/node/features/telegram.d.ts.map +1 -0
- package/dist/node/features/transpiler.d.ts +51 -0
- package/dist/node/features/transpiler.d.ts.map +1 -0
- package/dist/node/features/tts.d.ts +108 -0
- package/dist/node/features/tts.d.ts.map +1 -0
- package/dist/node/features/ui.d.ts +562 -0
- package/dist/node/features/ui.d.ts.map +1 -0
- package/dist/node/features/vault.d.ts +90 -0
- package/dist/node/features/vault.d.ts.map +1 -0
- package/dist/node/features/vm.d.ts +285 -0
- package/dist/node/features/vm.d.ts.map +1 -0
- package/dist/node/features/yaml-tree.d.ts +118 -0
- package/dist/node/features/yaml-tree.d.ts.map +1 -0
- package/dist/node/features/yaml.d.ts +127 -0
- package/dist/node/features/yaml.d.ts.map +1 -0
- package/dist/node.d.ts +67 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/python/generated.d.ts +2 -0
- package/dist/python/generated.d.ts.map +1 -0
- package/dist/react/index.d.ts +36 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/registry.d.ts +97 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/scaffolds/generated.d.ts +13 -0
- package/dist/scaffolds/generated.d.ts.map +1 -0
- package/dist/scaffolds/template.d.ts +11 -0
- package/dist/scaffolds/template.d.ts.map +1 -0
- package/dist/schemas/base.d.ts +254 -0
- package/dist/schemas/base.d.ts.map +1 -0
- package/dist/selector.d.ts +130 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/server.d.ts +89 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/servers/express.d.ts +104 -0
- package/dist/servers/express.d.ts.map +1 -0
- package/dist/servers/mcp.d.ts +201 -0
- package/dist/servers/mcp.d.ts.map +1 -0
- package/dist/servers/socket.d.ts +121 -0
- package/dist/servers/socket.d.ts.map +1 -0
- package/dist/state.d.ts +24 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/web/clients/socket.d.ts +37 -0
- package/dist/web/clients/socket.d.ts.map +1 -0
- package/dist/web/container.d.ts +55 -0
- package/dist/web/container.d.ts.map +1 -0
- package/dist/web/extension.d.ts +4 -0
- package/dist/web/extension.d.ts.map +1 -0
- package/dist/web/feature.d.ts +8 -0
- package/dist/web/feature.d.ts.map +1 -0
- package/dist/web/features/asset-loader.d.ts +35 -0
- package/dist/web/features/asset-loader.d.ts.map +1 -0
- package/dist/web/features/container-link.d.ts +167 -0
- package/dist/web/features/container-link.d.ts.map +1 -0
- package/dist/web/features/esbuild.d.ts +51 -0
- package/dist/web/features/esbuild.d.ts.map +1 -0
- package/dist/web/features/helpers.d.ts +140 -0
- package/dist/web/features/helpers.d.ts.map +1 -0
- package/dist/web/features/network.d.ts +69 -0
- package/dist/web/features/network.d.ts.map +1 -0
- package/dist/web/features/speech.d.ts +71 -0
- package/dist/web/features/speech.d.ts.map +1 -0
- package/dist/web/features/vault.d.ts +62 -0
- package/dist/web/features/vault.d.ts.map +1 -0
- package/dist/web/features/vm.d.ts +48 -0
- package/dist/web/features/vm.d.ts.map +1 -0
- package/dist/web/features/voice-recognition.d.ts +96 -0
- package/dist/web/features/voice-recognition.d.ts.map +1 -0
- package/dist/web/shims/isomorphic-vm.d.ts +22 -0
- package/dist/web/shims/isomorphic-vm.d.ts.map +1 -0
- package/docs/apis/features/agi/assistant.md +1 -0
- package/docs/apis/features/agi/assistants-manager.md +62 -2
- package/docs/apis/features/agi/auto-assistant.md +11 -109
- package/docs/apis/features/agi/claude-code.md +138 -0
- package/docs/apis/features/agi/conversation.md +60 -31
- package/docs/apis/features/agi/luca-coder.md +407 -0
- package/docs/apis/features/agi/openapi.md +2 -2
- package/docs/apis/features/agi/skills-library.md +12 -0
- package/docs/apis/features/node/python.md +81 -11
- package/docs/apis/features/node/transpiler.md +74 -0
- package/docs/apis/features/web/esbuild.md +0 -6
- package/docs/apis/servers/mcp.md +2 -2
- package/docs/examples/entity.md +124 -0
- package/package.json +73 -21
- package/scripts/test-assistant-hooks.ts +13 -0
- package/src/agi/feature.ts +13 -0
- package/src/agi/features/assistant.ts +36 -25
- package/src/agi/features/assistants-manager.ts +70 -5
- package/src/agi/features/autonomous-assistant.ts +1 -5
- package/src/agi/features/browser-use.ts +2 -2
- package/src/agi/features/claude-code.ts +165 -1
- package/src/agi/features/conversation-history.ts +2 -6
- package/src/agi/features/conversation.ts +95 -3
- package/src/agi/features/docs-reader.ts +2 -1
- package/src/agi/features/file-tools.ts +2 -2
- package/src/agi/features/luca-coder.ts +1 -5
- package/src/agi/features/openai-codex.ts +1 -1
- package/src/agi/features/openapi.ts +3 -3
- package/src/agi/features/skills-library.ts +90 -2
- package/src/agi/lib/interceptor-chain.ts +10 -0
- package/src/agi/lib/token-counter.ts +1 -1
- package/src/bootstrap/generated.ts +126 -1
- package/src/bus.ts +27 -5
- package/src/cli/build-info.ts +2 -2
- package/src/client.ts +2 -2
- package/src/clients/elevenlabs/index.ts +5 -0
- package/src/commands/bootstrap.ts +2 -1
- package/src/commands/chat.ts +1 -0
- package/src/commands/code.ts +4 -2
- package/src/commands/prompt.ts +34 -34
- package/src/commands/sandbox-mcp.ts +69 -163
- package/src/commands/save-api-docs.ts +10 -8
- package/src/commands/select.ts +8 -3
- package/src/container-describer.ts +70 -84
- package/src/container.ts +93 -3
- package/src/endpoint.ts +1 -1
- package/src/entity.ts +173 -0
- package/src/feature.ts +3 -3
- package/src/helper.ts +8 -4
- package/src/introspection/generated.agi.ts +1403 -929
- package/src/introspection/generated.node.ts +127 -33
- package/src/introspection/generated.web.ts +95 -3
- package/src/introspection/scan.ts +1 -1
- package/src/node/container.ts +1 -1
- package/src/node/features/content-db.ts +3 -3
- package/src/node/features/file-manager.ts +10 -9
- package/src/node/features/git.ts +5 -5
- package/src/node/features/helpers.ts +1 -1
- package/src/node/features/json-tree.ts +1 -1
- package/src/node/features/os.ts +3 -3
- package/src/node/features/package-finder.ts +1 -1
- package/src/node/features/process-manager.ts +1 -1
- package/src/node/features/python.ts +3 -3
- package/src/node/features/redis.ts +1 -1
- package/src/node/features/repl.ts +2 -2
- package/src/node/features/transpiler.ts +34 -9
- package/src/node/features/ui.ts +1 -1
- package/src/node/features/vm.ts +6 -5
- package/src/node/features/yaml-tree.ts +1 -1
- package/src/node.ts +1 -0
- package/src/python/generated.ts +1 -1
- package/src/scaffolds/generated.ts +1 -1
- package/src/selector.ts +74 -4
- package/src/server.ts +2 -2
- package/src/servers/mcp.ts +6 -6
- package/src/web/features/helpers.ts +1 -1
- package/src/web/features/network.ts +1 -0
- package/test/assistant.test.ts +72 -0
- package/test/conversation.test.ts +220 -0
- package/test/vm-loadmodule.test.ts +213 -0
- package/tsconfig.build.json +12 -0
- package/tsconfig.json +1 -1
- package/scripts/examples/telegram-ink-ui.ts +0 -302
- package/scripts/examples/using-openai-codex.ts +0 -23
- package/scripts/examples/vm-loading-esm-modules.ts +0 -16
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Feature } from '../feature.js';
|
|
3
|
+
import { type ContainerContext } from '../../container.js';
|
|
4
|
+
export declare const VaultStateSchema: z.ZodObject<{
|
|
5
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
6
|
+
secret: z.ZodOptional<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>;
|
|
7
|
+
}, z.core.$loose>;
|
|
8
|
+
export type VaultState = z.infer<typeof VaultStateSchema>;
|
|
9
|
+
export declare const VaultOptionsSchema: z.ZodObject<{
|
|
10
|
+
name: z.ZodOptional<z.ZodString>;
|
|
11
|
+
_cacheKey: z.ZodOptional<z.ZodString>;
|
|
12
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
enable: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
secret: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodString]>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export type VaultOptions = z.infer<typeof VaultOptionsSchema>;
|
|
17
|
+
/**
|
|
18
|
+
* The Vault feature provides encryption and decryption capabilities using AES-256-GCM.
|
|
19
|
+
*
|
|
20
|
+
* This feature allows you to securely encrypt and decrypt sensitive data using
|
|
21
|
+
* industry-standard encryption. It manages secret keys and provides a simple
|
|
22
|
+
* interface for cryptographic operations.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const vault = container.feature('vault')
|
|
27
|
+
*
|
|
28
|
+
* // Encrypt sensitive data
|
|
29
|
+
* const encrypted = vault.encrypt('sensitive information')
|
|
30
|
+
* console.log(encrypted) // Base64 encoded encrypted data
|
|
31
|
+
*
|
|
32
|
+
* // Decrypt the data
|
|
33
|
+
* const decrypted = vault.decrypt(encrypted)
|
|
34
|
+
* console.log(decrypted) // 'sensitive information'
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @extends Feature
|
|
38
|
+
*/
|
|
39
|
+
export declare class Vault extends Feature<VaultState, VaultOptions> {
|
|
40
|
+
static shortcut: "features.vault";
|
|
41
|
+
static stateSchema: z.ZodObject<{
|
|
42
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
43
|
+
secret: z.ZodOptional<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>;
|
|
44
|
+
}, z.core.$loose>;
|
|
45
|
+
static optionsSchema: z.ZodObject<{
|
|
46
|
+
name: z.ZodOptional<z.ZodString>;
|
|
47
|
+
_cacheKey: z.ZodOptional<z.ZodString>;
|
|
48
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
enable: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
+
secret: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodString]>>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
constructor(options: VaultOptions, context: ContainerContext);
|
|
53
|
+
/**
|
|
54
|
+
* Gets the secret key as a base64-encoded string.
|
|
55
|
+
*
|
|
56
|
+
* @returns {string | undefined} The secret key encoded as base64, or undefined if no secret is set
|
|
57
|
+
*/
|
|
58
|
+
get secretText(): string;
|
|
59
|
+
/**
|
|
60
|
+
* Gets or generates a secret key for encryption operations.
|
|
61
|
+
*
|
|
62
|
+
* @param {object} [options={}] - Options for secret key handling
|
|
63
|
+
* @param {boolean} [options.refresh=false] - Whether to generate a new secret key
|
|
64
|
+
* @param {boolean} [options.set=true] - Whether to store the generated key in state
|
|
65
|
+
* @returns {Buffer} The secret key as a Buffer
|
|
66
|
+
*/
|
|
67
|
+
secret({ refresh, set }?: {
|
|
68
|
+
refresh?: boolean | undefined;
|
|
69
|
+
set?: boolean | undefined;
|
|
70
|
+
}): Buffer;
|
|
71
|
+
/**
|
|
72
|
+
* Decrypts an encrypted payload that was created by the encrypt method.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} payload - The encrypted payload to decrypt (base64 encoded with delimiters)
|
|
75
|
+
* @returns {string} The decrypted plaintext
|
|
76
|
+
* @throws {Error} Throws an error if decryption fails or the payload is malformed
|
|
77
|
+
*/
|
|
78
|
+
decrypt(payload: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Encrypts a plaintext string using AES-256-GCM encryption.
|
|
81
|
+
*
|
|
82
|
+
* @param {string} payload - The plaintext string to encrypt
|
|
83
|
+
* @returns {string} The encrypted payload as a base64 encoded string with delimiters
|
|
84
|
+
*/
|
|
85
|
+
encrypt(payload: string): string;
|
|
86
|
+
private _encrypt;
|
|
87
|
+
private _decrypt;
|
|
88
|
+
}
|
|
89
|
+
export default Vault;
|
|
90
|
+
//# sourceMappingURL=vault.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["../../../src/node/features/vault.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,eAAO,MAAM,gBAAgB;;;iBAG3B,CAAA;AACF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAEzD,eAAO,MAAM,kBAAkB;;;;;;iBAG7B,CAAA;AACF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAE7D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,KAAM,SAAQ,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC;IAC1D,OAAgB,QAAQ,EAAG,gBAAgB,CAAS;IACpD,OAAgB,WAAW;;;sBAAmB;IAC9C,OAAgB,aAAa;;;;;;sBAAqB;gBAGtC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,gBAAgB;IAY5D;;;;OAIG;IACH,IAAI,UAAU,WAEb;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,OAAe,EAAE,GAAU,EAAE;;;KAAK,GAAI,MAAM;IAcrD;;;;;;OAMG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM;IAKvB;;;;;OAKG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM;IAUvB,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,QAAQ;CAGjB;AAED,eAAe,KAAK,CAAA"}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import vm from 'vm';
|
|
3
|
+
import { Feature } from "../feature.js";
|
|
4
|
+
export declare const VMStateSchema: z.ZodObject<{
|
|
5
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
6
|
+
}, z.core.$loose>;
|
|
7
|
+
export type VMState = z.infer<typeof VMStateSchema>;
|
|
8
|
+
export declare const VMOptionsSchema: z.ZodObject<{
|
|
9
|
+
name: z.ZodOptional<z.ZodString>;
|
|
10
|
+
_cacheKey: z.ZodOptional<z.ZodString>;
|
|
11
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
+
enable: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
context: z.ZodAny;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export type VMOptions = z.infer<typeof VMOptionsSchema>;
|
|
16
|
+
/**
|
|
17
|
+
* The VM feature provides Node.js virtual machine capabilities for executing JavaScript code.
|
|
18
|
+
*
|
|
19
|
+
* This feature wraps Node.js's built-in `vm` module to provide secure code execution
|
|
20
|
+
* in isolated contexts. It's useful for running untrusted code, creating sandboxed
|
|
21
|
+
* environments, or dynamically executing code with controlled access to variables and modules.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const vm = container.feature('vm')
|
|
26
|
+
*
|
|
27
|
+
* // Execute simple code
|
|
28
|
+
* const result = vm.run('1 + 2 + 3')
|
|
29
|
+
* console.log(result) // 6
|
|
30
|
+
*
|
|
31
|
+
* // Execute code with custom context
|
|
32
|
+
* const result2 = vm.run('greeting + " " + name', {
|
|
33
|
+
* greeting: 'Hello',
|
|
34
|
+
* name: 'World'
|
|
35
|
+
* })
|
|
36
|
+
* console.log(result2) // 'Hello World'
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @extends Feature
|
|
40
|
+
*/
|
|
41
|
+
export declare class VM<T extends VMState = VMState, K extends VMOptions = VMOptions> extends Feature<T, K> {
|
|
42
|
+
static shortcut: "features.vm";
|
|
43
|
+
static stateSchema: z.ZodObject<{
|
|
44
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
45
|
+
}, z.core.$loose>;
|
|
46
|
+
static optionsSchema: z.ZodObject<{
|
|
47
|
+
name: z.ZodOptional<z.ZodString>;
|
|
48
|
+
_cacheKey: z.ZodOptional<z.ZodString>;
|
|
49
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
+
enable: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
context: z.ZodAny;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
/** Map of virtual module IDs to their exports, consulted before Node's native require */
|
|
54
|
+
modules: Map<string, any>;
|
|
55
|
+
/**
|
|
56
|
+
* Register a virtual module that will be available to `require()` inside VM-executed code.
|
|
57
|
+
* Modules registered here take precedence over Node's native resolution.
|
|
58
|
+
*
|
|
59
|
+
* @param id - The module specifier (e.g. `'@soederpop/luca'`, `'zod'`)
|
|
60
|
+
* @param exports - The module's exports object
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const vm = container.feature('vm')
|
|
65
|
+
* vm.defineModule('@soederpop/luca', { Container, Feature, fs, proc })
|
|
66
|
+
* vm.defineModule('zod', { z })
|
|
67
|
+
*
|
|
68
|
+
* // Now loadModule can resolve these in user code:
|
|
69
|
+
* // import { Container } from '@soederpop/luca' → works
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
defineModule(id: string, exports: any): void;
|
|
73
|
+
/**
|
|
74
|
+
* Build a require function that resolves from the virtual modules map first,
|
|
75
|
+
* falling back to Node's native `createRequire` for everything else.
|
|
76
|
+
*
|
|
77
|
+
* @param filePath - The file path to scope native require resolution to
|
|
78
|
+
* @returns A require function with `.resolve` preserved from the native require
|
|
79
|
+
*/
|
|
80
|
+
createRequireFor(filePath: string): ((id: string) => any) & {
|
|
81
|
+
resolve: RequireResolve;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Creates a new VM script from the provided code.
|
|
85
|
+
*
|
|
86
|
+
* This method compiles JavaScript code into a VM script that can be executed
|
|
87
|
+
* multiple times in different contexts. The script is pre-compiled for better
|
|
88
|
+
* performance when executing the same code repeatedly.
|
|
89
|
+
*
|
|
90
|
+
* @param {string} code - The JavaScript code to compile into a script
|
|
91
|
+
* @param {vm.ScriptOptions} [options] - Options for script compilation
|
|
92
|
+
* @returns {vm.Script} A compiled VM script ready for execution
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const script = vm.createScript('Math.max(a, b)')
|
|
97
|
+
*
|
|
98
|
+
* // Execute the script multiple times with different contexts
|
|
99
|
+
* const result1 = script.runInContext(vm.createContext({ a: 5, b: 3 }))
|
|
100
|
+
* const result2 = script.runInContext(vm.createContext({ a: 10, b: 20 }))
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
createScript(code: string, options?: vm.ScriptOptions): vm.Script;
|
|
104
|
+
/**
|
|
105
|
+
* Check whether an object has already been contextified by `vm.createContext()`.
|
|
106
|
+
*
|
|
107
|
+
* Useful to avoid double-contextifying when you're not sure if the caller
|
|
108
|
+
* passed a plain object or an existing context.
|
|
109
|
+
*
|
|
110
|
+
* @param ctx - The object to check
|
|
111
|
+
* @returns True if the object is a VM context
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* const ctx = vm.createContext({ x: 1 })
|
|
116
|
+
* vm.isContext(ctx) // true
|
|
117
|
+
* vm.isContext({ x: 1 }) // false
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
isContext(ctx: unknown): ctx is vm.Context;
|
|
121
|
+
/**
|
|
122
|
+
* Create an isolated JavaScript execution context.
|
|
123
|
+
*
|
|
124
|
+
* Combines the container's context with any additional variables provided.
|
|
125
|
+
* If the input is already a VM context, it is returned as-is.
|
|
126
|
+
*
|
|
127
|
+
* @param ctx - Additional context variables to include
|
|
128
|
+
* @returns A VM context ready for script execution
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const context = vm.createContext({ user: { name: 'John' } })
|
|
133
|
+
* const result = vm.runSync('user.name', context)
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
createContext(ctx?: any): vm.Context;
|
|
137
|
+
/**
|
|
138
|
+
* Executes JavaScript code in a controlled environment.
|
|
139
|
+
*
|
|
140
|
+
* This method creates a script from the provided code, sets up an execution context
|
|
141
|
+
* with the specified variables, and runs the code safely. It handles errors gracefully
|
|
142
|
+
* and returns either the result or the error object.
|
|
143
|
+
*
|
|
144
|
+
* @param {string} code - The JavaScript code to execute
|
|
145
|
+
* @param {any} [ctx={}] - Context variables to make available to the executing code
|
|
146
|
+
* @returns {any} The result of the code execution, or an Error object if execution failed
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* // Simple calculation
|
|
151
|
+
* const result = vm.run('2 + 3 * 4')
|
|
152
|
+
* console.log(result) // 14
|
|
153
|
+
*
|
|
154
|
+
* // Using context variables
|
|
155
|
+
* const greeting = vm.run('`Hello ${name}!`', { name: 'Alice' })
|
|
156
|
+
* console.log(greeting) // 'Hello Alice!'
|
|
157
|
+
*
|
|
158
|
+
* // Array operations
|
|
159
|
+
* const sum = vm.run('numbers.reduce((a, b) => a + b, 0)', {
|
|
160
|
+
* numbers: [1, 2, 3, 4, 5]
|
|
161
|
+
* })
|
|
162
|
+
* console.log(sum) // 15
|
|
163
|
+
*
|
|
164
|
+
* // Error handling
|
|
165
|
+
* const error = vm.run('invalidFunction()')
|
|
166
|
+
* if (error instanceof Error) {
|
|
167
|
+
* console.log('Execution failed:', error.message)
|
|
168
|
+
* }
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
/**
|
|
172
|
+
* Wrap code containing top-level `await` in an async IIFE, injecting
|
|
173
|
+
* `return` before the last expression so the value is not lost.
|
|
174
|
+
*
|
|
175
|
+
* If the code does not contain `await`, or is already wrapped in an
|
|
176
|
+
* async function/arrow, it is returned unchanged.
|
|
177
|
+
*/
|
|
178
|
+
wrapTopLevelAwait(code: string): string;
|
|
179
|
+
run<T extends any>(code: string, ctx?: any): Promise<T>;
|
|
180
|
+
/**
|
|
181
|
+
* Execute code and capture all console output as structured JSON.
|
|
182
|
+
*
|
|
183
|
+
* Returns both the execution result and an array of every `console.*` call
|
|
184
|
+
* made during execution, each entry recording the method name and arguments.
|
|
185
|
+
*
|
|
186
|
+
* @param code - The JavaScript code to execute
|
|
187
|
+
* @param ctx - Context variables to make available to the executing code
|
|
188
|
+
* @returns The result, an array of captured console calls, and the context
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* const { result, console: calls } = await vm.runCaptured('console.log("hi"); console.warn("oh"); 42')
|
|
193
|
+
* // result === 42
|
|
194
|
+
* // calls === [{ method: 'log', args: ['hi'] }, { method: 'warn', args: ['oh'] }]
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
runCaptured<T extends any>(code: string, ctx?: any): Promise<{
|
|
198
|
+
result: T;
|
|
199
|
+
console: Array<{
|
|
200
|
+
method: string;
|
|
201
|
+
args: any[];
|
|
202
|
+
}>;
|
|
203
|
+
context: vm.Context;
|
|
204
|
+
}>;
|
|
205
|
+
/**
|
|
206
|
+
* Execute JavaScript code synchronously in a controlled environment.
|
|
207
|
+
*
|
|
208
|
+
* @param code - The JavaScript code to execute
|
|
209
|
+
* @param ctx - Context variables to make available to the executing code
|
|
210
|
+
* @returns The result of the code execution
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* const sum = vm.runSync('a + b', { a: 2, b: 3 })
|
|
215
|
+
* console.log(sum) // 5
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
runSync<T extends any = any>(code: string, ctx?: any): T;
|
|
219
|
+
/**
|
|
220
|
+
* Execute code asynchronously and return both the result and the execution context.
|
|
221
|
+
*
|
|
222
|
+
* Unlike `run`, this method also returns the context object, allowing you to inspect
|
|
223
|
+
* variables set during execution.
|
|
224
|
+
*
|
|
225
|
+
* @param code - The JavaScript code to execute
|
|
226
|
+
* @param ctx - Context variables to make available to the executing code
|
|
227
|
+
* @returns The execution result and the context object
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* const { result, context } = await vm.perform('x = 42; x * 2', { x: 0 })
|
|
232
|
+
* console.log(result) // 84
|
|
233
|
+
* console.log(context.x) // 42
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
perform<T extends any>(code: string, ctx?: any): Promise<{
|
|
237
|
+
result: T;
|
|
238
|
+
context: vm.Context;
|
|
239
|
+
}>;
|
|
240
|
+
/**
|
|
241
|
+
* Executes JavaScript code synchronously and returns both the result and the execution context.
|
|
242
|
+
*
|
|
243
|
+
* Unlike `runSync`, this method also returns the context object, allowing you to inspect
|
|
244
|
+
* variables set during execution (e.g. `module.exports`). This is the synchronous equivalent
|
|
245
|
+
* of `perform()`.
|
|
246
|
+
*
|
|
247
|
+
* @param {string} code - The JavaScript code to execute
|
|
248
|
+
* @param {any} [ctx={}] - Context variables to make available to the executing code
|
|
249
|
+
* @returns {{ result: T, context: vm.Context }} The execution result and the context object
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* const { result, context } = vm.performSync(code, {
|
|
254
|
+
* exports: {},
|
|
255
|
+
* module: { exports: {} },
|
|
256
|
+
* })
|
|
257
|
+
* const moduleExports = context.module?.exports || context.exports
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
performSync<T extends any = any>(code: string, ctx?: any): {
|
|
261
|
+
result: T;
|
|
262
|
+
context: vm.Context;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Synchronously loads a JavaScript/TypeScript module from a file path, executing it
|
|
266
|
+
* in an isolated VM context and returning its exports. The module gets `require`,
|
|
267
|
+
* `exports`, and `module` globals automatically, plus any additional context you provide.
|
|
268
|
+
*
|
|
269
|
+
* @param {string} filePath - Absolute path to the module file to load
|
|
270
|
+
* @param {any} [ctx={}] - Additional context variables to inject into the module's execution environment
|
|
271
|
+
* @returns {Record<string, any>} The module's exports (from `module.exports` or `exports`)
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* const vm = container.feature('vm')
|
|
276
|
+
*
|
|
277
|
+
* // Load a tools module, injecting the container
|
|
278
|
+
* const tools = vm.loadModule('/path/to/tools.ts', { container, me: assistant })
|
|
279
|
+
* // tools.myFunction, tools.schemas, etc.
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
loadModule(filePath: string, ctx?: any): Record<string, any>;
|
|
283
|
+
}
|
|
284
|
+
export default VM;
|
|
285
|
+
//# sourceMappingURL=vm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vm.d.ts","sourceRoot":"","sources":["../../../src/node/features/vm.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Feature } from "../feature.js";
|
|
3
|
+
import { NodeContainer } from "../container.js";
|
|
4
|
+
/**
|
|
5
|
+
* Zod schema for the YamlTree feature state.
|
|
6
|
+
* Extends FeatureStateSchema and allows any additional string-keyed properties for tree data.
|
|
7
|
+
*/
|
|
8
|
+
export declare const YamlTreeStateSchema: z.ZodObject<{
|
|
9
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
10
|
+
}, z.core.$catchall<z.ZodAny>>;
|
|
11
|
+
export type YamlTreeState = z.infer<typeof YamlTreeStateSchema>;
|
|
12
|
+
/**
|
|
13
|
+
* YamlTree Feature - A powerful YAML file tree loader and processor
|
|
14
|
+
*
|
|
15
|
+
* This feature provides functionality to recursively load YAML files from a directory structure
|
|
16
|
+
* and build a hierarchical tree representation. It automatically processes file paths to create
|
|
17
|
+
* a nested object structure where file paths become object property paths.
|
|
18
|
+
*
|
|
19
|
+
* **Key Features:**
|
|
20
|
+
* - Recursive YAML file discovery in directory trees
|
|
21
|
+
* - Automatic path-to-property mapping using camelCase conversion
|
|
22
|
+
* - Integration with FileManager for efficient file operations
|
|
23
|
+
* - State-based tree storage and retrieval
|
|
24
|
+
* - Support for both .yml and .yaml file extensions
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const yamlTree = container.feature('yamlTree', { enable: true });
|
|
29
|
+
* await yamlTree.loadTree('config', 'appConfig');
|
|
30
|
+
* const configData = yamlTree.tree.appConfig;
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @template T - The state type, defaults to YamlTreeState
|
|
34
|
+
* @extends {Feature<T>}
|
|
35
|
+
*/
|
|
36
|
+
export declare class YamlTree<T extends YamlTreeState = YamlTreeState> extends Feature<T> {
|
|
37
|
+
/** The shortcut path for accessing this feature */
|
|
38
|
+
static shortcut: "features.yamlTree";
|
|
39
|
+
static stateSchema: z.ZodObject<{
|
|
40
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
41
|
+
}, z.core.$catchall<z.ZodAny>>;
|
|
42
|
+
static optionsSchema: z.ZodObject<{
|
|
43
|
+
name: z.ZodOptional<z.ZodString>;
|
|
44
|
+
_cacheKey: z.ZodOptional<z.ZodString>;
|
|
45
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
+
enable: z.ZodOptional<z.ZodBoolean>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
/**
|
|
49
|
+
* Attaches the YamlTree feature to a NodeContainer instance.
|
|
50
|
+
* Registers the feature and creates an auto-enabled instance.
|
|
51
|
+
*
|
|
52
|
+
* @param container - The NodeContainer to attach to
|
|
53
|
+
* @returns The container for method chaining
|
|
54
|
+
*/
|
|
55
|
+
static attach(container: NodeContainer & {
|
|
56
|
+
yamlTree?: YamlTree;
|
|
57
|
+
}): void;
|
|
58
|
+
/**
|
|
59
|
+
* Loads a tree of YAML files from the specified base path and stores them in state.
|
|
60
|
+
*
|
|
61
|
+
* This method recursively scans the provided directory for YAML files (.yml and .yaml),
|
|
62
|
+
* processes their content, and builds a hierarchical object structure. File paths are
|
|
63
|
+
* converted to camelCase property names, and the resulting tree is stored in the feature's state.
|
|
64
|
+
*
|
|
65
|
+
* **Path Processing:**
|
|
66
|
+
* - Removes the base path prefix from file paths
|
|
67
|
+
* - Converts directory/file names to camelCase
|
|
68
|
+
* - Creates nested objects based on directory structure
|
|
69
|
+
* - Removes file extensions (.yml/.yaml)
|
|
70
|
+
*
|
|
71
|
+
* **Example:**
|
|
72
|
+
* ```
|
|
73
|
+
* config/
|
|
74
|
+
* database/
|
|
75
|
+
* production.yml -> tree.config.database.production
|
|
76
|
+
* staging.yml -> tree.config.database.staging
|
|
77
|
+
* api/
|
|
78
|
+
* endpoints.yaml -> tree.config.api.endpoints
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @param basePath - The root directory path to scan for YAML files
|
|
82
|
+
* @param key - The key to store the tree under in state (defaults to first segment of basePath)
|
|
83
|
+
* @returns Promise resolving to the complete tree object
|
|
84
|
+
*
|
|
85
|
+
* @throws {Error} When FileManager fails to start or files cannot be read
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* // Load all YAML files from 'config' directory into state.config
|
|
90
|
+
* await yamlTree.loadTree('config');
|
|
91
|
+
*
|
|
92
|
+
* // Load with custom key
|
|
93
|
+
* await yamlTree.loadTree('app/settings', 'appSettings');
|
|
94
|
+
*
|
|
95
|
+
* // Access the loaded data
|
|
96
|
+
* const dbConfig = yamlTree.tree.config.database.production;
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
loadTree(basePath: string, key?: string): Promise<Pick<T, Exclude<keyof T, "enabled">>>;
|
|
100
|
+
/**
|
|
101
|
+
* Gets the current tree data, excluding the 'enabled' state property.
|
|
102
|
+
*
|
|
103
|
+
* Returns a clean copy of the tree data without internal state management properties.
|
|
104
|
+
* This provides access to only the YAML tree data that has been loaded.
|
|
105
|
+
*
|
|
106
|
+
* @returns The tree object containing all loaded YAML data, organized by keys
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* await yamlTree.loadTree('config');
|
|
111
|
+
* const allTrees = yamlTree.tree;
|
|
112
|
+
* // Returns: { config: { database: { ... }, api: { ... } } }
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
get tree(): Pick<T, Exclude<keyof T, "enabled">>;
|
|
116
|
+
}
|
|
117
|
+
export default YamlTree;
|
|
118
|
+
//# sourceMappingURL=yaml-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml-tree.d.ts","sourceRoot":"","sources":["../../../src/node/features/yaml-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;8BAA+J,CAAA;AAC/L,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,QAAQ,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IAE/E,mDAAmD;IACnD,OAAgB,QAAQ,EAAG,mBAAmB,CAAS;IACvD,OAAgB,WAAW;;mCAAsB;IACjD,OAAgB,aAAa;;;;;sBAAuB;IAEpD;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,aAAa,GAAG;QAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;KAAE;IAIhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACG,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAE,MAAgC;IA+BtE;;;;;;;;;;;;;;OAcG;IACH,IAAI,IAAI,yCAEP;CACF;AAED,eAAe,QAAQ,CAAA"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Feature } from '../feature.js';
|
|
2
|
+
import { NodeContainer } from '../container.js';
|
|
3
|
+
/**
|
|
4
|
+
* The YAML feature provides utilities for parsing and stringifying YAML data.
|
|
5
|
+
*
|
|
6
|
+
* This feature wraps the js-yaml library to provide convenient methods for
|
|
7
|
+
* converting between YAML strings and JavaScript objects. It's automatically
|
|
8
|
+
* attached to Node containers for easy access.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const yamlFeature = container.feature('yaml')
|
|
13
|
+
*
|
|
14
|
+
* // Parse YAML string to object
|
|
15
|
+
* const config = yamlFeature.parse(`
|
|
16
|
+
* name: MyApp
|
|
17
|
+
* version: 1.0.0
|
|
18
|
+
* settings:
|
|
19
|
+
* debug: true
|
|
20
|
+
* `)
|
|
21
|
+
*
|
|
22
|
+
* // Convert object to YAML string
|
|
23
|
+
* const yamlString = yamlFeature.stringify(config)
|
|
24
|
+
* console.log(yamlString)
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @extends Feature
|
|
28
|
+
*/
|
|
29
|
+
export declare class YAML extends Feature {
|
|
30
|
+
static shortcut: "features.yaml";
|
|
31
|
+
static stateSchema: import("zod").ZodObject<{
|
|
32
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
33
|
+
}, import("zod/v4/core").$loose>;
|
|
34
|
+
static optionsSchema: import("zod").ZodObject<{
|
|
35
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
36
|
+
_cacheKey: import("zod").ZodOptional<import("zod").ZodString>;
|
|
37
|
+
cached: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
38
|
+
enable: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
39
|
+
}, import("zod/v4/core").$strip>;
|
|
40
|
+
/**
|
|
41
|
+
* Automatically attaches the YAML feature to Node containers.
|
|
42
|
+
*
|
|
43
|
+
* This static method ensures the YAML feature is automatically available
|
|
44
|
+
* on Node containers without needing manual registration.
|
|
45
|
+
*
|
|
46
|
+
* @param {NodeContainer} c - The Node container to attach to
|
|
47
|
+
*/
|
|
48
|
+
static attach(c: NodeContainer): void;
|
|
49
|
+
/**
|
|
50
|
+
* Converts a JavaScript object to a YAML string.
|
|
51
|
+
*
|
|
52
|
+
* This method serializes JavaScript data structures into YAML format,
|
|
53
|
+
* which is human-readable and commonly used for configuration files.
|
|
54
|
+
*
|
|
55
|
+
* @param {any} data - The data to convert to YAML format
|
|
56
|
+
* @returns {string} The YAML string representation of the data
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const config = {
|
|
61
|
+
* name: 'MyApp',
|
|
62
|
+
* version: '1.0.0',
|
|
63
|
+
* settings: {
|
|
64
|
+
* debug: true,
|
|
65
|
+
* ports: [3000, 3001]
|
|
66
|
+
* }
|
|
67
|
+
* }
|
|
68
|
+
*
|
|
69
|
+
* const yamlString = yaml.stringify(config)
|
|
70
|
+
* console.log(yamlString)
|
|
71
|
+
* // Output:
|
|
72
|
+
* // name: MyApp
|
|
73
|
+
* // version: 1.0.0
|
|
74
|
+
* // settings:
|
|
75
|
+
* // debug: true
|
|
76
|
+
* // ports:
|
|
77
|
+
* // - 3000
|
|
78
|
+
* // - 3001
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
stringify(data: any): string;
|
|
82
|
+
/**
|
|
83
|
+
* Parses a YAML string into a JavaScript object.
|
|
84
|
+
*
|
|
85
|
+
* This method deserializes YAML content into JavaScript data structures.
|
|
86
|
+
* It supports all standard YAML features including nested objects, arrays,
|
|
87
|
+
* and various data types.
|
|
88
|
+
*
|
|
89
|
+
* @template T - The expected type of the parsed object
|
|
90
|
+
* @param {string} yamlStr - The YAML string to parse
|
|
91
|
+
* @returns {T} The parsed JavaScript object
|
|
92
|
+
* @throws {Error} Throws an error if the YAML string is malformed
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const yamlContent = `
|
|
97
|
+
* name: MyApp
|
|
98
|
+
* version: 1.0.0
|
|
99
|
+
* settings:
|
|
100
|
+
* debug: true
|
|
101
|
+
* ports:
|
|
102
|
+
* - 3000
|
|
103
|
+
* - 3001
|
|
104
|
+
* `
|
|
105
|
+
*
|
|
106
|
+
* // Parse with type inference
|
|
107
|
+
* const config = yaml.parse(yamlContent)
|
|
108
|
+
* console.log(config.name) // 'MyApp'
|
|
109
|
+
*
|
|
110
|
+
* // Parse with explicit typing
|
|
111
|
+
* interface AppConfig {
|
|
112
|
+
* name: string
|
|
113
|
+
* version: string
|
|
114
|
+
* settings: {
|
|
115
|
+
* debug: boolean
|
|
116
|
+
* ports: number[]
|
|
117
|
+
* }
|
|
118
|
+
* }
|
|
119
|
+
*
|
|
120
|
+
* const typedConfig = yaml.parse<AppConfig>(yamlContent)
|
|
121
|
+
* console.log(typedConfig.settings.ports) // [3000, 3001]
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
parse<T extends object = any>(yamlStr: string): T;
|
|
125
|
+
}
|
|
126
|
+
export default YAML;
|
|
127
|
+
//# sourceMappingURL=yaml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../../src/node/features/yaml.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,IAAK,SAAQ,OAAO;IAC/B,OAAgB,QAAQ,EAAG,eAAe,CAAS;IACnD,OAAgB,WAAW;;qCAAqB;IAChD,OAAgB,aAAa;;;;;qCAAuB;IAGpD;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,aAAa;IAI9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,SAAS,CAAC,IAAI,EAAE,GAAG,GAAI,MAAM;IAI7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyCG;IACH,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,MAAM,GAAI,CAAC;CAGnD;AAED,eAAe,IAAI,CAAA"}
|