-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathopencode.ts
More file actions
44 lines (35 loc) · 1.13 KB
/
opencode.ts
File metadata and controls
44 lines (35 loc) · 1.13 KB
1
2
3
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
37
38
39
40
41
42
43
44
/**
* OpenCode agent adapter.
*
* Provides OpenCode-specific behavior for session tracking,
* working directory extraction, content normalization, and tool configuration.
*/
import type { Context } from "hono"
import type { AgentAdapter } from "../adapter"
import { normalizeContent } from "../messages"
import { extractClientCwd } from "../session/fingerprint"
import { BLOCKED_BUILTIN_TOOLS, CLAUDE_CODE_ONLY_TOOLS, MCP_SERVER_NAME, ALLOWED_MCP_TOOLS } from "../tools"
export const openCodeAdapter: AgentAdapter = {
name: "opencode",
getSessionId(c: Context): string | undefined {
return c.req.header("x-opencode-session")
},
extractWorkingDirectory(body: any): string | undefined {
return extractClientCwd(body)
},
normalizeContent(content: any): string {
return normalizeContent(content)
},
getBlockedBuiltinTools(): readonly string[] {
return BLOCKED_BUILTIN_TOOLS
},
getAgentIncompatibleTools(): readonly string[] {
return CLAUDE_CODE_ONLY_TOOLS
},
getMcpServerName(): string {
return MCP_SERVER_NAME
},
getAllowedMcpTools(): readonly string[] {
return ALLOWED_MCP_TOOLS
},
}