Push issues for a value that should be a File record. Empty string * prefix is fine for the singular File path; pass `file[N]: ` for list.
(value, issues, prefix)
| 149 | /** Push issues for a value that should be a File record. Empty string |
| 150 | * prefix is fine for the singular File path; pass `file[N]: ` for list. */ |
| 151 | function fileShapeIssues(value, issues, prefix) { |
| 152 | if (!value || typeof value !== "object") { |
| 153 | issues.push(`${prefix}expected File record, got ${typeof value}`); |
| 154 | return; |
| 155 | } |
| 156 | const v = value; |
| 157 | if (typeof v.path !== "string" || v.path.length === 0) { |
| 158 | issues.push(`${prefix}File.path must be a non-empty string`); |
| 159 | } |
| 160 | else if (v.path.includes("..") || v.path.startsWith("/") || /^[A-Za-z]:/.test(v.path)) { |
| 161 | // Defensive: reject path-traversal and absolute paths so the |
| 162 | // generated artifact can be safely written to a sandbox dir. |
| 163 | issues.push(`${prefix}File.path must be a relative path without ".." segments`); |
| 164 | } |
| 165 | if (typeof v.content !== "string") { |
| 166 | issues.push(`${prefix}File.content must be a string`); |
| 167 | } |
| 168 | else if (v.content.length === 0) { |
| 169 | issues.push(`${prefix}File.content is empty`); |
| 170 | } |
| 171 | if (v.kind !== undefined && typeof v.kind !== "string") { |
| 172 | issues.push(`${prefix}File.kind must be a string when present`); |
| 173 | } |
| 174 | } |
| 175 | function finalize(issues, kind) { |
| 176 | if (issues.length > 0) { |
| 177 | (0, metrics_1.counter)("cognition.validate.failed", { mode: "schema_only", kind }); |
no outgoing calls
no test coverage detected