opc-agent 5.0.0-rc.13 → 5.0.0-rc.15
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/CHANGELOG.md +140 -59
- package/CONTRIBUTING.md +175 -36
- package/README.md +245 -215
- package/README.zh-CN.md +247 -145
- package/TASK.md +56 -70
- package/dist/channels/discord.d.ts.map +1 -1
- package/dist/channels/discord.js +3 -1
- package/dist/channels/discord.js.map +1 -1
- package/dist/channels/slack.d.ts.map +1 -1
- package/dist/channels/slack.js +3 -1
- package/dist/channels/slack.js.map +1 -1
- package/dist/channels/telegram.d.ts.map +1 -1
- package/dist/channels/telegram.js +12 -4
- package/dist/channels/telegram.js.map +1 -1
- package/dist/channels/web.d.ts.map +1 -1
- package/dist/channels/web.js +4 -2
- package/dist/channels/web.js.map +1 -1
- package/dist/channels/wechat.d.ts.map +1 -1
- package/dist/channels/wechat.js +3 -1
- package/dist/channels/wechat.js.map +1 -1
- package/dist/cli.js +105 -4
- package/dist/cli.js.map +1 -1
- package/dist/core/agent.d.ts +2 -0
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js +30 -3
- package/dist/core/agent.js.map +1 -1
- package/dist/core/context-assembler.d.ts.map +1 -1
- package/dist/core/context-assembler.js +4 -1
- package/dist/core/context-assembler.js.map +1 -1
- package/dist/core/context-compressor.d.ts +19 -1
- package/dist/core/context-compressor.d.ts.map +1 -1
- package/dist/core/context-compressor.js +60 -5
- package/dist/core/context-compressor.js.map +1 -1
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/output-guard.d.ts +17 -0
- package/dist/core/output-guard.d.ts.map +1 -0
- package/dist/core/output-guard.js +134 -0
- package/dist/core/output-guard.js.map +1 -0
- package/dist/core/progressive-disclosure.d.ts +17 -0
- package/dist/core/progressive-disclosure.d.ts.map +1 -0
- package/dist/core/progressive-disclosure.js +34 -0
- package/dist/core/progressive-disclosure.js.map +1 -0
- package/dist/core/runtime.d.ts +1 -0
- package/dist/core/runtime.d.ts.map +1 -1
- package/dist/core/runtime.js +115 -19
- package/dist/core/runtime.js.map +1 -1
- package/dist/deepbrain/provider.d.ts +3 -0
- package/dist/deepbrain/provider.d.ts.map +1 -1
- package/dist/deepbrain/provider.js +12 -0
- package/dist/deepbrain/provider.js.map +1 -1
- package/dist/integrations/index.d.ts +3 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +7 -0
- package/dist/integrations/index.js.map +1 -0
- package/dist/integrations/mcp-client.d.ts +20 -0
- package/dist/integrations/mcp-client.d.ts.map +1 -0
- package/dist/integrations/mcp-client.js +51 -0
- package/dist/integrations/mcp-client.js.map +1 -0
- package/dist/memory/hybrid-search.d.ts +17 -0
- package/dist/memory/hybrid-search.d.ts.map +1 -0
- package/dist/memory/hybrid-search.js +47 -0
- package/dist/memory/hybrid-search.js.map +1 -0
- package/dist/sandbox/index.d.ts +3 -0
- package/dist/sandbox/index.d.ts.map +1 -0
- package/dist/sandbox/index.js +8 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/sandbox/manager.d.ts +31 -0
- package/dist/sandbox/manager.d.ts.map +1 -0
- package/dist/sandbox/manager.js +123 -0
- package/dist/sandbox/manager.js.map +1 -0
- package/dist/security/index.d.ts +2 -0
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +3 -1
- package/dist/security/index.js.map +1 -1
- package/dist/security/injection-detector.d.ts +10 -0
- package/dist/security/injection-detector.d.ts.map +1 -0
- package/dist/security/injection-detector.js +63 -0
- package/dist/security/injection-detector.js.map +1 -0
- package/dist/studio/server.d.ts.map +1 -1
- package/dist/studio/server.js +30 -4
- package/dist/studio/server.js.map +1 -1
- package/dist/studio-ui/index.html +328 -0
- package/dist/templates/ceo-coach-socratic/AGENTS.md +21 -0
- package/dist/templates/ceo-coach-socratic/KNOWLEDGE.md +21 -0
- package/dist/templates/ceo-coach-socratic/MEMORY.md +10 -0
- package/dist/templates/ceo-coach-socratic/SOUL.md +22 -0
- package/dist/templates/ceo-coach-socratic/USER.md +15 -0
- package/dist/templates/ceo-coach-socratic/template.yaml +21 -0
- package/dist/tools/builtin/index.d.ts +1 -0
- package/dist/tools/builtin/index.d.ts.map +1 -1
- package/dist/tools/builtin/index.js +5 -2
- package/dist/tools/builtin/index.js.map +1 -1
- package/dist/tools/builtin/skill-filter.d.ts +3 -0
- package/dist/tools/builtin/skill-filter.d.ts.map +1 -0
- package/dist/tools/builtin/skill-filter.js +141 -0
- package/dist/tools/builtin/skill-filter.js.map +1 -0
- package/dist/tui/log-stream.d.ts +19 -0
- package/dist/tui/log-stream.d.ts.map +1 -0
- package/dist/tui/log-stream.js +45 -0
- package/dist/tui/log-stream.js.map +1 -0
- package/dist/workflow/engine.d.ts +41 -0
- package/dist/workflow/engine.d.ts.map +1 -0
- package/dist/workflow/engine.js +147 -0
- package/dist/workflow/engine.js.map +1 -0
- package/dist/workflow/index.d.ts +3 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +6 -0
- package/dist/workflow/index.js.map +1 -0
- package/examples/README.md +67 -22
- package/package.json +1 -1
- package/scripts/postbuild.js +11 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,59 +1,140 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## [
|
|
4
|
-
|
|
5
|
-
### New Features
|
|
6
|
-
- **
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- **
|
|
26
|
-
- **
|
|
27
|
-
-
|
|
28
|
-
- **
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
-
|
|
58
|
-
|
|
59
|
-
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [5.0.0-rc.14] - 2026-04-23
|
|
4
|
+
|
|
5
|
+
### New Features
|
|
6
|
+
- **OutputGuard** — Unified output sanitization pipeline with 6 rules: PII scrubbing, prompt-injection echo suppression, `<think>` reasoning block stripping, model identity self-disclosure detection (Claude/GPT/Gemini/etc.), jailbreak echo filtering, and sensitive-key redaction. Integrated into all 6 active channels (Telegram, Web, WeChat, Feishu, Discord, Slack) with full streaming support.
|
|
7
|
+
|
|
8
|
+
## [5.0.0-rc.13] - 2026-04-23
|
|
9
|
+
|
|
10
|
+
### New Features
|
|
11
|
+
- **Hybrid FTS5 + Semantic Search** — DeepBrain now combines SQLite FTS5 full-text search with vector embeddings for higher-recall recall queries
|
|
12
|
+
- **Skill Platform Filter** — Skills declare supported platforms; runtime skips unsupported tools automatically
|
|
13
|
+
- **TUI LogStream** — Live structured log panel inside the terminal chat UI
|
|
14
|
+
- **MCPClient stub** — MCP client interface wired into runtime (server connectivity TBD)
|
|
15
|
+
- **WorkflowEngine** — DAG-based task orchestration with step dependencies and parallel branches
|
|
16
|
+
- **SandboxManager** — Isolated execution environment for untrusted code steps
|
|
17
|
+
- **Workstation Template system** — `opc init --template <id>` scaffolds a complete agent workspace (e.g. `opc init --template ceo-coach-socratic`)
|
|
18
|
+
- **7-layer System Prompt Assembly** — Layered prompt construction: base identity → EGO.md → SOUL.md → CONTEXT.md → memory → skills → conversation history
|
|
19
|
+
- **DeepBrain Auto-import** — Knowledge base is automatically populated on `opc brain learn`
|
|
20
|
+
- **DeepBrain Recall in Conversations** — Every conversation turn runs a semantic prefetch against DeepBrain and injects relevant memories into context
|
|
21
|
+
|
|
22
|
+
## [5.0.0-rc.12] - 2026-04-22
|
|
23
|
+
|
|
24
|
+
### New Features
|
|
25
|
+
- **FailoverProvider** — Automatic LLM provider failover with configurable priority order and circuit-breaker
|
|
26
|
+
- **HeartbeatMonitor** — Per-provider liveness probes; removes unhealthy providers from rotation
|
|
27
|
+
- **`create_skill` tool** — Agent self-writes new skills at runtime; persisted to disk and hot-reloaded
|
|
28
|
+
- **InsightsExtractor** — Structured extraction of entities, decisions, and action items from conversation turns
|
|
29
|
+
- **SubAgentManager** — Spawn, track, and aggregate results from parallel sub-agents
|
|
30
|
+
- **SessionEventEmitter** — Internal event bus for session lifecycle hooks (start, turn, end, error)
|
|
31
|
+
- **InjectionDetector** — Heuristic + pattern-based prompt injection detection layer
|
|
32
|
+
- **ProgressiveDisclosure** — Truncates lengthy tool outputs; exposes `show more` expansion in TUI
|
|
33
|
+
- **ContextCompressor V2** — Token-aware summarisation with configurable compression ratio and anchor preservation
|
|
34
|
+
|
|
35
|
+
## [5.0.0-rc.11] - 2026-04-22
|
|
36
|
+
|
|
37
|
+
### New Features
|
|
38
|
+
- **Provider Failover** — LLM provider switching on transient errors; retries with exponential back-off
|
|
39
|
+
- **Prompt Injection Detection** — Early-stage detection of adversarial inputs before they reach the model
|
|
40
|
+
|
|
41
|
+
## [5.0.0-rc.10]
|
|
42
|
+
|
|
43
|
+
### New Features
|
|
44
|
+
- **P1 Orchestration** — Memory prefetch/sync, context window guard (auto-truncation before overflow), cron job delivery to channels, DeepBrain recall wired into every turn
|
|
45
|
+
|
|
46
|
+
## [5.0.0-rc.9]
|
|
47
|
+
|
|
48
|
+
### New Features
|
|
49
|
+
- **P0 Orchestration** — SQLite conversation history persistence, context compaction (summarise-and-truncate), isolated cron scheduler
|
|
50
|
+
- **Pipe Mode Tool Loop** — `opc run --pipe` accepts newline-delimited JSON tasks; agent executes tool loop and writes JSON results to stdout
|
|
51
|
+
- **Skill Loader Integration** — Runtime discovers and loads skills from `~/.opc/skills/` and project-local `skills/` on startup
|
|
52
|
+
|
|
53
|
+
## [5.0.0-rc.5]
|
|
54
|
+
|
|
55
|
+
### Improvements
|
|
56
|
+
- **Banner v2** — High-fidelity ASCII-art splash with version and hardware stats
|
|
57
|
+
- **TUI Markdown Enhancement** — Tables, code fences, and inline styles rendered natively in terminal
|
|
58
|
+
|
|
59
|
+
## [5.0.0-rc.3]
|
|
60
|
+
|
|
61
|
+
### New Features
|
|
62
|
+
- **TUI Markdown Rendering** — Full CommonMark rendering in `opc chat` terminal UI
|
|
63
|
+
|
|
64
|
+
## [5.0.0-rc.2]
|
|
65
|
+
|
|
66
|
+
### New Features
|
|
67
|
+
- **Interactive Tool Calling** — Tools are confirmed and displayed live inside the TUI before execution
|
|
68
|
+
|
|
69
|
+
## [5.0.0-rc.1] - 2026-04-20
|
|
70
|
+
|
|
71
|
+
### Major Release — Complete v5 Rewrite
|
|
72
|
+
- All-in-one architecture merging **DeepBrain** (knowledge) + **AgentKits** (model routing) + **Workstation** (templates) into a single package
|
|
73
|
+
- 1114 tests passing
|
|
74
|
+
- TypeScript 5.x, CommonJS module format, Node.js 18+ required
|
|
75
|
+
- Declarative `oad.yaml` agent definition replaces legacy JSON config
|
|
76
|
+
- New self-evolution engine: L1 Experience Compile → L2 Memory Consolidate → L3 Skill Discovery → L4 Group Evolution
|
|
77
|
+
|
|
78
|
+
## [5.0.0-alpha.1]
|
|
79
|
+
|
|
80
|
+
- Initial v5 alpha — early preview of the rewritten architecture
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## [4.2.0] - 2026-04-21
|
|
85
|
+
|
|
86
|
+
### New Features
|
|
87
|
+
- **Priority Queue / Fast Mode** — Priority-aware request routing with per-session `/fast` toggle. Fast-mode requests are processed first and routed through provider priority endpoints (OpenAI, Anthropic, Google). Includes concurrency control, batch tier, and custom provider endpoint registration.
|
|
88
|
+
- **Gateway Registry** — Advanced multi-gateway tool provider pattern. Register multiple remote tool gateways with subscription-based access, per-tool quota tracking, auto-retry with backoff, and unified invocation routing across gateways. Complements the existing single-gateway `ToolGateway`.
|
|
89
|
+
|
|
90
|
+
### Improvements
|
|
91
|
+
- New `FastModeManager` for per-session priority state management
|
|
92
|
+
- `PriorityQueue` with weighted dequeue, provider concurrency limits, and drain support
|
|
93
|
+
- `ToolGatewayRegistry` for routing tool calls across multiple gateway providers
|
|
94
|
+
|
|
95
|
+
## [2.0.0] - 2026-04-18
|
|
96
|
+
|
|
97
|
+
### Major Features
|
|
98
|
+
- **Interactive CLI** (`opc chat`) — Full TUI with streaming, slash commands, history
|
|
99
|
+
- **Daemon Mode** (`opc start/stop/status`) — Run agents as background processes
|
|
100
|
+
- **Cron Scheduler** — Built-in job scheduling with cron expressions
|
|
101
|
+
- **Autonomous Skill Learning** — Agents create and improve skills from experience
|
|
102
|
+
- **Sub-Agent System** — Spawn parallel sub-agents for task delegation
|
|
103
|
+
- **Built-in Tools** — File operations, web fetch, shell exec, datetime
|
|
104
|
+
- **MCP Client** — Connect to external MCP servers via JSON-RPC
|
|
105
|
+
- **Telegram Channel** — Dual-mode (polling + webhook) with Markdown support
|
|
106
|
+
- **Discord Channel** — Gateway WebSocket with auto-reconnect
|
|
107
|
+
- **Slack Channel** — Real Events API + chat.postMessage
|
|
108
|
+
- **SOUL.md + CONTEXT.md** — Agent personality and project context files
|
|
109
|
+
- **Analytics** — Wired into runtime for message tracking, skill usage, errors
|
|
110
|
+
|
|
111
|
+
### Enhanced
|
|
112
|
+
- `/health` endpoint returns comprehensive agent info
|
|
113
|
+
- `opc init` generates SOUL.md, CONTEXT.md, and richer project templates
|
|
114
|
+
- OAD config supports scheduler, learning, and tools sections
|
|
115
|
+
- 204 tests passing
|
|
116
|
+
|
|
117
|
+
### CLI Commands
|
|
118
|
+
init, chat, run, dev, start, stop, status, jobs, skills, info, build, test, analytics, brain, logs, score, search, deploy, publish, install, plugin, tool, workflow, migrate
|
|
119
|
+
|
|
120
|
+
## [1.4.0] - 2026-04-18
|
|
121
|
+
- feat: wire Analytics into AgentRuntime (message timing, skill usage, error tracking)
|
|
122
|
+
- feat: expose analytics snapshot on /health and /api/dashboard endpoints
|
|
123
|
+
- feat: enhanced /health endpoint with agent name, version, uptime, memory type, skills, channels
|
|
124
|
+
- feat: Slack channel — real Events API webhook server + chat.postMessage via fetch
|
|
125
|
+
- feat: WebChannel metadata setters (version, memory type, skills, channels, analytics provider)
|
|
126
|
+
- feat: AgentRuntime.getAnalytics() and getConfig() accessors
|
|
127
|
+
|
|
128
|
+
## [1.3.1] - 2026-04-17
|
|
129
|
+
- fix: remove residual DTV/marketplace references
|
|
130
|
+
- fix: duplicate WatchPattern export
|
|
131
|
+
|
|
132
|
+
## [1.3.0] - 2026-04-17
|
|
133
|
+
- feat: Traces collection (OpenTelemetry-style)
|
|
134
|
+
- feat: DeepBrain exporter
|
|
135
|
+
- feat: brain/logs/score CLI commands
|
|
136
|
+
|
|
137
|
+
## [1.2.0]
|
|
138
|
+
- Initial public release
|
|
139
|
+
- 11 channels, plugins, analytics
|
|
140
|
+
- Declarative OAD configuration
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,36 +1,175 @@
|
|
|
1
|
-
# Contributing
|
|
2
|
-
|
|
3
|
-
Thanks for your interest in contributing!
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
# Contributing to OPC Agent
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing! This guide covers everything you need to get started.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Development Setup
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# 1. Fork and clone
|
|
11
|
+
git clone https://github.com/Deepleaper/opc-agent.git
|
|
12
|
+
cd opc-agent
|
|
13
|
+
|
|
14
|
+
# 2. Install dependencies
|
|
15
|
+
npm install
|
|
16
|
+
|
|
17
|
+
# 3. Build (TypeScript → CommonJS)
|
|
18
|
+
npx tsc
|
|
19
|
+
|
|
20
|
+
# 4. Run tests
|
|
21
|
+
npx vitest run
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
> **Note:** This is a **CommonJS** project (not ESM). All output goes to `dist/`. TypeScript 5.x is required. There are **no native dependencies** — the project uses `sql.js` (WASM) instead of `better-sqlite3` so it works on all platforms without compilation.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Project Structure
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
src/
|
|
32
|
+
core/ # Agent loop, runtime, session management, OutputGuard
|
|
33
|
+
channels/ # One file per channel: telegram.ts, web.ts, slack.ts, …
|
|
34
|
+
memory/ # DeepBrainMemoryStore, InMemoryStore, vector search
|
|
35
|
+
tools/ # Built-in tools (file ops, web fetch, shell exec, etc.)
|
|
36
|
+
schema/ # Zod schemas and shared TypeScript types
|
|
37
|
+
skills/ # Skill loader, BaseSkill, SkillPlatformFilter
|
|
38
|
+
evolution/ # L1–L4 self-evolution engine
|
|
39
|
+
workflow/ # WorkflowEngine, SandboxManager, SubAgentManager
|
|
40
|
+
cli/ # CLI entry point and command handlers
|
|
41
|
+
|
|
42
|
+
examples/ # Runnable usage examples
|
|
43
|
+
test/ # Test files, co-located with source or in test/
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Testing
|
|
49
|
+
|
|
50
|
+
The project has **1114+ tests** covering unit, integration, and end-to-end scenarios.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Run all tests
|
|
54
|
+
npx vitest run
|
|
55
|
+
|
|
56
|
+
# Run in watch mode during development
|
|
57
|
+
npx vitest
|
|
58
|
+
|
|
59
|
+
# Run a specific test file
|
|
60
|
+
npx vitest run src/core/output-guard.test.ts
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Conventions:**
|
|
64
|
+
- Test files live next to the code they test (`foo.ts` → `foo.test.ts`) or under `test/`.
|
|
65
|
+
- Use `describe` / `it` / `expect` from Vitest — no Jest imports.
|
|
66
|
+
- Mock at the boundary: stub external HTTP calls and file I/O, but don't mock internal modules unless unavoidable.
|
|
67
|
+
- Every new feature or bug fix must include a corresponding test.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Adding a Channel
|
|
72
|
+
|
|
73
|
+
Channels live in `src/channels/`. Each channel extends `BaseChannel` and plugs into the `AgentRuntime`.
|
|
74
|
+
|
|
75
|
+
1. **Create the file**: `src/channels/my-channel.ts`
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { BaseChannel, type OutboundMessage } from '../core/base-channel';
|
|
79
|
+
|
|
80
|
+
export class MyChannel extends BaseChannel {
|
|
81
|
+
readonly name = 'my-channel';
|
|
82
|
+
|
|
83
|
+
async start(): Promise<void> {
|
|
84
|
+
// Connect to the external service
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async stop(): Promise<void> {
|
|
88
|
+
// Disconnect cleanly
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
protected async send(message: OutboundMessage): Promise<void> {
|
|
92
|
+
// Deliver the message — OutputGuard has already run at this point
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
2. **Register it** in `src/core/runtime.ts` alongside existing channels.
|
|
98
|
+
|
|
99
|
+
3. **Add a test** in `src/channels/my-channel.test.ts`.
|
|
100
|
+
|
|
101
|
+
4. **Document it** in the CLI table in `README.md` and `README.zh-CN.md`.
|
|
102
|
+
|
|
103
|
+
> OutputGuard runs automatically on every message before `send()` is called — you do not need to add sanitization logic in your channel.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Adding a Built-in Tool
|
|
108
|
+
|
|
109
|
+
Built-in tools live in `src/tools/`. Each tool implements the `BuiltinTool` interface and is auto-discovered at runtime.
|
|
110
|
+
|
|
111
|
+
1. **Create the file**: `src/tools/my-tool.ts`
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { type BuiltinTool, type ToolResult } from '../schema/tool';
|
|
115
|
+
|
|
116
|
+
export const myTool: BuiltinTool = {
|
|
117
|
+
name: 'my_tool',
|
|
118
|
+
description: 'What this tool does, for the model to read',
|
|
119
|
+
parameters: {
|
|
120
|
+
type: 'object',
|
|
121
|
+
properties: {
|
|
122
|
+
input: { type: 'string', description: 'The input value' },
|
|
123
|
+
},
|
|
124
|
+
required: ['input'],
|
|
125
|
+
},
|
|
126
|
+
async execute(args: { input: string }): Promise<ToolResult> {
|
|
127
|
+
return { content: `Result: ${args.input}` };
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
2. **Export it** from `src/tools/index.ts`.
|
|
133
|
+
|
|
134
|
+
3. **Add a test** in `src/tools/my-tool.test.ts`.
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Commit Convention
|
|
139
|
+
|
|
140
|
+
| Prefix | Use for |
|
|
141
|
+
|--------|---------|
|
|
142
|
+
| `feat:` | New feature |
|
|
143
|
+
| `fix:` | Bug fix |
|
|
144
|
+
| `docs:` | Documentation only |
|
|
145
|
+
| `test:` | Tests only |
|
|
146
|
+
| `refactor:` | Code restructuring without behavior change |
|
|
147
|
+
| `chore:` | Build, tooling, dependencies |
|
|
148
|
+
|
|
149
|
+
Examples:
|
|
150
|
+
```
|
|
151
|
+
feat: add WeChat Work channel
|
|
152
|
+
fix: OutputGuard false-positive on base64 strings
|
|
153
|
+
docs: add channel mini-guide to CONTRIBUTING
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Pull Request Checklist
|
|
159
|
+
|
|
160
|
+
- [ ] `npx tsc` passes with no errors
|
|
161
|
+
- [ ] `npx vitest run` — all tests pass, new tests added
|
|
162
|
+
- [ ] No `.js` output files committed (build artifacts are gitignored)
|
|
163
|
+
- [ ] Docs updated if you added or changed a public API or CLI command
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Questions?
|
|
168
|
+
|
|
169
|
+
Open a [Discussion](https://github.com/Deepleaper/opc-agent/discussions) for design questions or [Issues](https://github.com/Deepleaper/opc-agent/issues) for bugs.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
By contributing, you agree that your contributions will be licensed under **Apache-2.0**.
|