ocpipe 0.6.9 → 0.6.11
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 +19 -15
- package/example/correction.ts +1 -2
- package/example/index.ts +6 -7
- package/package.json +13 -12
- package/src/agent.ts +184 -209
- package/src/claude-code.ts +19 -24
- package/src/index.ts +3 -3
- package/src/omp.ts +313 -0
- package/src/pipeline.ts +8 -7
- package/src/predict.ts +9 -8
- package/src/testing.ts +7 -5
- package/src/types.ts +75 -42
package/src/types.ts
CHANGED
|
@@ -8,29 +8,20 @@ import type { z } from 'zod/v4'
|
|
|
8
8
|
// Model Configuration
|
|
9
9
|
// ============================================================================
|
|
10
10
|
|
|
11
|
-
/** Backend type for running
|
|
12
|
-
export type BackendType = 'opencode' | 'claude-code' | 'codex' | 'pi'
|
|
11
|
+
/** Backend type for running prompts. */
|
|
12
|
+
export type BackendType = 'opencode' | 'claude-code' | 'codex' | 'pi' | 'omp'
|
|
13
13
|
|
|
14
14
|
/** Reasoning effort for Codex SDK threads. */
|
|
15
15
|
export type CodexReasoningEffort =
|
|
16
|
-
| '
|
|
17
|
-
| 'low'
|
|
18
|
-
| 'medium'
|
|
19
|
-
| 'high'
|
|
20
|
-
| 'xhigh'
|
|
16
|
+
'minimal' | 'low' | 'medium' | 'high' | 'xhigh'
|
|
21
17
|
|
|
22
18
|
/** Codex sandbox mode. */
|
|
23
19
|
export type CodexSandboxMode =
|
|
24
|
-
|
|
25
|
-
| 'workspace-write'
|
|
26
|
-
| 'danger-full-access'
|
|
20
|
+
'read-only' | 'workspace-write' | 'danger-full-access'
|
|
27
21
|
|
|
28
22
|
/** Codex approval policy. */
|
|
29
23
|
export type CodexApprovalPolicy =
|
|
30
|
-
| '
|
|
31
|
-
| 'on-request'
|
|
32
|
-
| 'on-failure'
|
|
33
|
-
| 'untrusted'
|
|
24
|
+
'never' | 'on-request' | 'on-failure' | 'untrusted'
|
|
34
25
|
|
|
35
26
|
/** Codex web search mode. */
|
|
36
27
|
export type CodexWebSearchMode = 'disabled' | 'cached' | 'live'
|
|
@@ -45,10 +36,7 @@ export type CodexConfigValue =
|
|
|
45
36
|
|
|
46
37
|
/** Permission mode for Claude Code sessions. */
|
|
47
38
|
export type PermissionMode =
|
|
48
|
-
| '
|
|
49
|
-
| 'acceptEdits'
|
|
50
|
-
| 'bypassPermissions'
|
|
51
|
-
| 'plan'
|
|
39
|
+
'default' | 'acceptEdits' | 'bypassPermissions' | 'plan'
|
|
52
40
|
|
|
53
41
|
/** Subagent definition for Claude Code's Task tool dispatch. */
|
|
54
42
|
export interface AgentDefinition {
|
|
@@ -75,8 +63,7 @@ export interface ClaudeCodeOptions {
|
|
|
75
63
|
* Can be a full string or use the preset format with append.
|
|
76
64
|
*/
|
|
77
65
|
systemPrompt?:
|
|
78
|
-
| string
|
|
79
|
-
| { type: 'preset'; preset: 'claude_code'; append: string }
|
|
66
|
+
string | { type: 'preset'; preset: 'claude_code'; append: string }
|
|
80
67
|
/**
|
|
81
68
|
* Subagent definitions for parallel task dispatch via the Task tool.
|
|
82
69
|
* Keys are agent names, values are agent definitions.
|
|
@@ -133,11 +120,53 @@ export interface PiOptions {
|
|
|
133
120
|
env?: Record<string, string>
|
|
134
121
|
}
|
|
135
122
|
|
|
123
|
+
/** OpenCode CLI specific session options. */
|
|
124
|
+
export interface OpenCodeOptions {
|
|
125
|
+
/** Path to the OpenCode executable (default: `opencode` from PATH). */
|
|
126
|
+
command?: string
|
|
127
|
+
/** Prompt-file directory; defaults to ocpipe's temporary directory, not `.opencode`. */
|
|
128
|
+
promptDir?: string
|
|
129
|
+
/** Extra environment variables passed to the OpenCode subprocess. */
|
|
130
|
+
env?: Record<string, string>
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Oh My Pi CLI specific session options. */
|
|
134
|
+
export interface OmpOptions {
|
|
135
|
+
/** Path to the Oh My Pi executable (default: `omp` from PATH). */
|
|
136
|
+
command?: string
|
|
137
|
+
/** Process cwd used to launch Oh My Pi; defaults to the target workdir. */
|
|
138
|
+
processCwd?: string
|
|
139
|
+
/** OMP_HOME passed to the Oh My Pi subprocess. */
|
|
140
|
+
home?: string
|
|
141
|
+
/** CODEX_HOME value passed via `--codex-home`; set to empty string to clear it. */
|
|
142
|
+
codexHome?: string
|
|
143
|
+
/** Extra environment variables passed to the Oh My Pi subprocess. */
|
|
144
|
+
env?: Record<string, string>
|
|
145
|
+
/** Add `--auto-approve` (default: true). */
|
|
146
|
+
autoApprove?: boolean
|
|
147
|
+
/** Approval mode passed with `--approval-mode` (default: `yolo`). */
|
|
148
|
+
approvalMode?: string
|
|
149
|
+
/** Thinking effort passed with `--thinking` (default: `high`). */
|
|
150
|
+
thinking?: string
|
|
151
|
+
/** Run Oh My Pi as a continuing headless goal. */
|
|
152
|
+
goalMode?: boolean
|
|
153
|
+
/** Goal objective; setting this also enables goal mode. */
|
|
154
|
+
goalObjective?: string
|
|
155
|
+
/** Stop when context reaches this percent of the model window. */
|
|
156
|
+
contextStopPercent?: number
|
|
157
|
+
/** Stop when context reaches this token count. */
|
|
158
|
+
contextStopTokens?: number
|
|
159
|
+
/** Scratch handoff path passed to Oh My Pi; relative paths resolve against workdir. */
|
|
160
|
+
scratchHandoffFile?: string
|
|
161
|
+
/** Extra raw Oh My Pi arguments appended before the prompt separator. */
|
|
162
|
+
extraArgs?: string[]
|
|
163
|
+
}
|
|
164
|
+
|
|
136
165
|
/** Model configuration for LLM backends. */
|
|
137
166
|
export interface ModelConfig {
|
|
138
|
-
/** Backend to use (default: '
|
|
167
|
+
/** Backend to use (default: 'omp'). */
|
|
139
168
|
backend?: BackendType
|
|
140
|
-
/** Provider ID
|
|
169
|
+
/** Provider ID for provider-qualified backends such as OpenCode. */
|
|
141
170
|
providerID?: string
|
|
142
171
|
modelID: string
|
|
143
172
|
/** Model variant for reasoning effort (e.g. 'low', 'medium', 'high', 'max'). */
|
|
@@ -152,22 +181,24 @@ export interface ModelConfig {
|
|
|
152
181
|
|
|
153
182
|
/** Execution context passed through pipeline execution. */
|
|
154
183
|
export interface ExecutionContext {
|
|
155
|
-
/** Current
|
|
184
|
+
/** Current backend session ID for continuity. */
|
|
156
185
|
sessionId?: string
|
|
157
186
|
/** Default model for predictions. */
|
|
158
187
|
defaultModel: ModelConfig
|
|
159
|
-
/** Default agent for predictions. */
|
|
160
|
-
defaultAgent: string
|
|
161
188
|
/** Timeout in seconds for agent calls. */
|
|
162
189
|
timeoutSec: number
|
|
163
|
-
/**
|
|
190
|
+
/** Target working directory for backend tools. */
|
|
164
191
|
workdir?: string
|
|
192
|
+
/** OpenCode CLI specific options. */
|
|
193
|
+
opencode?: OpenCodeOptions
|
|
165
194
|
/** Claude Code specific options. */
|
|
166
195
|
claudeCode?: ClaudeCodeOptions
|
|
167
196
|
/** Codex SDK specific options. */
|
|
168
197
|
codex?: CodexOptions
|
|
169
198
|
/** Pi coding agent specific options. */
|
|
170
199
|
pi?: PiOptions
|
|
200
|
+
/** Oh My Pi specific options. */
|
|
201
|
+
omp?: OmpOptions
|
|
171
202
|
/** AbortSignal for cancelling in-flight backend requests. */
|
|
172
203
|
signal?: AbortSignal
|
|
173
204
|
}
|
|
@@ -184,7 +215,7 @@ export interface StepResult<T> {
|
|
|
184
215
|
stepName: string
|
|
185
216
|
/** Execution duration in milliseconds. */
|
|
186
217
|
duration: number
|
|
187
|
-
/**
|
|
218
|
+
/** Backend session ID used. */
|
|
188
219
|
sessionId: string
|
|
189
220
|
/** Model used for this step. */
|
|
190
221
|
model: ModelConfig
|
|
@@ -217,8 +248,8 @@ export interface BaseState {
|
|
|
217
248
|
sessionId: string
|
|
218
249
|
/** ISO timestamp when pipeline started. */
|
|
219
250
|
startedAt: string
|
|
220
|
-
/** Current
|
|
221
|
-
|
|
251
|
+
/** Current backend session ID for continuity. */
|
|
252
|
+
agentSessionId?: string
|
|
222
253
|
/** Current phase name (for resume). */
|
|
223
254
|
phase: string
|
|
224
255
|
/** All completed steps. */
|
|
@@ -237,7 +268,7 @@ export interface PredictResult<T> {
|
|
|
237
268
|
data: T
|
|
238
269
|
/** Raw response text from the LLM. */
|
|
239
270
|
raw: string
|
|
240
|
-
/**
|
|
271
|
+
/** Backend session ID. */
|
|
241
272
|
sessionId: string
|
|
242
273
|
/** Execution duration in milliseconds. */
|
|
243
274
|
duration: number
|
|
@@ -330,9 +361,7 @@ export interface CorrectionConfig {
|
|
|
330
361
|
|
|
331
362
|
/** Error codes for field errors, enabling robust error type detection. */
|
|
332
363
|
export type FieldErrorCode =
|
|
333
|
-
| '
|
|
334
|
-
| 'no_json_found'
|
|
335
|
-
| 'schema_validation_failed'
|
|
364
|
+
'json_parse_failed' | 'no_json_found' | 'schema_validation_failed'
|
|
336
365
|
|
|
337
366
|
/** A field-level error from schema validation. */
|
|
338
367
|
export interface FieldError {
|
|
@@ -372,8 +401,6 @@ export interface PipelineConfig {
|
|
|
372
401
|
name: string
|
|
373
402
|
/** Default model for predictions. */
|
|
374
403
|
defaultModel: ModelConfig
|
|
375
|
-
/** Default agent for predictions. */
|
|
376
|
-
defaultAgent: string
|
|
377
404
|
/** Directory for checkpoint files. */
|
|
378
405
|
checkpointDir: string
|
|
379
406
|
/** Directory for log files. */
|
|
@@ -382,14 +409,18 @@ export interface PipelineConfig {
|
|
|
382
409
|
retry?: RetryConfig
|
|
383
410
|
/** Default timeout in seconds. */
|
|
384
411
|
timeoutSec?: number
|
|
385
|
-
/**
|
|
412
|
+
/** Target working directory for backend tools. */
|
|
386
413
|
workdir?: string
|
|
414
|
+
/** OpenCode CLI specific options. */
|
|
415
|
+
opencode?: OpenCodeOptions
|
|
387
416
|
/** Claude Code specific options. */
|
|
388
417
|
claudeCode?: ClaudeCodeOptions
|
|
389
418
|
/** Codex SDK specific options. */
|
|
390
419
|
codex?: CodexOptions
|
|
391
420
|
/** Pi coding agent specific options. */
|
|
392
421
|
pi?: PiOptions
|
|
422
|
+
/** Oh My Pi specific options. */
|
|
423
|
+
omp?: OmpOptions
|
|
393
424
|
}
|
|
394
425
|
|
|
395
426
|
/** Options for running a pipeline step. */
|
|
@@ -408,31 +439,33 @@ export interface RunOptions {
|
|
|
408
439
|
// Agent Types
|
|
409
440
|
// ============================================================================
|
|
410
441
|
|
|
411
|
-
/** Options for running
|
|
442
|
+
/** Options for running a prompt through a backend. */
|
|
412
443
|
export interface RunAgentOptions {
|
|
413
|
-
/** The prompt to send to the
|
|
444
|
+
/** The prompt to send to the backend. */
|
|
414
445
|
prompt: string
|
|
415
|
-
/** Agent type (e.g., "journey-creator", "explore", "general"). */
|
|
416
|
-
agent: string
|
|
417
446
|
/** Model to use. */
|
|
418
447
|
model: ModelConfig
|
|
419
448
|
/** Existing session ID to continue. */
|
|
420
449
|
sessionId?: string
|
|
421
450
|
/** Timeout in seconds. */
|
|
422
451
|
timeoutSec?: number
|
|
423
|
-
/**
|
|
452
|
+
/** Target working directory for backend tools. */
|
|
424
453
|
workdir?: string
|
|
454
|
+
/** OpenCode CLI specific options. */
|
|
455
|
+
opencode?: OpenCodeOptions
|
|
425
456
|
/** Claude Code specific options. */
|
|
426
457
|
claudeCode?: ClaudeCodeOptions
|
|
427
458
|
/** Codex SDK specific options. */
|
|
428
459
|
codex?: CodexOptions
|
|
429
460
|
/** Pi coding agent specific options. */
|
|
430
461
|
pi?: PiOptions
|
|
462
|
+
/** Oh My Pi specific options. */
|
|
463
|
+
omp?: OmpOptions
|
|
431
464
|
/** AbortSignal for cancelling the request. */
|
|
432
465
|
signal?: AbortSignal
|
|
433
466
|
}
|
|
434
467
|
|
|
435
|
-
/** Result from running
|
|
468
|
+
/** Result from running a prompt through a backend. */
|
|
436
469
|
export interface RunAgentResult {
|
|
437
470
|
/** The text response from the agent. */
|
|
438
471
|
text: string
|