@lazyingart/agintiflow 0.20.325 → 0.20.326
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/package.json +1 -1
- package/scripts/smoke-document-artifact-quality.js +18 -1
- package/scripts/smoke-dynamic-step-budget.js +25 -1
- package/scripts/smoke-scs-evidence-visibility.js +45 -0
- package/src/agent-runner.js +56 -26
- package/src/document-artifact-quality.js +26 -20
- package/src/scs-evidence.js +41 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lazyingart/agintiflow",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.326",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AgInTiFlow is a project-aware agent workspace for hybrid wet-dry R&D, hardware-aware intelligence, software automation, and industrial workflows.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -359,6 +359,17 @@ assert(
|
|
|
359
359
|
|
|
360
360
|
const exactSourceRoot = await fs.mkdtemp(path.join(os.tmpdir(), "aginti-document-source-"));
|
|
361
361
|
try {
|
|
362
|
+
await fs.writeFile(
|
|
363
|
+
path.join(exactSourceRoot, "AGENTS.md"),
|
|
364
|
+
"WeChat PYTHONPATH LazyEdit STEP WeCom CAD PCB OpenHI\n",
|
|
365
|
+
"utf8"
|
|
366
|
+
);
|
|
367
|
+
await fs.mkdir(path.join(exactSourceRoot, "references"));
|
|
368
|
+
await fs.writeFile(
|
|
369
|
+
path.join(exactSourceRoot, "references", "unrelated.md"),
|
|
370
|
+
"Repository-wide material that does not belong to this exact report.\n",
|
|
371
|
+
"utf8"
|
|
372
|
+
);
|
|
362
373
|
await fs.writeFile(
|
|
363
374
|
path.join(exactSourceRoot, "chat_history.md"),
|
|
364
375
|
"Later correction: keep the publication blocked until login is restored.\n",
|
|
@@ -371,7 +382,13 @@ try {
|
|
|
371
382
|
assert.deepEqual(
|
|
372
383
|
exactSources.map((item) => item.path),
|
|
373
384
|
["chat_history.md"],
|
|
374
|
-
"
|
|
385
|
+
"repository-wide context contaminated an exact document source contract"
|
|
386
|
+
);
|
|
387
|
+
const discoveredSources = await collectDocumentSourceDocuments(exactSourceRoot);
|
|
388
|
+
assert.deepEqual(
|
|
389
|
+
discoveredSources.map((item) => item.path).sort(),
|
|
390
|
+
["AGENTS.md", "references/unrelated.md"],
|
|
391
|
+
"repository source discovery stopped working when no exact input was declared"
|
|
375
392
|
);
|
|
376
393
|
} finally {
|
|
377
394
|
await fs.rm(exactSourceRoot, { recursive: true, force: true });
|
|
@@ -8546,6 +8546,29 @@ try {
|
|
|
8546
8546
|
const semanticGateDocumentState = structuredClone(
|
|
8547
8547
|
currentGoalGeneratedDocumentState
|
|
8548
8548
|
);
|
|
8549
|
+
semanticGateDocumentState.messages = [
|
|
8550
|
+
{
|
|
8551
|
+
role: "assistant",
|
|
8552
|
+
tool_calls: [{
|
|
8553
|
+
id: "read-unrelated-root-policy",
|
|
8554
|
+
type: "function",
|
|
8555
|
+
function: {
|
|
8556
|
+
name: "read_file",
|
|
8557
|
+
arguments: JSON.stringify({ path: "AGENTS.md" }),
|
|
8558
|
+
},
|
|
8559
|
+
}],
|
|
8560
|
+
},
|
|
8561
|
+
{
|
|
8562
|
+
role: "tool",
|
|
8563
|
+
tool_call_id: "read-unrelated-root-policy",
|
|
8564
|
+
content: JSON.stringify({
|
|
8565
|
+
ok: true,
|
|
8566
|
+
path: "AGENTS.md",
|
|
8567
|
+
content: "WeChat PYTHONPATH LazyEdit STEP WeCom CAD PCB OpenHI",
|
|
8568
|
+
contentTruncated: false,
|
|
8569
|
+
}),
|
|
8570
|
+
},
|
|
8571
|
+
];
|
|
8549
8572
|
semanticGateDocumentState.meta.scs = {
|
|
8550
8573
|
taskContract: { exactInputPaths: ["TASK.md"] },
|
|
8551
8574
|
};
|
|
@@ -8583,7 +8606,8 @@ try {
|
|
|
8583
8606
|
semanticGateValidatorInput?.exactOutputPaths?.includes(
|
|
8584
8607
|
"daily_memo.pdf"
|
|
8585
8608
|
) &&
|
|
8586
|
-
semanticGateValidatorInput?.exactInputPaths
|
|
8609
|
+
JSON.stringify(semanticGateValidatorInput?.exactInputPaths) ===
|
|
8610
|
+
JSON.stringify(["TASK.md"]),
|
|
8587
8611
|
`current-goal artifact discovery bypassed source/status quality gates or reopened the missing-artifact loop: ${JSON.stringify({
|
|
8588
8612
|
assessment: semanticGateAssessment,
|
|
8589
8613
|
input: semanticGateValidatorInput,
|
|
@@ -240,6 +240,28 @@ const pageSafeReportContract = deriveScsTaskContract({
|
|
|
240
240
|
taskProfile: "auto",
|
|
241
241
|
});
|
|
242
242
|
|
|
243
|
+
const hostCompiledReportContract = deriveScsTaskContract({
|
|
244
|
+
goal: [
|
|
245
|
+
"Create report.md and report.tex for the requested evidence-grounded report.",
|
|
246
|
+
"Do not invoke LaTeX, latexmk, pdflatex, make, package managers, or document compiler commands; the LabCanvas host compiler owns PDF compilation and validation.",
|
|
247
|
+
"The host will create output/report.pdf after the agent turn.",
|
|
248
|
+
].join(" "),
|
|
249
|
+
taskProfile: "research",
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
const agentCompiledReportContract = deriveScsTaskContract({
|
|
253
|
+
goal: "Create report.tex, compile output/report.pdf, inspect it, and return the PDF.",
|
|
254
|
+
taskProfile: "research",
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
const fallbackHostCompilationContract = deriveScsTaskContract({
|
|
258
|
+
goal: [
|
|
259
|
+
"Create report.tex and compile output/report.pdf.",
|
|
260
|
+
"If compilation is unavailable in the sandbox, the LabCanvas host recovery stage owns PDF compilation.",
|
|
261
|
+
].join(" "),
|
|
262
|
+
taskProfile: "research",
|
|
263
|
+
});
|
|
264
|
+
|
|
243
265
|
const forbiddenOutputContract = deriveScsTaskContract({
|
|
244
266
|
goal: "Continue the task. verification_suite.py does not exist and must not be rerun or created. Preserve smoke_test.py and finish from current evidence.",
|
|
245
267
|
taskProfile: "devops",
|
|
@@ -543,6 +565,29 @@ assert(
|
|
|
543
565
|
!pageSafeReportContract.requiredEvidence.some((item) => item.category === "browser"),
|
|
544
566
|
"the editorial phrase page-safe incorrectly required browser evidence"
|
|
545
567
|
);
|
|
568
|
+
assert.equal(
|
|
569
|
+
hostCompiledReportContract.hostManagedDocumentCompilation,
|
|
570
|
+
true,
|
|
571
|
+
"an explicit host-only compilation contract was not retained"
|
|
572
|
+
);
|
|
573
|
+
assert(
|
|
574
|
+
hostCompiledReportContract.requiredArtifactKinds.some((item) => item.id === "format:.tex") &&
|
|
575
|
+
!hostCompiledReportContract.requiredArtifactKinds.some((item) => item.id === "format:.pdf"),
|
|
576
|
+
"host-managed PDF compilation did not preserve editable source while deferring PDF production"
|
|
577
|
+
);
|
|
578
|
+
assert(
|
|
579
|
+
!hostCompiledReportContract.exactOutputPaths.some((item) => item.endsWith(".pdf")),
|
|
580
|
+
"a host-managed PDF path remained an agent-owned exact output"
|
|
581
|
+
);
|
|
582
|
+
assert(
|
|
583
|
+
agentCompiledReportContract.requiredArtifactKinds.some((item) => item.id === "format:.pdf") &&
|
|
584
|
+
agentCompiledReportContract.exactOutputPaths.some((item) => item.endsWith("output/report.pdf")),
|
|
585
|
+
"ordinary agent-owned PDF compilation was weakened by the host-managed exception"
|
|
586
|
+
);
|
|
587
|
+
assert(
|
|
588
|
+
fallbackHostCompilationContract.hostManagedDocumentCompilation === false,
|
|
589
|
+
"a conditional host recovery fallback was mistaken for an explicit host-only compilation contract"
|
|
590
|
+
);
|
|
546
591
|
|
|
547
592
|
const noEvidenceProgress = {
|
|
548
593
|
role: "student",
|
package/src/agent-runner.js
CHANGED
|
@@ -147,6 +147,7 @@ import {
|
|
|
147
147
|
finishResultClaimsBlocker,
|
|
148
148
|
finishResultClaimsIncompleteWork,
|
|
149
149
|
hasScsBlockerEvidence,
|
|
150
|
+
hostManagedDocumentCompilationRequested,
|
|
150
151
|
buildTmuxGitIntent,
|
|
151
152
|
inferAuthoritativeReadOnlyRoutine,
|
|
152
153
|
inferGitActionsFromCommand,
|
|
@@ -1414,6 +1415,22 @@ export function successfulReadFileEvidencePaths(messages = []) {
|
|
|
1414
1415
|
.map(({ path: sourcePath, complete }) => ({ path: sourcePath, complete }));
|
|
1415
1416
|
}
|
|
1416
1417
|
|
|
1418
|
+
export function authoritativeDocumentInputPaths(state = {}, contract = {}) {
|
|
1419
|
+
const normalize = (value = "") =>
|
|
1420
|
+
String(value || "").replace(/\\/gu, "/").replace(/^\.\//u, "").trim();
|
|
1421
|
+
const declared = [
|
|
1422
|
+
...(Array.isArray(contract?.exactInputPaths) ? contract.exactInputPaths : []),
|
|
1423
|
+
...exactInputPathsForState(state),
|
|
1424
|
+
]
|
|
1425
|
+
.map(normalize)
|
|
1426
|
+
.filter(Boolean);
|
|
1427
|
+
if (declared.length > 0) return [...new Set(declared)].slice(0, 32);
|
|
1428
|
+
return successfulReadFileEvidencePaths(state.messages || [])
|
|
1429
|
+
.map((item) => normalize(item.path))
|
|
1430
|
+
.filter(Boolean)
|
|
1431
|
+
.slice(-32);
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1417
1434
|
function writingRequestNeedsSourceGrounding(args = {}) {
|
|
1418
1435
|
const context = [args.writingBrief, args.canon, args.constraints, args.priorDraft]
|
|
1419
1436
|
.filter((value) => typeof value === "string")
|
|
@@ -3238,7 +3255,9 @@ async function createInitialState(config, sessionId) {
|
|
|
3238
3255
|
isRetainedWorkspaceProfile(config)
|
|
3239
3256
|
? "For website/app/code/LaTeX/Python/C/shell tasks, create or edit real workspace files and run bounded checks when useful."
|
|
3240
3257
|
: "For website/app/code/LaTeX/Python/C/shell tasks, create or edit real workspace files, run available build/compile/test commands, and surface artifacts through the canvas when useful.",
|
|
3241
|
-
|
|
3258
|
+
hostManagedDocumentCompilationRequested(config.goal)
|
|
3259
|
+
? "For this host-managed document task, create and verify the requested editable sources only. Do not invoke LaTeX, make, package managers, or document compilers; the host stage owns compilation and derived-PDF validation."
|
|
3260
|
+
: "For LaTeX/PDF tasks, check existing latexmk/pdflatex first and compile with the available host or Docker TeX toolchain before installing packages or rebuilding the sandbox.",
|
|
3242
3261
|
"For research or web-search tasks, use browser tools or safe shell network tools when the current policy allows; cite or save useful sources in workspace notes when the task needs traceability.",
|
|
3243
3262
|
completionRequirementCoverageInstruction(),
|
|
3244
3263
|
repositorySourcePrecedenceInstruction(),
|
|
@@ -10816,12 +10835,19 @@ export async function documentQualityCommitAssessment(
|
|
|
10816
10835
|
const requestedArtifactKinds = Array.isArray(contract.requiredArtifactKinds)
|
|
10817
10836
|
? contract.requiredArtifactKinds
|
|
10818
10837
|
: [];
|
|
10838
|
+
const hostManagedCompilation = Boolean(
|
|
10839
|
+
contract.hostManagedDocumentCompilation ||
|
|
10840
|
+
hostManagedDocumentCompilationRequested(completionContractGoal(config, state))
|
|
10841
|
+
);
|
|
10819
10842
|
const documentRequested = Boolean(
|
|
10820
|
-
exactOutputPaths.some((item) =>
|
|
10843
|
+
exactOutputPaths.some((item) =>
|
|
10844
|
+
/\.docx$/iu.test(String(item || "")) ||
|
|
10845
|
+
(!hostManagedCompilation && /\.pdf$/iu.test(String(item || "")))
|
|
10846
|
+
) ||
|
|
10821
10847
|
requestedArtifactKinds.some((item) =>
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
|
|
10848
|
+
String(item?.format || item?.extension || item || "").toLowerCase() === ".docx" ||
|
|
10849
|
+
(!hostManagedCompilation &&
|
|
10850
|
+
String(item?.format || item?.extension || item || "").toLowerCase() === ".pdf")
|
|
10825
10851
|
)
|
|
10826
10852
|
);
|
|
10827
10853
|
if (!documentRequested) return null;
|
|
@@ -10837,15 +10863,7 @@ export async function documentQualityCommitAssessment(
|
|
|
10837
10863
|
candidateResult: "",
|
|
10838
10864
|
goal: completionContractGoal(config, state),
|
|
10839
10865
|
exactOutputPaths,
|
|
10840
|
-
exactInputPaths:
|
|
10841
|
-
...(Array.isArray(contract.exactInputPaths)
|
|
10842
|
-
? contract.exactInputPaths
|
|
10843
|
-
: []),
|
|
10844
|
-
...exactInputPathsForState(state),
|
|
10845
|
-
...successfulReadFileEvidencePaths(state.messages || []).map(
|
|
10846
|
-
(item) => item.path
|
|
10847
|
-
),
|
|
10848
|
-
],
|
|
10866
|
+
exactInputPaths: authoritativeDocumentInputPaths(state, contract),
|
|
10849
10867
|
requireVersioned: false,
|
|
10850
10868
|
});
|
|
10851
10869
|
} catch (error) {
|
|
@@ -10887,7 +10905,8 @@ export async function documentQualityCommitAssessment(
|
|
|
10887
10905
|
);
|
|
10888
10906
|
const documentArtifactProducerCommand = inferredLatexArtifactProducerCommand(
|
|
10889
10907
|
state,
|
|
10890
|
-
config
|
|
10908
|
+
config,
|
|
10909
|
+
contract
|
|
10891
10910
|
);
|
|
10892
10911
|
const repair = completionRepairMutationRequirement({
|
|
10893
10912
|
contract,
|
|
@@ -16495,7 +16514,7 @@ export function nextStepRuntimeConfig(config = {}, state = {}) {
|
|
|
16495
16514
|
(item) => String(item?.id || "").toLowerCase() === "format:.tex"
|
|
16496
16515
|
)
|
|
16497
16516
|
)
|
|
16498
|
-
? inferredLatexArtifactProducerCommand(state, config)
|
|
16517
|
+
? inferredLatexArtifactProducerCommand(state, config, groundingExecutionContract)
|
|
16499
16518
|
: "";
|
|
16500
16519
|
const retainedRepairPacket = state.meta?.failedTestRecoveryPacket;
|
|
16501
16520
|
const repairedRetainedFailure = Boolean(
|
|
@@ -22450,7 +22469,13 @@ export function completionRepairMutationRequirement({
|
|
|
22450
22469
|
};
|
|
22451
22470
|
}
|
|
22452
22471
|
|
|
22453
|
-
function inferredLatexArtifactProducerCommand(state = {}, config = {}) {
|
|
22472
|
+
function inferredLatexArtifactProducerCommand(state = {}, config = {}, contract = {}) {
|
|
22473
|
+
if (
|
|
22474
|
+
contract?.hostManagedDocumentCompilation === true ||
|
|
22475
|
+
hostManagedDocumentCompilationRequested(completionContractGoal(config, state))
|
|
22476
|
+
) {
|
|
22477
|
+
return "";
|
|
22478
|
+
}
|
|
22454
22479
|
const verification = state.meta?.projectVerification || {};
|
|
22455
22480
|
const sourcePath = [...(verification.mutationHistory || [])]
|
|
22456
22481
|
.reverse()
|
|
@@ -22539,13 +22564,21 @@ async function completionEvidenceDecision({ config, state, store, observers, ste
|
|
|
22539
22564
|
...currentGoalDocumentArtifactPathsForState(state, config),
|
|
22540
22565
|
];
|
|
22541
22566
|
const documentContractText = `${completionContractGoal(config, state)}\n${candidateResult}`;
|
|
22567
|
+
const hostManagedCompilation = Boolean(
|
|
22568
|
+
assessment.contract?.hostManagedDocumentCompilation ||
|
|
22569
|
+
hostManagedDocumentCompilationRequested(completionContractGoal(config, state))
|
|
22570
|
+
);
|
|
22542
22571
|
const documentDeliverableRequested =
|
|
22543
22572
|
documentProfile === "word" ||
|
|
22544
|
-
documentExactOutputPaths.some((item) =>
|
|
22573
|
+
documentExactOutputPaths.some((item) =>
|
|
22574
|
+
/\.docx$/iu.test(String(item || "")) ||
|
|
22575
|
+
(!hostManagedCompilation && /\.pdf$/iu.test(String(item || "")))
|
|
22576
|
+
) ||
|
|
22545
22577
|
(["book", "latex", "paper", "writing"].includes(documentProfile) &&
|
|
22546
|
-
/(?:\b(?:docx|
|
|
22578
|
+
(/(?:\b(?:docx|word document)\b|可编辑.*(?:文档|文件)|(?:文档|文件).*可编辑)/iu.test(
|
|
22547
22579
|
documentContractText
|
|
22548
|
-
)
|
|
22580
|
+
) ||
|
|
22581
|
+
(!hostManagedCompilation && /\bpdf\b/iu.test(documentContractText))));
|
|
22549
22582
|
if (documentDeliverableRequested) {
|
|
22550
22583
|
try {
|
|
22551
22584
|
documentQuality = await validateWordDocumentArtifacts({
|
|
@@ -22553,11 +22586,7 @@ async function completionEvidenceDecision({ config, state, store, observers, ste
|
|
|
22553
22586
|
candidateResult,
|
|
22554
22587
|
goal: completionContractGoal(config, state),
|
|
22555
22588
|
exactOutputPaths: documentExactOutputPaths,
|
|
22556
|
-
exactInputPaths:
|
|
22557
|
-
...(assessment.contract?.exactInputPaths || []),
|
|
22558
|
-
...exactInputPathsForState(state),
|
|
22559
|
-
...successfulReadFileEvidencePaths(state.messages || []).map((item) => item.path),
|
|
22560
|
-
],
|
|
22589
|
+
exactInputPaths: authoritativeDocumentInputPaths(state, assessment.contract),
|
|
22561
22590
|
requireVersioned: (assessment.contract?.requiredGitActions || []).includes("commit"),
|
|
22562
22591
|
});
|
|
22563
22592
|
} catch (error) {
|
|
@@ -22838,7 +22867,8 @@ async function completionEvidenceDecision({ config, state, store, observers, ste
|
|
|
22838
22867
|
: "";
|
|
22839
22868
|
const documentArtifactProducerCommand = inferredLatexArtifactProducerCommand(
|
|
22840
22869
|
state,
|
|
22841
|
-
config
|
|
22870
|
+
config,
|
|
22871
|
+
assessment.contract
|
|
22842
22872
|
);
|
|
22843
22873
|
const freshMutationRequirement = completionRepairMutationRequirement({
|
|
22844
22874
|
contract: assessment.contract,
|
|
@@ -821,6 +821,32 @@ export async function collectDocumentSourceDocuments(commandCwd, exactInputPaths
|
|
|
821
821
|
const maxTotalBytes = 4 * 1024 * 1024;
|
|
822
822
|
const maxFileBytes = 512 * 1024;
|
|
823
823
|
|
|
824
|
+
const knownPaths = new Set();
|
|
825
|
+
for (const value of Array.isArray(exactInputPaths) ? exactInputPaths : []) {
|
|
826
|
+
if (documents.length >= maxFiles || totalBytes >= maxTotalBytes) break;
|
|
827
|
+
const absolutePath = path.resolve(commandCwd, String(value || ""));
|
|
828
|
+
if (!isInsideRoot(commandCwd, absolutePath)) continue;
|
|
829
|
+
const relativePath = portablePath(path.relative(commandCwd, absolutePath));
|
|
830
|
+
if (!relativePath || knownPaths.has(relativePath)) continue;
|
|
831
|
+
if (!DOCUMENT_EXTENSIONS.has(path.extname(absolutePath).toLowerCase())) continue;
|
|
832
|
+
try {
|
|
833
|
+
const stat = await fs.stat(absolutePath);
|
|
834
|
+
if (!stat.isFile() || stat.size <= 0 || stat.size > maxFileBytes) continue;
|
|
835
|
+
if (totalBytes + stat.size > maxTotalBytes) continue;
|
|
836
|
+
const text = await fs.readFile(absolutePath, "utf8");
|
|
837
|
+
documents.push({ path: relativePath, text });
|
|
838
|
+
knownPaths.add(relativePath);
|
|
839
|
+
totalBytes += stat.size;
|
|
840
|
+
} catch {
|
|
841
|
+
// Exact unreadable sources remain visible to the existing source/evidence gates.
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
// Declared task inputs are authoritative. Repository-wide discovery is a
|
|
846
|
+
// fallback for tasks that did not name a readable source, not extra context
|
|
847
|
+
// to blend into a scoped document review.
|
|
848
|
+
if (documents.length > 0) return documents;
|
|
849
|
+
|
|
824
850
|
async function visit(directory, sourceRoot = false, depth = 0) {
|
|
825
851
|
if (documents.length >= maxFiles || totalBytes >= maxTotalBytes || depth > 5) return;
|
|
826
852
|
let entries;
|
|
@@ -857,26 +883,6 @@ export async function collectDocumentSourceDocuments(commandCwd, exactInputPaths
|
|
|
857
883
|
}
|
|
858
884
|
|
|
859
885
|
await visit(commandCwd, false, 0);
|
|
860
|
-
const knownPaths = new Set(documents.map((item) => item.path));
|
|
861
|
-
for (const value of Array.isArray(exactInputPaths) ? exactInputPaths : []) {
|
|
862
|
-
if (documents.length >= maxFiles || totalBytes >= maxTotalBytes) break;
|
|
863
|
-
const absolutePath = path.resolve(commandCwd, String(value || ""));
|
|
864
|
-
if (!isInsideRoot(commandCwd, absolutePath)) continue;
|
|
865
|
-
const relativePath = portablePath(path.relative(commandCwd, absolutePath));
|
|
866
|
-
if (!relativePath || knownPaths.has(relativePath)) continue;
|
|
867
|
-
if (!DOCUMENT_EXTENSIONS.has(path.extname(absolutePath).toLowerCase())) continue;
|
|
868
|
-
try {
|
|
869
|
-
const stat = await fs.stat(absolutePath);
|
|
870
|
-
if (!stat.isFile() || stat.size <= 0 || stat.size > maxFileBytes) continue;
|
|
871
|
-
if (totalBytes + stat.size > maxTotalBytes) continue;
|
|
872
|
-
const text = await fs.readFile(absolutePath, "utf8");
|
|
873
|
-
documents.push({ path: relativePath, text });
|
|
874
|
-
knownPaths.add(relativePath);
|
|
875
|
-
totalBytes += stat.size;
|
|
876
|
-
} catch {
|
|
877
|
-
// Exact unreadable sources remain visible to the existing source/evidence gates.
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
886
|
return documents;
|
|
881
887
|
}
|
|
882
888
|
|
package/src/scs-evidence.js
CHANGED
|
@@ -670,9 +670,40 @@ function artifactRequestHasOutputIntent(goal = "", taskProfile = "") {
|
|
|
670
670
|
);
|
|
671
671
|
}
|
|
672
672
|
|
|
673
|
+
export function hostManagedDocumentCompilationRequested(goal = "") {
|
|
674
|
+
const source = String(goal || "").replace(/\s+/gu, " ").trim();
|
|
675
|
+
if (!source) return false;
|
|
676
|
+
if (
|
|
677
|
+
/\bdo\s+not\s+(?:invoke|run|use)\b[^.!?;。!?;]{0,180}\b(?:document\s+compiler|latexmk|pdflatex|xelatex|lualatex|latex|pandoc|make)\b[^.!?;。!?;]{0,180}\b(?:labcanvas\s+)?host\b/iu.test(
|
|
678
|
+
source
|
|
679
|
+
) ||
|
|
680
|
+
/(?:不要|不得|无需|不需要)(?:调用|运行|使用).{0,80}(?:LaTeX|latexmk|pdflatex|xelatex|文档编译器).{0,100}(?:由|交给)(?:\s*LabCanvas)?(?:主机|宿主)(?:编译|构建|渲染|验证)/u.test(
|
|
681
|
+
source
|
|
682
|
+
)
|
|
683
|
+
) {
|
|
684
|
+
return true;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
const ownershipPattern =
|
|
688
|
+
/\b(?:the\s+)?(?:labcanvas\s+)?host(?:\s+(?:compiler|recovery|stage)){0,2}\s+(?:alone\s+)?(?:owns|handles?|performs?|will\s+(?:build|compile|handle|perform|render|validate))\b[^.!?;。!?;]{0,120}\b(?:compil(?:ation|e)|document|latex|pdf|render|validation)\b/giu;
|
|
689
|
+
for (const match of source.matchAll(ownershipPattern)) {
|
|
690
|
+
const prefix = source.slice(Math.max(0, Number(match.index || 0) - 180), Number(match.index || 0));
|
|
691
|
+
if (
|
|
692
|
+
/\b(?:if|when)\b[^.!?;。!?;]{0,140}\b(?:cannot|can't|fails?|failure|unavailable|unsupported)\b/iu.test(
|
|
693
|
+
prefix
|
|
694
|
+
)
|
|
695
|
+
) {
|
|
696
|
+
continue;
|
|
697
|
+
}
|
|
698
|
+
return true;
|
|
699
|
+
}
|
|
700
|
+
return false;
|
|
701
|
+
}
|
|
702
|
+
|
|
673
703
|
export function inferRequestedArtifactRequirements(goal = "", taskProfile = "") {
|
|
674
704
|
const source = stripForbiddenLanguage(String(goal || ""));
|
|
675
705
|
if (!artifactRequestHasOutputIntent(source, taskProfile)) return [];
|
|
706
|
+
const hostManagedCompilation = hostManagedDocumentCompilationRequested(goal);
|
|
676
707
|
|
|
677
708
|
const requirements = [];
|
|
678
709
|
const add = (requirement) => {
|
|
@@ -681,6 +712,7 @@ export function inferRequestedArtifactRequirements(goal = "", taskProfile = "")
|
|
|
681
712
|
};
|
|
682
713
|
|
|
683
714
|
for (const format of REQUESTED_ARTIFACT_FORMATS) {
|
|
715
|
+
if (hostManagedCompilation && format.extension === ".pdf") continue;
|
|
684
716
|
if (!requestedArtifactFormatHasOutputIntent(source, format)) continue;
|
|
685
717
|
add({
|
|
686
718
|
id: `format:${format.extension}`,
|
|
@@ -702,6 +734,7 @@ export function inferRequestedArtifactRequirements(goal = "", taskProfile = "")
|
|
|
702
734
|
}
|
|
703
735
|
|
|
704
736
|
if (
|
|
737
|
+
!hostManagedCompilation &&
|
|
705
738
|
/\bprintable\b/i.test(source) &&
|
|
706
739
|
/\b(?:answer|deck|document|handout|material|practice|sheet|slides?|worksheet)\b/i.test(source)
|
|
707
740
|
) {
|
|
@@ -2170,9 +2203,16 @@ export function deriveScsTaskContract({ goal = "", taskProfile = "", acceptanceC
|
|
|
2170
2203
|
inferExactOutputPaths(positiveEvidenceGoal),
|
|
2171
2204
|
excludedOutputPaths
|
|
2172
2205
|
);
|
|
2206
|
+
const hostManagedDocumentCompilation = hostManagedDocumentCompilationRequested(
|
|
2207
|
+
evidenceGoal
|
|
2208
|
+
);
|
|
2173
2209
|
const exactOutputPaths = filterExplicitlyExcludedOutputPaths(
|
|
2174
2210
|
applyScopedArtifactRoot(inferredOutputPaths, artifactRoot),
|
|
2175
2211
|
excludedOutputPaths
|
|
2212
|
+
).filter(
|
|
2213
|
+
(item) =>
|
|
2214
|
+
!hostManagedDocumentCompilation ||
|
|
2215
|
+
path.extname(String(item || "")).toLocaleLowerCase("en-US") !== ".pdf"
|
|
2176
2216
|
);
|
|
2177
2217
|
const exactInputPaths = filterExplicitlyExcludedOutputPaths(
|
|
2178
2218
|
inferExactInputPaths(positiveEvidenceGoal),
|
|
@@ -2198,6 +2238,7 @@ export function deriveScsTaskContract({ goal = "", taskProfile = "", acceptanceC
|
|
|
2198
2238
|
forbiddenActions: inferForbiddenActions(evidenceGoal),
|
|
2199
2239
|
exactOutputPaths,
|
|
2200
2240
|
requiredArtifactKinds,
|
|
2241
|
+
hostManagedDocumentCompilation,
|
|
2201
2242
|
scopedArtifactDeliverable,
|
|
2202
2243
|
scopedArtifactOperation,
|
|
2203
2244
|
excludedOutputPaths,
|