@tea-agent/loop-agent 0.38.2 → 0.38.3
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 +18 -0
- package/README.md +2 -0
- package/bin/loop-agent.js +7 -3
- package/dist/application/task-lifecycle/advance.js +4 -0
- package/dist/build-stamp.json +3 -3
- package/dist/commands/task-advance.js +31 -0
- package/dist/executors/dag-pi-executor.js +58 -1
- package/dist/executors/pi-event-serializer.js +42 -1
- package/dist/executors/pi-executor.js +51 -0
- package/dist/executors/pi-extension-resolver.js +233 -0
- package/dist/executors/pi-sdk-executor.js +187 -59
- package/dist/executors/shell-executor.js +56 -2
- package/dist/executors/shell-write-guard.js +7 -0
- package/dist/task/contract/constants.js +1 -0
- package/dist/task/contract/diff.js +26 -0
- package/dist/task/contract/project.js +5 -0
- package/dist/task/contract/schema.js +6 -1
- package/dist/task/source-prepare/build-draft.js +15 -0
- package/dist/worker/console/pi-readiness.js +4 -4
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-C4bmo3iY.js → abnfDiagram-N423BO3Z-C4kVYweA.js} +1 -1
- package/dist/worker/console/static/assets/{arc-SAD7McOS.js → arc-Bj2M8iO5.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-DAVLUdK1.js → architectureDiagram-T3A2C74G-CLlXe4-6.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-CPPdv4vj.js → blockDiagram-VBNYF7ZC-psEp5xH0.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-D1GRGZax.js → c4Diagram-5PPSVZJV-DeKcOCGJ.js} +1 -1
- package/dist/worker/console/static/assets/channel-CPF4N7pf.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-D_Bq2ZqK.js → chunk-2GRJ4B5K-K0C744p1.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-CPLVtamK.js → chunk-2Q5K7J3B-xbNw4J9-.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-DnaZWcL3.js → chunk-5RXB4S5H-DjLaSDUO.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BRTmFgnq.js → chunk-5VM5RSS4-CtiPlKel.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-BRlfYZoH.js → chunk-6Q2QTUOP-DZtolir7.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-CjNybD4u.js → chunk-GF5L2VYU-CPcdNeew.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-D3e-74fG.js → chunk-JWPE2WC7-NgHc6V37.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-Br3ir6f2.js → chunk-KBJHAD2P-DQ_T-hg8.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-1NgVuRbh.js → chunk-RYQCIY6F-DgLsxcVP.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-BTYuvuWN.js → chunk-XXDRQBXY-UrVoM9z1.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-C2DwA_Y1.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-C2DwA_Y1.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-BC6Bgosf.js → cose-bilkent-JH36ORCC-CLkYvTb3.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-DV-HypfL.js → cynefin-VYW2F7L2-BwT_xKrE.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-DhTaddO-.js → cynefinDiagram-MW4NZA55-Bi9tuzif.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BnEcOmiI.js → dagre-VZM6K2ZE-BCIqkWBV.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-xphGRVKp.js → diagram-7IWD3JNH-Dip6l9_Z.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-CrdD1mRG.js → diagram-B4RE2ZJO-B-xkh_wK.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-D4YdLsaF.js → diagram-LBJQPF4R-DZO0kTt_.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-LCKyGZ5U.js → diagram-Q27KOJAE-D6ZplNbZ.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-BeiTe7t0.js → diagram-UB23O5K3-BPekbhoS.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-BO2cq8GS.js → ebnfDiagram-BXEA7PRR-BtmaJpK5.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-CmWww3Nt.js → erDiagram-JOGREHBK-6DS0Xc44.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-C2kkUYg5.js → flowDiagram-UKHOOZJN-CihnROSm.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-DY_JZ2iQ.js → ganttDiagram-PKOTCBZU-CZC4zOE2.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-BizhCSw9.js → gitGraphDiagram-DS77QQ5N-Dq1fhzGN.js} +1 -1
- package/dist/worker/console/static/assets/{index-BXN89VPX.js → index-DTZOKgAn.js} +142 -63
- package/dist/worker/console/static/assets/index-Ya5FE7cD.css +1 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-Dlo2eK_d.js → infoDiagram-6WML65LV-DlSl4BGx.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-3EIlIIuZ.js → ishikawaDiagram-WSZJBQD7-snnzFl_U.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-DiMDe5Yh.js → journeyDiagram-NVQOT4AX-BDE7qpMx.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-sN553oIN.js → kanban-definition-27J2QSJJ-CD2Ci04G.js} +1 -1
- package/dist/worker/console/static/assets/{linear-D9Py31Ld.js → linear-DdnapKIH.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-D7Occzk_.js → mermaid.core-BVjAT9b8.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-DjDRboiR.js → mindmap-definition-FAOFIHXS-D0yJk-zA.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-Cgc4qlzp.js → pegDiagram-VL7TDLO6-BVo9tFP-.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-DxZj8pKd.js → pieDiagram-7S7Q4E2Y-DnOV-mZ_.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-CJ50MngR.js → quadrantDiagram-CIZ2JOQS-CzUJo58i.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-BY-OD8Tr.js → railroadDiagram-AXF67PYL-Bvikrolh.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-CQFButfK.js → requirementDiagram-LRYGKXZP-DtaSVCap.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-BB_QUK_b.js → sankeyDiagram-W5VNT64P-C2c9A0wW.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-CqhXZjyx.js → sequenceDiagram-SI44F4Z6-DmXJcU7r.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-2l1U4rgJ.js → sizeCapture-X5ZJPWSS-B4GUFW92.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-BX1FbrhJ.js → stateDiagram-OKZ733FA-Dsad2MXf.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-B8FB_cNk.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DOSnT7hb.js → swimlanes-SLNWSIFB-DGq48Fbi.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-CrZYaWfx.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-DVJQA7AN.js → timeline-definition-Z64GVDOM-CSSi6OFf.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-74uxl9gx.js → vennDiagram-T6HMQDX7-BqyzPrWv.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-DsBxlcg_.js → wardleyDiagram-T6FBY63Y-DlznVb6S.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-snuW9Mjw.js → xychartDiagram-ELKLHX3M-CfBcgJ_K.js} +1 -1
- package/dist/worker/console/static/index.html +2 -2
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +328 -0
- package/dist/worker/observe/node-input.js +72 -3
- package/dist/worker/observe/static/dag-history-labels.js +4 -0
- package/dist/worker/observe/static/state.js +2 -2
- package/dist/worker/observe/static/views/dag-inspector.js +51 -0
- package/dist/worker/observe/static/views/session-timeline.js +18 -5
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +56 -4
- package/dist/workflows/dag/backend-test-scenario-partitions.js +73 -1
- package/dist/workflows/dag/contract-output-registry.js +15 -0
- package/dist/workflows/dag/failure-category.js +4 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +140 -39
- package/dist/workflows/dag/frontend-prewrite-gate.js +87 -135
- package/dist/workflows/dag/frontend-test-case-quality.js +5 -13
- package/dist/workflows/dag/frontend-test-environment-probe.js +227 -0
- package/dist/workflows/dag/frontend-test-markdown.js +61 -0
- package/dist/workflows/dag/frontend-test-result-contract.js +10 -18
- package/dist/workflows/dag/frontend-test-standard-scenarios.js +68 -0
- package/dist/workflows/dag/init-hybrid.js +79 -101
- package/dist/workflows/dag/node-execution.js +119 -8
- package/dist/workflows/dag/prompt.js +15 -1
- package/dist/workflows/dag/rerun-plan.js +22 -3
- package/dist/workflows/dag/structured-output-repair.js +712 -0
- package/dist/workflows/dag/types.js +23 -0
- package/dist/workflows/dag/validate.js +41 -1
- package/docs/operations/local-development-environment.md +1 -5
- package/docs/skills/vetted-skill-registry.md +14 -0
- package/docs/templates/README.md +1 -1
- package/docs/templates/agent-dag.schema.json +44 -0
- package/docs/templates/backend-test-dag.json +2 -2
- package/docs/templates/frontend-test-dag.json +8 -10
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +1 -1
- package/package.json +8 -4
- package/skills/analyze-product-requirements/SKILL.md +8 -5
- package/skills/analyze-product-requirements/references/acceptance-criteria.md +1 -1
- package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +10 -6
- package/skills/analyze-product-requirements/references/example.md +50 -0
- package/skills/analyze-product-requirements/references/forward-test-cases.md +11 -7
- package/skills/analyze-product-requirements/references/kb-integration.md +5 -5
- package/skills/analyze-product-requirements/references/product-analysis-schema.md +8 -4
- package/skills/analyze-product-requirements/references/product-requirement-schema.md +2 -2
- package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +1 -1
- package/skills/analyze-product-requirements/scripts/test-validators.mjs +11 -1
- package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +20 -1
- package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +9 -0
- package/skills/codebase-scout/SKILL.md +1 -1
- package/skills/improve-codebase-architecture/SKILL.md +81 -0
- package/skills/improve-codebase-architecture/deepening.md +37 -0
- package/skills/improve-codebase-architecture/html-report.md +123 -0
- package/skills/improve-codebase-architecture/interface-design.md +44 -0
- package/skills/improve-codebase-architecture/language.md +53 -0
- package/dist/worker/console/static/assets/channel-R6oQIDkw.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BPXlmPWI.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BPXlmPWI.js +0 -1
- package/dist/worker/console/static/assets/index-CuH5CNFu.css +0 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DJKi0Qel.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-YYe7EEm5.js +0 -8
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { appendFile, mkdir } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { computeExtensionToolAllowlistExtras } from "./pi-extension-resolver.js";
|
|
4
|
+
import { BoundedTextPreview, classifyPiFailure, createPiJsonlStreamCollector, DEFAULT_ABORT_GRACE_MS, DEFAULT_STALL_TIMEOUT_MS, DEFAULT_TIMEOUT_MS, extractPiEventStopReason, extractAssistantTextFromPiJson, } from "./pi-executor.js";
|
|
4
5
|
import { serializeSessionEvent } from "./pi-event-serializer.js";
|
|
5
6
|
import { PI_RECOMMENDED_COMPACTION, PI_RECOMMENDED_RETRY, } from "../shared/pi-retry-settings.js";
|
|
7
|
+
/** Same-session recovery after a transport stall. Exactly one continue per SDK attempt. */
|
|
8
|
+
export const PI_SDK_STALL_CONTINUE_MAX = 1;
|
|
9
|
+
/**
|
|
10
|
+
* Fixed follow-up sent after aborting a stalled prompt.
|
|
11
|
+
* Kept short so the model can resume without repeating the original task payload.
|
|
12
|
+
*/
|
|
13
|
+
export const PI_SDK_STALL_CONTINUE_PROMPT = "继续。上一轮因长时间无 provider 活动已被中止;请从中断处接着完成,不要重复已完成的步骤。若此前没有有效输出,请重新执行原任务。";
|
|
6
14
|
let sdkSessionFactoryOverride;
|
|
7
15
|
let sdkImportOverrideForTests;
|
|
8
16
|
let sdkModuleOverrideForTests;
|
|
@@ -44,15 +52,15 @@ export async function resetPiSdkReuseScopeForTests() {
|
|
|
44
52
|
export function setPiSdkSessionFactoryForTests(factory) {
|
|
45
53
|
sdkSessionFactoryOverride = factory;
|
|
46
54
|
}
|
|
47
|
-
/** Test hook: simulate SDK import success/failure without relying on
|
|
55
|
+
/** Test hook: simulate SDK import success/failure without relying on installed SDK state. */
|
|
48
56
|
export function setPiSdkImportOverrideForTests(fn) {
|
|
49
57
|
sdkImportOverrideForTests = fn;
|
|
50
58
|
}
|
|
51
|
-
/** Test hook: inject a mock Pi SDK module to exercise resolveSdkSessionFactory without
|
|
59
|
+
/** Test hook: inject a mock Pi SDK module to exercise resolveSdkSessionFactory without loading the real SDK. */
|
|
52
60
|
export function setPiSdkModuleOverrideForTests(fn) {
|
|
53
61
|
sdkModuleOverrideForTests = fn;
|
|
54
62
|
}
|
|
55
|
-
/** Check whether the Pi SDK
|
|
63
|
+
/** Check whether the Pi SDK runtime dependency satisfies the 0.83.0 runtime contract. */
|
|
56
64
|
export async function checkPiSdkAvailability(_repoRoot) {
|
|
57
65
|
if (sdkSessionFactoryOverride) {
|
|
58
66
|
return { ok: true, detail: "pi SDK session factory override active" };
|
|
@@ -68,10 +76,10 @@ export async function checkPiSdkAvailability(_repoRoot) {
|
|
|
68
76
|
typeof ModelRuntime?.create !== "function") {
|
|
69
77
|
return {
|
|
70
78
|
ok: false,
|
|
71
|
-
detail: "pi SDK incompatible: requires createAgentSession, getAgentDir, and ModelRuntime.create (0.
|
|
79
|
+
detail: "pi SDK incompatible: requires createAgentSession, getAgentDir, and ModelRuntime.create (0.83.0 contract)",
|
|
72
80
|
};
|
|
73
81
|
}
|
|
74
|
-
return { ok: true, detail: "pi SDK 0.
|
|
82
|
+
return { ok: true, detail: "pi SDK 0.83.0 contract available" };
|
|
75
83
|
}
|
|
76
84
|
catch (error) {
|
|
77
85
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -222,6 +230,9 @@ async function createSdkSession(sdk, input, shared) {
|
|
|
222
230
|
noContextFiles: true,
|
|
223
231
|
noSkills: true,
|
|
224
232
|
noExtensions: true,
|
|
233
|
+
...(input.additionalExtensionPaths && input.additionalExtensionPaths.length > 0
|
|
234
|
+
? { additionalExtensionPaths: input.additionalExtensionPaths }
|
|
235
|
+
: {}),
|
|
225
236
|
...(settingsManager ? { settingsManager } : {}),
|
|
226
237
|
appendSystemPromptOverride: (base) => [
|
|
227
238
|
...base,
|
|
@@ -229,6 +240,19 @@ async function createSdkSession(sdk, input, shared) {
|
|
|
229
240
|
],
|
|
230
241
|
});
|
|
231
242
|
await loader.reload();
|
|
243
|
+
// Discover extension-registered tool names BEFORE session creation (plan
|
|
244
|
+
// 2026-08-21 D5): verified against the real SDK — passing extension tool
|
|
245
|
+
// names in createAgentSession `tools` activates them, while a post-create
|
|
246
|
+
// setActiveToolsByName pin leaves the active set unchanged. Merge filtered
|
|
247
|
+
// extras into the create-time allowlist; protected builtins, the deny
|
|
248
|
+
// surface, and write-capable extension tools never join.
|
|
249
|
+
const extensionToolExtras = [];
|
|
250
|
+
if (input.additionalExtensionPaths &&
|
|
251
|
+
input.additionalExtensionPaths.length > 0) {
|
|
252
|
+
const registered = collectLoaderExtensionToolNames(loader);
|
|
253
|
+
extensionToolExtras.push(...computeExtensionToolAllowlistExtras(registered.map((name) => ({ name })), input.toolNames));
|
|
254
|
+
}
|
|
255
|
+
const sessionToolNames = [...input.toolNames, ...extensionToolExtras];
|
|
232
256
|
if (input.requireWriterCustomTools) {
|
|
233
257
|
if (!Array.isArray(input.customTools) || input.customTools.length === 0) {
|
|
234
258
|
throw new Error("pi writer tool policy missing customTools; refusing to create uncontrolled writer session");
|
|
@@ -238,7 +262,7 @@ async function createSdkSession(sdk, input, shared) {
|
|
|
238
262
|
cwd: input.cwd,
|
|
239
263
|
sessionManager: SessionManager.inMemory(input.cwd),
|
|
240
264
|
resourceLoader: loader,
|
|
241
|
-
tools:
|
|
265
|
+
tools: sessionToolNames,
|
|
242
266
|
modelRuntime,
|
|
243
267
|
...(settingsManager ? { settingsManager } : {}),
|
|
244
268
|
...(model ? { model } : {}),
|
|
@@ -247,6 +271,22 @@ async function createSdkSession(sdk, input, shared) {
|
|
|
247
271
|
? { customTools: input.customTools }
|
|
248
272
|
: {}),
|
|
249
273
|
});
|
|
274
|
+
if (extensionToolExtras.length > 0) {
|
|
275
|
+
// Fail closed when merged extension tools did not activate: a silent
|
|
276
|
+
// pin failure must never let the node run without its declared tools.
|
|
277
|
+
const activeTools = created.session.agent?.state?.tools;
|
|
278
|
+
if (!Array.isArray(activeTools)) {
|
|
279
|
+
throw new Error("pi SDK session does not expose agent.state.tools; refusing unverifiable extension-tool activation");
|
|
280
|
+
}
|
|
281
|
+
const activeNames = new Set(activeTools
|
|
282
|
+
.map((tool) => typeof tool?.name === "string" ? tool.name : undefined)
|
|
283
|
+
.filter((name) => Boolean(name)));
|
|
284
|
+
for (const extensionToolName of extensionToolExtras) {
|
|
285
|
+
if (!activeNames.has(extensionToolName)) {
|
|
286
|
+
throw new Error(`pi SDK extension-tool activation mismatch for ${extensionToolName}: tool did not activate at session creation`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
250
290
|
const customToolNames = (input.customTools ?? [])
|
|
251
291
|
.map((tool) => isRecord(tool) && typeof tool.name === "string" ? tool.name : undefined)
|
|
252
292
|
.filter((name) => Boolean(name));
|
|
@@ -259,7 +299,7 @@ async function createSdkSession(sdk, input, shared) {
|
|
|
259
299
|
.map((tool) => typeof tool?.name === "string" ? tool.name : undefined)
|
|
260
300
|
.filter((name) => Boolean(name)));
|
|
261
301
|
for (const customToolName of customToolNames) {
|
|
262
|
-
const expectedActive =
|
|
302
|
+
const expectedActive = sessionToolNames.includes(customToolName);
|
|
263
303
|
if (activeNames.has(customToolName) !== expectedActive) {
|
|
264
304
|
throw new Error(`pi SDK custom-tool activation mismatch for ${customToolName}: expectedActive=${expectedActive}`);
|
|
265
305
|
}
|
|
@@ -267,6 +307,47 @@ async function createSdkSession(sdk, input, shared) {
|
|
|
267
307
|
}
|
|
268
308
|
return created.session;
|
|
269
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* Collect tool names registered by loader-resolved extensions. The SDK exposes
|
|
312
|
+
* each extension's `tools` as a Record (name → definition) or Map; both shapes
|
|
313
|
+
* are handled. Missing getExtensions (older SDK) yields no extras — the node
|
|
314
|
+
* then runs with the baseline allowlist only.
|
|
315
|
+
*/
|
|
316
|
+
function collectLoaderExtensionToolNames(loader) {
|
|
317
|
+
const getExtensions = loader?.getExtensions;
|
|
318
|
+
if (typeof getExtensions !== "function")
|
|
319
|
+
return [];
|
|
320
|
+
let parsed;
|
|
321
|
+
try {
|
|
322
|
+
parsed = getExtensions.call(loader);
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
return [];
|
|
326
|
+
}
|
|
327
|
+
if (!parsed || typeof parsed !== "object")
|
|
328
|
+
return [];
|
|
329
|
+
const extensions = parsed.extensions;
|
|
330
|
+
if (!Array.isArray(extensions))
|
|
331
|
+
return [];
|
|
332
|
+
const names = [];
|
|
333
|
+
for (const extension of extensions) {
|
|
334
|
+
if (!extension || typeof extension !== "object")
|
|
335
|
+
continue;
|
|
336
|
+
const tools = extension.tools;
|
|
337
|
+
if (tools instanceof Map) {
|
|
338
|
+
for (const key of tools.keys()) {
|
|
339
|
+
if (typeof key === "string")
|
|
340
|
+
names.push(key);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
else if (tools && typeof tools === "object") {
|
|
344
|
+
for (const key of Object.keys(tools)) {
|
|
345
|
+
names.push(key);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return names;
|
|
350
|
+
}
|
|
270
351
|
/**
|
|
271
352
|
* Throttle high-noise Pi SDK events from session-events.jsonl.
|
|
272
353
|
* Always keeps tool lifecycle, turn/agent end, assistant messages, and errors.
|
|
@@ -404,25 +485,6 @@ function extractSdkUsageSample(event) {
|
|
|
404
485
|
const responseKey = responseKeyCandidates.find((value) => typeof value === "string" && value.length > 0);
|
|
405
486
|
return responseKey ? { responseKey, tokens } : { tokens };
|
|
406
487
|
}
|
|
407
|
-
/** Extract a non-empty stop reason from a terminal SDK event.
|
|
408
|
-
* Probes multiple field shapes across SDK versions so a missing field fails
|
|
409
|
-
* open (undefined) rather than misclassifying an attempt. */
|
|
410
|
-
function readStopReason(event) {
|
|
411
|
-
const message = isRecord(event.message) ? event.message : undefined;
|
|
412
|
-
const candidates = [
|
|
413
|
-
message?.stop_reason,
|
|
414
|
-
message?.stopReason,
|
|
415
|
-
event.stopReason,
|
|
416
|
-
event.stop_reason,
|
|
417
|
-
];
|
|
418
|
-
for (const candidate of candidates) {
|
|
419
|
-
if (typeof candidate === "string" &&
|
|
420
|
-
candidate.trim().length > 0) {
|
|
421
|
-
return candidate.trim();
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
return undefined;
|
|
425
|
-
}
|
|
426
488
|
function aggregateSdkTokenUsage(samples) {
|
|
427
489
|
const identified = new Map();
|
|
428
490
|
let anonymousMaximum = 0;
|
|
@@ -444,6 +506,8 @@ function aggregateSdkTokenUsage(samples) {
|
|
|
444
506
|
* When reuseScope is active, only shared auth/model resources are reused; each attempt still
|
|
445
507
|
* creates and disposes its own session and resource loader. Session reuse across steps is
|
|
446
508
|
* deferred until a proven reset/isolation strategy exists.
|
|
509
|
+
* A transport stall may abort the current prompt and send one continue on the
|
|
510
|
+
* same session; that is in-attempt recovery, not cross-step session reuse.
|
|
447
511
|
*/
|
|
448
512
|
export async function executeSingleSdkAttempt(options) {
|
|
449
513
|
const modelConfig = options.modelConfig;
|
|
@@ -494,7 +558,7 @@ export async function executeSingleSdkAttempt(options) {
|
|
|
494
558
|
type === "message_end" ||
|
|
495
559
|
type === "agent_end" ||
|
|
496
560
|
type === "agent_settled") {
|
|
497
|
-
const candidate =
|
|
561
|
+
const candidate = extractPiEventStopReason(event);
|
|
498
562
|
if (candidate)
|
|
499
563
|
stopReason = candidate;
|
|
500
564
|
}
|
|
@@ -555,20 +619,37 @@ export async function executeSingleSdkAttempt(options) {
|
|
|
555
619
|
? { customTools: writerCustomTools }
|
|
556
620
|
: {}),
|
|
557
621
|
...(requireWriterCustomTools ? { requireWriterCustomTools: true } : {}),
|
|
622
|
+
...(options.piExtensionPaths && options.piExtensionPaths.length > 0
|
|
623
|
+
? { additionalExtensionPaths: options.piExtensionPaths }
|
|
624
|
+
: {}),
|
|
558
625
|
});
|
|
559
626
|
let resolveStall;
|
|
560
627
|
let resolveSettlement;
|
|
561
628
|
let settled = false;
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
629
|
+
let abortConfirmed = true;
|
|
630
|
+
const persistRuntimeNote = (event) => {
|
|
631
|
+
const line = serializeSessionEvent(event);
|
|
632
|
+
stdoutPreview.append(`${line}\n`);
|
|
633
|
+
stdoutCollector.append(`${line}\n`);
|
|
634
|
+
sessionEventAppender?.append(line, event);
|
|
635
|
+
};
|
|
636
|
+
const resetSettlement = () => {
|
|
637
|
+
settled = false;
|
|
638
|
+
return new Promise((resolve) => {
|
|
639
|
+
resolveSettlement = resolve;
|
|
640
|
+
});
|
|
641
|
+
};
|
|
642
|
+
const resetStallPromise = () => {
|
|
643
|
+
if (stallTimeoutMs <= 0) {
|
|
644
|
+
resolveStall = undefined;
|
|
645
|
+
return null;
|
|
646
|
+
}
|
|
647
|
+
return new Promise((resolve) => {
|
|
567
648
|
resolveStall = resolve;
|
|
568
|
-
})
|
|
569
|
-
|
|
649
|
+
});
|
|
650
|
+
};
|
|
570
651
|
const armStallWatchdog = () => {
|
|
571
|
-
if (
|
|
652
|
+
if (stallTimeoutMs <= 0 || !resolveStall)
|
|
572
653
|
return;
|
|
573
654
|
if (stallHandle)
|
|
574
655
|
clearTimeout(stallHandle);
|
|
@@ -609,17 +690,6 @@ export async function executeSingleSdkAttempt(options) {
|
|
|
609
690
|
stdoutCollector.append(`${line}\n`);
|
|
610
691
|
sessionEventAppender?.append(line, event);
|
|
611
692
|
});
|
|
612
|
-
const filePrefix = options.attachedFiles
|
|
613
|
-
.map((file) => `@${file}`)
|
|
614
|
-
.join(" ");
|
|
615
|
-
const promptMessage = filePrefix
|
|
616
|
-
? `${filePrefix}\n${options.userMessage}`
|
|
617
|
-
: options.userMessage;
|
|
618
|
-
const promptPromise = session.prompt(promptMessage);
|
|
619
|
-
// A settlement event is permitted to win the race while prompt() remains
|
|
620
|
-
// pending. Observe a later rejection so it never becomes unhandled.
|
|
621
|
-
void promptPromise.catch(() => { });
|
|
622
|
-
armStallWatchdog();
|
|
623
693
|
const timeoutPromise = timeoutMs > 0
|
|
624
694
|
? new Promise((resolve) => {
|
|
625
695
|
timeoutHandle = setTimeout(() => {
|
|
@@ -627,21 +697,79 @@ export async function executeSingleSdkAttempt(options) {
|
|
|
627
697
|
}, timeoutMs);
|
|
628
698
|
})
|
|
629
699
|
: null;
|
|
630
|
-
const
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
700
|
+
const runTurn = async (userMessage) => {
|
|
701
|
+
const settlementPromise = resetSettlement();
|
|
702
|
+
const stallPromise = resetStallPromise();
|
|
703
|
+
const promptPromise = session.prompt(userMessage);
|
|
704
|
+
// A settlement event is permitted to win the race while prompt() remains
|
|
705
|
+
// pending. Observe a later rejection so it never becomes unhandled.
|
|
706
|
+
void promptPromise.catch(() => { });
|
|
707
|
+
armStallWatchdog();
|
|
708
|
+
return Promise.race([
|
|
709
|
+
promptPromise.then(() => "done"),
|
|
710
|
+
settlementPromise,
|
|
711
|
+
...(timeoutPromise ? [timeoutPromise] : []),
|
|
712
|
+
...(stallPromise ? [stallPromise] : []),
|
|
713
|
+
]);
|
|
714
|
+
};
|
|
715
|
+
const disposeSession = async () => {
|
|
642
716
|
disposeAttempted = true;
|
|
643
717
|
const disposeConfirmed = await runSessionActionWithGrace("dispose", () => session.dispose());
|
|
644
718
|
terminationConfirmed = abortConfirmed && disposeConfirmed;
|
|
719
|
+
};
|
|
720
|
+
const failClosedAfterWait = async (reason, extraStderr, abortFirst = true) => {
|
|
721
|
+
timedOut = true;
|
|
722
|
+
appendStderr(reason === "stall"
|
|
723
|
+
? `pi SDK step stalled after ${stallTimeoutMs}ms with no provider activity`
|
|
724
|
+
: `pi SDK step timed out after ${timeoutMs}ms`);
|
|
725
|
+
if (extraStderr)
|
|
726
|
+
appendStderr(extraStderr);
|
|
727
|
+
if (abortFirst) {
|
|
728
|
+
abortConfirmed = await runSessionActionWithGrace("abort", () => session.abort());
|
|
729
|
+
}
|
|
730
|
+
await disposeSession();
|
|
731
|
+
};
|
|
732
|
+
const filePrefix = options.attachedFiles
|
|
733
|
+
.map((file) => `@${file}`)
|
|
734
|
+
.join(" ");
|
|
735
|
+
const promptMessage = filePrefix
|
|
736
|
+
? `${filePrefix}\n${options.userMessage}`
|
|
737
|
+
: options.userMessage;
|
|
738
|
+
let continuesSent = 0;
|
|
739
|
+
let raced = await runTurn(promptMessage);
|
|
740
|
+
if (raced === "stall") {
|
|
741
|
+
abortConfirmed = await runSessionActionWithGrace("abort", () => session.abort());
|
|
742
|
+
const withinAbsoluteTimeout = timeoutMs <= 0 || Date.now() - startedAt < timeoutMs;
|
|
743
|
+
const canContinue = abortConfirmed &&
|
|
744
|
+
writeToolCallCount === 0 &&
|
|
745
|
+
withinAbsoluteTimeout &&
|
|
746
|
+
continuesSent < PI_SDK_STALL_CONTINUE_MAX;
|
|
747
|
+
if (canContinue) {
|
|
748
|
+
// The aborted turn's stopReason must not leak onto a recovered continue.
|
|
749
|
+
stopReason = undefined;
|
|
750
|
+
continuesSent += 1;
|
|
751
|
+
persistRuntimeNote({
|
|
752
|
+
type: "loop-agent-stall-continue",
|
|
753
|
+
prompt: PI_SDK_STALL_CONTINUE_PROMPT,
|
|
754
|
+
maxContinues: PI_SDK_STALL_CONTINUE_MAX,
|
|
755
|
+
});
|
|
756
|
+
raced = await runTurn(PI_SDK_STALL_CONTINUE_PROMPT);
|
|
757
|
+
if (raced !== "done" && raced !== "settled") {
|
|
758
|
+
await failClosedAfterWait(raced === "stall" ? "stall" : "absolute-timeout", raced === "stall"
|
|
759
|
+
? "pi SDK stall continue did not recover; treating as timeout"
|
|
760
|
+
: "pi SDK stall continue hit the absolute timeout", true);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
else {
|
|
764
|
+
await failClosedAfterWait("stall", !abortConfirmed
|
|
765
|
+
? undefined
|
|
766
|
+
: writeToolCallCount > 0
|
|
767
|
+
? "pi SDK stall continue skipped because write tools already ran"
|
|
768
|
+
: "pi SDK stall continue skipped because absolute timeout elapsed", false);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
else if (raced === "absolute-timeout") {
|
|
772
|
+
await failClosedAfterWait("absolute-timeout");
|
|
645
773
|
}
|
|
646
774
|
}
|
|
647
775
|
catch (error) {
|
|
@@ -15,6 +15,8 @@ import { materializeBackendTestAnalysisContract } from "../workflows/dag/backend
|
|
|
15
15
|
import { extractBackendTestContractEnvelope } from "../workflows/dag/backend-test-contract-envelope.js";
|
|
16
16
|
import { materializeFrontendImplementationContract } from "../workflows/dag/frontend-implementation-contract.js";
|
|
17
17
|
import { materializeFrontendTestResult, validateFrontendCaseEvidence, } from "../workflows/dag/frontend-test-result-contract.js";
|
|
18
|
+
import { copyFrontendTestStandardScenarios } from "../workflows/dag/frontend-test-standard-scenarios.js";
|
|
19
|
+
import { probeFrontendTestEnvironment } from "../workflows/dag/frontend-test-environment-probe.js";
|
|
18
20
|
import { renderFrontendTestL5Report } from "../workflows/dag/frontend-test-l5-report.js";
|
|
19
21
|
import { validateFrontendCaseChecklist } from "../workflows/dag/frontend-test-case-checklist.js";
|
|
20
22
|
import { materializeFrontendTestCaseManifest } from "../workflows/dag/frontend-test-case-manifest.js";
|
|
@@ -704,7 +706,7 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
704
706
|
// coverage findings stay advisory, but a declared filter axis missing
|
|
705
707
|
// an each-value/omitted slot or its complement slot must block pytest
|
|
706
708
|
// generation until the Markdown declares the slot.
|
|
707
|
-
const partitionBlocking = coverage.facts.findings.filter((finding) => /^(?:MISSING_PARTITION|MISSING_PARTITION_SLOT|MISSING_COMPLEMENT_SLOT|MISSING_PARTITION_TABLE)/.test(finding));
|
|
709
|
+
const partitionBlocking = coverage.facts.findings.filter((finding) => /^(?:MISSING_PARTITION|MISSING_PARTITION_SLOT|MISSING_COMPLEMENT_SLOT|MISSING_PARTITION_TABLE|INVALID_PARTITION_DOMAIN|NO_FINITE_DOMAIN|PARTITION_SOURCE_MISMATCH)/.test(finding));
|
|
708
710
|
if (partitionBlocking.length > 0) {
|
|
709
711
|
return {
|
|
710
712
|
ok: false,
|
|
@@ -877,7 +879,7 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
877
879
|
});
|
|
878
880
|
}
|
|
879
881
|
else if (initial.status === "REPAIRABLE") {
|
|
880
|
-
const mappedScripts = await collectBackendTestMappedPytestScripts(input.cwd);
|
|
882
|
+
const mappedScripts = await collectBackendTestMappedPytestScripts(input.cwd, backendLayout);
|
|
881
883
|
const scenario = await runBackendScenarioParamPreflight({
|
|
882
884
|
workspaceRoot: input.cwd,
|
|
883
885
|
runDir: meta.runDir,
|
|
@@ -2061,6 +2063,52 @@ async function executeFrontendTestHtmlReport(input, meta) {
|
|
|
2061
2063
|
};
|
|
2062
2064
|
}
|
|
2063
2065
|
}
|
|
2066
|
+
async function executeFrontendTestStandardScenarios(input) {
|
|
2067
|
+
const started = Date.now();
|
|
2068
|
+
try {
|
|
2069
|
+
const result = await copyFrontendTestStandardScenarios({
|
|
2070
|
+
workspaceRoot: input.cwd,
|
|
2071
|
+
});
|
|
2072
|
+
return {
|
|
2073
|
+
ok: true,
|
|
2074
|
+
stdout: JSON.stringify(result),
|
|
2075
|
+
stderr: "",
|
|
2076
|
+
failureCategory: "success",
|
|
2077
|
+
durationMs: Date.now() - started,
|
|
2078
|
+
};
|
|
2079
|
+
}
|
|
2080
|
+
catch (error) {
|
|
2081
|
+
return {
|
|
2082
|
+
ok: false,
|
|
2083
|
+
stdout: "",
|
|
2084
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
2085
|
+
failureCategory: "invalid-output",
|
|
2086
|
+
durationMs: Date.now() - started,
|
|
2087
|
+
};
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
async function executeFrontendTestEnvironmentProbe(input) {
|
|
2091
|
+
const started = Date.now();
|
|
2092
|
+
const result = await probeFrontendTestEnvironment({
|
|
2093
|
+
workspaceRoot: input.cwd,
|
|
2094
|
+
});
|
|
2095
|
+
if (result.ok) {
|
|
2096
|
+
return {
|
|
2097
|
+
ok: true,
|
|
2098
|
+
stdout: result.stdout,
|
|
2099
|
+
stderr: "",
|
|
2100
|
+
failureCategory: "success",
|
|
2101
|
+
durationMs: Date.now() - started,
|
|
2102
|
+
};
|
|
2103
|
+
}
|
|
2104
|
+
return {
|
|
2105
|
+
ok: false,
|
|
2106
|
+
stdout: "",
|
|
2107
|
+
stderr: result.stderr,
|
|
2108
|
+
failureCategory: "nonzero-exit",
|
|
2109
|
+
durationMs: Date.now() - started,
|
|
2110
|
+
};
|
|
2111
|
+
}
|
|
2064
2112
|
async function executeFrontendTestEvidenceValidation(input) {
|
|
2065
2113
|
const started = Date.now();
|
|
2066
2114
|
try {
|
|
@@ -2339,6 +2387,12 @@ export async function executeDagShellNode(input, meta) {
|
|
|
2339
2387
|
};
|
|
2340
2388
|
}
|
|
2341
2389
|
}
|
|
2390
|
+
if (shell?.frontendTestStandardScenarios) {
|
|
2391
|
+
return executeFrontendTestStandardScenarios(input);
|
|
2392
|
+
}
|
|
2393
|
+
if (shell?.frontendTestEnvironmentProbe) {
|
|
2394
|
+
return executeFrontendTestEnvironmentProbe(input);
|
|
2395
|
+
}
|
|
2342
2396
|
if (shell?.frontendBrowserToolPreflight) {
|
|
2343
2397
|
const started = Date.now();
|
|
2344
2398
|
try {
|
|
@@ -98,6 +98,13 @@ export function isEphemeralToolCachePath(filePath) {
|
|
|
98
98
|
const normalized = normalizePath(filePath);
|
|
99
99
|
if (!normalized)
|
|
100
100
|
return false;
|
|
101
|
+
// CodeGraph extension sync side effect (plan 2026-08-21 D7): a loaded
|
|
102
|
+
// pi-codegraph extension keeps an existing .codegraph/ index fresh at
|
|
103
|
+
// session start; those index files are extension-owned run state, not
|
|
104
|
+
// writer output, so they never count as write-guard violations.
|
|
105
|
+
if (normalized === ".codegraph" || normalized.startsWith(".codegraph/")) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
101
108
|
if (normalized === ".pytest_cache" ||
|
|
102
109
|
normalized.startsWith(".pytest_cache/")) {
|
|
103
110
|
return true;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { canonicalizeJsonValue } from "./canonicalize.js";
|
|
1
2
|
import { MANAGED_TASK_CONFIG_FIELDS } from "./constants.js";
|
|
2
3
|
function maxRisk(a, b) {
|
|
3
4
|
const order = ["routine", "elevated", "blocking"];
|
|
@@ -139,6 +140,31 @@ export function diffDraftAgainstCurrent(input) {
|
|
|
139
140
|
path: "task.json#featureId",
|
|
140
141
|
});
|
|
141
142
|
}
|
|
143
|
+
// backendTest is managed whole-object: an absent draft value means
|
|
144
|
+
// "keep existing" and never diffs; declared values compare canonically.
|
|
145
|
+
if (input.draft.backendTest !== undefined) {
|
|
146
|
+
const before = cfg.backendTest ?? {};
|
|
147
|
+
const after = input.draft.backendTest;
|
|
148
|
+
if (canonicalizeJsonValue(before) !== canonicalizeJsonValue(after)) {
|
|
149
|
+
changedManagedFields.push("backendTest");
|
|
150
|
+
risks.push({
|
|
151
|
+
code: "BACKEND_TEST_CONFIG_CHANGED",
|
|
152
|
+
level: "routine",
|
|
153
|
+
message: "backendTest configuration changed",
|
|
154
|
+
path: "task.json#backendTest",
|
|
155
|
+
});
|
|
156
|
+
const afterKeys = new Set(Object.keys(after));
|
|
157
|
+
const droppedKeys = Object.keys(before).filter((key) => !afterKeys.has(key));
|
|
158
|
+
if (droppedKeys.length > 0) {
|
|
159
|
+
risks.push({
|
|
160
|
+
code: "BACKEND_TEST_CONFIG_WEAKENED",
|
|
161
|
+
level: "elevated",
|
|
162
|
+
message: `drop backendTest keys: ${droppedKeys.sort().join(", ")}`,
|
|
163
|
+
path: "task.json#backendTest",
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
142
168
|
}
|
|
143
169
|
else {
|
|
144
170
|
for (const field of MANAGED_TASK_CONFIG_FIELDS) {
|
|
@@ -174,6 +174,11 @@ export function mergeManagedTaskConfigFields(existing, draft) {
|
|
|
174
174
|
if (draft.featureId !== undefined) {
|
|
175
175
|
next.featureId = draft.featureId;
|
|
176
176
|
}
|
|
177
|
+
// backendTest is whole-object replace when the draft declares it (`{}` is a
|
|
178
|
+
// legal explicit clear back to the default layout); absent keeps existing.
|
|
179
|
+
if (draft.backendTest !== undefined) {
|
|
180
|
+
next.backendTest = draft.backendTest;
|
|
181
|
+
}
|
|
177
182
|
return next;
|
|
178
183
|
}
|
|
179
184
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { taskKindSchema, taskVerifyCommandSchema } from "../config-types.js";
|
|
2
|
+
import { backendTestConfigSchema, taskKindSchema, taskVerifyCommandSchema, } from "../config-types.js";
|
|
3
3
|
import { TASK_CONFIG_SCHEMA_VERSION, TASK_CONTRACT_CANONICALIZER_VERSION, TASK_CONTRACT_DRAFT_SCHEMA_VERSION, TASK_CONTRACT_PROJECTION_VERSION, TASK_CONTRACT_REF_SCHEMA_VERSION, } from "./constants.js";
|
|
4
4
|
const sha256Schema = z
|
|
5
5
|
.string()
|
|
@@ -62,6 +62,11 @@ export const taskContractDraftSchema = z
|
|
|
62
62
|
requirement: taskContractDraftRequirementSchema,
|
|
63
63
|
constraints: taskContractDraftConstraintsSchema,
|
|
64
64
|
verification: taskContractDraftVerificationSchema,
|
|
65
|
+
/**
|
|
66
|
+
* Managed backend-test layout / pipeline configuration projected into
|
|
67
|
+
* task.json#backendTest. Optional: absent means "keep existing".
|
|
68
|
+
*/
|
|
69
|
+
backendTest: backendTestConfigSchema,
|
|
65
70
|
references: z.array(taskContractDraftReferenceSchema).optional(),
|
|
66
71
|
sourceResolutions: z
|
|
67
72
|
.array(taskContractDraftSourceResolutionSchema)
|
|
@@ -22,6 +22,18 @@ function resolveTaskKindExplicit(flags, baseDraft) {
|
|
|
22
22
|
return flags.taskKindExplicit;
|
|
23
23
|
return baseDraft?.taskKindExplicit ?? false;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Resolve managed backend-test layout config.
|
|
27
|
+
* Precedence: explicit CLI flags > --from-draft base > existing task.json
|
|
28
|
+
* (the last tier self-heals tasks whose backendTest was hand-written).
|
|
29
|
+
*/
|
|
30
|
+
function resolveBackendTest(flags, baseDraft, existing) {
|
|
31
|
+
if (flags.backendTest !== undefined)
|
|
32
|
+
return flags.backendTest;
|
|
33
|
+
if (baseDraft?.backendTest !== undefined)
|
|
34
|
+
return baseDraft.backendTest;
|
|
35
|
+
return existing?.backendTest ?? undefined;
|
|
36
|
+
}
|
|
25
37
|
function resolveTitle(taskId, flags, facts, baseDraft, existing) {
|
|
26
38
|
return (trimNonEmpty(flags.title) ??
|
|
27
39
|
trimNonEmpty(baseDraft?.title) ??
|
|
@@ -205,6 +217,9 @@ export function buildPrepareDraft(input) {
|
|
|
205
217
|
};
|
|
206
218
|
if (featureId)
|
|
207
219
|
draft.featureId = featureId;
|
|
220
|
+
const backendTest = resolveBackendTest(flags, baseDraft, existingTaskConfig);
|
|
221
|
+
if (backendTest !== undefined)
|
|
222
|
+
draft.backendTest = backendTest;
|
|
208
223
|
if (references && references.length > 0) {
|
|
209
224
|
draft.references = references.map((ref) => ({
|
|
210
225
|
role: ref.role,
|
|
@@ -85,7 +85,7 @@ function hasProviderConfig(snapshot) {
|
|
|
85
85
|
/**
|
|
86
86
|
* Discover live Pi SDK / auth / model readiness via ModelRuntime.
|
|
87
87
|
* Kept inside worker/console (dynamic import) so Worker does not depend on
|
|
88
|
-
* executors; contract matches pi-sdk-executor 0.
|
|
88
|
+
* executors; contract matches pi-sdk-executor 0.83.0.
|
|
89
89
|
*/
|
|
90
90
|
export async function discoverPiReadinessProbe(options) {
|
|
91
91
|
const repoRoot = options?.repoRoot ?? process.cwd();
|
|
@@ -118,7 +118,7 @@ export async function discoverPiReadinessProbe(options) {
|
|
|
118
118
|
modelsAvailable: false,
|
|
119
119
|
interviewSessionOk: false,
|
|
120
120
|
details: {
|
|
121
|
-
sdkMessage: "Pi SDK incompatible: requires createAgentSession, getAgentDir, and ModelRuntime.create (0.
|
|
121
|
+
sdkMessage: "Pi SDK incompatible: requires createAgentSession, getAgentDir, and ModelRuntime.create (0.83.0)",
|
|
122
122
|
authMessage: "skipped (sdk incompatible)",
|
|
123
123
|
modelsMessage: "skipped (sdk incompatible)",
|
|
124
124
|
sessionMessage: "skipped (sdk incompatible)",
|
|
@@ -159,7 +159,7 @@ export async function discoverPiReadinessProbe(options) {
|
|
|
159
159
|
modelsAvailable: false,
|
|
160
160
|
interviewSessionOk: false,
|
|
161
161
|
details: {
|
|
162
|
-
sdkMessage: "Pi SDK 0.
|
|
162
|
+
sdkMessage: "Pi SDK 0.83.0 contract available",
|
|
163
163
|
authMessage: `ModelRuntime.create failed: ${message}`,
|
|
164
164
|
modelsMessage: "skipped (runtime init failed)",
|
|
165
165
|
sessionMessage: "skipped (runtime init failed)",
|
|
@@ -224,7 +224,7 @@ export async function discoverPiReadinessProbe(options) {
|
|
|
224
224
|
interviewSessionOk,
|
|
225
225
|
piAvailableModels: availableModels,
|
|
226
226
|
details: {
|
|
227
|
-
sdkMessage: `Pi SDK 0.
|
|
227
|
+
sdkMessage: `Pi SDK 0.83.0 contract available (agentDir=${agentDir})`,
|
|
228
228
|
authMessage: authReady
|
|
229
229
|
? `credentials/providers ready (available=${availableCount}, providerConfig=${providerConfigured})`
|
|
230
230
|
: "no available models and no stored/configured provider credentials (set Pi auth or provider API keys)",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as p,r as u,d as a}from"./chunk-6Q2QTUOP-
|
|
1
|
+
import{g as p,r as u,d as a}from"./chunk-6Q2QTUOP-DZtolir7.js";import{p as f}from"./chunk-JWPE2WC7-NgHc6V37.js";import{_ as n,l as o}from"./mermaid.core-BVjAT9b8.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-BwT_xKrE.js";import"./index-DTZOKgAn.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Y as ln,$ as an,a0 as F,a1 as q,a2 as j,a3 as un,a4 as y,a5 as tn,a6 as J,a7 as _,a8 as rn,a9 as o,aa as on,ab as sn,ac as fn}from"./mermaid.core-
|
|
1
|
+
import{Y as ln,$ as an,a0 as F,a1 as q,a2 as j,a3 as un,a4 as y,a5 as tn,a6 as J,a7 as _,a8 as rn,a9 as o,aa as on,ab as sn,ac as fn}from"./mermaid.core-BVjAT9b8.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,z,a){var O=I-l,i=D-h,n=z-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function U(l,h,I,D,v,A,z){var a=l-I,O=h-D,i=(z?A:-A)/J(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,B=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*J(on(0,T*T*R-P*P)),Y=(P*g-m*S)/R,$=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=Y-B,e=$-t,r=w-B,C=p-t;return x*x+e*e>r*r+C*C&&(Y=w,$=p),{cx:Y,cy:$,x01:-n,y01:-d,x11:Y*(v/T-1),y11:$*(v/T-1)}}function hn(){var l=cn,h=yn,I=j(0),D=null,v=gn,A=dn,z=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,B=rn(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(B>tn-y)a.moveTo(s*F(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*F(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=B,S=B,Y=z.apply(this,arguments)/2,$=Y>y&&(D?+D.apply(this,arguments):J(u*u+s*s)),w=_(rn(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if($>y){var C=sn($/u*q(Y)),K=sn($/s*q(Y));(P-=C*2)>y?(C*=t?1:-1,R+=C,T-=C):(P=0,R=T=(f+c)/2),(S-=K*2)>y?(K*=t?1:-1,m+=K,g-=K):(S=0,m=g=(f+c)/2)}var G=s*F(m),H=s*q(m),L=u*F(T),M=u*q(T);if(w>y){var N=s*F(g),Q=s*q(g),V=u*F(R),W=u*q(R),E;if(B<an)if(E=pn(G,H,V,W,N,Q,L,M)){var X=G-E[0],Z=H-E[1],b=N-E[0],k=Q-E[1],nn=1/q(fn((X*b+Z*k)/(J(X*X+Z*Z)*J(b*b+k*k)))/2),en=J(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=U(V,W,G,H,s,x,t),r=U(N,Q,L,M,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(G,H),a.arc(0,0,s,m,g,!t)):a.moveTo(G,H),!(u>y)||!(P>y)?a.lineTo(L,M):p>y?(e=U(L,M,N,Q,u,-p,t),r=U(G,H,V,W,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[F(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:j(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:j(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:j(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:j(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:j(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:j(+n),i):A},i.padAngle=function(n){return arguments.length?(z=typeof n=="function"?n:j(+n),i):z},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
|