@soederpop/luca 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release.yaml +167 -0
- package/CLAUDE.md +2 -0
- package/README.md +3 -0
- package/assistants/codingAssistant/ABOUT.md +3 -0
- package/assistants/codingAssistant/CORE.md +22 -17
- package/assistants/codingAssistant/hooks.ts +17 -4
- package/assistants/codingAssistant/tools.ts +1 -106
- package/assistants/inkbot/ABOUT.md +5 -0
- package/assistants/inkbot/CORE.md +71 -0
- package/assistants/inkbot/hooks.ts +14 -0
- package/assistants/inkbot/tools.ts +47 -0
- package/bun.lock +20 -4
- package/commands/inkbot.ts +353 -0
- package/commands/release.ts +75 -181
- 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/docs/ideas/assistant-factory-pattern.md +142 -0
- package/package.json +74 -21
- package/src/agi/container.server.ts +10 -0
- package/src/agi/feature.ts +13 -0
- package/src/agi/features/agent-memory.ts +694 -0
- package/src/agi/features/assistant.ts +37 -26
- package/src/agi/features/assistants-manager.ts +95 -5
- package/src/agi/features/autonomous-assistant.ts +1 -5
- package/src/agi/features/browser-use.ts +32 -2
- package/src/agi/features/claude-code.ts +165 -1
- package/src/agi/features/coding-tools.ts +175 -0
- 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 +35 -28
- 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 +111 -13
- 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/clients/voicebox/index.ts +300 -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 +3012 -1356
- package/src/introspection/generated.node.ts +179 -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 +57 -30
- 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 +51 -18
- 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 +2 -2
- package/src/node/features/ui.ts +1 -1
- package/src/node/features/vm.ts +3 -3
- 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 +14 -5
- package/test/conversation.test.ts +220 -0
- package/test-integration/memory.test.ts +204 -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,173 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SQL } from 'bun';
|
|
3
|
+
import { Feature } from '../feature.js';
|
|
4
|
+
import type { ContainerContext } from '../../container.js';
|
|
5
|
+
type SqlValue = string | number | boolean | bigint | Uint8Array | Buffer | null;
|
|
6
|
+
export declare const PostgresStateSchema: z.ZodObject<{
|
|
7
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
8
|
+
connected: z.ZodDefault<z.ZodBoolean>;
|
|
9
|
+
url: z.ZodDefault<z.ZodString>;
|
|
10
|
+
lastQuery: z.ZodOptional<z.ZodString>;
|
|
11
|
+
lastRowCount: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
lastError: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$loose>;
|
|
14
|
+
export declare const PostgresOptionsSchema: z.ZodObject<{
|
|
15
|
+
name: z.ZodOptional<z.ZodString>;
|
|
16
|
+
_cacheKey: z.ZodOptional<z.ZodString>;
|
|
17
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
enable: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
url: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export type PostgresState = z.infer<typeof PostgresStateSchema>;
|
|
22
|
+
export type PostgresOptions = z.infer<typeof PostgresOptionsSchema>;
|
|
23
|
+
export declare const PostgresEventsSchema: z.ZodObject<{
|
|
24
|
+
stateChange: z.ZodTuple<[z.ZodAny], null>;
|
|
25
|
+
enabled: z.ZodTuple<[], null>;
|
|
26
|
+
query: z.ZodTuple<[z.ZodString, z.ZodArray<z.ZodAny>, z.ZodNumber], null>;
|
|
27
|
+
execute: z.ZodTuple<[z.ZodString, z.ZodArray<z.ZodAny>, z.ZodNumber], null>;
|
|
28
|
+
error: z.ZodTuple<[z.ZodAny], null>;
|
|
29
|
+
closed: z.ZodTuple<[], null>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
/**
|
|
32
|
+
* Postgres feature for safe SQL execution through Bun's native SQL client.
|
|
33
|
+
*
|
|
34
|
+
* Supports:
|
|
35
|
+
* - parameterized query execution (`query` / `execute`)
|
|
36
|
+
* - tagged-template query execution (`sql`) to avoid manual placeholder wiring
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const postgres = container.feature('postgres', { url: process.env.DATABASE_URL! })
|
|
41
|
+
*
|
|
42
|
+
* const users = await postgres.query<{ id: number; email: string }>(
|
|
43
|
+
* 'select id, email from users where id = $1',
|
|
44
|
+
* [123]
|
|
45
|
+
* )
|
|
46
|
+
*
|
|
47
|
+
* const rows = await postgres.sql<{ id: number }>`
|
|
48
|
+
* select id from users where email = ${'hello@example.com'}
|
|
49
|
+
* `
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare class Postgres extends Feature<PostgresState, PostgresOptions> {
|
|
53
|
+
static shortcut: "features.postgres";
|
|
54
|
+
static stateSchema: z.ZodObject<{
|
|
55
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
56
|
+
connected: z.ZodDefault<z.ZodBoolean>;
|
|
57
|
+
url: z.ZodDefault<z.ZodString>;
|
|
58
|
+
lastQuery: z.ZodOptional<z.ZodString>;
|
|
59
|
+
lastRowCount: z.ZodOptional<z.ZodNumber>;
|
|
60
|
+
lastError: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, z.core.$loose>;
|
|
62
|
+
static optionsSchema: z.ZodObject<{
|
|
63
|
+
name: z.ZodOptional<z.ZodString>;
|
|
64
|
+
_cacheKey: z.ZodOptional<z.ZodString>;
|
|
65
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
66
|
+
enable: z.ZodOptional<z.ZodBoolean>;
|
|
67
|
+
url: z.ZodOptional<z.ZodString>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
static eventsSchema: z.ZodObject<{
|
|
70
|
+
stateChange: z.ZodTuple<[z.ZodAny], null>;
|
|
71
|
+
enabled: z.ZodTuple<[], null>;
|
|
72
|
+
query: z.ZodTuple<[z.ZodString, z.ZodArray<z.ZodAny>, z.ZodNumber], null>;
|
|
73
|
+
execute: z.ZodTuple<[z.ZodString, z.ZodArray<z.ZodAny>, z.ZodNumber], null>;
|
|
74
|
+
error: z.ZodTuple<[z.ZodAny], null>;
|
|
75
|
+
closed: z.ZodTuple<[], null>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
private _client;
|
|
78
|
+
/**
|
|
79
|
+
* Default state for the Postgres feature before a connection is established.
|
|
80
|
+
* @returns The initial PostgresState with `connected: false` and empty `url`
|
|
81
|
+
*/
|
|
82
|
+
get initialState(): PostgresState;
|
|
83
|
+
constructor(options: PostgresOptions, context: ContainerContext);
|
|
84
|
+
/**
|
|
85
|
+
* Returns the underlying Bun SQL postgres client.
|
|
86
|
+
* @returns The raw `SQL` instance used for all database operations
|
|
87
|
+
*/
|
|
88
|
+
get client(): SQL;
|
|
89
|
+
/**
|
|
90
|
+
* Executes a SELECT-like query and returns result rows.
|
|
91
|
+
*
|
|
92
|
+
* Use postgres placeholders (`$1`, `$2`, ...) for `params`.
|
|
93
|
+
*
|
|
94
|
+
* @param queryText - The SQL query string with optional `$N` placeholders
|
|
95
|
+
* @param params - Ordered array of values to bind to the placeholders
|
|
96
|
+
* @returns Promise resolving to an array of typed result rows
|
|
97
|
+
* @throws {Error} When query text is empty or params contain `undefined`
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const pg = container.feature('postgres', { url: process.env.DATABASE_URL! })
|
|
102
|
+
* const users = await pg.query<{ id: number; email: string }>(
|
|
103
|
+
* 'SELECT id, email FROM users WHERE active = $1',
|
|
104
|
+
* [true]
|
|
105
|
+
* )
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
query<T extends object = Record<string, unknown>>(queryText: string, params?: SqlValue[]): Promise<T[]>;
|
|
109
|
+
/**
|
|
110
|
+
* Executes a write/update/delete statement and returns metadata.
|
|
111
|
+
*
|
|
112
|
+
* Use postgres placeholders (`$1`, `$2`, ...) for `params`.
|
|
113
|
+
*
|
|
114
|
+
* @param queryText - The SQL statement string with optional `$N` placeholders
|
|
115
|
+
* @param params - Ordered array of values to bind to the placeholders
|
|
116
|
+
* @returns Promise resolving to `{ rowCount }` indicating affected rows
|
|
117
|
+
* @throws {Error} When query text is empty or params contain `undefined`
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* const pg = container.feature('postgres', { url: process.env.DATABASE_URL! })
|
|
122
|
+
* const { rowCount } = await pg.execute(
|
|
123
|
+
* 'UPDATE users SET active = $1 WHERE last_login < $2',
|
|
124
|
+
* [false, '2024-01-01']
|
|
125
|
+
* )
|
|
126
|
+
* console.log(`Deactivated ${rowCount} users`)
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
execute(queryText: string, params?: SqlValue[]): Promise<{
|
|
130
|
+
rowCount: number;
|
|
131
|
+
}>;
|
|
132
|
+
/**
|
|
133
|
+
* Safe tagged-template SQL helper.
|
|
134
|
+
*
|
|
135
|
+
* Values become bound parameters automatically, preventing SQL injection.
|
|
136
|
+
*
|
|
137
|
+
* @param strings - Template literal string segments
|
|
138
|
+
* @param values - Interpolated values that become bound `$N` parameters
|
|
139
|
+
* @returns Promise resolving to an array of typed result rows
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const pg = container.feature('postgres', { url: process.env.DATABASE_URL! })
|
|
144
|
+
* const email = 'hello@example.com'
|
|
145
|
+
* const rows = await pg.sql<{ id: number }>`
|
|
146
|
+
* SELECT id FROM users WHERE email = ${email}
|
|
147
|
+
* `
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
sql<T extends object = Record<string, unknown>>(strings: TemplateStringsArray, ...values: SqlValue[]): Promise<T[]>;
|
|
151
|
+
/**
|
|
152
|
+
* Closes the postgres connection and updates feature state.
|
|
153
|
+
*
|
|
154
|
+
* Emits `closed` after the connection is torn down.
|
|
155
|
+
*
|
|
156
|
+
* @returns This Postgres feature instance for method chaining
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const pg = container.feature('postgres', { url: process.env.DATABASE_URL! })
|
|
161
|
+
* // ... run queries ...
|
|
162
|
+
* await pg.close()
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
close(): Promise<this>;
|
|
166
|
+
}
|
|
167
|
+
export default Postgres;
|
|
168
|
+
declare module '../../feature.js' {
|
|
169
|
+
interface AvailableFeatures {
|
|
170
|
+
postgres: typeof Postgres;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=postgres.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../../src/node/features/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,IAAI,CAAA;AAE/E,eAAO,MAAM,mBAAmB;;;;;;;iBAM9B,CAAA;AAEF,eAAO,MAAM,qBAAqB;;;;;;iBAEhC,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAC/D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEnE,eAAO,MAAM,oBAAoB;;;;;;;iBAaH,CAAA;AAE9B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,QAAS,SAAQ,OAAO,CAAC,aAAa,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it";
|
|
5
|
+
/** Stdout mode for the child process */
|
|
6
|
+
stdout?: "ignore" | "inherit";
|
|
7
|
+
/** Stderr mode for the child process */
|
|
8
|
+
stderr?: "ignore" | "inherit";
|
|
9
|
+
/** Working directory for the child process */
|
|
10
|
+
cwd?: string;
|
|
11
|
+
/** Environment variables to pass to the child process */
|
|
12
|
+
environment?: Record<string, any>;
|
|
13
|
+
/** Callback invoked when stderr data is received */
|
|
14
|
+
onError?: (data: string) => void;
|
|
15
|
+
/** Callback invoked when stdout data is received */
|
|
16
|
+
onOutput?: (data: string) => void;
|
|
17
|
+
/** Callback invoked when the process exits */
|
|
18
|
+
onExit?: (code: number) => void;
|
|
19
|
+
/** Callback invoked when the process starts */
|
|
20
|
+
onStart?: (childProcess: ChildProcess) => void;
|
|
21
|
+
}
|
|
22
|
+
interface RawSpawnOptions {
|
|
23
|
+
/** Working directory for the child process */
|
|
24
|
+
cwd?: string;
|
|
25
|
+
/** Environment variables to pass to the child process */
|
|
26
|
+
environment?: Record<string, any>;
|
|
27
|
+
/** Optional stdin payload written immediately after spawn */
|
|
28
|
+
stdin?: string | Buffer;
|
|
29
|
+
/** Stdout mode for the child process */
|
|
30
|
+
stdout?: "pipe" | "inherit" | "ignore";
|
|
31
|
+
/** Stderr mode for the child process */
|
|
32
|
+
stderr?: "pipe" | "inherit" | "ignore";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The ChildProcess feature provides utilities for executing external processes and commands.
|
|
36
|
+
*
|
|
37
|
+
* This feature wraps Node.js child process functionality to provide convenient methods
|
|
38
|
+
* for executing shell commands, spawning processes, and capturing their output.
|
|
39
|
+
* It supports both synchronous and asynchronous execution with various options.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const proc = container.feature('proc')
|
|
44
|
+
*
|
|
45
|
+
* // Execute a simple command synchronously
|
|
46
|
+
* const result = proc.exec('echo "Hello World"')
|
|
47
|
+
* console.log(result) // 'Hello World'
|
|
48
|
+
*
|
|
49
|
+
* // Execute and capture output asynchronously
|
|
50
|
+
* const { stdout, stderr } = await proc.spawnAndCapture('npm', ['--version'])
|
|
51
|
+
* console.log(`npm version: ${stdout}`)
|
|
52
|
+
*
|
|
53
|
+
* // Execute with callbacks for real-time output
|
|
54
|
+
* await proc.spawnAndCapture('npm', ['install'], {
|
|
55
|
+
* onOutput: (data) => console.log('OUT:', data),
|
|
56
|
+
* onError: (data) => console.log('ERR:', data)
|
|
57
|
+
* })
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @extends Feature
|
|
61
|
+
*/
|
|
62
|
+
export declare class ChildProcess extends Feature {
|
|
63
|
+
static shortcut: "features.proc";
|
|
64
|
+
static stateSchema: import("zod").ZodObject<{
|
|
65
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
66
|
+
}, import("zod/v4/core").$loose>;
|
|
67
|
+
static optionsSchema: import("zod").ZodObject<{
|
|
68
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
69
|
+
_cacheKey: import("zod").ZodOptional<import("zod").ZodString>;
|
|
70
|
+
cached: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
71
|
+
enable: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
72
|
+
}, import("zod/v4/core").$strip>;
|
|
73
|
+
/**
|
|
74
|
+
* Executes a command string and captures its output asynchronously.
|
|
75
|
+
*
|
|
76
|
+
* This method takes a complete command string, splits it into command and arguments,
|
|
77
|
+
* and executes it using the spawnAndCapture method. It's a convenient wrapper
|
|
78
|
+
* for simple command execution.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} cmd - The complete command string to execute (e.g., "git status --porcelain")
|
|
81
|
+
* @param {any} [options] - Options to pass to the underlying spawn process
|
|
82
|
+
* @returns {Promise<object>} Promise resolving to execution result with stdout, stderr, exitCode, pid, and error
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* // Execute a git command
|
|
87
|
+
* const result = await proc.execAndCapture('git status --porcelain')
|
|
88
|
+
* if (result.exitCode === 0) {
|
|
89
|
+
* console.log('Git status:', result.stdout)
|
|
90
|
+
* } else {
|
|
91
|
+
* console.error('Git error:', result.stderr)
|
|
92
|
+
* }
|
|
93
|
+
*
|
|
94
|
+
* // Execute with options
|
|
95
|
+
* const result = await proc.execAndCapture('npm list --depth=0', {
|
|
96
|
+
* cwd: '/path/to/project'
|
|
97
|
+
* })
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
execAndCapture(cmd: string, options?: any): Promise<{
|
|
101
|
+
stderr: string;
|
|
102
|
+
stdout: string;
|
|
103
|
+
error: null | any;
|
|
104
|
+
exitCode: number;
|
|
105
|
+
pid: number | null;
|
|
106
|
+
}>;
|
|
107
|
+
/**
|
|
108
|
+
* Spawns a process and captures its output with real-time monitoring capabilities.
|
|
109
|
+
*
|
|
110
|
+
* This method provides comprehensive process execution with the ability to capture
|
|
111
|
+
* output, monitor real-time data streams, and handle process lifecycle events.
|
|
112
|
+
* It's ideal for long-running processes where you need to capture output as it happens.
|
|
113
|
+
*
|
|
114
|
+
* @param {string} command - The command to execute (e.g., 'node', 'npm', 'git')
|
|
115
|
+
* @param {string[]} args - Array of arguments to pass to the command
|
|
116
|
+
* @param {SpawnOptions} [options] - Options for process execution and monitoring
|
|
117
|
+
* @param {string} [options.cwd] - Working directory for the process
|
|
118
|
+
* @param {Function} [options.onOutput] - Callback for stdout data
|
|
119
|
+
* @param {Function} [options.onError] - Callback for stderr data
|
|
120
|
+
* @param {Function} [options.onExit] - Callback for process exit
|
|
121
|
+
* @returns {Promise<object>} Promise resolving to complete execution result
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* // Basic usage
|
|
126
|
+
* const result = await proc.spawnAndCapture('node', ['--version'])
|
|
127
|
+
* console.log(`Node version: ${result.stdout}`)
|
|
128
|
+
*
|
|
129
|
+
* // With real-time output monitoring
|
|
130
|
+
* const result = await proc.spawnAndCapture('npm', ['install'], {
|
|
131
|
+
* onOutput: (data) => console.log('📦 ', data.trim()),
|
|
132
|
+
* onError: (data) => console.error('❌ ', data.trim()),
|
|
133
|
+
* onExit: (code) => console.log(`Process exited with code ${code}`)
|
|
134
|
+
* })
|
|
135
|
+
*
|
|
136
|
+
* // Long-running process with custom working directory
|
|
137
|
+
* const buildResult = await proc.spawnAndCapture('npm', ['run', 'build'], {
|
|
138
|
+
* cwd: '/path/to/project',
|
|
139
|
+
* onOutput: (data) => {
|
|
140
|
+
* if (data.includes('error')) {
|
|
141
|
+
* console.error('Build error detected:', data)
|
|
142
|
+
* }
|
|
143
|
+
* }
|
|
144
|
+
* })
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
spawnAndCapture(command: string, args: string[], options?: SpawnOptions): Promise<{
|
|
148
|
+
stderr: string;
|
|
149
|
+
stdout: string;
|
|
150
|
+
error: null | any;
|
|
151
|
+
exitCode: number;
|
|
152
|
+
pid: number | null;
|
|
153
|
+
}>;
|
|
154
|
+
/**
|
|
155
|
+
* Spawn a raw child process and return the handle immediately.
|
|
156
|
+
*
|
|
157
|
+
* Useful when callers need streaming access to stdout/stderr and
|
|
158
|
+
* direct lifecycle control (for example, cancellation via kill()).
|
|
159
|
+
*/
|
|
160
|
+
spawn(command: string, args?: string[], options?: RawSpawnOptions): import('child_process').ChildProcess;
|
|
161
|
+
/**
|
|
162
|
+
* Execute a command synchronously and return its output.
|
|
163
|
+
*
|
|
164
|
+
* Runs a shell command and waits for it to complete before returning.
|
|
165
|
+
* Useful for simple commands where you need the result immediately.
|
|
166
|
+
*
|
|
167
|
+
* @param command - The command to execute
|
|
168
|
+
* @param options - Options for command execution (cwd, encoding, etc.)
|
|
169
|
+
* @returns The trimmed stdout from the command execution
|
|
170
|
+
* @throws If the command fails or returns non-zero exit code
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```typescript
|
|
174
|
+
* const branch = proc.exec('git branch --show-current')
|
|
175
|
+
* const version = proc.exec('node --version')
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
exec(command: string, options?: any): string;
|
|
179
|
+
execSync(command: string, options?: any): string;
|
|
180
|
+
/**
|
|
181
|
+
* Establishes a PID-file lock to prevent duplicate process instances.
|
|
182
|
+
*
|
|
183
|
+
* Writes the current process PID to the given file path. If the file already exists
|
|
184
|
+
* and the PID inside it refers to a running process, the current process exits immediately.
|
|
185
|
+
* Stale PID files (where the process is no longer running) are automatically cleaned up.
|
|
186
|
+
*
|
|
187
|
+
* Cleanup handlers are registered on SIGTERM, SIGINT, and process exit to remove the
|
|
188
|
+
* PID file when the process shuts down.
|
|
189
|
+
*
|
|
190
|
+
* @param {string} pidPath - Path to the PID file, resolved relative to container.cwd
|
|
191
|
+
* @returns {{ release: () => void }} Object with a release function to manually remove the lock
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* // In a command handler — exits if already running
|
|
196
|
+
* const lock = proc.establishLock('tmp/luca-main.pid')
|
|
197
|
+
*
|
|
198
|
+
* // Later, if you need to release manually
|
|
199
|
+
* lock.release()
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
establishLock(pidPath: string): {
|
|
203
|
+
release: () => void;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Kills a process by its PID.
|
|
207
|
+
*
|
|
208
|
+
* @param {number} pid - The process ID to kill
|
|
209
|
+
* @param {NodeJS.Signals | number} [signal='SIGTERM'] - The signal to send (e.g. 'SIGTERM', 'SIGKILL', 9)
|
|
210
|
+
* @returns {boolean} True if the signal was sent successfully, false if the process was not found
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* // Gracefully terminate a process
|
|
215
|
+
* proc.kill(12345)
|
|
216
|
+
*
|
|
217
|
+
* // Force kill a process
|
|
218
|
+
* proc.kill(12345, 'SIGKILL')
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
kill(pid: number, signal?: NodeJS.Signals | number): boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Finds PIDs of processes listening on a given port.
|
|
224
|
+
*
|
|
225
|
+
* Uses `lsof` on macOS/Linux to discover which processes have a socket bound to the specified port.
|
|
226
|
+
*
|
|
227
|
+
* @param {number} port - The port number to search for
|
|
228
|
+
* @returns {number[]} Array of PIDs listening on that port (empty if none found)
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```typescript
|
|
232
|
+
* const pids = proc.findPidsByPort(3000)
|
|
233
|
+
* console.log(`Processes on port 3000: ${pids}`)
|
|
234
|
+
*
|
|
235
|
+
* // Kill everything on port 3000
|
|
236
|
+
* for (const pid of proc.findPidsByPort(3000)) {
|
|
237
|
+
* proc.kill(pid)
|
|
238
|
+
* }
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
findPidsByPort(port: number): number[];
|
|
242
|
+
/**
|
|
243
|
+
* Registers a handler for a process signal (e.g. SIGINT, SIGTERM, SIGUSR1).
|
|
244
|
+
*
|
|
245
|
+
* Returns a cleanup function that removes the listener when called.
|
|
246
|
+
*
|
|
247
|
+
* @param {NodeJS.Signals} signal - The signal name to listen for (e.g. 'SIGINT', 'SIGTERM', 'SIGUSR2')
|
|
248
|
+
* @param {() => void} handler - The function to call when the signal is received
|
|
249
|
+
* @returns {() => void} A function that removes the listener when called
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* // Graceful shutdown
|
|
254
|
+
* proc.onSignal('SIGTERM', () => {
|
|
255
|
+
* console.log('Shutting down gracefully...')
|
|
256
|
+
* process.exit(0)
|
|
257
|
+
* })
|
|
258
|
+
*
|
|
259
|
+
* // Remove the listener later
|
|
260
|
+
* const off = proc.onSignal('SIGUSR2', () => {
|
|
261
|
+
* console.log('Received SIGUSR2')
|
|
262
|
+
* })
|
|
263
|
+
* off()
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
/**
|
|
267
|
+
* Checks whether any process matching a given name is currently running.
|
|
268
|
+
*
|
|
269
|
+
* Uses `pgrep -x` for an exact match against process names.
|
|
270
|
+
*
|
|
271
|
+
* @param {string} name - The process name to look for (e.g. 'afplay', 'node', 'nginx')
|
|
272
|
+
* @returns {boolean} True if at least one matching process is running
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```typescript
|
|
276
|
+
* if (proc.isProcessRunning('afplay')) {
|
|
277
|
+
* console.log('Audio is currently playing')
|
|
278
|
+
* }
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
isProcessRunning(name: string): boolean;
|
|
282
|
+
onSignal(signal: NodeJS.Signals, handler: () => void): () => void;
|
|
283
|
+
}
|
|
284
|
+
export default ChildProcess;
|
|
285
|
+
//# sourceMappingURL=proc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proc.d.ts","sourceRoot":"","sources":["../../../src/node/features/proc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAOxC,UAAU,YAAY;IACpB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC7B,wCAAwC;IACxC,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC9B,wCAAwC;IACxC,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC9B,8CAA8C;IAC9C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAClC,oDAAoD;IACpD,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,oDAAoD;IACpD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,8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