@open-cr-agent/runtime-opencode 0.6.0 → 0.7.0

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 CHANGED
@@ -1,3 +1,3 @@
1
1
  # @open-cr-agent/runtime-opencode
2
2
 
3
- The agent runtime backed by [OpenCode](https://opencode.ai) of [Open-CR-Agent](https://github.com/jma49/Open-CR-Agent), the multi-agent code reviewer. Most users want [`@open-cr-agent/cli`](https://www.npmjs.com/package/@open-cr-agent/cli), which provides the `ocra` command and installs this package; see the [manual](https://ocracloud.com). All `@open-cr-agent` packages are released together at one version. Apache-2.0.
3
+ The [OpenCode](https://opencode.ai) agent runtime of [Open-CR-Agent](https://github.com/jma49/Open-CR-Agent), the multi-agent code reviewer. Most users want [`@open-cr-agent/cli`](https://www.npmjs.com/package/@open-cr-agent/cli) (the `ocra` command) and the [manual](https://ocracloud.com). All packages share one version. Apache-2.0.
package/dist/binary.d.ts CHANGED
@@ -8,4 +8,3 @@ export interface Host {
8
8
  export declare function resolveOpencodeBinary(env: Env, opencodePackage?: string): string;
9
9
  export declare function isNativeExecutable(path: string): boolean;
10
10
  export declare function binaryVariants(host: Host): string[];
11
- //# sourceMappingURL=binary.d.ts.map
package/dist/binary.js CHANGED
@@ -100,4 +100,3 @@ function lacksAvx2(platform) {
100
100
  catch { }
101
101
  return false;
102
102
  }
103
- //# sourceMappingURL=binary.js.map
@@ -11,4 +11,3 @@ export interface EffortSetup {
11
11
  }
12
12
  export declare function setUpEfforts(setup: EffortSetup): Promise<EffortRoutes>;
13
13
  export {};
14
- //# sourceMappingURL=effort-setup.d.ts.map
@@ -40,4 +40,3 @@ async function catalogModels(config) {
40
40
  }
41
41
  return models;
42
42
  }
43
- //# sourceMappingURL=effort-setup.js.map
package/dist/effort.d.ts CHANGED
@@ -24,4 +24,3 @@ export declare class AppliedEfforts {
24
24
  private requested;
25
25
  }
26
26
  export {};
27
- //# sourceMappingURL=effort.d.ts.map
package/dist/effort.js CHANGED
@@ -146,4 +146,3 @@ export class AppliedEfforts {
146
146
  return ["temperature", "seed"].filter((key) => this.sampling[key] !== undefined);
147
147
  }
148
148
  }
149
- //# sourceMappingURL=effort.js.map
package/dist/index.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export { opencodeRuntimePlugin } from "./plugin.js";
2
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,2 +1 @@
1
1
  export { opencodeRuntimePlugin } from "./plugin.js";
2
- //# sourceMappingURL=index.js.map
@@ -98,4 +98,3 @@ export declare function openCodeConfig(tools: Pick<ToolServer, "url" | "headers"
98
98
  };
99
99
  };
100
100
  };
101
- //# sourceMappingURL=opencode-config.d.ts.map
@@ -134,4 +134,3 @@ function checkProvider(id, provider) {
134
134
  throw new OcraError("CONFIG_INVALID", `Provider "${id}": apiKeyEnv must be an environment variable name`);
135
135
  }
136
136
  }
137
- //# sourceMappingURL=opencode-config.js.map
@@ -12,4 +12,3 @@ export interface StartOptions {
12
12
  startupTimeoutMs?: number;
13
13
  }
14
14
  export declare function startOpencodeServer(options: StartOptions): Promise<OpencodeServer>;
15
- //# sourceMappingURL=opencode-server.d.ts.map
@@ -83,4 +83,3 @@ function freePort() {
83
83
  });
84
84
  });
85
85
  }
86
- //# sourceMappingURL=opencode-server.js.map
package/dist/plugin.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  import type { OcraPlugin } from "@open-cr-agent/core";
2
2
  export declare const opencodeRuntimePlugin: OcraPlugin;
3
- //# sourceMappingURL=plugin.d.ts.map
package/dist/plugin.js CHANGED
@@ -5,4 +5,3 @@ export const opencodeRuntimePlugin = {
5
5
  ctx.registerRuntime("opencode", (options) => new OpenCodeRuntime(options));
6
6
  },
7
7
  };
8
- //# sourceMappingURL=plugin.js.map
package/dist/runtime.d.ts CHANGED
@@ -25,4 +25,3 @@ export declare class OpenCodeRuntime implements AgentRuntime {
25
25
  private launch;
26
26
  }
27
27
  export declare function providersOf(options: Pick<RuntimeOptions, "models" | "agentModels">): string[];
28
- //# sourceMappingURL=runtime.d.ts.map
package/dist/runtime.js CHANGED
@@ -199,4 +199,3 @@ function chainModels(options) {
199
199
  export function providersOf(options) {
200
200
  return chainModels(options).map((m) => parseModel(m).providerID);
201
201
  }
202
- //# sourceMappingURL=runtime.js.map
@@ -9,4 +9,3 @@ export declare function missingCredentials(base: Env, providers: readonly string
9
9
  export declare function credentialValues(base: Env, providers: readonly string[], custom?: CustomProviders): string[];
10
10
  export declare function serverEnv(base: Env, dirs: IsolatedDirs, providers: readonly string[], custom?: CustomProviders): Record<string, string>;
11
11
  export {};
12
- //# sourceMappingURL=server-env.d.ts.map
@@ -191,4 +191,3 @@ export function serverEnv(base, dirs, providers, custom = {}) {
191
191
  env.XDG_STATE_HOME = dirs.state;
192
192
  return env;
193
193
  }
194
- //# sourceMappingURL=server-env.js.map
@@ -36,4 +36,3 @@ export declare function parseSessionMessages(data: unknown): SessionMessage[];
36
36
  export declare function summarizeSession(messages: readonly SessionMessage[], reportTool: string, toolPrefix?: string): AttemptOutcome;
37
37
  export declare function sessionUsage(messages: readonly SessionMessage[]): Usage;
38
38
  export {};
39
- //# sourceMappingURL=session-outcome.d.ts.map
@@ -1,4 +1,4 @@
1
- import { parseQuotaError } from "@open-cr-agent/core";
1
+ import { exploredBy, parseQuotaError } from "@open-cr-agent/core";
2
2
  import { z } from "zod";
3
3
  // The part of OpenCode's session messages ocra reads, validated rather than
4
4
  // cast: the SDK's types are not checked at runtime, and a server of another
@@ -46,12 +46,17 @@ const AUTH_MESSAGE = /api key|unauthori[sz]ed|permission denied|forbidden/i;
46
46
  export function summarizeSession(messages, reportTool, toolPrefix = "") {
47
47
  const assistant = messages.filter((m) => m.info.role === "assistant");
48
48
  const tools = assistant.flatMap((m) => m.parts.filter((p) => p.type === "tool"));
49
+ const names = tools.map((p) => (p.tool ?? "unknown").replace(toolPrefix, ""));
49
50
  const outcome = {
50
51
  findings: tools
51
52
  .filter((p) => p.tool === reportTool && p.state?.status === "completed")
52
53
  .map((p) => p.state?.input),
53
54
  steps: assistant.reduce((n, m) => n + m.parts.filter((p) => p.type === "step-start").length, 0),
54
- toolCalls: tools.map((p) => (p.tool ?? "unknown").replace(toolPrefix, "")),
55
+ toolCalls: names,
56
+ // A call that did not complete never showed the reviewer anything.
57
+ ...exploredBy(tools.flatMap((p, i) => p.state?.status === "completed"
58
+ ? [{ name: names[i] ?? "unknown", input: p.state.input }]
59
+ : [])),
55
60
  text: assistant
56
61
  .flatMap((m) => m.parts.filter((p) => p.type === "text").map((p) => p.text ?? ""))
57
62
  .join("\n")
@@ -92,4 +97,3 @@ function isAuthError(error) {
92
97
  function sum(messages, pick) {
93
98
  return messages.reduce((total, m) => total + (pick(m) ?? 0), 0);
94
99
  }
95
- //# sourceMappingURL=session-outcome.js.map
@@ -24,4 +24,3 @@ interface ResumeOptions {
24
24
  type SessionApi = Pick<OpencodeClient["session"], "create" | "prompt" | "messages" | "abort">;
25
25
  export declare function promptSession(session: SessionApi, input: PromptInput, reportTool: string, signal: AbortSignal, activity?: ActivityOptions): Promise<AttemptOutcome>;
26
26
  export {};
27
- //# sourceMappingURL=session-prompt.d.ts.map
@@ -22,6 +22,14 @@ function stoppedEarly(outcome, resume) {
22
22
  outcome.steps < resume.maxSteps &&
23
23
  outcome.text.trim() === "");
24
24
  }
25
+ // OpenCode caps each prompt's steps, so the cap ended an attempt when its
26
+ // last turn alone used them all.
27
+ function capped(outcome, lastTurnSteps, resume) {
28
+ const atCap = !outcome.error &&
29
+ !outcome.toolCalls.includes(resume.doneTool) &&
30
+ lastTurnSteps >= resume.maxSteps;
31
+ return atCap ? { ...outcome, atStepCap: true } : outcome;
32
+ }
25
33
  export async function promptSession(session, input, reportTool, signal, activity = {}) {
26
34
  const created = await session.create({ title: input.title }, { signal });
27
35
  if (!created.data) {
@@ -66,8 +74,10 @@ export async function promptSession(session, input, reportTool, signal, activity
66
74
  },
67
75
  };
68
76
  }
69
- if (!input.resume || !stoppedEarly(outcome, input.resume))
77
+ if (!input.resume)
70
78
  return outcome;
79
+ if (!stoppedEarly(outcome, input.resume))
80
+ return capped(outcome, outcome.steps, input.resume);
71
81
  const again = await session.prompt({
72
82
  sessionID,
73
83
  agent: input.agent,
@@ -84,7 +94,7 @@ export async function promptSession(session, input, reportTool, signal, activity
84
94
  };
85
95
  if (again.error)
86
96
  resumed.error = { message: JSON.stringify(again.error), retryable: false };
87
- return resumed;
97
+ return capped(resumed, resumed.steps - outcome.steps, input.resume);
88
98
  }
89
99
  catch (error) {
90
100
  // Aborted or cut off by the transport: OpenCode may still be running the
@@ -166,4 +176,3 @@ async function harvest(session, sessionID, reportTool, toolPrefix) {
166
176
  function emptyOutcome() {
167
177
  return { findings: [], steps: 0, toolCalls: [], text: "", usage: emptyUsage() };
168
178
  }
169
- //# sourceMappingURL=session-prompt.js.map
@@ -5,4 +5,3 @@ export interface ToolServer {
5
5
  close(): Promise<void>;
6
6
  }
7
7
  export declare function startToolServer(tools: readonly ToolDefinition[], context: () => ReviewContext | undefined): Promise<ToolServer>;
8
- //# sourceMappingURL=tool-server.d.ts.map
@@ -60,4 +60,3 @@ function authorized(req, expected) {
60
60
  const actual = Buffer.from(req.headers.authorization ?? "");
61
61
  return actual.length === expected.length && timingSafeEqual(actual, expected);
62
62
  }
63
- //# sourceMappingURL=tool-server.js.map
@@ -1,4 +1,3 @@
1
1
  import { Agent, type Dispatcher } from "undici";
2
2
  export declare function createUntimedDispatcher(): Agent;
3
3
  export declare function untimedFetch(dispatcher: Dispatcher): typeof fetch;
4
- //# sourceMappingURL=transport.d.ts.map
package/dist/transport.js CHANGED
@@ -26,4 +26,3 @@ export function untimedFetch(dispatcher) {
26
26
  return response;
27
27
  };
28
28
  }
29
- //# sourceMappingURL=transport.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-cr-agent/runtime-opencode",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "OpenCode-based agent runtime for Open-CR-Agent",
5
5
  "keywords": [
6
6
  "code-review",
@@ -33,8 +33,8 @@
33
33
  "!dist/**/*.map"
34
34
  ],
35
35
  "dependencies": {
36
- "@modelcontextprotocol/sdk": "^1.30.1",
37
- "@open-cr-agent/core": "0.6.0",
36
+ "@modelcontextprotocol/sdk": "^1.31.0",
37
+ "@open-cr-agent/core": "0.7.0",
38
38
  "@opencode-ai/sdk": "1.18.32",
39
39
  "opencode-ai": "1.18.32",
40
40
  "undici": "^8.11.2",