@farmslot/agent-runtime 0.39.2 → 0.39.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 CHANGED
@@ -8,6 +8,10 @@
8
8
 
9
9
  - Active-development baseline; add user-facing changes here before release or package publication.
10
10
 
11
+ ## 0.39.3 - 2026-10-27
12
+
13
+ - Refuse worker completion when either evidence manifest names a missing media file, before changing the checklist or signal.
14
+
11
15
  ## 0.39.2 - 2026-10-26
12
16
 
13
17
  - Remove the local CI-parity worker step and its completion receipt requirement.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farmslot/agent-runtime",
3
- "version": "0.39.2",
3
+ "version": "0.39.3",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -5,7 +5,7 @@ import path from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
 
7
7
  const require = createRequire(import.meta.url);
8
- const { validateEvidenceManifest } = require('./evidence-manifest.cjs');
8
+ const { evidenceManifestArtifacts, normalizeArtifactPath } = require('./evidence-manifest.cjs');
9
9
  const {
10
10
  expandedArtifactsForCommand,
11
11
  resolveWorkerTerminalArtifactPath,
@@ -115,9 +115,6 @@ if (!taskDir) {
115
115
  }
116
116
 
117
117
  const issues = [];
118
- const mediaExt = /\.(png|jpe?g|gif|webp|mp4|mov|webm)$/i;
119
- const internalArtifactPath =
120
- /^artifacts\/(?:harness-launch|harness-relaunch|harness-relaunch-node20|runtime-launch|runtime-relaunch|runner-blockers)\//;
121
118
 
122
119
  function fileExists(rel) {
123
120
  try {
@@ -248,34 +245,6 @@ function isRecipeQualityArtifactStrict(value) {
248
245
  return validator(value);
249
246
  }
250
247
 
251
- function normalizeArtifactPath(value, mediaOnly = true) {
252
- if (typeof value !== 'string') return null;
253
- const trimmed = value.trim();
254
- if (!trimmed || /^(?:[a-z][a-z0-9+.-]*:|\/\/|#)/i.test(trimmed)) return null;
255
- const pathPart = trimmed.split(/[?#]/, 1)[0];
256
- const normalized = pathPart.replace(/\\/g, '/').replace(/^\.\/+/g, '');
257
- if (!normalized || path.posix.isAbsolute(normalized) || normalized.includes('\0')) return null;
258
- const segments = normalized.split('/').filter(Boolean);
259
- if (segments.some((segment) => segment === '.' || segment === '..')) return null;
260
- const withoutArtifacts =
261
- segments[0] === 'artifacts' ? segments.slice(1).join('/') : segments.join('/');
262
- if (!withoutArtifacts || (mediaOnly && !mediaExt.test(withoutArtifacts))) return null;
263
- return `artifacts/${withoutArtifacts}`;
264
- }
265
-
266
- function addRef(refs, value, artifactRoot = 'artifacts') {
267
- const relative = normalizeArtifactPath(value);
268
- const normalized = relative
269
- ? path.posix.join(artifactRoot, relative.slice('artifacts/'.length))
270
- : null;
271
- if (!normalized) return;
272
- if (internalArtifactPath.test(normalized)) {
273
- issues.push(`evidence-manifest references internal artifact: ${normalized}`);
274
- return;
275
- }
276
- refs.add(normalized);
277
- }
278
-
279
248
  function validateRecipeQualityArtifact() {
280
249
  const relPath = 'artifacts/recipe-quality.json';
281
250
  if (!fileExists(relPath)) return;
@@ -498,26 +467,10 @@ function parseManifest() {
498
467
  issues.push(`evidence-manifest.json: invalid JSON: ${error.message}`);
499
468
  return null;
500
469
  }
501
- const manifestIssues = validateEvidenceManifest(manifest);
502
- if (manifestIssues.length > 0) {
503
- issues.push(...manifestIssues);
504
- return null;
505
- }
506
-
507
- const refs = new Set();
508
- const artifactRoot = path.posix.dirname(relPath);
509
- for (const pair of manifest.before_after_pairs ?? []) {
510
- addRef(refs, pair?.before, artifactRoot);
511
- addRef(refs, pair?.after, artifactRoot);
512
- }
513
- for (const entry of manifest.standalone ?? []) addRef(refs, entry?.file, artifactRoot);
514
- addRef(refs, manifest.videos?.before, artifactRoot);
515
- addRef(refs, manifest.videos?.after, artifactRoot);
516
-
517
- for (const ref of [...refs].sort()) {
518
- if (!fileExists(ref)) issues.push(`evidence-manifest references missing artifact: ${ref}`);
519
- }
520
- return { manifest, refs };
470
+ const result = evidenceManifestArtifacts(manifest, path.posix.dirname(relPath), fileExists);
471
+ issues.push(...result.issues);
472
+ if (!result.refs) return null;
473
+ return { manifest, refs: result.refs };
521
474
  }
522
475
 
523
476
  let terminalContract;
@@ -1,3 +1,5 @@
1
+ const path = require('node:path');
2
+
1
3
  const MANIFEST_KEYS = new Set([
2
4
  'version',
3
5
  'preferred_mode',
@@ -141,4 +143,54 @@ function validateEvidenceManifest(value) {
141
143
  return issues;
142
144
  }
143
145
 
144
- module.exports = { validateEvidenceManifest };
146
+ function normalizeArtifactPath(value, mediaOnly = true) {
147
+ if (typeof value !== 'string') return null;
148
+ const trimmed = value.trim();
149
+ if (!trimmed || /^(?:[a-z][a-z0-9+.-]*:|\/\/|#)/i.test(trimmed)) return null;
150
+ const pathPart = trimmed.split(/[?#]/, 1)[0];
151
+ const normalized = pathPart.replace(/\\/g, '/').replace(/^\.\/+/g, '');
152
+ if (!normalized || path.posix.isAbsolute(normalized) || normalized.includes('\0')) return null;
153
+ const segments = normalized.split('/').filter(Boolean);
154
+ if (segments.some((segment) => segment === '.' || segment === '..')) return null;
155
+ const withoutArtifacts =
156
+ segments[0] === 'artifacts' ? segments.slice(1).join('/') : segments.join('/');
157
+ if (
158
+ !withoutArtifacts ||
159
+ (mediaOnly && !/\.(png|jpe?g|gif|webp|mp4|mov|webm)$/i.test(withoutArtifacts))
160
+ )
161
+ return null;
162
+ return `artifacts/${withoutArtifacts}`;
163
+ }
164
+
165
+ function evidenceManifestArtifacts(value, artifactRoot, fileExists) {
166
+ const issues = validateEvidenceManifest(value);
167
+ const refs = new Set();
168
+ if (issues.length) return { refs: null, issues };
169
+ const add = (value) => {
170
+ const relative = normalizeArtifactPath(value);
171
+ if (!relative) return;
172
+ const normalized = path.posix.join(artifactRoot, relative.slice('artifacts/'.length));
173
+ if (
174
+ /^artifacts\/(?:harness-launch|harness-relaunch|harness-relaunch-node20|runtime-launch|runtime-relaunch|runner-blockers)\//.test(
175
+ normalized,
176
+ )
177
+ ) {
178
+ issues.push(`evidence-manifest references internal artifact: ${normalized}`);
179
+ return;
180
+ }
181
+ refs.add(normalized);
182
+ };
183
+ for (const pair of value.before_after_pairs ?? []) {
184
+ add(pair.before);
185
+ add(pair.after);
186
+ }
187
+ for (const entry of value.standalone ?? []) add(entry.file);
188
+ add(value.videos?.before);
189
+ add(value.videos?.after);
190
+ for (const ref of [...refs].sort()) {
191
+ if (!fileExists(ref)) issues.push(`evidence-manifest references missing artifact: ${ref}`);
192
+ }
193
+ return { refs, issues };
194
+ }
195
+
196
+ module.exports = { validateEvidenceManifest, normalizeArtifactPath, evidenceManifestArtifacts };
@@ -1 +1,11 @@
1
1
  export function validateEvidenceManifest(value: unknown): string[];
2
+ export function normalizeArtifactPath(value: unknown, mediaOnly?: boolean): string | null;
3
+ export interface EvidenceManifestArtifacts {
4
+ refs: Set<string> | null;
5
+ issues: string[];
6
+ }
7
+ export function evidenceManifestArtifacts(
8
+ value: unknown,
9
+ artifactRoot: string,
10
+ fileExists: (path: string) => boolean,
11
+ ): EvidenceManifestArtifacts;
@@ -3,7 +3,7 @@ const fs = require('node:fs');
3
3
  const path = require('node:path');
4
4
  const { randomUUID } = require('node:crypto');
5
5
  const { spawnSync } = require('node:child_process');
6
- const { validateEvidenceManifest } = require('./evidence-manifest.cjs');
6
+ const { validateEvidenceManifest, evidenceManifestArtifacts } = require('./evidence-manifest.cjs');
7
7
  const {
8
8
  expandedArtifactsForCommand,
9
9
  resolveWorkerTerminalContract,
@@ -546,7 +546,13 @@ function assertEvidenceManifests() {
546
546
  issues.push(`${file}: invalid JSON: ${error.message}`);
547
547
  continue;
548
548
  }
549
- issues.push(...validateEvidenceManifest(manifest).map((issue) => `${file}: ${issue}`));
549
+ const manifestIssues =
550
+ terminalCommand === 'complete' || terminalCommand === 'no-change'
551
+ ? evidenceManifestArtifacts(manifest, path.posix.dirname(file), (ref) =>
552
+ taskFileExists(taskDir, ref),
553
+ ).issues
554
+ : validateEvidenceManifest(manifest);
555
+ issues.push(...manifestIssues.map((issue) => `${file}: ${issue}`));
550
556
  }
551
557
  if (issues.length > 0) {
552
558
  console.error(`Invalid evidence manifest:\n${issues.map((issue) => `- ${issue}`).join('\n')}`);