@lazyingart/agintiflow 0.20.313 → 0.20.315

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazyingart/agintiflow",
3
- "version": "0.20.313",
3
+ "version": "0.20.315",
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",
@@ -6030,13 +6030,86 @@ try {
6030
6030
  sandboxMode: "host",
6031
6031
  }
6032
6032
  );
6033
+ const scopedCompoundTestLogCommand = {
6034
+ toolName: "run_command",
6035
+ ok: true,
6036
+ exitCode: 0,
6037
+ args: {
6038
+ command: [
6039
+ `cd ${JSON.stringify(workspace)}`,
6040
+ `LOG=${JSON.stringify(path.join(scopedTaskRoot, "document-reader-test.log"))}`,
6041
+ 'echo "RUN_MARKER=now" > "$LOG"',
6042
+ 'python3 -m unittest discover -s tests -p \'test_reader.py\' -v >> "$LOG" 2>&1',
6043
+ 'echo "EXIT=0" >> "$LOG"',
6044
+ 'cat "$LOG"',
6045
+ ].join(" && "),
6046
+ },
6047
+ projectMutationPaths: [],
6048
+ stdout: "Ran 7 tests\nOK\nEXIT=0\n",
6049
+ stderr: "",
6050
+ };
6051
+ recordProjectVerificationOutcome(
6052
+ scopedTaskState,
6053
+ scopedCompoundTestLogCommand,
6054
+ {
6055
+ commandCwd: workspace,
6056
+ taskProfile: "auto",
6057
+ allowShellTool: true,
6058
+ sandboxMode: "host",
6059
+ }
6060
+ );
6061
+ const nullRedirectValidationCommand = {
6062
+ toolName: "run_command",
6063
+ ok: true,
6064
+ exitCode: 0,
6065
+ args: {
6066
+ command: [
6067
+ `cd ${JSON.stringify(workspace)}`,
6068
+ `python3 -m json.tool ${JSON.stringify(
6069
+ path.join(scopedTaskRoot, "agent-result.json")
6070
+ )} > /dev/null`,
6071
+ 'echo "JSON_VALID"',
6072
+ `grep -c '^## [0-9]' ${JSON.stringify(
6073
+ path.join(scopedTaskRoot, "source-intake-audit.md")
6074
+ )}`,
6075
+ ].join(" && "),
6076
+ },
6077
+ projectMutationPaths: [],
6078
+ stdout: "JSON_VALID\n5\n",
6079
+ stderr: "",
6080
+ };
6081
+ recordProjectVerificationOutcome(
6082
+ scopedTaskState,
6083
+ nullRedirectValidationCommand,
6084
+ {
6085
+ commandCwd: workspace,
6086
+ taskProfile: "auto",
6087
+ allowShellTool: true,
6088
+ sandboxMode: "host",
6089
+ }
6090
+ );
6033
6091
  assert(
6034
6092
  requestedOutputRevision === 1 &&
6035
6093
  scopedTaskState.meta.projectVerification?.mutationRevision === 1 &&
6036
6094
  readOnlyArtifactValidation.readOnlyArtifactValidation === true &&
6037
6095
  scopedManifestCommand.scopedTaskArtifactWrite === true &&
6038
- pythonScopedManifestCommand.scopedTaskArtifactWrite === true,
6039
- "task-scoped delivery bookkeeping invalidated requested artifact evidence"
6096
+ pythonScopedManifestCommand.scopedTaskArtifactWrite === true &&
6097
+ scopedCompoundTestLogCommand.scopedTaskArtifactWrite === true &&
6098
+ nullRedirectValidationCommand.readOnlyArtifactValidation === true,
6099
+ `task-scoped delivery bookkeeping invalidated requested artifact evidence: ${JSON.stringify({
6100
+ requestedOutputRevision,
6101
+ mutationRevision:
6102
+ scopedTaskState.meta.projectVerification?.mutationRevision,
6103
+ readOnlyArtifactValidation:
6104
+ readOnlyArtifactValidation.readOnlyArtifactValidation,
6105
+ scopedManifestCommand: scopedManifestCommand.scopedTaskArtifactWrite,
6106
+ pythonScopedManifestCommand:
6107
+ pythonScopedManifestCommand.scopedTaskArtifactWrite,
6108
+ scopedCompoundTestLogCommand:
6109
+ scopedCompoundTestLogCommand.scopedTaskArtifactWrite,
6110
+ nullRedirectValidationCommand:
6111
+ nullRedirectValidationCommand.readOnlyArtifactValidation,
6112
+ })}`
6040
6113
  );
6041
6114
  const mutatingInlinePython = {
6042
6115
  toolName: "run_command",
@@ -33,6 +33,19 @@ const groupBriefingContract = deriveScsTaskContract({
33
33
  ].join(" "),
34
34
  taskProfile: "research",
35
35
  });
36
+ const sourceIntakeAuditContract = deriveScsTaskContract({
37
+ goal: [
38
+ "Create one concise coherent Markdown report with exactly five numbered cases:",
39
+ "(1) a bare video has no publication;",
40
+ "(2) a current same-chat publish request authorizes only the exact referenced video through autopublish-video plus LazyEdit, while this audit performs no external action;",
41
+ "(3) Finder recovery remains evidence-limited;",
42
+ "(4) mp.weixin recovery never asks for browser verification;",
43
+ "(5) PDF/archive intake uses the guarded document reader.",
44
+ "Run only the focused existing unit test and write agent-result.json.",
45
+ "Do not send, publish, submit, upload, alter queues, or open a GUI.",
46
+ ].join(" "),
47
+ taskProfile: "auto",
48
+ });
36
49
  const scopedReadThenWriteRoot = fs.mkdtempSync(
37
50
  path.join(os.tmpdir(), "aginti-scoped-read-then-write-")
38
51
  );
@@ -83,6 +96,16 @@ assert.deepEqual(
83
96
  ["format:.pdf"],
84
97
  "an ordinary chat answer was incorrectly converted into a separate answer-key artifact"
85
98
  );
99
+ assert.deepEqual(
100
+ sourceIntakeAuditContract.requiredArtifactKinds.map((item) => item.id),
101
+ ["format:.md"],
102
+ "a Markdown-only audit inferred PDF from a described PDF intake case"
103
+ );
104
+ assert.equal(
105
+ sourceIntakeAuditContract.requiredEvidence.some((item) => item.category === "publish"),
106
+ false,
107
+ "a read-only audit of a publish contract fabricated a publish action obligation"
108
+ );
86
109
  assert.deepEqual(
87
110
  educationArtifactContract.requiredArtifactKinds.map((item) => item.id).sort(),
88
111
  [
@@ -12762,31 +12762,85 @@ function safePatchContextEvidencePath(value = "", state = {}, config = {}) {
12762
12762
  function commandWritesOnlyEvidenceMatching(command = "", pathMatches = () => false) {
12763
12763
  const normalized = String(command || "").trim();
12764
12764
  if (!normalized) return false;
12765
+ const assignments = new Map();
12766
+ for (const match of normalized.matchAll(
12767
+ /(?:^|[\s;&|])([A-Za-z_]\w*)\s*=\s*("[^"\n]+"|'[^'\n]+'|[^\s;&|]+)/g
12768
+ )) {
12769
+ assignments.set(
12770
+ match[1],
12771
+ String(match[2] || "").replace(/^["']|["']$/g, "")
12772
+ );
12773
+ }
12774
+ const resolveTarget = (value = "") => {
12775
+ const target = String(value || "")
12776
+ .trim()
12777
+ .replace(/^["']|["']$/g, "");
12778
+ const variable = target.match(/^\$(?:\{([A-Za-z_]\w*)\}|([A-Za-z_]\w*))$/);
12779
+ return variable
12780
+ ? String(assignments.get(variable[1] || variable[2]) || "")
12781
+ : target;
12782
+ };
12765
12783
  const tokens = tokenizeShellWords(normalized);
12766
12784
  if (tokens[0] === "tee") {
12767
12785
  let index = 1;
12768
12786
  if (["-a", "--append"].includes(tokens[index])) index += 1;
12769
12787
  if (tokens[index] === "--") index += 1;
12770
- const targets = tokens.slice(index);
12788
+ const targets = tokens.slice(index).map(resolveTarget);
12771
12789
  return targets.length > 0 && targets.every(pathMatches);
12772
12790
  }
12773
12791
  if (tokens[0] === "mkdir") {
12774
- const targets = tokens.slice(1).filter((token) => token !== "-p" && token !== "--");
12792
+ const targets = tokens
12793
+ .slice(1)
12794
+ .filter((token) => token !== "-p" && token !== "--")
12795
+ .map(resolveTarget);
12775
12796
  return targets.length > 0 && targets.every(pathMatches);
12776
12797
  }
12777
12798
 
12778
12799
  let strippedEvidenceRedirect = false;
12800
+ let rejectedRedirect = false;
12779
12801
  const withoutEvidenceRedirects = normalized.replace(
12780
12802
  /(^|\s)(?:\d*>>?|&>>?)\s*("[^"]+"|'[^']+'|[^\s;&|]+)/g,
12781
12803
  (match, prefix, target) => {
12782
- if (!pathMatches(target)) return match;
12804
+ const resolvedTarget = resolveTarget(target);
12805
+ if (/^(?:&\d+|\/dev\/null)$/u.test(resolvedTarget)) return prefix;
12806
+ if (!resolvedTarget || !pathMatches(resolvedTarget)) {
12807
+ rejectedRedirect = true;
12808
+ return match;
12809
+ }
12783
12810
  strippedEvidenceRedirect = true;
12784
12811
  return prefix;
12785
12812
  }
12786
12813
  ).trim();
12787
- if (!strippedEvidenceRedirect || !withoutEvidenceRedirects) return false;
12788
- const underlyingPolicy = classifyCommand(withoutEvidenceRedirects);
12789
- return underlyingPolicy.writesWorkspace !== true && underlyingPolicy.mayMutateProject !== true;
12814
+ if (rejectedRedirect || !strippedEvidenceRedirect || !withoutEvidenceRedirects) {
12815
+ return false;
12816
+ }
12817
+ const sequence = parseTopLevelShellSequence(withoutEvidenceRedirects);
12818
+ if (sequence.openQuote || sequence.trailingEscape || sequence.trailingSeparator) {
12819
+ return false;
12820
+ }
12821
+ return sequence.commands.every((segment) => {
12822
+ const withoutAssignments = String(segment || "")
12823
+ .trim()
12824
+ .replace(
12825
+ /^(?:[A-Za-z_]\w*=(?:"[^"\n]*"|'[^'\n]*'|[^\s;&|]+)\s*)+/u,
12826
+ ""
12827
+ )
12828
+ .trim();
12829
+ if (!withoutAssignments) return true;
12830
+ const commandTokens = tokenizeShellWords(withoutAssignments);
12831
+ if (
12832
+ ["cat", "cd", "head", "ls", "stat", "tail", "wc"].includes(
12833
+ String(commandTokens[0] || "")
12834
+ )
12835
+ ) {
12836
+ return true;
12837
+ }
12838
+ const underlyingPolicy = classifyCommand(withoutAssignments);
12839
+ return (
12840
+ underlyingPolicy.writesWorkspace !== true &&
12841
+ underlyingPolicy.mayMutateProject !== true
12842
+ );
12843
+ });
12790
12844
  }
12791
12845
 
12792
12846
  function commandWritesOnlyPrivateVerificationEvidence(command = "") {
@@ -12833,15 +12887,20 @@ function commandIsBoundedReadOnlyArtifactValidation(command = "") {
12833
12887
  const normalized = String(command || "").trim();
12834
12888
  if (!normalized) return false;
12835
12889
  if (
12836
- !/\bassert\b|\bjson\.(?:load|loads)\s*\(|\bJSON\.parse\s*\(|\bjq\b|\bsha256sum\b|\bmd5sum\b|\b(?:valid|pass|verified?)\b/i.test(
12890
+ !/\bassert\b|\bjson\.(?:load|loads|tool)\b|\bJSON\.parse\s*\(|\bjq\b|\bsha256sum\b|\bmd5sum\b|\b(?:valid|pass|verified?)\b/i.test(
12837
12891
  normalized
12838
12892
  )
12839
12893
  ) {
12840
12894
  return false;
12841
12895
  }
12896
+ const withoutNullRedirects = normalized.replace(
12897
+ /(^|\s)(?:\d*>>?|&>>?)\s*(?:"\/dev\/null"|'\/dev\/null'|\/dev\/null)/g,
12898
+ "$1"
12899
+ );
12842
12900
  // Heredoc input (`<<`) is compatible with read-only validation. Any output
12843
- // redirection or known mutator keeps conservative project revision tracking.
12844
- if (/(^|[^<])>{1,2}(?!=)/m.test(normalized)) return false;
12901
+ // redirection outside /dev/null or known mutator keeps conservative project
12902
+ // revision tracking.
12903
+ if (/(^|[^<])>{1,2}(?!=)/m.test(withoutNullRedirects)) return false;
12845
12904
  if (
12846
12905
  /\b(?:cp|install|mkdir|mv|rm|rmdir|tee|touch|truncate)\b|\bsed\s+-i\b|\bperl\s+-pi\b/i.test(
12847
12906
  normalized
@@ -583,6 +583,7 @@ const REQUESTED_ARTIFACT_FORMATS = [
583
583
  { extension: ".pptx", pattern: /\b(?:pptx|powerpoint)\b/i, description: "editable PowerPoint deck" },
584
584
  { extension: ".odp", pattern: /\b(?:odp|open(?:office|document) presentation)\b/i, description: "editable ODP deck" },
585
585
  { extension: ".pdf", pattern: /\bpdf\b/i, description: "PDF document" },
586
+ { extension: ".md", pattern: /(?:\bmarkdown\b|\.md\b)/i, description: "Markdown document" },
586
587
  {
587
588
  extension: ".tex",
588
589
  pattern: /(?:\b(?:editable\s+)?(?:latex|tex)\s+source\b|\.tex\b)/i,
@@ -594,6 +595,64 @@ const REQUESTED_ARTIFACT_FORMATS = [
594
595
  { extension: ".svg", pattern: /\bsvg\b/i, description: "editable SVG image" },
595
596
  ];
596
597
 
598
+ function requestedArtifactFormatHasOutputIntent(source = "", format = {}) {
599
+ const extension = String(format.extension || "").toLocaleLowerCase("en-US");
600
+ if (!extension || !format.pattern) return false;
601
+ if (
602
+ inferExactOutputPaths(source).some(
603
+ (candidate) => path.extname(candidate).toLocaleLowerCase("en-US") === extension
604
+ )
605
+ ) {
606
+ return true;
607
+ }
608
+
609
+ const matcher = new RegExp(
610
+ format.pattern.source,
611
+ format.pattern.flags.includes("g") ? format.pattern.flags : `${format.pattern.flags}g`
612
+ );
613
+ const outputAction =
614
+ /\b(?:compile|convert|create|deliver|export|generate|keep|make|output|prepare|preserve|produce|provide|render|retain|return|reuse|save|send|write)\b/i;
615
+ const directRequest =
616
+ /\b(?:can|could|would|will)\s+you\b|\b(?:i|we)\s+(?:also\s+)?(?:need|want|would\s+like|request)\b|\b(?:please|kindly)\b/i;
617
+ for (const match of source.matchAll(matcher)) {
618
+ const index = Number(match.index || 0);
619
+ const clauseStart = Math.max(
620
+ source.lastIndexOf(".", index - 1),
621
+ source.lastIndexOf("!", index - 1),
622
+ source.lastIndexOf("?", index - 1),
623
+ source.lastIndexOf(";", index - 1),
624
+ source.lastIndexOf("。", index - 1),
625
+ source.lastIndexOf("!", index - 1),
626
+ source.lastIndexOf("?", index - 1),
627
+ source.lastIndexOf(";", index - 1),
628
+ source.lastIndexOf("\n", index - 1)
629
+ );
630
+ const nextBoundaries = [".", "!", "?", ";", "。", "!", "?", ";", "\n"]
631
+ .map((delimiter) => source.indexOf(delimiter, index + String(match[0] || "").length))
632
+ .filter((candidate) => candidate >= 0);
633
+ const clauseEnd = nextBoundaries.length ? Math.min(...nextBoundaries) : source.length;
634
+ const clause = source.slice(clauseStart + 1, clauseEnd);
635
+ const matchOffset = index - clauseStart - 1;
636
+ const before = clause.slice(Math.max(0, matchOffset - 180), matchOffset);
637
+ const after = clause.slice(matchOffset + String(match[0] || "").length, matchOffset + 120);
638
+ if (outputAction.test(before) || directRequest.test(before)) return true;
639
+ if (
640
+ /\b(?:as|into|to)\s+(?:an?\s+)?$/i.test(before) &&
641
+ /\b(?:compile|convert|export|render|save)\b/i.test(clause)
642
+ ) {
643
+ return true;
644
+ }
645
+ if (
646
+ /^\s*(?:output|deliverable|file|document|report|version|copy)\b/i.test(after) &&
647
+ outputAction.test(clause)
648
+ ) {
649
+ return true;
650
+ }
651
+ if (/^\s*(?:please|required|requested)\b/i.test(after)) return true;
652
+ }
653
+ return false;
654
+ }
655
+
597
656
  function artifactRequestHasOutputIntent(goal = "", taskProfile = "") {
598
657
  const source = stripForbiddenLanguage(String(goal || ""));
599
658
  return Boolean(
@@ -622,7 +681,7 @@ export function inferRequestedArtifactRequirements(goal = "", taskProfile = "")
622
681
  };
623
682
 
624
683
  for (const format of REQUESTED_ARTIFACT_FORMATS) {
625
- if (!format.pattern.test(source)) continue;
684
+ if (!requestedArtifactFormatHasOutputIntent(source, format)) continue;
626
685
  add({
627
686
  id: `format:${format.extension}`,
628
687
  kind: "format",
@@ -1456,6 +1515,41 @@ function requiresSourceGrounding(goal = "") {
1456
1515
  );
1457
1516
  }
1458
1517
 
1518
+ function goalRequestsPublishAction(goal = "") {
1519
+ const text = normalizedText(stripCompletedWorkNarration(stripForbiddenLanguage(goal)));
1520
+ const action =
1521
+ "(?:publish|deploy|submit|upload\\s+to|generate\\s+(?:a\\s+)?video|npm\\s+publish)";
1522
+ const release =
1523
+ "(?:release|ship)(?:\\s+(?:(?:the|this|that|a|an)\\s+)?(?:package|version|build|app|application|software|library|plugin|extension|product)|\\s+(?:to|on|via|through))|cut\\s+(?:a\\s+)?release";
1524
+ const clauses = text
1525
+ .split(/[\n.!?;,;。!?]+/u)
1526
+ .map((clause) => clause.trim())
1527
+ .filter(Boolean);
1528
+ for (const clause of clauses) {
1529
+ if (
1530
+ new RegExp(
1531
+ `^(?:(?:and|also|then|next|finally|please|kindly)\\s+)*(?:${action}|${release})\\b`,
1532
+ "i"
1533
+ ).test(clause)
1534
+ ) {
1535
+ return true;
1536
+ }
1537
+ if (
1538
+ new RegExp(
1539
+ `\\b(?:(?:can|could|would|will)\\s+you|(?:i|we)\\s+(?:need|want|would\\s+like)\\s+(?:you\\s+)?to|you\\s+(?:must|should|need\\s+to|have\\s+to)|please|kindly|then|next|finally)\\b[^.\\n;]{0,140}\\b(?:${action}|${release})\\b`,
1540
+ "i"
1541
+ ).test(clause)
1542
+ ) {
1543
+ return true;
1544
+ }
1545
+ }
1546
+ return (
1547
+ /(?:请|請|需要|必须|必須|帮我|幫我|立即|现在|現在)[^。;\n]{0,100}(?:发布|發布|部署|提交|上传|上傳|生成视频|生成影片)/u.test(
1548
+ text
1549
+ ) || /^(?:发布|發布|部署|提交|上传|上傳|生成视频|生成影片)/u.test(text)
1550
+ );
1551
+ }
1552
+
1459
1553
  function inferRequirementCategories(goal = "", taskProfile = "", acceptanceCriteria = []) {
1460
1554
  const positiveGoal = stripForbiddenLanguage(goal);
1461
1555
  const text = normalizedText(positiveGoal);
@@ -1531,16 +1625,7 @@ function inferRequirementCategories(goal = "", taskProfile = "", acceptanceCrite
1531
1625
  ) {
1532
1626
  categories.add("visual");
1533
1627
  }
1534
- const explicitPublishAction =
1535
- textHas(
1536
- text,
1537
- /\b(?:publish|deploy|submit|upload to|generate video|external service|npm publish)\b/
1538
- ) ||
1539
- textHas(
1540
- text,
1541
- /\b(?:release|ship)\s+(?:(?:the|this|that|a|an)\s+)?(?:package|version|build|app|application|software|library|plugin|extension|product)\b|\b(?:release|ship)\s+(?:to|on|via|through)\b|\bcut\s+(?:a\s+)?release\b/
1542
- ) ||
1543
- /发布|部署|提交|生成视频|外部服务/.test(text);
1628
+ const explicitPublishAction = goalRequestsPublishAction(positiveGoal);
1544
1629
  if (explicitPublishAction) {
1545
1630
  categories.add("publish");
1546
1631
  }