@chanl/scenarios-core 0.4.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/LICENSE +21 -0
- package/dist/__tests__/e2e/test-helpers.d.ts +79 -0
- package/dist/__tests__/e2e/test-helpers.d.ts.map +1 -0
- package/dist/__tests__/e2e/test-helpers.js +162 -0
- package/dist/__tests__/e2e/test-helpers.js.map +1 -0
- package/dist/adapters/adapter-registry.d.ts +14 -0
- package/dist/adapters/adapter-registry.d.ts.map +1 -0
- package/dist/adapters/adapter-registry.js +53 -0
- package/dist/adapters/adapter-registry.js.map +1 -0
- package/dist/adapters/agent-adapter.interface.d.ts +70 -0
- package/dist/adapters/agent-adapter.interface.d.ts.map +1 -0
- package/dist/adapters/agent-adapter.interface.js +3 -0
- package/dist/adapters/agent-adapter.interface.js.map +1 -0
- package/dist/adapters/anthropic.adapter.d.ts +17 -0
- package/dist/adapters/anthropic.adapter.d.ts.map +1 -0
- package/dist/adapters/anthropic.adapter.js +145 -0
- package/dist/adapters/anthropic.adapter.js.map +1 -0
- package/dist/adapters/http.adapter.d.ts +17 -0
- package/dist/adapters/http.adapter.d.ts.map +1 -0
- package/dist/adapters/http.adapter.js +95 -0
- package/dist/adapters/http.adapter.js.map +1 -0
- package/dist/adapters/index.d.ts +6 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +22 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/openai.adapter.d.ts +17 -0
- package/dist/adapters/openai.adapter.d.ts.map +1 -0
- package/dist/adapters/openai.adapter.js +133 -0
- package/dist/adapters/openai.adapter.js.map +1 -0
- package/dist/dataset/convert.d.ts +28 -0
- package/dist/dataset/convert.d.ts.map +1 -0
- package/dist/dataset/convert.js +94 -0
- package/dist/dataset/convert.js.map +1 -0
- package/dist/dataset/formats/dpo.d.ts +41 -0
- package/dist/dataset/formats/dpo.d.ts.map +1 -0
- package/dist/dataset/formats/dpo.js +79 -0
- package/dist/dataset/formats/dpo.js.map +1 -0
- package/dist/dataset/formats/index.d.ts +4 -0
- package/dist/dataset/formats/index.d.ts.map +1 -0
- package/dist/dataset/formats/index.js +13 -0
- package/dist/dataset/formats/index.js.map +1 -0
- package/dist/dataset/formats/openai.d.ts +29 -0
- package/dist/dataset/formats/openai.d.ts.map +1 -0
- package/dist/dataset/formats/openai.js +98 -0
- package/dist/dataset/formats/openai.js.map +1 -0
- package/dist/dataset/formats/sharegpt.d.ts +31 -0
- package/dist/dataset/formats/sharegpt.d.ts.map +1 -0
- package/dist/dataset/formats/sharegpt.js +76 -0
- package/dist/dataset/formats/sharegpt.js.map +1 -0
- package/dist/dataset/index.d.ts +4 -0
- package/dist/dataset/index.d.ts.map +1 -0
- package/dist/dataset/index.js +20 -0
- package/dist/dataset/index.js.map +1 -0
- package/dist/dataset/types.d.ts +108 -0
- package/dist/dataset/types.d.ts.map +1 -0
- package/dist/dataset/types.js +7 -0
- package/dist/dataset/types.js.map +1 -0
- package/dist/execution/agent-config-resolver.d.ts +44 -0
- package/dist/execution/agent-config-resolver.d.ts.map +1 -0
- package/dist/execution/agent-config-resolver.js +76 -0
- package/dist/execution/agent-config-resolver.js.map +1 -0
- package/dist/execution/execution-processor.d.ts +75 -0
- package/dist/execution/execution-processor.d.ts.map +1 -0
- package/dist/execution/execution-processor.js +569 -0
- package/dist/execution/execution-processor.js.map +1 -0
- package/dist/execution/execution.module.d.ts +3 -0
- package/dist/execution/execution.module.d.ts.map +1 -0
- package/dist/execution/execution.module.js +56 -0
- package/dist/execution/execution.module.js.map +1 -0
- package/dist/execution/execution.service.d.ts +52 -0
- package/dist/execution/execution.service.d.ts.map +1 -0
- package/dist/execution/execution.service.js +182 -0
- package/dist/execution/execution.service.js.map +1 -0
- package/dist/execution/index.d.ts +11 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +30 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/interfaces/job-data.interface.d.ts +38 -0
- package/dist/execution/interfaces/job-data.interface.d.ts.map +1 -0
- package/dist/execution/interfaces/job-data.interface.js +3 -0
- package/dist/execution/interfaces/job-data.interface.js.map +1 -0
- package/dist/execution/judge-llm.d.ts +35 -0
- package/dist/execution/judge-llm.d.ts.map +1 -0
- package/dist/execution/judge-llm.js +129 -0
- package/dist/execution/judge-llm.js.map +1 -0
- package/dist/execution/llm-config-resolver.d.ts +26 -0
- package/dist/execution/llm-config-resolver.d.ts.map +1 -0
- package/dist/execution/llm-config-resolver.js +99 -0
- package/dist/execution/llm-config-resolver.js.map +1 -0
- package/dist/execution/persona-llm.d.ts +29 -0
- package/dist/execution/persona-llm.d.ts.map +1 -0
- package/dist/execution/persona-llm.js +98 -0
- package/dist/execution/persona-llm.js.map +1 -0
- package/dist/execution/persona-strategy-registry.d.ts +14 -0
- package/dist/execution/persona-strategy-registry.d.ts.map +1 -0
- package/dist/execution/persona-strategy-registry.js +51 -0
- package/dist/execution/persona-strategy-registry.js.map +1 -0
- package/dist/execution/persona-strategy.interface.d.ts +88 -0
- package/dist/execution/persona-strategy.interface.d.ts.map +1 -0
- package/dist/execution/persona-strategy.interface.js +3 -0
- package/dist/execution/persona-strategy.interface.js.map +1 -0
- package/dist/execution/queue-producer.service.d.ts +21 -0
- package/dist/execution/queue-producer.service.d.ts.map +1 -0
- package/dist/execution/queue-producer.service.js +60 -0
- package/dist/execution/queue-producer.service.js.map +1 -0
- package/dist/execution/queues.config.d.ts +39 -0
- package/dist/execution/queues.config.d.ts.map +1 -0
- package/dist/execution/queues.config.js +43 -0
- package/dist/execution/queues.config.js.map +1 -0
- package/dist/execution/strategies/default.strategy.d.ts +11 -0
- package/dist/execution/strategies/default.strategy.d.ts.map +1 -0
- package/dist/execution/strategies/default.strategy.js +31 -0
- package/dist/execution/strategies/default.strategy.js.map +1 -0
- package/dist/execution/strategies/reactive.strategy.d.ts +28 -0
- package/dist/execution/strategies/reactive.strategy.d.ts.map +1 -0
- package/dist/execution/strategies/reactive.strategy.js +220 -0
- package/dist/execution/strategies/reactive.strategy.js.map +1 -0
- package/dist/execution/template-renderer.d.ts +52 -0
- package/dist/execution/template-renderer.d.ts.map +1 -0
- package/dist/execution/template-renderer.js +90 -0
- package/dist/execution/template-renderer.js.map +1 -0
- package/dist/generation/index.d.ts +2 -0
- package/dist/generation/index.d.ts.map +1 -0
- package/dist/generation/index.js +6 -0
- package/dist/generation/index.js.map +1 -0
- package/dist/generation/scenario-generator.service.d.ts +77 -0
- package/dist/generation/scenario-generator.service.d.ts.map +1 -0
- package/dist/generation/scenario-generator.service.js +272 -0
- package/dist/generation/scenario-generator.service.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/personas/dto/create-persona.dto.d.ts +61 -0
- package/dist/personas/dto/create-persona.dto.d.ts.map +1 -0
- package/dist/personas/dto/create-persona.dto.js +146 -0
- package/dist/personas/dto/create-persona.dto.js.map +1 -0
- package/dist/personas/dto/index.d.ts +3 -0
- package/dist/personas/dto/index.d.ts.map +1 -0
- package/dist/personas/dto/index.js +19 -0
- package/dist/personas/dto/index.js.map +1 -0
- package/dist/personas/dto/update-persona.dto.d.ts +8 -0
- package/dist/personas/dto/update-persona.dto.d.ts.map +1 -0
- package/dist/personas/dto/update-persona.dto.js +29 -0
- package/dist/personas/dto/update-persona.dto.js.map +1 -0
- package/dist/personas/index.d.ts +6 -0
- package/dist/personas/index.d.ts.map +1 -0
- package/dist/personas/index.js +22 -0
- package/dist/personas/index.js.map +1 -0
- package/dist/personas/persona.controller.d.ts +69 -0
- package/dist/personas/persona.controller.d.ts.map +1 -0
- package/dist/personas/persona.controller.js +282 -0
- package/dist/personas/persona.controller.js.map +1 -0
- package/dist/personas/persona.module.d.ts +3 -0
- package/dist/personas/persona.module.d.ts.map +1 -0
- package/dist/personas/persona.module.js +28 -0
- package/dist/personas/persona.module.js.map +1 -0
- package/dist/personas/persona.service.d.ts +85 -0
- package/dist/personas/persona.service.d.ts.map +1 -0
- package/dist/personas/persona.service.js +382 -0
- package/dist/personas/persona.service.js.map +1 -0
- package/dist/personas/schemas/persona.schema.d.ts +90 -0
- package/dist/personas/schemas/persona.schema.d.ts.map +1 -0
- package/dist/personas/schemas/persona.schema.js +321 -0
- package/dist/personas/schemas/persona.schema.js.map +1 -0
- package/dist/scenarios/controllers/scenario-execution.controller.d.ts +48 -0
- package/dist/scenarios/controllers/scenario-execution.controller.d.ts.map +1 -0
- package/dist/scenarios/controllers/scenario-execution.controller.js +260 -0
- package/dist/scenarios/controllers/scenario-execution.controller.js.map +1 -0
- package/dist/scenarios/controllers/scenario.controller.d.ts +81 -0
- package/dist/scenarios/controllers/scenario.controller.d.ts.map +1 -0
- package/dist/scenarios/controllers/scenario.controller.js +345 -0
- package/dist/scenarios/controllers/scenario.controller.js.map +1 -0
- package/dist/scenarios/dto/create-scenario.dto.d.ts +31 -0
- package/dist/scenarios/dto/create-scenario.dto.d.ts.map +1 -0
- package/dist/scenarios/dto/create-scenario.dto.js +102 -0
- package/dist/scenarios/dto/create-scenario.dto.js.map +1 -0
- package/dist/scenarios/dto/execute-scenario.dto.d.ts +34 -0
- package/dist/scenarios/dto/execute-scenario.dto.d.ts.map +1 -0
- package/dist/scenarios/dto/execute-scenario.dto.js +150 -0
- package/dist/scenarios/dto/execute-scenario.dto.js.map +1 -0
- package/dist/scenarios/dto/index.d.ts +4 -0
- package/dist/scenarios/dto/index.d.ts.map +1 -0
- package/dist/scenarios/dto/index.js +20 -0
- package/dist/scenarios/dto/index.js.map +1 -0
- package/dist/scenarios/dto/update-scenario.dto.d.ts +6 -0
- package/dist/scenarios/dto/update-scenario.dto.d.ts.map +1 -0
- package/dist/scenarios/dto/update-scenario.dto.js +9 -0
- package/dist/scenarios/dto/update-scenario.dto.js.map +1 -0
- package/dist/scenarios/index.d.ts +9 -0
- package/dist/scenarios/index.d.ts.map +1 -0
- package/dist/scenarios/index.js +25 -0
- package/dist/scenarios/index.js.map +1 -0
- package/dist/scenarios/scenario.module.d.ts +3 -0
- package/dist/scenarios/scenario.module.d.ts.map +1 -0
- package/dist/scenarios/scenario.module.js +42 -0
- package/dist/scenarios/scenario.module.js.map +1 -0
- package/dist/scenarios/schemas/scenario-execution.schema.d.ts +133 -0
- package/dist/scenarios/schemas/scenario-execution.schema.d.ts.map +1 -0
- package/dist/scenarios/schemas/scenario-execution.schema.js +292 -0
- package/dist/scenarios/schemas/scenario-execution.schema.js.map +1 -0
- package/dist/scenarios/schemas/scenario.schema.d.ts +106 -0
- package/dist/scenarios/schemas/scenario.schema.d.ts.map +1 -0
- package/dist/scenarios/schemas/scenario.schema.js +205 -0
- package/dist/scenarios/schemas/scenario.schema.js.map +1 -0
- package/dist/scenarios/services/scenario-execution.service.d.ts +73 -0
- package/dist/scenarios/services/scenario-execution.service.d.ts.map +1 -0
- package/dist/scenarios/services/scenario-execution.service.js +505 -0
- package/dist/scenarios/services/scenario-execution.service.js.map +1 -0
- package/dist/scenarios/services/scenario.service.d.ts +110 -0
- package/dist/scenarios/services/scenario.service.d.ts.map +1 -0
- package/dist/scenarios/services/scenario.service.js +608 -0
- package/dist/scenarios/services/scenario.service.js.map +1 -0
- package/dist/simulator/index.d.ts +2 -0
- package/dist/simulator/index.d.ts.map +1 -0
- package/dist/simulator/index.js +18 -0
- package/dist/simulator/index.js.map +1 -0
- package/dist/simulator/persona-simulator.service.d.ts +81 -0
- package/dist/simulator/persona-simulator.service.d.ts.map +1 -0
- package/dist/simulator/persona-simulator.service.js +358 -0
- package/dist/simulator/persona-simulator.service.js.map +1 -0
- package/dist/templates/dto/create-template.dto.d.ts +16 -0
- package/dist/templates/dto/create-template.dto.d.ts.map +1 -0
- package/dist/templates/dto/create-template.dto.js +75 -0
- package/dist/templates/dto/create-template.dto.js.map +1 -0
- package/dist/templates/dto/index.d.ts +4 -0
- package/dist/templates/dto/index.d.ts.map +1 -0
- package/dist/templates/dto/index.js +10 -0
- package/dist/templates/dto/index.js.map +1 -0
- package/dist/templates/dto/instantiate-template.dto.d.ts +7 -0
- package/dist/templates/dto/instantiate-template.dto.d.ts.map +1 -0
- package/dist/templates/dto/instantiate-template.dto.js +38 -0
- package/dist/templates/dto/instantiate-template.dto.js.map +1 -0
- package/dist/templates/dto/update-template.dto.d.ts +6 -0
- package/dist/templates/dto/update-template.dto.d.ts.map +1 -0
- package/dist/templates/dto/update-template.dto.js +9 -0
- package/dist/templates/dto/update-template.dto.js.map +1 -0
- package/dist/templates/index.d.ts +6 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +22 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/scenario-template.controller.d.ts +42 -0
- package/dist/templates/scenario-template.controller.d.ts.map +1 -0
- package/dist/templates/scenario-template.controller.js +148 -0
- package/dist/templates/scenario-template.controller.js.map +1 -0
- package/dist/templates/scenario-template.module.d.ts +3 -0
- package/dist/templates/scenario-template.module.d.ts.map +1 -0
- package/dist/templates/scenario-template.module.js +30 -0
- package/dist/templates/scenario-template.module.js.map +1 -0
- package/dist/templates/scenario-template.service.d.ts +50 -0
- package/dist/templates/scenario-template.service.d.ts.map +1 -0
- package/dist/templates/scenario-template.service.js +497 -0
- package/dist/templates/scenario-template.service.js.map +1 -0
- package/dist/templates/schemas/scenario-template.schema.d.ts +59 -0
- package/dist/templates/schemas/scenario-template.schema.d.ts.map +1 -0
- package/dist/templates/schemas/scenario-template.schema.js +132 -0
- package/dist/templates/schemas/scenario-template.schema.js.map +1 -0
- package/dist/tool-fixtures/dto/create-tool-fixture.dto.d.ts +18 -0
- package/dist/tool-fixtures/dto/create-tool-fixture.dto.d.ts.map +1 -0
- package/dist/tool-fixtures/dto/create-tool-fixture.dto.js +46 -0
- package/dist/tool-fixtures/dto/create-tool-fixture.dto.js.map +1 -0
- package/dist/tool-fixtures/dto/index.d.ts +4 -0
- package/dist/tool-fixtures/dto/index.d.ts.map +1 -0
- package/dist/tool-fixtures/dto/index.js +20 -0
- package/dist/tool-fixtures/dto/index.js.map +1 -0
- package/dist/tool-fixtures/dto/tool-fixture-filter.dto.d.ts +6 -0
- package/dist/tool-fixtures/dto/tool-fixture-filter.dto.d.ts.map +1 -0
- package/dist/tool-fixtures/dto/tool-fixture-filter.dto.js +33 -0
- package/dist/tool-fixtures/dto/tool-fixture-filter.dto.js.map +1 -0
- package/dist/tool-fixtures/dto/update-tool-fixture.dto.d.ts +6 -0
- package/dist/tool-fixtures/dto/update-tool-fixture.dto.d.ts.map +1 -0
- package/dist/tool-fixtures/dto/update-tool-fixture.dto.js +9 -0
- package/dist/tool-fixtures/dto/update-tool-fixture.dto.js.map +1 -0
- package/dist/tool-fixtures/index.d.ts +7 -0
- package/dist/tool-fixtures/index.d.ts.map +1 -0
- package/dist/tool-fixtures/index.js +23 -0
- package/dist/tool-fixtures/index.js.map +1 -0
- package/dist/tool-fixtures/mock-resolver.service.d.ts +48 -0
- package/dist/tool-fixtures/mock-resolver.service.d.ts.map +1 -0
- package/dist/tool-fixtures/mock-resolver.service.js +99 -0
- package/dist/tool-fixtures/mock-resolver.service.js.map +1 -0
- package/dist/tool-fixtures/schemas/tool-fixture.schema.d.ts +35 -0
- package/dist/tool-fixtures/schemas/tool-fixture.schema.d.ts.map +1 -0
- package/dist/tool-fixtures/schemas/tool-fixture.schema.js +87 -0
- package/dist/tool-fixtures/schemas/tool-fixture.schema.js.map +1 -0
- package/dist/tool-fixtures/tool-fixture.controller.d.ts +45 -0
- package/dist/tool-fixtures/tool-fixture.controller.d.ts.map +1 -0
- package/dist/tool-fixtures/tool-fixture.controller.js +223 -0
- package/dist/tool-fixtures/tool-fixture.controller.js.map +1 -0
- package/dist/tool-fixtures/tool-fixture.module.d.ts +3 -0
- package/dist/tool-fixtures/tool-fixture.module.d.ts.map +1 -0
- package/dist/tool-fixtures/tool-fixture.module.js +31 -0
- package/dist/tool-fixtures/tool-fixture.module.js.map +1 -0
- package/dist/tool-fixtures/tool-fixture.service.d.ts +59 -0
- package/dist/tool-fixtures/tool-fixture.service.d.ts.map +1 -0
- package/dist/tool-fixtures/tool-fixture.service.js +198 -0
- package/dist/tool-fixtures/tool-fixture.service.js.map +1 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 chanl.ai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* E2E Test Helpers
|
|
3
|
+
*
|
|
4
|
+
* Shared utilities for end-to-end tests that exercise the full
|
|
5
|
+
* conversation loop without mocking the core pipeline.
|
|
6
|
+
*/
|
|
7
|
+
import * as http from 'http';
|
|
8
|
+
export interface MockAgentResponse {
|
|
9
|
+
content: string;
|
|
10
|
+
tool_calls?: Array<{
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
arguments: Record<string, any>;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
export interface MockAgentServer {
|
|
17
|
+
url: string;
|
|
18
|
+
port: number;
|
|
19
|
+
server: http.Server;
|
|
20
|
+
receivedMessages: Array<{
|
|
21
|
+
message: string;
|
|
22
|
+
history: any[];
|
|
23
|
+
}>;
|
|
24
|
+
close: () => Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Start a mock HTTP agent that returns sequential responses.
|
|
28
|
+
* If responses run out, returns a "goodbye" message to end the conversation.
|
|
29
|
+
*/
|
|
30
|
+
export declare function startMockAgent(responses: MockAgentResponse[], port?: number): Promise<MockAgentServer>;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a message is one of the hardcoded fallback responses
|
|
33
|
+
* from the execution processor's generateNextPersonaMessage().
|
|
34
|
+
*/
|
|
35
|
+
export declare function isCannedMessage(message: string): boolean;
|
|
36
|
+
export declare function makePersonaData(overrides?: Record<string, any>): {
|
|
37
|
+
name: string;
|
|
38
|
+
gender: string;
|
|
39
|
+
emotion: string;
|
|
40
|
+
language: string;
|
|
41
|
+
accent: string;
|
|
42
|
+
intentClarity: string;
|
|
43
|
+
speechStyle: string;
|
|
44
|
+
backgroundNoise: boolean;
|
|
45
|
+
allowInterruptions: boolean;
|
|
46
|
+
description: string;
|
|
47
|
+
backstory: string;
|
|
48
|
+
behavior: {
|
|
49
|
+
personality: string;
|
|
50
|
+
cooperationLevel: string;
|
|
51
|
+
patience: string;
|
|
52
|
+
communicationStyle: string;
|
|
53
|
+
};
|
|
54
|
+
variables: {};
|
|
55
|
+
tags: string[];
|
|
56
|
+
isActive: boolean;
|
|
57
|
+
isDefault: boolean;
|
|
58
|
+
createdBy: string;
|
|
59
|
+
};
|
|
60
|
+
export declare function makeScenarioData(personaIds: string[], overrides?: Record<string, any>): {
|
|
61
|
+
name: string;
|
|
62
|
+
prompt: string;
|
|
63
|
+
category: string;
|
|
64
|
+
difficulty: string;
|
|
65
|
+
status: string;
|
|
66
|
+
personaIds: string[];
|
|
67
|
+
tags: string[];
|
|
68
|
+
createdBy: string;
|
|
69
|
+
};
|
|
70
|
+
export declare function makePromptData(endpoint: string, overrides?: Record<string, any>): {
|
|
71
|
+
name: string;
|
|
72
|
+
content: string;
|
|
73
|
+
status: string;
|
|
74
|
+
tags: string[];
|
|
75
|
+
adapterConfig: any;
|
|
76
|
+
createdAt: Date;
|
|
77
|
+
updatedAt: Date;
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=test-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["../../../src/__tests__/e2e/test-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAO7B,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,CAAC,CAAC;CAClF;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;IACpB,gBAAgB,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,GAAG,EAAE,CAAA;KAAE,CAAC,CAAC;IAC7D,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,iBAAiB,EAAE,EAC9B,IAAI,SAAI,GACP,OAAO,CAAC,eAAe,CAAC,CA2C1B;AASD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGxD;AAID,wBAAgB,eAAe,CAAC,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;;;;;;;;;;;;;;;;;;;;;;;EA0BlE;AAED,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAAE,EACpB,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;;;;;;;;;EAcpC;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;;;;;;;;EAmBpC"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* E2E Test Helpers
|
|
4
|
+
*
|
|
5
|
+
* Shared utilities for end-to-end tests that exercise the full
|
|
6
|
+
* conversation loop without mocking the core pipeline.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.startMockAgent = startMockAgent;
|
|
43
|
+
exports.isCannedMessage = isCannedMessage;
|
|
44
|
+
exports.makePersonaData = makePersonaData;
|
|
45
|
+
exports.makeScenarioData = makeScenarioData;
|
|
46
|
+
exports.makePromptData = makePromptData;
|
|
47
|
+
const http = __importStar(require("http"));
|
|
48
|
+
/**
|
|
49
|
+
* Start a mock HTTP agent that returns sequential responses.
|
|
50
|
+
* If responses run out, returns a "goodbye" message to end the conversation.
|
|
51
|
+
*/
|
|
52
|
+
function startMockAgent(responses, port = 0) {
|
|
53
|
+
return new Promise((resolve) => {
|
|
54
|
+
let callIndex = 0;
|
|
55
|
+
const receivedMessages = [];
|
|
56
|
+
const server = http.createServer(async (req, res) => {
|
|
57
|
+
if (req.method !== 'POST') {
|
|
58
|
+
res.writeHead(405);
|
|
59
|
+
res.end('Method not allowed');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const chunks = [];
|
|
63
|
+
for await (const chunk of req)
|
|
64
|
+
chunks.push(chunk);
|
|
65
|
+
const body = JSON.parse(Buffer.concat(chunks).toString());
|
|
66
|
+
receivedMessages.push({
|
|
67
|
+
message: body.message,
|
|
68
|
+
history: body.history || [],
|
|
69
|
+
});
|
|
70
|
+
const response = callIndex < responses.length
|
|
71
|
+
? responses[callIndex]
|
|
72
|
+
: { content: 'Thank you for calling. Goodbye!' };
|
|
73
|
+
callIndex++;
|
|
74
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
75
|
+
res.end(JSON.stringify(response));
|
|
76
|
+
});
|
|
77
|
+
server.listen(port, '127.0.0.1', () => {
|
|
78
|
+
const addr = server.address();
|
|
79
|
+
resolve({
|
|
80
|
+
url: `http://127.0.0.1:${addr.port}`,
|
|
81
|
+
port: addr.port,
|
|
82
|
+
server,
|
|
83
|
+
receivedMessages,
|
|
84
|
+
close: () => new Promise((r) => server.close(() => r())),
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
// ─── Canned Message Detection ─────────────────────────────────────────
|
|
90
|
+
const CANNED_MESSAGES = [
|
|
91
|
+
'can you tell me more about that?',
|
|
92
|
+
'i see. can you help me with that?',
|
|
93
|
+
];
|
|
94
|
+
/**
|
|
95
|
+
* Check if a message is one of the hardcoded fallback responses
|
|
96
|
+
* from the execution processor's generateNextPersonaMessage().
|
|
97
|
+
*/
|
|
98
|
+
function isCannedMessage(message) {
|
|
99
|
+
const lower = message.toLowerCase().trim();
|
|
100
|
+
return CANNED_MESSAGES.some((c) => lower === c);
|
|
101
|
+
}
|
|
102
|
+
// ─── Default Test Data Factories ──────────────────────────────────────
|
|
103
|
+
function makePersonaData(overrides = {}) {
|
|
104
|
+
return {
|
|
105
|
+
name: 'Test Customer',
|
|
106
|
+
gender: 'female',
|
|
107
|
+
emotion: 'frustrated',
|
|
108
|
+
language: 'english',
|
|
109
|
+
accent: 'american',
|
|
110
|
+
intentClarity: 'very clear',
|
|
111
|
+
speechStyle: 'normal',
|
|
112
|
+
backgroundNoise: false,
|
|
113
|
+
allowInterruptions: false,
|
|
114
|
+
description: 'A frustrated customer with a broken laptop',
|
|
115
|
+
backstory: 'You bought a laptop 2 weeks ago and it keeps crashing.',
|
|
116
|
+
behavior: {
|
|
117
|
+
personality: 'assertive',
|
|
118
|
+
cooperationLevel: 'difficult',
|
|
119
|
+
patience: 'impatient',
|
|
120
|
+
communicationStyle: 'direct',
|
|
121
|
+
},
|
|
122
|
+
variables: {},
|
|
123
|
+
tags: ['e2e-test'],
|
|
124
|
+
isActive: true,
|
|
125
|
+
isDefault: false,
|
|
126
|
+
createdBy: 'e2e-test',
|
|
127
|
+
...overrides,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function makeScenarioData(personaIds, overrides = {}) {
|
|
131
|
+
return {
|
|
132
|
+
name: 'E2E Test Scenario',
|
|
133
|
+
prompt: 'I bought a laptop two weeks ago and it keeps crashing. I want a full refund.',
|
|
134
|
+
category: 'support',
|
|
135
|
+
difficulty: 'medium',
|
|
136
|
+
status: 'active',
|
|
137
|
+
personaIds,
|
|
138
|
+
tags: ['e2e-test'],
|
|
139
|
+
createdBy: 'e2e-test',
|
|
140
|
+
...overrides,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function makePromptData(endpoint, overrides = {}) {
|
|
144
|
+
return {
|
|
145
|
+
name: 'E2E Test Agent',
|
|
146
|
+
content: 'You are a helpful customer service agent. Help resolve issues politely.',
|
|
147
|
+
status: 'active',
|
|
148
|
+
tags: ['e2e-test'],
|
|
149
|
+
adapterConfig: {
|
|
150
|
+
adapterType: 'http',
|
|
151
|
+
endpoint,
|
|
152
|
+
model: 'mock',
|
|
153
|
+
temperature: 0.7,
|
|
154
|
+
maxTokens: 512,
|
|
155
|
+
...overrides.adapterConfig,
|
|
156
|
+
},
|
|
157
|
+
createdAt: new Date(),
|
|
158
|
+
updatedAt: new Date(),
|
|
159
|
+
...overrides,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=test-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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it } from '@nestjs/common';
|
|
2
|
+
import { AgentAdapter } from './agent-adapter.interface';
|
|
3
|
+
export declare class AdapterRegistry implements OnModuleInit {
|
|
4
|
+
private readonly logger;
|
|
5
|
+
private readonly adapters;
|
|
6
|
+
onModuleInit(): void;
|
|
7
|
+
register(adapter: AgentAdapter): void;
|
|
8
|
+
get(type: string): AgentAdapter | undefined;
|
|
9
|
+
getOrThrow(type: string): AgentAdapter;
|
|
10
|
+
list(): AgentAdapter[];
|
|
11
|
+
listTypes(): string[];
|
|
12
|
+
has(type: string): boolean;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=adapter-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-registry.d.ts","sourceRoot":"","sources":["../../src/adapters/adapter-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAKzD,qBACa,eAAgB,YAAW,YAAY;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAC3D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmC;IAE5D,YAAY,IAAI,IAAI;IAMpB,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAKrC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAI3C,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY;IAUtC,IAAI,IAAI,YAAY,EAAE;IAItB,SAAS,IAAI,MAAM,EAAE;IAIrB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAG3B"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var AdapterRegistry_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AdapterRegistry = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const openai_adapter_1 = require("./openai.adapter");
|
|
13
|
+
const anthropic_adapter_1 = require("./anthropic.adapter");
|
|
14
|
+
const http_adapter_1 = require("./http.adapter");
|
|
15
|
+
let AdapterRegistry = AdapterRegistry_1 = class AdapterRegistry {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.logger = new common_1.Logger(AdapterRegistry_1.name);
|
|
18
|
+
this.adapters = new Map();
|
|
19
|
+
}
|
|
20
|
+
onModuleInit() {
|
|
21
|
+
this.register(new openai_adapter_1.OpenAIAdapter());
|
|
22
|
+
this.register(new anthropic_adapter_1.AnthropicAdapter());
|
|
23
|
+
this.register(new http_adapter_1.HttpAdapter());
|
|
24
|
+
}
|
|
25
|
+
register(adapter) {
|
|
26
|
+
this.adapters.set(adapter.type, adapter);
|
|
27
|
+
this.logger.log(`Registered adapter: ${adapter.type} (${adapter.name})`);
|
|
28
|
+
}
|
|
29
|
+
get(type) {
|
|
30
|
+
return this.adapters.get(type);
|
|
31
|
+
}
|
|
32
|
+
getOrThrow(type) {
|
|
33
|
+
const adapter = this.adapters.get(type);
|
|
34
|
+
if (!adapter) {
|
|
35
|
+
throw new Error(`No adapter registered for type "${type}". Available: ${this.listTypes().join(', ')}`);
|
|
36
|
+
}
|
|
37
|
+
return adapter;
|
|
38
|
+
}
|
|
39
|
+
list() {
|
|
40
|
+
return Array.from(this.adapters.values());
|
|
41
|
+
}
|
|
42
|
+
listTypes() {
|
|
43
|
+
return Array.from(this.adapters.keys());
|
|
44
|
+
}
|
|
45
|
+
has(type) {
|
|
46
|
+
return this.adapters.has(type);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.AdapterRegistry = AdapterRegistry;
|
|
50
|
+
exports.AdapterRegistry = AdapterRegistry = AdapterRegistry_1 = __decorate([
|
|
51
|
+
(0, common_1.Injectable)()
|
|
52
|
+
], AdapterRegistry);
|
|
53
|
+
//# sourceMappingURL=adapter-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-registry.js","sourceRoot":"","sources":["../../src/adapters/adapter-registry.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAkE;AAElE,qDAAiD;AACjD,2DAAuD;AACvD,iDAA6C;AAGtC,IAAM,eAAe,uBAArB,MAAM,eAAe;IAArB;QACY,WAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;QAC1C,aAAQ,GAAG,IAAI,GAAG,EAAwB,CAAC;IAsC9D,CAAC;IApCC,YAAY;QACV,IAAI,CAAC,QAAQ,CAAC,IAAI,8BAAa,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,IAAI,oCAAgB,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC,QAAQ,CAAC,IAAI,0BAAW,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ,CAAC,OAAqB;QAC5B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,uBAAuB,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;IAC3E,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACb,mCAAmC,IAAI,iBAAiB,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACtF,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,SAAS;QACP,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;CACF,CAAA;AAxCY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;GACA,eAAe,CAwC3B"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export interface AgentMessage {
|
|
2
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
3
|
+
content: string;
|
|
4
|
+
timestamp?: Date;
|
|
5
|
+
/**
|
|
6
|
+
* Provider-specific data that should be passed through as-is when
|
|
7
|
+
* rebuilding the message array for the next API call.
|
|
8
|
+
* For example, OpenAI assistant messages with tool_calls, or
|
|
9
|
+
* Anthropic tool_result content blocks.
|
|
10
|
+
*/
|
|
11
|
+
providerData?: Record<string, any>;
|
|
12
|
+
}
|
|
13
|
+
export interface ToolDefinition {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
parameters: Record<string, any>;
|
|
17
|
+
}
|
|
18
|
+
export interface AgentResponse {
|
|
19
|
+
content: string;
|
|
20
|
+
metadata?: Record<string, any>;
|
|
21
|
+
latencyMs?: number;
|
|
22
|
+
toolCalls?: Array<{
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
arguments: Record<string, any>;
|
|
26
|
+
result?: any;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
export interface AgentAdapterConfig {
|
|
30
|
+
model?: string;
|
|
31
|
+
temperature?: number;
|
|
32
|
+
maxTokens?: number;
|
|
33
|
+
systemPrompt?: string;
|
|
34
|
+
endpoint?: string;
|
|
35
|
+
apiKey?: string;
|
|
36
|
+
headers?: Record<string, string>;
|
|
37
|
+
tools?: ToolDefinition[];
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
}
|
|
40
|
+
export interface AgentAdapter {
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly type: string;
|
|
43
|
+
connect(config: AgentAdapterConfig): Promise<void>;
|
|
44
|
+
sendMessage(message: string, history: AgentMessage[]): Promise<AgentResponse>;
|
|
45
|
+
disconnect(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Format a tool execution result into a provider-specific message
|
|
48
|
+
* that can be appended to the conversation history.
|
|
49
|
+
*/
|
|
50
|
+
formatToolResult(toolCallId: string, toolName: string, result: any): AgentMessage;
|
|
51
|
+
/**
|
|
52
|
+
* Build the complete set of history messages needed after a tool call round.
|
|
53
|
+
* Returns: [assistant message with tool_calls, ...tool result messages]
|
|
54
|
+
*
|
|
55
|
+
* Each provider has different requirements:
|
|
56
|
+
* - OpenAI: assistant msg must include raw `tool_calls`, results use `role: tool`
|
|
57
|
+
* - Anthropic: assistant msg includes `tool_use` content blocks, results wrapped in `tool_result`
|
|
58
|
+
* - HTTP: generic format
|
|
59
|
+
*
|
|
60
|
+
* The execution processor pushes all returned messages into history, then
|
|
61
|
+
* calls sendMessage again. This keeps all provider-specific formatting
|
|
62
|
+
* inside the adapter.
|
|
63
|
+
*/
|
|
64
|
+
buildToolCallHistory(response: AgentResponse, resolvedResults: Array<{
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
result: any;
|
|
68
|
+
}>): AgentMessage[];
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=agent-adapter.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-adapter.interface.d.ts","sourceRoot":"","sources":["../../src/adapters/agent-adapter.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,KAAK,CAAC;QAChB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC/B,MAAM,CAAC,EAAE,GAAG,CAAC;KACd,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,OAAO,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,WAAW,CACT,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,YAAY,EAAE,GACtB,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B;;;OAGG;IACH,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,YAAY,CAAC;IAElF;;;;;;;;;;;;OAYG;IACH,oBAAoB,CAClB,QAAQ,EAAE,aAAa,EACvB,eAAe,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAE,CAAC,GAChE,YAAY,EAAE,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-adapter.interface.js","sourceRoot":"","sources":["../../src/adapters/agent-adapter.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AgentAdapter, AgentAdapterConfig, AgentMessage, AgentResponse } from './agent-adapter.interface';
|
|
2
|
+
export declare class AnthropicAdapter implements AgentAdapter {
|
|
3
|
+
readonly name = "Anthropic";
|
|
4
|
+
readonly type = "anthropic";
|
|
5
|
+
private config;
|
|
6
|
+
private connected;
|
|
7
|
+
connect(config: AgentAdapterConfig): Promise<void>;
|
|
8
|
+
sendMessage(message: string, history: AgentMessage[]): Promise<AgentResponse>;
|
|
9
|
+
formatToolResult(toolCallId: string, _toolName: string, result: any): AgentMessage;
|
|
10
|
+
buildToolCallHistory(response: AgentResponse, resolvedResults: Array<{
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
result: any;
|
|
14
|
+
}>): AgentMessage[];
|
|
15
|
+
disconnect(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=anthropic.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/anthropic.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACd,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,gBAAiB,YAAW,YAAY;IACnD,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,IAAI,eAAe;IAE5B,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,SAAS,CAAS;IAEpB,OAAO,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAclD,WAAW,CACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,YAAY,EAAE,GACtB,OAAO,CAAC,aAAa,CAAC;IA0FzB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,YAAY;IAiBlF,oBAAoB,CAClB,QAAQ,EAAE,aAAa,EACvB,eAAe,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAE,CAAC,GAChE,YAAY,EAAE;IA2BX,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAIlC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnthropicAdapter = void 0;
|
|
4
|
+
class AnthropicAdapter {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'Anthropic';
|
|
7
|
+
this.type = 'anthropic';
|
|
8
|
+
this.config = {};
|
|
9
|
+
this.connected = false;
|
|
10
|
+
}
|
|
11
|
+
async connect(config) {
|
|
12
|
+
if (!config.apiKey) {
|
|
13
|
+
throw new Error('Anthropic adapter requires apiKey');
|
|
14
|
+
}
|
|
15
|
+
this.config = {
|
|
16
|
+
model: 'claude-sonnet-4-5-20250929',
|
|
17
|
+
temperature: 0.7,
|
|
18
|
+
maxTokens: 1024,
|
|
19
|
+
endpoint: 'https://api.anthropic.com/v1/messages',
|
|
20
|
+
...config,
|
|
21
|
+
};
|
|
22
|
+
this.connected = true;
|
|
23
|
+
}
|
|
24
|
+
async sendMessage(message, history) {
|
|
25
|
+
if (!this.connected) {
|
|
26
|
+
throw new Error('Anthropic adapter not connected. Call connect() first.');
|
|
27
|
+
}
|
|
28
|
+
const messages = [];
|
|
29
|
+
for (const msg of history) {
|
|
30
|
+
if (msg.role === 'system')
|
|
31
|
+
continue;
|
|
32
|
+
if (msg.providerData) {
|
|
33
|
+
// Pass through provider-specific message structure (e.g. assistant
|
|
34
|
+
// messages with content blocks, or user messages with tool_result blocks)
|
|
35
|
+
messages.push({ role: msg.role, content: msg.content, ...msg.providerData });
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
messages.push({ role: msg.role, content: msg.content });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
messages.push({ role: 'user', content: message });
|
|
42
|
+
const start = Date.now();
|
|
43
|
+
const headers = {
|
|
44
|
+
'Content-Type': 'application/json',
|
|
45
|
+
'x-api-key': this.config.apiKey,
|
|
46
|
+
'anthropic-version': '2023-06-01',
|
|
47
|
+
...this.config.headers,
|
|
48
|
+
};
|
|
49
|
+
const body = {
|
|
50
|
+
model: this.config.model,
|
|
51
|
+
messages,
|
|
52
|
+
max_tokens: this.config.maxTokens,
|
|
53
|
+
temperature: this.config.temperature,
|
|
54
|
+
};
|
|
55
|
+
if (this.config.systemPrompt) {
|
|
56
|
+
body.system = this.config.systemPrompt;
|
|
57
|
+
}
|
|
58
|
+
if (this.config.tools?.length) {
|
|
59
|
+
body.tools = this.config.tools.map((t) => ({
|
|
60
|
+
name: t.name,
|
|
61
|
+
description: t.description,
|
|
62
|
+
input_schema: t.parameters,
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
const response = await fetch(this.config.endpoint, {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
headers,
|
|
68
|
+
body: JSON.stringify(body),
|
|
69
|
+
});
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
const error = await response.text();
|
|
72
|
+
throw new Error(`Anthropic API error (${response.status}): ${error}`);
|
|
73
|
+
}
|
|
74
|
+
const data = await response.json();
|
|
75
|
+
const latencyMs = Date.now() - start;
|
|
76
|
+
const content = data.content
|
|
77
|
+
?.filter((c) => c.type === 'text')
|
|
78
|
+
.map((c) => c.text)
|
|
79
|
+
.join('') || '';
|
|
80
|
+
const rawToolUseBlocks = data.content?.filter((c) => c.type === 'tool_use');
|
|
81
|
+
const toolCalls = rawToolUseBlocks?.map((c) => ({
|
|
82
|
+
id: c.id,
|
|
83
|
+
name: c.name,
|
|
84
|
+
arguments: c.input || {},
|
|
85
|
+
}));
|
|
86
|
+
return {
|
|
87
|
+
content,
|
|
88
|
+
latencyMs,
|
|
89
|
+
toolCalls: toolCalls?.length ? toolCalls : undefined,
|
|
90
|
+
metadata: {
|
|
91
|
+
model: data.model,
|
|
92
|
+
usage: data.usage,
|
|
93
|
+
stopReason: data.stop_reason,
|
|
94
|
+
// Preserve raw content blocks so the caller can rebuild history
|
|
95
|
+
// with providerData for multi-turn tool use
|
|
96
|
+
...(rawToolUseBlocks?.length ? { rawContentBlocks: data.content } : {}),
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
formatToolResult(toolCallId, _toolName, result) {
|
|
101
|
+
const resultContent = typeof result === 'string' ? result : JSON.stringify(result);
|
|
102
|
+
return {
|
|
103
|
+
role: 'user',
|
|
104
|
+
content: resultContent,
|
|
105
|
+
providerData: {
|
|
106
|
+
content: [
|
|
107
|
+
{
|
|
108
|
+
type: 'tool_result',
|
|
109
|
+
tool_use_id: toolCallId,
|
|
110
|
+
content: resultContent,
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
buildToolCallHistory(response, resolvedResults) {
|
|
117
|
+
const messages = [];
|
|
118
|
+
// 1. Assistant message with raw content blocks from Anthropic's response
|
|
119
|
+
messages.push({
|
|
120
|
+
role: 'assistant',
|
|
121
|
+
content: response.content || '',
|
|
122
|
+
providerData: response.metadata?.rawContentBlocks
|
|
123
|
+
? { content: response.metadata.rawContentBlocks }
|
|
124
|
+
: undefined,
|
|
125
|
+
});
|
|
126
|
+
// 2. Anthropic expects all tool results in a single user message
|
|
127
|
+
const toolResults = resolvedResults.map((r) => ({
|
|
128
|
+
type: 'tool_result',
|
|
129
|
+
tool_use_id: r.id,
|
|
130
|
+
content: typeof r.result === 'string' ? r.result : JSON.stringify(r.result),
|
|
131
|
+
}));
|
|
132
|
+
messages.push({
|
|
133
|
+
role: 'user',
|
|
134
|
+
content: '',
|
|
135
|
+
providerData: { content: toolResults },
|
|
136
|
+
});
|
|
137
|
+
return messages;
|
|
138
|
+
}
|
|
139
|
+
async disconnect() {
|
|
140
|
+
this.connected = false;
|
|
141
|
+
this.config = {};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.AnthropicAdapter = AnthropicAdapter;
|
|
145
|
+
//# sourceMappingURL=anthropic.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.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CAAC,CAAC,CAAC,MAAM,CAAC;SAC5E,CAAC,CAAC,CAAC;QACJ,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,EAAE;YACX,YAAY,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE;SACvC,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;CACF;AArKD,4CAqKC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AgentAdapter, AgentAdapterConfig, AgentMessage, AgentResponse } from './agent-adapter.interface';
|
|
2
|
+
export declare class HttpAdapter implements AgentAdapter {
|
|
3
|
+
readonly name = "HTTP";
|
|
4
|
+
readonly type = "http";
|
|
5
|
+
private config;
|
|
6
|
+
private connected;
|
|
7
|
+
connect(config: AgentAdapterConfig): Promise<void>;
|
|
8
|
+
sendMessage(message: string, history: AgentMessage[]): Promise<AgentResponse>;
|
|
9
|
+
formatToolResult(toolCallId: string, toolName: string, result: any): AgentMessage;
|
|
10
|
+
buildToolCallHistory(response: AgentResponse, resolvedResults: Array<{
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
result: any;
|
|
14
|
+
}>): AgentMessage[];
|
|
15
|
+
disconnect(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=http.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/http.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACd,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,WAAY,YAAW,YAAY;IAC9C,QAAQ,CAAC,IAAI,UAAU;IACvB,QAAQ,CAAC,IAAI,UAAU;IAEvB,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,SAAS,CAAS;IAEpB,OAAO,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQlD,WAAW,CACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,YAAY,EAAE,GACtB,OAAO,CAAC,aAAa,CAAC;IAiEzB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,YAAY;IAYjF,oBAAoB,CAClB,QAAQ,EAAE,aAAa,EACvB,eAAe,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAE,CAAC,GAChE,YAAY,EAAE;IASX,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAIlC"}
|