@tea-agent/loop-agent 0.16.9 → 0.16.10

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/CHANGELOG.md CHANGED
@@ -18,6 +18,12 @@
18
18
  - Pi SDK 执行长推理或大段结构化输出时不再把高频流式增量事件无界累积到内存;同一响应在多个生命周期事件中重复出现的 Token 用量只统计一次,避免 `Invalid string length` 和成本数据虚高。
19
19
  - 后端测试复合执行节点继续保持 clean environment、失败分类和 fail-closed outcome,并为 initial/final Result、repair eligibility、traceability 与 Observe 投影保留结构化运行证据。
20
20
 
21
+ ## [0.16.10] - 2026-07-20
22
+
23
+ ### 修复
24
+
25
+ - 后端测试执行合同物化会清理 `managedCommand` 中的空字符串(如 `stop: ""`),避免 near-schema 侦察输出在 strict parse 下误拦 in-process BE-TEST。
26
+
21
27
  ## [0.16.9] - 2026-07-20
22
28
 
23
29
  ### 修复
@@ -334,22 +334,50 @@ function asRecord(value) {
334
334
  * Prefer exact schema payloads; otherwise map common discovery shapes onto the
335
335
  * pytest-centric runtime contract without inventing secrets or managed commands.
336
336
  */
337
+ /** Drop empty managedCommand strings; omit block when not managed-command. */
338
+ export function sanitizeBackendTestExecutionInput(value) {
339
+ const record = asRecord(value);
340
+ if (!record)
341
+ return value;
342
+ const next = { ...record };
343
+ const managed = asRecord(record.managedCommand);
344
+ if (!managed)
345
+ return next;
346
+ const cleaned = {};
347
+ for (const key of ["start", "stop", "sourceRef"]) {
348
+ const raw = managed[key];
349
+ if (typeof raw === "string" && raw.trim())
350
+ cleaned[key] = raw.trim();
351
+ }
352
+ if (next.targetMode === "managed-command") {
353
+ next.managedCommand = cleaned;
354
+ }
355
+ else if (Object.keys(cleaned).length === 0) {
356
+ delete next.managedCommand;
357
+ }
358
+ else {
359
+ // in-process / external: optional managedCommand must not carry empty strings
360
+ next.managedCommand = cleaned;
361
+ }
362
+ return next;
363
+ }
337
364
  export function coerceBackendTestExecutionInput(value) {
338
- const direct = backendTestExecutionContractSchema.safeParse(value);
365
+ const sanitized = sanitizeBackendTestExecutionInput(value);
366
+ const direct = backendTestExecutionContractSchema.safeParse(sanitized);
339
367
  if (direct.success)
340
368
  return direct.data;
341
- const record = asRecord(value);
369
+ const record = asRecord(sanitized);
342
370
  if (!record)
343
- return value;
371
+ return sanitized;
344
372
  // Near-schema payloads (string framework + runner + testRoot) must stay fail-closed.
345
373
  // Only free-form discovery envelopes are rewritten onto the pytest contract.
346
374
  const looksSchemaShaped = typeof record.framework === "string" &&
347
375
  asRecord(record.runner) !== null &&
348
376
  typeof record.testRoot === "string";
349
377
  if (looksSchemaShaped)
350
- return value;
378
+ return sanitized;
351
379
  if (typeof record.framework === "string" && record.framework !== "pytest") {
352
- return value;
380
+ return sanitized;
353
381
  }
354
382
  const frameworkObj = asRecord(record.framework);
355
383
  const discovered = asRecord(record.discoveredFixtures);
@@ -504,7 +532,10 @@ export async function materializeBackendTestExecutionContract(input) {
504
532
  catch (error) {
505
533
  throw new Error(`invalid-output: ${error instanceof Error ? error.message : String(error)}`);
506
534
  }
507
- const candidates = [parsed, coerceBackendTestExecutionInput(parsed)];
535
+ const candidates = [
536
+ sanitizeBackendTestExecutionInput(parsed),
537
+ coerceBackendTestExecutionInput(parsed),
538
+ ];
508
539
  let accepted = null;
509
540
  let lastSchemaError = "invalid execution contract";
510
541
  let lastSecretError = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tea-agent/loop-agent",
3
- "version": "0.16.9",
3
+ "version": "0.16.10",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "loop-agent": "bin/loop-agent.js",