ocpipe 0.1.0 → 0.3.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/LICENSE +21 -0
- package/README.md +37 -311
- package/example/ckpt/hello-world_20251227_044217.json +27 -0
- package/example/correction.ts +21 -7
- package/example/index.ts +1 -1
- package/example/module.ts +2 -2
- package/example/signature.ts +1 -1
- package/package.json +24 -12
- package/{agent.ts → src/agent.ts} +46 -21
- package/{index.ts → src/index.ts} +3 -16
- package/{module.ts → src/module.ts} +25 -0
- package/{parsing.ts → src/parsing.ts} +131 -41
- package/src/paths.ts +4 -0
- package/{pipeline.ts → src/pipeline.ts} +3 -2
- package/{predict.ts → src/predict.ts} +55 -22
- package/{signature.ts → src/signature.ts} +1 -1
- package/{testing.ts → src/testing.ts} +19 -11
- package/{types.ts → src/types.ts} +7 -7
- /package/{state.ts → src/state.ts} +0 -0
|
@@ -34,7 +34,10 @@ export class MockAgentBackend {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/** addJsonResponse adds a mock JSON response. */
|
|
37
|
-
addJsonResponse(
|
|
37
|
+
addJsonResponse(
|
|
38
|
+
data: Record<string, unknown>,
|
|
39
|
+
options?: Partial<MockResponse>,
|
|
40
|
+
): this {
|
|
38
41
|
return this.addResponse({
|
|
39
42
|
response: JSON.stringify(data, null, 2),
|
|
40
43
|
...options,
|
|
@@ -76,7 +79,7 @@ export class MockAgentBackend {
|
|
|
76
79
|
for (let i = 0; i < this.responses.length; i++) {
|
|
77
80
|
const r = this.responses[i]
|
|
78
81
|
if (!r) continue
|
|
79
|
-
|
|
82
|
+
|
|
80
83
|
if (!r.match) {
|
|
81
84
|
response = r
|
|
82
85
|
responseIndex = i
|
|
@@ -116,7 +119,8 @@ export class MockAgentBackend {
|
|
|
116
119
|
|
|
117
120
|
return {
|
|
118
121
|
text: response.response ?? '',
|
|
119
|
-
sessionId:
|
|
122
|
+
sessionId:
|
|
123
|
+
response.sessionId ?? options.sessionId ?? this.defaultSessionId,
|
|
120
124
|
}
|
|
121
125
|
}
|
|
122
126
|
|
|
@@ -127,12 +131,14 @@ export class MockAgentBackend {
|
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
/** createMockContext creates a test execution context. */
|
|
130
|
-
export function createMockContext(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
export function createMockContext(
|
|
135
|
+
overrides?: Partial<{
|
|
136
|
+
sessionId: string
|
|
137
|
+
defaultModel: { providerID: string; modelID: string }
|
|
138
|
+
defaultAgent: string
|
|
139
|
+
timeoutSec: number
|
|
140
|
+
}>,
|
|
141
|
+
) {
|
|
136
142
|
return {
|
|
137
143
|
sessionId: overrides?.sessionId,
|
|
138
144
|
defaultModel: overrides?.defaultModel ?? {
|
|
@@ -145,12 +151,14 @@ export function createMockContext(overrides?: Partial<{
|
|
|
145
151
|
}
|
|
146
152
|
|
|
147
153
|
/** generateMockOutputs creates mock output data based on a schema. */
|
|
148
|
-
export function generateMockOutputs(
|
|
154
|
+
export function generateMockOutputs(
|
|
155
|
+
schema: Record<string, FieldConfig>,
|
|
156
|
+
): Record<string, unknown> {
|
|
149
157
|
const result: Record<string, unknown> = {}
|
|
150
158
|
for (const [name, config] of Object.entries(schema)) {
|
|
151
159
|
// Use constructor name for type detection (works across zod versions)
|
|
152
160
|
const typeName = config.type.constructor.name
|
|
153
|
-
|
|
161
|
+
|
|
154
162
|
switch (typeName) {
|
|
155
163
|
case 'ZodString':
|
|
156
164
|
result[name] = `mock_${name}`
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Core type definitions for the Declarative Self-Improving TypeScript SDK.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { z } from 'zod'
|
|
7
|
+
import type { z } from 'zod/v4'
|
|
8
8
|
|
|
9
9
|
// ============================================================================
|
|
10
10
|
// Model Configuration
|
|
@@ -132,15 +132,15 @@ export interface SignatureDef<
|
|
|
132
132
|
|
|
133
133
|
/** Infer the input type from a signature definition. */
|
|
134
134
|
export type InferInputs<S extends SignatureDef<any, any>> =
|
|
135
|
-
S extends SignatureDef<infer I, any>
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
S extends SignatureDef<infer I, any> ?
|
|
136
|
+
{ [K in keyof I]: z.infer<I[K]['type']> }
|
|
137
|
+
: never
|
|
138
138
|
|
|
139
139
|
/** Infer the output type from a signature definition. */
|
|
140
140
|
export type InferOutputs<S extends SignatureDef<any, any>> =
|
|
141
|
-
S extends SignatureDef<any, infer O>
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
S extends SignatureDef<any, infer O> ?
|
|
142
|
+
{ [K in keyof O]: z.infer<O[K]['type']> }
|
|
143
|
+
: never
|
|
144
144
|
|
|
145
145
|
// ============================================================================
|
|
146
146
|
// Retry Configuration
|
|
File without changes
|