@danceiny/gotry 0.0.1-rc.18 → 0.0.1-rc.20
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 +42 -16
- package/README.zh-CN.md +37 -15
- package/bin/gotry-bootstrap.js +309 -30
- package/bin/gotry-inner.js +74 -23
- package/bin/gotry-runtime-resolution.d.ts +1 -1
- package/bin/gotry-runtime-resolution.js +7 -8
- package/cordis.gotry-patch.yml +22 -8
- package/data/stations-12306-verify.json +524 -0
- package/dist/capabilities/agent-reach.js +4 -4
- package/dist/capabilities/anything.js +62 -29
- package/dist/capabilities/channel-health.js +103 -0
- package/dist/capabilities/channel-registry.js +213 -0
- package/dist/capabilities/doctor.js +307 -0
- package/dist/capabilities/effect.js +178 -5
- package/dist/capabilities/flyai.js +13 -0
- package/dist/capabilities/hbcli.js +28 -2
- package/dist/capabilities/session/adapters/ctrip-hotel.js +207 -0
- package/dist/capabilities/session/adapters/rail-12306.js +285 -0
- package/dist/capabilities/session/extension-bridge.js +14 -1
- package/dist/capabilities/session/extension-channel.js +4 -2
- package/dist/capabilities/session/extension-distribution.js +1 -1
- package/dist/capabilities/session-search.js +311 -0
- package/dist/capabilities/visa-policy.js +126 -0
- package/dist/scripts/agent-planning-turn-deadline-e2e.js +305 -0
- package/dist/scripts/agent-planning-turn-deadline-tests.js +281 -0
- package/dist/scripts/anything-tests.js +70 -21
- package/dist/scripts/benchmark-environment-bridge-e2e.js +139 -37
- package/dist/scripts/benchmark-environment-bridge-tests.js +1099 -306
- package/dist/scripts/booking-copilot-availability-ledger-binding-tests.js +26 -26
- package/dist/scripts/{booking-copilot-availability-policy-v2-tests.js → booking-copilot-availability-policy-tests.js} +115 -115
- package/dist/scripts/booking-copilot-crossrepo-fixture-server.js +41 -1
- package/dist/scripts/booking-copilot-dsh-core-proof-tests.js +75 -120
- package/dist/scripts/booking-copilot-dsh-planner-proof-tests.js +370 -61
- package/dist/scripts/booking-copilot-dsh-plugin-proof-tests.js +2 -2
- package/dist/scripts/booking-copilot-event-sequence-concurrency-proof-tests.js +7 -3
- package/dist/scripts/booking-copilot-gap-code-contract-proof-tests.js +15 -9
- package/dist/scripts/booking-copilot-operation-ledger-concurrency-proof-tests.js +19 -11
- package/dist/scripts/booking-copilot-receipt-ledger-concurrency-proof-tests.js +16 -52
- package/dist/scripts/booking-copilot-runtime-proof-tests.js +3953 -155
- package/dist/scripts/booking-copilot-server-proof-tests.js +58 -23
- package/dist/scripts/booking-copilot-startup-proof-tests.js +10 -119
- package/dist/scripts/booking-surface-contract-proof-tests.js +1154 -326
- package/dist/scripts/bootstrap-tests.js +113 -2
- package/dist/scripts/build-metrics-report.js +339 -0
- package/dist/scripts/channel-probe-tests.js +148 -0
- package/dist/scripts/channel-probe.js +252 -0
- package/dist/scripts/channel-registry-tests.js +262 -0
- package/dist/scripts/doctor-tests.js +175 -0
- package/dist/scripts/effect-tests.js +274 -1
- package/dist/scripts/extension-tests.js +129 -11
- package/dist/scripts/fact-gate-tests.js +91 -2
- package/dist/scripts/flyai-tests.js +17 -1
- package/dist/scripts/hbcli-e2e-tests.js +1 -3
- package/dist/scripts/hbcli-tests.js +38 -1
- package/dist/scripts/metrics-report-tests.js +288 -0
- package/dist/scripts/persona-surface-guard-tests.js +19 -0
- package/dist/scripts/session-tests.js +401 -1
- package/dist/scripts/smoke.js +100 -83
- package/dist/scripts/turn-handoff-collect-tests.js +216 -0
- package/dist/scripts/turn-handoff-collect.js +189 -0
- package/dist/scripts/turn-policy-tests.js +56 -0
- package/dist/scripts/typed-contract-canary.js +261 -0
- package/dist/scripts/visa-policy-tests.js +75 -0
- package/dist/scripts/wish-channel-gate-tests.js +111 -0
- package/dist/src/artifact-gate.js +91 -3
- package/dist/src/benchmark-agent-conformance.js +39 -16
- package/dist/src/benchmark-environment-bridge.js +316 -52
- package/dist/src/bookable-facts.js +62 -3
- package/dist/src/booking-surface/{availability-policy-v2.js → availability-policy.js} +89 -89
- package/dist/src/booking-surface/canonical-schema.js +8 -22
- package/dist/src/booking-surface/contracts.js +70 -19
- package/dist/src/booking-surface/dsh-planner.js +310 -177
- package/dist/src/booking-surface/dsh-plugin.js +3 -3
- package/dist/src/booking-surface/index.js +1 -5
- package/dist/src/booking-surface/profile.js +1 -1
- package/dist/src/booking-surface/runtime.js +1682 -247
- package/dist/src/booking-surface/server.js +371 -185
- package/dist/src/booking-surface/startup.js +17 -27
- package/dist/src/booking-surface/validation.js +270 -760
- package/dist/src/index.js +739 -150
- package/dist/src/turn-deadline.js +292 -0
- package/dist/src/turn-policy.js +146 -0
- package/dist/src/wish-pool.js +5 -0
- package/extension/background.js +23 -4
- package/extension/content-main.js +47 -9
- package/extension/manifest.json +27 -9
- package/package.json +7 -26
- package/schemas/booking.surface.schema.json +2593 -0
- package/ts/capabilities/agent-reach.ts +4 -4
- package/ts/capabilities/anything.ts +89 -38
- package/ts/capabilities/flyai.ts +21 -3
- package/ts/capabilities/hbcli.ts +53 -4
- package/ts/capabilities/session/action-cache.ts +1 -1
- package/ts/capabilities/session/adapters/ctrip-hotel.ts +238 -0
- package/ts/capabilities/session/adapters/rail-12306.ts +293 -0
- package/ts/capabilities/session/extension-bridge.ts +32 -2
- package/ts/capabilities/session/extension-channel.ts +9 -8
- package/ts/capabilities/session/extension-distribution.ts +3 -1
- package/ts/capabilities/session/health-watch.ts +1 -1
- package/ts/capabilities/session/read-guard.ts +1 -1
- package/ts/capabilities/session/wizard.ts +1 -1
- package/ts/capabilities/session-search.ts +323 -1
- package/ts/dsh-runtime/vendor/README.md +60 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/LICENSE +21 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/README.en.md +200 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/README.md +202 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/client/client.js +216 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/cordis.patch.yml +5 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/amap.js +371 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/nominatim.js +63 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/osrm.js +56 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/photon.js +55 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config-file.js +87 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config-route.js +126 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config.js +16 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/index.js +109 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/settings-ns.js +27 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/geocode.js +127 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/poi.js +84 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/routes.js +170 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/amap.d.ts +53 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/nominatim.d.ts +17 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/osrm.d.ts +15 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/photon.d.ts +22 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config-file.d.ts +33 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config-route.d.ts +20 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config.d.ts +23 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/index.d.ts +18 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/settings-ns.d.ts +14 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/geocode.d.ts +11 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/poi.d.ts +9 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/routes.d.ts +16 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/types.d.ts +55 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types.js +16 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/package.json +91 -0
- package/ts/package.json +9 -0
- package/ts/scripts/turn-handoff-collect.ts +178 -0
- package/ts/src/artifact-gate.ts +82 -2
- package/ts/src/benchmark-agent-conformance.ts +54 -15
- package/ts/src/benchmark-environment-bridge.ts +234 -46
- package/ts/src/bookable-facts.ts +109 -5
- package/ts/src/booking-saga.ts +1 -1
- package/ts/src/booking-surface/{availability-policy-v2.ts → availability-policy.ts} +124 -125
- package/ts/src/booking-surface/canonical-schema.js +8 -22
- package/ts/src/booking-surface/contracts.ts +278 -239
- package/ts/src/booking-surface/dsh-planner.ts +333 -194
- package/ts/src/booking-surface/dsh-plugin.js +3 -3
- package/ts/src/booking-surface/index.ts +1 -5
- package/ts/src/booking-surface/profile.ts +11 -11
- package/ts/src/booking-surface/runtime.ts +1351 -351
- package/ts/src/booking-surface/server.ts +282 -175
- package/ts/src/booking-surface/startup.ts +36 -48
- package/ts/src/booking-surface/validation.ts +194 -442
- package/ts/src/contracts.ts +1 -1
- package/ts/src/index.ts +492 -172
- package/ts/src/loop.ts +1 -1
- package/ts/src/state-ledger.ts +1 -1
- package/ts/src/turn-deadline.ts +365 -0
- package/ts/src/turn-policy.ts +154 -0
- package/ts/src/wish-pool.ts +17 -4
- package/dist/scripts/agent-planning-budget-e2e.js +0 -227
- package/dist/scripts/agent-planning-budget-tests.js +0 -173
- package/dist/scripts/booking-copilot-v2-runtime-proof-tests.js +0 -3935
- package/dist/scripts/booking-surface-v2-contract-proof-tests.js +0 -1174
- package/dist/src/booking-surface/contracts-v2.js +0 -89
- package/dist/src/booking-surface/runtime-v2.js +0 -1771
- package/dist/src/booking-surface/server-v2.js +0 -334
- package/dist/src/booking-surface/validation-v2.js +0 -319
- package/dist/src/tool-budget.js +0 -136
- package/schemas/booking.surface.v1.schema.json +0 -927
- package/schemas/booking.surface.v2.schema.json +0 -61
- package/ts/src/booking-surface/contracts-v2.ts +0 -118
- package/ts/src/booking-surface/runtime-v2.ts +0 -1466
- package/ts/src/booking-surface/server-v2.ts +0 -247
- package/ts/src/booking-surface/validation-v2.ts +0 -205
- package/ts/src/tool-budget.ts +0 -165
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flightClaimVerdict, itineraryInvariants, latestFactsForRouteDate } from './bookable-facts.js';
|
|
1
|
+
import { flightClaimVerdict, hotelClaimVerdict, itineraryInvariants, latestFactsForRouteDate } from './bookable-facts.js';
|
|
2
2
|
export const ARTIFACT_GATE_SCHEMA = 'gotry_artifact_gate.v1';
|
|
3
3
|
const FLIGHT_NO = /(?<![A-Za-z0-9])([A-Z0-9]{2}\d{3,4})(?![\d])/g;
|
|
4
4
|
const CARRIER_DIRECT = /(?<![A-Za-z0-9])([A-Z0-9]{2})(?!\d)(?:\s|[一-龥]){0,6}直飞/g;
|
|
@@ -26,6 +26,12 @@ function hasDirectAssertion(line) {
|
|
|
26
26
|
const before = line.slice(Math.max(0, idx - 3), idx);
|
|
27
27
|
return !(before.endsWith('无') || before.endsWith('不') || before.endsWith('没有') || before.endsWith('未见'));
|
|
28
28
|
}
|
|
29
|
+
function occ1(line, map) {
|
|
30
|
+
for (const city of Object.keys(map.city_alias)){
|
|
31
|
+
if (line.includes(city)) return city;
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
29
35
|
function routeCtxOf(text, map, defaultYear) {
|
|
30
36
|
const occ = [];
|
|
31
37
|
for (const [city, iata] of Object.entries(map.city_alias)){
|
|
@@ -72,13 +78,21 @@ export function extractClaims(markdown, map, opts) {
|
|
|
72
78
|
flights: [],
|
|
73
79
|
policies: [],
|
|
74
80
|
airports: [],
|
|
75
|
-
direct_lines: []
|
|
81
|
+
direct_lines: [],
|
|
82
|
+
hotels: [],
|
|
83
|
+
anchors: new Map()
|
|
76
84
|
};
|
|
77
85
|
const lines = markdown.split('\n');
|
|
78
86
|
let section = {};
|
|
87
|
+
const ANCHOR = /fact:([0-9a-f]{16})/;
|
|
79
88
|
for(let i = 0; i < lines.length; i++){
|
|
80
89
|
const line = lines[i];
|
|
81
90
|
const lineNo = i + 1;
|
|
91
|
+
const anchorMatch = line.match(ANCHOR);
|
|
92
|
+
if (anchorMatch) {
|
|
93
|
+
claims.anchors.set(lineNo, anchorMatch[1].toLowerCase());
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
82
96
|
if (/^#{1,4}\s/.test(line)) {
|
|
83
97
|
const ctx = routeCtxOf(line, map, opts?.trip_year);
|
|
84
98
|
section = {
|
|
@@ -145,6 +159,20 @@ export function extractClaims(markdown, map, opts) {
|
|
|
145
159
|
has_as_of: AS_OF_WORD.test(line)
|
|
146
160
|
});
|
|
147
161
|
}
|
|
162
|
+
const HOTEL_ASSERT = /酒店|住宿|客栈|民宿/;
|
|
163
|
+
const HOTEL_BOOKABLE = /有房|可订|在架|已核验|已验证|可住|✓|✅/;
|
|
164
|
+
if (HOTEL_ASSERT.test(line) && HOTEL_BOOKABLE.test(line)) {
|
|
165
|
+
const stays = [
|
|
166
|
+
...line.matchAll(/(?<!\d)(\d{4}-\d{2}-\d{2})(?!\d)/g)
|
|
167
|
+
].map((m)=>m[1]);
|
|
168
|
+
claims.hotels.push({
|
|
169
|
+
line: lineNo,
|
|
170
|
+
text: line.trim().slice(0, 160),
|
|
171
|
+
destination: occ1(line, map),
|
|
172
|
+
check_in: stays[0],
|
|
173
|
+
check_out: stays[1]
|
|
174
|
+
});
|
|
175
|
+
}
|
|
148
176
|
for (const [city, carriers] of Object.entries(map.carrier_airport)){
|
|
149
177
|
const airports = [
|
|
150
178
|
...new Set(Object.values(carriers))
|
|
@@ -176,6 +204,66 @@ export function gateArtifact(markdown, facts, map, opts) {
|
|
|
176
204
|
const claims = extractClaims(markdown, map, opts);
|
|
177
205
|
const violations = [];
|
|
178
206
|
let traceable = 0;
|
|
207
|
+
for (const [lineNo, factId] of claims.anchors){
|
|
208
|
+
const f = facts.find((x)=>x.fact_id === factId);
|
|
209
|
+
if (!f) {
|
|
210
|
+
violations.push({
|
|
211
|
+
kind: 'fact_anchor_unknown',
|
|
212
|
+
line: lineNo,
|
|
213
|
+
detail: `渲染锚点 fact:${factId} 不在事实注册表——锚点被手改或伪造,产物不可信`
|
|
214
|
+
});
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (f.kind !== 'policy' && f.bookability === 'unavailable_exact_date') {
|
|
218
|
+
violations.push({
|
|
219
|
+
kind: 'not_in_source',
|
|
220
|
+
line: lineNo,
|
|
221
|
+
detail: `锚点事实为 exact-date 负事实(${f.fetched_at ?? ''})——负事实对应的可住/可订断言不得出现`
|
|
222
|
+
});
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
traceable++;
|
|
226
|
+
}
|
|
227
|
+
for (const c of claims.hotels){
|
|
228
|
+
if (claims.anchors.has(c.line)) continue;
|
|
229
|
+
if (!c.destination) {
|
|
230
|
+
violations.push({
|
|
231
|
+
kind: 'unverifiable_hotel_claim',
|
|
232
|
+
line: c.line,
|
|
233
|
+
detail: `酒店可住断言缺目的地上下文,无法回溯 exact-date 事实——fail closed 按未核验处理`
|
|
234
|
+
});
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
const r = hotelClaimVerdict(facts, {
|
|
238
|
+
destination: c.destination,
|
|
239
|
+
check_in: c.check_in,
|
|
240
|
+
check_out: c.check_out
|
|
241
|
+
});
|
|
242
|
+
if (r.verdict === 'traceable') {
|
|
243
|
+
traceable++;
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (r.verdict === 'unverified') {
|
|
247
|
+
violations.push({
|
|
248
|
+
kind: 'unverifiable_hotel_claim',
|
|
249
|
+
line: c.line,
|
|
250
|
+
detail: r.reason
|
|
251
|
+
});
|
|
252
|
+
} else {
|
|
253
|
+
violations.push({
|
|
254
|
+
kind: 'not_in_source',
|
|
255
|
+
line: c.line,
|
|
256
|
+
detail: r.reason
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
if (CHECK_MARK.test(c.text)) {
|
|
260
|
+
violations.push({
|
|
261
|
+
kind: 'unconditional_check',
|
|
262
|
+
line: c.line,
|
|
263
|
+
detail: '对未核验酒店使用无条件 ✓/✅——只有 bookable_exact_date 才允许确定性标记'
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
179
267
|
for (const c of claims.flights){
|
|
180
268
|
if (c.carrier_only) {
|
|
181
269
|
const hasCarrier = facts.some((f)=>f.kind === 'flight' && f.bookability === 'bookable_exact_date' && f.nonstop !== false && f.flight_no.startsWith(c.carrier_only) && (!c.origin || f.route.origin === c.origin || f.route.origin_airport === c.origin) && (!c.destination || f.route.destination === c.destination || f.route.dest_airport === c.destination) && (!c.date || f.date === c.date));
|
|
@@ -277,7 +365,7 @@ export function gateArtifact(markdown, facts, map, opts) {
|
|
|
277
365
|
const nos = [
|
|
278
366
|
...line.matchAll(FLIGHT_NO)
|
|
279
367
|
].map((m)=>m[1].toUpperCase());
|
|
280
|
-
const matched = facts.filter((f)=>f.kind
|
|
368
|
+
const matched = facts.filter((f)=>(f.kind === 'flight' || f.kind === 'train') && nos.includes(f.flight_no.toUpperCase()));
|
|
281
369
|
const allProtected = nos.length > 0 && matched.length === nos.length && matched.every((f)=>f.protected_connection === true);
|
|
282
370
|
if (!allProtected) {
|
|
283
371
|
violations.push({
|
|
@@ -12,6 +12,13 @@ export const BENCHMARK_BRIDGE_RETRY_CALL_NOT_ALLOWED = 'BENCHMARK_BRIDGE_RETRY_C
|
|
|
12
12
|
export const BENCHMARK_CONFORMANCE_STATE_UNAVAILABLE = 'BENCHMARK_CONFORMANCE_STATE_UNAVAILABLE';
|
|
13
13
|
const IDENTIFIER = /^[A-Za-z][A-Za-z0-9_.-]*$/;
|
|
14
14
|
const MAX_TERMINAL_BYTES = 1024 * 1024;
|
|
15
|
+
const BENCHMARK_TOOL_RESULT_SCHEMA_VERSION = 'gotry_benchmark_tool_result_v1';
|
|
16
|
+
const BENCHMARK_DOMAIN_RECOVERIES = new Set([
|
|
17
|
+
'none',
|
|
18
|
+
'retry_same',
|
|
19
|
+
'revise_arguments',
|
|
20
|
+
'choose_alternative'
|
|
21
|
+
]);
|
|
15
22
|
function plainObject(value) {
|
|
16
23
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
17
24
|
}
|
|
@@ -29,10 +36,13 @@ function invalidTerminal() {
|
|
|
29
36
|
error: 'invalid_terminal_output'
|
|
30
37
|
};
|
|
31
38
|
}
|
|
39
|
+
function stripReasoningBlocks(raw) {
|
|
40
|
+
return raw.replace(/<think>[\s\S]*?<\/think>\s*/gi, '');
|
|
41
|
+
}
|
|
32
42
|
export function parseBenchmarkTerminal(raw, config) {
|
|
33
43
|
if (!validateTerminalOutputConfig(config)) return invalidTerminal();
|
|
34
44
|
if (Buffer.byteLength(raw, 'utf8') > config.max_bytes) return invalidTerminal();
|
|
35
|
-
const trimmed = raw.trim();
|
|
45
|
+
const trimmed = stripReasoningBlocks(raw).trim();
|
|
36
46
|
const opening = `<${config.tag}>`;
|
|
37
47
|
const closing = `</${config.tag}>`;
|
|
38
48
|
if (!trimmed.startsWith(opening) || !trimmed.endsWith(closing)) return invalidTerminal();
|
|
@@ -87,13 +97,23 @@ function bridgeResultStatus(data, callId) {
|
|
|
87
97
|
try {
|
|
88
98
|
const parsed = JSON.parse(text);
|
|
89
99
|
if (!plainObject(parsed)) return undefined;
|
|
90
|
-
|
|
91
|
-
|
|
100
|
+
const keys = Object.keys(parsed).sort().join(',');
|
|
101
|
+
if (parsed.ok === true && keys === 'ok,result' && (plainObject(parsed.result) || Array.isArray(parsed.result))) return {
|
|
102
|
+
kind: 'result'
|
|
92
103
|
};
|
|
104
|
+
if (parsed.ok === true && keys === 'ok,outcome' && plainObject(parsed.outcome)) {
|
|
105
|
+
const outcomeKeys = Object.keys(parsed.outcome).sort().join(',');
|
|
106
|
+
if (outcomeKeys === 'code,recovery,schema_version,status' && parsed.outcome.schema_version === BENCHMARK_TOOL_RESULT_SCHEMA_VERSION && (parsed.outcome.status === 'miss' || parsed.outcome.status === 'error') && typeof parsed.outcome.code === 'string' && IDENTIFIER.test(parsed.outcome.code) && typeof parsed.outcome.recovery === 'string' && BENCHMARK_DOMAIN_RECOVERIES.has(parsed.outcome.recovery)) return {
|
|
107
|
+
kind: 'domain'
|
|
108
|
+
};
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
93
111
|
if (parsed.ok === false && typeof parsed.error === 'string') {
|
|
112
|
+
const exactFailure = parsed.error === 'runner_failed' ? keys === 'error,ok' || keys === 'error,exit_code,ok,signal' && (parsed.exit_code === null || typeof parsed.exit_code === 'number' && Number.isInteger(parsed.exit_code)) && (parsed.signal === null || typeof parsed.signal === 'string') : parsed.error === 'invalid_arguments' ? keys === 'error,ok,reason' && typeof parsed.reason === 'string' : keys === 'error,ok';
|
|
113
|
+
if (!exactFailure) return undefined;
|
|
94
114
|
const code = parsed.error === 'timed_out' ? BENCHMARK_BRIDGE_TIMED_OUT : parsed.error === 'runner_failed' ? BENCHMARK_BRIDGE_RUNNER_FAILED : parsed.error === 'spawn_failed' ? BENCHMARK_BRIDGE_SPAWN_FAILED : parsed.error === 'output_truncated' ? BENCHMARK_BRIDGE_OUTPUT_TRUNCATED : BENCHMARK_BRIDGE_CALL_FAILED;
|
|
95
115
|
return {
|
|
96
|
-
|
|
116
|
+
kind: 'failure',
|
|
97
117
|
code
|
|
98
118
|
};
|
|
99
119
|
}
|
|
@@ -150,8 +170,8 @@ export function createBenchmarkAgentConformance(projection) {
|
|
|
150
170
|
}
|
|
151
171
|
if (typeof event.data.callId !== 'string') return;
|
|
152
172
|
const args = parseToolArguments(event.data.arguments);
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
173
|
+
const flat = args && plainObject(args) ? args : undefined;
|
|
174
|
+
if (flat?.action === 'call' && typeof flat.tool === 'string' && projection.allowedTools.includes(flat.tool)) {
|
|
155
175
|
state.validCallIds.add(event.data.callId);
|
|
156
176
|
}
|
|
157
177
|
return;
|
|
@@ -161,8 +181,11 @@ export function createBenchmarkAgentConformance(projection) {
|
|
|
161
181
|
const callId = event.data.message.source.callId;
|
|
162
182
|
if (typeof callId !== 'string' || !state.validCallIds.has(callId)) return;
|
|
163
183
|
const resultStatus = bridgeResultStatus(event.data, callId);
|
|
164
|
-
if (
|
|
184
|
+
if (typeof event.data.step === 'number') state.lastBridgeResponseStep = event.data.step;
|
|
185
|
+
if (resultStatus?.kind === 'result') {
|
|
165
186
|
state.successfulResultStep = typeof event.data.step === 'number' ? event.data.step : state.successfulResultStep;
|
|
187
|
+
} else if (resultStatus?.kind === 'domain') {
|
|
188
|
+
state.domainOutcomeStep = typeof event.data.step === 'number' ? event.data.step : state.domainOutcomeStep;
|
|
166
189
|
} else {
|
|
167
190
|
state.bridgeCallFailed = true;
|
|
168
191
|
state.bridgeFailureCode = resultStatus?.code ?? BENCHMARK_BRIDGE_CALL_FAILED;
|
|
@@ -191,13 +214,13 @@ export function createBenchmarkAgentConformance(projection) {
|
|
|
191
214
|
code: BENCHMARK_BRIDGE_RETRY_CALL_NOT_ALLOWED
|
|
192
215
|
};
|
|
193
216
|
}
|
|
194
|
-
if (state.successfulResultStep === undefined) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
217
|
+
if (state.bridgeCallFailed && state.successfulResultStep === undefined) {
|
|
218
|
+
return {
|
|
219
|
+
kind: 'reject',
|
|
220
|
+
code: state.bridgeFailureCode ?? BENCHMARK_BRIDGE_CALL_FAILED
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
if (state.successfulResultStep === undefined && state.domainOutcomeStep === undefined) {
|
|
201
224
|
if (state.retryCount >= MAX_CONFORMANCE_RETRIES) {
|
|
202
225
|
return {
|
|
203
226
|
kind: 'reject',
|
|
@@ -212,7 +235,7 @@ export function createBenchmarkAgentConformance(projection) {
|
|
|
212
235
|
};
|
|
213
236
|
}
|
|
214
237
|
const terminal = state.lastAssistant;
|
|
215
|
-
const terminalIsValid = terminal !== undefined && !terminal.interrupted && terminal.step > state.
|
|
238
|
+
const terminalIsValid = terminal !== undefined && !terminal.interrupted && terminal.step > state.lastBridgeResponseStep && parseBenchmarkTerminal(terminal.text, projection.terminal).ok;
|
|
216
239
|
if (terminalIsValid) return {
|
|
217
240
|
kind: 'accept'
|
|
218
241
|
};
|
|
@@ -261,7 +284,7 @@ function systemSection(projection) {
|
|
|
261
284
|
text: [
|
|
262
285
|
'Benchmark execution contract:',
|
|
263
286
|
`- Translate every task instruction to use a CLI, shell, Python, or agent_env.cli into the native tool ${projection.toolName}; do not merely describe the intended command.`,
|
|
264
|
-
`- Call it with exactly {"
|
|
287
|
+
`- Call it with exactly {"action":"call","tool":"<one of: ${allowed}>","arguments":{...}}.`,
|
|
265
288
|
'- action:"tools" is discovery only and does not satisfy the required environment call.',
|
|
266
289
|
`- After a successful tool result, reply only <${projection.terminal.tag}>{...one JSON object...}</${projection.terminal.tag}> with no prose or code fence.`,
|
|
267
290
|
'- If a terminal-format correction arrives, reuse the existing result and do not call the tool again.'
|