@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,824 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Feature } from '../feature.js';
|
|
3
|
+
declare module '@soederpop/luca/feature' {
|
|
4
|
+
interface AvailableFeatures {
|
|
5
|
+
claudeCode: typeof ClaudeCode;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export interface ClaudeInitEvent {
|
|
9
|
+
type: 'system';
|
|
10
|
+
subtype: 'init';
|
|
11
|
+
session_id: string;
|
|
12
|
+
cwd: string;
|
|
13
|
+
model: string;
|
|
14
|
+
tools: string[];
|
|
15
|
+
mcp_servers: string[];
|
|
16
|
+
permissionMode: string;
|
|
17
|
+
claude_code_version: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ClaudeAssistantMessage {
|
|
20
|
+
type: 'assistant';
|
|
21
|
+
message: {
|
|
22
|
+
id: string;
|
|
23
|
+
model: string;
|
|
24
|
+
role: 'assistant';
|
|
25
|
+
content: Array<{
|
|
26
|
+
type: 'text';
|
|
27
|
+
text: string;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'tool_use';
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
input: any;
|
|
33
|
+
}>;
|
|
34
|
+
stop_reason: string | null;
|
|
35
|
+
usage: {
|
|
36
|
+
input_tokens: number;
|
|
37
|
+
output_tokens: number;
|
|
38
|
+
cache_read_input_tokens?: number;
|
|
39
|
+
cache_creation_input_tokens?: number;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
session_id: string;
|
|
43
|
+
parent_tool_use_id: string | null;
|
|
44
|
+
}
|
|
45
|
+
export interface ClaudeToolResult {
|
|
46
|
+
type: 'tool_result';
|
|
47
|
+
tool_use_id: string;
|
|
48
|
+
content: string;
|
|
49
|
+
session_id: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ClaudeStreamEvent {
|
|
52
|
+
type: 'stream_event';
|
|
53
|
+
event: {
|
|
54
|
+
type: 'message_start' | 'content_block_start' | 'content_block_delta' | 'content_block_stop' | 'message_delta' | 'message_stop';
|
|
55
|
+
index?: number;
|
|
56
|
+
delta?: {
|
|
57
|
+
type: string;
|
|
58
|
+
text?: string;
|
|
59
|
+
};
|
|
60
|
+
content_block?: {
|
|
61
|
+
type: string;
|
|
62
|
+
text?: string;
|
|
63
|
+
};
|
|
64
|
+
message?: any;
|
|
65
|
+
usage?: any;
|
|
66
|
+
};
|
|
67
|
+
session_id: string;
|
|
68
|
+
parent_tool_use_id: string | null;
|
|
69
|
+
}
|
|
70
|
+
export interface ClaudeResultEvent {
|
|
71
|
+
type: 'result';
|
|
72
|
+
subtype: 'success' | 'error';
|
|
73
|
+
is_error: boolean;
|
|
74
|
+
result: string;
|
|
75
|
+
session_id: string;
|
|
76
|
+
duration_ms: number;
|
|
77
|
+
num_turns: number;
|
|
78
|
+
total_cost_usd: number;
|
|
79
|
+
usage: Record<string, any>;
|
|
80
|
+
}
|
|
81
|
+
export type ClaudeEvent = ClaudeInitEvent | ClaudeAssistantMessage | ClaudeToolResult | ClaudeStreamEvent | ClaudeResultEvent | {
|
|
82
|
+
type: string;
|
|
83
|
+
[key: string]: any;
|
|
84
|
+
};
|
|
85
|
+
export interface ClaudeSession {
|
|
86
|
+
id: string;
|
|
87
|
+
sessionId?: string;
|
|
88
|
+
status: 'idle' | 'running' | 'completed' | 'error';
|
|
89
|
+
prompt: string;
|
|
90
|
+
result?: string;
|
|
91
|
+
error?: string;
|
|
92
|
+
costUsd: number;
|
|
93
|
+
turns: number;
|
|
94
|
+
messages: ClaudeAssistantMessage[];
|
|
95
|
+
process?: any;
|
|
96
|
+
}
|
|
97
|
+
export interface McpStdioServer {
|
|
98
|
+
type: 'stdio';
|
|
99
|
+
command: string;
|
|
100
|
+
args?: string[];
|
|
101
|
+
env?: Record<string, string>;
|
|
102
|
+
}
|
|
103
|
+
export interface McpHttpServer {
|
|
104
|
+
type: 'http';
|
|
105
|
+
url: string;
|
|
106
|
+
headers?: Record<string, string>;
|
|
107
|
+
}
|
|
108
|
+
export interface McpSseServer {
|
|
109
|
+
type: 'sse';
|
|
110
|
+
url: string;
|
|
111
|
+
headers?: Record<string, string>;
|
|
112
|
+
}
|
|
113
|
+
export type McpServerConfig = McpStdioServer | McpHttpServer | McpSseServer;
|
|
114
|
+
export declare const ClaudeCodeStateSchema: z.ZodObject<{
|
|
115
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
116
|
+
sessions: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
117
|
+
activeSessions: z.ZodArray<z.ZodString>;
|
|
118
|
+
claudeAvailable: z.ZodBoolean;
|
|
119
|
+
claudeVersion: z.ZodOptional<z.ZodString>;
|
|
120
|
+
}, z.core.$loose>;
|
|
121
|
+
export declare const FileLogLevelSchema: z.ZodEnum<{
|
|
122
|
+
minimal: "minimal";
|
|
123
|
+
verbose: "verbose";
|
|
124
|
+
normal: "normal";
|
|
125
|
+
}>;
|
|
126
|
+
export type FileLogLevel = z.infer<typeof FileLogLevelSchema>;
|
|
127
|
+
export declare const ClaudeCodeOptionsSchema: z.ZodObject<{
|
|
128
|
+
name: z.ZodOptional<z.ZodString>;
|
|
129
|
+
_cacheKey: z.ZodOptional<z.ZodString>;
|
|
130
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
131
|
+
enable: z.ZodOptional<z.ZodBoolean>;
|
|
132
|
+
session: z.ZodOptional<z.ZodString>;
|
|
133
|
+
claudePath: z.ZodOptional<z.ZodString>;
|
|
134
|
+
model: z.ZodOptional<z.ZodString>;
|
|
135
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
136
|
+
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
137
|
+
appendSystemPrompt: z.ZodOptional<z.ZodString>;
|
|
138
|
+
permissionMode: z.ZodOptional<z.ZodEnum<{
|
|
139
|
+
default: "default";
|
|
140
|
+
acceptEdits: "acceptEdits";
|
|
141
|
+
bypassPermissions: "bypassPermissions";
|
|
142
|
+
plan: "plan";
|
|
143
|
+
dontAsk: "dontAsk";
|
|
144
|
+
}>>;
|
|
145
|
+
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
146
|
+
disallowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
147
|
+
streaming: z.ZodOptional<z.ZodBoolean>;
|
|
148
|
+
mcpConfig: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
149
|
+
mcpServers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
150
|
+
fileLogPath: z.ZodOptional<z.ZodString>;
|
|
151
|
+
fileLogLevel: z.ZodOptional<z.ZodEnum<{
|
|
152
|
+
minimal: "minimal";
|
|
153
|
+
verbose: "verbose";
|
|
154
|
+
normal: "normal";
|
|
155
|
+
}>>;
|
|
156
|
+
effort: z.ZodOptional<z.ZodEnum<{
|
|
157
|
+
low: "low";
|
|
158
|
+
medium: "medium";
|
|
159
|
+
high: "high";
|
|
160
|
+
}>>;
|
|
161
|
+
maxBudgetUsd: z.ZodOptional<z.ZodNumber>;
|
|
162
|
+
fallbackModel: z.ZodOptional<z.ZodString>;
|
|
163
|
+
agent: z.ZodOptional<z.ZodString>;
|
|
164
|
+
noSessionPersistence: z.ZodOptional<z.ZodBoolean>;
|
|
165
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
166
|
+
strictMcpConfig: z.ZodOptional<z.ZodBoolean>;
|
|
167
|
+
settingsFile: z.ZodOptional<z.ZodString>;
|
|
168
|
+
skillsFolders: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
169
|
+
chrome: z.ZodOptional<z.ZodBoolean>;
|
|
170
|
+
}, z.core.$strip>;
|
|
171
|
+
export declare const ClaudeCodeEventsSchema: z.ZodObject<{
|
|
172
|
+
stateChange: z.ZodTuple<[z.ZodAny], null>;
|
|
173
|
+
enabled: z.ZodTuple<[], null>;
|
|
174
|
+
'session:start': z.ZodTuple<[z.ZodObject<{
|
|
175
|
+
sessionId: z.ZodString;
|
|
176
|
+
prompt: z.ZodString;
|
|
177
|
+
}, z.core.$strip>], null>;
|
|
178
|
+
'session:init': z.ZodTuple<[z.ZodObject<{
|
|
179
|
+
sessionId: z.ZodString;
|
|
180
|
+
init: z.ZodAny;
|
|
181
|
+
}, z.core.$strip>], null>;
|
|
182
|
+
'session:event': z.ZodTuple<[z.ZodObject<{
|
|
183
|
+
sessionId: z.ZodString;
|
|
184
|
+
event: z.ZodAny;
|
|
185
|
+
}, z.core.$strip>], null>;
|
|
186
|
+
'session:stream': z.ZodTuple<[z.ZodObject<{
|
|
187
|
+
sessionId: z.ZodString;
|
|
188
|
+
streamEvent: z.ZodAny;
|
|
189
|
+
}, z.core.$strip>], null>;
|
|
190
|
+
'session:delta': z.ZodTuple<[z.ZodObject<{
|
|
191
|
+
sessionId: z.ZodString;
|
|
192
|
+
text: z.ZodString;
|
|
193
|
+
role: z.ZodString;
|
|
194
|
+
}, z.core.$strip>], null>;
|
|
195
|
+
'session:message': z.ZodTuple<[z.ZodObject<{
|
|
196
|
+
sessionId: z.ZodString;
|
|
197
|
+
message: z.ZodAny;
|
|
198
|
+
}, z.core.$strip>], null>;
|
|
199
|
+
'session:result': z.ZodTuple<[z.ZodObject<{
|
|
200
|
+
sessionId: z.ZodString;
|
|
201
|
+
result: z.ZodString;
|
|
202
|
+
}, z.core.$strip>], null>;
|
|
203
|
+
'session:error': z.ZodTuple<[z.ZodObject<{
|
|
204
|
+
sessionId: z.ZodString;
|
|
205
|
+
error: z.ZodAny;
|
|
206
|
+
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
207
|
+
}, z.core.$strip>], null>;
|
|
208
|
+
'session:abort': z.ZodTuple<[z.ZodObject<{
|
|
209
|
+
sessionId: z.ZodString;
|
|
210
|
+
}, z.core.$strip>], null>;
|
|
211
|
+
'session:warning': z.ZodTuple<[z.ZodObject<{
|
|
212
|
+
sessionId: z.ZodString;
|
|
213
|
+
message: z.ZodString;
|
|
214
|
+
}, z.core.$strip>], null>;
|
|
215
|
+
'session:log-error': z.ZodTuple<[z.ZodObject<{
|
|
216
|
+
sessionId: z.ZodString;
|
|
217
|
+
error: z.ZodAny;
|
|
218
|
+
}, z.core.$strip>], null>;
|
|
219
|
+
'session:parse-error': z.ZodTuple<[z.ZodObject<{
|
|
220
|
+
sessionId: z.ZodString;
|
|
221
|
+
line: z.ZodString;
|
|
222
|
+
}, z.core.$strip>], null>;
|
|
223
|
+
}, z.core.$strip>;
|
|
224
|
+
export type ClaudeCodeState = z.infer<typeof ClaudeCodeStateSchema>;
|
|
225
|
+
export type ClaudeCodeOptions = z.infer<typeof ClaudeCodeOptionsSchema>;
|
|
226
|
+
export interface RunOptions {
|
|
227
|
+
/** Override model for this session. */
|
|
228
|
+
model?: string;
|
|
229
|
+
/** Override working directory. */
|
|
230
|
+
cwd?: string;
|
|
231
|
+
/** System prompt for this session. */
|
|
232
|
+
systemPrompt?: string;
|
|
233
|
+
/** Append system prompt for this session. */
|
|
234
|
+
appendSystemPrompt?: string;
|
|
235
|
+
/** Permission mode override. */
|
|
236
|
+
permissionMode?: 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan' | 'dontAsk';
|
|
237
|
+
/** Allowed tools override. */
|
|
238
|
+
allowedTools?: string[];
|
|
239
|
+
/** Disallowed tools override. */
|
|
240
|
+
disallowedTools?: string[];
|
|
241
|
+
/** Whether to stream partial messages. */
|
|
242
|
+
streaming?: boolean;
|
|
243
|
+
/** Resume a previous session by ID. */
|
|
244
|
+
resumeSessionId?: string;
|
|
245
|
+
/** Continue the most recent conversation. */
|
|
246
|
+
continue?: boolean;
|
|
247
|
+
/** Additional directories to allow tool access to. */
|
|
248
|
+
addDirs?: string[];
|
|
249
|
+
/** Directories containing Claude Code skills (SKILL.md files) to load into sessions. Merged with addDirs as --add-dir. */
|
|
250
|
+
skillsFolders?: string[];
|
|
251
|
+
/** MCP config file paths. */
|
|
252
|
+
mcpConfig?: string[];
|
|
253
|
+
/** MCP servers to inject, keyed by server name. */
|
|
254
|
+
mcpServers?: Record<string, McpServerConfig>;
|
|
255
|
+
/** Skip all permission checks (only for sandboxed environments). */
|
|
256
|
+
dangerouslySkipPermissions?: boolean;
|
|
257
|
+
/** Additional arbitrary CLI flags. */
|
|
258
|
+
extraArgs?: string[];
|
|
259
|
+
/** Path to write a parseable NDJSON session log file. Overrides feature-level fileLogPath. */
|
|
260
|
+
fileLogPath?: string;
|
|
261
|
+
/** Verbosity level for file logging. Overrides feature-level fileLogLevel. */
|
|
262
|
+
fileLogLevel?: FileLogLevel;
|
|
263
|
+
/** Effort level for Claude reasoning. */
|
|
264
|
+
effort?: 'low' | 'medium' | 'high';
|
|
265
|
+
/** Maximum cost budget in USD. */
|
|
266
|
+
maxBudgetUsd?: number;
|
|
267
|
+
/** Fallback model when the primary is unavailable. */
|
|
268
|
+
fallbackModel?: string;
|
|
269
|
+
/** JSON schema for structured output validation. */
|
|
270
|
+
jsonSchema?: string | object;
|
|
271
|
+
/** Agent to use for this session. */
|
|
272
|
+
agent?: string;
|
|
273
|
+
/** Resume or fork a specific Claude session by ID. */
|
|
274
|
+
sessionId?: string;
|
|
275
|
+
/** Disable session persistence for this run. */
|
|
276
|
+
noSessionPersistence?: boolean;
|
|
277
|
+
/** Fork from an existing session instead of resuming. */
|
|
278
|
+
forkSession?: boolean;
|
|
279
|
+
/** Tools to make available. */
|
|
280
|
+
tools?: string[];
|
|
281
|
+
/** Require strict MCP config validation. */
|
|
282
|
+
strictMcpConfig?: boolean;
|
|
283
|
+
/** Enable debug output. Pass a string for specific debug channels, or true for all. */
|
|
284
|
+
debug?: string | boolean;
|
|
285
|
+
/** Path to write debug output to a file. */
|
|
286
|
+
debugFile?: string;
|
|
287
|
+
/** Path to a custom settings file. */
|
|
288
|
+
settingsFile?: string;
|
|
289
|
+
/** Launch Claude Code with a Chrome browser tool. */
|
|
290
|
+
chrome?: boolean;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Claude Code CLI wrapper feature. Spawns and manages Claude Code sessions
|
|
294
|
+
* as subprocesses, streaming structured JSON events back through the
|
|
295
|
+
* container's event system.
|
|
296
|
+
*
|
|
297
|
+
* Sessions are long-lived: each call to `run()` spawns a `claude -p` process
|
|
298
|
+
* with `--output-format stream-json`, parses NDJSON from stdout line-by-line,
|
|
299
|
+
* and emits typed events on the feature's event bus.
|
|
300
|
+
*
|
|
301
|
+
* @extends Feature
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```typescript
|
|
305
|
+
* const cc = container.feature('claudeCode')
|
|
306
|
+
*
|
|
307
|
+
* // Listen for events
|
|
308
|
+
* cc.on('session:delta', ({ sessionId, text }) => process.stdout.write(text))
|
|
309
|
+
* cc.on('session:result', ({ sessionId, result }) => console.log('Done:', result))
|
|
310
|
+
*
|
|
311
|
+
* // Run a prompt
|
|
312
|
+
* const session = await cc.run('Explain the architecture of this project')
|
|
313
|
+
* console.log(session.result)
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
export declare class ClaudeCode extends Feature<ClaudeCodeState, ClaudeCodeOptions> {
|
|
317
|
+
static stateSchema: z.ZodObject<{
|
|
318
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
319
|
+
sessions: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
320
|
+
activeSessions: z.ZodArray<z.ZodString>;
|
|
321
|
+
claudeAvailable: z.ZodBoolean;
|
|
322
|
+
claudeVersion: z.ZodOptional<z.ZodString>;
|
|
323
|
+
}, z.core.$loose>;
|
|
324
|
+
static optionsSchema: z.ZodObject<{
|
|
325
|
+
name: z.ZodOptional<z.ZodString>;
|
|
326
|
+
_cacheKey: z.ZodOptional<z.ZodString>;
|
|
327
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
328
|
+
enable: z.ZodOptional<z.ZodBoolean>;
|
|
329
|
+
session: z.ZodOptional<z.ZodString>;
|
|
330
|
+
claudePath: z.ZodOptional<z.ZodString>;
|
|
331
|
+
model: z.ZodOptional<z.ZodString>;
|
|
332
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
333
|
+
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
334
|
+
appendSystemPrompt: z.ZodOptional<z.ZodString>;
|
|
335
|
+
permissionMode: z.ZodOptional<z.ZodEnum<{
|
|
336
|
+
default: "default";
|
|
337
|
+
acceptEdits: "acceptEdits";
|
|
338
|
+
bypassPermissions: "bypassPermissions";
|
|
339
|
+
plan: "plan";
|
|
340
|
+
dontAsk: "dontAsk";
|
|
341
|
+
}>>;
|
|
342
|
+
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
343
|
+
disallowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
344
|
+
streaming: z.ZodOptional<z.ZodBoolean>;
|
|
345
|
+
mcpConfig: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
346
|
+
mcpServers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
347
|
+
fileLogPath: z.ZodOptional<z.ZodString>;
|
|
348
|
+
fileLogLevel: z.ZodOptional<z.ZodEnum<{
|
|
349
|
+
minimal: "minimal";
|
|
350
|
+
verbose: "verbose";
|
|
351
|
+
normal: "normal";
|
|
352
|
+
}>>;
|
|
353
|
+
effort: z.ZodOptional<z.ZodEnum<{
|
|
354
|
+
low: "low";
|
|
355
|
+
medium: "medium";
|
|
356
|
+
high: "high";
|
|
357
|
+
}>>;
|
|
358
|
+
maxBudgetUsd: z.ZodOptional<z.ZodNumber>;
|
|
359
|
+
fallbackModel: z.ZodOptional<z.ZodString>;
|
|
360
|
+
agent: z.ZodOptional<z.ZodString>;
|
|
361
|
+
noSessionPersistence: z.ZodOptional<z.ZodBoolean>;
|
|
362
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
363
|
+
strictMcpConfig: z.ZodOptional<z.ZodBoolean>;
|
|
364
|
+
settingsFile: z.ZodOptional<z.ZodString>;
|
|
365
|
+
skillsFolders: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
366
|
+
chrome: z.ZodOptional<z.ZodBoolean>;
|
|
367
|
+
}, z.core.$strip>;
|
|
368
|
+
static eventsSchema: z.ZodObject<{
|
|
369
|
+
stateChange: z.ZodTuple<[z.ZodAny], null>;
|
|
370
|
+
enabled: z.ZodTuple<[], null>;
|
|
371
|
+
'session:start': z.ZodTuple<[z.ZodObject<{
|
|
372
|
+
sessionId: z.ZodString;
|
|
373
|
+
prompt: z.ZodString;
|
|
374
|
+
}, z.core.$strip>], null>;
|
|
375
|
+
'session:init': z.ZodTuple<[z.ZodObject<{
|
|
376
|
+
sessionId: z.ZodString;
|
|
377
|
+
init: z.ZodAny;
|
|
378
|
+
}, z.core.$strip>], null>;
|
|
379
|
+
'session:event': z.ZodTuple<[z.ZodObject<{
|
|
380
|
+
sessionId: z.ZodString;
|
|
381
|
+
event: z.ZodAny;
|
|
382
|
+
}, z.core.$strip>], null>;
|
|
383
|
+
'session:stream': z.ZodTuple<[z.ZodObject<{
|
|
384
|
+
sessionId: z.ZodString;
|
|
385
|
+
streamEvent: z.ZodAny;
|
|
386
|
+
}, z.core.$strip>], null>;
|
|
387
|
+
'session:delta': z.ZodTuple<[z.ZodObject<{
|
|
388
|
+
sessionId: z.ZodString;
|
|
389
|
+
text: z.ZodString;
|
|
390
|
+
role: z.ZodString;
|
|
391
|
+
}, z.core.$strip>], null>;
|
|
392
|
+
'session:message': z.ZodTuple<[z.ZodObject<{
|
|
393
|
+
sessionId: z.ZodString;
|
|
394
|
+
message: z.ZodAny;
|
|
395
|
+
}, z.core.$strip>], null>;
|
|
396
|
+
'session:result': z.ZodTuple<[z.ZodObject<{
|
|
397
|
+
sessionId: z.ZodString;
|
|
398
|
+
result: z.ZodString;
|
|
399
|
+
}, z.core.$strip>], null>;
|
|
400
|
+
'session:error': z.ZodTuple<[z.ZodObject<{
|
|
401
|
+
sessionId: z.ZodString;
|
|
402
|
+
error: z.ZodAny;
|
|
403
|
+
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
404
|
+
}, z.core.$strip>], null>;
|
|
405
|
+
'session:abort': z.ZodTuple<[z.ZodObject<{
|
|
406
|
+
sessionId: z.ZodString;
|
|
407
|
+
}, z.core.$strip>], null>;
|
|
408
|
+
'session:warning': z.ZodTuple<[z.ZodObject<{
|
|
409
|
+
sessionId: z.ZodString;
|
|
410
|
+
message: z.ZodString;
|
|
411
|
+
}, z.core.$strip>], null>;
|
|
412
|
+
'session:log-error': z.ZodTuple<[z.ZodObject<{
|
|
413
|
+
sessionId: z.ZodString;
|
|
414
|
+
error: z.ZodAny;
|
|
415
|
+
}, z.core.$strip>], null>;
|
|
416
|
+
'session:parse-error': z.ZodTuple<[z.ZodObject<{
|
|
417
|
+
sessionId: z.ZodString;
|
|
418
|
+
line: z.ZodString;
|
|
419
|
+
}, z.core.$strip>], null>;
|
|
420
|
+
}, z.core.$strip>;
|
|
421
|
+
static shortcut: "features.claudeCode";
|
|
422
|
+
static envVars: string[];
|
|
423
|
+
get initialState(): ClaudeCodeState;
|
|
424
|
+
/**
|
|
425
|
+
* Resolve the path to the claude CLI binary.
|
|
426
|
+
*
|
|
427
|
+
* @returns {string} The path to the claude binary
|
|
428
|
+
*/
|
|
429
|
+
private _resolvedClaudePath;
|
|
430
|
+
get claudePath(): string;
|
|
431
|
+
/**
|
|
432
|
+
* Parsed semver components from the detected CLI version, or undefined if not yet checked.
|
|
433
|
+
*
|
|
434
|
+
* @returns {{ major: number; minor: number; patch: number } | undefined} Parsed version
|
|
435
|
+
*/
|
|
436
|
+
get parsedVersion(): {
|
|
437
|
+
major: number;
|
|
438
|
+
minor: number;
|
|
439
|
+
patch: number;
|
|
440
|
+
} | undefined;
|
|
441
|
+
/**
|
|
442
|
+
* Assert that the detected CLI version meets a minimum major.minor requirement.
|
|
443
|
+
* Throws if the CLI version is below the specified minimum.
|
|
444
|
+
*
|
|
445
|
+
* @param {number} major - Minimum major version
|
|
446
|
+
* @param {number} minor - Minimum minor version
|
|
447
|
+
*/
|
|
448
|
+
assertMinVersion(major: number, minor: number): void;
|
|
449
|
+
/**
|
|
450
|
+
* Check if the Claude CLI is available and capture its version.
|
|
451
|
+
*
|
|
452
|
+
* @returns {Promise<boolean>} Whether the CLI is available
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```typescript
|
|
456
|
+
* const available = await cc.checkAvailability()
|
|
457
|
+
* if (!available) throw new Error('Claude CLI not found')
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
460
|
+
checkAvailability(): Promise<boolean>;
|
|
461
|
+
/** Tracks temp MCP config files created for cleanup */
|
|
462
|
+
private mcpTempFiles;
|
|
463
|
+
/** Tracks active file log paths per session */
|
|
464
|
+
private sessionLogPaths;
|
|
465
|
+
/**
|
|
466
|
+
* Resolve the file log path for a session, checking per-session options then feature-level defaults.
|
|
467
|
+
*
|
|
468
|
+
* @param {RunOptions} options - Per-session options
|
|
469
|
+
* @returns {{ path: string; level: FileLogLevel } | undefined} Log config if logging is enabled
|
|
470
|
+
*/
|
|
471
|
+
private resolveFileLog;
|
|
472
|
+
/**
|
|
473
|
+
* Write a log entry to the session's NDJSON log file.
|
|
474
|
+
* Each line is a self-contained JSON object with timestamp, sessionId, event type, and data.
|
|
475
|
+
*
|
|
476
|
+
* @param {string} sessionId - The local session ID
|
|
477
|
+
* @param {string} type - Event type label (e.g. 'session:init', 'session:message')
|
|
478
|
+
* @param {any} data - Event payload
|
|
479
|
+
*/
|
|
480
|
+
private writeLogEntry;
|
|
481
|
+
/**
|
|
482
|
+
* Determine if an event should be logged based on the configured log level.
|
|
483
|
+
*
|
|
484
|
+
* - verbose: all events (stream deltas, partial messages, everything)
|
|
485
|
+
* - normal: assistant messages, tool results, init, result, errors (no stream_event)
|
|
486
|
+
* - minimal: init and result/error only
|
|
487
|
+
*
|
|
488
|
+
* @param {string} eventType - The Claude event type
|
|
489
|
+
* @param {FileLogLevel} level - The configured log level
|
|
490
|
+
* @returns {boolean} Whether to log this event
|
|
491
|
+
*/
|
|
492
|
+
private shouldLog;
|
|
493
|
+
/**
|
|
494
|
+
* Write an MCP server config map to a temp file suitable for `--mcp-config`.
|
|
495
|
+
*
|
|
496
|
+
* @param {Record<string, McpServerConfig>} servers - Server configs keyed by name
|
|
497
|
+
* @returns {Promise<string>} Path to the generated temp config file
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* ```typescript
|
|
501
|
+
* const configPath = await cc.writeMcpConfig({
|
|
502
|
+
* 'my-api': { type: 'http', url: 'https://api.example.com/mcp' },
|
|
503
|
+
* 'local-tool': { type: 'stdio', command: 'bun', args: ['run', 'server.ts'] }
|
|
504
|
+
* })
|
|
505
|
+
* ```
|
|
506
|
+
*/
|
|
507
|
+
writeMcpConfig(servers: Record<string, McpServerConfig>): Promise<string>;
|
|
508
|
+
/**
|
|
509
|
+
* Build the argument array for a claude CLI invocation.
|
|
510
|
+
*
|
|
511
|
+
* @param {string} prompt - The prompt text
|
|
512
|
+
* @param {RunOptions} options - Session options
|
|
513
|
+
* @returns {Promise<string[]>} CLI arguments
|
|
514
|
+
*/
|
|
515
|
+
private buildArgs;
|
|
516
|
+
/**
|
|
517
|
+
* Create a unique session ID.
|
|
518
|
+
*
|
|
519
|
+
* @returns {string} A UUID-based session ID
|
|
520
|
+
*/
|
|
521
|
+
private createSessionId;
|
|
522
|
+
/**
|
|
523
|
+
* Update a session in state.
|
|
524
|
+
*
|
|
525
|
+
* @param {string} id - The local session ID
|
|
526
|
+
* @param {Partial<ClaudeSession>} update - Fields to merge
|
|
527
|
+
*/
|
|
528
|
+
private updateSession;
|
|
529
|
+
/**
|
|
530
|
+
* Process a parsed JSON event from the Claude CLI stream.
|
|
531
|
+
*
|
|
532
|
+
* @param {string} sessionId - The local session ID
|
|
533
|
+
* @param {ClaudeEvent} event - The parsed event
|
|
534
|
+
*/
|
|
535
|
+
private handleEvent;
|
|
536
|
+
/**
|
|
537
|
+
* Run a prompt in a new Claude Code session. Spawns a subprocess,
|
|
538
|
+
* streams NDJSON events, and resolves when the session completes.
|
|
539
|
+
*
|
|
540
|
+
* @param {string} prompt - The instruction/prompt to send
|
|
541
|
+
* @param {RunOptions} [options] - Session configuration overrides
|
|
542
|
+
* @returns {Promise<ClaudeSession>} The completed session with result
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* ```typescript
|
|
546
|
+
* // Simple one-shot
|
|
547
|
+
* const session = await cc.run('What files are in this project?')
|
|
548
|
+
* console.log(session.result)
|
|
549
|
+
*
|
|
550
|
+
* // With options
|
|
551
|
+
* const session = await cc.run('Refactor the auth module', {
|
|
552
|
+
* model: 'opus',
|
|
553
|
+
* cwd: '/path/to/project',
|
|
554
|
+
* permissionMode: 'acceptEdits',
|
|
555
|
+
* streaming: true
|
|
556
|
+
* })
|
|
557
|
+
*
|
|
558
|
+
* // With injected MCP servers
|
|
559
|
+
* const session = await cc.run('Use the database tools to list tables', {
|
|
560
|
+
* mcpServers: {
|
|
561
|
+
* 'db-tools': { type: 'stdio', command: 'bun', args: ['run', 'db-mcp.ts'] },
|
|
562
|
+
* 'api': { type: 'http', url: 'https://api.example.com/mcp' }
|
|
563
|
+
* }
|
|
564
|
+
* })
|
|
565
|
+
*
|
|
566
|
+
* // Resume a previous session
|
|
567
|
+
* const session = await cc.run('Now add tests for that', {
|
|
568
|
+
* resumeSessionId: previousSession.sessionId
|
|
569
|
+
* })
|
|
570
|
+
* ```
|
|
571
|
+
*/
|
|
572
|
+
run(prompt: string, options?: RunOptions): Promise<ClaudeSession>;
|
|
573
|
+
/**
|
|
574
|
+
* Run a prompt without waiting for completion. Returns the session ID
|
|
575
|
+
* immediately so you can subscribe to events.
|
|
576
|
+
*
|
|
577
|
+
* @param {string} prompt - The instruction/prompt to send
|
|
578
|
+
* @param {RunOptions} [options] - Session configuration overrides
|
|
579
|
+
* @returns {string} The session ID to track via events
|
|
580
|
+
*
|
|
581
|
+
* @example
|
|
582
|
+
* ```typescript
|
|
583
|
+
* const sessionId = cc.start('Build a REST API for users')
|
|
584
|
+
*
|
|
585
|
+
* cc.on('session:delta', ({ sessionId: sid, text }) => {
|
|
586
|
+
* if (sid === sessionId) process.stdout.write(text)
|
|
587
|
+
* })
|
|
588
|
+
*
|
|
589
|
+
* cc.on('session:result', ({ sessionId: sid, result }) => {
|
|
590
|
+
* if (sid === sessionId) console.log('\nDone:', result)
|
|
591
|
+
* })
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
start(prompt: string, options?: RunOptions): Promise<string>;
|
|
595
|
+
/**
|
|
596
|
+
* Consume the stdout stream of a running process in the background.
|
|
597
|
+
*
|
|
598
|
+
* @param {string} sessionId - The local session ID
|
|
599
|
+
* @param {any} proc - The process handle returned by features.proc.spawn()
|
|
600
|
+
*/
|
|
601
|
+
private consumeStream;
|
|
602
|
+
/**
|
|
603
|
+
* Kill a running session's subprocess.
|
|
604
|
+
*
|
|
605
|
+
* @param {string} sessionId - The local session ID to abort
|
|
606
|
+
*
|
|
607
|
+
* @example
|
|
608
|
+
* ```typescript
|
|
609
|
+
* const sessionId = cc.start('Do something long')
|
|
610
|
+
* // ... later
|
|
611
|
+
* cc.abort(sessionId)
|
|
612
|
+
* ```
|
|
613
|
+
*/
|
|
614
|
+
abort(sessionId: string): void;
|
|
615
|
+
/**
|
|
616
|
+
* Get a session by its local ID.
|
|
617
|
+
*
|
|
618
|
+
* @param {string} sessionId - The local session ID
|
|
619
|
+
* @returns {ClaudeSession | undefined} The session if it exists
|
|
620
|
+
*
|
|
621
|
+
* @example
|
|
622
|
+
* ```typescript
|
|
623
|
+
* const session = cc.getSession(sessionId)
|
|
624
|
+
* if (session?.status === 'completed') {
|
|
625
|
+
* console.log(session.result)
|
|
626
|
+
* }
|
|
627
|
+
* ```
|
|
628
|
+
*/
|
|
629
|
+
getSession(sessionId: string): ClaudeSession | undefined;
|
|
630
|
+
/**
|
|
631
|
+
* Wait for a running session to complete.
|
|
632
|
+
*
|
|
633
|
+
* @param {string} sessionId - The local session ID
|
|
634
|
+
* @returns {Promise<ClaudeSession>} The completed session
|
|
635
|
+
*
|
|
636
|
+
* @example
|
|
637
|
+
* ```typescript
|
|
638
|
+
* const id = cc.start('Build something cool')
|
|
639
|
+
* const session = await cc.waitForSession(id)
|
|
640
|
+
* console.log(session.result)
|
|
641
|
+
* ```
|
|
642
|
+
*/
|
|
643
|
+
waitForSession(sessionId: string): Promise<ClaudeSession>;
|
|
644
|
+
/**
|
|
645
|
+
* Get aggregated usage statistics across all sessions, or for a specific session.
|
|
646
|
+
*
|
|
647
|
+
* @param {string} [sessionId] - Optional session ID to get usage for a single session
|
|
648
|
+
* @returns {{ totalCostUsd: number; totalInputTokens: number; totalOutputTokens: number; totalCacheReadTokens: number; totalCacheCreationTokens: number; totalTurns: number; sessionCount: number; sessions: Array<{ id: string; costUsd: number; turns: number; inputTokens: number; outputTokens: number; status: string }> }} Usage statistics
|
|
649
|
+
*
|
|
650
|
+
* @example
|
|
651
|
+
* ```typescript
|
|
652
|
+
* const stats = cc.usage()
|
|
653
|
+
* console.log(`Total cost: $${stats.totalCostUsd.toFixed(4)}`)
|
|
654
|
+
* console.log(`Tokens: ${stats.totalInputTokens} in / ${stats.totalOutputTokens} out`)
|
|
655
|
+
*
|
|
656
|
+
* // Single session
|
|
657
|
+
* const sessionStats = cc.usage(sessionId)
|
|
658
|
+
* ```
|
|
659
|
+
*/
|
|
660
|
+
usage(sessionId?: string): {
|
|
661
|
+
totalCostUsd: number;
|
|
662
|
+
totalInputTokens: number;
|
|
663
|
+
totalOutputTokens: number;
|
|
664
|
+
totalCacheReadTokens: number;
|
|
665
|
+
totalCacheCreationTokens: number;
|
|
666
|
+
totalTurns: number;
|
|
667
|
+
sessionCount: number;
|
|
668
|
+
maxBudgetUsd: number | null;
|
|
669
|
+
budgetRemainingUsd: number | null;
|
|
670
|
+
budgetUsedPercent: number | null;
|
|
671
|
+
sessions: {
|
|
672
|
+
id: string;
|
|
673
|
+
costUsd: number;
|
|
674
|
+
turns: number;
|
|
675
|
+
inputTokens: number;
|
|
676
|
+
outputTokens: number;
|
|
677
|
+
status: string;
|
|
678
|
+
}[];
|
|
679
|
+
};
|
|
680
|
+
/**
|
|
681
|
+
* The Claude CLI session ID of the most recently initialized session,
|
|
682
|
+
* or the session set via the `session` option. Useful for resuming later.
|
|
683
|
+
*
|
|
684
|
+
* @returns {string | undefined} The Claude CLI session ID
|
|
685
|
+
*
|
|
686
|
+
* @example
|
|
687
|
+
* ```typescript
|
|
688
|
+
* const cc = container.feature('claudeCode')
|
|
689
|
+
* await cc.run('Do something')
|
|
690
|
+
* console.log(cc.sessionId) // the Claude CLI session ID
|
|
691
|
+
* ```
|
|
692
|
+
*/
|
|
693
|
+
get sessionId(): string | undefined;
|
|
694
|
+
/**
|
|
695
|
+
* Export session history as a readable markdown document.
|
|
696
|
+
* Reads from a raw JSONL file (Claude CLI session log or this feature's NDJSON log)
|
|
697
|
+
* so it works independently of in-memory state.
|
|
698
|
+
*
|
|
699
|
+
* Can also accept a local session ID to export from in-memory state as a fallback.
|
|
700
|
+
*
|
|
701
|
+
* @param {string} [source] - Path to a JSONL file, a local session ID, or omit for the most recent session
|
|
702
|
+
* @returns {Promise<string>} Markdown-formatted session history
|
|
703
|
+
*
|
|
704
|
+
* @example
|
|
705
|
+
* ```typescript
|
|
706
|
+
* // From a JSONL file (works without any prior state)
|
|
707
|
+
* const md = await cc.sessionHistoryToMarkdown('/path/to/session.jsonl')
|
|
708
|
+
*
|
|
709
|
+
* // From the most recent in-memory session
|
|
710
|
+
* const md = await cc.sessionHistoryToMarkdown()
|
|
711
|
+
*
|
|
712
|
+
* // From a specific local session ID
|
|
713
|
+
* const md = await cc.sessionHistoryToMarkdown(localSessionId)
|
|
714
|
+
* ```
|
|
715
|
+
*/
|
|
716
|
+
sessionHistoryToMarkdown(source?: string): Promise<string>;
|
|
717
|
+
/**
|
|
718
|
+
* Find the local ID of the most recent session.
|
|
719
|
+
*/
|
|
720
|
+
private findLastSessionId;
|
|
721
|
+
/**
|
|
722
|
+
* Parse a JSONL file and convert its events to markdown.
|
|
723
|
+
*/
|
|
724
|
+
private jsonlToMarkdown;
|
|
725
|
+
/**
|
|
726
|
+
* Convert a ClaudeSession (from state) to markdown.
|
|
727
|
+
*/
|
|
728
|
+
private sessionToMarkdown;
|
|
729
|
+
/**
|
|
730
|
+
* Convert raw Claude events to markdown.
|
|
731
|
+
*/
|
|
732
|
+
private eventsToMarkdown;
|
|
733
|
+
/**
|
|
734
|
+
* Render a single assistant message to markdown lines.
|
|
735
|
+
*/
|
|
736
|
+
private renderAssistantMessage;
|
|
737
|
+
/**
|
|
738
|
+
* List all Claude Code processes currently registered in ~/.claude/sessions/.
|
|
739
|
+
* Returns each session's metadata along with whether the process is still alive.
|
|
740
|
+
*
|
|
741
|
+
* @returns {Promise<Array<{ pid: number; sessionId: string; cwd: string; startedAt: number; kind: string; entrypoint: string; alive: boolean }>>}
|
|
742
|
+
*
|
|
743
|
+
* @example
|
|
744
|
+
* const sessions = await cc.listProcessSessions()
|
|
745
|
+
* for (const s of sessions) {
|
|
746
|
+
* console.log(`[${s.alive ? 'LIVE' : 'dead'}] PID ${s.pid} in ${s.cwd}`)
|
|
747
|
+
* }
|
|
748
|
+
*/
|
|
749
|
+
listProcessSessions(): Promise<Array<{
|
|
750
|
+
pid: number;
|
|
751
|
+
sessionId: string;
|
|
752
|
+
cwd: string;
|
|
753
|
+
startedAt: number;
|
|
754
|
+
kind: string;
|
|
755
|
+
entrypoint: string;
|
|
756
|
+
alive: boolean;
|
|
757
|
+
}>>;
|
|
758
|
+
/**
|
|
759
|
+
* Read a single process session by PID from ~/.claude/sessions/<pid>.json.
|
|
760
|
+
*
|
|
761
|
+
* @param {number} pid - The process ID
|
|
762
|
+
* @returns {Promise<{ pid: number; sessionId: string; cwd: string; startedAt: number; kind: string; entrypoint: string } | null>}
|
|
763
|
+
*
|
|
764
|
+
* @example
|
|
765
|
+
* const session = await cc.getProcessSession(12345)
|
|
766
|
+
* console.log(session?.cwd)
|
|
767
|
+
*/
|
|
768
|
+
getProcessSession(pid: number): Promise<{
|
|
769
|
+
pid: number;
|
|
770
|
+
sessionId: string;
|
|
771
|
+
cwd: string;
|
|
772
|
+
startedAt: number;
|
|
773
|
+
kind: string;
|
|
774
|
+
entrypoint: string;
|
|
775
|
+
} | null>;
|
|
776
|
+
/**
|
|
777
|
+
* Read the conversation history for a Claude Code session from its JSONL file in
|
|
778
|
+
* ~/.claude/projects/<encoded-cwd>/<sessionId>.jsonl.
|
|
779
|
+
*
|
|
780
|
+
* Returns an array of parsed message objects (user, assistant, tool_use, tool_result).
|
|
781
|
+
*
|
|
782
|
+
* @param {string} sessionId - The Claude CLI session ID (from listProcessSessions or getProcessSession)
|
|
783
|
+
* @param {string} cwd - The working directory of the session (used to locate the project folder)
|
|
784
|
+
* @returns {Promise<any[]>} Array of parsed JSONL records
|
|
785
|
+
*
|
|
786
|
+
* @example
|
|
787
|
+
* const sessions = await cc.listProcessSessions()
|
|
788
|
+
* const s = sessions[0]
|
|
789
|
+
* const history = await cc.getConversationHistory(s.sessionId, s.cwd)
|
|
790
|
+
* console.log(history.length, 'turns')
|
|
791
|
+
*/
|
|
792
|
+
getConversationHistory(sessionId: string, cwd?: string): Promise<any[]>;
|
|
793
|
+
/**
|
|
794
|
+
* List all conversation sessions stored for a given working directory.
|
|
795
|
+
* Reads ~/.claude/projects/<encoded-cwd>/ and returns metadata for each .jsonl file.
|
|
796
|
+
*
|
|
797
|
+
* @param {string} cwd - The working directory path to look up
|
|
798
|
+
* @returns {Promise<Array<{ sessionId: string; filePath: string; messageCount: number }>>}
|
|
799
|
+
*
|
|
800
|
+
* @example
|
|
801
|
+
* const sessions = await cc.listSessionsForCwd('/Users/me/my-project')
|
|
802
|
+
* for (const s of sessions) {
|
|
803
|
+
* console.log(s.sessionId, s.messageCount, 'messages')
|
|
804
|
+
* }
|
|
805
|
+
*/
|
|
806
|
+
listSessionsForCwd(cwd?: string): Promise<Array<{
|
|
807
|
+
sessionId: string;
|
|
808
|
+
filePath: string;
|
|
809
|
+
messageCount: number;
|
|
810
|
+
}>>;
|
|
811
|
+
/**
|
|
812
|
+
* Clean up any temp MCP config files created during sessions.
|
|
813
|
+
*/
|
|
814
|
+
cleanupMcpTempFiles(): Promise<void>;
|
|
815
|
+
/**
|
|
816
|
+
* Initialize the feature.
|
|
817
|
+
*
|
|
818
|
+
* @param {any} [options] - Enable options
|
|
819
|
+
* @returns {Promise<this>} The enabled feature
|
|
820
|
+
*/
|
|
821
|
+
enable(options?: any): Promise<this>;
|
|
822
|
+
}
|
|
823
|
+
export default ClaudeCode;
|
|
824
|
+
//# sourceMappingURL=claude-code.d.ts.map
|