@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
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Central LLM configuration resolver for chanl-eval.
|
|
4
|
+
*
|
|
5
|
+
* Replaces 6 scattered resolution paths with a single 4-tier chain:
|
|
6
|
+
* 1. Explicit config (adapterConfig.apiKey)
|
|
7
|
+
* 2. Simulation-specific keys (adapterConfig.simulationApiKey, legacy fields)
|
|
8
|
+
* 3. Environment variables (CHANL_OPENAI_API_KEY, CHANL_ANTHROPIC_API_KEY)
|
|
9
|
+
* 4. Settings DB (async callback)
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.resolveLlmConfigSync = resolveLlmConfigSync;
|
|
13
|
+
exports.resolveLlmConfig = resolveLlmConfig;
|
|
14
|
+
function isNonEmpty(val) {
|
|
15
|
+
return typeof val === 'string' && val.length > 0;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Synchronous resolver — tiers 1-3 (no DB access).
|
|
19
|
+
* Used by persona-llm.ts and persona strategies where async isn't needed.
|
|
20
|
+
*/
|
|
21
|
+
function resolveLlmConfigSync(adapterType, adapterConfig) {
|
|
22
|
+
const cfg = adapterConfig || {};
|
|
23
|
+
// Tier 2: Simulation-specific key (higher priority — dedicated persona/judge key)
|
|
24
|
+
if (isNonEmpty(cfg.simulationApiKey)) {
|
|
25
|
+
return {
|
|
26
|
+
kind: (adapterType === 'anthropic' ? 'anthropic' : 'openai'),
|
|
27
|
+
apiKey: cfg.simulationApiKey,
|
|
28
|
+
model: cfg.simulationModel || undefined,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
// Tier 2b: Legacy explicit persona key fields (always treated as openai)
|
|
32
|
+
const legacyKey = cfg.personaLlmApiKey || cfg.personaOpenAiKey || cfg.openaiApiKey;
|
|
33
|
+
if (isNonEmpty(legacyKey)) {
|
|
34
|
+
return { kind: 'openai', apiKey: legacyKey, model: undefined };
|
|
35
|
+
}
|
|
36
|
+
// Tier 1: Explicit apiKey from adapterConfig
|
|
37
|
+
if (isNonEmpty(cfg.apiKey)) {
|
|
38
|
+
const kind = (adapterType === 'anthropic' ? 'anthropic' : 'openai');
|
|
39
|
+
return { kind, apiKey: cfg.apiKey, model: cfg.model || undefined };
|
|
40
|
+
}
|
|
41
|
+
// Tier 3: Environment variables
|
|
42
|
+
// If adapterType is specified, check that provider's env var first
|
|
43
|
+
if (adapterType === 'anthropic') {
|
|
44
|
+
if (isNonEmpty(process.env.CHANL_ANTHROPIC_API_KEY)) {
|
|
45
|
+
return { kind: 'anthropic', apiKey: process.env.CHANL_ANTHROPIC_API_KEY, model: undefined };
|
|
46
|
+
}
|
|
47
|
+
if (isNonEmpty(process.env.CHANL_OPENAI_API_KEY)) {
|
|
48
|
+
return { kind: 'openai', apiKey: process.env.CHANL_OPENAI_API_KEY, model: undefined };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// openai or unspecified — check openai first
|
|
53
|
+
if (isNonEmpty(process.env.CHANL_OPENAI_API_KEY)) {
|
|
54
|
+
return { kind: 'openai', apiKey: process.env.CHANL_OPENAI_API_KEY, model: undefined };
|
|
55
|
+
}
|
|
56
|
+
if (isNonEmpty(process.env.CHANL_ANTHROPIC_API_KEY)) {
|
|
57
|
+
return { kind: 'anthropic', apiKey: process.env.CHANL_ANTHROPIC_API_KEY, model: undefined };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Async resolver — all 4 tiers including settings DB lookup.
|
|
64
|
+
* Used by ExecutionProcessor and ChatService where DB access is available.
|
|
65
|
+
*/
|
|
66
|
+
async function resolveLlmConfig(adapterType, adapterConfig, settingsLookup) {
|
|
67
|
+
// Try tiers 1-3 first (sync)
|
|
68
|
+
const syncResult = resolveLlmConfigSync(adapterType, adapterConfig);
|
|
69
|
+
if (syncResult)
|
|
70
|
+
return syncResult;
|
|
71
|
+
// Tier 4: Settings DB via async callback
|
|
72
|
+
if (!settingsLookup)
|
|
73
|
+
return null;
|
|
74
|
+
try {
|
|
75
|
+
// If adapterType specified, try that first
|
|
76
|
+
if (adapterType) {
|
|
77
|
+
const key = await settingsLookup(adapterType);
|
|
78
|
+
if (isNonEmpty(key)) {
|
|
79
|
+
const kind = (adapterType === 'anthropic' ? 'anthropic' : 'openai');
|
|
80
|
+
return { kind, apiKey: key, model: undefined };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Try openai
|
|
84
|
+
const openaiKey = await settingsLookup('openai');
|
|
85
|
+
if (isNonEmpty(openaiKey)) {
|
|
86
|
+
return { kind: 'openai', apiKey: openaiKey, model: undefined };
|
|
87
|
+
}
|
|
88
|
+
// Try anthropic
|
|
89
|
+
const anthropicKey = await settingsLookup('anthropic');
|
|
90
|
+
if (isNonEmpty(anthropicKey)) {
|
|
91
|
+
return { kind: 'anthropic', apiKey: anthropicKey, model: undefined };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// Settings lookup failed — graceful degradation
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=llm-config-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-config-resolver.js","sourceRoot":"","sources":["../../src/execution/llm-config-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAkBH,oDA+CC;AAMD,4CAsCC;AAnGD,SAAS,UAAU,CAAC,GAAY;IAC9B,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,SAAgB,oBAAoB,CAClC,WAA+B,EAC/B,a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AAC,CAAC,QAAQ,CAA2B,CAAC;gBAC9F,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;YACjD,CAAC;QACH,CAAC;QAED,aAAa;QACb,MAAM,SAAS,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;QACjD,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC1B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QACjE,CAAC;QAED,gBAAgB;QAChB,MAAM,YAAY,GAAG,MAAM,cAAc,CAAC,WAAW,CAAC,CAAC;QACvD,IAAI,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAC7B,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QACvE,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,gDAAgD;IAClD,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AgentMessage } from '../adapters/agent-adapter.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve API material for a separate "persona" LLM call (does not use the agent adapter instance).
|
|
4
|
+
* Delegates to the central resolver (tiers 1-3: config → legacy → env vars).
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolvePersonaLlmKey(adapterType: string | undefined, adapterConfig: Record<string, any> | undefined): {
|
|
7
|
+
kind: 'openai' | 'anthropic';
|
|
8
|
+
apiKey: string;
|
|
9
|
+
model?: string;
|
|
10
|
+
} | null;
|
|
11
|
+
/**
|
|
12
|
+
* Generate the next persona utterance using an LLM and the persona system prompt.
|
|
13
|
+
*/
|
|
14
|
+
export declare function generatePersonaUtterance(options: {
|
|
15
|
+
personaSystemPrompt: string;
|
|
16
|
+
history: AgentMessage[];
|
|
17
|
+
adapterType?: string;
|
|
18
|
+
adapterConfig?: Record<string, any>;
|
|
19
|
+
}): Promise<string | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Optional opening line via LLM (richer than echoing the scenario prompt).
|
|
22
|
+
*/
|
|
23
|
+
export declare function generatePersonaOpening(options: {
|
|
24
|
+
personaSystemPrompt: string;
|
|
25
|
+
scenarioPrompt: string;
|
|
26
|
+
adapterType?: string;
|
|
27
|
+
adapterConfig?: Record<string, any>;
|
|
28
|
+
}): Promise<string | null>;
|
|
29
|
+
//# sourceMappingURL=persona-llm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persona-llm.d.ts","sourceRoot":"","sources":["../../src/execution/persona-llm.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAMnE;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,GAC7C;IAAE,IAAI,EAAE,QAAQ,GAAG,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAEzE;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE;IACtD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACrC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAsCzB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE;IACpD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACrC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA0CzB"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolvePersonaLlmKey = resolvePersonaLlmKey;
|
|
4
|
+
exports.generatePersonaUtterance = generatePersonaUtterance;
|
|
5
|
+
exports.generatePersonaOpening = generatePersonaOpening;
|
|
6
|
+
const openai_adapter_1 = require("../adapters/openai.adapter");
|
|
7
|
+
const anthropic_adapter_1 = require("../adapters/anthropic.adapter");
|
|
8
|
+
const llm_config_resolver_1 = require("./llm-config-resolver");
|
|
9
|
+
const USER_TURN = 'Respond as the customer with your next message only. Stay in character. Keep it to one or two short sentences. No role labels or quotes.';
|
|
10
|
+
/**
|
|
11
|
+
* Resolve API material for a separate "persona" LLM call (does not use the agent adapter instance).
|
|
12
|
+
* Delegates to the central resolver (tiers 1-3: config → legacy → env vars).
|
|
13
|
+
*/
|
|
14
|
+
function resolvePersonaLlmKey(adapterType, adapterConfig) {
|
|
15
|
+
return (0, llm_config_resolver_1.resolveLlmConfigSync)(adapterType, adapterConfig);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Generate the next persona utterance using an LLM and the persona system prompt.
|
|
19
|
+
*/
|
|
20
|
+
async function generatePersonaUtterance(options) {
|
|
21
|
+
const resolved = resolvePersonaLlmKey(options.adapterType, options.adapterConfig);
|
|
22
|
+
if (!resolved)
|
|
23
|
+
return null;
|
|
24
|
+
try {
|
|
25
|
+
if (resolved.kind === 'openai') {
|
|
26
|
+
const adapter = new openai_adapter_1.OpenAIAdapter();
|
|
27
|
+
await adapter.connect({
|
|
28
|
+
apiKey: resolved.apiKey,
|
|
29
|
+
model: resolved.model || 'gpt-4o-mini',
|
|
30
|
+
temperature: 0.85,
|
|
31
|
+
maxTokens: 256,
|
|
32
|
+
systemPrompt: options.personaSystemPrompt,
|
|
33
|
+
});
|
|
34
|
+
const res = await adapter.sendMessage(USER_TURN, options.history);
|
|
35
|
+
await adapter.disconnect();
|
|
36
|
+
const text = (res.content || '').trim();
|
|
37
|
+
return text.length > 0 ? text : null;
|
|
38
|
+
}
|
|
39
|
+
const adapter = new anthropic_adapter_1.AnthropicAdapter();
|
|
40
|
+
await adapter.connect({
|
|
41
|
+
apiKey: resolved.apiKey,
|
|
42
|
+
model: resolved.model || 'claude-3-5-haiku-20241022',
|
|
43
|
+
temperature: 0.85,
|
|
44
|
+
maxTokens: 256,
|
|
45
|
+
systemPrompt: options.personaSystemPrompt,
|
|
46
|
+
});
|
|
47
|
+
const res = await adapter.sendMessage(USER_TURN, options.history);
|
|
48
|
+
await adapter.disconnect();
|
|
49
|
+
const text = (res.content || '').trim();
|
|
50
|
+
return text.length > 0 ? text : null;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Optional opening line via LLM (richer than echoing the scenario prompt).
|
|
58
|
+
*/
|
|
59
|
+
async function generatePersonaOpening(options) {
|
|
60
|
+
const resolved = resolvePersonaLlmKey(options.adapterType, options.adapterConfig);
|
|
61
|
+
if (!resolved)
|
|
62
|
+
return null;
|
|
63
|
+
const openerUserMsg = `Situation: ${options.scenarioPrompt}
|
|
64
|
+
|
|
65
|
+
You are starting the conversation as this customer. Say your opening line only — one or two short sentences.`;
|
|
66
|
+
try {
|
|
67
|
+
if (resolved.kind === 'openai') {
|
|
68
|
+
const adapter = new openai_adapter_1.OpenAIAdapter();
|
|
69
|
+
await adapter.connect({
|
|
70
|
+
apiKey: resolved.apiKey,
|
|
71
|
+
model: resolved.model || 'gpt-4o-mini',
|
|
72
|
+
temperature: 0.8,
|
|
73
|
+
maxTokens: 200,
|
|
74
|
+
systemPrompt: options.personaSystemPrompt,
|
|
75
|
+
});
|
|
76
|
+
const res = await adapter.sendMessage(openerUserMsg, []);
|
|
77
|
+
await adapter.disconnect();
|
|
78
|
+
const text = (res.content || '').trim();
|
|
79
|
+
return text.length > 0 ? text : null;
|
|
80
|
+
}
|
|
81
|
+
const adapter = new anthropic_adapter_1.AnthropicAdapter();
|
|
82
|
+
await adapter.connect({
|
|
83
|
+
apiKey: resolved.apiKey,
|
|
84
|
+
model: resolved.model || 'claude-3-5-haiku-20241022',
|
|
85
|
+
temperature: 0.8,
|
|
86
|
+
maxTokens: 200,
|
|
87
|
+
systemPrompt: options.personaSystemPrompt,
|
|
88
|
+
});
|
|
89
|
+
const res = await adapter.sendMessage(openerUserMsg, []);
|
|
90
|
+
await adapter.disconnect();
|
|
91
|
+
const text = (res.content || '').trim();
|
|
92
|
+
return text.length > 0 ? text : null;
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=persona-llm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persona-llm.js","sourceRoot":"","sources":["../../src/execution/persona-llm.ts"],"names":[],"mappings":";;AAYA,oDAKC;AAKD,4DA2CC;AAKD,wDA+CC;AArHD,+DAA2D;AAC3D,qEAAiE;AAEjE,+DAA6D;AAE7D,MAAM,SAAS,GACb,0IAA0I,CAAC;AAE7I;;;GAGG;AACH,SAAgB,oBAAoB,CAClC,WAA+B,EAC/B,aAA8C;IAE9C,OAAO,IAAA,0CAAoB,EAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AAC1D,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,wBAAwB,CAAC,OAK9C;IACC,MAAM,QAAQ,GAAG,oBAAoB,CACnC,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,aAAa,CACtB,CAAC;IACF,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAE3B,IAAI,CAAC;QACH,IAAI,QAAQ,CAAC,IA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G;YAChB,SAAS,EAAE,GAAG;YACd,YAAY,EAAE,OAAO,CAAC,mBAAmB;SAC1C,CAAC,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QACzD,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import { PersonaStrategy } from './persona-strategy.interface';
|
|
3
|
+
export declare class PersonaStrategyRegistry implements OnModuleInit {
|
|
4
|
+
private readonly logger;
|
|
5
|
+
private readonly strategies;
|
|
6
|
+
onModuleInit(): void;
|
|
7
|
+
register(strategy: PersonaStrategy): void;
|
|
8
|
+
get(type: string): PersonaStrategy | undefined;
|
|
9
|
+
getOrThrow(type: string): PersonaStrategy;
|
|
10
|
+
list(): PersonaStrategy[];
|
|
11
|
+
listTypes(): string[];
|
|
12
|
+
has(type: string): boolean;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=persona-strategy-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persona-strategy-registry.d.ts","sourceRoot":"","sources":["../../src/execution/persona-strategy-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAI/D,qBACa,uBAAwB,YAAW,YAAY;IAC1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4C;IACnE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAsC;IAEjE,YAAY,IAAI,IAAI;IAKpB,QAAQ,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAKzC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAI9C,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAUzC,IAAI,IAAI,eAAe,EAAE;IAIzB,SAAS,IAAI,MAAM,EAAE;IAIrB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAG3B"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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 PersonaStrategyRegistry_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.PersonaStrategyRegistry = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const default_strategy_1 = require("./strategies/default.strategy");
|
|
13
|
+
const reactive_strategy_1 = require("./strategies/reactive.strategy");
|
|
14
|
+
let PersonaStrategyRegistry = PersonaStrategyRegistry_1 = class PersonaStrategyRegistry {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.logger = new common_1.Logger(PersonaStrategyRegistry_1.name);
|
|
17
|
+
this.strategies = new Map();
|
|
18
|
+
}
|
|
19
|
+
onModuleInit() {
|
|
20
|
+
this.register(new default_strategy_1.DefaultPersonaStrategy());
|
|
21
|
+
this.register(new reactive_strategy_1.ReactivePersonaStrategy());
|
|
22
|
+
}
|
|
23
|
+
register(strategy) {
|
|
24
|
+
this.strategies.set(strategy.type, strategy);
|
|
25
|
+
this.logger.log(`Registered persona strategy: ${strategy.type}`);
|
|
26
|
+
}
|
|
27
|
+
get(type) {
|
|
28
|
+
return this.strategies.get(type);
|
|
29
|
+
}
|
|
30
|
+
getOrThrow(type) {
|
|
31
|
+
const strategy = this.strategies.get(type);
|
|
32
|
+
if (!strategy) {
|
|
33
|
+
throw new Error(`No persona strategy registered for type "${type}". Available: ${this.listTypes().join(', ')}`);
|
|
34
|
+
}
|
|
35
|
+
return strategy;
|
|
36
|
+
}
|
|
37
|
+
list() {
|
|
38
|
+
return Array.from(this.strategies.values());
|
|
39
|
+
}
|
|
40
|
+
listTypes() {
|
|
41
|
+
return Array.from(this.strategies.keys());
|
|
42
|
+
}
|
|
43
|
+
has(type) {
|
|
44
|
+
return this.strategies.has(type);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
exports.PersonaStrategyRegistry = PersonaStrategyRegistry;
|
|
48
|
+
exports.PersonaStrategyRegistry = PersonaStrategyRegistry = PersonaStrategyRegistry_1 = __decorate([
|
|
49
|
+
(0, common_1.Injectable)()
|
|
50
|
+
], PersonaStrategyRegistry);
|
|
51
|
+
//# sourceMappingURL=persona-strategy-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persona-strategy-registry.js","sourceRoot":"","sources":["../../src/execution/persona-strategy-registry.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAkE;AAElE,oEAAuE;AACvE,sEAAyE;AAGlE,IAAM,uBAAuB,+BAA7B,MAAM,uBAAuB;IAA7B;QACY,WAAM,GAAG,IAAI,eAAM,CAAC,yBAAuB,CAAC,IAAI,CAAC,CAAC;QAClD,eAAU,GAAG,IAAI,GAAG,EAA2B,CAAC;IAqCnE,CAAC;IAnCC,YAAY;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ent-adapter.interface';
|
|
2
|
+
import { TranscriptEntry } from './interfaces/job-data.interface';
|
|
3
|
+
/**
|
|
4
|
+
* Persona traits passed to strategies for prompt generation and behavior decisions.
|
|
5
|
+
*/
|
|
6
|
+
export interface PersonaTraits {
|
|
7
|
+
name: string;
|
|
8
|
+
emotion?: string;
|
|
9
|
+
speechStyle?: string;
|
|
10
|
+
intentClarity?: string;
|
|
11
|
+
backgroundNoise?: boolean;
|
|
12
|
+
description?: string;
|
|
13
|
+
backstory?: string;
|
|
14
|
+
gender?: string;
|
|
15
|
+
language?: string;
|
|
16
|
+
accent?: string;
|
|
17
|
+
behavior?: {
|
|
18
|
+
personality?: string;
|
|
19
|
+
emotionalState?: string;
|
|
20
|
+
cooperationLevel?: string;
|
|
21
|
+
patience?: string;
|
|
22
|
+
communicationStyle?: string;
|
|
23
|
+
};
|
|
24
|
+
conversationTraits?: {
|
|
25
|
+
allowInterruptions?: boolean;
|
|
26
|
+
interruptionFrequency?: string;
|
|
27
|
+
asksClarifyingQuestions?: boolean;
|
|
28
|
+
repeatsInformation?: boolean;
|
|
29
|
+
goesOffTopic?: boolean;
|
|
30
|
+
};
|
|
31
|
+
variables?: Record<string, string>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Context provided to persona strategies for each utterance generation.
|
|
35
|
+
*/
|
|
36
|
+
export interface PersonaStrategyContext {
|
|
37
|
+
personaTraits: PersonaTraits;
|
|
38
|
+
systemPrompt: string;
|
|
39
|
+
history: AgentMessage[];
|
|
40
|
+
lastAgentResponse: string;
|
|
41
|
+
turn: number;
|
|
42
|
+
transcript: TranscriptEntry[];
|
|
43
|
+
scenarioPrompt: string;
|
|
44
|
+
adapterType?: string;
|
|
45
|
+
adapterConfig?: Record<string, any>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Tool definition for internal persona tools.
|
|
49
|
+
* These are structured-output tools the persona LLM can call to reason
|
|
50
|
+
* about the agent's behavior before generating its visible response.
|
|
51
|
+
*/
|
|
52
|
+
export interface PersonaToolDefinition {
|
|
53
|
+
name: string;
|
|
54
|
+
description: string;
|
|
55
|
+
parameters: Record<string, any>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Pluggable persona strategy interface.
|
|
59
|
+
* Mirrors the AgentAdapter pattern — register strategies in PersonaStrategyRegistry.
|
|
60
|
+
*
|
|
61
|
+
* Built-in strategies:
|
|
62
|
+
* - 'default': Standard LLM persona (wraps existing persona-llm.ts behavior)
|
|
63
|
+
* - 'reactive': Tool-augmented persona that analyzes agent responses before replying
|
|
64
|
+
*/
|
|
65
|
+
export interface PersonaStrategy {
|
|
66
|
+
readonly type: string;
|
|
67
|
+
/**
|
|
68
|
+
* Generate the persona's opening message for the conversation.
|
|
69
|
+
* Return null to fall back to heuristic opening.
|
|
70
|
+
*/
|
|
71
|
+
generateOpening(ctx: PersonaStrategyContext): Promise<string | null>;
|
|
72
|
+
/**
|
|
73
|
+
* Generate the persona's next utterance in the conversation.
|
|
74
|
+
* Return null to fall back to heuristic generation.
|
|
75
|
+
*/
|
|
76
|
+
generateUtterance(ctx: PersonaStrategyContext): Promise<string | null>;
|
|
77
|
+
/**
|
|
78
|
+
* Optional: mutate the system prompt mid-conversation based on agent behavior.
|
|
79
|
+
* Return null to keep the current prompt unchanged.
|
|
80
|
+
*/
|
|
81
|
+
updateSystemPrompt?(ctx: PersonaStrategyContext): Promise<string | null>;
|
|
82
|
+
/**
|
|
83
|
+
* Optional: declare internal tools available to the persona LLM.
|
|
84
|
+
* These are self-reflective tools — the LLM reasons about the conversation.
|
|
85
|
+
*/
|
|
86
|
+
getInternalTools?(): PersonaToolDefinition[];
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=persona-strategy.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persona-strategy.interface.d.ts","sourceRoot":"","sources":["../../src/execution/persona-strategy.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAA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;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACrC;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,eAAe,CAAC,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAErE;;;OAGG;IACH,iBAAiB,CAAC,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAEvE;;;OAGG;IACH,kBAAkB,CAAC,CAAC,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAEzE;;;OAGG;IACH,gBAAgB,CAAC,IAAI,qBAAqB,EAAE,CAAC;CAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persona-strategy.interface.js","sourceRoot":"","sources":["../../src/execution/persona-strategy.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Queue } from 'bull';
|
|
2
|
+
import { ScenarioExecutionJobData } from './interfaces/job-data.interface';
|
|
3
|
+
export declare class QueueProducerService {
|
|
4
|
+
private readonly executionQueue;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(executionQueue: Queue<ScenarioExecutionJobData>);
|
|
7
|
+
/**
|
|
8
|
+
* Enqueue a scenario execution job.
|
|
9
|
+
*
|
|
10
|
+
* @param executionId - The unique execution ID (exec_<uuid>)
|
|
11
|
+
* @param scenarioId - The scenario to execute
|
|
12
|
+
* @param options - Additional job options (adapter, persona, max turns, etc.)
|
|
13
|
+
* @returns The Bull job instance
|
|
14
|
+
*/
|
|
15
|
+
enqueueExecution(executionId: string, scenarioId: string, options: Pick<ScenarioExecutionJobData, 'promptId'> & Partial<Omit<ScenarioExecutionJobData, 'executionId' | 'scenarioId' | 'promptId'>>): Promise<import("bull").Job<ScenarioExecutionJobData>>;
|
|
16
|
+
/**
|
|
17
|
+
* Get the current count of waiting and active jobs.
|
|
18
|
+
*/
|
|
19
|
+
getQueueCounts(): Promise<import("bull").JobCounts>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=queue-producer.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue-producer.service.d.ts","sourceRoot":"","sources":["../../src/execution/queue-producer.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,qBACa,oBAAoB;IAK7B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAJjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;gBAI7C,cAAc,EAAE,KAAK,CAAC,wBAAwB,CAAC;IAGlE;;;;;;;OAOG;IACG,gBAAgB,CACpB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,IAAI,CAAC,wBAAwB,EAAE,UAAU,CAAC,GACjD,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,aAAa,GAAG,YAAY,GAAG,UAAU,CAAC,CAAC;IAoBtF;;OAEG;IACG,cAAc;CAIrB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var QueueProducerService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.QueueProducerService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const bull_1 = require("@nestjs/bull");
|
|
19
|
+
const queues_config_1 = require("./queues.config");
|
|
20
|
+
let QueueProducerService = QueueProducerService_1 = class QueueProducerService {
|
|
21
|
+
constructor(executionQueue) {
|
|
22
|
+
this.executionQueue = executionQueue;
|
|
23
|
+
this.logger = new common_1.Logger(QueueProducerService_1.name);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Enqueue a scenario execution job.
|
|
27
|
+
*
|
|
28
|
+
* @param executionId - The unique execution ID (exec_<uuid>)
|
|
29
|
+
* @param scenarioId - The scenario to execute
|
|
30
|
+
* @param options - Additional job options (adapter, persona, max turns, etc.)
|
|
31
|
+
* @returns The Bull job instance
|
|
32
|
+
*/
|
|
33
|
+
async enqueueExecution(executionId, scenarioId, options) {
|
|
34
|
+
const jobData = {
|
|
35
|
+
executionId,
|
|
36
|
+
scenarioId,
|
|
37
|
+
...options,
|
|
38
|
+
};
|
|
39
|
+
const job = await this.executionQueue.add('execute', jobData, {
|
|
40
|
+
...queues_config_1.defaultJobOptions,
|
|
41
|
+
jobId: executionId,
|
|
42
|
+
});
|
|
43
|
+
this.logger.log(`Enqueued execution ${executionId} for scenario ${scenarioId} (job ${job.id})`);
|
|
44
|
+
return job;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the current count of waiting and active jobs.
|
|
48
|
+
*/
|
|
49
|
+
async getQueueCounts() {
|
|
50
|
+
const counts = await this.executionQueue.getJobCounts();
|
|
51
|
+
return counts;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.QueueProducerService = QueueProducerService;
|
|
55
|
+
exports.QueueProducerService = QueueProducerService = QueueProducerService_1 = __decorate([
|
|
56
|
+
(0, common_1.Injectable)(),
|
|
57
|
+
__param(0, (0, bull_1.InjectQueue)(queues_config_1.QUEUE_NAMES.SCENARIO_EXECUTION)),
|
|
58
|
+
__metadata("design:paramtypes", [Object])
|
|
59
|
+
], QueueProducerService);
|
|
60
|
+
//# sourceMappingURL=queue-producer.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue-producer.service.js","sourceRoot":"","sources":["../../src/execution/queue-producer.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,uCAA2C;AAE3C,mDAAiE;AAI1D,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAG/B,YAEE,cAAgE;QAA/C,mBAAc,GAAd,cAAc,CAAiC;QAJjD,WAAM,GAAG,IAAI,eAAM,CAAC,sBAAoB,CAAC,IAAI,CAAC,CAAC;IAK7D,CAAC;IAEJ;;;;;;;OAOG;IACH,KAAK,CAAC,gBAAgB,CACpB,WAAmB,EACnB,UAAkB,EAClB,OACoF;QAEpF,MAAM,OAAO,GAA6B;YACxC,WAAW;YACX,UAAU;YACV,GAAG,OAAO;SACX,CAAC;QAEF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE;YAC5D,GAAG,iCAAiB;YACpB,KAAK,EAAE,WAAW;SACnB,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,sBAAsB,WAAW,iBAAiB,UAAU,SAAS,GAAG,CAAC,EAAE,GAAG,CAC/E,CAAC;QAEF,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc;QAClB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;QACxD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AA/CY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,kBAAW,EAAC,2BAAW,CAAC,kBAAkB,CAAC,CAAA;;GAJnC,oBAAoB,CA+ChC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue configuration for scenario execution.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Queue name constants.
|
|
6
|
+
*/
|
|
7
|
+
export declare const QUEUE_NAMES: {
|
|
8
|
+
readonly SCENARIO_EXECUTION: "scenario-execution";
|
|
9
|
+
};
|
|
10
|
+
export type QueueName = (typeof QUEUE_NAMES)[keyof typeof QUEUE_NAMES];
|
|
11
|
+
/**
|
|
12
|
+
* Default job options for the scenario-execution queue.
|
|
13
|
+
*/
|
|
14
|
+
export declare const defaultJobOptions: {
|
|
15
|
+
attempts: number;
|
|
16
|
+
backoff: {
|
|
17
|
+
type: "exponential";
|
|
18
|
+
delay: number;
|
|
19
|
+
};
|
|
20
|
+
removeOnComplete: {
|
|
21
|
+
age: number;
|
|
22
|
+
count: number;
|
|
23
|
+
};
|
|
24
|
+
removeOnFail: {
|
|
25
|
+
age: number;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Worker/concurrency settings per queue.
|
|
30
|
+
*/
|
|
31
|
+
export declare const workerOptions: Record<QueueName, {
|
|
32
|
+
concurrency: number;
|
|
33
|
+
maxPerMinute: number;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Default maximum turns for a conversation loop.
|
|
37
|
+
*/
|
|
38
|
+
export declare const DEFAULT_MAX_TURNS = 10;
|
|
39
|
+
//# sourceMappingURL=queues.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queues.config.d.ts","sourceRoot":"","sources":["../../src/execution/queues.config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,WAAW;;CAEd,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEvE;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;CAa7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAChC,SAAS,EACT;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAM9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,KAAK,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Queue configuration for scenario execution.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DEFAULT_MAX_TURNS = exports.workerOptions = exports.defaultJobOptions = exports.QUEUE_NAMES = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Queue name constants.
|
|
9
|
+
*/
|
|
10
|
+
exports.QUEUE_NAMES = {
|
|
11
|
+
SCENARIO_EXECUTION: 'scenario-execution',
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Default job options for the scenario-execution queue.
|
|
15
|
+
*/
|
|
16
|
+
exports.defaultJobOptions = {
|
|
17
|
+
attempts: 3,
|
|
18
|
+
backoff: {
|
|
19
|
+
type: 'exponential',
|
|
20
|
+
delay: 1000, // 1s, 2s, 4s
|
|
21
|
+
},
|
|
22
|
+
removeOnComplete: {
|
|
23
|
+
age: 24 * 3600, // 24 hours
|
|
24
|
+
count: 1000,
|
|
25
|
+
},
|
|
26
|
+
removeOnFail: {
|
|
27
|
+
age: 7 * 24 * 3600, // 7 days
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Worker/concurrency settings per queue.
|
|
32
|
+
*/
|
|
33
|
+
exports.workerOptions = {
|
|
34
|
+
[exports.QUEUE_NAMES.SCENARIO_EXECUTION]: {
|
|
35
|
+
concurrency: 5,
|
|
36
|
+
maxPerMinute: 10,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Default maximum turns for a conversation loop.
|
|
41
|
+
*/
|
|
42
|
+
exports.DEFAULT_MAX_TURNS = 10;
|
|
43
|
+
//# sourceMappingURL=queues.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queues.config.js","sourceRoot":"","sources":["../../src/execution/queues.config.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH;;GAEG;AACU,QAAA,WAAW,GAAG;IACzB,kBAAkB,EAAE,oBAAoB;CAChC,CAAC;AAIX;;GAEG;AACU,QAAA,iBAAiB,GAAG;IAC/B,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE;QACP,IAAI,EAAE,aAAsB;QAC5B,KAAK,EAAE,IAAI,EAAE,aAAa;KAC3B;IACD,gBAAgB,EAAE;QAChB,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,WAAW;QAC3B,KAAK,EAAE,IAAI;KACZ;IACD,YAAY,EAAE;QACZ,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,SAAS;KAC9B;CACF,CAAC;AAEF;;GAEG;AACU,QAAA,aAAa,GAGtB;IACF,CAAC,mBAAW,CAAC,kBAAkB,CAAC,EAAE;QAChC,WAAW,EAAE,CAAC;QACd,YAAY,EAAE,EAAE;KACjB;CACF,CAAC;AAEF;;GAEG;AACU,QAAA,iBAAiB,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PersonaStrategy, PersonaStrategyContext } from '../persona-strategy.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Default persona strategy — wraps the existing persona-llm.ts behavior.
|
|
4
|
+
* No internal tools, no dynamic prompt mutation. Backward compatible.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DefaultPersonaStrategy implements PersonaStrategy {
|
|
7
|
+
readonly type = "default";
|
|
8
|
+
generateOpening(ctx: PersonaStrategyContext): Promise<string | null>;
|
|
9
|
+
generateUtterance(ctx: PersonaStrategyContext): Promise<string | null>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=default.strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.strategy.d.ts","sourceRoot":"","sources":["../../../src/execution/strategies/default.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,sBAAsB,EACvB,MAAM,+BAA+B,CAAC;AAMvC;;;GAGG;AACH,qBAAa,sBAAuB,YAAW,eAAe;IAC5D,QAAQ,CAAC,IAAI,aAAa;IAEpB,eAAe,CAAC,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IASpE,iBAAiB,CAAC,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAQ7E"}
|