@agent-nexus/driftbench 0.0.0-stage → 0.1.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 +201 -0
- package/README.md +32 -2
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +8 -0
- package/dist/chunk-57ZRX7PY.js +1024 -0
- package/dist/chunk-5DPBYSU3.js +11649 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +16 -0
- package/dist/random-agent-E43SQJDO.js +66 -0
- package/dist/src-5XXPWAL2.js +26 -0
- package/package.json +65 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Where a command writes, and the folder relative paths are shown from. Tests pass their own. */
|
|
2
|
+
type Io = {
|
|
3
|
+
out: (text: string) => void;
|
|
4
|
+
err: (text: string) => void;
|
|
5
|
+
readonly cwd: string;
|
|
6
|
+
};
|
|
7
|
+
declare const processIo: Io;
|
|
8
|
+
|
|
9
|
+
type CoverageOptions = {
|
|
10
|
+
/** Path to the behaviour inventory (YAML or JSON). */
|
|
11
|
+
inventory: string;
|
|
12
|
+
/** Limit the matrix to one channel. */
|
|
13
|
+
channel?: string;
|
|
14
|
+
json?: boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* `driftbench spec coverage <paths...> --inventory <file>`: the behaviour x spec matrix and the
|
|
18
|
+
* flow x deviation matrix. Exit 0 when every applicable behaviour and every required deviation is
|
|
19
|
+
* covered, 1 when one is missing, 2 on a usage or input error.
|
|
20
|
+
*/
|
|
21
|
+
declare function coverageCommand(paths: string[], options: CoverageOptions, io: Io): Promise<number>;
|
|
22
|
+
|
|
23
|
+
declare function validateCommand(paths: string[], options: {
|
|
24
|
+
json?: boolean;
|
|
25
|
+
}, io: Io): Promise<number>;
|
|
26
|
+
declare function lintCommand(paths: string[], options: {
|
|
27
|
+
json?: boolean;
|
|
28
|
+
strict?: boolean;
|
|
29
|
+
}, io: Io): Promise<number>;
|
|
30
|
+
|
|
31
|
+
/** Runs the CLI with arguments (without `node` and the script) and returns the exit code. */
|
|
32
|
+
declare function main(argv: string[], io?: Io): Promise<number>;
|
|
33
|
+
|
|
34
|
+
/** Kept equal to package.json by a test. */
|
|
35
|
+
declare const VERSION = "0.1.0";
|
|
36
|
+
|
|
37
|
+
export { type CoverageOptions, type Io, VERSION, coverageCommand, lintCommand, main, processIo, validateCommand };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createAcmeAgent,
|
|
3
|
+
createStore
|
|
4
|
+
} from "./chunk-57ZRX7PY.js";
|
|
5
|
+
|
|
6
|
+
// ../../examples/acme/pilot/random-agent/index.ts
|
|
7
|
+
import { createHash } from "crypto";
|
|
8
|
+
import { PILOT_CONTROL_MARKER } from "@agent-nexus/driftbench-generate";
|
|
9
|
+
var RANDOM_AGENT_DEFAULTS = {
|
|
10
|
+
seed: 7,
|
|
11
|
+
fragile: 0.5,
|
|
12
|
+
pFragile: 0.5,
|
|
13
|
+
pSturdy: 0.05
|
|
14
|
+
};
|
|
15
|
+
function uniform(...parts) {
|
|
16
|
+
const digest = createHash("sha256").update(parts.join("\0")).digest();
|
|
17
|
+
return digest.readUInt32BE(0) / 2 ** 32;
|
|
18
|
+
}
|
|
19
|
+
function createRandomAgent(options = {}) {
|
|
20
|
+
const o = { ...RANDOM_AGENT_DEFAULTS, ...options };
|
|
21
|
+
for (const key of ["fragile", "pFragile", "pSturdy"]) {
|
|
22
|
+
if (!(o[key] >= 0 && o[key] <= 1)) throw new RangeError(`createRandomAgent: ${key} must lie in [0, 1]`);
|
|
23
|
+
}
|
|
24
|
+
const opened = /* @__PURE__ */ new Map();
|
|
25
|
+
return {
|
|
26
|
+
options: o,
|
|
27
|
+
create(given) {
|
|
28
|
+
const k = opened.get(given.hash) ?? 0;
|
|
29
|
+
opened.set(given.hash, k + 1);
|
|
30
|
+
let draw = 0;
|
|
31
|
+
const store = createStore();
|
|
32
|
+
return {
|
|
33
|
+
agent: createAcmeAgent(store),
|
|
34
|
+
store,
|
|
35
|
+
given: given.hash,
|
|
36
|
+
next: () => {
|
|
37
|
+
draw += 1;
|
|
38
|
+
return uniform("run", o.seed, given.hash, k, draw);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
async respond(messages, world, session) {
|
|
43
|
+
const observed = await session.agent.respond(messages, world);
|
|
44
|
+
const texts = messages.filter((message) => message.role === "user").map((message) => message.content);
|
|
45
|
+
const fragile = uniform("wording", o.seed, session.given, ...texts) < o.fragile;
|
|
46
|
+
const pFail = fragile ? o.pFragile : o.pSturdy;
|
|
47
|
+
const failed = session.next() < pFail;
|
|
48
|
+
const text = failed ? `${observed.text} ${PILOT_CONTROL_MARKER}` : observed.text;
|
|
49
|
+
const segments = observed.segments.map(
|
|
50
|
+
(segment, i) => failed && segment.type === "text" && i === observed.segments.length - 1 ? { ...segment, text } : segment
|
|
51
|
+
);
|
|
52
|
+
const raw = observed.raw !== null && typeof observed.raw === "object" ? observed.raw : {};
|
|
53
|
+
return {
|
|
54
|
+
...observed,
|
|
55
|
+
segments,
|
|
56
|
+
text,
|
|
57
|
+
raw: { ...raw, pilotControl: { pFail, fragile, failed, model: { ...o } } }
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
RANDOM_AGENT_DEFAULTS,
|
|
64
|
+
createRandomAgent,
|
|
65
|
+
uniform
|
|
66
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ACME,
|
|
3
|
+
SIDE_EFFECT_TOOLS,
|
|
4
|
+
STAGES,
|
|
5
|
+
TOOL_LABELS,
|
|
6
|
+
callTool,
|
|
7
|
+
createAcmeAgent,
|
|
8
|
+
createStore,
|
|
9
|
+
initialState,
|
|
10
|
+
isToolLabel,
|
|
11
|
+
takeTurn,
|
|
12
|
+
withSeed
|
|
13
|
+
} from "./chunk-57ZRX7PY.js";
|
|
14
|
+
export {
|
|
15
|
+
ACME,
|
|
16
|
+
SIDE_EFFECT_TOOLS,
|
|
17
|
+
STAGES,
|
|
18
|
+
TOOL_LABELS,
|
|
19
|
+
callTool,
|
|
20
|
+
createAcmeAgent,
|
|
21
|
+
createStore,
|
|
22
|
+
initialState,
|
|
23
|
+
isToolLabel,
|
|
24
|
+
takeTurn,
|
|
25
|
+
withSeed
|
|
26
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-nexus/driftbench",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The driftbench command line: validate and run specs, campaigns in teacher-forced, free-running and perturbed modes, reports, generation and validators.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"driftbench",
|
|
7
|
+
"ai-agents",
|
|
8
|
+
"evaluation",
|
|
9
|
+
"llm",
|
|
10
|
+
"testing",
|
|
11
|
+
"cli",
|
|
12
|
+
"command-line",
|
|
13
|
+
"continuous-integration"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://github.com/achammah/driftbench#readme",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/achammah/driftbench/issues"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/achammah/driftbench.git",
|
|
22
|
+
"directory": "packages/cli"
|
|
23
|
+
},
|
|
24
|
+
"license": "Apache-2.0",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=22.13"
|
|
28
|
+
},
|
|
29
|
+
"bin": {
|
|
30
|
+
"driftbench": "./dist/bin.js"
|
|
31
|
+
},
|
|
32
|
+
"main": "./dist/index.js",
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist"
|
|
42
|
+
],
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"commander": "^15.0.0",
|
|
45
|
+
"yaml": "^2.9.1",
|
|
46
|
+
"@agent-nexus/driftbench-adapters": "0.1.0",
|
|
47
|
+
"@agent-nexus/driftbench-checks": "0.1.0",
|
|
48
|
+
"@agent-nexus/driftbench-core": "0.1.0",
|
|
49
|
+
"@agent-nexus/driftbench-artifacts": "0.1.0",
|
|
50
|
+
"@agent-nexus/driftbench-generate": "0.1.0",
|
|
51
|
+
"@agent-nexus/driftbench-estate": "0.1.0",
|
|
52
|
+
"@agent-nexus/driftbench-judges": "0.1.0",
|
|
53
|
+
"@agent-nexus/driftbench-report": "0.1.0",
|
|
54
|
+
"@agent-nexus/driftbench-space": "0.1.0",
|
|
55
|
+
"@agent-nexus/driftbench-stats": "0.1.0",
|
|
56
|
+
"@agent-nexus/driftbench-users": "0.1.0",
|
|
57
|
+
"@agent-nexus/driftbench-store": "0.1.0",
|
|
58
|
+
"@agent-nexus/driftbench-validators": "0.1.0",
|
|
59
|
+
"@agent-nexus/driftbench-sandbox": "0.1.0"
|
|
60
|
+
},
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public",
|
|
63
|
+
"provenance": true
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "tsup src/index.ts src/bin.ts --format esm --dts --clean --target node22"
|
|
67
|
+
}
|
|
6
68
|
}
|