@phuetz/code-buddy 2.0.0 → 2.2.0
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/README.fr.md +56 -0
- package/README.md +74 -16
- package/codebuddy-runtime.json +5 -5
- package/dist/agent/codebuddy-agent.d.ts +18 -0
- package/dist/agent/codebuddy-agent.js +45 -8
- package/dist/agent/execution/agent-executor.d.ts +0 -9
- package/dist/agent/execution/agent-executor.js +176 -12
- package/dist/agent/execution/context-pipeline.d.ts +9 -0
- package/dist/agent/execution/context-pipeline.js +64 -2
- package/dist/agent/execution/tool-loop-guard.d.ts +76 -0
- package/dist/agent/execution/tool-loop-guard.js +165 -0
- package/dist/agent/execution/tool-selection-strategy.d.ts +7 -0
- package/dist/agent/execution/tool-selection-strategy.js +32 -2
- package/dist/agent/facades/session-facade.d.ts +0 -6
- package/dist/agent/facades/session-facade.js +0 -45
- package/dist/agent/hermes-claw-migrate.d.ts +0 -21
- package/dist/agent/hermes-claw-migrate.js +9 -4
- package/dist/agent/hermes-protocol-gateways.js +8 -1
- package/dist/agent/repo-profiler.js +17 -4
- package/dist/agent/self-improvement/authored-tool-runtime.js +10 -2
- package/dist/agent/self-improvement/evolution/ast-novelty.d.ts +5 -0
- package/dist/agent/self-improvement/evolution/ast-novelty.js +58 -23
- package/dist/agent/self-improvement/evolution/code-variant-store.d.ts +3 -0
- package/dist/agent/self-improvement/evolution/evolution-engine.js +2 -0
- package/dist/agent/self-improvement/evolution/protected-paths.js +6 -0
- package/dist/agent/self-improvement/evolution/variant-fitness.d.ts +13 -2
- package/dist/agent/self-improvement/evolution/variant-fitness.js +184 -58
- package/dist/agent/self-improvement/evolution/worktree-scorer.d.ts +2 -0
- package/dist/agent/self-improvement/evolution/worktree-scorer.js +15 -0
- package/dist/agent/self-improvement/evolutionary-archive.d.ts +2 -1
- package/dist/agent/self-improvement/evolutionary-archive.js +34 -5
- package/dist/agent/self-improvement/proposal-store.d.ts +1 -0
- package/dist/agent/self-improvement/proposal-store.js +79 -17
- package/dist/agent/self-improvement/skill-apply-journal.d.ts +44 -0
- package/dist/agent/self-improvement/skill-apply-journal.js +178 -0
- package/dist/agent/self-improvement/skill-behavior-benchmark.d.ts +3 -0
- package/dist/agent/self-improvement/skill-behavior-benchmark.js +19 -0
- package/dist/agent/self-improvement/skill-behavior-gate.d.ts +34 -0
- package/dist/agent/self-improvement/skill-behavior-gate.js +96 -0
- package/dist/agent/self-improvement/skill-engine.d.ts +22 -0
- package/dist/agent/self-improvement/skill-engine.js +385 -13
- package/dist/agent/self-improvement/skill-gate.d.ts +2 -0
- package/dist/agent/self-improvement/skill-gate.js +17 -2
- package/dist/agent/self-improvement/skill-mutator.d.ts +6 -1
- package/dist/agent/self-improvement/skill-mutator.js +51 -15
- package/dist/agent/self-improvement/skill-types.d.ts +2 -1
- package/dist/agent/self-improvement/types.d.ts +11 -0
- package/dist/agent/tool-handler.d.ts +1 -1
- package/dist/agent/tool-handler.js +28 -9
- package/dist/auth/profile-manager.js +1 -1
- package/dist/channels/companion-channel-turn.d.ts +53 -4
- package/dist/channels/companion-channel-turn.js +218 -16
- package/dist/channels/slash-parity.d.ts +4 -6
- package/dist/channels/slash-parity.js +9 -44
- package/dist/cli/session-commands.d.ts +9 -0
- package/dist/cli/session-commands.js +45 -5
- package/dist/cli/session-picker.d.ts +43 -0
- package/dist/cli/session-picker.js +128 -0
- package/dist/codebuddy/a2a-call-tool-defs.d.ts +26 -0
- package/dist/codebuddy/a2a-call-tool-defs.js +12 -0
- package/dist/codebuddy/fleet-tool-defs.d.ts +2 -0
- package/dist/codebuddy/fleet-tool-defs.js +55 -0
- package/dist/codebuddy/providers/chatgpt-headers.d.ts +18 -0
- package/dist/codebuddy/providers/chatgpt-headers.js +37 -0
- package/dist/codebuddy/providers/provider-chatgpt-responses.d.ts +2 -1
- package/dist/codebuddy/providers/provider-chatgpt-responses.js +10 -23
- package/dist/codebuddy/providers/provider-openai-compat.d.ts +7 -0
- package/dist/codebuddy/providers/provider-openai-compat.js +29 -1
- package/dist/codebuddy/ragchat-tool-defs.d.ts +31 -0
- package/dist/codebuddy/ragchat-tool-defs.js +19 -0
- package/dist/codebuddy/resource-catalog-tool-defs.d.ts +28 -0
- package/dist/codebuddy/resource-catalog-tool-defs.js +18 -0
- package/dist/codebuddy/tool-definitions/agent-tools.js +2 -2
- package/dist/codebuddy/tool-definitions/code-exec-tools.js +5 -1
- package/dist/codebuddy/tool-definitions/cron-tools.js +6 -0
- package/dist/codebuddy/tool-definitions/self-describe-tools.js +6 -1
- package/dist/codebuddy/tools.d.ts +0 -6
- package/dist/codebuddy/tools.js +25 -3
- package/dist/commands/cli/daemon-commands.js +3 -1
- package/dist/commands/cli/evolve-command.js +21 -5
- package/dist/commands/cli/fleet-collaboration-commands.d.ts +2 -0
- package/dist/commands/cli/fleet-collaboration-commands.js +57 -0
- package/dist/commands/cli/fleet-commands.js +29 -0
- package/dist/commands/cli/fleet-mission-commands.d.ts +3 -0
- package/dist/commands/cli/fleet-mission-commands.js +72 -0
- package/dist/commands/cli/fleet-rooms-commands.d.ts +10 -0
- package/dist/commands/cli/fleet-rooms-commands.js +289 -0
- package/dist/commands/cli/tools-commands.js +2 -1
- package/dist/commands/cli/triage-command.d.ts +8 -0
- package/dist/commands/cli/triage-command.js +72 -0
- package/dist/commands/cli/utility-commands.js +25 -1
- package/dist/commands/client-dispatcher.d.ts +7 -0
- package/dist/commands/client-dispatcher.js +73 -21
- package/dist/commands/cron-cli/index.d.ts +3 -1
- package/dist/commands/cron-cli/index.js +25 -0
- package/dist/commands/device-auth.d.ts +10 -0
- package/dist/commands/device-auth.js +91 -0
- package/dist/commands/enhanced-command-handler.d.ts +9 -0
- package/dist/commands/enhanced-command-handler.js +28 -6
- package/dist/commands/handlers/agent-handlers.d.ts +1 -1
- package/dist/commands/handlers/agent-handlers.js +4 -4
- package/dist/commands/handlers/channel-handlers.js +53 -2
- package/dist/commands/handlers/export-handlers.d.ts +3 -2
- package/dist/commands/handlers/export-handlers.js +55 -28
- package/dist/commands/handlers/extra-handlers.js +5 -1
- package/dist/commands/handlers/grill-me-handler.js +26 -18
- package/dist/commands/handlers/memory-handlers.d.ts +6 -2
- package/dist/commands/handlers/memory-handlers.js +35 -15
- package/dist/commands/handlers/missing-handlers.d.ts +2 -2
- package/dist/commands/handlers/missing-handlers.js +12 -4
- package/dist/commands/handlers/resources-handler.d.ts +12 -0
- package/dist/commands/handlers/resources-handler.js +52 -0
- package/dist/commands/handlers/starter-handlers.d.ts +1 -1
- package/dist/commands/handlers/starter-handlers.js +32 -2
- package/dist/commands/handlers/switch-handler.d.ts +1 -1
- package/dist/commands/handlers/switch-handler.js +15 -0
- package/dist/commands/handlers/test-handlers.js +4 -86
- package/dist/commands/handlers/ui-handlers.js +11 -5
- package/dist/commands/login-chatgpt.d.ts +8 -0
- package/dist/commands/login-chatgpt.js +17 -0
- package/dist/commands/mcp-import.d.ts +11 -0
- package/dist/commands/mcp-import.js +67 -0
- package/dist/commands/mcp-invoke.d.ts +2 -0
- package/dist/commands/mcp-invoke.js +68 -0
- package/dist/commands/mcp.d.ts +13 -0
- package/dist/commands/mcp.js +66 -21
- package/dist/commands/pipeline.d.ts +7 -1
- package/dist/commands/pipeline.js +104 -7
- package/dist/commands/resources.d.ts +2 -0
- package/dist/commands/resources.js +64 -0
- package/dist/commands/skills-cli/index.js +35 -12
- package/dist/commands/slash/builtin-commands.js +16 -3
- package/dist/commands/slash/index.d.ts +3 -1
- package/dist/commands/slash/index.js +2 -0
- package/dist/commands/slash/surfaces.d.ts +53 -0
- package/dist/commands/slash/surfaces.js +177 -0
- package/dist/commands/slash/types.d.ts +17 -0
- package/dist/commands/try.d.ts +1 -1
- package/dist/commands/try.js +1 -1
- package/dist/companion/companion-identity.d.ts +43 -0
- package/dist/companion/companion-identity.js +136 -0
- package/dist/companion/companion-toolset.d.ts +66 -0
- package/dist/companion/companion-toolset.js +368 -0
- package/dist/companion/companion-turn.d.ts +10 -2
- package/dist/companion/companion-turn.js +38 -1
- package/dist/config/code-exec-policy.d.ts +25 -0
- package/dist/config/code-exec-policy.js +39 -0
- package/dist/config/model-tools.d.ts +9 -0
- package/dist/config/model-tools.js +103 -0
- package/dist/context/context-manager-v2.js +2 -2
- package/dist/context/lm-resizer-compressor.js +3 -2
- package/dist/context/lm-resizer-diagnostics.d.ts +9 -0
- package/dist/context/lm-resizer-diagnostics.js +30 -0
- package/dist/context/tool-output-masking.js +3 -4
- package/dist/curator/curator.d.ts +6 -0
- package/dist/curator/curator.js +53 -3
- package/dist/daemon/cron-agent-bridge.d.ts +6 -0
- package/dist/daemon/cron-agent-bridge.js +31 -4
- package/dist/doctor/index.d.ts +11 -2
- package/dist/doctor/index.js +84 -21
- package/dist/doctor/integrations.d.ts +197 -0
- package/dist/doctor/integrations.js +241 -0
- package/dist/doctor/triage.d.ts +108 -0
- package/dist/doctor/triage.js +304 -0
- package/dist/errors/crash-handler.js +2 -0
- package/dist/fleet/collaboration.d.ts +44 -0
- package/dist/fleet/collaboration.js +170 -0
- package/dist/fleet/fleet-listener.d.ts +1 -0
- package/dist/fleet/fleet-listener.js +87 -46
- package/dist/fleet/fleet-registry.d.ts +2 -0
- package/dist/fleet/resource-catalog.d.ts +245 -0
- package/dist/fleet/resource-catalog.js +211 -0
- package/dist/fleet/rooms/room-access.d.ts +138 -0
- package/dist/fleet/rooms/room-access.js +196 -0
- package/dist/fleet/rooms/room-client.d.ts +158 -0
- package/dist/fleet/rooms/room-client.js +685 -0
- package/dist/fleet/rooms/room-event.d.ts +139 -0
- package/dist/fleet/rooms/room-event.js +330 -0
- package/dist/fleet/rooms/room-filter.d.ts +48 -0
- package/dist/fleet/rooms/room-filter.js +152 -0
- package/dist/fleet/rooms/room-hub.d.ts +154 -0
- package/dist/fleet/rooms/room-hub.js +363 -0
- package/dist/fleet/rooms/room-identity.d.ts +26 -0
- package/dist/fleet/rooms/room-identity.js +82 -0
- package/dist/fleet/rooms/room-lock.d.ts +34 -0
- package/dist/fleet/rooms/room-lock.js +180 -0
- package/dist/fleet/rooms/room-observations.d.ts +7 -0
- package/dist/fleet/rooms/room-observations.js +61 -0
- package/dist/fleet/rooms/room-server.d.ts +28 -0
- package/dist/fleet/rooms/room-server.js +75 -0
- package/dist/fleet/rooms/room-store.d.ts +119 -0
- package/dist/fleet/rooms/room-store.js +448 -0
- package/dist/fleet/rooms/room-ws-bridge.d.ts +27 -0
- package/dist/fleet/rooms/room-ws-bridge.js +137 -0
- package/dist/fleet/sensory-mission-bridge.d.ts +42 -0
- package/dist/fleet/sensory-mission-bridge.js +136 -0
- package/dist/git/worktree-sessions.js +1 -0
- package/dist/harness/contract.d.ts +4 -4
- package/dist/harness/fleet-supervisor.d.ts +16 -0
- package/dist/harness/fleet-supervisor.js +64 -0
- package/dist/harness/index.d.ts +4 -0
- package/dist/harness/index.js +4 -0
- package/dist/harness/mission-runner.d.ts +3 -0
- package/dist/harness/mission-runner.js +53 -0
- package/dist/harness/mission-store.d.ts +93 -0
- package/dist/harness/mission-store.js +297 -0
- package/dist/harness/tool-harness.d.ts +56 -0
- package/dist/harness/tool-harness.js +153 -0
- package/dist/hooks/use-enhanced-input.js +48 -4
- package/dist/hooks/use-input-handler.d.ts +1 -0
- package/dist/hooks/use-input-handler.js +82 -22
- package/dist/hooks/use-input-history.js +1 -0
- package/dist/identity/lisa-introspection.js +5 -2
- package/dist/identity/operational-self-model.d.ts +2 -0
- package/dist/identity/operational-self-model.js +4 -0
- package/dist/index.js +52 -6
- package/dist/mcp/client.d.ts +11 -0
- package/dist/mcp/client.js +68 -3
- package/dist/mcp/config.d.ts +20 -0
- package/dist/mcp/config.js +121 -8
- package/dist/mcp/import-normalize.d.ts +12 -0
- package/dist/mcp/import-normalize.js +114 -0
- package/dist/mcp/mcp-oauth-constants.d.ts +8 -0
- package/dist/mcp/mcp-oauth-constants.js +9 -0
- package/dist/mcp/mcp-oauth-provider.d.ts +80 -0
- package/dist/mcp/mcp-oauth-provider.js +241 -0
- package/dist/mcp/mcp-oauth.d.ts +60 -1
- package/dist/mcp/mcp-oauth.js +241 -65
- package/dist/mcp/transports.d.ts +14 -5
- package/dist/mcp/transports.js +112 -101
- package/dist/mcp/types.d.ts +5 -0
- package/dist/media/comfyui-recipe-contract.d.ts +7 -7
- package/dist/memory/facts-memory.d.ts +11 -1
- package/dist/memory/facts-memory.js +47 -8
- package/dist/memory/memory-candidate-queue.d.ts +2 -2
- package/dist/memory/memory-candidate-queue.js +6 -6
- package/dist/memory/persistent-memory.d.ts +13 -8
- package/dist/memory/persistent-memory.js +77 -30
- package/dist/nodes/device-node.js +5 -9
- package/dist/observability/mobile-supervision-gateway-contract.js +20 -7
- package/dist/observability/run-event-writer.d.ts +21 -0
- package/dist/observability/run-event-writer.js +81 -0
- package/dist/observability/run-store.d.ts +5 -0
- package/dist/observability/run-store.js +18 -13
- package/dist/observability/run-trajectory.js +1 -1
- package/dist/optimization/prompt-cache.d.ts +19 -2
- package/dist/optimization/prompt-cache.js +41 -6
- package/dist/orchestration/orchestrator.d.ts +21 -0
- package/dist/orchestration/orchestrator.js +122 -15
- package/dist/persistence/session-content.d.ts +8 -0
- package/dist/persistence/session-content.js +76 -0
- package/dist/persistence/session-handoff.d.ts +64 -0
- package/dist/persistence/session-handoff.js +80 -0
- package/dist/persistence/session-history.d.ts +4 -0
- package/dist/persistence/session-history.js +38 -0
- package/dist/persistence/session-store.d.ts +9 -0
- package/dist/persistence/session-store.js +48 -20
- package/dist/personas/persona-manager.js +17 -1
- package/dist/plugins/code-explorer/CodeExplorerManager.d.ts +10 -4
- package/dist/plugins/code-explorer/CodeExplorerManager.js +69 -16
- package/dist/plugins/plugin-manager.js +10 -1
- package/dist/prompts/prompt-manager.js +11 -4
- package/dist/prompts/system-base.js +6 -2
- package/dist/protocols/a2a/codebuddy-executor.d.ts +11 -2
- package/dist/protocols/a2a/codebuddy-executor.js +9 -8
- package/dist/protocols/a2a/index.d.ts +1 -1
- package/dist/protocols/a2a/jsonrpc-v1.d.ts +41 -0
- package/dist/protocols/a2a/jsonrpc-v1.js +145 -0
- package/dist/protocols/a2a/peer-config.d.ts +20 -0
- package/dist/protocols/a2a/peer-config.js +55 -0
- package/dist/providers/codex-oauth.js +30 -6
- package/dist/providers/model-provider-compat.js +2 -1
- package/dist/sandbox/os-sandbox.d.ts +1 -1
- package/dist/scheduler/cron-scheduler.d.ts +15 -2
- package/dist/scheduler/cron-scheduler.js +35 -4
- package/dist/scheduler/job-notepad.d.ts +69 -0
- package/dist/scheduler/job-notepad.js +339 -0
- package/dist/security/audit-logger.d.ts +1 -1
- package/dist/security/compute-confinement.d.ts +4 -0
- package/dist/security/compute-confinement.js +89 -0
- package/dist/security/session-encryption.d.ts +4 -0
- package/dist/security/session-encryption.js +31 -0
- package/dist/sensory/voice-loop.d.ts +17 -0
- package/dist/sensory/voice-loop.js +72 -15
- package/dist/server/auth/device-session-context.d.ts +9 -0
- package/dist/server/auth/device-session-context.js +13 -0
- package/dist/server/auth/device-store.d.ts +89 -0
- package/dist/server/auth/device-store.js +261 -0
- package/dist/server/auth/device-token.d.ts +3 -0
- package/dist/server/auth/device-token.js +6 -0
- package/dist/server/auth/jwt.js +4 -0
- package/dist/server/index.d.ts +0 -10
- package/dist/server/index.js +28 -0
- package/dist/server/middleware/auth.js +3 -2
- package/dist/server/routes/a2a-jsonrpc.d.ts +9 -0
- package/dist/server/routes/a2a-jsonrpc.js +66 -0
- package/dist/server/routes/a2a-protocol.d.ts +12 -0
- package/dist/server/routes/a2a-protocol.js +1 -1
- package/dist/server/routes/device-auth.d.ts +4 -0
- package/dist/server/routes/device-auth.js +40 -0
- package/dist/server/types.d.ts +4 -0
- package/dist/server/websocket/handler.d.ts +13 -0
- package/dist/server/websocket/handler.js +102 -17
- package/dist/services/prompt-builder.d.ts +2 -0
- package/dist/services/prompt-builder.js +16 -6
- package/dist/services/runtime-settings-context.d.ts +81 -0
- package/dist/services/runtime-settings-context.js +79 -0
- package/dist/skills/executor.js +2 -0
- package/dist/skills/hub.js +16 -14
- package/dist/skills/local-inventory.d.ts +21 -0
- package/dist/skills/local-inventory.js +72 -0
- package/dist/skills/skill-loader.js +2 -2
- package/dist/skills/skill-usage-store.d.ts +49 -0
- package/dist/skills/skill-usage-store.js +121 -0
- package/dist/testing/ai-integration-tests.js +8 -5
- package/dist/themes/theme-manager.d.ts +12 -0
- package/dist/themes/theme-manager.js +29 -0
- package/dist/themes/theme-schema.d.ts +24 -24
- package/dist/tools/a2a-call-tool.d.ts +34 -0
- package/dist/tools/a2a-call-tool.js +75 -0
- package/dist/tools/bash/streaming-executor.d.ts +1 -0
- package/dist/tools/bash/streaming-executor.js +78 -90
- package/dist/tools/code-exec-preflight-runner.d.ts +41 -0
- package/dist/tools/code-exec-preflight-runner.js +254 -0
- package/dist/tools/code-exec-preflight.d.ts +44 -0
- package/dist/tools/code-exec-preflight.js +501 -0
- package/dist/tools/code-exec-tool.d.ts +48 -1
- package/dist/tools/code-exec-tool.js +191 -47
- package/dist/tools/comment-watcher.js +29 -12
- package/dist/tools/core-code-inspection.d.ts +56 -0
- package/dist/tools/core-code-inspection.js +86 -0
- package/dist/tools/create-skill-tool.d.ts +2 -3
- package/dist/tools/create-skill-tool.js +16 -75
- package/dist/tools/cronjob-tool.d.ts +1 -0
- package/dist/tools/cronjob-tool.js +1 -0
- package/dist/tools/env-doctor-tool.d.ts +2 -0
- package/dist/tools/env-doctor-tool.js +4 -3
- package/dist/tools/execute-code-rpc-invoker.d.ts +1 -1
- package/dist/tools/execute-code-rpc-invoker.js +35 -19
- package/dist/tools/execute-code-runner.d.ts +2 -0
- package/dist/tools/execute-code-runner.js +52 -17
- package/dist/tools/fleet-room-tool.d.ts +104 -0
- package/dist/tools/fleet-room-tool.js +124 -0
- package/dist/tools/integration-tool-hints.d.ts +4 -0
- package/dist/tools/integration-tool-hints.js +19 -0
- package/dist/tools/list-peers-tool.d.ts +3 -0
- package/dist/tools/list-peers-tool.js +11 -4
- package/dist/tools/media-generation-tool.d.ts +16 -1
- package/dist/tools/media-generation-tool.js +341 -9
- package/dist/tools/merge-conflict-tool.js +53 -25
- package/dist/tools/metadata.d.ts +1 -5
- package/dist/tools/metadata.js +30 -28
- package/dist/tools/peer-tool-invoke-tool.d.ts +61 -0
- package/dist/tools/peer-tool-invoke-tool.js +396 -0
- package/dist/tools/ragchat-tool.d.ts +39 -0
- package/dist/tools/ragchat-tool.js +105 -0
- package/dist/tools/registry/fleet-tools.d.ts +21 -3
- package/dist/tools/registry/fleet-tools.js +137 -4
- package/dist/tools/registry/index.d.ts +1 -1
- package/dist/tools/registry/index.js +2 -2
- package/dist/tools/registry/knowledge-tools.d.ts +2 -2
- package/dist/tools/registry/knowledge-tools.js +2 -2
- package/dist/tools/registry/lessons-tools.d.ts +7 -0
- package/dist/tools/registry/lessons-tools.js +43 -3
- package/dist/tools/registry/memory-tools.d.ts +1 -1
- package/dist/tools/registry/memory-tools.js +8 -8
- package/dist/tools/registry/research-tools.d.ts +1 -0
- package/dist/tools/registry/research-tools.js +4 -13
- package/dist/tools/registry/self-describe-tools.d.ts +1 -1
- package/dist/tools/registry/self-describe-tools.js +43 -30
- package/dist/tools/resource-catalog-tool.d.ts +38 -0
- package/dist/tools/resource-catalog-tool.js +46 -0
- package/dist/tools/skills-inspection-tool.js +30 -1
- package/dist/tools/stream-tool-output.d.ts +3 -0
- package/dist/tools/stream-tool-output.js +33 -0
- package/dist/tools/tool-call-scheduler.d.ts +10 -0
- package/dist/tools/tool-call-scheduler.js +58 -0
- package/dist/tools/tool-effect.d.ts +5 -0
- package/dist/tools/tool-effect.js +26 -0
- package/dist/tools/tool-search.d.ts +12 -11
- package/dist/tools/tool-search.js +67 -26
- package/dist/tools/types.d.ts +6 -0
- package/dist/ui/components/ChatHistory.d.ts +1 -1
- package/dist/ui/components/ChatHistory.js +2 -2
- package/dist/ui/components/ChatInput.d.ts +2 -1
- package/dist/ui/components/ChatInput.js +42 -88
- package/dist/ui/components/ChatInterface.d.ts +4 -2
- package/dist/ui/components/ChatInterface.js +27 -63
- package/dist/ui/components/CommandSuggestions.d.ts +0 -1
- package/dist/ui/components/CommandSuggestions.js +4 -6
- package/dist/ui/components/FileAutocomplete.js +1 -1
- package/dist/ui/components/KeyboardHelp.js +8 -6
- package/dist/ui/components/ModelSelection.js +6 -5
- package/dist/ui/components/StatusBar.d.ts +2 -1
- package/dist/ui/components/StatusBar.js +8 -7
- package/dist/ui/context/theme-context.js +3 -2
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/ui/utils/markdown-renderer.js +4 -13
- package/dist/utils/atomic-write.d.ts +22 -0
- package/dist/utils/atomic-write.js +29 -0
- package/dist/utils/bounded-output.d.ts +16 -0
- package/dist/utils/bounded-output.js +63 -0
- package/dist/utils/config-validation/schema.d.ts +2 -2
- package/dist/utils/device-store-file.d.ts +4 -0
- package/dist/utils/device-store-file.js +40 -0
- package/dist/utils/export-manager.d.ts +9 -0
- package/dist/utils/export-manager.js +19 -0
- package/dist/utils/first-use-hints.d.ts +25 -0
- package/dist/utils/first-use-hints.js +58 -0
- package/dist/utils/graceful-shutdown.d.ts +8 -0
- package/dist/utils/graceful-shutdown.js +23 -7
- package/dist/utils/history-manager.js +1 -1
- package/dist/utils/update-notifier.js +16 -18
- package/dist/wizard/environment-detection.d.ts +5 -1
- package/dist/wizard/environment-detection.js +49 -7
- package/dist/wizard/onboarding.d.ts +5 -1
- package/dist/wizard/onboarding.js +90 -30
- package/dist/wizard/provider-onboarding.d.ts +2 -0
- package/dist/wizard/provider-onboarding.js +55 -17
- package/package.json +7 -3
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-surface availability of slash commands (comparatif plan P4).
|
|
3
|
+
*
|
|
4
|
+
* Single declaration read by the CLI catalog, the Cowork main process (which
|
|
5
|
+
* derives its headless allowlist from it) and the generated slash wiki.
|
|
6
|
+
*
|
|
7
|
+
* Rules:
|
|
8
|
+
* - CLI: every built-in is available unless a command declares otherwise.
|
|
9
|
+
* - Cowork, DEFAULT-DENY for engine tokens (`__FOO__` prompts): a token is only
|
|
10
|
+
* pilotable from Cowork when it is declared below either as `headless` (runs
|
|
11
|
+
* through `executeHeadlessSlashToken` with this allowlist) or `ui_effect`
|
|
12
|
+
* (Cowork renders a native panel/effect). Undeclared tokens are unavailable
|
|
13
|
+
* with an explicit reason. Natural-language prompt commands are forwarded as
|
|
14
|
+
* prompts and are therefore available.
|
|
15
|
+
* - A command-level `surfaces` declaration can only RESTRICT a surface (hidden
|
|
16
|
+
* or unavailable); it never widens the Cowork token allowlist.
|
|
17
|
+
*/
|
|
18
|
+
import type { SlashAvailability, SlashCommand, SlashSurface } from './types.js';
|
|
19
|
+
export type CoworkTokenMode = 'headless' | 'ui_effect';
|
|
20
|
+
/**
|
|
21
|
+
* Tokens Cowork can pilot. `headless` entries are safe to run from the Cowork
|
|
22
|
+
* main process today (read-only info or session-scoped goal state); see the
|
|
23
|
+
* rationale kept in cowork/src/main/commands/slash-command-bridge.ts.
|
|
24
|
+
*/
|
|
25
|
+
export declare const COWORK_TOKEN_SURFACES: Readonly<Record<string, CoworkTokenMode>>;
|
|
26
|
+
/**
|
|
27
|
+
* Bot commands expected on each messaging platform (the `channels` surface).
|
|
28
|
+
* This is the single declaration read by `src/channels/slash-parity.ts`.
|
|
29
|
+
* A name that matches a builtin is the same command reached from a chat
|
|
30
|
+
* platform; `channelOnly` marks bot-only commands with no terminal builtin.
|
|
31
|
+
*/
|
|
32
|
+
export interface ChannelSlashSpec {
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
required?: boolean;
|
|
36
|
+
channelOnly?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare const CHANNEL_SLASH_SURFACES: Readonly<Record<string, readonly ChannelSlashSpec[]>>;
|
|
39
|
+
/** Platforms whose bot exposes this command; a `channels` restriction on the command removes it everywhere. */
|
|
40
|
+
export declare function channelPlatformsFor(command: Pick<SlashCommand, 'name' | 'surfaces'>): string[];
|
|
41
|
+
export declare const COWORK_UNAVAILABLE_REASON = "not pilotable from Cowork yet \u2014 use the terminal (buddy)";
|
|
42
|
+
export declare function isEngineToken(prompt: string): boolean;
|
|
43
|
+
/** Tokens the Cowork main process may run headlessly (derived, never hand-maintained elsewhere). */
|
|
44
|
+
export declare function coworkHeadlessAllowlist(): ReadonlySet<string>;
|
|
45
|
+
export declare function coworkUiEffectTokens(): ReadonlySet<string>;
|
|
46
|
+
/** Effective availability of one catalog command on one surface. */
|
|
47
|
+
export declare function resolveSlashAvailability(command: Pick<SlashCommand, 'name' | 'prompt' | 'surfaces'>, surface: SlashSurface): SlashAvailability;
|
|
48
|
+
export interface SlashCommandWithAvailability extends SlashCommand {
|
|
49
|
+
availability: Record<'cli' | 'cowork', SlashAvailability>;
|
|
50
|
+
/** Messaging platforms whose bot exposes the same command (from CHANNEL_SLASH_SURFACES). */
|
|
51
|
+
channelPlatforms: string[];
|
|
52
|
+
}
|
|
53
|
+
export declare function withAvailability(commands: readonly SlashCommand[]): SlashCommandWithAvailability[];
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-surface availability of slash commands (comparatif plan P4).
|
|
3
|
+
*
|
|
4
|
+
* Single declaration read by the CLI catalog, the Cowork main process (which
|
|
5
|
+
* derives its headless allowlist from it) and the generated slash wiki.
|
|
6
|
+
*
|
|
7
|
+
* Rules:
|
|
8
|
+
* - CLI: every built-in is available unless a command declares otherwise.
|
|
9
|
+
* - Cowork, DEFAULT-DENY for engine tokens (`__FOO__` prompts): a token is only
|
|
10
|
+
* pilotable from Cowork when it is declared below either as `headless` (runs
|
|
11
|
+
* through `executeHeadlessSlashToken` with this allowlist) or `ui_effect`
|
|
12
|
+
* (Cowork renders a native panel/effect). Undeclared tokens are unavailable
|
|
13
|
+
* with an explicit reason. Natural-language prompt commands are forwarded as
|
|
14
|
+
* prompts and are therefore available.
|
|
15
|
+
* - A command-level `surfaces` declaration can only RESTRICT a surface (hidden
|
|
16
|
+
* or unavailable); it never widens the Cowork token allowlist.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Tokens Cowork can pilot. `headless` entries are safe to run from the Cowork
|
|
20
|
+
* main process today (read-only info or session-scoped goal state); see the
|
|
21
|
+
* rationale kept in cowork/src/main/commands/slash-command-bridge.ts.
|
|
22
|
+
*/
|
|
23
|
+
export const COWORK_TOKEN_SURFACES = Object.freeze({
|
|
24
|
+
// Headless (engine behaviour, default-deny allowlist)
|
|
25
|
+
__HELP__: 'headless',
|
|
26
|
+
__STATS__: 'headless',
|
|
27
|
+
__COST__: 'headless',
|
|
28
|
+
__TOOLS__: 'headless',
|
|
29
|
+
__WHOAMI__: 'headless',
|
|
30
|
+
__STATUS__: 'headless',
|
|
31
|
+
__FEATURES__: 'headless',
|
|
32
|
+
__HISTORY__: 'headless',
|
|
33
|
+
__LOG__: 'headless',
|
|
34
|
+
__WORKSPACE__: 'headless',
|
|
35
|
+
__DIFF__: 'headless',
|
|
36
|
+
__QUOTA__: 'headless',
|
|
37
|
+
__EXPORT_FORMATS__: 'headless',
|
|
38
|
+
__EXPORT_LIST__: 'headless',
|
|
39
|
+
__GOAL__: 'headless',
|
|
40
|
+
__SUBGOAL__: 'headless',
|
|
41
|
+
__RESOURCES__: 'headless',
|
|
42
|
+
// Native Cowork effects (panels, settings tabs, orchestrator, engine actions)
|
|
43
|
+
__CHANGE_MODEL__: 'ui_effect',
|
|
44
|
+
__SWITCH__: 'ui_effect',
|
|
45
|
+
__PLAN_MODE__: 'ui_effect',
|
|
46
|
+
__SWARM__: 'ui_effect',
|
|
47
|
+
__PARALLEL__: 'ui_effect',
|
|
48
|
+
__BATCH__: 'ui_effect',
|
|
49
|
+
__AGENTS__: 'ui_effect',
|
|
50
|
+
__FLEET__: 'ui_effect',
|
|
51
|
+
__TEAM__: 'ui_effect',
|
|
52
|
+
__LESSONS__: 'ui_effect',
|
|
53
|
+
__COMPANION__: 'ui_effect',
|
|
54
|
+
__TRACK__: 'ui_effect',
|
|
55
|
+
__CONFIG__: 'ui_effect',
|
|
56
|
+
__WORKFLOW__: 'ui_effect',
|
|
57
|
+
__PIPELINE__: 'ui_effect',
|
|
58
|
+
__PERMISSIONS__: 'ui_effect',
|
|
59
|
+
__POLICY__: 'ui_effect',
|
|
60
|
+
__APPROVALS__: 'ui_effect',
|
|
61
|
+
__ELEVATED__: 'ui_effect',
|
|
62
|
+
__BATCH_REVIEW__: 'ui_effect',
|
|
63
|
+
__SECURITY__: 'ui_effect',
|
|
64
|
+
__HOOKS__: 'ui_effect',
|
|
65
|
+
__PLUGINS__: 'ui_effect',
|
|
66
|
+
__PLUGIN__: 'ui_effect',
|
|
67
|
+
__THEME__: 'ui_effect',
|
|
68
|
+
__AVATAR__: 'ui_effect',
|
|
69
|
+
__VIM_MODE__: 'ui_effect',
|
|
70
|
+
__FAST_MODE__: 'ui_effect',
|
|
71
|
+
__DRY_RUN__: 'ui_effect',
|
|
72
|
+
__CACHE__: 'ui_effect',
|
|
73
|
+
__PROMPT_CACHE__: 'ui_effect',
|
|
74
|
+
__SELF_HEALING__: 'ui_effect',
|
|
75
|
+
__SEARCH__: 'ui_effect',
|
|
76
|
+
__SHORTCUTS__: 'ui_effect',
|
|
77
|
+
__PERSONA__: 'ui_effect',
|
|
78
|
+
__SESSIONS__: 'ui_effect',
|
|
79
|
+
__REMEMBER__: 'ui_effect',
|
|
80
|
+
__IDENTITY__: 'ui_effect',
|
|
81
|
+
__PAIRING__: 'ui_effect',
|
|
82
|
+
__VOICE__: 'ui_effect',
|
|
83
|
+
__SPEAK__: 'ui_effect',
|
|
84
|
+
__TTS__: 'ui_effect',
|
|
85
|
+
__EXPORT__: 'ui_effect',
|
|
86
|
+
__SAVE_CONVERSATION__: 'ui_effect',
|
|
87
|
+
__TEST__: 'ui_effect',
|
|
88
|
+
__THINK__: 'ui_effect',
|
|
89
|
+
__KNOWLEDGE_GRAPH__: 'ui_effect',
|
|
90
|
+
__UNDO__: 'ui_effect',
|
|
91
|
+
__REDO__: 'ui_effect',
|
|
92
|
+
__SUBAGENT__: 'ui_effect',
|
|
93
|
+
__AGENT__: 'ui_effect',
|
|
94
|
+
});
|
|
95
|
+
export const CHANNEL_SLASH_SURFACES = Object.freeze({
|
|
96
|
+
discord: [
|
|
97
|
+
{ name: 'ask', description: 'Ask Code Buddy a question', channelOnly: true },
|
|
98
|
+
{ name: 'status', description: 'Show bot and channel status' },
|
|
99
|
+
{ name: 'clear', description: 'Clear conversation history' },
|
|
100
|
+
{ name: 'help', description: 'Show available commands' },
|
|
101
|
+
{ name: 'model', description: 'Switch or show current model' },
|
|
102
|
+
{ name: 'think', description: 'Set reasoning depth', required: false },
|
|
103
|
+
{ name: 'compact', description: 'Compact conversation context', required: false },
|
|
104
|
+
{ name: 'repo', description: 'Show repository info', required: false, channelOnly: true },
|
|
105
|
+
],
|
|
106
|
+
telegram: [
|
|
107
|
+
{ name: 'ask', description: 'Ask Code Buddy a question', channelOnly: true },
|
|
108
|
+
{ name: 'status', description: 'Show bot and channel status' },
|
|
109
|
+
{ name: 'clear', description: 'Clear conversation history' },
|
|
110
|
+
{ name: 'help', description: 'Show available commands' },
|
|
111
|
+
{ name: 'model', description: 'Switch or show current model' },
|
|
112
|
+
{ name: 'yolo', description: 'Toggle YOLO mode', required: false },
|
|
113
|
+
{ name: 'repo', description: 'Show repository info', required: false, channelOnly: true },
|
|
114
|
+
{ name: 'branch', description: 'Show branch info', required: false },
|
|
115
|
+
],
|
|
116
|
+
slack: [
|
|
117
|
+
{ name: 'ask', description: 'Ask Code Buddy a question', channelOnly: true },
|
|
118
|
+
{ name: 'status', description: 'Show bot and channel status' },
|
|
119
|
+
{ name: 'clear', description: 'Clear conversation history' },
|
|
120
|
+
{ name: 'help', description: 'Show available commands' },
|
|
121
|
+
{ name: 'model', description: 'Switch or show current model' },
|
|
122
|
+
{ name: 'compact', description: 'Compact conversation context', required: false },
|
|
123
|
+
{ name: 'think', description: 'Set reasoning depth', required: false },
|
|
124
|
+
],
|
|
125
|
+
matrix: [
|
|
126
|
+
{ name: 'ask', description: 'Ask Code Buddy a question', channelOnly: true },
|
|
127
|
+
{ name: 'status', description: 'Show bot and channel status' },
|
|
128
|
+
{ name: 'clear', description: 'Clear conversation history' },
|
|
129
|
+
{ name: 'help', description: 'Show available commands' },
|
|
130
|
+
{ name: 'model', description: 'Switch or show current model', required: false },
|
|
131
|
+
],
|
|
132
|
+
});
|
|
133
|
+
/** Platforms whose bot exposes this command; a `channels` restriction on the command removes it everywhere. */
|
|
134
|
+
export function channelPlatformsFor(command) {
|
|
135
|
+
const declared = command.surfaces?.channels;
|
|
136
|
+
if (declared && declared.status !== 'available')
|
|
137
|
+
return [];
|
|
138
|
+
return Object.entries(CHANNEL_SLASH_SURFACES)
|
|
139
|
+
.filter(([, specs]) => specs.some((spec) => !spec.channelOnly && spec.name === command.name))
|
|
140
|
+
.map(([platform]) => platform);
|
|
141
|
+
}
|
|
142
|
+
export const COWORK_UNAVAILABLE_REASON = 'not pilotable from Cowork yet — use the terminal (buddy)';
|
|
143
|
+
export function isEngineToken(prompt) {
|
|
144
|
+
return prompt.length > 4 && prompt.startsWith('__') && prompt.endsWith('__');
|
|
145
|
+
}
|
|
146
|
+
/** Tokens the Cowork main process may run headlessly (derived, never hand-maintained elsewhere). */
|
|
147
|
+
export function coworkHeadlessAllowlist() {
|
|
148
|
+
return new Set(Object.entries(COWORK_TOKEN_SURFACES).filter(([, mode]) => mode === 'headless').map(([token]) => token));
|
|
149
|
+
}
|
|
150
|
+
export function coworkUiEffectTokens() {
|
|
151
|
+
return new Set(Object.entries(COWORK_TOKEN_SURFACES).filter(([, mode]) => mode === 'ui_effect').map(([token]) => token));
|
|
152
|
+
}
|
|
153
|
+
const AVAILABLE = { status: 'available' };
|
|
154
|
+
/** Effective availability of one catalog command on one surface. */
|
|
155
|
+
export function resolveSlashAvailability(command, surface) {
|
|
156
|
+
const declared = command.surfaces?.[surface];
|
|
157
|
+
const restricting = declared && declared.status !== 'available' ? declared : undefined;
|
|
158
|
+
if (surface === 'cowork') {
|
|
159
|
+
if (restricting)
|
|
160
|
+
return restricting;
|
|
161
|
+
if (!isEngineToken(command.prompt))
|
|
162
|
+
return AVAILABLE;
|
|
163
|
+
return COWORK_TOKEN_SURFACES[command.prompt] ? AVAILABLE : { status: 'unavailable', reason: COWORK_UNAVAILABLE_REASON };
|
|
164
|
+
}
|
|
165
|
+
return declared ?? AVAILABLE;
|
|
166
|
+
}
|
|
167
|
+
export function withAvailability(commands) {
|
|
168
|
+
return commands.map((command) => ({
|
|
169
|
+
...command,
|
|
170
|
+
availability: {
|
|
171
|
+
cli: resolveSlashAvailability(command, 'cli'),
|
|
172
|
+
cowork: resolveSlashAvailability(command, 'cowork'),
|
|
173
|
+
},
|
|
174
|
+
channelPlatforms: channelPlatformsFor(command),
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=surfaces.js.map
|
|
@@ -32,7 +32,24 @@ export interface SlashCommand {
|
|
|
32
32
|
isBuiltin: boolean;
|
|
33
33
|
/** List of arguments accepted by the command. */
|
|
34
34
|
arguments?: SlashCommandArgument[];
|
|
35
|
+
/**
|
|
36
|
+
* Optional per-surface restriction (P4). Resolution lives in `surfaces.ts`;
|
|
37
|
+
* a declaration can hide or disable a command on a surface, never widen the
|
|
38
|
+
* Cowork default-deny token allowlist.
|
|
39
|
+
*/
|
|
40
|
+
surfaces?: Partial<Record<SlashSurface, SlashAvailability>>;
|
|
35
41
|
}
|
|
42
|
+
/** Surfaces that expose slash commands. */
|
|
43
|
+
export type SlashSurface = 'cli' | 'cowork' | 'channels';
|
|
44
|
+
/** Availability of a command on a surface. */
|
|
45
|
+
export type SlashAvailability = {
|
|
46
|
+
status: 'available';
|
|
47
|
+
} | {
|
|
48
|
+
status: 'hidden';
|
|
49
|
+
} | {
|
|
50
|
+
status: 'unavailable';
|
|
51
|
+
reason: string;
|
|
52
|
+
};
|
|
36
53
|
/**
|
|
37
54
|
* Result of executing or parsing a slash command.
|
|
38
55
|
*/
|
package/dist/commands/try.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export interface RunTryDemoOptions extends ResolveTryProviderOptions {
|
|
|
54
54
|
export interface TryCommandDependencies {
|
|
55
55
|
runTryDemo?: (options: RunTryDemoOptions) => Promise<number>;
|
|
56
56
|
}
|
|
57
|
-
export declare const TRY_DEMO_PROMPT = "You are driving a short coding-agent demo in an empty temporary folder.\n\nExact goal:\n1. Create fizzbuzz.js in CommonJS. Export a function fizzBuzz(value) that returns the number as a string, \"Fizz\" for multiples of 3, \"Buzz\" for multiples of 5, and \"FizzBuzz\" for multiples of 15.\n2. Create fizzbuzz.test.js using node:test and node:assert/strict. Test at least 1, 3, 5, and 15.\n3. Run exactly: node --test fizzbuzz.test.js\n4. If a test fails, fix the code and run it again.\n5. Finish with a very short summary naming the two files you created and the test result.\n\nWrite everything in English. Use the file and terminal tools
|
|
57
|
+
export declare const TRY_DEMO_PROMPT = "You are driving a short coding-agent demo in an empty temporary folder.\n\nExact goal:\n1. Create fizzbuzz.js in CommonJS. Export a function fizzBuzz(value) that returns the number as a string, \"Fizz\" for multiples of 3, \"Buzz\" for multiples of 5, and \"FizzBuzz\" for multiples of 15.\n2. Create fizzbuzz.test.js using node:test and node:assert/strict. Test at least 1, 3, 5, and 15.\n3. Run exactly: node --test fizzbuzz.test.js\n4. If a test fails, fix the code and run it again.\n5. Finish with a very short summary naming the two files you created and the test result.\n\nWrite everything in English. Use the file and terminal tools with the configured permissions. Work only inside the temporary folder; no dependency installation is needed.";
|
|
58
58
|
export declare const NO_TRY_PROVIDER_MESSAGE: string;
|
|
59
59
|
/** Pick a coding-oriented local model without assuming one exact Ollama tag. */
|
|
60
60
|
export declare function chooseOllamaModel(models: readonly string[], requested?: string): string | null;
|
package/dist/commands/try.js
CHANGED
|
@@ -24,7 +24,7 @@ Exact goal:
|
|
|
24
24
|
4. If a test fails, fix the code and run it again.
|
|
25
25
|
5. Finish with a very short summary naming the two files you created and the test result.
|
|
26
26
|
|
|
27
|
-
Write everything in English. Use the file and terminal tools
|
|
27
|
+
Write everything in English. Use the file and terminal tools with the configured permissions. Work only inside the temporary folder; no dependency installation is needed.`;
|
|
28
28
|
export const NO_TRY_PROVIDER_MESSAGE = [
|
|
29
29
|
'No free provider is ready for the demo.',
|
|
30
30
|
'',
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Companion identity resolution.
|
|
3
|
+
*
|
|
4
|
+
* Resolves who is speaking to Lisa across Telegram, PWA mobile WebSocket,
|
|
5
|
+
* and physical voice presence, and assigns a trust level:
|
|
6
|
+
* - 'owner': Full trust. Identified via Telegram allowlist/chat or PWA JWT.
|
|
7
|
+
* - 'present': Physical presence detected and robot named. Lower trust.
|
|
8
|
+
* - 'guest': Unknown / unauthenticated speaker. Fail-closed: ZERO tools.
|
|
9
|
+
*
|
|
10
|
+
* @module companion/companion-identity
|
|
11
|
+
*/
|
|
12
|
+
export type CompanionIdentityRole = 'owner' | 'present' | 'guest';
|
|
13
|
+
export type CompanionIdentityConfidence = 'high' | 'medium' | 'none';
|
|
14
|
+
export interface CompanionIdentity {
|
|
15
|
+
role: CompanionIdentityRole;
|
|
16
|
+
channel: 'telegram' | 'pwa' | 'voice' | 'channel' | 'unknown';
|
|
17
|
+
userId?: string;
|
|
18
|
+
chatId?: string;
|
|
19
|
+
confidence: CompanionIdentityConfidence;
|
|
20
|
+
reason: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ResolveIdentityOptions {
|
|
23
|
+
channel: 'telegram' | 'pwa' | 'mobile' | 'voice' | 'channel' | string;
|
|
24
|
+
userId?: string;
|
|
25
|
+
chatId?: string;
|
|
26
|
+
senderId?: string;
|
|
27
|
+
senderUsername?: string;
|
|
28
|
+
allowedUsers?: readonly string[];
|
|
29
|
+
isVoicePresence?: boolean;
|
|
30
|
+
robotNamed?: boolean;
|
|
31
|
+
env?: NodeJS.ProcessEnv;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resolve identity and confidence tier from incoming channel information.
|
|
35
|
+
* Pure function: takes options and env, zero global side-effects.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveCompanionIdentity(options: ResolveIdentityOptions): CompanionIdentity;
|
|
38
|
+
/** Check if identity is owner */
|
|
39
|
+
export declare function isCompanionOwner(identity?: CompanionIdentity | null): boolean;
|
|
40
|
+
/** Check if identity is at least present (owner or present) */
|
|
41
|
+
export declare function isCompanionPresentOrOwner(identity?: CompanionIdentity | null): boolean;
|
|
42
|
+
/** Default guest identity (fail-closed) */
|
|
43
|
+
export declare const DEFAULT_GUEST_IDENTITY: CompanionIdentity;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Companion identity resolution.
|
|
3
|
+
*
|
|
4
|
+
* Resolves who is speaking to Lisa across Telegram, PWA mobile WebSocket,
|
|
5
|
+
* and physical voice presence, and assigns a trust level:
|
|
6
|
+
* - 'owner': Full trust. Identified via Telegram allowlist/chat or PWA JWT.
|
|
7
|
+
* - 'present': Physical presence detected and robot named. Lower trust.
|
|
8
|
+
* - 'guest': Unknown / unauthenticated speaker. Fail-closed: ZERO tools.
|
|
9
|
+
*
|
|
10
|
+
* @module companion/companion-identity
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Resolve identity and confidence tier from incoming channel information.
|
|
14
|
+
* Pure function: takes options and env, zero global side-effects.
|
|
15
|
+
*/
|
|
16
|
+
export function resolveCompanionIdentity(options) {
|
|
17
|
+
const env = options.env ?? process.env;
|
|
18
|
+
const channelRaw = (options.channel || '').toLowerCase().trim();
|
|
19
|
+
// 1. Telegram
|
|
20
|
+
if (channelRaw === 'telegram') {
|
|
21
|
+
const alertChat = (env.CODEBUDDY_SENSORY_ALERT_CHAT ?? '').trim();
|
|
22
|
+
const allowed = new Set((options.allowedUsers ?? []).map((u) => u.trim().toLowerCase()));
|
|
23
|
+
const chatId = (options.chatId ?? '').trim();
|
|
24
|
+
const senderId = (options.senderId ?? options.userId ?? '').trim();
|
|
25
|
+
const rawUsername = (options.senderUsername ?? '').trim().toLowerCase();
|
|
26
|
+
const senderUsername = rawUsername.replace(/^@/, '');
|
|
27
|
+
const isChatAlertMatch = Boolean(alertChat && chatId && chatId === alertChat);
|
|
28
|
+
const isChatAllowedMatch = Boolean(chatId && allowed.has(chatId.toLowerCase()));
|
|
29
|
+
const isSenderIdMatch = Boolean(senderId && allowed.has(senderId.toLowerCase()));
|
|
30
|
+
const isUsernameMatch = Boolean(senderUsername && (allowed.has(senderUsername) || allowed.has(`@${senderUsername}`)));
|
|
31
|
+
if (isChatAlertMatch || isChatAllowedMatch || isSenderIdMatch || isUsernameMatch) {
|
|
32
|
+
return {
|
|
33
|
+
role: 'owner',
|
|
34
|
+
channel: 'telegram',
|
|
35
|
+
...(senderId ? { userId: senderId } : {}),
|
|
36
|
+
...(chatId ? { chatId } : {}),
|
|
37
|
+
confidence: 'high',
|
|
38
|
+
reason: isChatAlertMatch
|
|
39
|
+
? 'telegram_sensory_alert_chat_match'
|
|
40
|
+
: isChatAllowedMatch
|
|
41
|
+
? 'telegram_chat_id_allowed'
|
|
42
|
+
: isSenderIdMatch
|
|
43
|
+
? 'telegram_sender_id_allowed'
|
|
44
|
+
: 'telegram_username_allowed',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
role: 'guest',
|
|
49
|
+
channel: 'telegram',
|
|
50
|
+
...(chatId ? { chatId } : {}),
|
|
51
|
+
confidence: 'none',
|
|
52
|
+
reason: 'telegram_unauthorized_sender',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// 2. PWA (Mobile / Web)
|
|
56
|
+
if (channelRaw === 'pwa' || channelRaw === 'mobile') {
|
|
57
|
+
const userId = (options.userId ?? options.senderId ?? '').trim();
|
|
58
|
+
if (!userId) {
|
|
59
|
+
return {
|
|
60
|
+
role: 'guest',
|
|
61
|
+
channel: 'pwa',
|
|
62
|
+
confidence: 'none',
|
|
63
|
+
reason: 'pwa_missing_jwt_user_id',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const ownerUserId = (env.CODEBUDDY_OWNER_USER_ID ?? '').trim();
|
|
67
|
+
if (ownerUserId) {
|
|
68
|
+
if (userId === ownerUserId) {
|
|
69
|
+
return {
|
|
70
|
+
role: 'owner',
|
|
71
|
+
channel: 'pwa',
|
|
72
|
+
userId,
|
|
73
|
+
confidence: 'high',
|
|
74
|
+
reason: 'pwa_jwt_owner_matched',
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
role: 'guest',
|
|
79
|
+
channel: 'pwa',
|
|
80
|
+
userId,
|
|
81
|
+
confidence: 'none',
|
|
82
|
+
reason: 'pwa_jwt_user_not_owner',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// Default when CODEBUDDY_OWNER_USER_ID is not set:
|
|
86
|
+
// Any valid JWT issued and verified by this daemon is recognized as owner.
|
|
87
|
+
// In a single-user self-hosted installation, only the owner holds the login credentials.
|
|
88
|
+
return {
|
|
89
|
+
role: 'owner',
|
|
90
|
+
channel: 'pwa',
|
|
91
|
+
userId,
|
|
92
|
+
confidence: 'high',
|
|
93
|
+
reason: 'pwa_jwt_valid_server_token_default_owner',
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// 3. Voice
|
|
97
|
+
if (channelRaw === 'voice') {
|
|
98
|
+
if (options.isVoicePresence === true && options.robotNamed === true) {
|
|
99
|
+
return {
|
|
100
|
+
role: 'present',
|
|
101
|
+
channel: 'voice',
|
|
102
|
+
confidence: 'medium',
|
|
103
|
+
reason: 'voice_presence_and_robot_named',
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
role: 'guest',
|
|
108
|
+
channel: 'voice',
|
|
109
|
+
confidence: 'none',
|
|
110
|
+
reason: 'voice_unauthenticated_or_unnamed',
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
// 4. Default / unknown channel -> fail closed
|
|
114
|
+
return {
|
|
115
|
+
role: 'guest',
|
|
116
|
+
channel: 'unknown',
|
|
117
|
+
confidence: 'none',
|
|
118
|
+
reason: 'unknown_channel_fail_closed',
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/** Check if identity is owner */
|
|
122
|
+
export function isCompanionOwner(identity) {
|
|
123
|
+
return identity?.role === 'owner';
|
|
124
|
+
}
|
|
125
|
+
/** Check if identity is at least present (owner or present) */
|
|
126
|
+
export function isCompanionPresentOrOwner(identity) {
|
|
127
|
+
return identity?.role === 'owner' || identity?.role === 'present';
|
|
128
|
+
}
|
|
129
|
+
/** Default guest identity (fail-closed) */
|
|
130
|
+
export const DEFAULT_GUEST_IDENTITY = Object.freeze({
|
|
131
|
+
role: 'guest',
|
|
132
|
+
channel: 'unknown',
|
|
133
|
+
confidence: 'none',
|
|
134
|
+
reason: 'default_guest_fail_closed',
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=companion-identity.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Companion Toolset definition, authorization and execution gates.
|
|
3
|
+
*
|
|
4
|
+
* Defines which tools Lisa can use based on the interlocutor's identity tier:
|
|
5
|
+
* - 'owner': image_generate, image_edit, remind, web_search, weather, stock_quote,
|
|
6
|
+
* understand_video, camera_analyze, recall.
|
|
7
|
+
* - 'present': same tools WITHOUT remind and WITHOUT camera (camera_analyze).
|
|
8
|
+
* - 'guest': NO tools (fail-closed, byte-identical to historical turn).
|
|
9
|
+
*
|
|
10
|
+
* Hard security invariants:
|
|
11
|
+
* - NEVER bash, shell_exec, file writing (create_file, edit, patch), MCP, fleet tools.
|
|
12
|
+
* - Circuit-breaker: CODEBUDDY_COMPANION_TOOLS_ENABLED (default: false -> 0 tools).
|
|
13
|
+
* - Surcharge: CODEBUDDY_COMPANION_TOOLS (csv list, filtered against hard constraints).
|
|
14
|
+
*
|
|
15
|
+
* @module companion/companion-toolset
|
|
16
|
+
*/
|
|
17
|
+
import type { CodeBuddyTool } from '../codebuddy/client.js';
|
|
18
|
+
import type { ToolResult } from '../types/index.js';
|
|
19
|
+
import { ConfirmationService } from '../utils/confirmation-service.js';
|
|
20
|
+
import { FormalToolRegistry } from '../tools/registry/tool-registry.js';
|
|
21
|
+
import type { CompanionIdentity } from './companion-identity.js';
|
|
22
|
+
export declare const OWNER_COMPANION_TOOLS: readonly string[];
|
|
23
|
+
export declare const PRESENT_COMPANION_TOOLS: readonly string[];
|
|
24
|
+
export declare const GUEST_COMPANION_TOOLS: readonly string[];
|
|
25
|
+
/** Strictly forbidden tool patterns that can NEVER be exposed to companion */
|
|
26
|
+
export declare const COMPANION_FORBIDDEN_PATTERNS: readonly (string | RegExp)[];
|
|
27
|
+
/**
|
|
28
|
+
* Check if a tool is strictly forbidden for the companion.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isForbiddenCompanionTool(toolName: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Check if companion tools are enabled via circuit-breaker.
|
|
33
|
+
* Default is FALSE (OFF).
|
|
34
|
+
*/
|
|
35
|
+
export declare function isCompanionToolsEnabled(env?: NodeJS.ProcessEnv): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Resolve allowed tool names for a given identity and environment.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getCompanionToolNames(identity: CompanionIdentity, env?: NodeJS.ProcessEnv): string[];
|
|
40
|
+
/**
|
|
41
|
+
* Human-friendly waiting phrase when a slow tool starts executing.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getCompanionToolWaitingWord(toolName: string): string | null;
|
|
44
|
+
/**
|
|
45
|
+
* Get OpenAI-compatible function tool definitions for allowed companion tools.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getCompanionToolDefinitions(identity: CompanionIdentity, options?: {
|
|
48
|
+
env?: NodeJS.ProcessEnv;
|
|
49
|
+
registry?: FormalToolRegistry;
|
|
50
|
+
}): Promise<CodeBuddyTool[]>;
|
|
51
|
+
export interface CompanionToolExecutionContext {
|
|
52
|
+
identity: CompanionIdentity;
|
|
53
|
+
env?: NodeJS.ProcessEnv;
|
|
54
|
+
cwd?: string;
|
|
55
|
+
signal?: AbortSignal;
|
|
56
|
+
registry?: FormalToolRegistry;
|
|
57
|
+
confirmationService?: ConfirmationService;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Safely execute a companion tool call.
|
|
61
|
+
*/
|
|
62
|
+
export declare function executeCompanionTool(toolName: string, args: Record<string, unknown>, context: CompanionToolExecutionContext): Promise<ToolResult>;
|
|
63
|
+
/**
|
|
64
|
+
* Extract image path from tool execution result if one was created/returned.
|
|
65
|
+
*/
|
|
66
|
+
export declare function extractImagePathFromToolResult(result: ToolResult, cwd?: string): string | undefined;
|