@agentica/core 0.29.5 → 0.30.0
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/lib/constants/AgenticaSystemPrompt.d.ts +1 -0
- package/lib/constants/AgenticaSystemPrompt.js +2 -1
- package/lib/constants/AgenticaSystemPrompt.js.map +1 -1
- package/lib/events/AgenticaEvent.d.ts +3 -1
- package/lib/events/AgenticaJsonParseErrorEvent.d.ts +8 -0
- package/lib/events/AgenticaJsonParseErrorEvent.js +3 -0
- package/lib/events/AgenticaJsonParseErrorEvent.js.map +1 -0
- package/lib/events/MicroAgenticaEvent.d.ts +3 -1
- package/lib/events/index.d.ts +1 -0
- package/lib/events/index.js +1 -0
- package/lib/events/index.js.map +1 -1
- package/lib/factory/events.d.ts +8 -1
- package/lib/factory/events.js +14 -2
- package/lib/factory/events.js.map +1 -1
- package/lib/functional/assertHttpController.js +14 -14
- package/lib/functional/assertHttpLlmApplication.js +14 -14
- package/lib/functional/validateHttpController.js +14 -14
- package/lib/functional/validateHttpLlmApplication.js +14 -14
- package/lib/index.mjs +764 -1722
- package/lib/index.mjs.map +1 -1
- package/lib/json/IAgenticaEventJson.d.ts +18 -5
- package/lib/orchestrate/call.d.ts +1 -1
- package/lib/orchestrate/call.js +199 -285
- package/lib/orchestrate/call.js.map +1 -1
- package/lib/orchestrate/cancel.js +23 -20
- package/lib/orchestrate/cancel.js.map +1 -1
- package/lib/orchestrate/initialize.js +565 -1560
- package/lib/orchestrate/initialize.js.map +1 -1
- package/lib/orchestrate/select.js +24 -21
- package/lib/orchestrate/select.js.map +1 -1
- package/lib/structures/IAgenticaSystemPrompt.d.ts +31 -0
- package/lib/structures/IMicroAgenticaSystemPrompt.d.ts +31 -0
- package/package.json +5 -5
- package/prompts/json_parse_error.md +32 -0
- package/prompts/validate.md +61 -13
- package/src/constants/AgenticaSystemPrompt.ts +3 -1
- package/src/events/AgenticaEvent.ts +3 -0
- package/src/events/AgenticaJsonParseErrorEvent.ts +12 -0
- package/src/events/MicroAgenticaEvent.ts +4 -1
- package/src/events/index.ts +1 -0
- package/src/factory/events.ts +19 -1
- package/src/json/IAgenticaEventJson.ts +20 -4
- package/src/orchestrate/call.ts +273 -389
- package/src/orchestrate/initialize.ts +2 -2
- package/src/orchestrate/select.ts +2 -2
- package/src/structures/IAgenticaSystemPrompt.ts +32 -0
- package/src/structures/IMicroAgenticaSystemPrompt.ts +32 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../src/orchestrate/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,gCA+HC;;AAlJD,kDAA0B;AAM1B,8EAA2E;AAC3E,4EAAyE;AACzE,
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../src/orchestrate/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,gCA+HC;;AAlJD,kDAA0B;AAM1B,8EAA2E;AAC3E,4EAAyE;AACzE,8CAAgE;AAChE,oDAA+E;AAC/E,wFAAqF;AACrF,wCAAqC;AACrC,oDAAsF;AAEtF,MAAM,QAAQ,GAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC7D,CAAC,CAAA,CAAC,CAAC;QAEH,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO;QACP,qBAAqB;QACrB,OAAO;QACP,IACE,UAAU,CAAC,OAAO,CAAC,IAAI,CACrB,CAAC,CAAC,EAAE,CACF,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI,IAAI;eACzB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAC1B,EAAE,CAAC,EAAE,CACH,EAAE,CAAC,IAAI,KAAK,UAAU,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAC/D,CACJ,EACD,CAAC;YACD,MAAM,GAAG,CAAC,UAAU,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -59,7 +59,7 @@ const selectFunctionFromContext_1 = require("./internal/selectFunctionFromContex
|
|
|
59
59
|
const CONTAINER = {
|
|
60
60
|
model: "chatgpt",
|
|
61
61
|
options: {
|
|
62
|
-
reference:
|
|
62
|
+
reference: true,
|
|
63
63
|
strict: false,
|
|
64
64
|
separate: null
|
|
65
65
|
},
|
|
@@ -75,24 +75,7 @@ const CONTAINER = {
|
|
|
75
75
|
description: "List of target functions.",
|
|
76
76
|
type: "array",
|
|
77
77
|
items: {
|
|
78
|
-
|
|
79
|
-
type: "object",
|
|
80
|
-
properties: {
|
|
81
|
-
reason: {
|
|
82
|
-
title: "The reason of the function selection",
|
|
83
|
-
description: "The reason of the function selection.\n\nJust write the reason why you've determined to select this function.",
|
|
84
|
-
type: "string"
|
|
85
|
-
},
|
|
86
|
-
name: {
|
|
87
|
-
title: "Name of the target function to call",
|
|
88
|
-
description: "Name of the target function to call.",
|
|
89
|
-
type: "string"
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
required: [
|
|
93
|
-
"reason",
|
|
94
|
-
"name"
|
|
95
|
-
]
|
|
78
|
+
$ref: "#/$defs/___IChatFunctionReference"
|
|
96
79
|
}
|
|
97
80
|
}
|
|
98
81
|
},
|
|
@@ -100,7 +83,27 @@ const CONTAINER = {
|
|
|
100
83
|
"functions"
|
|
101
84
|
],
|
|
102
85
|
additionalProperties: false,
|
|
103
|
-
$defs: {
|
|
86
|
+
$defs: {
|
|
87
|
+
___IChatFunctionReference: {
|
|
88
|
+
type: "object",
|
|
89
|
+
properties: {
|
|
90
|
+
reason: {
|
|
91
|
+
title: "The reason of the function selection",
|
|
92
|
+
description: "The reason of the function selection.\n\nJust write the reason why you've determined to select this function.",
|
|
93
|
+
type: "string"
|
|
94
|
+
},
|
|
95
|
+
name: {
|
|
96
|
+
title: "Name of the target function to call",
|
|
97
|
+
description: "Name of the target function to call.",
|
|
98
|
+
type: "string"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
required: [
|
|
102
|
+
"reason",
|
|
103
|
+
"name"
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
104
107
|
},
|
|
105
108
|
description: "Select proper API functions to call.\n\nIf you A.I. agent has found some proper API functions to call\nfrom the conversation with user, please select the API functions\njust by calling this function.\n\nWhen user wants to call a same function multiply, you A.I. agent must\nlist up it multiply in the `functions` property. Otherwise the user has\nrequested to call many different functions, you A.I. agent have to assign\nthem all into the `functions` property.\n\nAlso, if you A.I. agent can't specify a specific function to call due to lack\nof specificity or homogeneity of candidate functions, just assign all of them\nby in the` functions` property` too. Instead, when you A.I. agent can specify\na specific function to call, the others would be eliminated.",
|
|
106
109
|
validate: (() => { const _io0 = input => Array.isArray(input.functions) && input.functions.every(elem => "object" === typeof elem && null !== elem && _io1(elem)); const _io1 = input => "string" === typeof input.reason && "string" === typeof input.name; const _vo0 = (input, _path, _exceptionable = true) => [(Array.isArray(input.functions) || _report(_exceptionable, {
|
|
@@ -368,7 +371,7 @@ function step(ctx, operations, retry, failures) {
|
|
|
368
371
|
if (choice.message.role === "assistant"
|
|
369
372
|
&& choice.message.content != null
|
|
370
373
|
&& choice.message.content.length !== 0) {
|
|
371
|
-
const event = (0, events_1.
|
|
374
|
+
const event = (0, events_1.createAssistantMessageEvent)({
|
|
372
375
|
stream: (0, StreamUtil_1.toAsyncGenerator)(choice.message.content),
|
|
373
376
|
join: () => __awaiter(this, void 0, void 0, function* () { return Promise.resolve(choice.message.content); }),
|
|
374
377
|
done: () => true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/orchestrate/select.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,wBAmDC;;AAlFD,kDAA0B;AAU1B,oEAAiE;AACjE,8EAA2E;AAC3E,4EAAyE;AACzE,
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/orchestrate/select.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,wBAmDC;;AAlFD,kDAA0B;AAU1B,oEAAiE;AACjE,8EAA2E;AAC3E,4EAAyE;AACzE,8CAAgE;AAChE,oDAA+E;AAC/E,wFAAqF;AACrF,oDAAmE;AAEnE,oFAAiF;AAEjF,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGZ,CAAC;AAQJ,SAAsB,MAAM,CAC1B,GAA2B;;;QAE3B,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YACzC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC5C,CAAC;QAED,MAAM,MAAM,GACR,GAAG,CAAC,UAAU,CAAC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AAE;gBACV;oBACE,IAAI,EAAE,UAAU;oBAChB,EAAE,EAAE,CAAC,CAAC,EAAE;oBACR,QAAQ,EAAE;wBACR,IAAI,EAAE,CAAC,CAAC,IAAI;wBACZ,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;qBAC7C;iBACF;aACF;SACmD;QACtD;YACE,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;YAC5C,YAAY,EAAE,CAAC,CAAC,EAAE;SAC6B;QACjD;YACE,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,wDAAwD;gBACxD,EAAE;gBACF,0CAA0C;aAC3C,CAAC,IAAI,CAAC,IAAI,CAAC;SACqC;KACpD,CAAC;SACD,IAAI,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
import type { AgenticaJsonParseErrorEvent } from "../events";
|
|
2
3
|
import type { AgenticaValidateEvent } from "../events/AgenticaValidateEvent";
|
|
3
4
|
import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
|
|
4
5
|
import type { AgenticaHistory } from "../histories/AgenticaHistory";
|
|
@@ -165,6 +166,36 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
165
166
|
* @default Built-in validation feedback prompt optimized for typia IValidation.IFailure processing
|
|
166
167
|
*/
|
|
167
168
|
validate?: (events: AgenticaValidateEvent<Model>[]) => string;
|
|
169
|
+
/**
|
|
170
|
+
* JSON parsing error system prompt.
|
|
171
|
+
*
|
|
172
|
+
* When the AI generates function arguments with invalid JSON syntax
|
|
173
|
+
* that cannot be parsed by `JSON.parse()`, this prompt provides system
|
|
174
|
+
* instructions for handling the parsing error and requesting corrected
|
|
175
|
+
* function calls.
|
|
176
|
+
*
|
|
177
|
+
* This specialized prompt enables the AI to:
|
|
178
|
+
* - Understand that the function call arguments contained malformed JSON
|
|
179
|
+
* - Receive the specific error message from `JSON.parse()`
|
|
180
|
+
* - Get guidance on common JSON syntax issues (trailing commas, quote problems, etc.)
|
|
181
|
+
* - Retry the function call with properly formatted JSON arguments
|
|
182
|
+
*
|
|
183
|
+
* The JSON parse error prompt acts as an immediate correction mechanism
|
|
184
|
+
* when function calling fails at the JSON parsing stage, before any
|
|
185
|
+
* schema validation occurs. This ensures that basic JSON syntax compliance
|
|
186
|
+
* is maintained for all function calls.
|
|
187
|
+
*
|
|
188
|
+
* Key features include:
|
|
189
|
+
* - Direct error message reporting from `JSON.parse()`
|
|
190
|
+
* - Clear identification of the problematic function call
|
|
191
|
+
* - Specific guidance on JSON syntax requirements
|
|
192
|
+
* - Immediate retry instruction without additional processing
|
|
193
|
+
*
|
|
194
|
+
* @param event The JSON parse error event containing the malformed arguments and error details
|
|
195
|
+
* @returns JSON parse error system prompt
|
|
196
|
+
* @default Built-in JSON parse error prompt optimized for syntax correction
|
|
197
|
+
*/
|
|
198
|
+
jsonParseError?: (event: AgenticaJsonParseErrorEvent<Model>) => string;
|
|
168
199
|
/**
|
|
169
200
|
* Describe system prompt.
|
|
170
201
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
import type { AgenticaJsonParseErrorEvent } from "../events/AgenticaJsonParseErrorEvent";
|
|
2
3
|
import type { AgenticaValidateEvent } from "../events/AgenticaValidateEvent";
|
|
3
4
|
import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
|
|
4
5
|
import type { MicroAgenticaHistory } from "../histories/MicroAgenticaHistory";
|
|
@@ -101,6 +102,36 @@ export interface IMicroAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
101
102
|
* @default Built-in validation feedback prompt optimized for typia IValidation.IFailure processing
|
|
102
103
|
*/
|
|
103
104
|
validate?: (events: AgenticaValidateEvent<Model>[]) => string;
|
|
105
|
+
/**
|
|
106
|
+
* JSON parsing error system prompt.
|
|
107
|
+
*
|
|
108
|
+
* When the AI generates function arguments with invalid JSON syntax
|
|
109
|
+
* that cannot be parsed by `JSON.parse()`, this prompt provides system
|
|
110
|
+
* instructions for handling the parsing error and requesting corrected
|
|
111
|
+
* function calls.
|
|
112
|
+
*
|
|
113
|
+
* This specialized prompt enables the AI to:
|
|
114
|
+
* - Understand that the function call arguments contained malformed JSON
|
|
115
|
+
* - Receive the specific error message from `JSON.parse()`
|
|
116
|
+
* - Get guidance on common JSON syntax issues (trailing commas, quote problems, etc.)
|
|
117
|
+
* - Retry the function call with properly formatted JSON arguments
|
|
118
|
+
*
|
|
119
|
+
* The JSON parse error prompt acts as an immediate correction mechanism
|
|
120
|
+
* when function calling fails at the JSON parsing stage, before any
|
|
121
|
+
* schema validation occurs. This ensures that basic JSON syntax compliance
|
|
122
|
+
* is maintained for all function calls.
|
|
123
|
+
*
|
|
124
|
+
* Key features include:
|
|
125
|
+
* - Direct error message reporting from `JSON.parse()`
|
|
126
|
+
* - Clear identification of the problematic function call
|
|
127
|
+
* - Specific guidance on JSON syntax requirements
|
|
128
|
+
* - Immediate retry instruction without additional processing
|
|
129
|
+
*
|
|
130
|
+
* @param event The JSON parse error event containing the malformed arguments and error details
|
|
131
|
+
* @returns JSON parse error system prompt
|
|
132
|
+
* @default Built-in JSON parse error prompt optimized for syntax correction
|
|
133
|
+
*/
|
|
134
|
+
jsonParseError?: (event: AgenticaJsonParseErrorEvent<Model>) => string;
|
|
104
135
|
/**
|
|
105
136
|
* Describe system prompt.
|
|
106
137
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentica/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"description": "Agentic AI Library specialized in LLM Function Calling",
|
|
5
5
|
"author": "Wrtn Technologies",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@samchon/openapi": "^4.
|
|
39
|
+
"@samchon/openapi": "^4.4.1",
|
|
40
40
|
"openai": "^5.2.0",
|
|
41
|
-
"typia": "^9.
|
|
41
|
+
"typia": "^9.4.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@samchon/openapi": "^4.
|
|
44
|
+
"@samchon/openapi": "^4.4.1",
|
|
45
45
|
"tstl": "^3.0.0",
|
|
46
|
-
"typia": "^9.
|
|
46
|
+
"typia": "^9.4.0",
|
|
47
47
|
"uuid": "^11.0.4"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# JSON Parsing Error - Function Call Arguments Invalid
|
|
2
|
+
|
|
3
|
+
## 🚨 Critical Error: Invalid JSON Format
|
|
4
|
+
|
|
5
|
+
The `arguments` field in your function call contains invalid JSON syntax and cannot be parsed.
|
|
6
|
+
|
|
7
|
+
### Error Message
|
|
8
|
+
|
|
9
|
+
Here is the `Error.message` occurred from the `JSON.parse()` function:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
%{{ERROR_MESSAGE}}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Issue Location:
|
|
16
|
+
- Function call `arguments` field contains malformed JSON
|
|
17
|
+
- The JSON string failed `JSON.parse()` validation
|
|
18
|
+
- Function execution cannot proceed
|
|
19
|
+
|
|
20
|
+
### Required Action:
|
|
21
|
+
- **Retry the function call** with **valid JSON format**
|
|
22
|
+
- Fix the JSON syntax error indicated above
|
|
23
|
+
- Ensure proper JSON structure in the `arguments` field
|
|
24
|
+
|
|
25
|
+
### Common JSON Syntax Requirements:
|
|
26
|
+
- Use double quotes for all keys and string values
|
|
27
|
+
- Remove trailing commas
|
|
28
|
+
- Use lowercase `true`/`false` for booleans
|
|
29
|
+
- Use lowercase `null` for null values
|
|
30
|
+
- Properly escape special characters in strings
|
|
31
|
+
|
|
32
|
+
**Please correct the JSON format and retry the function call immediately.**
|
package/prompts/validate.md
CHANGED
|
@@ -115,43 +115,91 @@ export namespace IValidation {
|
|
|
115
115
|
*
|
|
116
116
|
* This error format is particularly valuable for AI function calling
|
|
117
117
|
* scenarios, where LLMs need to understand exactly what went wrong to
|
|
118
|
-
* generate correct parameters. The combination of path, expected type,
|
|
119
|
-
* actual value provides the AI with
|
|
120
|
-
* corrections, which is why
|
|
121
|
-
* success rates in validation
|
|
118
|
+
* generate correct parameters. The combination of path, expected type name,
|
|
119
|
+
* actual value, and optional human-readable description provides the AI with
|
|
120
|
+
* comprehensive context to make accurate corrections, which is why
|
|
121
|
+
* ILlmFunction.validate() can achieve such high success rates in validation
|
|
122
|
+
* feedback loops.
|
|
123
|
+
*
|
|
124
|
+
* The value field can contain any type of data, including `undefined` when
|
|
125
|
+
* dealing with missing required properties or null/undefined validation
|
|
126
|
+
* scenarios. This allows for precise error reporting in cases where the AI
|
|
127
|
+
* agent omits required fields or provides null/undefined values
|
|
128
|
+
* inappropriately.
|
|
122
129
|
*
|
|
123
130
|
* Real-world examples from AI function calling:
|
|
124
131
|
*
|
|
125
132
|
* {
|
|
126
|
-
* path: "input.member.age",
|
|
127
|
-
* expected: "number
|
|
133
|
+
* path: "$input.member.age",
|
|
134
|
+
* expected: "number",
|
|
135
|
+
* value: "25" // AI provided string instead of number
|
|
136
|
+
* }
|
|
137
|
+
*
|
|
138
|
+
* {
|
|
139
|
+
* path: "$input.count",
|
|
140
|
+
* expected: "number & Type<'uint32'>",
|
|
128
141
|
* value: 20.75 // AI provided float instead of uint32
|
|
129
142
|
* }
|
|
130
143
|
*
|
|
131
144
|
* {
|
|
132
|
-
* path: "input.categories",
|
|
145
|
+
* path: "$input.categories",
|
|
133
146
|
* expected: "Array<string>",
|
|
134
147
|
* value: "technology" // AI provided string instead of array
|
|
135
148
|
* }
|
|
136
149
|
*
|
|
137
150
|
* {
|
|
138
|
-
* path: "input.id",
|
|
151
|
+
* path: "$input.id",
|
|
139
152
|
* expected: "string & Format<'uuid'>",
|
|
140
153
|
* value: "invalid-uuid-format" // AI provided malformed UUID
|
|
141
154
|
* }
|
|
155
|
+
*
|
|
156
|
+
* {
|
|
157
|
+
* path: "$input.user.name",
|
|
158
|
+
* expected: "string",
|
|
159
|
+
* value: undefined // AI omitted required property
|
|
160
|
+
* }
|
|
142
161
|
*/
|
|
143
162
|
export interface IError {
|
|
144
163
|
/**
|
|
145
|
-
* The path to the property that failed validation
|
|
146
|
-
*
|
|
164
|
+
* The path to the property that failed validation
|
|
165
|
+
*
|
|
166
|
+
* Dot-notation path using $input prefix indicating the exact location of
|
|
167
|
+
* the validation failure within the input object structure. Examples
|
|
168
|
+
* include "$input.member.age", "$input.categories[0]",
|
|
169
|
+
* "$input.user.profile.email"
|
|
147
170
|
*/
|
|
148
171
|
path: string;
|
|
149
172
|
|
|
150
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* The expected type name or type expression
|
|
175
|
+
*
|
|
176
|
+
* Technical type specification that describes what type was expected at
|
|
177
|
+
* this path. This follows TypeScript-like syntax with embedded constraint
|
|
178
|
+
* information, such as "string", "number & Type<'uint32'>",
|
|
179
|
+
* "Array<string>", "string & Format<'uuid'> & MinLength<8>", etc.
|
|
180
|
+
*/
|
|
151
181
|
expected: string;
|
|
152
182
|
|
|
153
|
-
/**
|
|
154
|
-
|
|
183
|
+
/**
|
|
184
|
+
* The actual value that caused the validation failure
|
|
185
|
+
*
|
|
186
|
+
* This field contains the actual value that was provided but failed
|
|
187
|
+
* validation. Note that this value can be `undefined` in cases where a
|
|
188
|
+
* required property is missing or when validating against undefined
|
|
189
|
+
* values.
|
|
190
|
+
*/
|
|
191
|
+
value: unknown;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Optional human-readable description of the validation error
|
|
195
|
+
*
|
|
196
|
+
* This field is rarely populated in standard typia validation and is
|
|
197
|
+
* primarily intended for specialized AI agent libraries or custom
|
|
198
|
+
* validation scenarios that require additional context beyond the technical
|
|
199
|
+
* type information. Most validation errors rely solely on the path,
|
|
200
|
+
* expected, and value fields for comprehensive error reporting.
|
|
201
|
+
*/
|
|
202
|
+
description?: string;
|
|
155
203
|
}
|
|
156
204
|
}
|
|
157
205
|
````
|