@niscorp/cortex 0.1.4 → 0.1.6
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 +23 -0
- package/DESIGN.md +25 -19
- package/README.md +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -432,6 +432,8 @@ type SchemaIssue = {
|
|
|
432
432
|
path: PropertyKey[];
|
|
433
433
|
message: string;
|
|
434
434
|
errors?: SchemaIssue[][];
|
|
435
|
+
issues?: SchemaIssue[];
|
|
436
|
+
origin?: string;
|
|
435
437
|
};
|
|
436
438
|
declare const flattenSchemaIssues: (issues: SchemaIssue[], prefix?: PropertyKey[]) => SchemaIssue[];
|
|
437
439
|
|
package/dist/index.d.ts
CHANGED
|
@@ -432,6 +432,8 @@ type SchemaIssue = {
|
|
|
432
432
|
path: PropertyKey[];
|
|
433
433
|
message: string;
|
|
434
434
|
errors?: SchemaIssue[][];
|
|
435
|
+
issues?: SchemaIssue[];
|
|
436
|
+
origin?: string;
|
|
435
437
|
};
|
|
436
438
|
declare const flattenSchemaIssues: (issues: SchemaIssue[], prefix?: PropertyKey[]) => SchemaIssue[];
|
|
437
439
|
|
package/dist/index.js
CHANGED
|
@@ -175,6 +175,9 @@ var pickBranch = (branches) => branches.reduce((best, branch) => {
|
|
|
175
175
|
});
|
|
176
176
|
var flattenSchemaIssues = (issues, prefix = []) => issues.flatMap((issue) => {
|
|
177
177
|
const path = [...prefix, ...issue.path];
|
|
178
|
+
if (issue.code === "invalid_key" && issue.origin === "record" && issue.issues && issue.issues.length > 0) {
|
|
179
|
+
return flattenSchemaIssues(issue.issues, path);
|
|
180
|
+
}
|
|
178
181
|
if (issue.code !== "invalid_union" || !issue.errors || issue.errors.length === 0) return [{ ...issue, path }];
|
|
179
182
|
return flattenSchemaIssues(pickBranch(issue.errors), path);
|
|
180
183
|
});
|
|
@@ -502,7 +505,7 @@ var runLoop = async (cfg) => {
|
|
|
502
505
|
if (repaired.success) parsedArgs = repaired;
|
|
503
506
|
}
|
|
504
507
|
if (!parsedArgs.success) {
|
|
505
|
-
const issues = parsedArgs.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
|
|
508
|
+
const issues = flattenSchemaIssues(parsedArgs.error.issues).map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
|
|
506
509
|
const hint = typeof args === "string" ? ' (your arguments arrived as ONE STRING \u2014 call again with a plain JSON object, e.g. {"key": "value"})' : isEmptyObject(args) ? ` (your arguments arrived EMPTY \u2014 nothing was sent. Call ${toolId} again with its arguments filled in, as its parameters describe)` : "";
|
|
507
510
|
record(
|
|
508
511
|
call,
|