ocpipe 0.5.7 → 0.5.9

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
@@ -80,8 +80,8 @@ claudeCode: { permissionMode: 'acceptEdits' },
80
80
 
81
81
  **For OpenCode backend:** Currently requires [this OpenCode fork](https://github.com/paralin/opencode). Once the following PRs are merged, the official release will work:
82
82
 
83
- - [#5426](https://github.com/anomalyco/opencode/pull/5426) - Adds `--prompt-file` flag
84
- - [#5339](https://github.com/anomalyco/opencode/pull/5339) - Session export fixes
83
+ - [#5426](https://github.com/anomalyco/opencode/pull/5426) - Adds session export command
84
+ - [#5339](https://github.com/anomalyco/opencode/pull/5339) - Adds `--tools` flag to limit available tools (optional)
85
85
 
86
86
  **For Claude Code backend:** Install the SDK as a peer dependency:
87
87
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ocpipe",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
4
4
  "description": "SDK for LLM pipelines with OpenCode and Zod",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -31,7 +31,7 @@
31
31
  "dependencies": {},
32
32
  "peerDependencies": {
33
33
  "zod": "4.3.6",
34
- "@anthropic-ai/claude-agent-sdk": "0.2.20"
34
+ "@anthropic-ai/claude-agent-sdk": "0.2.29"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "@anthropic-ai/claude-agent-sdk": {
@@ -149,6 +149,9 @@ export async function runClaudeCodeAgent(
149
149
  }
150
150
  signal?.addEventListener('abort', abortHandler, { once: true })
151
151
 
152
+ // Declare outside try block so finally can access it
153
+ let timeoutId: ReturnType<typeof setTimeout> | null = null
154
+
152
155
  try {
153
156
  // Send the prompt
154
157
  await session.send(prompt)
@@ -157,11 +160,11 @@ export async function runClaudeCodeAgent(
157
160
  const textParts: string[] = []
158
161
  let newSessionId = sessionId || ''
159
162
 
160
- // Set up timeout
163
+ // Set up timeout (store ID so we can clear it later)
161
164
  const timeoutPromise =
162
165
  timeoutSec > 0 ?
163
166
  new Promise<never>((_, reject) => {
164
- setTimeout(() => {
167
+ timeoutId = setTimeout(() => {
165
168
  session.close()
166
169
  reject(new Error(`Timeout after ${timeoutSec}s`))
167
170
  }, timeoutSec * 1000)
@@ -204,6 +207,9 @@ export async function runClaudeCodeAgent(
204
207
  if (abortPromise) promises.push(abortPromise)
205
208
  await Promise.race(promises)
206
209
 
210
+ // Clear the timeout to prevent it from keeping the event loop alive
211
+ if (timeoutId) clearTimeout(timeoutId)
212
+
207
213
  const response = textParts.join('')
208
214
  const sessionStr = newSessionId || 'none'
209
215
  console.error(
@@ -216,6 +222,7 @@ export async function runClaudeCodeAgent(
216
222
  }
217
223
  } finally {
218
224
  signal?.removeEventListener('abort', abortHandler)
225
+ if (timeoutId) clearTimeout(timeoutId)
219
226
  session.close()
220
227
  }
221
228
  }
package/src/predict.ts CHANGED
@@ -204,7 +204,7 @@ export class Predict<S extends AnySignature> {
204
204
  model: correctionModel ?? ctx.defaultModel,
205
205
  sessionId: correctionModel ? undefined : sessionId,
206
206
  agent: ctx.defaultAgent,
207
- timeoutSec: 60,
207
+ timeoutSec: ctx.timeoutSec,
208
208
  workdir: ctx.workdir,
209
209
  claudeCode: ctx.claudeCode,
210
210
  signal: ctx.signal,
@@ -281,7 +281,7 @@ export class Predict<S extends AnySignature> {
281
281
  model: correctionModel ?? ctx.defaultModel,
282
282
  sessionId: correctionModel ? undefined : sessionId,
283
283
  agent: ctx.defaultAgent,
284
- timeoutSec: 60, // Short timeout for simple patches
284
+ timeoutSec: ctx.timeoutSec,
285
285
  workdir: ctx.workdir,
286
286
  claudeCode: ctx.claudeCode,
287
287
  signal: ctx.signal,