anpord 0.1.5 → 0.1.7
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/dist/cli.cjs +16 -19
- package/dist/cli.mjs +16 -19
- package/dist/{client-BfhmGRQl.mjs → client-D0Rd_z6s.mjs} +18 -3
- package/dist/{client-BCZEcfVE.cjs → client-Dy5oayYb.cjs} +18 -3
- package/dist/{compiler-CZoX4jkx.cjs → compiler-CE-EYxtc.cjs} +55 -5
- package/dist/{compiler-CKiewwUc.mjs → compiler-eCuSUgYl.mjs} +55 -5
- package/dist/config.cjs +1 -1
- package/dist/config.mjs +1 -1
- package/dist/eval.cjs +1 -1
- package/dist/eval.d.cts +5 -2
- package/dist/eval.d.mts +5 -2
- package/dist/eval.mjs +1 -1
- package/dist/{evals-api-DUNVUGUy.d.mts → evals-api-7CuLOvxe.d.mts} +8 -2
- package/dist/{evals-api-sqVNeWet.d.cts → evals-api-w3tR6UNj.d.cts} +8 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +156 -82
- package/dist/index.d.mts +156 -82
- package/dist/index.mjs +1 -1
- package/dist/{source-DQ8HChlm.d.cts → source-DZEcNQVL.d.cts} +6 -2
- package/dist/{source-DQ8HChlm.d.mts → source-DZEcNQVL.d.mts} +6 -2
- package/dist/source.d.cts +1 -1
- package/dist/source.d.mts +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_client = require("./client-
|
|
2
|
+
const require_client = require("./client-Dy5oayYb.cjs");
|
|
3
3
|
const require_config = require("./config.cjs");
|
|
4
4
|
const require_errors = require("./errors-Boum34f5.cjs");
|
|
5
|
-
const require_compiler = require("./compiler-
|
|
5
|
+
const require_compiler = require("./compiler-CE-EYxtc.cjs");
|
|
6
6
|
let _effect_platform = require("@effect/platform");
|
|
7
7
|
let effect = require("effect");
|
|
8
8
|
let _effect_cli = require("@effect/cli");
|
|
9
9
|
let _effect_platform_node = require("@effect/platform-node");
|
|
10
10
|
//#region package.json
|
|
11
|
-
var version$1 = "0.1.
|
|
11
|
+
var version$1 = "0.1.7";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region ../template/src/extract.ts
|
|
14
14
|
/**
|
|
@@ -172,28 +172,25 @@ const summaryOf = (run, trials, drawn) => drawn ? "" : gridOf(run, trials, 0).jo
|
|
|
172
172
|
const FIRST_POLL = 2e3;
|
|
173
173
|
const SLOWEST_POLL = 1e4;
|
|
174
174
|
const WIDENING = 1.5;
|
|
175
|
-
const running = (
|
|
176
|
-
const widen = (gap) => Math.min(Math.round(gap * WIDENING), SLOWEST_POLL);
|
|
175
|
+
const running = (run) => run.status === "running";
|
|
177
176
|
const waitForRun = (id, onProgress) => effect.Effect.gen(function* () {
|
|
178
177
|
const api = yield* require_client.AnpordApi;
|
|
179
178
|
const startedAt = yield* effect.Clock.currentTimeMillis;
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
yield* onProgress(
|
|
184
|
-
return
|
|
185
|
-
gap: widen(gap),
|
|
186
|
-
run: next
|
|
187
|
-
};
|
|
179
|
+
const gap = yield* effect.Ref.make(FIRST_POLL);
|
|
180
|
+
const poll = effect.Effect.gen(function* () {
|
|
181
|
+
const run = yield* api.evals.get({ payload: { id } });
|
|
182
|
+
yield* onProgress(run, (yield* effect.Clock.currentTimeMillis) - startedAt);
|
|
183
|
+
return run;
|
|
188
184
|
});
|
|
189
|
-
const
|
|
190
|
-
gap
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
185
|
+
const waitThenPoll = effect.Effect.gen(function* () {
|
|
186
|
+
const millis = yield* effect.Ref.getAndUpdate(gap, (current) => Math.min(Math.round(current * WIDENING), SLOWEST_POLL));
|
|
187
|
+
yield* effect.Effect.sleep(effect.Duration.millis(millis));
|
|
188
|
+
return yield* poll;
|
|
189
|
+
});
|
|
190
|
+
return yield* effect.Effect.iterate(yield* poll, {
|
|
191
|
+
body: () => waitThenPoll,
|
|
194
192
|
while: running
|
|
195
193
|
});
|
|
196
|
-
return run ?? (yield* api.evals.get({ payload: { id } }));
|
|
197
194
|
}).pipe(effect.Effect.withSpan("Cli.waitForRun", { attributes: { runId: id } }));
|
|
198
195
|
//#endregion
|
|
199
196
|
//#region src/cli/commands.ts
|
package/dist/cli.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as ChannelName, o as PromptId, r as layer, s as VersionNumber, t as AnpordApi } from "./client-
|
|
2
|
+
import { a as ChannelName, o as PromptId, r as layer, s as VersionNumber, t as AnpordApi } from "./client-D0Rd_z6s.mjs";
|
|
3
3
|
import { clientOptionsConfig } from "./config.mjs";
|
|
4
4
|
import { i as tokenMatcher, r as asAnpordError } from "./errors-C9bQUcA3.mjs";
|
|
5
|
-
import { n as compileEvalEffect } from "./compiler-
|
|
5
|
+
import { n as compileEvalEffect } from "./compiler-eCuSUgYl.mjs";
|
|
6
6
|
import { FileSystem } from "@effect/platform";
|
|
7
7
|
import { Cause, Clock, Console, Data, Duration, Effect, Layer, Option, Ref } from "effect";
|
|
8
8
|
import { Args, Command, Options } from "@effect/cli";
|
|
9
9
|
import { NodeContext, NodeRuntime } from "@effect/platform-node";
|
|
10
10
|
//#region package.json
|
|
11
|
-
var version$1 = "0.1.
|
|
11
|
+
var version$1 = "0.1.7";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region ../template/src/extract.ts
|
|
14
14
|
/**
|
|
@@ -172,28 +172,25 @@ const summaryOf = (run, trials, drawn) => drawn ? "" : gridOf(run, trials, 0).jo
|
|
|
172
172
|
const FIRST_POLL = 2e3;
|
|
173
173
|
const SLOWEST_POLL = 1e4;
|
|
174
174
|
const WIDENING = 1.5;
|
|
175
|
-
const running = (
|
|
176
|
-
const widen = (gap) => Math.min(Math.round(gap * WIDENING), SLOWEST_POLL);
|
|
175
|
+
const running = (run) => run.status === "running";
|
|
177
176
|
const waitForRun = (id, onProgress) => Effect.gen(function* () {
|
|
178
177
|
const api = yield* AnpordApi;
|
|
179
178
|
const startedAt = yield* Clock.currentTimeMillis;
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
yield* onProgress(
|
|
184
|
-
return
|
|
185
|
-
gap: widen(gap),
|
|
186
|
-
run: next
|
|
187
|
-
};
|
|
179
|
+
const gap = yield* Ref.make(FIRST_POLL);
|
|
180
|
+
const poll = Effect.gen(function* () {
|
|
181
|
+
const run = yield* api.evals.get({ payload: { id } });
|
|
182
|
+
yield* onProgress(run, (yield* Clock.currentTimeMillis) - startedAt);
|
|
183
|
+
return run;
|
|
188
184
|
});
|
|
189
|
-
const
|
|
190
|
-
gap
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
185
|
+
const waitThenPoll = Effect.gen(function* () {
|
|
186
|
+
const millis = yield* Ref.getAndUpdate(gap, (current) => Math.min(Math.round(current * WIDENING), SLOWEST_POLL));
|
|
187
|
+
yield* Effect.sleep(Duration.millis(millis));
|
|
188
|
+
return yield* poll;
|
|
189
|
+
});
|
|
190
|
+
return yield* Effect.iterate(yield* poll, {
|
|
191
|
+
body: () => waitThenPoll,
|
|
194
192
|
while: running
|
|
195
193
|
});
|
|
196
|
-
return run ?? (yield* api.evals.get({ payload: { id } }));
|
|
197
194
|
}).pipe(Effect.withSpan("Cli.waitForRun", { attributes: { runId: id } }));
|
|
198
195
|
//#endregion
|
|
199
196
|
//#region src/cli/commands.ts
|
|
@@ -133,6 +133,20 @@ const EvalValidator = Schema.Struct({
|
|
|
133
133
|
description: "A bundled TypeScript validator and its exported function name.",
|
|
134
134
|
identifier: "EvalValidator"
|
|
135
135
|
});
|
|
136
|
+
const EvalPrepare = Schema.Struct({
|
|
137
|
+
name: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(100)),
|
|
138
|
+
source: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(1e6))
|
|
139
|
+
}).annotations({
|
|
140
|
+
description: "A bundled TypeScript workspace setup and its exported function name.",
|
|
141
|
+
identifier: "EvalPrepare"
|
|
142
|
+
});
|
|
143
|
+
const EvalPrepareValue = Schema.Record({
|
|
144
|
+
key: Schema.String,
|
|
145
|
+
value: Schema.Unknown
|
|
146
|
+
}).annotations({
|
|
147
|
+
description: "What a workspace setup returned, handed to the validator.",
|
|
148
|
+
identifier: "EvalPrepareValue"
|
|
149
|
+
});
|
|
136
150
|
const EvalVariables = Schema.Record({
|
|
137
151
|
key: Schema.String,
|
|
138
152
|
value: Schema.String
|
|
@@ -142,7 +156,7 @@ const EvalVariables = Schema.Record({
|
|
|
142
156
|
});
|
|
143
157
|
const EvalCase = Schema.Struct({
|
|
144
158
|
name: Schema.String,
|
|
145
|
-
|
|
159
|
+
prepare: Schema.NullOr(EvalPrepare),
|
|
146
160
|
source: EvalSource,
|
|
147
161
|
variables: Schema.optionalWith(EvalVariables, { default: () => ({}) }),
|
|
148
162
|
validator: Schema.optionalWith(Schema.NullOr(EvalValidator), { default: () => null }),
|
|
@@ -216,6 +230,7 @@ const EvalVerifyStep = Schema.Struct({
|
|
|
216
230
|
});
|
|
217
231
|
const EvalTrial = Schema.Struct({
|
|
218
232
|
commands: Schema.Int,
|
|
233
|
+
prepared: Schema.NullOr(EvalPrepareValue),
|
|
219
234
|
exitCode: Schema.Int,
|
|
220
235
|
failedCommands: Schema.Int,
|
|
221
236
|
filesChanged: Schema.Array(Schema.String),
|
|
@@ -265,7 +280,7 @@ const EvalSetup = Schema.Struct({
|
|
|
265
280
|
prompt: Schema.String,
|
|
266
281
|
repoRef: Schema.NullOr(Schema.String),
|
|
267
282
|
repoUrl: Schema.NullOr(Schema.String),
|
|
268
|
-
|
|
283
|
+
prepareName: Schema.NullOr(Schema.String),
|
|
269
284
|
validatorName: Schema.NullOr(Schema.String),
|
|
270
285
|
verifyCommand: Schema.NullOr(Schema.String),
|
|
271
286
|
workspace: Schema.String
|
|
@@ -472,7 +487,7 @@ const ListEvalsRequest = Schema.Struct({
|
|
|
472
487
|
});
|
|
473
488
|
const PublicEvalCase = Schema.Struct({
|
|
474
489
|
name: Schema.String,
|
|
475
|
-
|
|
490
|
+
prepare: Schema.optional(Schema.NullOr(EvalPrepare)),
|
|
476
491
|
source: Schema.optional(EvalSource),
|
|
477
492
|
validator: Schema.optional(Schema.NullOr(EvalValidator)),
|
|
478
493
|
variables: Schema.optional(EvalVariables),
|
|
@@ -133,6 +133,20 @@ const EvalValidator = effect.Schema.Struct({
|
|
|
133
133
|
description: "A bundled TypeScript validator and its exported function name.",
|
|
134
134
|
identifier: "EvalValidator"
|
|
135
135
|
});
|
|
136
|
+
const EvalPrepare = effect.Schema.Struct({
|
|
137
|
+
name: effect.Schema.String.pipe(effect.Schema.minLength(1), effect.Schema.maxLength(100)),
|
|
138
|
+
source: effect.Schema.String.pipe(effect.Schema.minLength(1), effect.Schema.maxLength(1e6))
|
|
139
|
+
}).annotations({
|
|
140
|
+
description: "A bundled TypeScript workspace setup and its exported function name.",
|
|
141
|
+
identifier: "EvalPrepare"
|
|
142
|
+
});
|
|
143
|
+
const EvalPrepareValue = effect.Schema.Record({
|
|
144
|
+
key: effect.Schema.String,
|
|
145
|
+
value: effect.Schema.Unknown
|
|
146
|
+
}).annotations({
|
|
147
|
+
description: "What a workspace setup returned, handed to the validator.",
|
|
148
|
+
identifier: "EvalPrepareValue"
|
|
149
|
+
});
|
|
136
150
|
const EvalVariables = effect.Schema.Record({
|
|
137
151
|
key: effect.Schema.String,
|
|
138
152
|
value: effect.Schema.String
|
|
@@ -142,7 +156,7 @@ const EvalVariables = effect.Schema.Record({
|
|
|
142
156
|
});
|
|
143
157
|
const EvalCase = effect.Schema.Struct({
|
|
144
158
|
name: effect.Schema.String,
|
|
145
|
-
|
|
159
|
+
prepare: effect.Schema.NullOr(EvalPrepare),
|
|
146
160
|
source: EvalSource,
|
|
147
161
|
variables: effect.Schema.optionalWith(EvalVariables, { default: () => ({}) }),
|
|
148
162
|
validator: effect.Schema.optionalWith(effect.Schema.NullOr(EvalValidator), { default: () => null }),
|
|
@@ -216,6 +230,7 @@ const EvalVerifyStep = effect.Schema.Struct({
|
|
|
216
230
|
});
|
|
217
231
|
const EvalTrial = effect.Schema.Struct({
|
|
218
232
|
commands: effect.Schema.Int,
|
|
233
|
+
prepared: effect.Schema.NullOr(EvalPrepareValue),
|
|
219
234
|
exitCode: effect.Schema.Int,
|
|
220
235
|
failedCommands: effect.Schema.Int,
|
|
221
236
|
filesChanged: effect.Schema.Array(effect.Schema.String),
|
|
@@ -265,7 +280,7 @@ const EvalSetup = effect.Schema.Struct({
|
|
|
265
280
|
prompt: effect.Schema.String,
|
|
266
281
|
repoRef: effect.Schema.NullOr(effect.Schema.String),
|
|
267
282
|
repoUrl: effect.Schema.NullOr(effect.Schema.String),
|
|
268
|
-
|
|
283
|
+
prepareName: effect.Schema.NullOr(effect.Schema.String),
|
|
269
284
|
validatorName: effect.Schema.NullOr(effect.Schema.String),
|
|
270
285
|
verifyCommand: effect.Schema.NullOr(effect.Schema.String),
|
|
271
286
|
workspace: effect.Schema.String
|
|
@@ -472,7 +487,7 @@ const ListEvalsRequest = effect.Schema.Struct({
|
|
|
472
487
|
});
|
|
473
488
|
const PublicEvalCase = effect.Schema.Struct({
|
|
474
489
|
name: effect.Schema.String,
|
|
475
|
-
|
|
490
|
+
prepare: effect.Schema.optional(effect.Schema.NullOr(EvalPrepare)),
|
|
476
491
|
source: effect.Schema.optional(EvalSource),
|
|
477
492
|
validator: effect.Schema.optional(effect.Schema.NullOr(EvalValidator)),
|
|
478
493
|
variables: effect.Schema.optional(EvalVariables),
|
|
@@ -59,6 +59,7 @@ const context = {
|
|
|
59
59
|
exec,
|
|
60
60
|
exists: path => access(path).then(() => true, () => false),
|
|
61
61
|
readText: path => readFile(path, "utf8"),
|
|
62
|
+
prepared: JSON.parse(process.env.ANPORD_PREPARE_VALUE ?? "{}"),
|
|
62
63
|
};
|
|
63
64
|
|
|
64
65
|
try {
|
|
@@ -72,6 +73,49 @@ try {
|
|
|
72
73
|
}
|
|
73
74
|
`;
|
|
74
75
|
const validatorEntry = (module, name) => `import { ${name} as validate } from ${JSON.stringify(module)};\n${runtime}`;
|
|
76
|
+
const prepareRuntime = `
|
|
77
|
+
import { access, readFile } from "node:fs/promises";
|
|
78
|
+
import { spawn } from "node:child_process";
|
|
79
|
+
|
|
80
|
+
const exec = (file, args = [], options = {}) => new Promise((resolve, reject) => {
|
|
81
|
+
const child = spawn(file, args, {
|
|
82
|
+
cwd: options.cwd ?? process.cwd(),
|
|
83
|
+
env: { ...process.env, ...options.env },
|
|
84
|
+
});
|
|
85
|
+
let stderr = "";
|
|
86
|
+
let stdout = "";
|
|
87
|
+
let timer;
|
|
88
|
+
if (options.timeoutMs) {
|
|
89
|
+
timer = setTimeout(() => {
|
|
90
|
+
child.kill("SIGKILL");
|
|
91
|
+
reject(new Error(\`\${file} did not finish within \${options.timeoutMs}ms\`));
|
|
92
|
+
}, options.timeoutMs);
|
|
93
|
+
}
|
|
94
|
+
child.stderr.on("data", chunk => { stderr += chunk; });
|
|
95
|
+
child.stdout.on("data", chunk => { stdout += chunk; });
|
|
96
|
+
child.on("error", error => { clearTimeout(timer); reject(error); });
|
|
97
|
+
child.on("close", code => {
|
|
98
|
+
clearTimeout(timer);
|
|
99
|
+
resolve({ exitCode: code ?? 1, stderr, stdout });
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const context = {
|
|
104
|
+
exec,
|
|
105
|
+
exists: path => access(path).then(() => true, () => false),
|
|
106
|
+
readText: path => readFile(path, "utf8"),
|
|
107
|
+
workspace: process.cwd(),
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
const value = await setup(context) ?? {};
|
|
112
|
+
console.log("ANPORD_PREPARE_RESULT=" + JSON.stringify(value));
|
|
113
|
+
} catch (error) {
|
|
114
|
+
console.error(error instanceof Error ? error.stack : String(error));
|
|
115
|
+
process.exitCode = 1;
|
|
116
|
+
}
|
|
117
|
+
`;
|
|
118
|
+
const prepareEntry = (module, name) => `import { ${name} as setup } from ${JSON.stringify(module)};\n${prepareRuntime}`;
|
|
75
119
|
const definitionEntry = (entry) => `import definition from ${JSON.stringify(entry)}; export default definition;`;
|
|
76
120
|
//#endregion
|
|
77
121
|
//#region src/evals/compiler.ts
|
|
@@ -154,6 +198,14 @@ const sourceFor = (definition, subject, fallback) => {
|
|
|
154
198
|
onSome: (source) => ({ source })
|
|
155
199
|
});
|
|
156
200
|
};
|
|
201
|
+
const bundled = (entry, inputs, name, wrap) => effect.Effect.gen(function* () {
|
|
202
|
+
const module = yield* validatorModule(entry, inputs, name);
|
|
203
|
+
const { source } = yield* bundle(wrap(module, name), entry);
|
|
204
|
+
return {
|
|
205
|
+
name,
|
|
206
|
+
source
|
|
207
|
+
};
|
|
208
|
+
});
|
|
157
209
|
const compileEvalEffect = (path) => effect.Effect.gen(function* () {
|
|
158
210
|
const entry = (0, node_path.resolve)(path);
|
|
159
211
|
const loaded = yield* loadDefinition(entry);
|
|
@@ -164,13 +216,11 @@ const compileEvalEffect = (path) => effect.Effect.gen(function* () {
|
|
|
164
216
|
cases: yield* effect.Effect.forEach(definition.cases, (subject) => effect.Effect.gen(function* () {
|
|
165
217
|
const hasValidator = typeof subject.validate === "function";
|
|
166
218
|
if (hasValidator === (typeof subject.verify === "string")) return yield* effect.Effect.fail(/* @__PURE__ */ new Error(`${subject.name} must have exactly one of validate or verify`));
|
|
167
|
-
const validator = hasValidator ?
|
|
168
|
-
|
|
169
|
-
source: (yield* bundle(validatorEntry(yield* validatorModule(entry, loaded.inputs, subject.validate?.name || subject.name), subject.validate?.name || subject.name), entry)).source
|
|
170
|
-
} : null;
|
|
219
|
+
const validator = hasValidator ? yield* bundled(entry, loaded.inputs, subject.validate?.name || subject.name, validatorEntry) : null;
|
|
220
|
+
const prepare = typeof subject.prepare === "function" ? yield* bundled(entry, loaded.inputs, subject.prepare.name || `${subject.name}-prepare`, prepareEntry) : null;
|
|
171
221
|
return {
|
|
172
222
|
name: subject.name,
|
|
173
|
-
|
|
223
|
+
prepare,
|
|
174
224
|
...sourceFor(definition, subject, fallback),
|
|
175
225
|
validator,
|
|
176
226
|
variables: subject.variables ?? {},
|
|
@@ -60,6 +60,7 @@ const context = {
|
|
|
60
60
|
exec,
|
|
61
61
|
exists: path => access(path).then(() => true, () => false),
|
|
62
62
|
readText: path => readFile(path, "utf8"),
|
|
63
|
+
prepared: JSON.parse(process.env.ANPORD_PREPARE_VALUE ?? "{}"),
|
|
63
64
|
};
|
|
64
65
|
|
|
65
66
|
try {
|
|
@@ -73,6 +74,49 @@ try {
|
|
|
73
74
|
}
|
|
74
75
|
`;
|
|
75
76
|
const validatorEntry = (module, name) => `import { ${name} as validate } from ${JSON.stringify(module)};\n${runtime}`;
|
|
77
|
+
const prepareRuntime = `
|
|
78
|
+
import { access, readFile } from "node:fs/promises";
|
|
79
|
+
import { spawn } from "node:child_process";
|
|
80
|
+
|
|
81
|
+
const exec = (file, args = [], options = {}) => new Promise((resolve, reject) => {
|
|
82
|
+
const child = spawn(file, args, {
|
|
83
|
+
cwd: options.cwd ?? process.cwd(),
|
|
84
|
+
env: { ...process.env, ...options.env },
|
|
85
|
+
});
|
|
86
|
+
let stderr = "";
|
|
87
|
+
let stdout = "";
|
|
88
|
+
let timer;
|
|
89
|
+
if (options.timeoutMs) {
|
|
90
|
+
timer = setTimeout(() => {
|
|
91
|
+
child.kill("SIGKILL");
|
|
92
|
+
reject(new Error(\`\${file} did not finish within \${options.timeoutMs}ms\`));
|
|
93
|
+
}, options.timeoutMs);
|
|
94
|
+
}
|
|
95
|
+
child.stderr.on("data", chunk => { stderr += chunk; });
|
|
96
|
+
child.stdout.on("data", chunk => { stdout += chunk; });
|
|
97
|
+
child.on("error", error => { clearTimeout(timer); reject(error); });
|
|
98
|
+
child.on("close", code => {
|
|
99
|
+
clearTimeout(timer);
|
|
100
|
+
resolve({ exitCode: code ?? 1, stderr, stdout });
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const context = {
|
|
105
|
+
exec,
|
|
106
|
+
exists: path => access(path).then(() => true, () => false),
|
|
107
|
+
readText: path => readFile(path, "utf8"),
|
|
108
|
+
workspace: process.cwd(),
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
const value = await setup(context) ?? {};
|
|
113
|
+
console.log("ANPORD_PREPARE_RESULT=" + JSON.stringify(value));
|
|
114
|
+
} catch (error) {
|
|
115
|
+
console.error(error instanceof Error ? error.stack : String(error));
|
|
116
|
+
process.exitCode = 1;
|
|
117
|
+
}
|
|
118
|
+
`;
|
|
119
|
+
const prepareEntry = (module, name) => `import { ${name} as setup } from ${JSON.stringify(module)};\n${prepareRuntime}`;
|
|
76
120
|
const definitionEntry = (entry) => `import definition from ${JSON.stringify(entry)}; export default definition;`;
|
|
77
121
|
//#endregion
|
|
78
122
|
//#region src/evals/compiler.ts
|
|
@@ -155,6 +199,14 @@ const sourceFor = (definition, subject, fallback) => {
|
|
|
155
199
|
onSome: (source) => ({ source })
|
|
156
200
|
});
|
|
157
201
|
};
|
|
202
|
+
const bundled = (entry, inputs, name, wrap) => Effect.gen(function* () {
|
|
203
|
+
const module = yield* validatorModule(entry, inputs, name);
|
|
204
|
+
const { source } = yield* bundle(wrap(module, name), entry);
|
|
205
|
+
return {
|
|
206
|
+
name,
|
|
207
|
+
source
|
|
208
|
+
};
|
|
209
|
+
});
|
|
158
210
|
const compileEvalEffect = (path) => Effect.gen(function* () {
|
|
159
211
|
const entry = resolve(path);
|
|
160
212
|
const loaded = yield* loadDefinition(entry);
|
|
@@ -165,13 +217,11 @@ const compileEvalEffect = (path) => Effect.gen(function* () {
|
|
|
165
217
|
cases: yield* Effect.forEach(definition.cases, (subject) => Effect.gen(function* () {
|
|
166
218
|
const hasValidator = typeof subject.validate === "function";
|
|
167
219
|
if (hasValidator === (typeof subject.verify === "string")) return yield* Effect.fail(/* @__PURE__ */ new Error(`${subject.name} must have exactly one of validate or verify`));
|
|
168
|
-
const validator = hasValidator ?
|
|
169
|
-
|
|
170
|
-
source: (yield* bundle(validatorEntry(yield* validatorModule(entry, loaded.inputs, subject.validate?.name || subject.name), subject.validate?.name || subject.name), entry)).source
|
|
171
|
-
} : null;
|
|
220
|
+
const validator = hasValidator ? yield* bundled(entry, loaded.inputs, subject.validate?.name || subject.name, validatorEntry) : null;
|
|
221
|
+
const prepare = typeof subject.prepare === "function" ? yield* bundled(entry, loaded.inputs, subject.prepare.name || `${subject.name}-prepare`, prepareEntry) : null;
|
|
172
222
|
return {
|
|
173
223
|
name: subject.name,
|
|
174
|
-
|
|
224
|
+
prepare,
|
|
175
225
|
...sourceFor(definition, subject, fallback),
|
|
176
226
|
validator,
|
|
177
227
|
variables: subject.variables ?? {},
|
package/dist/config.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_client = require("./client-
|
|
2
|
+
const require_client = require("./client-Dy5oayYb.cjs");
|
|
3
3
|
let effect = require("effect");
|
|
4
4
|
//#region src/client/config.ts
|
|
5
5
|
const apiKeyConfig = effect.Config.redacted("ANPORD_API_KEY");
|
package/dist/config.mjs
CHANGED
package/dist/eval.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_compiler = require("./compiler-
|
|
2
|
+
const require_compiler = require("./compiler-CE-EYxtc.cjs");
|
|
3
3
|
exports.compileEval = require_compiler.compileEval;
|
|
4
4
|
exports.compileEvalEffect = require_compiler.compileEvalEffect;
|
package/dist/eval.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PublicStartEvalRequest } from "./evals-api-
|
|
1
|
+
import { t as PublicStartEvalRequest } from "./evals-api-w3tR6UNj.cjs";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
//#region src/evals/compiler.d.ts
|
|
4
4
|
declare const compileEvalEffect: (path: string) => Effect.Effect<{
|
|
@@ -10,7 +10,10 @@ declare const compileEvalEffect: (path: string) => Effect.Effect<{
|
|
|
10
10
|
variables: Readonly<Record<string, string>>;
|
|
11
11
|
verify: string | null;
|
|
12
12
|
name: string;
|
|
13
|
-
|
|
13
|
+
prepare: {
|
|
14
|
+
name: string;
|
|
15
|
+
source: string;
|
|
16
|
+
} | null;
|
|
14
17
|
}[];
|
|
15
18
|
prompt: string;
|
|
16
19
|
tasks: {
|
package/dist/eval.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PublicStartEvalRequest } from "./evals-api-
|
|
1
|
+
import { t as PublicStartEvalRequest } from "./evals-api-7CuLOvxe.mjs";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
//#region src/evals/compiler.d.ts
|
|
4
4
|
declare const compileEvalEffect: (path: string) => Effect.Effect<{
|
|
@@ -10,7 +10,10 @@ declare const compileEvalEffect: (path: string) => Effect.Effect<{
|
|
|
10
10
|
variables: Readonly<Record<string, string>>;
|
|
11
11
|
verify: string | null;
|
|
12
12
|
name: string;
|
|
13
|
-
|
|
13
|
+
prepare: {
|
|
14
|
+
name: string;
|
|
15
|
+
source: string;
|
|
16
|
+
} | null;
|
|
14
17
|
}[];
|
|
15
18
|
prompt: string;
|
|
16
19
|
tasks: {
|
package/dist/eval.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as compileEvalEffect, t as compileEval } from "./compiler-
|
|
1
|
+
import { n as compileEvalEffect, t as compileEval } from "./compiler-eCuSUgYl.mjs";
|
|
2
2
|
export { compileEval, compileEvalEffect };
|
|
@@ -39,7 +39,10 @@ declare class Forbidden extends Forbidden_base {}
|
|
|
39
39
|
declare const PublicStartEvalRequest: Schema.Struct<{
|
|
40
40
|
cases: Schema.filter<Schema.Array$<Schema.refine<{
|
|
41
41
|
readonly name: string;
|
|
42
|
-
readonly
|
|
42
|
+
readonly prepare?: {
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly source: string;
|
|
45
|
+
} | null | undefined;
|
|
43
46
|
readonly source?: {
|
|
44
47
|
readonly kind: "empty";
|
|
45
48
|
} | {
|
|
@@ -62,7 +65,10 @@ declare const PublicStartEvalRequest: Schema.Struct<{
|
|
|
62
65
|
readonly verify: string | null;
|
|
63
66
|
}, Schema.Struct<{
|
|
64
67
|
name: typeof Schema.String;
|
|
65
|
-
|
|
68
|
+
prepare: Schema.optional<Schema.NullOr<Schema.Struct<{
|
|
69
|
+
name: Schema.filter<Schema.filter<typeof Schema.String>>;
|
|
70
|
+
source: Schema.filter<Schema.filter<typeof Schema.String>>;
|
|
71
|
+
}>>>;
|
|
66
72
|
source: Schema.optional<Schema.Union<[Schema.Struct<{
|
|
67
73
|
kind: Schema.Literal<["empty"]>;
|
|
68
74
|
}>, Schema.Struct<{
|
|
@@ -39,7 +39,10 @@ declare class Forbidden extends Forbidden_base {}
|
|
|
39
39
|
declare const PublicStartEvalRequest: Schema.Struct<{
|
|
40
40
|
cases: Schema.filter<Schema.Array$<Schema.refine<{
|
|
41
41
|
readonly name: string;
|
|
42
|
-
readonly
|
|
42
|
+
readonly prepare?: {
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly source: string;
|
|
45
|
+
} | null | undefined;
|
|
43
46
|
readonly source?: {
|
|
44
47
|
readonly kind: "empty";
|
|
45
48
|
} | {
|
|
@@ -62,7 +65,10 @@ declare const PublicStartEvalRequest: Schema.Struct<{
|
|
|
62
65
|
readonly verify: string | null;
|
|
63
66
|
}, Schema.Struct<{
|
|
64
67
|
name: typeof Schema.String;
|
|
65
|
-
|
|
68
|
+
prepare: Schema.optional<Schema.NullOr<Schema.Struct<{
|
|
69
|
+
name: Schema.filter<Schema.filter<typeof Schema.String>>;
|
|
70
|
+
source: Schema.filter<Schema.filter<typeof Schema.String>>;
|
|
71
|
+
}>>>;
|
|
66
72
|
source: Schema.optional<Schema.Union<[Schema.Struct<{
|
|
67
73
|
kind: Schema.Literal<["empty"]>;
|
|
68
74
|
}>, Schema.Struct<{
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_client = require("./client-
|
|
2
|
+
const require_client = require("./client-Dy5oayYb.cjs");
|
|
3
3
|
const require_errors = require("./errors-Boum34f5.cjs");
|
|
4
4
|
const require_source = require("./source-DvlGawEw.cjs");
|
|
5
5
|
let _effect_platform = require("@effect/platform");
|