Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .devcontainer/devcontainer-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"features": {
"ghcr.io/devcontainers-extra/features/bun:1": {
"version": "1.1.0",
"resolved": "ghcr.io/devcontainers-extra/features/bun@sha256:0624284ecaead9dd4c6654616a7f939cfa4ebcbc60593700a74e35b1767befa5",
"integrity": "sha256:0624284ecaead9dd4c6654616a7f939cfa4ebcbc60593700a74e35b1767befa5"
}
}
}
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:5-24-trixie",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers-extra/features/bun:1": {}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
36 changes: 0 additions & 36 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 18 additions & 15 deletions packages/opencode/src/tool/mcp-websearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,30 +66,33 @@ const McpRequest = <F extends Schema.Struct.Fields>(args: Schema.Struct<F>) =>
}),
})

export const call = <F extends Schema.Struct.Fields>(
http: HttpClient.HttpClient,
url: string,
tool: string,
args: Schema.Struct<F>,
value: Schema.Struct.Type<F>,
timeout: Duration.Input,
headers?: Record<string, string>,
) =>
export const call = <F extends Schema.Struct.Fields>(options: {
http: HttpClient.HttpClient
url: string
tool: string
args: Schema.Struct<F>
value: Schema.Struct.Type<F>
timeout: Duration.Input
headers?: Record<string, string>
}) =>
Effect.gen(function* () {
const request = yield* HttpClientRequest.post(url).pipe(
const request = yield* HttpClientRequest.post(options.url).pipe(
HttpClientRequest.accept("application/json, text/event-stream"),
HttpClientRequest.setHeaders(headers ?? {}),
HttpClientRequest.schemaBodyJson(McpRequest(args))({
HttpClientRequest.setHeaders(options.headers ?? {}),
HttpClientRequest.schemaBodyJson(McpRequest(options.args))({
jsonrpc: "2.0" as const,
id: 1 as const,
method: "tools/call" as const,
params: { name: tool, arguments: value },
params: { name: options.tool, arguments: options.value },
}),
)
const response = yield* HttpClient.filterStatusOk(http)
const response = yield* HttpClient.filterStatusOk(options.http)
.execute(request)
.pipe(
Effect.timeoutOrElse({ duration: timeout, orElse: () => Effect.die(new Error(`${tool} request timed out`)) }),
Effect.timeoutOrElse({
duration: options.timeout,
orElse: () => Effect.die(new Error(`${options.tool} request timed out`)),
}),
)
const body = yield* response.text
return yield* parseResponse(body)
Expand Down
32 changes: 16 additions & 16 deletions packages/opencode/src/tool/websearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,43 +57,43 @@ function parallelAuthHeaders() {
return { ...headers, Authorization: `Bearer ${process.env.PARALLEL_API_KEY}` }
}

function callProvider(
export function callProvider(
http: HttpClient.HttpClient,
provider: WebSearchProvider,
params: Schema.Schema.Type<typeof Parameters>,
ctx: Tool.Context,
) {
if (provider === "parallel") {
return McpWebSearch.call(
return McpWebSearch.call({
http,
McpWebSearch.PARALLEL_URL,
"web_search",
McpWebSearch.ParallelSearchArgs,
{
url: McpWebSearch.PARALLEL_URL,
tool: "web_search",
args: McpWebSearch.ParallelSearchArgs,
value: {
objective: params.query,
search_queries: [params.query],
session_id: ctx.sessionID,
model_name: webSearchModelName(ctx.extra),
},
"25 seconds",
parallelAuthHeaders(),
)
timeout: "25 seconds",
headers: parallelAuthHeaders(),
})
}

return McpWebSearch.call(
return McpWebSearch.call({
http,
McpWebSearch.EXA_URL,
"web_search_exa",
McpWebSearch.SearchArgs,
{
url: McpWebSearch.EXA_URL,
tool: "web_search_exa",
args: McpWebSearch.SearchArgs,
value: {
query: params.query,
type: params.type || "auto",
numResults: params.numResults || 8,
livecrawl: params.livecrawl || "fallback",
contextMaxCharacters: params.contextMaxCharacters,
},
"25 seconds",
)
timeout: "25 seconds",
})
}

export const WebSearchTool = Tool.define(
Expand Down
Loading
Loading