niceeval 0.21.1-canary.132 → 0.22.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/dist/agents/deepseek-harness.js +14 -11
- package/dist/experiment/host/cli/contribution.js +11 -6
- package/dist/o11y/parsers/codex.js +8 -4
- package/dist/record/sqlite/admission-repository.js +4 -14
- package/dist/record/sqlite/database.d.ts +5 -0
- package/dist/record/sqlite/database.js +46 -7
- package/dist/record/sqlite/project-state-database.js +3 -3
- package/dist/runner/direct-agent-sandbox.js +1 -1
- package/dist/sandbox/e2b-snapshot-driver.js +1 -1
- package/dist/sandbox/instabox/snapshot-driver.js +1 -1
- package/dist/sandbox/opensandbox/snapshot-driver.js +1 -1
- package/docs-site/zh/examples/ai-agent-application.mdx +1 -1
- package/docs-site/zh/examples/index.mdx +2 -2
- package/docs-site/zh/examples/integrations/ai-sdk-v7.mdx +2 -2
- package/docs-site/zh/examples/integrations/claude-sdk.mdx +2 -2
- package/docs-site/zh/examples/integrations/codex-sdk.mdx +2 -2
- package/docs-site/zh/examples/integrations/langgraph.mdx +2 -2
- package/docs-site/zh/examples/integrations/pi-sdk.mdx +2 -2
- package/docs-site/zh/introduction.mdx +1 -1
- package/docs-site/zh/reference/builtin-agents.mdx +4 -4
- package/docs-site/zh/tutorials/connect-otel.mdx +2 -2
- package/docs-site/zh/tutorials/connect-your-agent.mdx +1 -1
- package/docs-site/zh/tutorials/custom-application.mdx +1 -1
- package/docs-site/zh/tutorials/write-send.mdx +1 -1
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ const DSH_EVIDENCE_COVERAGE = {
|
|
|
18
18
|
data: { status: "unavailable", reason: "DSH headless mode does not expose a separate Turn.data value." },
|
|
19
19
|
};
|
|
20
20
|
const DSH_PNPM_VERSION = "10.17.1";
|
|
21
|
+
const DSH_RUN_PATCH = "niceeval.patch.yml";
|
|
21
22
|
function dshPluginLayer(cliVersion, plugins) {
|
|
22
23
|
const identity = {
|
|
23
24
|
agent: "deepseek-harness-plugins",
|
|
@@ -95,17 +96,18 @@ export function deepSeekHarnessAgent(config) {
|
|
|
95
96
|
throw new Error("DeepSeek Harness setup requires an absolute sandbox HOME directory");
|
|
96
97
|
}
|
|
97
98
|
const dshHome = `${home}/.niceeval-dsh`;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
defaultPreset: "danger-full-access",
|
|
99
|
+
const patch = [
|
|
100
|
+
{
|
|
101
|
+
id: "agent-default-model",
|
|
102
|
+
config: {
|
|
103
|
+
provider: "deepseek-official",
|
|
104
|
+
model: ctx.model ?? "deepseek-v4-flash",
|
|
105
|
+
},
|
|
106
106
|
},
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
{ id: "permission", config: { defaultPreset: "danger-full-access" } },
|
|
108
|
+
];
|
|
109
|
+
await sb.writeText(`${dshHome}/${DSH_RUN_PATCH}`, JSON.stringify(patch, null, 2));
|
|
110
|
+
homes.set(sb.sandboxId, dshHome);
|
|
109
111
|
},
|
|
110
112
|
catch: (cause) => cause,
|
|
111
113
|
}),
|
|
@@ -124,8 +126,9 @@ export function deepSeekHarnessAgent(config) {
|
|
|
124
126
|
const baseUrl = resolveBaseUrl(config);
|
|
125
127
|
if (baseUrl)
|
|
126
128
|
env.DEEPSEEK_BASE_URL = baseUrl;
|
|
129
|
+
const args = ["--profile", "headless", "--patch", `${dshHome}/${DSH_RUN_PATCH}`, input.text];
|
|
127
130
|
const res = yield* Effect.tryPromise({
|
|
128
|
-
try: (signal) => ctx.sandbox.runCommand(dshBin,
|
|
131
|
+
try: (signal) => ctx.sandbox.runCommand(dshBin, args, {
|
|
129
132
|
env,
|
|
130
133
|
sensitiveValues: knownSensitiveValues(apiKey),
|
|
131
134
|
stream: true,
|
|
@@ -342,18 +342,23 @@ function teardownFailure(operation, cause, recoveryKey) {
|
|
|
342
342
|
function dryRows(plan) {
|
|
343
343
|
const rows = new Map();
|
|
344
344
|
for (const slot of plan.slots) {
|
|
345
|
-
const
|
|
345
|
+
const { evalGroup, ...target } = slot.target;
|
|
346
|
+
const evalGroupId = evalGroup?.id;
|
|
347
|
+
const evalGroupIndex = evalGroup?.index;
|
|
348
|
+
const key = JSON.stringify([target.experimentId, target.evalId]);
|
|
346
349
|
const row = rows.get(key) ?? {
|
|
347
|
-
experimentId:
|
|
348
|
-
evalId:
|
|
349
|
-
evalGroupId
|
|
350
|
-
evalGroupIndex
|
|
350
|
+
experimentId: target.experimentId,
|
|
351
|
+
evalId: target.evalId,
|
|
352
|
+
evalGroupId,
|
|
353
|
+
evalGroupIndex,
|
|
351
354
|
slots: [],
|
|
352
355
|
readbacks: [],
|
|
353
356
|
locked: undefined,
|
|
354
357
|
};
|
|
355
358
|
row.slots.push({
|
|
356
|
-
...
|
|
359
|
+
...target,
|
|
360
|
+
evalGroupId,
|
|
361
|
+
evalGroupIndex,
|
|
357
362
|
state: slot.state === "reuse" ? "reused" : "gap",
|
|
358
363
|
comparisons: slot.comparisons,
|
|
359
364
|
reason: slot.state === "gap" ? slot.reason : undefined,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Codex exec JSONL and
|
|
1
|
+
// Codex exec JSONL and normalized app-server notifications share this parser.
|
|
2
2
|
import * as Schema from "effect/Schema";
|
|
3
3
|
import * as SchemaGetter from "effect/SchemaGetter";
|
|
4
4
|
import { GENERIC_VERB_ALIASES, normalizeToolName as normalizeShared } from "../tool-names.js";
|
|
@@ -16,6 +16,8 @@ const id = field(Schema.Union([Schema.String, Schema.Number]));
|
|
|
16
16
|
const TextBlock = Schema.Union([Schema.String, Schema.Struct({ text: string, content: string, thinking: string })]);
|
|
17
17
|
const Content = Schema.Union([Schema.String, Schema.Array(TextBlock)]);
|
|
18
18
|
const textFields = { text: field(Content), content: field(Content), summary: field(Schema.Array(TextBlock)) };
|
|
19
|
+
// Codex exec emits a string kind and app-server emits an object tagged by type.
|
|
20
|
+
const changeKind = field(Schema.Union([Schema.String, Schema.Struct({ type: Schema.String })]));
|
|
19
21
|
const itemFields = {
|
|
20
22
|
...textFields,
|
|
21
23
|
id,
|
|
@@ -38,7 +40,7 @@ const itemFields = {
|
|
|
38
40
|
query: json,
|
|
39
41
|
search: json,
|
|
40
42
|
results: json,
|
|
41
|
-
changes: field(Schema.Array(Schema.Struct({ path: json, file: json, kind:
|
|
43
|
+
changes: field(Schema.Array(Schema.Struct({ path: json, file: json, kind: changeKind, type: string }))),
|
|
42
44
|
path: json,
|
|
43
45
|
kind: string,
|
|
44
46
|
usage: field(TokenUsage),
|
|
@@ -276,14 +278,16 @@ export function parseCodexTranscript(raw) {
|
|
|
276
278
|
if (!completed)
|
|
277
279
|
return;
|
|
278
280
|
const changes = item.changes ?? [{ path: item.path, file: undefined, kind: undefined, type: undefined }];
|
|
281
|
+
const status = commandStatus(item.status, undefined);
|
|
279
282
|
changes.forEach((change, index) => {
|
|
280
283
|
const path = change.path ?? change.file;
|
|
281
|
-
const
|
|
284
|
+
const reportedKind = typeof change.kind === "string" ? change.kind : change.kind?.type;
|
|
285
|
+
const kind = (reportedKind ?? change.type ?? item.kind ?? "update").toLowerCase();
|
|
282
286
|
const tool = kind === "add" || kind === "delete" ? "file_write" : "file_edit";
|
|
283
287
|
const callId = `${baseId || "patch"}#${index}`;
|
|
284
288
|
const input = path === undefined ? { kind } : { path, kind };
|
|
285
289
|
emitCall(callId, "file_change", input, tool, notCommandProjection());
|
|
286
|
-
emitResult(callId, input,
|
|
290
|
+
emitResult(callId, input, status);
|
|
287
291
|
});
|
|
288
292
|
return;
|
|
289
293
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { recordStatement } from "./database.js";
|
|
2
|
+
import { clearRecordWriterOnConnection, recordStatement } from "./database.js";
|
|
3
3
|
import { sqliteError } from "./errors.js";
|
|
4
4
|
import { withImmediateTransaction } from "./transaction.js";
|
|
5
5
|
import { exactProcessState } from "../../coordination/platform/node-process-identity.js";
|
|
@@ -84,16 +84,6 @@ function coordinationState(connection) {
|
|
|
84
84
|
barrier,
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
-
function clearWriter(connection, owner) {
|
|
88
|
-
const result = recordStatement(connection, `UPDATE ne19_coordination_state SET
|
|
89
|
-
writer_ticket_id=NULL,writer_sequence=NULL,writer_host=NULL,writer_pid=NULL,
|
|
90
|
-
writer_boot_id=NULL,writer_process_start=NULL,
|
|
91
|
-
writer_deadline=NULL,writer_enqueued_at=NULL,writer_nonce=NULL,
|
|
92
|
-
writer_admitted_at=NULL,writer_lease_expires_at=NULL,revision=revision+1
|
|
93
|
-
WHERE singleton=1 AND writer_ticket_id=? AND writer_sequence=? AND writer_nonce=?`).run(owner.ticketId, owner.sequence, owner.nonce);
|
|
94
|
-
if (Number(result.changes) !== 1)
|
|
95
|
-
invalid("coordination", "writer owner changed while clearing");
|
|
96
|
-
}
|
|
97
87
|
function clearBarrier(connection, owner) {
|
|
98
88
|
const result = recordStatement(connection, `UPDATE ne19_coordination_state SET
|
|
99
89
|
barrier_id=NULL,barrier_nonce=NULL,barrier_host=NULL,barrier_pid=NULL,
|
|
@@ -114,7 +104,7 @@ function recover(connection, _now) {
|
|
|
114
104
|
}
|
|
115
105
|
const state = coordinationState(connection);
|
|
116
106
|
if (state.writer !== undefined && isExactlyDead(state.writer)) {
|
|
117
|
-
|
|
107
|
+
clearRecordWriterOnConnection(connection, state.writer);
|
|
118
108
|
}
|
|
119
109
|
if (state.barrier !== undefined && isExactlyDead(state.barrier)) {
|
|
120
110
|
clearBarrier(connection, state.barrier);
|
|
@@ -229,7 +219,7 @@ function runCancelWriter(connection, request) {
|
|
|
229
219
|
if (!sameWriter(writer, { ...request, sequence: writer.sequence })) {
|
|
230
220
|
invalid(request.operation, "writer cancellation identity does not match its owner");
|
|
231
221
|
}
|
|
232
|
-
|
|
222
|
+
clearRecordWriterOnConnection(connection, writer);
|
|
233
223
|
}
|
|
234
224
|
}
|
|
235
225
|
function runReleaseWriter(connection, request) {
|
|
@@ -240,7 +230,7 @@ function runReleaseWriter(connection, request) {
|
|
|
240
230
|
if (!sameWriter(writer, request)) {
|
|
241
231
|
invalid(request.operation, "writer release identity does not match its owner");
|
|
242
232
|
}
|
|
243
|
-
|
|
233
|
+
clearRecordWriterOnConnection(connection, writer);
|
|
244
234
|
}
|
|
245
235
|
function runRequestBarrier(connection, request) {
|
|
246
236
|
recover(connection, request.requestedAt);
|
|
@@ -39,6 +39,11 @@ export declare function checkpointRecordDatabase(connection: RecordDatabase): vo
|
|
|
39
39
|
export declare function reopenProjectDatabase(path: string): void;
|
|
40
40
|
/** Reopen and owner admission share the caller's BEGIN IMMEDIATE transaction. */
|
|
41
41
|
export declare function reopenProjectDatabaseOnConnection(connection: RecordDatabase): void;
|
|
42
|
+
export declare function clearRecordWriterOnConnection(connection: RecordDatabase, owner: {
|
|
43
|
+
readonly ticketId: string;
|
|
44
|
+
readonly sequence: number;
|
|
45
|
+
readonly nonce: string;
|
|
46
|
+
}): void;
|
|
42
47
|
/**
|
|
43
48
|
* Closes the project-wide writer admission and proves that the canonical file
|
|
44
49
|
* itself is portable. The first transaction deliberately persists draining;
|
|
@@ -607,6 +607,37 @@ export function reopenProjectDatabaseOnConnection(connection) {
|
|
|
607
607
|
currentStatement(connection.db, "UPDATE ne19_coordination_state SET operational_generation=?,revision=revision+1 WHERE singleton=1").run(generation);
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
|
+
export function clearRecordWriterOnConnection(connection, owner) {
|
|
611
|
+
const result = recordStatement(connection, `UPDATE ne19_coordination_state SET
|
|
612
|
+
writer_ticket_id=NULL,writer_sequence=NULL,writer_host=NULL,writer_pid=NULL,
|
|
613
|
+
writer_boot_id=NULL,writer_process_start=NULL,
|
|
614
|
+
writer_deadline=NULL,writer_enqueued_at=NULL,writer_nonce=NULL,
|
|
615
|
+
writer_admitted_at=NULL,writer_lease_expires_at=NULL,revision=revision+1
|
|
616
|
+
WHERE singleton=1 AND writer_ticket_id=? AND writer_sequence=? AND writer_nonce=?`).run(owner.ticketId, owner.sequence, owner.nonce);
|
|
617
|
+
if (Number(result.changes) !== 1)
|
|
618
|
+
throw sqliteError("record-database-invalid", "coordination", "writer owner changed while clearing");
|
|
619
|
+
}
|
|
620
|
+
function reclaimTerminatedWriter(connection) {
|
|
621
|
+
const writer = requiredRecordRow(recordStatement(connection, `SELECT writer_ticket_id,writer_sequence,writer_nonce,writer_host,writer_pid,writer_boot_id,
|
|
622
|
+
writer_process_start FROM ne19_coordination_state WHERE singleton=1`).get());
|
|
623
|
+
if (writer.writer_ticket_id === null)
|
|
624
|
+
return true;
|
|
625
|
+
const ticketId = decodeText(writer.writer_ticket_id, "writer_ticket_id");
|
|
626
|
+
if (exactProcessState({
|
|
627
|
+
ownerId: ticketId,
|
|
628
|
+
host: decodeText(writer.writer_host, "writer_host"),
|
|
629
|
+
pid: decodeInteger(writer.writer_pid, "writer_pid"),
|
|
630
|
+
bootId: decodeText(writer.writer_boot_id, "writer_boot_id"),
|
|
631
|
+
processStart: decodeText(writer.writer_process_start, "writer_process_start"),
|
|
632
|
+
}) !== "dead")
|
|
633
|
+
return false;
|
|
634
|
+
clearRecordWriterOnConnection(connection, {
|
|
635
|
+
ticketId,
|
|
636
|
+
sequence: decodeInteger(writer.writer_sequence, "writer_sequence"),
|
|
637
|
+
nonce: decodeText(writer.writer_nonce, "writer_nonce"),
|
|
638
|
+
});
|
|
639
|
+
return true;
|
|
640
|
+
}
|
|
610
641
|
/**
|
|
611
642
|
* Closes the project-wide writer admission and proves that the canonical file
|
|
612
643
|
* itself is portable. The first transaction deliberately persists draining;
|
|
@@ -630,6 +661,20 @@ export function makeProjectDatabasePortable(path) {
|
|
|
630
661
|
connection.db.exec("COMMIT");
|
|
631
662
|
return true;
|
|
632
663
|
}
|
|
664
|
+
const admittedActive = currentStatement(connection.db, `SELECT
|
|
665
|
+
(SELECT count(*) FROM ne19_run_resources WHERE terminal_state IS NULL)+
|
|
666
|
+
(SELECT count(*) FROM ne19_invocation_sessions WHERE state IN ('active','recovering'))+
|
|
667
|
+
(SELECT count(*) FROM ne19_case_locks)+
|
|
668
|
+
(SELECT count(*) FROM ne19_teardown_obligations)+
|
|
669
|
+
(SELECT count(*) FROM ne19_shared_state_generations s WHERE state_kind!='free' AND generation=(SELECT max(generation) FROM ne19_shared_state_generations WHERE state_key=s.state_key)) AS count`).get();
|
|
670
|
+
const hasActiveWork = decodeInteger(admittedActive.count, "active_runs") !== 0;
|
|
671
|
+
// Admission and this check share the SQLite write lock. A live or unproven
|
|
672
|
+
// writer keeps the gate open. A dead writer's exact ticket must be cleared
|
|
673
|
+
// before draining, where the schema forbids updates retaining a writer.
|
|
674
|
+
if (barrierState === "open" && (hasActiveWork || !reclaimTerminatedWriter(connection))) {
|
|
675
|
+
connection.db.exec("COMMIT");
|
|
676
|
+
return false;
|
|
677
|
+
}
|
|
633
678
|
if (barrierState === "draining") {
|
|
634
679
|
const previous = currentStatement(connection.db, `SELECT barrier_id,barrier_nonce,barrier_host,barrier_pid,
|
|
635
680
|
barrier_boot_id,barrier_process_start FROM ne19_coordination_state WHERE singleton=1`).get();
|
|
@@ -674,13 +719,7 @@ export function makeProjectDatabasePortable(path) {
|
|
|
674
719
|
else {
|
|
675
720
|
throw sqliteError("record-database-invalid", "portable-gate", "ProjectDatabase barrier state is invalid");
|
|
676
721
|
}
|
|
677
|
-
|
|
678
|
-
(SELECT count(*) FROM ne19_run_resources WHERE terminal_state IS NULL)+
|
|
679
|
-
(SELECT count(*) FROM ne19_invocation_sessions WHERE state IN ('active','recovering'))+
|
|
680
|
-
(SELECT count(*) FROM ne19_case_locks)+
|
|
681
|
-
(SELECT count(*) FROM ne19_teardown_obligations)+
|
|
682
|
-
(SELECT count(*) FROM ne19_shared_state_generations s WHERE state_kind!='free' AND generation=(SELECT max(generation) FROM ne19_shared_state_generations WHERE state_key=s.state_key)) AS count`).get();
|
|
683
|
-
if (decodeInteger(admittedActive.count, "active_runs") !== 0) {
|
|
722
|
+
if (hasActiveWork) {
|
|
684
723
|
currentStatement(connection.db, `UPDATE ne19_record_metadata SET barrier_state='open',portable_gate_id=NULL
|
|
685
724
|
WHERE singleton=1 AND barrier_state='draining' AND portable_gate_id=?`).run(gateId);
|
|
686
725
|
currentStatement(connection.db, `UPDATE ne19_coordination_state SET barrier_id=NULL,barrier_nonce=NULL,barrier_host=NULL,
|
|
@@ -126,9 +126,9 @@ function makeProjectStateResource() {
|
|
|
126
126
|
if (invocationPortableClosed)
|
|
127
127
|
return;
|
|
128
128
|
await close(portableRoot);
|
|
129
|
-
// Another Invocation may still own project-local work.
|
|
130
|
-
//
|
|
131
|
-
//
|
|
129
|
+
// Another Invocation may still own project-local work. The database
|
|
130
|
+
// stays open for that work, and the last Invocation to close will
|
|
131
|
+
// attempt portability after its own terminal writes.
|
|
132
132
|
finalizeInvocationPortable(recordSqlitePath(portableRoot));
|
|
133
133
|
invocationPortableClosed = true;
|
|
134
134
|
},
|
|
@@ -93,7 +93,7 @@ export function createEvalSandboxView(sandbox, baseDir, options) {
|
|
|
93
93
|
const plan = options.plans[index];
|
|
94
94
|
if (plan === undefined ||
|
|
95
95
|
plan.operation !== operation ||
|
|
96
|
-
plan.source !== path ||
|
|
96
|
+
resolve(plan.source) !== path ||
|
|
97
97
|
plan.target !== target ||
|
|
98
98
|
plan.sendOrdinal !== options.sendOrdinal() ||
|
|
99
99
|
JSON.stringify(plan.ignore) !== JSON.stringify(ignore)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @concord-file
|
|
2
|
-
// @concord-implements docs/feature/sandbox/architecture/
|
|
2
|
+
// @concord-implements docs/feature/sandbox/architecture/providers/e2b.md#远端-snapshot-driver
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { Effect } from "effect";
|
|
5
5
|
import { materializeE2BProviderPlan } from "./runtime.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @concord-file
|
|
2
|
-
// @concord-implements docs/feature/sandbox/architecture/
|
|
2
|
+
// @concord-implements docs/feature/sandbox/architecture/providers/instabox.md#远端-snapshot-driver
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { Effect, Schema } from "effect";
|
|
5
5
|
import { BeforeCacheSnapshotError } from "../remote-snapshot/driver.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @concord-file
|
|
2
|
-
// @concord-implements docs/feature/sandbox/architecture/
|
|
2
|
+
// @concord-implements docs/feature/sandbox/architecture/providers/opensandbox.md#远端-snapshot-driver
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { Effect } from "effect";
|
|
5
5
|
import { BeforeCacheSnapshotError } from "../remote-snapshot/driver.js";
|
|
@@ -6,7 +6,7 @@ description: "一个可运行的 AI SDK v6 Web Agent 评测项目,覆盖自写
|
|
|
6
6
|
|
|
7
7
|
这个项目演示如何用 `defineAgent` 把已有 HTTP Agent 接入 NiceEval。它适合需要控制自有协议和事件映射的应用。
|
|
8
8
|
|
|
9
|
-
- [查看完整源码](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
9
|
+
- [查看完整源码](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/ai-sdk)
|
|
10
10
|
- 本地目录:`examples/zh/ai-sdk/`
|
|
11
11
|
|
|
12
12
|
<Note>
|
|
@@ -20,11 +20,11 @@ description: "按被测对象选择可运行的 NiceEval 示例:Agent Framewor
|
|
|
20
20
|
| [pi-agent-core](/zh/examples/integrations/pi-sdk) | `createPiAgentEventStream` | 原生事件流、多轮、工具、HITL。SDK 没有 OTel |
|
|
21
21
|
| [LangGraph](/zh/examples/integrations/langgraph) | 手写自定义 SSE 帧映射 | Python 应用、多轮、工具、HITL |
|
|
22
22
|
|
|
23
|
-
每组源码都位于 [`examples/zh/origin/`](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
23
|
+
每组源码都位于 [`examples/zh/origin/`](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/origin) 和 [`examples/zh/tier1/`](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/tier1)。需要 OTel 或 Experiment Flags 时,再沿相同项目进入 `tier2/` 和 `tier3/`。每次运行的结果从项目本机的 `niceeval show`、`show --json` 或 `view` 审阅。
|
|
24
24
|
|
|
25
25
|
## 完整评测项目
|
|
26
26
|
|
|
27
|
-
[模拟 X 社交平台](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
27
|
+
[模拟 X 社交平台](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/llm-x) 展示文字与生图应用的评估。
|
|
28
28
|
人物、主页、推文和社交互动由 LLM 生成;评估直接调用应用方法,检查状态与内容关系。
|
|
29
29
|
接入方式见 [评估自定义 LLM 应用](/zh/tutorials/custom-application)。
|
|
30
30
|
|
|
@@ -8,8 +8,8 @@ description: "一个 AI SDK v7 聊天应用,对着它的 HTTP 接口无侵入
|
|
|
8
8
|
|
|
9
9
|
对比对象:
|
|
10
10
|
|
|
11
|
-
- **before**:[origin/ai-sdk-v7](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
12
|
-
- **after**:[tier1/ai-sdk-v7](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
11
|
+
- **before**:[origin/ai-sdk-v7](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/origin/ai-sdk-v7) —— 普通的 AI SDK v7 聊天应用(HTTP 服务器 + React 聊天 UI),还没接任何评估用例。
|
|
12
|
+
- **after**:[tier1/ai-sdk-v7](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/tier1/ai-sdk-v7) —— 同一个应用接入 NiceEval 之后的样子。
|
|
13
13
|
|
|
14
14
|
**接入方式**:内置的 `uiMessageStreamAgent` 可以直接连接 AI SDK UI Message Stream,也就是 `useChat` 后端使用的标准 SSE 协议。
|
|
15
15
|
Adapter 只需填写接口地址,并说明如何把 `model` 放进请求体。NiceEval 会处理会话重放、HITL 审批,以及工具和消息事件。
|
|
@@ -8,8 +8,8 @@ description: "一个 Claude Agent SDK 助手后端,接入 NiceEval 前后的
|
|
|
8
8
|
|
|
9
9
|
对比对象:
|
|
10
10
|
|
|
11
|
-
- **before**:[origin/claude-sdk](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
12
|
-
- **after**:[tier1/claude-sdk](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
11
|
+
- **before**:[origin/claude-sdk](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/origin/claude-sdk) —— 独立的 `@anthropic-ai/claude-agent-sdk` HTTP 服务,还没接任何评估用例。
|
|
12
|
+
- **after**:[tier1/claude-sdk](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/tier1/claude-sdk) —— 同一个应用接入 NiceEval 之后的样子。
|
|
13
13
|
|
|
14
14
|
**接入方式**:`createClaudeSdkEventStream`(从 `"niceeval/adapter"` 导出)把 Claude Agent SDK 的 `SDKMessage` 转成 NiceEval 的标准事件。
|
|
15
15
|
|
|
@@ -8,8 +8,8 @@ description: "一个 Codex SDK(目录里的编码 agent)后端,接入 Nice
|
|
|
8
8
|
|
|
9
9
|
对比对象:
|
|
10
10
|
|
|
11
|
-
- **before**:[origin/codex-sdk](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
12
|
-
- **after**:[tier1/codex-sdk](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
11
|
+
- **before**:[origin/codex-sdk](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/origin/codex-sdk) —— 独立的 `@openai/codex-sdk` HTTP 服务,还没接任何评估用例。
|
|
12
|
+
- **after**:[tier1/codex-sdk](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/tier1/codex-sdk) —— 同一个应用接入 NiceEval 之后的样子。
|
|
13
13
|
|
|
14
14
|
**接入方式**:`createCodexThreadEventStream`(从 `"niceeval/adapter"` 导出)把 Codex SDK 的 `ThreadEvent` 转成 NiceEval 的标准事件。
|
|
15
15
|
消息文本直接来自事件流。转换器会把 `command_execution`、`mcp_tool_call` 和 `file_change` 配对成 `operation.started` 与 `operation.finished`。
|
|
@@ -8,8 +8,8 @@ description: "一个纯 Python LangGraph + LangSmith OTel 导出的应用,接
|
|
|
8
8
|
|
|
9
9
|
对比对象:
|
|
10
10
|
|
|
11
|
-
- **before**:[`origin/langgraph`](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
12
|
-
- **after**:[tier1/langgraph](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
11
|
+
- **before**:[`origin/langgraph`](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/origin/langgraph) —— 纯 Python 的 `create_agent`(LangChain 1.x / LangGraph)HTTP 服务,还没接任何评估用例。
|
|
12
|
+
- **after**:[tier1/langgraph](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/tier1/langgraph) —— 同一个应用接入 NiceEval 之后的样子。
|
|
13
13
|
|
|
14
14
|
**接入方式**:这个应用使用自定义 JSON 帧,因此 Adapter 需要自行把每一帧转成 NiceEval 的标准事件。
|
|
15
15
|
`tool-input` 映射为 `operation.started`,`tool-output` 映射为 `operation.finished`,`text-delta` 累积成 `message`。
|
|
@@ -8,8 +8,8 @@ description: "一个 pi-agent-core(@earendil-works)助手后端,接入 NiceEva
|
|
|
8
8
|
|
|
9
9
|
对比对象:
|
|
10
10
|
|
|
11
|
-
- **before**:[origin/pi-sdk](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
12
|
-
- **after**:[tier1/pi-sdk](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
11
|
+
- **before**:[origin/pi-sdk](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/origin/pi-sdk) —— 独立的 `@earendil-works/pi-agent-core` HTTP 服务,还没接任何评估用例。
|
|
12
|
+
- **after**:[tier1/pi-sdk](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/tier1/pi-sdk) —— 同一个应用接入 NiceEval 之后的样子。
|
|
13
13
|
|
|
14
14
|
**接入方式**:`createPiAgentEventStream`(从 `"niceeval/adapter"` 导出)把 pi 原生 `AgentEvent` 转成 NiceEval 的标准事件。
|
|
15
15
|
|
|
@@ -80,7 +80,7 @@ export default defineEval({
|
|
|
80
80
|
</Card>
|
|
81
81
|
</CardGroup>
|
|
82
82
|
|
|
83
|
-
不是对话式 Agent 的应用,评估里调用的就是它自己的方法。下面是 [`examples/zh/llm-x`](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
83
|
+
不是对话式 Agent 的应用,评估里调用的就是它自己的方法。下面是 [`examples/zh/llm-x`](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/llm-x) 里一个 AI 社交应用的评估:
|
|
84
84
|
|
|
85
85
|
```ts
|
|
86
86
|
// evals/social-journey.eval.ts —— 被测对象是一个 AI 驱动的社交应用
|
|
@@ -30,7 +30,7 @@ description: "查看 claude-code、codex、bub 与 Antigravity CLI 适配器的
|
|
|
30
30
|
<Warning>
|
|
31
31
|
`claude-code` 和 `codex` 支持 HITL:Agent 调用原生提问工具(Claude Code 的 `AskUserQuestion`、Codex 的 `request_user_input`)时,`send` 返回 `status: "waiting"` 和 `input.requested` 事件,用 `t.respond()` 或模拟用户回答后继续同一轮。文字提问随该轮回复返回,`t.send()` 可继续下一轮。`bub` 和 `agy` 只支持普通对话。
|
|
32
32
|
|
|
33
|
-
其它被测对象需要 `t.respond()` / `t.requireInputRequest()` 时:被测对象是 AI SDK `useChat` 后端的话,用下文的内置 `uiMessageStreamAgent`(v7 tool approval 原生映射成 HITL)。其它被测对象自己写 adapter:实现 `waiting` 状态 + `input.requested` 事件 + resume 交回,[`examples/zh/tier1/pi-sdk`](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
33
|
+
其它被测对象需要 `t.respond()` / `t.requireInputRequest()` 时:被测对象是 AI SDK `useChat` 后端的话,用下文的内置 `uiMessageStreamAgent`(v7 tool approval 原生映射成 HITL)。其它被测对象自己写 adapter:实现 `waiting` 状态 + `input.requested` 事件 + resume 交回,[`examples/zh/tier1/pi-sdk`](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/tier1/pi-sdk) / [`examples/zh/tier1/claude-sdk`](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/tier1/claude-sdk) 都有手写 HITL 的现成参考。
|
|
34
34
|
</Warning>
|
|
35
35
|
|
|
36
36
|
## 逐 agent 细节
|
|
@@ -425,7 +425,7 @@ export default uiMessageStreamAgent({
|
|
|
425
425
|
- **拒绝**:调用以 `rejected` 落进事件流,且默认带「不要重试」的 reason(`denyReason` 可覆盖)——不带的话模型经常原样重发同一个调用。
|
|
426
426
|
- **usage / 瀑布图**:UI Message Stream 协议帧里没有 usage,所以 `t.maxTokens` 这类用量断言在这个内置件上默认没有数据(应用把 usage 放进 message metadata 属于应用自己的协议扩展)。瀑布图是另一回事:应用有 OTel 埋点(如官方 `@ai-sdk/otel`)时,按 [OTel 接入](/zh/tutorials/connect-otel)把 span 发给 [NiceEval](https://niceeval.com/),`niceeval view` 就有完整瀑布图——span 只进瀑布图,不喂断言。
|
|
427
427
|
|
|
428
|
-
需要在评估用例项目里安装 `ai`(可选 peer 依赖,协议 reducer 来自它)。完整可跑示例:[`examples/zh/tier1/ai-sdk-v7`](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
428
|
+
需要在评估用例项目里安装 `ai`(可选 peer 依赖,协议 reducer 来自它)。完整可跑示例:[`examples/zh/tier1/ai-sdk-v7`](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/tier1/ai-sdk-v7)。
|
|
429
429
|
|
|
430
430
|
`uiMessageStreamAgent(options)` 完整参数(`UiMessageStreamAgentOptions`):
|
|
431
431
|
|
|
@@ -547,7 +547,7 @@ return driveFrameStream(frames, stream, ctx); // 逐帧喂 stream.add()
|
|
|
547
547
|
- **`createPiAgentEventStream`**(pi-agent-core `AgentEvent`):`message_end` 的文本/thinking/usage、`tool_execution_start/end` 的工具对。
|
|
548
548
|
- **`createCodexThreadEventStream`**(Codex SDK `ThreadEvent`):`agent_message`/`reasoning` 的消息类。工具项包括:`command_execution` / `mcp_tool_call` / `file_change` / `web_search` → 配对的 tool `operation.started` + `operation.finished`。`turn.completed` 的 usage、错误帧。瀑布图要 codex CLI 原生 OTLP(config.toml 的 `[otel]` 块)把 span 发给 [NiceEval](https://niceeval.com/),配官方 `mapCodexSpans` 归一。
|
|
549
549
|
|
|
550
|
-
可运行的参考实现位于 [`examples/zh/tier1`](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
550
|
+
可运行的参考实现位于 [`examples/zh/tier1`](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/tier1)。其中 Claude SDK、pi SDK 和 Codex SDK 的 Adapter 都由转换器、`driveFrameStream` 和应用接口配置组成。
|
|
551
551
|
|
|
552
552
|
## 通用「拼装方式」件:`driveFrameStream` / `deltaStream` + `ctx.session`
|
|
553
553
|
|
|
@@ -607,7 +607,7 @@ export default defineAgent({
|
|
|
607
607
|
## 怎么选
|
|
608
608
|
|
|
609
609
|
- 被测对象是 AI SDK 应用(`useChat` 后端):内置 `uiMessageStreamAgent` 无侵入接入,零映射(含 HITL)。
|
|
610
|
-
- 被测对象是其它 agent 系统(HTTP / gRPC 服务):无侵入接入,手写事件映射(官方转换器能覆盖大半)——[`examples/zh/tier1`](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
610
|
+
- 被测对象是其它 agent 系统(HTTP / gRPC 服务):无侵入接入,手写事件映射(官方转换器能覆盖大半)——[`examples/zh/tier1`](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/tier1) 下五个示例全是这条路。应用已埋 OTel 的话顺手接上,多一张瀑布图。
|
|
611
611
|
- 需要调用瀑布图(`niceeval view` 的 trace):`claude-code` / `codex` / `bub` 三个都自发 OTLP(claude-code 走 CLI 的 beta 遥测,span 只有结构与计时)。自己写的 adapter 声明 `tracing` 即可(见 OTel 指南)。
|
|
612
612
|
- 需要人工审批 / 多步确认(HITL):`uiMessageStreamAgent` 原生支持(AI SDK v7 tool approval)。Sandbox 型里 `claude-code` 与 `codex` 支持,`bub` 不支持;其它被测对象自己写 Adapter,拿 `driveFrameStream` + typed key 拼(Tier 1 示例里 pi-sdk / claude-sdk 有现成写法)。
|
|
613
613
|
- 想跑一个 coding agent 改代码、看 diff、判断工具调用:`claude-code` / `codex` / `bub`(收发 + 事件流 + 会话续接 + workspace + sandbox)。
|
|
@@ -85,7 +85,7 @@ export default defineAgent({
|
|
|
85
85
|
});
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
exporter 走标准 OTel Node SDK,endpoint 指向 [NiceEval](https://niceeval.com/)(注入的 env 或固定端口)。可跑示例:应用侧埋点见 [`examples/zh/origin/ai-sdk-v7`](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
88
|
+
exporter 走标准 OTel Node SDK,endpoint 指向 [NiceEval](https://niceeval.com/)(注入的 env 或固定端口)。可跑示例:应用侧埋点见 [`examples/zh/origin/ai-sdk-v7`](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/origin/ai-sdk-v7)(`src/backend/otel.ts`,官方 `@ai-sdk/otel`),接入后的完整评测项目见 [`examples/zh/tier1/ai-sdk-v7`](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/tier1/ai-sdk-v7)。
|
|
89
89
|
</Tab>
|
|
90
90
|
<Tab title="LangGraph / LangChain">
|
|
91
91
|
零依赖路线,三个环境变量:
|
|
@@ -98,7 +98,7 @@ export default defineAgent({
|
|
|
98
98
|
node server.js # 端点值按「向应用提供端点」一节选择:注入的 env 或固定端口
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
`LANGSMITH_OTEL_ONLY` 表示只发 OTLP、不发 LangSmith 云端。需要双发时移除该变量。**Python** 版 `langsmith` SDK 会在 import 时自动注册 OTel hook。**JS** 版(`langsmith@0.7.x`)还需要显式调用 `langsmith/experimental/otel/setup` 导出的 `initializeOTEL()`,否则只输出警告,不产生 span。三个环境变量保持不变。Python 后端示例见 [`examples/zh/origin/langgraph`](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
101
|
+
`LANGSMITH_OTEL_ONLY` 表示只发 OTLP、不发 LangSmith 云端。需要双发时移除该变量。**Python** 版 `langsmith` SDK 会在 import 时自动注册 OTel hook。**JS** 版(`langsmith@0.7.x`)还需要显式调用 `langsmith/experimental/otel/setup` 导出的 `initializeOTEL()`,否则只输出警告,不产生 span。三个环境变量保持不变。Python 后端示例见 [`examples/zh/origin/langgraph`](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/origin/langgraph),完整评测项目见 [`examples/zh/tier1/langgraph`](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/tier1/langgraph)。
|
|
102
102
|
</Tab>
|
|
103
103
|
<Tab title="OpenLLMetry">
|
|
104
104
|
```ts
|
|
@@ -169,4 +169,4 @@ async send(input, ctx) {
|
|
|
169
169
|
|
|
170
170
|
## 参考实现
|
|
171
171
|
|
|
172
|
-
[`examples/zh/tier1`](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
172
|
+
[`examples/zh/tier1`](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/tier1) 有五个可运行的接入示例:AI SDK v7、Claude SDK、Codex SDK、Pi SDK 和 LangGraph。它们覆盖工具调用断言、多轮隔离、HITL 的批准与拒绝,以及调用瀑布图。`send` 的完整字段见 [Adapter](/zh/explanation/adapter),全部官方适配器见[官方适配器一览](/zh/reference/official-adapters)。
|
|
@@ -279,5 +279,5 @@ NiceEval 没有采集到的会话、工具调用和费用会显示为缺失,
|
|
|
279
279
|
|
|
280
280
|
因为拿不到应用的完整费用,自定义应用不能设置 `budget`,也不能声明只有 Agent 才有的 Sandbox 或会话能力。生命周期 Plugin 需要 Agent 的执行准备步骤,在自定义应用上配置它们会在运行前报错。
|
|
281
281
|
|
|
282
|
-
完整可运行的模拟 X 示例位于 [LLM X 源码](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
282
|
+
完整可运行的模拟 X 示例位于 [LLM X 源码](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/llm-x)。
|
|
283
283
|
它由 LLM 生成人物、个人主页、推文、配图和后续社交动态,并使用应用原生方法进行评估。
|
|
@@ -260,7 +260,7 @@ Chat Completions 响应**不保证列出全过程**。应用可能在服务端
|
|
|
260
260
|
|
|
261
261
|
HTTP 请求由 `openSseJsonFrames` 交给 Attempt 持有,跨 callback 保持连接。评估在等待时结束,Attempt 也会关闭它。
|
|
262
262
|
|
|
263
|
-
HITL 几乎总发生在流式接口上,应用停在流的中间。所以这一步的示例换成一个用 SSE 透传原生事件的应用,它同时用上前面几步的全部内容(完整可跑版本见 [tier1 示例](https://github.com/NiceEval/NiceEval/tree/v0.
|
|
263
|
+
HITL 几乎总发生在流式接口上,应用停在流的中间。所以这一步的示例换成一个用 SSE 透传原生事件的应用,它同时用上前面几步的全部内容(完整可跑版本见 [tier1 示例](https://github.com/NiceEval/NiceEval/tree/v0.22.0/examples/zh/tier1)):
|
|
264
264
|
|
|
265
265
|
```ts
|
|
266
266
|
// agents/my-app.ts
|