opencode-acp-provider 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -19
- package/package.json +3 -2
- package/src/acp-client.ts +67 -4
- package/src/acp-tools/antigravity.ts +117 -0
- package/src/acp-tools/claude.ts +105 -0
- package/src/acp-tools/codex.ts +204 -0
- package/src/acp-tools/command-code.ts +135 -0
- package/src/acp-tools/fallback.ts +92 -0
- package/src/acp-tools/shared.ts +436 -0
- package/src/acp-tools.ts +119 -241
- package/src/agent-command.ts +1 -1
- package/src/agent-pool.ts +5 -1
- package/src/index.ts +132 -47
- package/src/inventory.ts +14 -0
- package/src/language-model.ts +27 -13
- package/src/mcp-server.ts +73 -55
- package/src/prompt.ts +22 -5
- package/src/server-manager.ts +517 -74
- package/src/shim.ts +75 -35
- package/src/unsolicited.ts +388 -0
- package/src/mcp-config.ts +0 -198
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type { DiffItem, PatchEntry, ResolvedTool, ToolContext } from "./shared.ts"
|
|
2
|
+
import {
|
|
3
|
+
commandOf,
|
|
4
|
+
editInput,
|
|
5
|
+
firstText,
|
|
6
|
+
grepInput,
|
|
7
|
+
isOpencodeQuestionName,
|
|
8
|
+
patchInput,
|
|
9
|
+
questionInput,
|
|
10
|
+
readInput,
|
|
11
|
+
record,
|
|
12
|
+
shellInput,
|
|
13
|
+
text,
|
|
14
|
+
websearchInput,
|
|
15
|
+
writeInput,
|
|
16
|
+
} from "./shared.ts"
|
|
17
|
+
|
|
18
|
+
const CODEX_NAMES = new Set(["exec_command", "write_stdin", "view_image", "request_permissions"])
|
|
19
|
+
|
|
20
|
+
function diffKind(diff: DiffItem) {
|
|
21
|
+
return diff.kind ?? (diff.oldText === null ? "add" : diff.newText === "" ? "delete" : "update")
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function patchEntries(diffs: DiffItem[]): PatchEntry[] {
|
|
25
|
+
const entries: PatchEntry[] = []
|
|
26
|
+
const updates = new Map<string, Extract<PatchEntry, { kind: "update" }>>()
|
|
27
|
+
for (const diff of diffs) {
|
|
28
|
+
const kind = diffKind(diff)
|
|
29
|
+
const path = diff.path ?? ""
|
|
30
|
+
if (kind === "add") {
|
|
31
|
+
entries.push({ kind: "add", path, content: diff.newText ?? "" })
|
|
32
|
+
continue
|
|
33
|
+
}
|
|
34
|
+
if (kind === "delete") {
|
|
35
|
+
entries.push({ kind: "delete", path })
|
|
36
|
+
continue
|
|
37
|
+
}
|
|
38
|
+
let entry = updates.get(path)
|
|
39
|
+
if (!entry) {
|
|
40
|
+
entry = { kind: "update", path, chunks: [] }
|
|
41
|
+
updates.set(path, entry)
|
|
42
|
+
entries.push(entry)
|
|
43
|
+
}
|
|
44
|
+
entry.chunks.push({ oldText: diff.oldText ?? "", newText: diff.newText ?? "" })
|
|
45
|
+
}
|
|
46
|
+
return entries
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function resolveCodex(ctx: ToolContext): ResolvedTool | undefined {
|
|
50
|
+
const raw = ctx.raw
|
|
51
|
+
const title = ctx.title
|
|
52
|
+
const meta = record(ctx.update._meta)
|
|
53
|
+
|
|
54
|
+
if (meta?.is_mcp_tool_call === true || title?.startsWith("mcp.")) {
|
|
55
|
+
if (isOpencodeQuestionName(title) || (raw?.server === "opencode" && raw?.tool === "question")) {
|
|
56
|
+
return {
|
|
57
|
+
agent: "codex",
|
|
58
|
+
rawName: title ?? "mcp.opencode.question",
|
|
59
|
+
name: "question",
|
|
60
|
+
input: questionInput(raw),
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const server = firstText(raw?.server)
|
|
64
|
+
const tool = firstText(raw?.tool)
|
|
65
|
+
const mcpName = title ?? (server && tool ? `mcp.${server}.${tool}` : "mcp")
|
|
66
|
+
return { agent: "codex", rawName: mcpName, name: mcpName, input: raw ? { ...raw } : {} }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const webSearchTitle = title?.match(/^Web search(?::\s*(.*))?$/)
|
|
70
|
+
const action = record(raw?.action)
|
|
71
|
+
const actionQueries = action?.queries
|
|
72
|
+
if (
|
|
73
|
+
raw?.type === "webSearch" ||
|
|
74
|
+
(ctx.kind === "search" && ((raw !== undefined && "action" in raw) || Boolean(webSearchTitle)))
|
|
75
|
+
) {
|
|
76
|
+
const query =
|
|
77
|
+
firstText(
|
|
78
|
+
raw?.query,
|
|
79
|
+
action?.query,
|
|
80
|
+
Array.isArray(actionQueries)
|
|
81
|
+
? actionQueries.find((value) => typeof value === "string" && value.trim())
|
|
82
|
+
: undefined,
|
|
83
|
+
) ?? text(webSearchTitle?.[1])
|
|
84
|
+
return { agent: "codex", rawName: "webSearch", name: "websearch", input: websearchInput({ query }) }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (ctx.topName && !CODEX_NAMES.has(ctx.topName)) {
|
|
88
|
+
// A dynamic tool call arrives as `{ arguments }` and keeps its own name.
|
|
89
|
+
if (ctx.kind === "execute" && raw && Object.keys(raw).length === 1 && "arguments" in raw) {
|
|
90
|
+
const name = title ?? ctx.topName
|
|
91
|
+
return { agent: "codex", rawName: name, name, input: { ...raw } }
|
|
92
|
+
}
|
|
93
|
+
return undefined
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const imageTitle = title?.match(/^View Image\s+(.+)$/)
|
|
97
|
+
if (ctx.topName === "view_image" || (ctx.kind === "read" && imageTitle)) {
|
|
98
|
+
return {
|
|
99
|
+
agent: "codex",
|
|
100
|
+
rawName: "view_image",
|
|
101
|
+
name: "read",
|
|
102
|
+
input: readInput({ path: firstText(raw?.path) ?? ctx.locationPath ?? text(imageTitle?.[1]) }),
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (
|
|
107
|
+
ctx.kind === "edit" &&
|
|
108
|
+
(title === "Editing files" ||
|
|
109
|
+
title === "Edit files" ||
|
|
110
|
+
(ctx.priorAgent === "codex" && ctx.priorRawName === "fileChange"))
|
|
111
|
+
) {
|
|
112
|
+
const diffs = ctx.diffs
|
|
113
|
+
if (diffs.length === 0) return { agent: "codex", rawName: "fileChange", name: "edit", input: {} }
|
|
114
|
+
if (diffs.length === 1) {
|
|
115
|
+
const diff = diffs[0]
|
|
116
|
+
const kind = diffKind(diff)
|
|
117
|
+
if (kind === "add") {
|
|
118
|
+
return {
|
|
119
|
+
agent: "codex",
|
|
120
|
+
rawName: "fileChange",
|
|
121
|
+
name: "write",
|
|
122
|
+
input: writeInput({ path: diff.path, content: diff.newText ?? "" }),
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (kind === "delete") {
|
|
126
|
+
return {
|
|
127
|
+
agent: "codex",
|
|
128
|
+
rawName: "fileChange",
|
|
129
|
+
name: "patch",
|
|
130
|
+
input: patchInput(diff.path ? [{ kind: "delete", path: diff.path }] : []),
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
agent: "codex",
|
|
135
|
+
rawName: "fileChange",
|
|
136
|
+
name: "edit",
|
|
137
|
+
input: editInput({ path: diff.path, oldString: diff.oldText ?? "", newString: diff.newText ?? "" }),
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return { agent: "codex", rawName: "fileChange", name: "patch", input: patchInput(patchEntries(diffs)) }
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const readPath =
|
|
144
|
+
text(title?.match(/^Read file '(.+)'$/)?.[1]) ?? text(title?.match(/^List files in '(.+)'$/)?.[1])
|
|
145
|
+
if (
|
|
146
|
+
ctx.kind === "read" &&
|
|
147
|
+
(ctx.topName === "exec_command" || title === "Read file" || title === "List files" || Boolean(readPath))
|
|
148
|
+
) {
|
|
149
|
+
return {
|
|
150
|
+
agent: "codex",
|
|
151
|
+
rawName: ctx.topName ?? "read",
|
|
152
|
+
name: "read",
|
|
153
|
+
input: readInput({ path: ctx.locationPath ?? firstText(raw?.path) ?? readPath }),
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (
|
|
158
|
+
ctx.kind === "search" &&
|
|
159
|
+
!title?.startsWith("Search:") &&
|
|
160
|
+
(ctx.topName === "exec_command" || title === "Search" || Boolean(title?.match(/^Search (?:for|in) /)))
|
|
161
|
+
) {
|
|
162
|
+
const forIn = title?.match(/^Search for '(.+)' in (.+)$/)
|
|
163
|
+
const forOnly = title?.match(/^Search for '(.+)'$/)
|
|
164
|
+
const inOnly = title?.match(/^Search in '(.+)'$/)
|
|
165
|
+
const query = text(forIn?.[1]) ?? text(forOnly?.[1])
|
|
166
|
+
const searchPath = text(forIn?.[2]) ?? text(inOnly?.[1])
|
|
167
|
+
return {
|
|
168
|
+
agent: "codex",
|
|
169
|
+
rawName: ctx.topName ?? "search",
|
|
170
|
+
name: "grep",
|
|
171
|
+
input: grepInput({
|
|
172
|
+
pattern: firstText(raw?.query, raw?.pattern) ?? query,
|
|
173
|
+
path: firstText(raw?.path) ?? ctx.locationPath ?? searchPath,
|
|
174
|
+
}),
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const commandCodeShell =
|
|
179
|
+
title?.startsWith("Shell:") ||
|
|
180
|
+
title?.startsWith("Monitor:") ||
|
|
181
|
+
title?.startsWith("Command:") ||
|
|
182
|
+
title?.toLowerCase().startsWith("powershell")
|
|
183
|
+
if (
|
|
184
|
+
ctx.kind === "execute" &&
|
|
185
|
+
!commandCodeShell &&
|
|
186
|
+
!title?.startsWith("mcp__") &&
|
|
187
|
+
!(raw && ("timeout" in raw || "run_in_background" in raw)) &&
|
|
188
|
+
(ctx.topName === "exec_command" ||
|
|
189
|
+
ctx.topName === "write_stdin" ||
|
|
190
|
+
(raw !== undefined && "command" in raw))
|
|
191
|
+
) {
|
|
192
|
+
return {
|
|
193
|
+
agent: "codex",
|
|
194
|
+
rawName: ctx.topName ?? "exec_command",
|
|
195
|
+
name: "shell",
|
|
196
|
+
input: shellInput({ command: commandOf(raw?.command), workdir: firstText(raw?.cwd, raw?.workdir) }),
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (ctx.kind === "execute" && raw && Object.keys(raw).length === 1 && "arguments" in raw && title) {
|
|
201
|
+
return { agent: "codex", rawName: title, name: title, input: { ...raw } }
|
|
202
|
+
}
|
|
203
|
+
return undefined
|
|
204
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { ResolvedTool, ToolContext } from "./shared.ts"
|
|
2
|
+
import {
|
|
3
|
+
booleanOf,
|
|
4
|
+
commandOf,
|
|
5
|
+
editInput,
|
|
6
|
+
executeInput,
|
|
7
|
+
finiteNumber,
|
|
8
|
+
firstText,
|
|
9
|
+
globInput,
|
|
10
|
+
grepInput,
|
|
11
|
+
isOpencodeQuestionName,
|
|
12
|
+
literal,
|
|
13
|
+
questionInput,
|
|
14
|
+
readInput,
|
|
15
|
+
shellInput,
|
|
16
|
+
skillInput,
|
|
17
|
+
text,
|
|
18
|
+
webfetchInput,
|
|
19
|
+
websearchInput,
|
|
20
|
+
writeInput,
|
|
21
|
+
} from "./shared.ts"
|
|
22
|
+
|
|
23
|
+
/** Command Code titles a card with its tool label, sometimes followed by detail. */
|
|
24
|
+
function hasLabel(title: string | undefined, label: string): boolean {
|
|
25
|
+
return title === label || Boolean(title?.startsWith(`${label}:`))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function resolveCommandCode(ctx: ToolContext): ResolvedTool | undefined {
|
|
29
|
+
const raw = ctx.raw
|
|
30
|
+
const title = ctx.title
|
|
31
|
+
const resolved = (name: string, input: Record<string, unknown>): ResolvedTool => ({
|
|
32
|
+
agent: "command-code",
|
|
33
|
+
name,
|
|
34
|
+
input,
|
|
35
|
+
})
|
|
36
|
+
const unchanged = (name: string): ResolvedTool => resolved(name, raw ? { ...raw } : {})
|
|
37
|
+
|
|
38
|
+
if (
|
|
39
|
+
hasLabel(title, "Shell") ||
|
|
40
|
+
hasLabel(title, "Monitor") ||
|
|
41
|
+
hasLabel(title, "Command") ||
|
|
42
|
+
title === "shell_command" ||
|
|
43
|
+
title === "monitor_command" ||
|
|
44
|
+
title === "run_command" ||
|
|
45
|
+
title === "powershell" ||
|
|
46
|
+
hasLabel(title, "powershell") ||
|
|
47
|
+
hasLabel(title, "PowerShell")
|
|
48
|
+
) {
|
|
49
|
+
return resolved(
|
|
50
|
+
"shell",
|
|
51
|
+
shellInput({
|
|
52
|
+
command: commandOf(raw?.command),
|
|
53
|
+
workdir: firstText(raw?.cwd, raw?.workdir),
|
|
54
|
+
timeout: finiteNumber(raw?.timeout),
|
|
55
|
+
background: booleanOf(raw?.run_in_background),
|
|
56
|
+
}),
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
if (hasLabel(title, "Kill") || title === "kill_shell") return unchanged("kill_shell")
|
|
60
|
+
if (title === "monitor_events" || title === "shell_tasks" || title === "bash_output") return unchanged(title)
|
|
61
|
+
if (
|
|
62
|
+
title === "read_multiple_files" ||
|
|
63
|
+
(hasLabel(title, "Read") &&
|
|
64
|
+
(Array.isArray(raw?.paths) || (Array.isArray(raw?.include) && typeof raw?.file_path !== "string")))
|
|
65
|
+
) {
|
|
66
|
+
return unchanged("read_multiple_files")
|
|
67
|
+
}
|
|
68
|
+
if (title === "Diagnostics" || title === "get_diagnostics") return unchanged("get_diagnostics")
|
|
69
|
+
if (hasLabel(title, "Read") || hasLabel(title, "List") || title === "read_file" || title === "read_directory") {
|
|
70
|
+
const path = firstText(raw?.file_path, raw?.path) ?? ctx.locationPath
|
|
71
|
+
const offset = finiteNumber(raw?.offset)
|
|
72
|
+
const limit = finiteNumber(raw?.limit)
|
|
73
|
+
// A negative offset asks OpenCode's read tool for the tail of the file;
|
|
74
|
+
// sending it would reject the card, so keep only the path and read it whole.
|
|
75
|
+
return resolved("read", offset !== undefined && offset < 0 ? readInput({ path }) : readInput({ path, offset, limit }))
|
|
76
|
+
}
|
|
77
|
+
if (hasLabel(title, "Edit") || title === "edit_file") {
|
|
78
|
+
return resolved(
|
|
79
|
+
"edit",
|
|
80
|
+
editInput({
|
|
81
|
+
path: firstText(raw?.file_path, raw?.path) ?? ctx.locationPath,
|
|
82
|
+
oldString: literal(raw?.old_string),
|
|
83
|
+
newString: literal(raw?.new_string),
|
|
84
|
+
replaceAll: booleanOf(raw?.replace_all),
|
|
85
|
+
}),
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
if (hasLabel(title, "Write") || title === "write_file") {
|
|
89
|
+
return resolved(
|
|
90
|
+
"write",
|
|
91
|
+
writeInput({ path: firstText(raw?.file_path, raw?.path) ?? ctx.locationPath, content: literal(raw?.content) }),
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
if (hasLabel(title, "Search") || title === "grep" || title === "web_search") {
|
|
95
|
+
if (title === "web_search" || (text(raw?.query) !== undefined && raw?.pattern === undefined)) {
|
|
96
|
+
return resolved("websearch", websearchInput({ query: text(raw?.query) }))
|
|
97
|
+
}
|
|
98
|
+
const headLimit = finiteNumber(raw?.head_limit)
|
|
99
|
+
const caseInsensitive = raw?.["-i"]
|
|
100
|
+
return resolved(
|
|
101
|
+
"grep",
|
|
102
|
+
grepInput({
|
|
103
|
+
pattern: text(raw?.pattern),
|
|
104
|
+
path: firstText(raw?.path) ?? ctx.locationPath,
|
|
105
|
+
include: text(raw?.glob),
|
|
106
|
+
caseSensitive: typeof caseInsensitive === "boolean" ? !caseInsensitive : undefined,
|
|
107
|
+
limit: headLimit !== undefined && headLimit > 0 ? headLimit : undefined,
|
|
108
|
+
}),
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
if (hasLabel(title, "Glob") || title === "glob") {
|
|
112
|
+
return resolved(
|
|
113
|
+
"glob",
|
|
114
|
+
globInput({ pattern: text(raw?.pattern), path: firstText(raw?.path) ?? ctx.locationPath, limit: finiteNumber(raw?.limit) }),
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
if (hasLabel(title, "Fetch") || title === "web_fetch") {
|
|
118
|
+
const format =
|
|
119
|
+
raw?.format === "text" || raw?.format === "markdown" || raw?.format === "html" ? raw.format : "markdown"
|
|
120
|
+
return resolved(
|
|
121
|
+
"webfetch",
|
|
122
|
+
webfetchInput({ url: text(raw?.url), format, timeout: finiteNumber(raw?.timeout) }),
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
if (title === "activate_skill") return resolved("skill", skillInput({ id: text(raw?.name) }))
|
|
126
|
+
if (title === "codemode") return resolved("execute", executeInput({ code: literal(raw?.code) }))
|
|
127
|
+
if (isOpencodeQuestionName(title)) return resolved("question", questionInput(raw))
|
|
128
|
+
// MCP tools stay generic even when they carry a shell-like `command` field
|
|
129
|
+
// or arrive with an execute/think kind.
|
|
130
|
+
if (title?.startsWith("mcp__")) return unchanged(title)
|
|
131
|
+
// Command Code subagent calls keep their own label and stay visible.
|
|
132
|
+
if (title && (hasLabel(title, "Agent") || title === "task" || title === "agent")) return unchanged(title)
|
|
133
|
+
if (title === "ask_user_question") return unchanged("ask_user_question")
|
|
134
|
+
return undefined
|
|
135
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { ResolvedTool, ToolContext } from "./shared.ts"
|
|
2
|
+
import {
|
|
3
|
+
booleanOf,
|
|
4
|
+
commandOf,
|
|
5
|
+
editInput,
|
|
6
|
+
finiteNumber,
|
|
7
|
+
firstText,
|
|
8
|
+
globInput,
|
|
9
|
+
grepInput,
|
|
10
|
+
literal,
|
|
11
|
+
readInput,
|
|
12
|
+
shellInput,
|
|
13
|
+
webfetchInput,
|
|
14
|
+
writeInput,
|
|
15
|
+
} from "./shared.ts"
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Last resort for agents without a dedicated mapping. It still builds the
|
|
19
|
+
* strict input shape OpenCode's native cards expect, never a generic "tool".
|
|
20
|
+
*/
|
|
21
|
+
export function resolveFallback(ctx: ToolContext): ResolvedTool {
|
|
22
|
+
const raw = ctx.raw
|
|
23
|
+
const title = ctx.title
|
|
24
|
+
const path = firstText(raw?.path, raw?.file_path, raw?.filePath, raw?.file) ?? ctx.locationPath
|
|
25
|
+
|
|
26
|
+
if (ctx.kind === "execute") {
|
|
27
|
+
const command = commandOf(raw?.command) ?? firstText(raw?.cmd, raw?.shell_command)
|
|
28
|
+
if (command || raw === undefined) {
|
|
29
|
+
return {
|
|
30
|
+
agent: "fallback",
|
|
31
|
+
name: "shell",
|
|
32
|
+
input: shellInput({
|
|
33
|
+
command,
|
|
34
|
+
workdir: firstText(raw?.workdir, raw?.cwd, raw?.working_directory),
|
|
35
|
+
timeout: finiteNumber(raw?.timeout),
|
|
36
|
+
background: booleanOf(raw?.run_in_background),
|
|
37
|
+
}),
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (ctx.kind === "read") {
|
|
42
|
+
return {
|
|
43
|
+
agent: "fallback",
|
|
44
|
+
name: "read",
|
|
45
|
+
input: readInput({ path, offset: finiteNumber(raw?.offset), limit: finiteNumber(raw?.limit) }),
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (ctx.kind === "edit") {
|
|
49
|
+
if (title && /write|create/i.test(title)) {
|
|
50
|
+
return { agent: "fallback", name: "write", input: writeInput({ path, content: literal(raw?.content) }) }
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
agent: "fallback",
|
|
54
|
+
name: "edit",
|
|
55
|
+
input: editInput({
|
|
56
|
+
path,
|
|
57
|
+
oldString: literal(raw?.oldString) ?? literal(raw?.old_string),
|
|
58
|
+
newString: literal(raw?.newString) ?? literal(raw?.new_string),
|
|
59
|
+
replaceAll: booleanOf(raw?.replaceAll) ?? booleanOf(raw?.replace_all),
|
|
60
|
+
}),
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (ctx.kind === "search") {
|
|
64
|
+
if (title && /glob/i.test(title)) {
|
|
65
|
+
return {
|
|
66
|
+
agent: "fallback",
|
|
67
|
+
name: "glob",
|
|
68
|
+
input: globInput({
|
|
69
|
+
pattern: firstText(raw?.pattern, raw?.glob),
|
|
70
|
+
path: firstText(raw?.path) ?? ctx.locationPath,
|
|
71
|
+
limit: finiteNumber(raw?.limit),
|
|
72
|
+
}),
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
agent: "fallback",
|
|
77
|
+
name: "grep",
|
|
78
|
+
input: grepInput({
|
|
79
|
+
pattern: firstText(raw?.pattern, raw?.query),
|
|
80
|
+
path: firstText(raw?.path) ?? ctx.locationPath,
|
|
81
|
+
}),
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (ctx.kind === "fetch") {
|
|
85
|
+
return {
|
|
86
|
+
agent: "fallback",
|
|
87
|
+
name: "webfetch",
|
|
88
|
+
input: webfetchInput({ url: firstText(raw?.url, raw?.uri), format: "markdown" }),
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return { agent: "fallback", name: title ?? ctx.kind ?? "unknown", input: raw ? { ...raw } : {} }
|
|
92
|
+
}
|