opencode
opencode
¶
OpenCodeAgent -- wraps the opencode coding agent via its headless HTTP server.
Spawns opencode serve (https://opencode.ai) and drives a session over its
HTTP API, configured to use OpenJarvis's local engine through an
OpenAI-compatible provider. This keeps coding-agent work local-first: opencode
handles the agentic loop / tools, OpenJarvis supplies the model.
opencode is an external binary (install: npm i -g opencode-ai or
brew install anomalyco/tap/opencode). It is not bundled; :meth:run
raises a clear error if it is not on PATH.
Classes¶
OpenCodeAgent
¶
OpenCodeAgent(engine: InferenceEngine, model: str, *, bus: Optional[EventBus] = None, temperature: Optional[float] = None, max_tokens: Optional[int] = None, workspace: str = '', agent: str = 'build', provider_id: str = 'openjarvis', provider_base_url: str = '', model_id: str = '', api_key: str = '', permission: Optional[Any] = None, hostname: str = '127.0.0.1', port: int = 0, server_password: str = '', timeout: int = 600, opencode_bin: str = '')
Bases: BaseAgent
Agent that delegates coding tasks to a local opencode server.
The engine is used to wire opencode at an OpenAI-compatible provider so
inference runs on OpenJarvis's selected local model. agent selects
opencode's built-in agent: build (full access) or plan (read-only).
Source code in src/openjarvis/agents/opencode.py
Functions¶
close
¶
Dispose the opencode session/server and terminate the process.
Source code in src/openjarvis/agents/opencode.py
run
¶
run(input: str, context: Optional[AgentContext] = None, **kwargs: Any) -> AgentResult
Run a coding task through opencode and return the assistant result.
Source code in src/openjarvis/agents/opencode.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |