ocpipe 0.4.3 → 0.5.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/claude-code.ts +11 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ocpipe",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "description": "SDK for LLM pipelines with OpenCode and Zod",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -11,6 +11,15 @@ import {
11
11
  } from '@anthropic-ai/claude-agent-sdk'
12
12
  import type { RunAgentOptions, RunAgentResult } from './types.js'
13
13
 
14
+ /** Normalize model ID to Claude Code format (opus, sonnet, haiku). */
15
+ function normalizeModelId(modelId: string): string {
16
+ const lower = modelId.toLowerCase()
17
+ if (lower.includes('opus')) return 'opus'
18
+ if (lower.includes('sonnet')) return 'sonnet'
19
+ if (lower.includes('haiku')) return 'haiku'
20
+ return modelId
21
+ }
22
+
14
23
  /** Extract text from assistant messages. */
15
24
  function getAssistantText(msg: SDKMessage): string | null {
16
25
  if (msg.type !== 'assistant') return null
@@ -29,8 +38,8 @@ export async function runClaudeCodeAgent(
29
38
  ): Promise<RunAgentResult> {
30
39
  const { prompt, model, sessionId, timeoutSec = 300 } = options
31
40
 
32
- // Claude Agent SDK only uses modelID, not providerID
33
- const modelStr = model.modelID
41
+ // Claude Code understands simple names: opus, sonnet, haiku
42
+ const modelStr = normalizeModelId(model.modelID)
34
43
  const sessionInfo = sessionId ? `[session:${sessionId}]` : '[new session]'
35
44
  const promptPreview = prompt.slice(0, 50).replace(/\n/g, ' ')
36
45