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/core/context-refs.ts
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import { execSync } from 'child_process';
|
|
4
|
-
|
|
5
|
-
export type RefType = 'file' | 'folder' | 'url' | 'git-diff' | 'git-log';
|
|
6
|
-
|
|
7
|
-
export interface ContextRef {
|
|
8
|
-
type: RefType;
|
|
9
|
-
path: string;
|
|
10
|
-
content?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface Message {
|
|
14
|
-
role: string;
|
|
15
|
-
content: string;
|
|
16
|
-
[key: string]: unknown;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const MAX_CONTENT_LENGTH = 5000;
|
|
20
|
-
|
|
21
|
-
function truncate(text: string, max: number = MAX_CONTENT_LENGTH): string {
|
|
22
|
-
if (text.length <= max) return text;
|
|
23
|
-
return text.slice(0, max) + `\n...[truncated, ${text.length - max} chars omitted]`;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export class ContextRefResolver {
|
|
27
|
-
/**
|
|
28
|
-
* Parse @-references from text without resolving content.
|
|
29
|
-
*/
|
|
30
|
-
parseRefs(text: string): ContextRef[] {
|
|
31
|
-
const refs: ContextRef[] = [];
|
|
32
|
-
const patterns: [RegExp, RefType, (m: RegExpMatchArray) => string][] = [
|
|
33
|
-
[/@file:(\S+)/g, 'file', (m) => m[1]],
|
|
34
|
-
[/@folder:(\S+)/g, 'folder', (m) => m[1]],
|
|
35
|
-
[/@url:(https?:\/\/\S+)/g, 'url', (m) => m[1]],
|
|
36
|
-
[/@git-diff\b/g, 'git-diff', () => 'git-diff'],
|
|
37
|
-
[/@git-log:(\d+)/g, 'git-log', (m) => m[1]],
|
|
38
|
-
[/@git-log\b(?!:)/g, 'git-log', () => '10'],
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
for (const [regex, type, extract] of patterns) {
|
|
42
|
-
let match: RegExpExecArray | null;
|
|
43
|
-
while ((match = regex.exec(text)) !== null) {
|
|
44
|
-
refs.push({ type, path: extract(match) });
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return refs;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Resolve content for each ref. Returns new array with content filled in.
|
|
52
|
-
*/
|
|
53
|
-
async resolveRefs(refs: ContextRef[]): Promise<ContextRef[]> {
|
|
54
|
-
return Promise.all(refs.map(async (ref) => {
|
|
55
|
-
try {
|
|
56
|
-
const content = await this.resolveOne(ref);
|
|
57
|
-
return { ...ref, content: truncate(content) };
|
|
58
|
-
} catch (err) {
|
|
59
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
60
|
-
return { ...ref, content: `[Error resolving @${ref.type}:${ref.path}]: ${msg}` };
|
|
61
|
-
}
|
|
62
|
-
}));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
private async resolveOne(ref: ContextRef): Promise<string> {
|
|
66
|
-
switch (ref.type) {
|
|
67
|
-
case 'file':
|
|
68
|
-
return fs.readFileSync(ref.path, 'utf-8');
|
|
69
|
-
case 'folder':
|
|
70
|
-
return this.listDir(ref.path);
|
|
71
|
-
case 'url':
|
|
72
|
-
return await this.fetchUrl(ref.path);
|
|
73
|
-
case 'git-diff':
|
|
74
|
-
return execSync('git diff', { encoding: 'utf-8', timeout: 10000 });
|
|
75
|
-
case 'git-log': {
|
|
76
|
-
const n = parseInt(ref.path) || 10;
|
|
77
|
-
return execSync(`git log --oneline -${n}`, { encoding: 'utf-8', timeout: 10000 });
|
|
78
|
-
}
|
|
79
|
-
default:
|
|
80
|
-
return `[Unknown ref type: ${ref.type}]`;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private listDir(dirPath: string, prefix: string = '', depth: number = 0): string {
|
|
85
|
-
if (depth > 5) return prefix + '...(max depth)\n';
|
|
86
|
-
if (!fs.existsSync(dirPath)) throw new Error(`Directory not found: ${dirPath}`);
|
|
87
|
-
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
88
|
-
let result = '';
|
|
89
|
-
for (const entry of entries) {
|
|
90
|
-
if (entry.name.startsWith('.') || entry.name === 'node_modules') continue;
|
|
91
|
-
result += `${prefix}${entry.isDirectory() ? '📁 ' : '📄 '}${entry.name}\n`;
|
|
92
|
-
if (entry.isDirectory()) {
|
|
93
|
-
result += this.listDir(path.join(dirPath, entry.name), prefix + ' ', depth + 1);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return result;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
private async fetchUrl(url: string): Promise<string> {
|
|
100
|
-
const controller = new AbortController();
|
|
101
|
-
const timeout = setTimeout(() => controller.abort(), 10000);
|
|
102
|
-
try {
|
|
103
|
-
const res = await fetch(url, { signal: controller.signal });
|
|
104
|
-
const text = await res.text();
|
|
105
|
-
return text;
|
|
106
|
-
} finally {
|
|
107
|
-
clearTimeout(timeout);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Inject resolved refs as system messages before the user's last message.
|
|
113
|
-
*/
|
|
114
|
-
injectRefs(messages: Message[], refs: ContextRef[]): Message[] {
|
|
115
|
-
if (refs.length === 0) return messages;
|
|
116
|
-
|
|
117
|
-
const resolvedRefs = refs.filter(r => r.content);
|
|
118
|
-
if (resolvedRefs.length === 0) return messages;
|
|
119
|
-
|
|
120
|
-
const contextMessages: Message[] = resolvedRefs.map(ref => ({
|
|
121
|
-
role: 'system',
|
|
122
|
-
content: `[Context from @${ref.type}:${ref.path}]\n\`\`\`\n${ref.content}\n\`\`\``,
|
|
123
|
-
}));
|
|
124
|
-
|
|
125
|
-
// Insert before the last user message
|
|
126
|
-
const result = [...messages];
|
|
127
|
-
let lastUserIdx = -1;
|
|
128
|
-
for (let i = result.length - 1; i >= 0; i--) {
|
|
129
|
-
if (result[i].role === 'user') { lastUserIdx = i; break; }
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (lastUserIdx >= 0) {
|
|
133
|
-
result.splice(lastUserIdx, 0, ...contextMessages);
|
|
134
|
-
} else {
|
|
135
|
-
result.push(...contextMessages);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return result;
|
|
139
|
-
}
|
|
140
|
-
}
|
package/src/core/errors.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OPC Agent Error Hierarchy - v1.0.0
|
|
3
|
-
* Custom error classes with user-friendly messages and recovery hints.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export class OPCError extends Error {
|
|
7
|
-
public readonly code: string;
|
|
8
|
-
public readonly hint?: string;
|
|
9
|
-
public readonly context?: Record<string, unknown>;
|
|
10
|
-
public readonly timestamp = Date.now();
|
|
11
|
-
|
|
12
|
-
constructor(message: string, opts?: { code?: string; hint?: string; context?: Record<string, unknown>; cause?: Error }) {
|
|
13
|
-
super(message);
|
|
14
|
-
this.name = 'OPCError';
|
|
15
|
-
this.code = opts?.code ?? 'OPC_UNKNOWN';
|
|
16
|
-
this.hint = opts?.hint;
|
|
17
|
-
this.context = opts?.context;
|
|
18
|
-
if (opts?.cause) this.cause = opts.cause;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
toJSON(): Record<string, unknown> {
|
|
22
|
-
return { name: this.name, code: this.code, message: this.message, hint: this.hint, context: this.context, timestamp: this.timestamp };
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
toUserMessage(): string {
|
|
26
|
-
return this.hint ? `${this.message}\n💡 ${this.hint}` : this.message;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export class ProviderError extends OPCError {
|
|
31
|
-
public readonly provider: string;
|
|
32
|
-
public readonly statusCode?: number;
|
|
33
|
-
|
|
34
|
-
constructor(provider: string, message: string, opts?: { statusCode?: number; hint?: string; cause?: Error }) {
|
|
35
|
-
super(message, {
|
|
36
|
-
code: 'OPC_PROVIDER_ERROR',
|
|
37
|
-
hint: opts?.hint ?? `Check your API key and network connection for ${provider}.`,
|
|
38
|
-
context: { provider, statusCode: opts?.statusCode },
|
|
39
|
-
cause: opts?.cause,
|
|
40
|
-
});
|
|
41
|
-
this.name = 'ProviderError';
|
|
42
|
-
this.provider = provider;
|
|
43
|
-
this.statusCode = opts?.statusCode;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export class ValidationError extends OPCError {
|
|
48
|
-
public readonly field?: string;
|
|
49
|
-
public readonly errors: string[];
|
|
50
|
-
|
|
51
|
-
constructor(message: string, errors: string[] = [], field?: string) {
|
|
52
|
-
super(message, {
|
|
53
|
-
code: 'OPC_VALIDATION_ERROR',
|
|
54
|
-
hint: 'Check your OAD configuration file for missing or invalid fields.',
|
|
55
|
-
context: { field, errors },
|
|
56
|
-
});
|
|
57
|
-
this.name = 'ValidationError';
|
|
58
|
-
this.field = field;
|
|
59
|
-
this.errors = errors;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export class ConfigError extends OPCError {
|
|
64
|
-
constructor(message: string, hint?: string) {
|
|
65
|
-
super(message, { code: 'OPC_CONFIG_ERROR', hint: hint ?? 'Check your oad.yaml and .env files.' });
|
|
66
|
-
this.name = 'ConfigError';
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export class ChannelError extends OPCError {
|
|
71
|
-
public readonly channelType: string;
|
|
72
|
-
|
|
73
|
-
constructor(channelType: string, message: string, opts?: { hint?: string; cause?: Error }) {
|
|
74
|
-
super(message, {
|
|
75
|
-
code: 'OPC_CHANNEL_ERROR',
|
|
76
|
-
hint: opts?.hint ?? `Check configuration for the ${channelType} channel.`,
|
|
77
|
-
context: { channelType },
|
|
78
|
-
cause: opts?.cause,
|
|
79
|
-
});
|
|
80
|
-
this.name = 'ChannelError';
|
|
81
|
-
this.channelType = channelType;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export class PluginError extends OPCError {
|
|
86
|
-
public readonly pluginName: string;
|
|
87
|
-
|
|
88
|
-
constructor(pluginName: string, message: string, opts?: { hint?: string; cause?: Error }) {
|
|
89
|
-
super(message, {
|
|
90
|
-
code: 'OPC_PLUGIN_ERROR',
|
|
91
|
-
hint: opts?.hint ?? `Check plugin "${pluginName}" configuration.`,
|
|
92
|
-
context: { pluginName },
|
|
93
|
-
cause: opts?.cause,
|
|
94
|
-
});
|
|
95
|
-
this.name = 'PluginError';
|
|
96
|
-
this.pluginName = pluginName;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export class RateLimitError extends OPCError {
|
|
101
|
-
public readonly retryAfterMs?: number;
|
|
102
|
-
|
|
103
|
-
constructor(message?: string, retryAfterMs?: number) {
|
|
104
|
-
super(message ?? 'Rate limit exceeded. Please slow down.', {
|
|
105
|
-
code: 'OPC_RATE_LIMIT',
|
|
106
|
-
hint: retryAfterMs ? `Try again in ${Math.ceil(retryAfterMs / 1000)} seconds.` : 'Please wait before sending more messages.',
|
|
107
|
-
context: { retryAfterMs },
|
|
108
|
-
});
|
|
109
|
-
this.name = 'RateLimitError';
|
|
110
|
-
this.retryAfterMs = retryAfterMs;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export class SecurityError extends OPCError {
|
|
115
|
-
constructor(message: string, hint?: string) {
|
|
116
|
-
super(message, { code: 'OPC_SECURITY_ERROR', hint: hint ?? 'This request was blocked for security reasons.' });
|
|
117
|
-
this.name = 'SecurityError';
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export class TimeoutError extends OPCError {
|
|
122
|
-
constructor(operation: string, timeoutMs: number) {
|
|
123
|
-
super(`Operation "${operation}" timed out after ${timeoutMs}ms`, {
|
|
124
|
-
code: 'OPC_TIMEOUT',
|
|
125
|
-
hint: 'The operation took too long. Try again or increase the timeout.',
|
|
126
|
-
context: { operation, timeoutMs },
|
|
127
|
-
});
|
|
128
|
-
this.name = 'TimeoutError';
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Wrap an unknown thrown value into an OPCError.
|
|
134
|
-
*/
|
|
135
|
-
export function wrapError(err: unknown, fallbackMessage = 'An unexpected error occurred'): OPCError {
|
|
136
|
-
if (err instanceof OPCError) return err;
|
|
137
|
-
if (err instanceof Error) return new OPCError(err.message, { cause: err });
|
|
138
|
-
return new OPCError(typeof err === 'string' ? err : fallbackMessage);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Format error for user display (no stack traces).
|
|
143
|
-
*/
|
|
144
|
-
export function formatErrorForUser(err: unknown): string {
|
|
145
|
-
if (err instanceof OPCError) return err.toUserMessage();
|
|
146
|
-
if (err instanceof Error) return err.message;
|
|
147
|
-
return String(err);
|
|
148
|
-
}
|
package/src/core/gateway.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { randomUUID } from 'crypto';
|
|
3
|
-
|
|
4
|
-
export interface AgentConfig {
|
|
5
|
-
id: string;
|
|
6
|
-
name: string;
|
|
7
|
-
model?: string;
|
|
8
|
-
skills?: string[];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface ChannelConfig {
|
|
12
|
-
id: string;
|
|
13
|
-
type: string;
|
|
14
|
-
config?: Record<string, unknown>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface GatewayConfig {
|
|
18
|
-
port: number;
|
|
19
|
-
agents: AgentConfig[];
|
|
20
|
-
channels: ChannelConfig[];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface GatewayMessage {
|
|
24
|
-
id: string;
|
|
25
|
-
content: string;
|
|
26
|
-
channel: string;
|
|
27
|
-
timestamp: number;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export class Gateway extends EventEmitter {
|
|
31
|
-
private config: GatewayConfig;
|
|
32
|
-
private agents = new Map<string, AgentConfig>();
|
|
33
|
-
private channels = new Map<string, ChannelConfig>();
|
|
34
|
-
private running = false;
|
|
35
|
-
private startTime = 0;
|
|
36
|
-
private messagesProcessed = 0;
|
|
37
|
-
private latencies: number[] = [];
|
|
38
|
-
private errors = 0;
|
|
39
|
-
|
|
40
|
-
constructor(config: GatewayConfig) {
|
|
41
|
-
super();
|
|
42
|
-
this.config = config;
|
|
43
|
-
for (const a of config.agents) this.agents.set(a.id, a);
|
|
44
|
-
for (const c of config.channels) this.channels.set(c.id, c);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async start(): Promise<void> {
|
|
48
|
-
if (this.running) throw new Error('Gateway already running');
|
|
49
|
-
this.running = true;
|
|
50
|
-
this.startTime = Date.now();
|
|
51
|
-
this.emit('started');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async stop(): Promise<void> {
|
|
55
|
-
if (!this.running) throw new Error('Gateway not running');
|
|
56
|
-
this.running = false;
|
|
57
|
-
this.emit('stopped');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async routeMessage(message: GatewayMessage, channel: string): Promise<string> {
|
|
61
|
-
if (!this.running) throw new Error('Gateway not running');
|
|
62
|
-
const start = Date.now();
|
|
63
|
-
this.messagesProcessed++;
|
|
64
|
-
// Simple round-robin routing
|
|
65
|
-
const agentIds = Array.from(this.agents.keys());
|
|
66
|
-
if (agentIds.length === 0) {
|
|
67
|
-
this.errors++;
|
|
68
|
-
throw new Error('No agents available');
|
|
69
|
-
}
|
|
70
|
-
const agentId = agentIds[this.messagesProcessed % agentIds.length];
|
|
71
|
-
this.latencies.push(Date.now() - start);
|
|
72
|
-
return agentId;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
addAgent(config: AgentConfig): void {
|
|
76
|
-
this.agents.set(config.id, config);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
removeAgent(id: string): void {
|
|
80
|
-
if (!this.agents.has(id)) throw new Error(`Agent ${id} not found`);
|
|
81
|
-
this.agents.delete(id);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
addChannel(config: ChannelConfig): void {
|
|
85
|
-
this.channels.set(config.id, config);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
getStatus(): { uptime: number; agents: number; channels: number; messagesProcessed: number } {
|
|
89
|
-
return {
|
|
90
|
-
uptime: this.running ? Date.now() - this.startTime : 0,
|
|
91
|
-
agents: this.agents.size,
|
|
92
|
-
channels: this.channels.size,
|
|
93
|
-
messagesProcessed: this.messagesProcessed,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
getMetrics(): { messagesPerMinute: number; avgLatency: number; errorRate: number } {
|
|
98
|
-
const upMinutes = this.running ? (Date.now() - this.startTime) / 60000 : 1;
|
|
99
|
-
const avgLatency = this.latencies.length ? this.latencies.reduce((a, b) => a + b, 0) / this.latencies.length : 0;
|
|
100
|
-
return {
|
|
101
|
-
messagesPerMinute: this.messagesProcessed / Math.max(upMinutes, 0.001),
|
|
102
|
-
avgLatency,
|
|
103
|
-
errorRate: this.messagesProcessed ? this.errors / this.messagesProcessed : 0,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}
|
package/src/core/heartbeat.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
export interface HeartbeatConfig {
|
|
2
|
-
interval: number;
|
|
3
|
-
checkFn: () => Promise<string>;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export class HeartbeatManager {
|
|
7
|
-
private config: HeartbeatConfig;
|
|
8
|
-
private timer: ReturnType<typeof setInterval> | null = null;
|
|
9
|
-
private callbacks: ((status: string) => void)[] = [];
|
|
10
|
-
private lastBeat: { timestamp: number; status: string } | null = null;
|
|
11
|
-
|
|
12
|
-
constructor(config: HeartbeatConfig) {
|
|
13
|
-
if (!config.interval || config.interval < 100) {
|
|
14
|
-
throw new Error('HeartbeatManager requires interval >= 100ms');
|
|
15
|
-
}
|
|
16
|
-
if (typeof config.checkFn !== 'function') {
|
|
17
|
-
throw new Error('HeartbeatManager requires checkFn');
|
|
18
|
-
}
|
|
19
|
-
this.config = config;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
start(): void {
|
|
23
|
-
if (this.timer) return;
|
|
24
|
-
this.timer = setInterval(async () => {
|
|
25
|
-
try {
|
|
26
|
-
const status = await this.config.checkFn();
|
|
27
|
-
this.lastBeat = { timestamp: Date.now(), status };
|
|
28
|
-
for (const cb of this.callbacks) cb(status);
|
|
29
|
-
} catch (err: any) {
|
|
30
|
-
const status = `error: ${err.message}`;
|
|
31
|
-
this.lastBeat = { timestamp: Date.now(), status };
|
|
32
|
-
for (const cb of this.callbacks) cb(status);
|
|
33
|
-
}
|
|
34
|
-
}, this.config.interval);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
stop(): void {
|
|
38
|
-
if (this.timer) {
|
|
39
|
-
clearInterval(this.timer);
|
|
40
|
-
this.timer = null;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
onBeat(callback: (status: string) => void): void {
|
|
45
|
-
this.callbacks.push(callback);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
getLastBeat(): { timestamp: number; status: string } | null {
|
|
49
|
-
return this.lastBeat;
|
|
50
|
-
}
|
|
51
|
-
}
|
package/src/core/hitl.ts
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { Logger } from './logger';
|
|
3
|
-
|
|
4
|
-
// ── HITL Types ──────────────────────────────────────────────
|
|
5
|
-
|
|
6
|
-
export interface ApprovalRequest {
|
|
7
|
-
id: string;
|
|
8
|
-
action: string;
|
|
9
|
-
description: string;
|
|
10
|
-
context?: Record<string, unknown>;
|
|
11
|
-
timeoutMs: number;
|
|
12
|
-
defaultAction: 'approve' | 'deny';
|
|
13
|
-
createdAt: number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface ApprovalResponse {
|
|
17
|
-
requestId: string;
|
|
18
|
-
decision: 'approve' | 'deny';
|
|
19
|
-
respondedBy?: string;
|
|
20
|
-
respondedAt: number;
|
|
21
|
-
timedOut: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type ApprovalHandler = (request: ApprovalRequest) => Promise<ApprovalResponse>;
|
|
25
|
-
|
|
26
|
-
export interface HITLConfig {
|
|
27
|
-
/** Actions that always require approval */
|
|
28
|
-
requireApproval: string[];
|
|
29
|
-
/** Default timeout in ms */
|
|
30
|
-
defaultTimeoutMs: number;
|
|
31
|
-
/** Default action on timeout */
|
|
32
|
-
defaultAction: 'approve' | 'deny';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// ── HITL Manager ────────────────────────────────────────────
|
|
36
|
-
|
|
37
|
-
export class HITLManager extends EventEmitter {
|
|
38
|
-
private config: HITLConfig;
|
|
39
|
-
private handler: ApprovalHandler | null = null;
|
|
40
|
-
private pending: Map<string, { request: ApprovalRequest; resolve: (r: ApprovalResponse) => void }> = new Map();
|
|
41
|
-
private logger = new Logger('hitl');
|
|
42
|
-
|
|
43
|
-
constructor(config?: Partial<HITLConfig>) {
|
|
44
|
-
super();
|
|
45
|
-
this.config = {
|
|
46
|
-
requireApproval: config?.requireApproval ?? [],
|
|
47
|
-
defaultTimeoutMs: config?.defaultTimeoutMs ?? 60000,
|
|
48
|
-
defaultAction: config?.defaultAction ?? 'deny',
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
setHandler(handler: ApprovalHandler): void {
|
|
53
|
-
this.handler = handler;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
needsApproval(action: string): boolean {
|
|
57
|
-
if (this.config.requireApproval.includes('*')) return true;
|
|
58
|
-
return this.config.requireApproval.includes(action);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async requestApproval(action: string, description: string, context?: Record<string, unknown>): Promise<ApprovalResponse> {
|
|
62
|
-
const request: ApprovalRequest = {
|
|
63
|
-
id: `hitl_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
|
|
64
|
-
action,
|
|
65
|
-
description,
|
|
66
|
-
context,
|
|
67
|
-
timeoutMs: this.config.defaultTimeoutMs,
|
|
68
|
-
defaultAction: this.config.defaultAction,
|
|
69
|
-
createdAt: Date.now(),
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
this.emit('approval:requested', request);
|
|
73
|
-
this.logger.info('Approval requested', { id: request.id, action });
|
|
74
|
-
|
|
75
|
-
if (this.handler) {
|
|
76
|
-
try {
|
|
77
|
-
const response = await Promise.race([
|
|
78
|
-
this.handler(request),
|
|
79
|
-
this.createTimeout(request),
|
|
80
|
-
]);
|
|
81
|
-
this.emit('approval:responded', response);
|
|
82
|
-
return response;
|
|
83
|
-
} catch {
|
|
84
|
-
return this.timeoutResponse(request);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// No handler: wait for manual response via respond()
|
|
89
|
-
return new Promise<ApprovalResponse>((resolve) => {
|
|
90
|
-
this.pending.set(request.id, { request, resolve });
|
|
91
|
-
|
|
92
|
-
setTimeout(() => {
|
|
93
|
-
if (this.pending.has(request.id)) {
|
|
94
|
-
this.pending.delete(request.id);
|
|
95
|
-
const response = this.timeoutResponse(request);
|
|
96
|
-
this.emit('approval:timeout', response);
|
|
97
|
-
resolve(response);
|
|
98
|
-
}
|
|
99
|
-
}, request.timeoutMs);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
respond(requestId: string, decision: 'approve' | 'deny', respondedBy?: string): boolean {
|
|
104
|
-
const entry = this.pending.get(requestId);
|
|
105
|
-
if (!entry) return false;
|
|
106
|
-
|
|
107
|
-
this.pending.delete(requestId);
|
|
108
|
-
const response: ApprovalResponse = {
|
|
109
|
-
requestId,
|
|
110
|
-
decision,
|
|
111
|
-
respondedBy,
|
|
112
|
-
respondedAt: Date.now(),
|
|
113
|
-
timedOut: false,
|
|
114
|
-
};
|
|
115
|
-
entry.resolve(response);
|
|
116
|
-
this.emit('approval:responded', response);
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
getPending(): ApprovalRequest[] {
|
|
121
|
-
return Array.from(this.pending.values()).map(e => e.request);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
private createTimeout(request: ApprovalRequest): Promise<ApprovalResponse> {
|
|
125
|
-
return new Promise((resolve) => {
|
|
126
|
-
setTimeout(() => resolve(this.timeoutResponse(request)), request.timeoutMs);
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
private timeoutResponse(request: ApprovalRequest): ApprovalResponse {
|
|
131
|
-
return {
|
|
132
|
-
requestId: request.id,
|
|
133
|
-
decision: request.defaultAction,
|
|
134
|
-
respondedAt: Date.now(),
|
|
135
|
-
timedOut: true,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
}
|
package/src/core/hooks.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hooks Module - v1.0.0
|
|
3
|
-
* Event hook system with priority ordering and context modification.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export type HookEvent =
|
|
7
|
-
| 'before:message' | 'after:message'
|
|
8
|
-
| 'before:tool' | 'after:tool'
|
|
9
|
-
| 'before:llm' | 'after:llm'
|
|
10
|
-
| 'before:send' | 'after:send'
|
|
11
|
-
| 'before:learn' | 'after:learn'
|
|
12
|
-
| 'before:recall' | 'after:recall'
|
|
13
|
-
| 'on:error' | 'on:start' | 'on:stop';
|
|
14
|
-
|
|
15
|
-
export const ALL_HOOK_EVENTS: HookEvent[] = [
|
|
16
|
-
'before:message', 'after:message',
|
|
17
|
-
'before:tool', 'after:tool',
|
|
18
|
-
'before:llm', 'after:llm',
|
|
19
|
-
'before:send', 'after:send',
|
|
20
|
-
'before:learn', 'after:learn',
|
|
21
|
-
'before:recall', 'after:recall',
|
|
22
|
-
'on:error', 'on:start', 'on:stop',
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
export interface HookContext {
|
|
26
|
-
[key: string]: unknown;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export type HookHandler = (ctx: HookContext) => HookContext | void | Promise<HookContext | void>;
|
|
30
|
-
|
|
31
|
-
interface RegisteredHook {
|
|
32
|
-
id: string;
|
|
33
|
-
event: HookEvent;
|
|
34
|
-
handler: HookHandler;
|
|
35
|
-
priority: number;
|
|
36
|
-
name?: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let hookIdCounter = 0;
|
|
40
|
-
|
|
41
|
-
export class HookManager {
|
|
42
|
-
private hooks: Map<HookEvent, RegisteredHook[]> = new Map();
|
|
43
|
-
|
|
44
|
-
register(event: HookEvent, handler: HookHandler, options?: { priority?: number; name?: string }): string {
|
|
45
|
-
const id = `hook_${++hookIdCounter}`;
|
|
46
|
-
const entry: RegisteredHook = {
|
|
47
|
-
id,
|
|
48
|
-
event,
|
|
49
|
-
handler,
|
|
50
|
-
priority: options?.priority ?? 100,
|
|
51
|
-
name: options?.name,
|
|
52
|
-
};
|
|
53
|
-
if (!this.hooks.has(event)) this.hooks.set(event, []);
|
|
54
|
-
const list = this.hooks.get(event)!;
|
|
55
|
-
list.push(entry);
|
|
56
|
-
list.sort((a, b) => a.priority - b.priority);
|
|
57
|
-
return id;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
unregister(id: string): boolean {
|
|
61
|
-
for (const [event, list] of this.hooks) {
|
|
62
|
-
const idx = list.findIndex(h => h.id === id);
|
|
63
|
-
if (idx !== -1) {
|
|
64
|
-
list.splice(idx, 1);
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async run(event: HookEvent, ctx: HookContext = {}): Promise<HookContext> {
|
|
72
|
-
const list = this.hooks.get(event);
|
|
73
|
-
if (!list || list.length === 0) return ctx;
|
|
74
|
-
let current = { ...ctx };
|
|
75
|
-
for (const hook of list) {
|
|
76
|
-
const result = await hook.handler(current);
|
|
77
|
-
if (result) current = { ...current, ...result };
|
|
78
|
-
}
|
|
79
|
-
return current;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
getRegistered(event?: HookEvent): { id: string; event: HookEvent; priority: number; name?: string }[] {
|
|
83
|
-
const results: { id: string; event: HookEvent; priority: number; name?: string }[] = [];
|
|
84
|
-
const events = event ? [event] : ALL_HOOK_EVENTS;
|
|
85
|
-
for (const e of events) {
|
|
86
|
-
const list = this.hooks.get(e) ?? [];
|
|
87
|
-
for (const h of list) {
|
|
88
|
-
results.push({ id: h.id, event: h.event, priority: h.priority, name: h.name });
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return results;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
clear(event?: HookEvent): void {
|
|
95
|
-
if (event) {
|
|
96
|
-
this.hooks.delete(event);
|
|
97
|
-
} else {
|
|
98
|
-
this.hooks.clear();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
hasHooks(event: HookEvent): boolean {
|
|
103
|
-
return (this.hooks.get(event)?.length ?? 0) > 0;
|
|
104
|
-
}
|
|
105
|
-
}
|