@jterrazz/intelligence 1.5.0 → 2.0.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/README.md +199 -83
- package/dist/adapters/agents/{basic-agent.adapter.d.ts → chat-agent.adapter.d.ts} +6 -6
- package/dist/adapters/agents/{basic-agent.adapter.js → chat-agent.adapter.js} +54 -27
- package/dist/adapters/agents/chat-agent.adapter.js.map +1 -0
- package/dist/adapters/agents/{retryable-agent.adapter.d.ts → resilient-agent.adapter.d.ts} +4 -4
- package/dist/adapters/agents/{retryable-agent.adapter.js → resilient-agent.adapter.js} +22 -13
- package/dist/adapters/agents/resilient-agent.adapter.js.map +1 -0
- package/dist/adapters/agents/{autonomous-agent.adapter.d.ts → tool-agent.adapter.d.ts} +6 -6
- package/dist/adapters/agents/{autonomous-agent.adapter.js → tool-agent.adapter.js} +29 -18
- package/dist/adapters/agents/tool-agent.adapter.js.map +1 -0
- package/dist/adapters/models/openrouter-model.adapter.d.ts +17 -32
- package/dist/adapters/models/openrouter-model.adapter.js +84 -25
- package/dist/adapters/models/openrouter-model.adapter.js.map +1 -1
- package/dist/adapters/prompts/__tests__/presets.test.js +4 -4
- package/dist/adapters/prompts/__tests__/presets.test.js.map +1 -1
- package/dist/adapters/prompts/system-prompt.adapter.d.ts +2 -2
- package/dist/adapters/prompts/system-prompt.adapter.js +6 -6
- package/dist/adapters/prompts/system-prompt.adapter.js.map +1 -1
- package/dist/adapters/prompts/user-prompt.adapter.d.ts +2 -2
- package/dist/adapters/prompts/user-prompt.adapter.js +6 -6
- package/dist/adapters/prompts/user-prompt.adapter.js.map +1 -1
- package/dist/adapters/providers/openrouter-provider.adapter.d.ts +34 -0
- package/dist/adapters/providers/openrouter-provider.adapter.js +57 -0
- package/dist/adapters/providers/openrouter-provider.adapter.js.map +1 -0
- package/dist/adapters/tools/safe-tool.adapter.d.ts +2 -2
- package/dist/adapters/tools/safe-tool.adapter.js +6 -6
- package/dist/adapters/tools/safe-tool.adapter.js.map +1 -1
- package/dist/adapters/utils/__tests__/{ai-response-parser.test.js → structured-response-parser.test.js} +30 -30
- package/dist/adapters/utils/__tests__/structured-response-parser.test.js.map +1 -0
- package/dist/adapters/utils/{ai-response-parser-error.d.ts → structured-response-parser-error.d.ts} +2 -2
- package/dist/adapters/utils/{ai-response-parser-error.js → structured-response-parser-error.js} +9 -9
- package/dist/adapters/utils/structured-response-parser-error.js.map +1 -0
- package/dist/adapters/utils/{ai-response-parser.d.ts → structured-response-parser.d.ts} +1 -1
- package/dist/adapters/utils/{ai-response-parser.js → structured-response-parser.js} +13 -13
- package/dist/adapters/utils/structured-response-parser.js.map +1 -0
- package/dist/index.cjs +748 -342
- package/dist/index.d.ts +11 -8
- package/dist/index.js +29 -8
- package/dist/index.js.map +1 -1
- package/dist/ports/model.port.d.ts +30 -3
- package/dist/ports/model.port.js +1 -1
- package/dist/ports/model.port.js.map +1 -1
- package/dist/ports/provider.port.d.ts +13 -0
- package/dist/ports/provider.port.js +5 -0
- package/dist/ports/provider.port.js.map +1 -0
- package/package.json +11 -9
- package/dist/adapters/agents/autonomous-agent.adapter.js.map +0 -1
- package/dist/adapters/agents/basic-agent.adapter.js.map +0 -1
- package/dist/adapters/agents/retryable-agent.adapter.js.map +0 -1
- package/dist/adapters/utils/__tests__/ai-response-parser.test.js.map +0 -1
- package/dist/adapters/utils/ai-response-parser-error.js.map +0 -1
- package/dist/adapters/utils/ai-response-parser.js.map +0 -1
- /package/dist/adapters/utils/__tests__/{ai-response-parser.test.d.ts → structured-response-parser.test.d.ts} +0 -0
|
@@ -31,19 +31,19 @@ function _define_property(obj, key, value) {
|
|
|
31
31
|
return obj;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* System prompt
|
|
35
|
-
*/ export var
|
|
34
|
+
* System prompt that generates a system prompt from a list of strings
|
|
35
|
+
*/ export var SystemPrompt = /*#__PURE__*/ function() {
|
|
36
36
|
"use strict";
|
|
37
|
-
function
|
|
37
|
+
function SystemPrompt() {
|
|
38
38
|
for(var _len = arguments.length, prompts = new Array(_len), _key = 0; _key < _len; _key++){
|
|
39
39
|
prompts[_key] = arguments[_key];
|
|
40
40
|
}
|
|
41
|
-
_class_call_check(this,
|
|
41
|
+
_class_call_check(this, SystemPrompt);
|
|
42
42
|
_define_property(this, "finalPrompt", void 0);
|
|
43
43
|
var flattenedPrompts = prompts.flat();
|
|
44
44
|
this.finalPrompt = flattenedPrompts.join('\n\n');
|
|
45
45
|
}
|
|
46
|
-
_create_class(
|
|
46
|
+
_create_class(SystemPrompt, [
|
|
47
47
|
{
|
|
48
48
|
key: "generate",
|
|
49
49
|
value: function generate() {
|
|
@@ -51,7 +51,7 @@ function _define_property(obj, key, value) {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
]);
|
|
54
|
-
return
|
|
54
|
+
return SystemPrompt;
|
|
55
55
|
}();
|
|
56
56
|
|
|
57
57
|
//# sourceMappingURL=system-prompt.adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/prompts/system-prompt.adapter.ts"],"sourcesContent":["import type { PromptPort } from '../../ports/prompt.port.js';\n\n/**\n * System prompt
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/prompts/system-prompt.adapter.ts"],"sourcesContent":["import type { PromptPort } from '../../ports/prompt.port.js';\n\n/**\n * System prompt that generates a system prompt from a list of strings\n */\nexport class SystemPrompt implements PromptPort {\n private readonly finalPrompt: string;\n\n constructor(...prompts: readonly (readonly string[] | string)[]) {\n const flattenedPrompts = prompts.flat();\n this.finalPrompt = flattenedPrompts.join('\\n\\n');\n }\n\n generate(): string {\n return this.finalPrompt;\n }\n}\n"],"names":["SystemPrompt","prompts","finalPrompt","flattenedPrompts","flat","join","generate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;CAEC,GACD,OAAO,IAAA,AAAMA,6BAAN;;aAAMA;QAGG,IAAA,IAAA,OAAA,UAAA,QAAA,AAAGC,UAAH,UAAA,OAAA,OAAA,GAAA,OAAA,MAAA;YAAGA,QAAH,QAAA,SAAA,CAAA,KAAmD;;gCAHtDD;QACT,uBAAiBE,eAAjB,KAAA;QAGI,IAAMC,mBAAmBF,QAAQG,IAAI;QACrC,IAAI,CAACF,WAAW,GAAGC,iBAAiBE,IAAI,CAAC;;kBALpCL;;YAQTM,KAAAA;mBAAAA,SAAAA;gBACI,OAAO,IAAI,CAACJ,WAAW;YAC3B;;;WAVSF;IAWZ"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { PromptPort } from '../../ports/prompt.port.js';
|
|
2
2
|
/**
|
|
3
|
-
* User prompt
|
|
3
|
+
* User prompt that generates a user prompt from a list of strings
|
|
4
4
|
*/
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class UserPrompt implements PromptPort {
|
|
6
6
|
private readonly finalPrompt;
|
|
7
7
|
constructor(...prompts: readonly (readonly string[] | string)[]);
|
|
8
8
|
generate(): string;
|
|
@@ -31,19 +31,19 @@ function _define_property(obj, key, value) {
|
|
|
31
31
|
return obj;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* User prompt
|
|
35
|
-
*/ export var
|
|
34
|
+
* User prompt that generates a user prompt from a list of strings
|
|
35
|
+
*/ export var UserPrompt = /*#__PURE__*/ function() {
|
|
36
36
|
"use strict";
|
|
37
|
-
function
|
|
37
|
+
function UserPrompt() {
|
|
38
38
|
for(var _len = arguments.length, prompts = new Array(_len), _key = 0; _key < _len; _key++){
|
|
39
39
|
prompts[_key] = arguments[_key];
|
|
40
40
|
}
|
|
41
|
-
_class_call_check(this,
|
|
41
|
+
_class_call_check(this, UserPrompt);
|
|
42
42
|
_define_property(this, "finalPrompt", void 0);
|
|
43
43
|
var flattenedPrompts = prompts.flat();
|
|
44
44
|
this.finalPrompt = flattenedPrompts.join('\n\n');
|
|
45
45
|
}
|
|
46
|
-
_create_class(
|
|
46
|
+
_create_class(UserPrompt, [
|
|
47
47
|
{
|
|
48
48
|
key: "generate",
|
|
49
49
|
value: function generate() {
|
|
@@ -51,7 +51,7 @@ function _define_property(obj, key, value) {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
]);
|
|
54
|
-
return
|
|
54
|
+
return UserPrompt;
|
|
55
55
|
}();
|
|
56
56
|
|
|
57
57
|
//# sourceMappingURL=user-prompt.adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/prompts/user-prompt.adapter.ts"],"sourcesContent":["import type { PromptPort } from '../../ports/prompt.port.js';\n\n/**\n * User prompt
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/prompts/user-prompt.adapter.ts"],"sourcesContent":["import type { PromptPort } from '../../ports/prompt.port.js';\n\n/**\n * User prompt that generates a user prompt from a list of strings\n */\nexport class UserPrompt implements PromptPort {\n private readonly finalPrompt: string;\n\n constructor(...prompts: readonly (readonly string[] | string)[]) {\n const flattenedPrompts = prompts.flat();\n this.finalPrompt = flattenedPrompts.join('\\n\\n');\n }\n\n generate(): string {\n return this.finalPrompt;\n }\n}\n"],"names":["UserPrompt","prompts","finalPrompt","flattenedPrompts","flat","join","generate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;CAEC,GACD,OAAO,IAAA,AAAMA,2BAAN;;aAAMA;QAGG,IAAA,IAAA,OAAA,UAAA,QAAA,AAAGC,UAAH,UAAA,OAAA,OAAA,GAAA,OAAA,MAAA;YAAGA,QAAH,QAAA,SAAA,CAAA,KAAmD;;gCAHtDD;QACT,uBAAiBE,eAAjB,KAAA;QAGI,IAAMC,mBAAmBF,QAAQG,IAAI;QACrC,IAAI,CAACF,WAAW,GAAGC,iBAAiBE,IAAI,CAAC;;kBALpCL;;YAQTM,KAAAA;mBAAAA,SAAAA;gBACI,OAAO,IAAI,CAACJ,WAAW;YAC3B;;;WAVSF;IAWZ"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ModelConfig } from '../../ports/model.port.js';
|
|
2
|
+
import type { ProviderPort } from '../../ports/provider.port.js';
|
|
3
|
+
import { OpenRouterModel } from '../models/openrouter-model.adapter.js';
|
|
4
|
+
export interface OpenRouterConfig {
|
|
5
|
+
/**
|
|
6
|
+
* OpenRouter API key
|
|
7
|
+
*/
|
|
8
|
+
apiKey: string;
|
|
9
|
+
/**
|
|
10
|
+
* Optional metadata for request headers
|
|
11
|
+
*/
|
|
12
|
+
metadata?: OpenRouterMetadata;
|
|
13
|
+
}
|
|
14
|
+
export interface OpenRouterMetadata {
|
|
15
|
+
/**
|
|
16
|
+
* Application title for X-Title header
|
|
17
|
+
*/
|
|
18
|
+
application?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Website URL for HTTP-Referer header
|
|
21
|
+
*/
|
|
22
|
+
website?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* OpenRouter provider that manages connection configuration
|
|
26
|
+
*/
|
|
27
|
+
export declare class OpenRouterProvider implements ProviderPort {
|
|
28
|
+
private readonly config;
|
|
29
|
+
constructor(config: OpenRouterConfig);
|
|
30
|
+
/**
|
|
31
|
+
* Get a model instance for the specified model name
|
|
32
|
+
*/
|
|
33
|
+
getModel(modelName: string, modelConfig?: ModelConfig): OpenRouterModel;
|
|
34
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
function _class_call_check(instance, Constructor) {
|
|
2
|
+
if (!(instance instanceof Constructor)) {
|
|
3
|
+
throw new TypeError("Cannot call a class as a function");
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
function _defineProperties(target, props) {
|
|
7
|
+
for(var i = 0; i < props.length; i++){
|
|
8
|
+
var descriptor = props[i];
|
|
9
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
10
|
+
descriptor.configurable = true;
|
|
11
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
12
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
16
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
|
+
return Constructor;
|
|
19
|
+
}
|
|
20
|
+
function _define_property(obj, key, value) {
|
|
21
|
+
if (key in obj) {
|
|
22
|
+
Object.defineProperty(obj, key, {
|
|
23
|
+
value: value,
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
obj[key] = value;
|
|
30
|
+
}
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
import { OpenRouterModel } from '../models/openrouter-model.adapter.js';
|
|
34
|
+
/**
|
|
35
|
+
* OpenRouter provider that manages connection configuration
|
|
36
|
+
*/ export var OpenRouterProvider = /*#__PURE__*/ function() {
|
|
37
|
+
"use strict";
|
|
38
|
+
function OpenRouterProvider(config) {
|
|
39
|
+
_class_call_check(this, OpenRouterProvider);
|
|
40
|
+
_define_property(this, "config", void 0);
|
|
41
|
+
this.config = config;
|
|
42
|
+
}
|
|
43
|
+
_create_class(OpenRouterProvider, [
|
|
44
|
+
{
|
|
45
|
+
/**
|
|
46
|
+
* Get a model instance for the specified model name
|
|
47
|
+
*/ key: "getModel",
|
|
48
|
+
value: function getModel(modelName) {
|
|
49
|
+
var modelConfig = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
50
|
+
return new OpenRouterModel(this.config, modelName, modelConfig);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
]);
|
|
54
|
+
return OpenRouterProvider;
|
|
55
|
+
}();
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=openrouter-provider.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/providers/openrouter-provider.adapter.ts"],"sourcesContent":["import type { ModelConfig } from '../../ports/model.port.js';\nimport type { ProviderPort } from '../../ports/provider.port.js';\n\nimport { OpenRouterModel } from '../models/openrouter-model.adapter.js';\n\nexport interface OpenRouterConfig {\n /**\n * OpenRouter API key\n */\n apiKey: string;\n /**\n * Optional metadata for request headers\n */\n metadata?: OpenRouterMetadata;\n}\n\nexport interface OpenRouterMetadata {\n /**\n * Application title for X-Title header\n */\n application?: string;\n /**\n * Website URL for HTTP-Referer header\n */\n website?: string;\n}\n\n/**\n * OpenRouter provider that manages connection configuration\n */\nexport class OpenRouterProvider implements ProviderPort {\n constructor(private readonly config: OpenRouterConfig) {}\n\n /**\n * Get a model instance for the specified model name\n */\n getModel(modelName: string, modelConfig: ModelConfig = {}) {\n return new OpenRouterModel(this.config, modelName, modelConfig);\n }\n}\n"],"names":["OpenRouterModel","OpenRouterProvider","config","getModel","modelName","modelConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAASA,eAAe,QAAQ,wCAAwC;AAwBxE;;CAEC,GACD,OAAO,IAAA,AAAMC,mCAAN;;aAAMA,mBACG,AAAiBC,MAAwB;gCAD5CD;;aACoBC,SAAAA;;kBADpBD;;YAGT;;KAEC,GACDE,KAAAA;mBAAAA,SAAAA,SAASC,SAAiB;oBAAEC,cAAAA,iEAA2B,CAAC;gBACpD,OAAO,IAAIL,gBAAgB,IAAI,CAACE,MAAM,EAAEE,WAAWC;YACvD;;;WARSJ;IASZ"}
|
|
@@ -13,9 +13,9 @@ export type ToolConfig<T = void> = {
|
|
|
13
13
|
};
|
|
14
14
|
export type ToolFunction<T = void> = T extends void ? () => Promise<string> : (args: T) => Promise<string>;
|
|
15
15
|
/**
|
|
16
|
-
* Safe tool
|
|
16
|
+
* Safe tool that provides error handling and logging for LangChain tools
|
|
17
17
|
*/
|
|
18
|
-
export declare class
|
|
18
|
+
export declare class SafeTool<T = void> implements ToolPort {
|
|
19
19
|
private readonly config;
|
|
20
20
|
private readonly options;
|
|
21
21
|
private readonly dynamicTool;
|
|
@@ -159,12 +159,12 @@ function _ts_generator(thisArg, body) {
|
|
|
159
159
|
}
|
|
160
160
|
import { DynamicStructuredTool, DynamicTool } from 'langchain/tools';
|
|
161
161
|
/**
|
|
162
|
-
* Safe tool
|
|
163
|
-
*/ export var
|
|
162
|
+
* Safe tool that provides error handling and logging for LangChain tools
|
|
163
|
+
*/ export var SafeTool = /*#__PURE__*/ function() {
|
|
164
164
|
"use strict";
|
|
165
|
-
function
|
|
165
|
+
function SafeTool(config) {
|
|
166
166
|
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
167
|
-
_class_call_check(this,
|
|
167
|
+
_class_call_check(this, SafeTool);
|
|
168
168
|
_define_property(this, "config", void 0);
|
|
169
169
|
_define_property(this, "options", void 0);
|
|
170
170
|
_define_property(this, "dynamicTool", void 0);
|
|
@@ -267,7 +267,7 @@ import { DynamicStructuredTool, DynamicTool } from 'langchain/tools';
|
|
|
267
267
|
});
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
|
-
_create_class(
|
|
270
|
+
_create_class(SafeTool, [
|
|
271
271
|
{
|
|
272
272
|
/**
|
|
273
273
|
* Get the underlying LangChain DynamicTool instance
|
|
@@ -277,7 +277,7 @@ import { DynamicStructuredTool, DynamicTool } from 'langchain/tools';
|
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
]);
|
|
280
|
-
return
|
|
280
|
+
return SafeTool;
|
|
281
281
|
}();
|
|
282
282
|
|
|
283
283
|
//# sourceMappingURL=safe-tool.adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/tools/safe-tool.adapter.ts"],"sourcesContent":["import type { LoggerPort } from '@jterrazz/logger';\nimport { DynamicStructuredTool, DynamicTool } from 'langchain/tools';\nimport type { z } from 'zod/v4';\n\nimport type { ToolPort } from '../../ports/tool.port.js';\n\nexport interface SafeToolOptions<T> {\n logger?: LoggerPort;\n schema?: z.ZodSchema<T>;\n}\n\nexport type ToolConfig<T = void> = {\n description: string;\n execute: ToolFunction<T>;\n name: string;\n};\n\nexport type ToolFunction<T = void> = T extends void\n ? () => Promise<string>\n : (args: T) => Promise<string>;\n\n/**\n * Safe tool
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/tools/safe-tool.adapter.ts"],"sourcesContent":["import type { LoggerPort } from '@jterrazz/logger';\nimport { DynamicStructuredTool, DynamicTool } from 'langchain/tools';\nimport type { z } from 'zod/v4';\n\nimport type { ToolPort } from '../../ports/tool.port.js';\n\nexport interface SafeToolOptions<T> {\n logger?: LoggerPort;\n schema?: z.ZodSchema<T>;\n}\n\nexport type ToolConfig<T = void> = {\n description: string;\n execute: ToolFunction<T>;\n name: string;\n};\n\nexport type ToolFunction<T = void> = T extends void\n ? () => Promise<string>\n : (args: T) => Promise<string>;\n\n/**\n * Safe tool that provides error handling and logging for LangChain tools\n */\nexport class SafeTool<T = void> implements ToolPort {\n private readonly dynamicTool: DynamicStructuredTool<z.ZodSchema<T>> | DynamicTool;\n\n constructor(\n private readonly config: ToolConfig<T>,\n private readonly options: SafeToolOptions<T> = {},\n ) {\n const { logger, schema } = options;\n\n if (schema) {\n // Use DynamicStructuredTool for parameterized tools\n this.dynamicTool = new DynamicStructuredTool({\n description: config.description,\n func: async (args: T) => {\n try {\n return await (config.execute as ToolFunction<T>)(args);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n\n logger?.error(`Unexpected error in ${config.name}`, {\n args,\n error: errorMessage,\n toolName: config.name,\n });\n\n return `Tool ${config.name} failed to execute`;\n }\n },\n name: config.name,\n schema: schema,\n });\n } else {\n // Use DynamicTool for simple tools\n this.dynamicTool = new DynamicTool({\n description: config.description,\n func: async () => {\n try {\n return await (config.execute as ToolFunction<void>)();\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n\n logger?.error(`Unexpected error in ${config.name}`, {\n error: errorMessage,\n toolName: config.name,\n });\n\n return `Tool ${config.name} failed to execute`;\n }\n },\n name: config.name,\n });\n }\n }\n\n /**\n * Get the underlying LangChain DynamicTool instance\n */\n getDynamicTool(): DynamicStructuredTool<z.ZodSchema<unknown>> | DynamicTool {\n return this.dynamicTool as DynamicStructuredTool<z.ZodSchema<unknown>> | DynamicTool;\n }\n}\n"],"names":["DynamicStructuredTool","DynamicTool","SafeTool","config","options","dynamicTool","logger","schema","description","func","args","error","errorMessage","execute","Error","message","String","name","toolName","getDynamicTool"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAASA,qBAAqB,EAAEC,WAAW,QAAQ,kBAAkB;AAoBrE;;CAEC,GACD,OAAO,IAAA,AAAMC,yBAAN;;aAAMA,SAIL,AAAiBC,MAAqB;YACtC,AAAiBC,UAAjB,iEAA+C,CAAC;gCAL3CF;;;QACT,uBAAiBG,eAAjB,KAAA;aAGqBF,SAAAA;aACAC,UAAAA;QAEjB,IAAQE,SAAmBF,QAAnBE,QAAQC,SAAWH,QAAXG;QAEhB,IAAIA,QAAQ;YACR,oDAAoD;YACpD,IAAI,CAACF,WAAW,GAAG,IAAIL,sBAAsB;gBACzCQ,aAAaL,OAAOK,WAAW;gBAC/BC,MAAM,SAAOC;;4BAGAC,OACCC;;;;;;;;;;oCAFC;;wCAAOT,OAAOU,OAAO,CAAqBH;;;oCAAjD;;wCAAO;;;oCACFC;oCACCC,eAAeD,AAAK,YAALA,OAAiBG,SAAQH,MAAMI,OAAO,GAAGC,OAAOL;oCAErEL,mBAAAA,6BAAAA,OAAQK,KAAK,CAAC,AAAC,uBAAkC,OAAZR,OAAOc,IAAI,GAAI;wCAChDP,MAAAA;wCACAC,OAAOC;wCACPM,UAAUf,OAAOc,IAAI;oCACzB;oCAEA;;wCAAQ,QAAmB,OAAZd,OAAOc,IAAI,EAAC;;;;;;;;oBAEnC;;gBACAA,MAAMd,OAAOc,IAAI;gBACjBV,QAAQA;YACZ;QACJ,OAAO;YACH,mCAAmC;YACnC,IAAI,CAACF,WAAW,GAAG,IAAIJ,YAAY;gBAC/BO,aAAaL,OAAOK,WAAW;gBAC/BC,MAAM;;4BAGOE,OACCC;;;;;;;;;;oCAFC;;wCAAOT,OAAOU,OAAO;;;oCAA5B;;wCAAO;;;oCACFF;oCACCC,eAAeD,AAAK,YAALA,OAAiBG,SAAQH,MAAMI,OAAO,GAAGC,OAAOL;oCAErEL,mBAAAA,6BAAAA,OAAQK,KAAK,CAAC,AAAC,uBAAkC,OAAZR,OAAOc,IAAI,GAAI;wCAChDN,OAAOC;wCACPM,UAAUf,OAAOc,IAAI;oCACzB;oCAEA;;wCAAQ,QAAmB,OAAZd,OAAOc,IAAI,EAAC;;;;;;;;oBAEnC;;gBACAA,MAAMd,OAAOc,IAAI;YACrB;QACJ;;kBAnDKf;;YAsDT;;KAEC,GACDiB,KAAAA;mBAAAA,SAAAA;gBACI,OAAO,IAAI,CAACd,WAAW;YAC3B;;;WA3DSH;IA4DZ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it } from '@jterrazz/test';
|
|
2
2
|
import { z } from 'zod/v4';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { StructuredResponseParser } from '../structured-response-parser.js';
|
|
4
|
+
import { StructuredResponseParserError } from '../structured-response-parser-error.js';
|
|
5
5
|
// Test data
|
|
6
6
|
var testSchema = z.object({
|
|
7
7
|
content: z.string(),
|
|
@@ -17,12 +17,12 @@ var validJson = {
|
|
|
17
17
|
title: 'Test Article'
|
|
18
18
|
};
|
|
19
19
|
var validJsonString = JSON.stringify(validJson);
|
|
20
|
-
describe('
|
|
20
|
+
describe('StructuredResponseParser', function() {
|
|
21
21
|
describe('parse', function() {
|
|
22
22
|
it('should parse valid JSON object', function() {
|
|
23
23
|
// Given - a valid JSON object string and parser
|
|
24
24
|
var text = validJsonString;
|
|
25
|
-
var parser = new
|
|
25
|
+
var parser = new StructuredResponseParser(testSchema);
|
|
26
26
|
// When - parsing the string
|
|
27
27
|
var result = parser.parse(text);
|
|
28
28
|
// Then - it should return the parsed object
|
|
@@ -31,7 +31,7 @@ describe('AIResponseParser', function() {
|
|
|
31
31
|
it('should parse JSON object with surrounding text', function() {
|
|
32
32
|
// Given - a JSON object string with surrounding text and parser
|
|
33
33
|
var text = "Here's the article: ".concat(validJsonString, " - end of article");
|
|
34
|
-
var parser = new
|
|
34
|
+
var parser = new StructuredResponseParser(testSchema);
|
|
35
35
|
// When - parsing the string
|
|
36
36
|
var result = parser.parse(text);
|
|
37
37
|
// Then - it should return the parsed object
|
|
@@ -41,7 +41,7 @@ describe('AIResponseParser', function() {
|
|
|
41
41
|
// Given - a JSON array string and array parser
|
|
42
42
|
var arraySchema = z.array(z.string());
|
|
43
43
|
var text = '["test", "ai", "content"]';
|
|
44
|
-
var parser = new
|
|
44
|
+
var parser = new StructuredResponseParser(arraySchema);
|
|
45
45
|
// When - parsing the string
|
|
46
46
|
var result = parser.parse(text);
|
|
47
47
|
// Then - it should return the parsed array
|
|
@@ -54,7 +54,7 @@ describe('AIResponseParser', function() {
|
|
|
54
54
|
it('should parse primitive string value', function() {
|
|
55
55
|
// Given - a JSON string value and string parser
|
|
56
56
|
var text = '"test string"';
|
|
57
|
-
var parser = new
|
|
57
|
+
var parser = new StructuredResponseParser(z.string());
|
|
58
58
|
// When - parsing the string
|
|
59
59
|
var result = parser.parse(text);
|
|
60
60
|
// Then - it should return the parsed string
|
|
@@ -63,7 +63,7 @@ describe('AIResponseParser', function() {
|
|
|
63
63
|
it('should parse primitive number value', function() {
|
|
64
64
|
// Given - a JSON number value and number parser
|
|
65
65
|
var text = '42';
|
|
66
|
-
var parser = new
|
|
66
|
+
var parser = new StructuredResponseParser(z.number());
|
|
67
67
|
// When - parsing the string
|
|
68
68
|
var result = parser.parse(text);
|
|
69
69
|
// Then - it should return the parsed number
|
|
@@ -72,7 +72,7 @@ describe('AIResponseParser', function() {
|
|
|
72
72
|
it('should parse primitive boolean value', function() {
|
|
73
73
|
// Given - a JSON boolean value and boolean parser
|
|
74
74
|
var text = 'true';
|
|
75
|
-
var parser = new
|
|
75
|
+
var parser = new StructuredResponseParser(z["boolean"]());
|
|
76
76
|
// When - parsing the string
|
|
77
77
|
var result = parser.parse(text);
|
|
78
78
|
// Then - it should return the parsed boolean
|
|
@@ -81,7 +81,7 @@ describe('AIResponseParser', function() {
|
|
|
81
81
|
it('should parse primitive null value', function() {
|
|
82
82
|
// Given - a JSON null value and null parser
|
|
83
83
|
var text = 'null';
|
|
84
|
-
var parser = new
|
|
84
|
+
var parser = new StructuredResponseParser(z["null"]());
|
|
85
85
|
// When - parsing the string
|
|
86
86
|
var result = parser.parse(text);
|
|
87
87
|
// Then - it should return the parsed null
|
|
@@ -90,11 +90,11 @@ describe('AIResponseParser', function() {
|
|
|
90
90
|
it('should throw ResponseParsingError when JSON is invalid', function() {
|
|
91
91
|
// Given - an invalid JSON string and parser
|
|
92
92
|
var text = '{invalid json}';
|
|
93
|
-
var parser = new
|
|
93
|
+
var parser = new StructuredResponseParser(testSchema);
|
|
94
94
|
// When/Then - parsing the string should throw a ResponseParsingError
|
|
95
95
|
expect(function() {
|
|
96
96
|
return parser.parse(text);
|
|
97
|
-
}).toThrow(
|
|
97
|
+
}).toThrow(StructuredResponseParserError);
|
|
98
98
|
});
|
|
99
99
|
it('should throw ResponseParsingError when schema validation fails', function() {
|
|
100
100
|
// Given - an invalid JSON object and parser
|
|
@@ -108,30 +108,30 @@ describe('AIResponseParser', function() {
|
|
|
108
108
|
title: 123
|
|
109
109
|
};
|
|
110
110
|
var text = JSON.stringify(invalidJson);
|
|
111
|
-
var parser = new
|
|
111
|
+
var parser = new StructuredResponseParser(testSchema);
|
|
112
112
|
// When/Then - parsing the string should throw a ResponseParsingError
|
|
113
113
|
expect(function() {
|
|
114
114
|
return parser.parse(text);
|
|
115
|
-
}).toThrow(
|
|
115
|
+
}).toThrow(StructuredResponseParserError);
|
|
116
116
|
});
|
|
117
117
|
it('should throw ResponseParsingError when no object found in text', function() {
|
|
118
118
|
// Given - a text without a JSON object and parser
|
|
119
119
|
var text = 'No JSON object here';
|
|
120
|
-
var parser = new
|
|
120
|
+
var parser = new StructuredResponseParser(testSchema);
|
|
121
121
|
// When/Then - parsing the string should throw a ResponseParsingError
|
|
122
122
|
expect(function() {
|
|
123
123
|
return parser.parse(text);
|
|
124
|
-
}).toThrow(
|
|
124
|
+
}).toThrow(StructuredResponseParserError);
|
|
125
125
|
});
|
|
126
126
|
it('should throw ResponseParsingError when no array found in text', function() {
|
|
127
127
|
// Given - a text without a JSON array and array parser
|
|
128
128
|
var text = 'No array here';
|
|
129
129
|
var arraySchema = z.array(z.string());
|
|
130
|
-
var parser = new
|
|
130
|
+
var parser = new StructuredResponseParser(arraySchema);
|
|
131
131
|
// When/Then - parsing the string should throw a ResponseParsingError
|
|
132
132
|
expect(function() {
|
|
133
133
|
return parser.parse(text);
|
|
134
|
-
}).toThrow(
|
|
134
|
+
}).toThrow(StructuredResponseParserError);
|
|
135
135
|
});
|
|
136
136
|
it('should throw ResponseParsingError for unsupported schema type', function() {
|
|
137
137
|
// Given - a text with an unsupported schema type and parser
|
|
@@ -140,30 +140,30 @@ describe('AIResponseParser', function() {
|
|
|
140
140
|
z.string(),
|
|
141
141
|
z.number()
|
|
142
142
|
]);
|
|
143
|
-
var parser = new
|
|
143
|
+
var parser = new StructuredResponseParser(unsupportedSchema);
|
|
144
144
|
// When/Then - parsing the string should throw a ResponseParsingError
|
|
145
145
|
expect(function() {
|
|
146
146
|
return parser.parse(text);
|
|
147
|
-
}).toThrow(
|
|
147
|
+
}).toThrow(StructuredResponseParserError);
|
|
148
148
|
});
|
|
149
149
|
it('should include original text in error when parsing fails', function() {
|
|
150
150
|
// Given - an invalid JSON string and parser
|
|
151
151
|
var text = '{invalid json}';
|
|
152
|
-
var parser = new
|
|
152
|
+
var parser = new StructuredResponseParser(testSchema);
|
|
153
153
|
// When - parsing the string
|
|
154
154
|
try {
|
|
155
155
|
parser.parse(text);
|
|
156
156
|
throw new Error('Should have thrown an error');
|
|
157
157
|
} catch (error) {
|
|
158
158
|
// Then - the error should include the original text
|
|
159
|
-
expect(error).toBeInstanceOf(
|
|
159
|
+
expect(error).toBeInstanceOf(StructuredResponseParserError);
|
|
160
160
|
expect(error.text).toBe(text);
|
|
161
161
|
}
|
|
162
162
|
});
|
|
163
163
|
it('should handle text with newlines in JSON object', function() {
|
|
164
164
|
// Given - a JSON object with newlines and parser
|
|
165
165
|
var textWithNewlines = '{\n "content": "Test\ncontent\nwith\nnewlines",\n "tags": ["test", "ai"],\n "title": "Test\nArticle"\n }';
|
|
166
|
-
var parser = new
|
|
166
|
+
var parser = new StructuredResponseParser(testSchema);
|
|
167
167
|
// When - parsing the string
|
|
168
168
|
var result = parser.parse(textWithNewlines);
|
|
169
169
|
// Then - it should return the parsed object
|
|
@@ -179,7 +179,7 @@ describe('AIResponseParser', function() {
|
|
|
179
179
|
it('should handle text with newlines in surrounding text', function() {
|
|
180
180
|
// Given - a text with newlines around the JSON object and parser
|
|
181
181
|
var textWithNewlines = "Here's the\narticle:\n".concat(validJsonString, "\n- end of\narticle");
|
|
182
|
-
var parser = new
|
|
182
|
+
var parser = new StructuredResponseParser(testSchema);
|
|
183
183
|
// When - parsing the string
|
|
184
184
|
var result = parser.parse(textWithNewlines);
|
|
185
185
|
// Then - it should return the parsed object
|
|
@@ -188,7 +188,7 @@ describe('AIResponseParser', function() {
|
|
|
188
188
|
it('should handle text with multiple consecutive newlines and spaces', function() {
|
|
189
189
|
// Given - a text with multiple consecutive newlines and spaces and parser
|
|
190
190
|
var textWithNewlines = "Here's the\n\n article: \n\n".concat(validJsonString, "\n\n");
|
|
191
|
-
var parser = new
|
|
191
|
+
var parser = new StructuredResponseParser(testSchema);
|
|
192
192
|
// When - parsing the string
|
|
193
193
|
var result = parser.parse(textWithNewlines);
|
|
194
194
|
// Then - it should return the parsed object
|
|
@@ -197,7 +197,7 @@ describe('AIResponseParser', function() {
|
|
|
197
197
|
it('should handle escaped characters in JSON', function() {
|
|
198
198
|
// Given - a JSON string with escaped characters and parser
|
|
199
199
|
var text = '{"content": "Test\\ncontent\\twith\\r\\nescapes", "tags": ["test\\u0020ai", "escaped\\"quotes\\""], "title": "Test\\\\Article"}';
|
|
200
|
-
var parser = new
|
|
200
|
+
var parser = new StructuredResponseParser(testSchema);
|
|
201
201
|
// When - parsing the string
|
|
202
202
|
var result = parser.parse(text);
|
|
203
203
|
// Then - it should return the parsed object
|
|
@@ -213,7 +213,7 @@ describe('AIResponseParser', function() {
|
|
|
213
213
|
it('should handle escaped characters in markdown code blocks', function() {
|
|
214
214
|
// Given - a markdown code block with escaped characters and parser
|
|
215
215
|
var text = '```json\n{"content": "Test\\nContent", "tags": ["test\\u0020ai"], "title": "Test\\\\Title"}\n```';
|
|
216
|
-
var parser = new
|
|
216
|
+
var parser = new StructuredResponseParser(testSchema);
|
|
217
217
|
// When - parsing the string
|
|
218
218
|
var result = parser.parse(text);
|
|
219
219
|
// Then - it should return the parsed object
|
|
@@ -229,7 +229,7 @@ describe('AIResponseParser', function() {
|
|
|
229
229
|
// Given - a markdown code block with escaped characters and array parser
|
|
230
230
|
var text = '```json\n [\n{"content": "Test\\nContent", "tags": ["test\\u0020ai"], "title": "Test\\\\Title"}\n]\n```';
|
|
231
231
|
var arraySchema = z.array(testSchema);
|
|
232
|
-
var parser = new
|
|
232
|
+
var parser = new StructuredResponseParser(arraySchema);
|
|
233
233
|
// When - parsing the string
|
|
234
234
|
var result = parser.parse(text);
|
|
235
235
|
// Then - it should return the parsed array
|
|
@@ -258,7 +258,7 @@ describe('AIResponseParser', function() {
|
|
|
258
258
|
synopsis: z.string()
|
|
259
259
|
});
|
|
260
260
|
var text = '```json\n{\n "category": "sports",\n "countries": [\n "us"\n ],\n "perspectives": [\n {\n "holisticDigest": "The NBA offseason has seen a massive blockbuster trade as the Phoenix Suns have sent Kevin Durant to the Houston Rockets. The Rockets are acquiring Durant in exchange for Jalen Green, Dillon Brooks, the No. 10 pick in the 2025 NBA draft, and five second-round picks. This move significantly boosts the Rockets\' championship aspirations, positioning them as immediate contenders in the Western Conference alongside established teams. Durant, a future Hall of Famer, is expected to provide elite scoring and shot creation, addressing the Rockets\' previous offensive struggles in the half-court, particularly in the playoffs. Durant\'s decision to list Houston as a preferred destination suggests a potential long-term commitment, with an extension likely upon the opening of the new league year. For the Suns, this trade represents a pivot towards rebuilding, allowing them to acquire young talent and draft assets after their "Big 3" experiment failed to yield a championship. The Suns\' return is viewed by some analysts as lacking compared to Durant\'s caliber, but it does provide them with a reset and a chance to retool around Devin Booker and the draft picks. The specifics of the deal, including Dillon Brooks\' contract and the distribution of second-round picks, have also been highlighted as key elements enabling the trade to go through. The Rockets\' odds to win the NBA title have shortened considerably following the acquisition.",\n "tags": {\n "discourse_type": "mainstream",\n "stance": "neutral"\n }\n }\n ],\n "synopsis": "This collection of articles reports on a major NBA trade where the Phoenix Suns have sent veteran superstar Kevin Durant to the Houston Rockets. The Rockets have acquired Durant in exchange for a package that includes young players Jalen Green and Dillon Brooks, as well as the No. 10 pick in the 2025 NBA draft and five second-round picks. The trade is seen as a significant move that immediately elevates the Rockets into championship contention in the Western Conference. For the Suns, the deal signals a shift towards rebuilding, acquiring young assets and draft capital after their pursuit of a championship with Durant did not come to fruition. Analysis within the articles discusses the potential impact of Durant on the Rockets\' offense and their championship odds, as well as the Suns\' strategy in moving forward after this blockbuster deal. The player himself was reportedly informed of the trade while on stage at an event, offering a brief, somewhat non-committal reaction to the news."\n}\n```';
|
|
261
|
-
var parser = new
|
|
261
|
+
var parser = new StructuredResponseParser(complexSchema);
|
|
262
262
|
// When - parsing the string
|
|
263
263
|
var result = parser.parse(text);
|
|
264
264
|
// Then - it should return the parsed object with escaped quotes properly handled
|
|
@@ -286,4 +286,4 @@ describe('AIResponseParser', function() {
|
|
|
286
286
|
});
|
|
287
287
|
});
|
|
288
288
|
|
|
289
|
-
//# sourceMappingURL=
|
|
289
|
+
//# sourceMappingURL=structured-response-parser.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/adapters/utils/__tests__/structured-response-parser.test.ts"],"sourcesContent":["import { describe, expect, it } from '@jterrazz/test';\nimport { z } from 'zod/v4';\n\nimport { StructuredResponseParser } from '../structured-response-parser.js';\nimport { StructuredResponseParserError } from '../structured-response-parser-error.js';\n\n// Test data\nconst testSchema = z.object({\n content: z.string(),\n tags: z.array(z.string()),\n title: z.string(),\n});\n\nconst validJson = {\n content: 'Test content',\n tags: ['test', 'ai'],\n title: 'Test Article',\n};\n\nconst validJsonString = JSON.stringify(validJson);\n\ndescribe('StructuredResponseParser', () => {\n describe('parse', () => {\n it('should parse valid JSON object', () => {\n // Given - a valid JSON object string and parser\n const text = validJsonString;\n const parser = new StructuredResponseParser(testSchema);\n\n // When - parsing the string\n const result = parser.parse(text);\n\n // Then - it should return the parsed object\n expect(result).toEqual(validJson);\n });\n\n it('should parse JSON object with surrounding text', () => {\n // Given - a JSON object string with surrounding text and parser\n const text = `Here's the article: ${validJsonString} - end of article`;\n const parser = new StructuredResponseParser(testSchema);\n\n // When - parsing the string\n const result = parser.parse(text);\n\n // Then - it should return the parsed object\n expect(result).toEqual(validJson);\n });\n\n it('should parse array response', () => {\n // Given - a JSON array string and array parser\n const arraySchema = z.array(z.string());\n const text = '[\"test\", \"ai\", \"content\"]';\n const parser = new StructuredResponseParser(arraySchema);\n\n // When - parsing the string\n const result = parser.parse(text);\n\n // Then - it should return the parsed array\n expect(result).toEqual(['test', 'ai', 'content']);\n });\n\n it('should parse primitive string value', () => {\n // Given - a JSON string value and string parser\n const text = '\"test string\"';\n const parser = new StructuredResponseParser(z.string());\n\n // When - parsing the string\n const result = parser.parse(text);\n\n // Then - it should return the parsed string\n expect(result).toBe('test string');\n });\n\n it('should parse primitive number value', () => {\n // Given - a JSON number value and number parser\n const text = '42';\n const parser = new StructuredResponseParser(z.number());\n\n // When - parsing the string\n const result = parser.parse(text);\n\n // Then - it should return the parsed number\n expect(result).toBe(42);\n });\n\n it('should parse primitive boolean value', () => {\n // Given - a JSON boolean value and boolean parser\n const text = 'true';\n const parser = new StructuredResponseParser(z.boolean());\n\n // When - parsing the string\n const result = parser.parse(text);\n\n // Then - it should return the parsed boolean\n expect(result).toBe(true);\n });\n\n it('should parse primitive null value', () => {\n // Given - a JSON null value and null parser\n const text = 'null';\n const parser = new StructuredResponseParser(z.null());\n\n // When - parsing the string\n const result = parser.parse(text);\n\n // Then - it should return the parsed null\n expect(result).toBeNull();\n });\n\n it('should throw ResponseParsingError when JSON is invalid', () => {\n // Given - an invalid JSON string and parser\n const text = '{invalid json}';\n const parser = new StructuredResponseParser(testSchema);\n\n // When/Then - parsing the string should throw a ResponseParsingError\n expect(() => parser.parse(text)).toThrow(StructuredResponseParserError);\n });\n\n it('should throw ResponseParsingError when schema validation fails', () => {\n // Given - an invalid JSON object and parser\n const invalidJson = {\n // Should be string\n content: 'Test content',\n tags: ['test', 'ai'],\n title: 123,\n };\n const text = JSON.stringify(invalidJson);\n const parser = new StructuredResponseParser(testSchema);\n\n // When/Then - parsing the string should throw a ResponseParsingError\n expect(() => parser.parse(text)).toThrow(StructuredResponseParserError);\n });\n\n it('should throw ResponseParsingError when no object found in text', () => {\n // Given - a text without a JSON object and parser\n const text = 'No JSON object here';\n const parser = new StructuredResponseParser(testSchema);\n\n // When/Then - parsing the string should throw a ResponseParsingError\n expect(() => parser.parse(text)).toThrow(StructuredResponseParserError);\n });\n\n it('should throw ResponseParsingError when no array found in text', () => {\n // Given - a text without a JSON array and array parser\n const text = 'No array here';\n const arraySchema = z.array(z.string());\n const parser = new StructuredResponseParser(arraySchema);\n\n // When/Then - parsing the string should throw a ResponseParsingError\n expect(() => parser.parse(text)).toThrow(StructuredResponseParserError);\n });\n\n it('should throw ResponseParsingError for unsupported schema type', () => {\n // Given - a text with an unsupported schema type and parser\n const text = 'test';\n const unsupportedSchema = z.union([z.string(), z.number()]);\n const parser = new StructuredResponseParser(unsupportedSchema);\n\n // When/Then - parsing the string should throw a ResponseParsingError\n expect(() => parser.parse(text)).toThrow(StructuredResponseParserError);\n });\n\n it('should include original text in error when parsing fails', () => {\n // Given - an invalid JSON string and parser\n const text = '{invalid json}';\n const parser = new StructuredResponseParser(testSchema);\n\n // When - parsing the string\n try {\n parser.parse(text);\n throw new Error('Should have thrown an error');\n } catch (error) {\n // Then - the error should include the original text\n expect(error).toBeInstanceOf(StructuredResponseParserError);\n expect((error as StructuredResponseParserError).text).toBe(text);\n }\n });\n\n it('should handle text with newlines in JSON object', () => {\n // Given - a JSON object with newlines and parser\n const textWithNewlines = `{\n \"content\": \"Test\\ncontent\\nwith\\nnewlines\",\n \"tags\": [\"test\", \"ai\"],\n \"title\": \"Test\\nArticle\"\n }`;\n const parser = new StructuredResponseParser(testSchema);\n\n // When - parsing the string\n const result = parser.parse(textWithNewlines);\n\n // Then - it should return the parsed object\n expect(result).toEqual({\n content: 'Test content with newlines',\n tags: ['test', 'ai'],\n title: 'Test Article',\n });\n });\n\n it('should handle text with newlines in surrounding text', () => {\n // Given - a text with newlines around the JSON object and parser\n const textWithNewlines = `Here's the\\narticle:\\n${validJsonString}\\n- end of\\narticle`;\n const parser = new StructuredResponseParser(testSchema);\n\n // When - parsing the string\n const result = parser.parse(textWithNewlines);\n\n // Then - it should return the parsed object\n expect(result).toEqual(validJson);\n });\n\n it('should handle text with multiple consecutive newlines and spaces', () => {\n // Given - a text with multiple consecutive newlines and spaces and parser\n const textWithNewlines = `Here's the\\n\\n article: \\n\\n${validJsonString}\\n\\n`;\n const parser = new StructuredResponseParser(testSchema);\n\n // When - parsing the string\n const result = parser.parse(textWithNewlines);\n\n // Then - it should return the parsed object\n expect(result).toEqual(validJson);\n });\n\n it('should handle escaped characters in JSON', () => {\n // Given - a JSON string with escaped characters and parser\n const text =\n '{\"content\": \"Test\\\\ncontent\\\\twith\\\\r\\\\nescapes\", \"tags\": [\"test\\\\u0020ai\", \"escaped\\\\\"quotes\\\\\"\"], \"title\": \"Test\\\\\\\\Article\"}';\n const parser = new StructuredResponseParser(testSchema);\n\n // When - parsing the string\n const result = parser.parse(text);\n\n // Then - it should return the parsed object\n expect(result).toEqual({\n content: 'Test\\ncontent\\twith\\r\\nescapes',\n tags: ['test ai', 'escaped\"quotes\"'],\n title: 'Test\\\\Article',\n });\n });\n\n it('should handle escaped characters in markdown code blocks', () => {\n // Given - a markdown code block with escaped characters and parser\n const text =\n '```json\\n{\"content\": \"Test\\\\nContent\", \"tags\": [\"test\\\\u0020ai\"], \"title\": \"Test\\\\\\\\Title\"}\\n```';\n const parser = new StructuredResponseParser(testSchema);\n\n // When - parsing the string\n const result = parser.parse(text);\n\n // Then - it should return the parsed object\n expect(result).toEqual({\n content: 'Test\\nContent',\n tags: ['test ai'],\n title: 'Test\\\\Title',\n });\n });\n\n it('should handle escaped characters in markdown code blocks', () => {\n // Given - a markdown code block with escaped characters and array parser\n const text =\n '```json\\n [\\n{\"content\": \"Test\\\\nContent\", \"tags\": [\"test\\\\u0020ai\"], \"title\": \"Test\\\\\\\\Title\"}\\n]\\n```';\n const arraySchema = z.array(testSchema);\n const parser = new StructuredResponseParser(arraySchema);\n\n // When - parsing the string\n const result = parser.parse(text);\n\n // Then - it should return the parsed array\n expect(result).toEqual([\n {\n content: 'Test\\nContent',\n tags: ['test ai'],\n title: 'Test\\\\Title',\n },\n ]);\n });\n\n it('should parse complex NBA trade analysis JSON with escaped quotes', () => {\n // Given - a complex JSON object with nested structures and escaped quotes in markdown\n const complexSchema = z.object({\n category: z.string(),\n countries: z.array(z.string()),\n perspectives: z.array(\n z.object({\n holisticDigest: z.string(),\n tags: z.object({\n discourse_type: z.string(),\n stance: z.string(),\n }),\n }),\n ),\n synopsis: z.string(),\n });\n\n const text =\n '```json\\n{\\n \"category\": \"sports\",\\n \"countries\": [\\n \"us\"\\n ],\\n \"perspectives\": [\\n {\\n \"holisticDigest\": \"The NBA offseason has seen a massive blockbuster trade as the Phoenix Suns have sent Kevin Durant to the Houston Rockets. The Rockets are acquiring Durant in exchange for Jalen Green, Dillon Brooks, the No. 10 pick in the 2025 NBA draft, and five second-round picks. This move significantly boosts the Rockets\\' championship aspirations, positioning them as immediate contenders in the Western Conference alongside established teams. Durant, a future Hall of Famer, is expected to provide elite scoring and shot creation, addressing the Rockets\\' previous offensive struggles in the half-court, particularly in the playoffs. Durant\\'s decision to list Houston as a preferred destination suggests a potential long-term commitment, with an extension likely upon the opening of the new league year. For the Suns, this trade represents a pivot towards rebuilding, allowing them to acquire young talent and draft assets after their \"Big 3\" experiment failed to yield a championship. The Suns\\' return is viewed by some analysts as lacking compared to Durant\\'s caliber, but it does provide them with a reset and a chance to retool around Devin Booker and the draft picks. The specifics of the deal, including Dillon Brooks\\' contract and the distribution of second-round picks, have also been highlighted as key elements enabling the trade to go through. The Rockets\\' odds to win the NBA title have shortened considerably following the acquisition.\",\\n \"tags\": {\\n \"discourse_type\": \"mainstream\",\\n \"stance\": \"neutral\"\\n }\\n }\\n ],\\n \"synopsis\": \"This collection of articles reports on a major NBA trade where the Phoenix Suns have sent veteran superstar Kevin Durant to the Houston Rockets. The Rockets have acquired Durant in exchange for a package that includes young players Jalen Green and Dillon Brooks, as well as the No. 10 pick in the 2025 NBA draft and five second-round picks. The trade is seen as a significant move that immediately elevates the Rockets into championship contention in the Western Conference. For the Suns, the deal signals a shift towards rebuilding, acquiring young assets and draft capital after their pursuit of a championship with Durant did not come to fruition. Analysis within the articles discusses the potential impact of Durant on the Rockets\\' offense and their championship odds, as well as the Suns\\' strategy in moving forward after this blockbuster deal. The player himself was reportedly informed of the trade while on stage at an event, offering a brief, somewhat non-committal reaction to the news.\"\\n}\\n```';\n\n const parser = new StructuredResponseParser(complexSchema);\n\n // When - parsing the string\n const result = parser.parse(text);\n\n // Then - it should return the parsed object with escaped quotes properly handled\n expect(result).toEqual({\n category: 'sports',\n countries: ['us'],\n perspectives: [\n {\n holisticDigest: expect.stringContaining(\n 'The NBA offseason has seen a massive blockbuster trade',\n ),\n tags: {\n discourse_type: 'mainstream',\n stance: 'neutral',\n },\n },\n ],\n synopsis: expect.stringContaining(\n 'This collection of articles reports on a major NBA trade',\n ),\n });\n\n // Additional verification for escaped quotes handling\n expect(result.perspectives[0].holisticDigest).toContain('\"Big 3\" experiment');\n expect(result.perspectives[0].holisticDigest).toContain(\n \"Rockets' championship aspirations\",\n );\n expect(result.perspectives[0].holisticDigest).toContain(\"Durant's decision\");\n });\n });\n});\n"],"names":["describe","expect","it","z","StructuredResponseParser","StructuredResponseParserError","testSchema","object","content","string","tags","array","title","validJson","validJsonString","JSON","stringify","text","parser","result","parse","toEqual","arraySchema","toBe","number","boolean","null","toBeNull","toThrow","invalidJson","unsupportedSchema","union","Error","error","toBeInstanceOf","textWithNewlines","complexSchema","category","countries","perspectives","holisticDigest","discourse_type","stance","synopsis","stringContaining","toContain"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,iBAAiB;AACtD,SAASC,CAAC,QAAQ,SAAS;AAE3B,SAASC,wBAAwB,QAAQ,mCAAmC;AAC5E,SAASC,6BAA6B,QAAQ,yCAAyC;AAEvF,YAAY;AACZ,IAAMC,aAAaH,EAAEI,MAAM,CAAC;IACxBC,SAASL,EAAEM,MAAM;IACjBC,MAAMP,EAAEQ,KAAK,CAACR,EAAEM,MAAM;IACtBG,OAAOT,EAAEM,MAAM;AACnB;AAEA,IAAMI,YAAY;IACdL,SAAS;IACTE,MAAM;QAAC;QAAQ;KAAK;IACpBE,OAAO;AACX;AAEA,IAAME,kBAAkBC,KAAKC,SAAS,CAACH;AAEvCb,SAAS,4BAA4B;IACjCA,SAAS,SAAS;QACdE,GAAG,kCAAkC;YACjC,gDAAgD;YAChD,IAAMe,OAAOH;YACb,IAAMI,SAAS,IAAId,yBAAyBE;YAE5C,4BAA4B;YAC5B,IAAMa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EM,MAAM;wBACxBiC,QAAQvC,EAAEM,MAAM;oBACpB;gBACJ;gBAEJkC,UAAUxC,EAAEM,MAAM;YACtB;YAEA,IAAMQ,OACF;YAEJ,IAAMC,SAAS,IAAId,yBAAyBgC;YAE5C,4BAA4B;YAC5B,IAAMjB,SAASD,OAAOE,KAAK,CAACH;YAE5B,iFAAiF;YACjFhB,OAAOkB,QAAQE,OAAO,CAAC;gBACnBgB,UAAU;gBACVC,WAAW;oBAAC;iBAAK;gBACjBC,cAAc;oBACV;wBACIC,gBAAgBvC,OAAO2C,gBAAgB,CACnC;wBAEJlC,MAAM;4BACF+B,gBAAgB;4BAChBC,QAAQ;wBACZ;oBACJ;iBACH;gBACDC,UAAU1C,OAAO2C,gBAAgB,CAC7B;YAER;YAEA,sDAAsD;YACtD3C,OAAOkB,OAAOoB,YAAY,CAAC,EAAE,CAACC,cAAc,EAAEK,SAAS,CAAC;YACxD5C,OAAOkB,OAAOoB,YAAY,CAAC,EAAE,CAACC,cAAc,EAAEK,SAAS,CACnD;YAEJ5C,OAAOkB,OAAOoB,YAAY,CAAC,EAAE,CAACC,cAAc,EAAEK,SAAS,CAAC;QAC5D;IACJ;AACJ"}
|
package/dist/adapters/utils/{ai-response-parser-error.d.ts → structured-response-parser-error.d.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Custom error for
|
|
2
|
+
* Custom error for structured response parsing failures
|
|
3
3
|
*/
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class StructuredResponseParserError extends Error {
|
|
5
5
|
readonly cause?: unknown | undefined;
|
|
6
6
|
readonly text?: string | undefined;
|
|
7
7
|
constructor(message: string, cause?: unknown | undefined, text?: string | undefined);
|
package/dist/adapters/utils/{ai-response-parser-error.js → structured-response-parser-error.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Custom error for
|
|
2
|
+
* Custom error for structured response parsing failures
|
|
3
3
|
*/ function _assert_this_initialized(self) {
|
|
4
4
|
if (self === void 0) {
|
|
5
5
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
@@ -118,19 +118,19 @@ function _is_native_reflect_construct() {
|
|
|
118
118
|
return !!result;
|
|
119
119
|
})();
|
|
120
120
|
}
|
|
121
|
-
export var
|
|
121
|
+
export var StructuredResponseParserError = /*#__PURE__*/ function(Error1) {
|
|
122
122
|
"use strict";
|
|
123
|
-
_inherits(
|
|
124
|
-
function
|
|
125
|
-
_class_call_check(this,
|
|
123
|
+
_inherits(StructuredResponseParserError, Error1);
|
|
124
|
+
function StructuredResponseParserError(message, cause, text) {
|
|
125
|
+
_class_call_check(this, StructuredResponseParserError);
|
|
126
126
|
var _this;
|
|
127
|
-
_this = _call_super(this,
|
|
127
|
+
_this = _call_super(this, StructuredResponseParserError, [
|
|
128
128
|
message
|
|
129
129
|
]), _define_property(_this, "cause", void 0), _define_property(_this, "text", void 0), _this.cause = cause, _this.text = text;
|
|
130
|
-
_this.name = '
|
|
130
|
+
_this.name = 'StructuredResponseParserError';
|
|
131
131
|
return _this;
|
|
132
132
|
}
|
|
133
|
-
return
|
|
133
|
+
return StructuredResponseParserError;
|
|
134
134
|
}(_wrap_native_super(Error));
|
|
135
135
|
|
|
136
|
-
//# sourceMappingURL=
|
|
136
|
+
//# sourceMappingURL=structured-response-parser-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/utils/structured-response-parser-error.ts"],"sourcesContent":["/**\n * Custom error for structured response parsing failures\n */\nexport class StructuredResponseParserError extends Error {\n constructor(\n message: string,\n public readonly cause?: unknown,\n public readonly text?: string,\n ) {\n super(message);\n this.name = 'StructuredResponseParserError';\n }\n}\n"],"names":["StructuredResponseParserError","message","cause","text","name","Error"],"mappings":"AAAA;;CAEC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACD,OAAO,IAAA,AAAMA,8CAAN;;cAAMA;aAAAA,8BAELC,OAAe,EACf,AAAgBC,KAAe,EAC/B,AAAgBC,IAAa;gCAJxBH;;gBAML,kBANKA;YAMCC;qGAHUC,QAAAA,aACAC,OAAAA;QAGhB,MAAKC,IAAI,GAAG;;;WAPPJ;qBAAsCK,QASlD"}
|
|
@@ -2,7 +2,7 @@ import { z } from 'zod/v4';
|
|
|
2
2
|
/**
|
|
3
3
|
* Parses AI response text into structured data based on Zod schema
|
|
4
4
|
*/
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class StructuredResponseParser<T> {
|
|
6
6
|
private readonly schema;
|
|
7
7
|
constructor(schema: z.ZodSchema<T>);
|
|
8
8
|
/**
|