opc-agent 4.1.2 → 4.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/dist/analytics/index.d.ts.map +1 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/channels/dingtalk.d.ts.map +1 -0
- package/dist/channels/dingtalk.js.map +1 -0
- package/dist/channels/discord.d.ts.map +1 -0
- package/dist/channels/discord.js.map +1 -0
- package/dist/channels/email.d.ts.map +1 -0
- package/dist/channels/email.js.map +1 -0
- package/dist/channels/feishu.d.ts.map +1 -0
- package/dist/channels/feishu.js.map +1 -0
- package/dist/channels/googlechat.d.ts.map +1 -0
- package/dist/channels/googlechat.js.map +1 -0
- package/dist/channels/imessage.d.ts.map +1 -0
- package/dist/channels/imessage.js.map +1 -0
- package/dist/channels/index.d.ts.map +1 -0
- package/dist/channels/index.js.map +1 -0
- package/dist/channels/irc.d.ts.map +1 -0
- package/dist/channels/irc.js.map +1 -0
- package/dist/channels/line.d.ts.map +1 -0
- package/dist/channels/line.js.map +1 -0
- package/dist/channels/matrix.d.ts.map +1 -0
- package/dist/channels/matrix.js.map +1 -0
- package/dist/channels/mattermost.d.ts.map +1 -0
- package/dist/channels/mattermost.js.map +1 -0
- package/dist/channels/msteams.d.ts.map +1 -0
- package/dist/channels/msteams.js.map +1 -0
- package/dist/channels/nostr.d.ts.map +1 -0
- package/dist/channels/nostr.js.map +1 -0
- package/dist/channels/qq.d.ts.map +1 -0
- package/dist/channels/qq.js.map +1 -0
- package/dist/channels/signal.d.ts.map +1 -0
- package/dist/channels/signal.js.map +1 -0
- package/dist/channels/slack.d.ts.map +1 -0
- package/dist/channels/slack.js.map +1 -0
- package/dist/channels/sms.d.ts.map +1 -0
- package/dist/channels/sms.js.map +1 -0
- package/dist/channels/telegram.d.ts.map +1 -0
- package/dist/channels/telegram.js.map +1 -0
- package/dist/channels/twitch.d.ts.map +1 -0
- package/dist/channels/twitch.js.map +1 -0
- package/dist/channels/voice-call.d.ts.map +1 -0
- package/dist/channels/voice-call.js.map +1 -0
- package/dist/channels/voice.d.ts.map +1 -0
- package/dist/channels/voice.js.map +1 -0
- package/dist/channels/web.d.ts.map +1 -0
- package/dist/channels/web.js.map +1 -0
- package/dist/channels/webhook.d.ts.map +1 -0
- package/dist/channels/webhook.js.map +1 -0
- package/dist/channels/websocket.d.ts.map +1 -0
- package/dist/channels/websocket.js.map +1 -0
- package/dist/channels/wechat.d.ts.map +1 -0
- package/dist/channels/wechat.js.map +1 -0
- package/dist/channels/whatsapp.d.ts.map +1 -0
- package/dist/channels/whatsapp.js.map +1 -0
- package/dist/cli/chat.d.ts.map +1 -0
- package/dist/cli/chat.js.map +1 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +72 -11
- package/dist/cli.js.map +1 -0
- package/dist/core/a2a.d.ts.map +1 -0
- package/dist/core/a2a.js.map +1 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/analytics-engine.d.ts.map +1 -0
- package/dist/core/analytics-engine.js.map +1 -0
- package/dist/core/api-server.d.ts.map +1 -0
- package/dist/core/api-server.js.map +1 -0
- package/dist/core/audio.d.ts.map +1 -0
- package/dist/core/audio.js.map +1 -0
- package/dist/core/auth.d.ts.map +1 -0
- package/dist/core/auth.js.map +1 -0
- package/dist/core/cache.d.ts.map +1 -0
- package/dist/core/cache.js.map +1 -0
- package/dist/core/collaboration.d.ts.map +1 -0
- package/dist/core/collaboration.js.map +1 -0
- package/dist/core/compose.d.ts.map +1 -0
- package/dist/core/compose.js.map +1 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/context-discovery.d.ts.map +1 -0
- package/dist/core/context-discovery.js.map +1 -0
- package/dist/core/context-refs.d.ts.map +1 -0
- package/dist/core/context-refs.js.map +1 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/gateway.d.ts.map +1 -0
- package/dist/core/gateway.js.map +1 -0
- package/dist/core/heartbeat.d.ts.map +1 -0
- package/dist/core/heartbeat.js.map +1 -0
- package/dist/core/hitl.d.ts.map +1 -0
- package/dist/core/hitl.js.map +1 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/hooks.js.map +1 -0
- package/dist/core/ide-bridge.d.ts.map +1 -0
- package/dist/core/ide-bridge.js.map +1 -0
- package/dist/core/knowledge.d.ts.map +1 -0
- package/dist/core/knowledge.js.map +1 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/node-network.d.ts.map +1 -0
- package/dist/core/node-network.js.map +1 -0
- package/dist/core/orchestrator.d.ts.map +1 -0
- package/dist/core/orchestrator.js.map +1 -0
- package/dist/core/performance.d.ts.map +1 -0
- package/dist/core/performance.js.map +1 -0
- package/dist/core/profiles.d.ts.map +1 -0
- package/dist/core/profiles.js.map +1 -0
- package/dist/core/rate-limiter.d.ts.map +1 -0
- package/dist/core/rate-limiter.js.map +1 -0
- package/dist/core/room.d.ts.map +1 -0
- package/dist/core/room.js.map +1 -0
- package/dist/core/runtime.d.ts.map +1 -0
- package/dist/core/runtime.js.map +1 -0
- package/dist/core/sandbox.d.ts.map +1 -0
- package/dist/core/sandbox.js.map +1 -0
- package/dist/core/scheduler.d.ts.map +1 -0
- package/dist/core/scheduler.js.map +1 -0
- package/dist/core/security.d.ts.map +1 -0
- package/dist/core/security.js.map +1 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/streaming.d.ts.map +1 -0
- package/dist/core/streaming.js.map +1 -0
- package/dist/core/subagent.d.ts.map +1 -0
- package/dist/core/subagent.js.map +1 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/versioning.d.ts.map +1 -0
- package/dist/core/versioning.js.map +1 -0
- package/dist/core/vision.d.ts.map +1 -0
- package/dist/core/vision.js.map +1 -0
- package/dist/core/watch.d.ts.map +1 -0
- package/dist/core/watch.js.map +1 -0
- package/dist/core/workflow-graph.d.ts.map +1 -0
- package/dist/core/workflow-graph.js.map +1 -0
- package/dist/core/workflow.d.ts.map +1 -0
- package/dist/core/workflow.js.map +1 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js.map +1 -0
- package/dist/deploy/hermes.d.ts.map +1 -0
- package/dist/deploy/hermes.js.map +1 -0
- package/dist/deploy/index.d.ts.map +1 -0
- package/dist/deploy/index.js.map +1 -0
- package/dist/deploy/openclaw.d.ts.map +1 -0
- package/dist/deploy/openclaw.js.map +1 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js.map +1 -0
- package/dist/eval/index.d.ts.map +1 -0
- package/dist/eval/index.js.map +1 -0
- package/dist/hub/brain-seed.d.ts.map +1 -0
- package/dist/hub/brain-seed.js.map +1 -0
- package/dist/hub/client.d.ts.map +1 -0
- package/dist/hub/client.js.map +1 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/servers/calculator-mcp.d.ts.map +1 -0
- package/dist/mcp/servers/calculator-mcp.js.map +1 -0
- package/dist/mcp/servers/crypto-mcp.d.ts.map +1 -0
- package/dist/mcp/servers/crypto-mcp.js.map +1 -0
- package/dist/mcp/servers/database-mcp.d.ts.map +1 -0
- package/dist/mcp/servers/database-mcp.js.map +1 -0
- package/dist/mcp/servers/datetime-mcp.d.ts.map +1 -0
- package/dist/mcp/servers/datetime-mcp.js.map +1 -0
- package/dist/mcp/servers/filesystem.d.ts.map +1 -0
- package/dist/mcp/servers/filesystem.js.map +1 -0
- package/dist/mcp/servers/github-mcp.d.ts.map +1 -0
- package/dist/mcp/servers/github-mcp.js.map +1 -0
- package/dist/mcp/servers/index.d.ts.map +1 -0
- package/dist/mcp/servers/index.js.map +1 -0
- package/dist/mcp/servers/json-mcp.d.ts.map +1 -0
- package/dist/mcp/servers/json-mcp.js.map +1 -0
- package/dist/mcp/servers/memory-mcp.d.ts.map +1 -0
- package/dist/mcp/servers/memory-mcp.js.map +1 -0
- package/dist/mcp/servers/regex-mcp.d.ts.map +1 -0
- package/dist/mcp/servers/regex-mcp.js.map +1 -0
- package/dist/mcp/servers/web-mcp.d.ts.map +1 -0
- package/dist/mcp/servers/web-mcp.js.map +1 -0
- package/dist/memory/context-compressor.d.ts.map +1 -0
- package/dist/memory/context-compressor.js.map +1 -0
- package/dist/memory/deepbrain.d.ts.map +1 -0
- package/dist/memory/deepbrain.js.map +1 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/seed-loader.d.ts.map +1 -0
- package/dist/memory/seed-loader.js.map +1 -0
- package/dist/memory/user-profiler.d.ts.map +1 -0
- package/dist/memory/user-profiler.js.map +1 -0
- package/dist/plugins/content-filter.d.ts.map +1 -0
- package/dist/plugins/content-filter.js.map +1 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/logger.d.ts.map +1 -0
- package/dist/plugins/logger.js.map +1 -0
- package/dist/plugins/rate-limiter.d.ts.map +1 -0
- package/dist/plugins/rate-limiter.js.map +1 -0
- package/dist/protocols/a2a/client.d.ts.map +1 -0
- package/dist/protocols/a2a/client.js.map +1 -0
- package/dist/protocols/a2a/index.d.ts.map +1 -0
- package/dist/protocols/a2a/index.js.map +1 -0
- package/dist/protocols/a2a/server.d.ts.map +1 -0
- package/dist/protocols/a2a/server.js.map +1 -0
- package/dist/protocols/a2a/types.d.ts.map +1 -0
- package/dist/protocols/a2a/types.js.map +1 -0
- package/dist/protocols/a2a/utils.d.ts.map +1 -0
- package/dist/protocols/a2a/utils.js.map +1 -0
- package/dist/protocols/agui/client.d.ts.map +1 -0
- package/dist/protocols/agui/client.js.map +1 -0
- package/dist/protocols/agui/index.d.ts.map +1 -0
- package/dist/protocols/agui/index.js.map +1 -0
- package/dist/protocols/agui/server.d.ts.map +1 -0
- package/dist/protocols/agui/server.js.map +1 -0
- package/dist/protocols/agui/types.d.ts.map +1 -0
- package/dist/protocols/agui/types.js.map +1 -0
- package/dist/protocols/index.d.ts.map +1 -0
- package/dist/protocols/index.js.map +1 -0
- package/dist/protocols/mcp/agent-tools.d.ts.map +1 -0
- package/dist/protocols/mcp/agent-tools.js.map +1 -0
- package/dist/protocols/mcp/index.d.ts.map +1 -0
- package/dist/protocols/mcp/index.js.map +1 -0
- package/dist/protocols/mcp/server.d.ts.map +1 -0
- package/dist/protocols/mcp/server.js.map +1 -0
- package/dist/protocols/mcp/types.d.ts.map +1 -0
- package/dist/protocols/mcp/types.js.map +1 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/publish/index.d.ts.map +1 -0
- package/dist/publish/index.js.map +1 -0
- package/dist/scheduler/cron-engine.d.ts.map +1 -0
- package/dist/scheduler/cron-engine.js.map +1 -0
- package/dist/scheduler/index.d.ts.map +1 -0
- package/dist/scheduler/index.js.map +1 -0
- package/dist/schema/oad.d.ts.map +1 -0
- package/dist/schema/oad.js.map +1 -0
- package/dist/security/approval.d.ts.map +1 -0
- package/dist/security/approval.js.map +1 -0
- package/dist/security/approvals.d.ts.map +1 -0
- package/dist/security/approvals.js.map +1 -0
- package/dist/security/elevated.d.ts.map +1 -0
- package/dist/security/elevated.js.map +1 -0
- package/dist/security/guardrails.d.ts.map +1 -0
- package/dist/security/guardrails.js.map +1 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/keys.d.ts.map +1 -0
- package/dist/security/keys.js.map +1 -0
- package/dist/security/secrets.d.ts.map +1 -0
- package/dist/security/secrets.js.map +1 -0
- package/dist/skills/auto-learn.d.ts.map +1 -0
- package/dist/skills/auto-learn.js.map +1 -0
- package/dist/skills/base.d.ts.map +1 -0
- package/dist/skills/base.js.map +1 -0
- package/dist/skills/builtin/index.d.ts.map +1 -0
- package/dist/skills/builtin/index.js.map +1 -0
- package/dist/skills/document.d.ts.map +1 -0
- package/dist/skills/document.js.map +1 -0
- package/dist/skills/http.d.ts.map +1 -0
- package/dist/skills/http.js.map +1 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/marketplace.d.ts.map +1 -0
- package/dist/skills/marketplace.js.map +1 -0
- package/dist/skills/scheduler.d.ts.map +1 -0
- package/dist/skills/scheduler.js.map +1 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/skills/webhook-trigger.d.ts.map +1 -0
- package/dist/skills/webhook-trigger.js.map +1 -0
- package/dist/studio/server.d.ts.map +1 -0
- package/dist/studio/server.js.map +1 -0
- package/dist/studio/templates-data.d.ts.map +1 -0
- package/dist/studio/templates-data.js.map +1 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/templates/code-reviewer.d.ts.map +1 -0
- package/dist/templates/code-reviewer.js.map +1 -0
- package/dist/templates/content-writer.d.ts.map +1 -0
- package/dist/templates/content-writer.js.map +1 -0
- package/dist/templates/customer-service.d.ts.map +1 -0
- package/dist/templates/customer-service.js.map +1 -0
- package/dist/templates/data-analyst.d.ts.map +1 -0
- package/dist/templates/data-analyst.js.map +1 -0
- package/dist/templates/executive-assistant.d.ts.map +1 -0
- package/dist/templates/executive-assistant.js.map +1 -0
- package/dist/templates/financial-advisor.d.ts.map +1 -0
- package/dist/templates/financial-advisor.js.map +1 -0
- package/dist/templates/hr-recruiter.d.ts.map +1 -0
- package/dist/templates/hr-recruiter.js.map +1 -0
- package/dist/templates/knowledge-base.d.ts.map +1 -0
- package/dist/templates/knowledge-base.js.map +1 -0
- package/dist/templates/legal-assistant.d.ts.map +1 -0
- package/dist/templates/legal-assistant.js.map +1 -0
- package/dist/templates/project-manager.d.ts.map +1 -0
- package/dist/templates/project-manager.js.map +1 -0
- package/dist/templates/sales-assistant.d.ts.map +1 -0
- package/dist/templates/sales-assistant.js.map +1 -0
- package/dist/templates/teacher.d.ts.map +1 -0
- package/dist/templates/teacher.js.map +1 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/tools/builtin/browser.d.ts.map +1 -0
- package/dist/tools/builtin/browser.js.map +1 -0
- package/dist/tools/builtin/datetime.d.ts.map +1 -0
- package/dist/tools/builtin/datetime.js.map +1 -0
- package/dist/tools/builtin/file.d.ts.map +1 -0
- package/dist/tools/builtin/file.js.map +1 -0
- package/dist/tools/builtin/home-assistant.d.ts.map +1 -0
- package/dist/tools/builtin/home-assistant.js.map +1 -0
- package/dist/tools/builtin/index.d.ts.map +1 -0
- package/dist/tools/builtin/index.js.map +1 -0
- package/dist/tools/builtin/rl-tools.d.ts.map +1 -0
- package/dist/tools/builtin/rl-tools.js.map +1 -0
- package/dist/tools/builtin/shell.d.ts.map +1 -0
- package/dist/tools/builtin/shell.js.map +1 -0
- package/dist/tools/builtin/vision.d.ts.map +1 -0
- package/dist/tools/builtin/vision.js.map +1 -0
- package/dist/tools/builtin/web-search.d.ts.map +1 -0
- package/dist/tools/builtin/web-search.js.map +1 -0
- package/dist/tools/builtin/web.d.ts.map +1 -0
- package/dist/tools/builtin/web.js.map +1 -0
- package/dist/tools/calculator.d.ts.map +1 -0
- package/dist/tools/calculator.js.map +1 -0
- package/dist/tools/datetime.d.ts.map +1 -0
- package/dist/tools/datetime.js.map +1 -0
- package/dist/tools/document-processor.d.ts.map +1 -0
- package/dist/tools/document-processor.js.map +1 -0
- package/dist/tools/gateway.d.ts.map +1 -0
- package/dist/tools/gateway.js.map +1 -0
- package/dist/tools/image-generator.d.ts.map +1 -0
- package/dist/tools/image-generator.js.map +1 -0
- package/dist/tools/integrations/calendar.d.ts.map +1 -0
- package/dist/tools/integrations/calendar.js.map +1 -0
- package/dist/tools/integrations/code-exec.d.ts.map +1 -0
- package/dist/tools/integrations/code-exec.js.map +1 -0
- package/dist/tools/integrations/csv-analyzer.d.ts.map +1 -0
- package/dist/tools/integrations/csv-analyzer.js.map +1 -0
- package/dist/tools/integrations/database.d.ts.map +1 -0
- package/dist/tools/integrations/database.js.map +1 -0
- package/dist/tools/integrations/email-send.d.ts.map +1 -0
- package/dist/tools/integrations/email-send.js.map +1 -0
- package/dist/tools/integrations/git-tool.d.ts.map +1 -0
- package/dist/tools/integrations/git-tool.js.map +1 -0
- package/dist/tools/integrations/github-tool.d.ts.map +1 -0
- package/dist/tools/integrations/github-tool.js.map +1 -0
- package/dist/tools/integrations/image-gen.d.ts.map +1 -0
- package/dist/tools/integrations/image-gen.js.map +1 -0
- package/dist/tools/integrations/index.d.ts.map +1 -0
- package/dist/tools/integrations/index.js.map +1 -0
- package/dist/tools/integrations/jira.d.ts.map +1 -0
- package/dist/tools/integrations/jira.js.map +1 -0
- package/dist/tools/integrations/notion.d.ts.map +1 -0
- package/dist/tools/integrations/notion.js.map +1 -0
- package/dist/tools/integrations/npm-tool.d.ts.map +1 -0
- package/dist/tools/integrations/npm-tool.js.map +1 -0
- package/dist/tools/integrations/pdf-reader.d.ts.map +1 -0
- package/dist/tools/integrations/pdf-reader.js.map +1 -0
- package/dist/tools/integrations/slack.d.ts.map +1 -0
- package/dist/tools/integrations/slack.js.map +1 -0
- package/dist/tools/integrations/summarizer.d.ts.map +1 -0
- package/dist/tools/integrations/summarizer.js.map +1 -0
- package/dist/tools/integrations/translator.d.ts.map +1 -0
- package/dist/tools/integrations/translator.js.map +1 -0
- package/dist/tools/integrations/trello.d.ts.map +1 -0
- package/dist/tools/integrations/trello.js.map +1 -0
- package/dist/tools/integrations/vector-search.d.ts.map +1 -0
- package/dist/tools/integrations/vector-search.js.map +1 -0
- package/dist/tools/integrations/web-scraper.d.ts.map +1 -0
- package/dist/tools/integrations/web-scraper.js.map +1 -0
- package/dist/tools/integrations/web-search.d.ts.map +1 -0
- package/dist/tools/integrations/web-search.js.map +1 -0
- package/dist/tools/integrations/webhook.d.ts.map +1 -0
- package/dist/tools/integrations/webhook.js.map +1 -0
- package/dist/tools/json-transform.d.ts.map +1 -0
- package/dist/tools/json-transform.js.map +1 -0
- package/dist/tools/mcp-client.d.ts.map +1 -0
- package/dist/tools/mcp-client.js.map +1 -0
- package/dist/tools/mcp.d.ts.map +1 -0
- package/dist/tools/mcp.js.map +1 -0
- package/dist/tools/text-analysis.d.ts.map +1 -0
- package/dist/tools/text-analysis.js.map +1 -0
- package/dist/tools/web-scraper.d.ts.map +1 -0
- package/dist/tools/web-scraper.js.map +1 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/traces/index.d.ts.map +1 -0
- package/dist/traces/index.js.map +1 -0
- package/dist/ui/components.d.ts.map +1 -0
- package/dist/ui/components.js.map +1 -0
- package/package.json +1 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -20
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -14
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -13
- package/.github/workflows/ci.yml +0 -24
- package/USABILITY-ISSUES.md +0 -73
- package/docs/.vitepress/config.ts +0 -103
- package/docs/api/cli.md +0 -48
- package/docs/api/oad-schema.md +0 -64
- package/docs/api/sdk.md +0 -80
- package/docs/guide/concepts.md +0 -51
- package/docs/guide/configuration.md +0 -79
- package/docs/guide/deployment.md +0 -42
- package/docs/guide/getting-started.md +0 -44
- package/docs/guide/templates.md +0 -28
- package/docs/guide/testing.md +0 -84
- package/docs/index.md +0 -27
- package/docs/zh/api/cli.md +0 -54
- package/docs/zh/api/oad-schema.md +0 -87
- package/docs/zh/api/sdk.md +0 -102
- package/docs/zh/guide/concepts.md +0 -104
- package/docs/zh/guide/configuration.md +0 -135
- package/docs/zh/guide/deployment.md +0 -81
- package/docs/zh/guide/getting-started.md +0 -82
- package/docs/zh/guide/templates.md +0 -84
- package/docs/zh/guide/testing.md +0 -88
- package/docs/zh/index.md +0 -27
- package/fix-sidebar.mjs +0 -188
- package/serve-studio.js +0 -13
- package/serve-test.js +0 -25
- package/src/analytics/index.ts +0 -66
- package/src/channels/dingtalk.ts +0 -46
- package/src/channels/discord.ts +0 -192
- package/src/channels/email.ts +0 -351
- package/src/channels/feishu.ts +0 -349
- package/src/channels/googlechat.ts +0 -42
- package/src/channels/imessage.ts +0 -32
- package/src/channels/index.ts +0 -15
- package/src/channels/irc.ts +0 -82
- package/src/channels/line.ts +0 -33
- package/src/channels/matrix.ts +0 -34
- package/src/channels/mattermost.ts +0 -57
- package/src/channels/msteams.ts +0 -33
- package/src/channels/nostr.ts +0 -33
- package/src/channels/qq.ts +0 -34
- package/src/channels/signal.ts +0 -33
- package/src/channels/slack.ts +0 -217
- package/src/channels/sms.ts +0 -34
- package/src/channels/telegram.ts +0 -616
- package/src/channels/twitch.ts +0 -65
- package/src/channels/voice-call.ts +0 -100
- package/src/channels/voice.ts +0 -471
- package/src/channels/web.ts +0 -638
- package/src/channels/webhook.ts +0 -199
- package/src/channels/websocket.ts +0 -399
- package/src/channels/wechat.ts +0 -329
- package/src/channels/whatsapp.ts +0 -33
- package/src/cli/chat.ts +0 -99
- package/src/cli/setup.ts +0 -314
- package/src/cli.ts +0 -2826
- package/src/core/a2a.ts +0 -203
- package/src/core/agent.ts +0 -476
- package/src/core/analytics-engine.ts +0 -186
- package/src/core/api-server.ts +0 -277
- package/src/core/audio.ts +0 -98
- package/src/core/auth.ts +0 -57
- package/src/core/cache.ts +0 -141
- package/src/core/collaboration.ts +0 -275
- package/src/core/compose.ts +0 -77
- package/src/core/config.ts +0 -14
- package/src/core/context-discovery.ts +0 -85
- package/src/core/context-refs.ts +0 -140
- package/src/core/errors.ts +0 -148
- package/src/core/gateway.ts +0 -106
- package/src/core/heartbeat.ts +0 -51
- package/src/core/hitl.ts +0 -138
- package/src/core/hooks.ts +0 -105
- package/src/core/ide-bridge.ts +0 -133
- package/src/core/knowledge.ts +0 -255
- package/src/core/logger.ts +0 -57
- package/src/core/node-network.ts +0 -86
- package/src/core/orchestrator.ts +0 -215
- package/src/core/performance.ts +0 -187
- package/src/core/profiles.ts +0 -122
- package/src/core/rate-limiter.ts +0 -128
- package/src/core/room.ts +0 -109
- package/src/core/runtime.ts +0 -435
- package/src/core/sandbox.ts +0 -344
- package/src/core/scheduler.ts +0 -187
- package/src/core/security.ts +0 -171
- package/src/core/session-manager.ts +0 -137
- package/src/core/streaming.ts +0 -195
- package/src/core/subagent.ts +0 -98
- package/src/core/types.ts +0 -68
- package/src/core/versioning.ts +0 -106
- package/src/core/vision.ts +0 -180
- package/src/core/watch.ts +0 -178
- package/src/core/workflow-graph.ts +0 -365
- package/src/core/workflow.ts +0 -235
- package/src/daemon.ts +0 -96
- package/src/deploy/hermes.ts +0 -156
- package/src/deploy/index.ts +0 -255
- package/src/deploy/openclaw.ts +0 -190
- package/src/doctor.ts +0 -243
- package/src/eval/index.ts +0 -211
- package/src/eval/suites/basic.json +0 -16
- package/src/eval/suites/memory.json +0 -12
- package/src/eval/suites/safety.json +0 -14
- package/src/hub/brain-seed.ts +0 -54
- package/src/hub/client.ts +0 -60
- package/src/i18n/index.ts +0 -216
- package/src/index.ts +0 -283
- package/src/mcp/servers/calculator-mcp.ts +0 -65
- package/src/mcp/servers/crypto-mcp.ts +0 -73
- package/src/mcp/servers/database-mcp.ts +0 -72
- package/src/mcp/servers/datetime-mcp.ts +0 -69
- package/src/mcp/servers/filesystem.ts +0 -66
- package/src/mcp/servers/github-mcp.ts +0 -58
- package/src/mcp/servers/index.ts +0 -63
- package/src/mcp/servers/json-mcp.ts +0 -102
- package/src/mcp/servers/memory-mcp.ts +0 -56
- package/src/mcp/servers/regex-mcp.ts +0 -53
- package/src/mcp/servers/web-mcp.ts +0 -49
- package/src/memory/context-compressor.ts +0 -189
- package/src/memory/deepbrain.ts +0 -202
- package/src/memory/index.ts +0 -41
- package/src/memory/seed-loader.ts +0 -212
- package/src/memory/user-profiler.ts +0 -215
- package/src/plugins/content-filter.ts +0 -23
- package/src/plugins/index.ts +0 -339
- package/src/plugins/logger.ts +0 -18
- package/src/plugins/rate-limiter.ts +0 -38
- package/src/protocols/a2a/client.ts +0 -132
- package/src/protocols/a2a/index.ts +0 -8
- package/src/protocols/a2a/server.ts +0 -333
- package/src/protocols/a2a/types.ts +0 -88
- package/src/protocols/a2a/utils.ts +0 -50
- package/src/protocols/agui/client.ts +0 -83
- package/src/protocols/agui/index.ts +0 -4
- package/src/protocols/agui/server.ts +0 -218
- package/src/protocols/agui/types.ts +0 -153
- package/src/protocols/index.ts +0 -2
- package/src/protocols/mcp/agent-tools.ts +0 -134
- package/src/protocols/mcp/index.ts +0 -8
- package/src/protocols/mcp/server.ts +0 -262
- package/src/protocols/mcp/types.ts +0 -69
- package/src/providers/index.ts +0 -632
- package/src/publish/index.ts +0 -376
- package/src/scheduler/cron-engine.ts +0 -191
- package/src/scheduler/index.ts +0 -2
- package/src/schema/oad.ts +0 -217
- package/src/security/approval.ts +0 -131
- package/src/security/approvals.ts +0 -143
- package/src/security/elevated.ts +0 -105
- package/src/security/guardrails.ts +0 -248
- package/src/security/index.ts +0 -9
- package/src/security/keys.ts +0 -87
- package/src/security/secrets.ts +0 -129
- package/src/skills/auto-learn.ts +0 -262
- package/src/skills/base.ts +0 -16
- package/src/skills/builtin/index.ts +0 -408
- package/src/skills/document.ts +0 -100
- package/src/skills/http.ts +0 -35
- package/src/skills/index.ts +0 -27
- package/src/skills/marketplace.ts +0 -113
- package/src/skills/scheduler.ts +0 -80
- package/src/skills/types.ts +0 -42
- package/src/skills/webhook-trigger.ts +0 -59
- package/src/studio/server.ts +0 -1791
- package/src/studio/templates-data.ts +0 -178
- package/src/studio-ui/index.html +0 -3076
- package/src/telemetry/index.ts +0 -324
- package/src/templates/code-reviewer.ts +0 -30
- package/src/templates/content-writer.ts +0 -58
- package/src/templates/customer-service.ts +0 -76
- package/src/templates/data-analyst.ts +0 -66
- package/src/templates/executive-assistant.ts +0 -71
- package/src/templates/financial-advisor.ts +0 -60
- package/src/templates/hr-recruiter.ts +0 -58
- package/src/templates/knowledge-base.ts +0 -27
- package/src/templates/legal-assistant.ts +0 -71
- package/src/templates/project-manager.ts +0 -58
- package/src/templates/sales-assistant.ts +0 -75
- package/src/templates/teacher.ts +0 -75
- package/src/testing/index.ts +0 -181
- package/src/tools/builtin/browser.ts +0 -299
- package/src/tools/builtin/datetime.ts +0 -41
- package/src/tools/builtin/file.ts +0 -107
- package/src/tools/builtin/home-assistant.ts +0 -116
- package/src/tools/builtin/index.ts +0 -37
- package/src/tools/builtin/rl-tools.ts +0 -243
- package/src/tools/builtin/shell.ts +0 -43
- package/src/tools/builtin/vision.ts +0 -64
- package/src/tools/builtin/web-search.ts +0 -126
- package/src/tools/builtin/web.ts +0 -35
- package/src/tools/calculator.ts +0 -73
- package/src/tools/datetime.ts +0 -149
- package/src/tools/document-processor.ts +0 -213
- package/src/tools/gateway.ts +0 -220
- package/src/tools/image-generator.ts +0 -150
- package/src/tools/integrations/calendar.ts +0 -73
- package/src/tools/integrations/code-exec.ts +0 -39
- package/src/tools/integrations/csv-analyzer.ts +0 -92
- package/src/tools/integrations/database.ts +0 -44
- package/src/tools/integrations/email-send.ts +0 -76
- package/src/tools/integrations/git-tool.ts +0 -42
- package/src/tools/integrations/github-tool.ts +0 -76
- package/src/tools/integrations/image-gen.ts +0 -56
- package/src/tools/integrations/index.ts +0 -92
- package/src/tools/integrations/jira.ts +0 -83
- package/src/tools/integrations/notion.ts +0 -71
- package/src/tools/integrations/npm-tool.ts +0 -48
- package/src/tools/integrations/pdf-reader.ts +0 -58
- package/src/tools/integrations/slack.ts +0 -65
- package/src/tools/integrations/summarizer.ts +0 -49
- package/src/tools/integrations/translator.ts +0 -48
- package/src/tools/integrations/trello.ts +0 -60
- package/src/tools/integrations/vector-search.ts +0 -42
- package/src/tools/integrations/web-scraper.ts +0 -47
- package/src/tools/integrations/web-search.ts +0 -58
- package/src/tools/integrations/webhook.ts +0 -38
- package/src/tools/json-transform.ts +0 -187
- package/src/tools/mcp-client.ts +0 -131
- package/src/tools/mcp.ts +0 -76
- package/src/tools/text-analysis.ts +0 -116
- package/src/tools/web-scraper.ts +0 -179
- package/src/tools/web-search.ts +0 -180
- package/src/traces/index.ts +0 -132
- package/src/types/agent-workstation.d.ts +0 -2
- package/src/ui/components.ts +0 -127
- package/srv-err.txt +0 -0
- package/srv-out.txt +0 -1
- package/test-agent/Dockerfile +0 -9
- package/test-agent/README.md +0 -50
- package/test-agent/agent.yaml +0 -23
- package/test-agent/docker-compose.yml +0 -11
- package/test-agent/oad.yaml +0 -31
- package/test-agent/package-lock.json +0 -1492
- package/test-agent/package.json +0 -18
- package/test-agent/src/index.ts +0 -24
- package/test-agent/src/skills/echo.ts +0 -15
- package/test-agent/tsconfig.json +0 -25
- package/test-full.js +0 -43
- package/test-sidebar.js +0 -22
- package/test-studio3.js +0 -75
- package/test-studio4.js +0 -41
- package/tests/a2a-protocol.test.ts +0 -285
- package/tests/a2a.test.ts +0 -66
- package/tests/agent.test.ts +0 -72
- package/tests/agui-protocol.test.ts +0 -246
- package/tests/analytics.test.ts +0 -50
- package/tests/api-server.test.ts +0 -148
- package/tests/approvals.test.ts +0 -89
- package/tests/audio.test.ts +0 -40
- package/tests/auto-learn.test.ts +0 -105
- package/tests/brain-seed-extended.test.ts +0 -490
- package/tests/brain-seed.test.ts +0 -239
- package/tests/browser.test.ts +0 -179
- package/tests/builtin-tools.test.ts +0 -83
- package/tests/channel.test.ts +0 -39
- package/tests/channels/discord.test.ts +0 -79
- package/tests/channels/email.test.ts +0 -148
- package/tests/channels/feishu.test.ts +0 -123
- package/tests/channels/telegram.test.ts +0 -129
- package/tests/channels/websocket.test.ts +0 -53
- package/tests/channels/wechat.test.ts +0 -170
- package/tests/channels-extra.test.ts +0 -45
- package/tests/chat-cli.test.ts +0 -160
- package/tests/cli.test.ts +0 -46
- package/tests/collaboration.test.ts +0 -319
- package/tests/context-compressor.test.ts +0 -172
- package/tests/context-refs.test.ts +0 -121
- package/tests/cron-engine.test.ts +0 -101
- package/tests/daemon.test.ts +0 -135
- package/tests/deepbrain-wire.test.ts +0 -234
- package/tests/deploy-and-dag.test.ts +0 -196
- package/tests/doctor.test.ts +0 -38
- package/tests/document-processor.test.ts +0 -69
- package/tests/e2e-nocode.test.ts +0 -442
- package/tests/e2e.test.ts +0 -134
- package/tests/elevated.test.ts +0 -69
- package/tests/errors.test.ts +0 -83
- package/tests/eval.test.ts +0 -173
- package/tests/gateway.test.ts +0 -63
- package/tests/guardrails.test.ts +0 -177
- package/tests/hitl.test.ts +0 -71
- package/tests/home-assistant.test.ts +0 -40
- package/tests/hooks.test.ts +0 -79
- package/tests/i18n.test.ts +0 -41
- package/tests/ide-bridge.test.ts +0 -38
- package/tests/image-generator.test.ts +0 -84
- package/tests/init-role.test.ts +0 -124
- package/tests/integrations.test.ts +0 -249
- package/tests/mcp-client.test.ts +0 -92
- package/tests/mcp-server.test.ts +0 -178
- package/tests/mcp-servers.test.ts +0 -260
- package/tests/mcp.test.ts +0 -54
- package/tests/node-network.test.ts +0 -74
- package/tests/oad.test.ts +0 -68
- package/tests/performance.test.ts +0 -115
- package/tests/plugin-a2a-enhanced.test.ts +0 -230
- package/tests/plugin.test.ts +0 -74
- package/tests/profiles.test.ts +0 -61
- package/tests/publish.test.ts +0 -231
- package/tests/rl-tools.test.ts +0 -93
- package/tests/room.test.ts +0 -106
- package/tests/runtime.test.ts +0 -42
- package/tests/sandbox-manager.test.ts +0 -46
- package/tests/sandbox.test.ts +0 -46
- package/tests/scheduler.test.ts +0 -200
- package/tests/secrets.test.ts +0 -107
- package/tests/security-enhanced.test.ts +0 -233
- package/tests/security.test.ts +0 -60
- package/tests/settings-api.test.ts +0 -148
- package/tests/setup.test.ts +0 -73
- package/tests/skill-learner.test.ts +0 -161
- package/tests/streaming.test.ts +0 -109
- package/tests/studio.test.ts +0 -402
- package/tests/subagent.test.ts +0 -193
- package/tests/telegram-discord.test.ts +0 -60
- package/tests/telemetry.test.ts +0 -186
- package/tests/templates.test.ts +0 -77
- package/tests/tools/builtin-extended.test.ts +0 -138
- package/tests/user-profiler.test.ts +0 -169
- package/tests/v070.test.ts +0 -76
- package/tests/v090-features.test.ts +0 -254
- package/tests/versioning.test.ts +0 -75
- package/tests/vision.test.ts +0 -61
- package/tests/voice-call.test.ts +0 -47
- package/tests/voice-enhanced.test.ts +0 -169
- package/tests/voice-interaction.test.ts +0 -38
- package/tests/voice.test.ts +0 -61
- package/tests/web-search.test.ts +0 -155
- package/tests/webhook.test.ts +0 -29
- package/tests/workflow-graph.test.ts +0 -279
- package/tests/workflow.test.ts +0 -143
- package/tmp-js-test.js +0 -1532
- package/tmp-sc.js +0 -1716
- package/tutorial/customer-service-agent/README.md +0 -612
- package/tutorial/customer-service-agent/SOUL.md +0 -26
- package/tutorial/customer-service-agent/agent.yaml +0 -63
- package/tutorial/customer-service-agent/package.json +0 -19
- package/tutorial/customer-service-agent/src/index.ts +0 -69
- package/tutorial/customer-service-agent/src/skills/faq.ts +0 -27
- package/tutorial/customer-service-agent/src/skills/ticket.ts +0 -22
- package/tutorial/customer-service-agent/tsconfig.json +0 -14
- package/vitest.config.ts +0 -9
package/src/providers/index.ts
DELETED
|
@@ -1,632 +0,0 @@
|
|
|
1
|
-
import type { Message } from '../core/types';
|
|
2
|
-
import type { MCPToolDefinition } from '../tools/mcp';
|
|
3
|
-
import * as https from 'https';
|
|
4
|
-
import * as http from 'http';
|
|
5
|
-
|
|
6
|
-
export interface ChatOptions {
|
|
7
|
-
tools?: MCPToolDefinition[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface LLMProvider {
|
|
11
|
-
name: string;
|
|
12
|
-
chat(messages: Message[], systemPrompt?: string, options?: ChatOptions): Promise<string>;
|
|
13
|
-
chatStream(messages: Message[], systemPrompt?: string): AsyncIterable<string>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface OpenAIMessage {
|
|
17
|
-
role: 'system' | 'user' | 'assistant';
|
|
18
|
-
content: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function getApiKey(): string {
|
|
22
|
-
return process.env.OPC_LLM_API_KEY || process.env.OPENAI_API_KEY || '';
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function getBaseUrl(): string {
|
|
26
|
-
return process.env.OPC_LLM_BASE_URL || 'https://api.openai.com/v1';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function buildToolPrompt(tools: MCPToolDefinition[]): string {
|
|
30
|
-
const toolsDesc = tools.map(t =>
|
|
31
|
-
`- ${t.name}: ${t.description}\n Input schema: ${JSON.stringify(t.inputSchema)}`
|
|
32
|
-
).join('\n');
|
|
33
|
-
return `\n\nYou have access to the following tools. To use a tool, respond with ONLY a JSON object in this format:\n<tool_call>{"name": "tool_name", "arguments": {...}}</tool_call>\n\nAvailable tools:\n${toolsDesc}\n\nIf you don't need a tool, respond normally with text.`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
class OpenAICompatibleProvider implements LLMProvider {
|
|
37
|
-
name: string;
|
|
38
|
-
private model: string;
|
|
39
|
-
private baseUrl: string;
|
|
40
|
-
private apiKey: string;
|
|
41
|
-
|
|
42
|
-
constructor(name: string, model: string, baseUrl?: string, apiKey?: string) {
|
|
43
|
-
this.name = name;
|
|
44
|
-
this.model = model;
|
|
45
|
-
this.baseUrl = baseUrl || getBaseUrl();
|
|
46
|
-
this.apiKey = apiKey || getApiKey();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private formatMessages(messages: Message[], systemPrompt?: string): OpenAIMessage[] {
|
|
50
|
-
const formatted: OpenAIMessage[] = [];
|
|
51
|
-
if (systemPrompt) {
|
|
52
|
-
formatted.push({ role: 'system', content: systemPrompt });
|
|
53
|
-
}
|
|
54
|
-
for (const m of messages) {
|
|
55
|
-
formatted.push({ role: m.role as 'user' | 'assistant', content: m.content });
|
|
56
|
-
}
|
|
57
|
-
return formatted;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
private async request(body: any): Promise<any> {
|
|
61
|
-
if (!this.apiKey) {
|
|
62
|
-
throw new Error('No API key configured. Set OPC_LLM_API_KEY or OPENAI_API_KEY environment variable.');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const url = new URL(`${this.baseUrl}/chat/completions`);
|
|
66
|
-
const isGemini = url.hostname.includes('googleapis.com');
|
|
67
|
-
if (isGemini) {
|
|
68
|
-
url.searchParams.set('key', this.apiKey);
|
|
69
|
-
}
|
|
70
|
-
const isHttps = url.protocol === 'https:';
|
|
71
|
-
const lib = isHttps ? https : http;
|
|
72
|
-
|
|
73
|
-
const postData = JSON.stringify(body);
|
|
74
|
-
|
|
75
|
-
const headers: Record<string, string> = {
|
|
76
|
-
'Content-Type': 'application/json',
|
|
77
|
-
'Content-Length': String(Buffer.byteLength(postData)),
|
|
78
|
-
};
|
|
79
|
-
if (!isGemini) {
|
|
80
|
-
headers['Authorization'] = `Bearer ${this.apiKey}`;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return new Promise((resolve, reject) => {
|
|
84
|
-
const req = lib.request(
|
|
85
|
-
{
|
|
86
|
-
hostname: url.hostname,
|
|
87
|
-
port: url.port || (isHttps ? 443 : 80),
|
|
88
|
-
path: url.pathname + url.search,
|
|
89
|
-
method: 'POST',
|
|
90
|
-
headers,
|
|
91
|
-
},
|
|
92
|
-
(res) => {
|
|
93
|
-
let data = '';
|
|
94
|
-
res.on('data', (chunk: Buffer) => (data += chunk.toString()));
|
|
95
|
-
res.on('end', () => {
|
|
96
|
-
if (res.statusCode && res.statusCode >= 400) {
|
|
97
|
-
reject(new Error(`LLM API error ${res.statusCode}: ${data}`));
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
try {
|
|
101
|
-
resolve(JSON.parse(data));
|
|
102
|
-
} catch {
|
|
103
|
-
reject(new Error(`Invalid JSON response: ${data.slice(0, 200)}`));
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
},
|
|
107
|
-
);
|
|
108
|
-
req.on('error', reject);
|
|
109
|
-
req.write(postData);
|
|
110
|
-
req.end();
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
async chat(messages: Message[], systemPrompt?: string, options?: ChatOptions): Promise<string> {
|
|
115
|
-
if (!this.apiKey) {
|
|
116
|
-
const last = messages[messages.length - 1];
|
|
117
|
-
return `[${this.name}/${this.model} - no API key] Echo: ${last?.content ?? ''}`;
|
|
118
|
-
}
|
|
119
|
-
let effectivePrompt = systemPrompt;
|
|
120
|
-
if (options?.tools && options.tools.length > 0) {
|
|
121
|
-
effectivePrompt = (systemPrompt || '') + buildToolPrompt(options.tools);
|
|
122
|
-
}
|
|
123
|
-
const formatted = this.formatMessages(messages, effectivePrompt);
|
|
124
|
-
const result = await this.request({
|
|
125
|
-
model: this.model,
|
|
126
|
-
messages: formatted,
|
|
127
|
-
temperature: 0.7,
|
|
128
|
-
max_tokens: 2048,
|
|
129
|
-
});
|
|
130
|
-
return result.choices?.[0]?.message?.content ?? '';
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
async *chatStream(messages: Message[], systemPrompt?: string): AsyncIterable<string> {
|
|
134
|
-
if (!this.apiKey) {
|
|
135
|
-
const last = messages[messages.length - 1];
|
|
136
|
-
yield `[${this.name}/${this.model} - no API key] Echo: ${last?.content ?? ''}`;
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const formatted = this.formatMessages(messages, systemPrompt);
|
|
141
|
-
const url = new URL(`${this.baseUrl}/chat/completions`);
|
|
142
|
-
const isGemini = url.hostname.includes('googleapis.com');
|
|
143
|
-
if (isGemini) {
|
|
144
|
-
url.searchParams.set('key', this.apiKey);
|
|
145
|
-
}
|
|
146
|
-
const isHttps = url.protocol === 'https:';
|
|
147
|
-
const lib = isHttps ? https : http;
|
|
148
|
-
const postData = JSON.stringify({
|
|
149
|
-
model: this.model,
|
|
150
|
-
messages: formatted,
|
|
151
|
-
temperature: 0.7,
|
|
152
|
-
max_tokens: 2048,
|
|
153
|
-
stream: true,
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
const streamHeaders: Record<string, string> = {
|
|
157
|
-
'Content-Type': 'application/json',
|
|
158
|
-
'Content-Length': String(Buffer.byteLength(postData)),
|
|
159
|
-
};
|
|
160
|
-
if (!isGemini) {
|
|
161
|
-
streamHeaders['Authorization'] = `Bearer ${this.apiKey}`;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const response = await new Promise<http.IncomingMessage>((resolve, reject) => {
|
|
165
|
-
const req = lib.request(
|
|
166
|
-
{
|
|
167
|
-
hostname: url.hostname,
|
|
168
|
-
port: url.port || (isHttps ? 443 : 80),
|
|
169
|
-
path: url.pathname + url.search,
|
|
170
|
-
method: 'POST',
|
|
171
|
-
headers: streamHeaders,
|
|
172
|
-
},
|
|
173
|
-
resolve,
|
|
174
|
-
);
|
|
175
|
-
req.on('error', reject);
|
|
176
|
-
req.write(postData);
|
|
177
|
-
req.end();
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
if (response.statusCode && response.statusCode >= 400) {
|
|
181
|
-
let data = '';
|
|
182
|
-
for await (const chunk of response) data += chunk.toString();
|
|
183
|
-
throw new Error(`LLM API error ${response.statusCode}: ${data}`);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
let buffer = '';
|
|
187
|
-
for await (const chunk of response) {
|
|
188
|
-
buffer += chunk.toString();
|
|
189
|
-
const lines = buffer.split('\n');
|
|
190
|
-
buffer = lines.pop() ?? '';
|
|
191
|
-
|
|
192
|
-
for (const line of lines) {
|
|
193
|
-
const trimmed = line.trim();
|
|
194
|
-
if (!trimmed || !trimmed.startsWith('data: ')) continue;
|
|
195
|
-
const data = trimmed.slice(6);
|
|
196
|
-
if (data === '[DONE]') return;
|
|
197
|
-
try {
|
|
198
|
-
const parsed = JSON.parse(data);
|
|
199
|
-
const content = parsed.choices?.[0]?.delta?.content;
|
|
200
|
-
if (content) yield content;
|
|
201
|
-
} catch {
|
|
202
|
-
// skip malformed lines
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
class GeminiNativeProvider implements LLMProvider {
|
|
210
|
-
name = 'gemini';
|
|
211
|
-
private model: string;
|
|
212
|
-
private apiKey: string;
|
|
213
|
-
|
|
214
|
-
constructor(model: string, apiKey?: string) {
|
|
215
|
-
this.model = model;
|
|
216
|
-
this.apiKey = apiKey || getApiKey();
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
private buildUrl(stream: boolean): string {
|
|
220
|
-
const action = stream ? 'streamGenerateContent?alt=sse&' : 'generateContent?';
|
|
221
|
-
return `https://generativelanguage.googleapis.com/v1beta/models/${this.model}:${action}key=${this.apiKey}`;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
private formatContents(messages: Message[], systemPrompt?: string): { contents: any[]; systemInstruction?: any } {
|
|
225
|
-
const contents: any[] = [];
|
|
226
|
-
for (const m of messages) {
|
|
227
|
-
contents.push({ role: m.role === 'assistant' ? 'model' : 'user', parts: [{ text: m.content }] });
|
|
228
|
-
}
|
|
229
|
-
const result: any = { contents };
|
|
230
|
-
if (systemPrompt) {
|
|
231
|
-
result.systemInstruction = { parts: [{ text: systemPrompt }] };
|
|
232
|
-
}
|
|
233
|
-
return result;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
async chat(messages: Message[], systemPrompt?: string, options?: ChatOptions): Promise<string> {
|
|
237
|
-
if (!this.apiKey) {
|
|
238
|
-
const last = messages[messages.length - 1];
|
|
239
|
-
return `[gemini/${this.model} - no API key] Echo: ${last?.content ?? ''}`;
|
|
240
|
-
}
|
|
241
|
-
let effectivePrompt = systemPrompt;
|
|
242
|
-
if (options?.tools && options.tools.length > 0) {
|
|
243
|
-
effectivePrompt = (systemPrompt || '') + buildToolPrompt(options.tools);
|
|
244
|
-
}
|
|
245
|
-
const body = this.formatContents(messages, effectivePrompt);
|
|
246
|
-
const url = this.buildUrl(false);
|
|
247
|
-
const postData = JSON.stringify(body);
|
|
248
|
-
|
|
249
|
-
return new Promise((resolve, reject) => {
|
|
250
|
-
const parsedUrl = new URL(url);
|
|
251
|
-
const req = https.request({
|
|
252
|
-
hostname: parsedUrl.hostname,
|
|
253
|
-
path: parsedUrl.pathname + parsedUrl.search,
|
|
254
|
-
method: 'POST',
|
|
255
|
-
headers: { 'Content-Type': 'application/json', 'Content-Length': String(Buffer.byteLength(postData)) },
|
|
256
|
-
}, (res) => {
|
|
257
|
-
let data = '';
|
|
258
|
-
res.on('data', (chunk: Buffer) => (data += chunk.toString()));
|
|
259
|
-
res.on('end', () => {
|
|
260
|
-
if (res.statusCode && res.statusCode >= 400) { reject(new Error(`Gemini API error ${res.statusCode}: ${data}`)); return; }
|
|
261
|
-
try {
|
|
262
|
-
const parsed = JSON.parse(data);
|
|
263
|
-
resolve(parsed.candidates?.[0]?.content?.parts?.[0]?.text ?? '');
|
|
264
|
-
} catch { reject(new Error(`Invalid Gemini response: ${data.slice(0, 200)}`)); }
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
req.on('error', reject);
|
|
268
|
-
req.write(postData);
|
|
269
|
-
req.end();
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
async *chatStream(messages: Message[], systemPrompt?: string): AsyncIterable<string> {
|
|
274
|
-
if (!this.apiKey) {
|
|
275
|
-
const last = messages[messages.length - 1];
|
|
276
|
-
yield `[gemini/${this.model} - no API key] Echo: ${last?.content ?? ''}`;
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
const body = this.formatContents(messages, systemPrompt);
|
|
280
|
-
const url = this.buildUrl(true);
|
|
281
|
-
const postData = JSON.stringify(body);
|
|
282
|
-
const parsedUrl = new URL(url);
|
|
283
|
-
|
|
284
|
-
const response = await new Promise<http.IncomingMessage>((resolve, reject) => {
|
|
285
|
-
const req = https.request({
|
|
286
|
-
hostname: parsedUrl.hostname,
|
|
287
|
-
path: parsedUrl.pathname + parsedUrl.search,
|
|
288
|
-
method: 'POST',
|
|
289
|
-
headers: { 'Content-Type': 'application/json', 'Content-Length': String(Buffer.byteLength(postData)) },
|
|
290
|
-
}, resolve);
|
|
291
|
-
req.on('error', reject);
|
|
292
|
-
req.write(postData);
|
|
293
|
-
req.end();
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
if (response.statusCode && response.statusCode >= 400) {
|
|
297
|
-
let data = '';
|
|
298
|
-
for await (const chunk of response) data += chunk.toString();
|
|
299
|
-
throw new Error(`Gemini API error ${response.statusCode}: ${data}`);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
let buffer = '';
|
|
303
|
-
for await (const chunk of response) {
|
|
304
|
-
buffer += chunk.toString();
|
|
305
|
-
const lines = buffer.split('\n');
|
|
306
|
-
buffer = lines.pop() ?? '';
|
|
307
|
-
for (const line of lines) {
|
|
308
|
-
const trimmed = line.trim();
|
|
309
|
-
if (!trimmed.startsWith('data: ')) continue;
|
|
310
|
-
const data = trimmed.slice(6);
|
|
311
|
-
if (data === '[DONE]') return;
|
|
312
|
-
try {
|
|
313
|
-
const parsed = JSON.parse(data);
|
|
314
|
-
const text = parsed.candidates?.[0]?.content?.parts?.[0]?.text;
|
|
315
|
-
if (text) yield text;
|
|
316
|
-
} catch {}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
function isGeminiNative(): boolean {
|
|
323
|
-
const baseUrl = process.env.OPC_LLM_BASE_URL || '';
|
|
324
|
-
const key = getApiKey();
|
|
325
|
-
return key.startsWith('AQ.') || (baseUrl.includes('googleapis.com') && !baseUrl.includes('/openai'));
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
class ClaudeCLIProvider implements LLMProvider {
|
|
329
|
-
name = 'claude-cli';
|
|
330
|
-
private model: string;
|
|
331
|
-
|
|
332
|
-
constructor(model?: string) {
|
|
333
|
-
// Claude CLI uses short model names; don't pass API-style model names
|
|
334
|
-
// Let Claude CLI use its default model unless explicitly set to a known CLI model
|
|
335
|
-
const cliModels = ['sonnet', 'opus', 'haiku', 'claude-sonnet-4-20250514', 'claude-opus-4-20250514'];
|
|
336
|
-
if (model && !cliModels.includes(model)) {
|
|
337
|
-
// Map common patterns
|
|
338
|
-
if (model.includes('opus')) this.model = 'opus';
|
|
339
|
-
else if (model.includes('haiku')) this.model = 'haiku';
|
|
340
|
-
else this.model = ''; // let CLI choose default
|
|
341
|
-
} else {
|
|
342
|
-
this.model = model || '';
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
async chat(messages: Message[], systemPrompt?: string, options?: ChatOptions): Promise<string> {
|
|
347
|
-
const { writeFileSync, unlinkSync, mkdtempSync } = await import('fs');
|
|
348
|
-
const { join } = await import('path');
|
|
349
|
-
const { tmpdir } = await import('os');
|
|
350
|
-
|
|
351
|
-
// Build the prompt from messages
|
|
352
|
-
const lastMessage = messages[messages.length - 1];
|
|
353
|
-
if (!lastMessage) return '';
|
|
354
|
-
|
|
355
|
-
let prompt = lastMessage.content;
|
|
356
|
-
|
|
357
|
-
// Add tool prompt if tools provided
|
|
358
|
-
if (options?.tools && options.tools.length > 0) {
|
|
359
|
-
prompt += buildToolPrompt(options.tools);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
const args = ['-p'];
|
|
363
|
-
// Write system prompt to temp file to avoid shell escaping issues
|
|
364
|
-
let tmpFile: string | undefined;
|
|
365
|
-
if (systemPrompt) {
|
|
366
|
-
const tmpDir = mkdtempSync(join(tmpdir(), 'opc-'));
|
|
367
|
-
tmpFile = join(tmpDir, 'system.txt');
|
|
368
|
-
writeFileSync(tmpFile, systemPrompt, 'utf8');
|
|
369
|
-
args.push('--system-prompt-file', tmpFile);
|
|
370
|
-
}
|
|
371
|
-
if (this.model) {
|
|
372
|
-
args.push('--model', this.model);
|
|
373
|
-
}
|
|
374
|
-
args.push(prompt);
|
|
375
|
-
|
|
376
|
-
try {
|
|
377
|
-
const { spawn } = await import('child_process');
|
|
378
|
-
const result = await new Promise<string>((resolve, reject) => {
|
|
379
|
-
const proc = spawn('claude', args, {
|
|
380
|
-
env: { ...process.env },
|
|
381
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
382
|
-
});
|
|
383
|
-
// Close stdin immediately to avoid "no stdin data" warning
|
|
384
|
-
proc.stdin.end();
|
|
385
|
-
let stdout = '';
|
|
386
|
-
let stderr = '';
|
|
387
|
-
proc.stdout.on('data', (d: Buffer) => { stdout += d.toString(); });
|
|
388
|
-
proc.stderr.on('data', (d: Buffer) => { stderr += d.toString(); });
|
|
389
|
-
proc.on('close', (code) => {
|
|
390
|
-
if (code === 0 || stdout.trim()) {
|
|
391
|
-
resolve(stdout.trim());
|
|
392
|
-
} else {
|
|
393
|
-
reject(new Error(`Claude CLI exited ${code}: ${stderr}`));
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
proc.on('error', (err: any) => {
|
|
397
|
-
if (err.code === 'ENOENT') {
|
|
398
|
-
reject(new Error(
|
|
399
|
-
'Claude CLI not found. Install it: npm install -g @anthropic-ai/claude-code\n' +
|
|
400
|
-
'Then authenticate: claude login'
|
|
401
|
-
));
|
|
402
|
-
} else {
|
|
403
|
-
reject(err);
|
|
404
|
-
}
|
|
405
|
-
});
|
|
406
|
-
// Timeout
|
|
407
|
-
setTimeout(() => {
|
|
408
|
-
proc.kill();
|
|
409
|
-
reject(new Error('Claude CLI timed out after 120s'));
|
|
410
|
-
}, 120_000);
|
|
411
|
-
});
|
|
412
|
-
return result;
|
|
413
|
-
} catch (err: any) {
|
|
414
|
-
throw new Error(`Claude CLI error: ${err.message}`);
|
|
415
|
-
} finally {
|
|
416
|
-
if (tmpFile) {
|
|
417
|
-
try { unlinkSync(tmpFile); } catch {}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
async *chatStream(messages: Message[], systemPrompt?: string): AsyncIterable<string> {
|
|
423
|
-
const args = ['-p', '--verbose', '--output-format', 'stream-json'];
|
|
424
|
-
if (this.model) {
|
|
425
|
-
args.push('--model', this.model);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// Write system prompt to temp file if needed
|
|
429
|
-
let tmpFile: string | undefined;
|
|
430
|
-
if (systemPrompt) {
|
|
431
|
-
const { writeFileSync } = await import('fs');
|
|
432
|
-
const { join } = await import('path');
|
|
433
|
-
const { tmpdir } = await import('os');
|
|
434
|
-
tmpFile = join(tmpdir(), `opc-claude-stream-${Date.now()}.txt`);
|
|
435
|
-
writeFileSync(tmpFile, systemPrompt);
|
|
436
|
-
args.push('--system-prompt-file', tmpFile);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
const lastMsg = messages[messages.length - 1];
|
|
440
|
-
args.push(lastMsg?.content ?? '');
|
|
441
|
-
|
|
442
|
-
const { spawn } = await import('child_process');
|
|
443
|
-
|
|
444
|
-
try {
|
|
445
|
-
const proc = spawn('claude', args, {
|
|
446
|
-
env: { ...process.env },
|
|
447
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
448
|
-
});
|
|
449
|
-
proc.stdin.end();
|
|
450
|
-
|
|
451
|
-
let buffer = '';
|
|
452
|
-
let lastContent = '';
|
|
453
|
-
|
|
454
|
-
for await (const chunk of proc.stdout) {
|
|
455
|
-
buffer += (chunk as Buffer).toString();
|
|
456
|
-
const lines = buffer.split('\n');
|
|
457
|
-
buffer = lines.pop() ?? '';
|
|
458
|
-
|
|
459
|
-
for (const line of lines) {
|
|
460
|
-
const trimmed = line.trim();
|
|
461
|
-
if (!trimmed) continue;
|
|
462
|
-
try {
|
|
463
|
-
const event = JSON.parse(trimmed);
|
|
464
|
-
// Claude CLI stream-json format:
|
|
465
|
-
// {"type":"assistant","message":{"content":[{"type":"text","text":"..."}]}}
|
|
466
|
-
if (event.type === 'assistant' && event.message?.content) {
|
|
467
|
-
for (const block of event.message.content) {
|
|
468
|
-
if (block.type === 'text' && block.text) {
|
|
469
|
-
const newContent = block.text;
|
|
470
|
-
if (newContent.length > lastContent.length) {
|
|
471
|
-
yield newContent.slice(lastContent.length);
|
|
472
|
-
lastContent = newContent;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
// Also handle result type for final content
|
|
478
|
-
if (event.type === 'result' && event.result) {
|
|
479
|
-
const remaining = event.result.slice(lastContent.length);
|
|
480
|
-
if (remaining) yield remaining;
|
|
481
|
-
}
|
|
482
|
-
// Handle assistant message with content array
|
|
483
|
-
if (event.type === 'assistant' && event.message?.content) {
|
|
484
|
-
for (const block of event.message.content) {
|
|
485
|
-
if (block.type === 'text' && block.text) {
|
|
486
|
-
const newText = block.text;
|
|
487
|
-
if (newText.length > lastContent.length) {
|
|
488
|
-
yield newText.slice(lastContent.length);
|
|
489
|
-
lastContent = newText;
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
// Handle result message
|
|
495
|
-
if (event.type === 'result' && event.result) {
|
|
496
|
-
const resultText = typeof event.result === 'string' ? event.result : '';
|
|
497
|
-
if (resultText && resultText.length > lastContent.length) {
|
|
498
|
-
yield resultText.slice(lastContent.length);
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
} catch {
|
|
502
|
-
// Not JSON, might be raw text
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
// Process remaining buffer
|
|
508
|
-
if (buffer.trim()) {
|
|
509
|
-
try {
|
|
510
|
-
const event = JSON.parse(buffer.trim());
|
|
511
|
-
if (event.type === 'result' && event.result) {
|
|
512
|
-
const resultText = typeof event.result === 'string' ? event.result : '';
|
|
513
|
-
if (resultText && resultText.length > lastContent.length) {
|
|
514
|
-
yield resultText.slice(lastContent.length);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
} catch {
|
|
518
|
-
// If not JSON, yield as raw text if we haven't yielded anything
|
|
519
|
-
if (!lastContent && buffer.trim()) {
|
|
520
|
-
yield buffer.trim();
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
await new Promise<void>((resolve) => {
|
|
526
|
-
proc.on('close', () => resolve());
|
|
527
|
-
});
|
|
528
|
-
} finally {
|
|
529
|
-
if (tmpFile) {
|
|
530
|
-
try { const { unlinkSync } = await import('fs'); unlinkSync(tmpFile); } catch {}
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
import { execSync } from 'child_process';
|
|
537
|
-
|
|
538
|
-
function detectClaudeCLI(): boolean {
|
|
539
|
-
try {
|
|
540
|
-
execSync('claude --version', { stdio: 'pipe', timeout: 3000 });
|
|
541
|
-
return true;
|
|
542
|
-
} catch { return false; }
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
function detectOllama(): boolean {
|
|
546
|
-
try {
|
|
547
|
-
// Use node http instead of curl for Windows compatibility
|
|
548
|
-
const { execSync: es } = require('child_process');
|
|
549
|
-
// Quick check: try to connect to Ollama API via node
|
|
550
|
-
const result = es(
|
|
551
|
-
`node -e "const h=require('http');const r=h.get('http://localhost:11434/api/tags',{timeout:2000},s=>{let d='';s.on('data',c=>d+=c);s.on('end',()=>{process.stdout.write(d.includes('models')?'1':'0')})});r.on('error',()=>process.stdout.write('0'));r.on('timeout',()=>{r.destroy();process.stdout.write('0')})"`,
|
|
552
|
-
{ stdio: 'pipe', timeout: 5000 }
|
|
553
|
-
);
|
|
554
|
-
return result.toString().trim() === '1';
|
|
555
|
-
} catch { return false; }
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
function detectApiKeys(): { provider: string; key: string; baseUrl?: string } | null {
|
|
559
|
-
if (process.env.ANTHROPIC_API_KEY) return { provider: 'anthropic', key: process.env.ANTHROPIC_API_KEY };
|
|
560
|
-
if (process.env.OPENAI_API_KEY && process.env.OPENAI_API_KEY !== 'your-api-key-here') return { provider: 'openai', key: process.env.OPENAI_API_KEY };
|
|
561
|
-
if (process.env.DEEPSEEK_API_KEY) return { provider: 'deepseek', key: process.env.DEEPSEEK_API_KEY, baseUrl: 'https://api.deepseek.com/v1' };
|
|
562
|
-
if (process.env.DASHSCOPE_API_KEY) return { provider: 'qwen', key: process.env.DASHSCOPE_API_KEY, baseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1' };
|
|
563
|
-
if (process.env.GEMINI_API_KEY) return { provider: 'gemini', key: process.env.GEMINI_API_KEY };
|
|
564
|
-
return null;
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
export function autoDetectProvider(): { name: string; model?: string; baseUrl?: string; apiKey?: string } {
|
|
568
|
-
// 1. Claude CLI (zero config, Claude Max/Pro subscription)
|
|
569
|
-
if (detectClaudeCLI()) {
|
|
570
|
-
return { name: 'claude-cli' };
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// 2. API keys from environment
|
|
574
|
-
const apiKey = detectApiKeys();
|
|
575
|
-
if (apiKey) {
|
|
576
|
-
return { name: apiKey.provider, apiKey: apiKey.key, baseUrl: apiKey.baseUrl };
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
// 3. Ollama (local, free)
|
|
580
|
-
if (detectOllama()) {
|
|
581
|
-
return { name: 'ollama', model: 'qwen2.5:7b' };
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
// 4. Nothing found
|
|
585
|
-
return { name: 'none' };
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
export function createProvider(name: string = 'auto', model?: string, baseUrl?: string, apiKey?: string): LLMProvider {
|
|
589
|
-
// Auto-detect if name is 'auto' or default openai with no real key
|
|
590
|
-
const needsAutoDetect = name === 'auto' || (name === 'openai' && !apiKey && (!process.env.OPENAI_API_KEY || process.env.OPENAI_API_KEY === 'your-api-key-here'));
|
|
591
|
-
if (needsAutoDetect) {
|
|
592
|
-
const detected = autoDetectProvider();
|
|
593
|
-
if (detected.name !== 'none') {
|
|
594
|
-
console.log(`[provider] Auto-detected: ${detected.name}`);
|
|
595
|
-
name = detected.name;
|
|
596
|
-
model = model || detected.model;
|
|
597
|
-
baseUrl = baseUrl || detected.baseUrl;
|
|
598
|
-
apiKey = apiKey || detected.apiKey;
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
const finalModel = model || process.env.OPC_LLM_MODEL || 'gpt-4o-mini';
|
|
603
|
-
|
|
604
|
-
// Claude CLI mode: use local claude command (Claude Max/Pro subscription)
|
|
605
|
-
if (name === 'claude-cli' || process.env.OPC_LLM_PROVIDER === 'claude-cli') {
|
|
606
|
-
return new ClaudeCLIProvider(finalModel !== 'gpt-4o-mini' ? finalModel : undefined);
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
if (name === 'ollama') {
|
|
610
|
-
const ollamaBase = baseUrl || process.env.OPC_LLM_BASE_URL || 'http://localhost:11434/v1';
|
|
611
|
-
const ollamaKey = apiKey || process.env.OPC_LLM_API_KEY || 'ollama';
|
|
612
|
-
return new OpenAICompatibleProvider('ollama', finalModel, ollamaBase, ollamaKey);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
const finalKey = apiKey || getApiKey();
|
|
616
|
-
const finalBaseUrl = baseUrl || getBaseUrl();
|
|
617
|
-
|
|
618
|
-
if (finalKey.startsWith('AQ.') || isGeminiNative()) {
|
|
619
|
-
return new GeminiNativeProvider(finalModel, finalKey);
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
let resolvedName = name;
|
|
623
|
-
if (finalBaseUrl.includes('deepseek.com')) {
|
|
624
|
-
resolvedName = 'deepseek';
|
|
625
|
-
} else if (finalBaseUrl.includes('dashscope.aliyuncs.com')) {
|
|
626
|
-
resolvedName = 'qwen';
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
return new OpenAICompatibleProvider(resolvedName, finalModel, finalBaseUrl, finalKey);
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
export const SUPPORTED_PROVIDERS = ['openai', 'ollama', 'claude-cli', 'deepseek', 'qwen', 'gemini', 'dashscope', 'zhipu', 'moonshot'] as const;
|