@elizaos/training 2.0.0-alpha.13 → 2.0.0-alpha.15
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/package.json +2 -2
- package/research-output/training-runs/training-run-1773726941205.json +38 -0
- package/scripts/rank_trajectories.ts +0 -1
- package/scripts/run_task_benchmark.ts +4 -11
- package/src/adapter.ts +96 -49
- package/src/archetypes/ArchetypeConfigService.ts +188 -185
- package/src/archetypes/derive-archetype.ts +47 -47
- package/src/archetypes/index.ts +2 -2
- package/src/benchmark/ArchetypeMatchupBenchmark.ts +70 -70
- package/src/benchmark/BenchmarkChartGenerator.ts +70 -69
- package/src/benchmark/BenchmarkDataGenerator.ts +136 -136
- package/src/benchmark/BenchmarkDataViewer.ts +32 -30
- package/src/benchmark/BenchmarkHistoryService.ts +13 -12
- package/src/benchmark/BenchmarkRunner.ts +87 -83
- package/src/benchmark/BenchmarkValidator.ts +48 -46
- package/src/benchmark/FastEvalRunner.ts +17 -16
- package/src/benchmark/MetricsValidator.ts +20 -21
- package/src/benchmark/MetricsVisualizer.ts +92 -85
- package/src/benchmark/ModelBenchmarkService.ts +90 -82
- package/src/benchmark/ModelRegistry.ts +44 -44
- package/src/benchmark/RulerBenchmarkIntegration.ts +24 -24
- package/src/benchmark/SimulationA2AInterface.ts +118 -118
- package/src/benchmark/SimulationEngine.ts +51 -51
- package/src/benchmark/TaskRunner.ts +87 -79
- package/src/benchmark/__tests__/BenchmarkRunner.test.ts +80 -80
- package/src/benchmark/__tests__/HeadToHead.test.ts +26 -26
- package/src/benchmark/index.ts +27 -27
- package/src/benchmark/parseSimulationMetrics.ts +32 -32
- package/src/benchmark/simulation-types.ts +10 -10
- package/src/dependencies.ts +34 -34
- package/src/generation/TrajectoryGenerator.ts +39 -37
- package/src/generation/index.ts +1 -1
- package/src/huggingface/HuggingFaceDatasetUploader.ts +72 -72
- package/src/huggingface/HuggingFaceIntegrationService.ts +59 -53
- package/src/huggingface/HuggingFaceModelUploader.ts +60 -59
- package/src/huggingface/index.ts +6 -6
- package/src/huggingface/shared/HuggingFaceUploadUtil.ts +32 -32
- package/src/index.ts +27 -27
- package/src/init-training.ts +6 -6
- package/src/metrics/TrajectoryMetricsExtractor.ts +70 -71
- package/src/metrics/__tests__/TrajectoryMetricsExtractor.test.ts +182 -182
- package/src/metrics/index.ts +2 -2
- package/src/rubrics/__tests__/index.test.ts +73 -73
- package/src/rubrics/ass-kisser.ts +6 -6
- package/src/rubrics/degen.ts +6 -6
- package/src/rubrics/goody-twoshoes.ts +6 -6
- package/src/rubrics/index.ts +50 -50
- package/src/rubrics/information-trader.ts +6 -6
- package/src/rubrics/infosec.ts +6 -6
- package/src/rubrics/liar.ts +6 -6
- package/src/rubrics/perps-trader.ts +6 -6
- package/src/rubrics/researcher.ts +6 -6
- package/src/rubrics/scammer.ts +6 -6
- package/src/rubrics/social-butterfly.ts +7 -7
- package/src/rubrics/super-predictor.ts +6 -6
- package/src/rubrics/trader.ts +5 -5
- package/src/scoring/ArchetypeScoringService.ts +56 -54
- package/src/scoring/JudgePromptBuilder.ts +96 -96
- package/src/scoring/LLMJudgeCache.ts +26 -23
- package/src/scoring/index.ts +3 -3
- package/src/training/AutomationPipeline.ts +149 -140
- package/src/training/BenchmarkService.ts +49 -45
- package/src/training/ConfigValidator.ts +38 -32
- package/src/training/MarketOutcomesTracker.ts +22 -12
- package/src/training/ModelDeployer.ts +15 -15
- package/src/training/ModelFetcher.ts +7 -7
- package/src/training/ModelSelectionService.ts +32 -32
- package/src/training/ModelUsageVerifier.ts +31 -24
- package/src/training/MultiModelOrchestrator.ts +44 -44
- package/src/training/RLModelConfig.ts +57 -57
- package/src/training/RewardBackpropagationService.ts +18 -17
- package/src/training/RulerScoringService.ts +73 -72
- package/src/training/TrainingMonitor.ts +29 -29
- package/src/training/TrajectoryRecorder.ts +25 -27
- package/src/training/__tests__/TrajectoryRecorder.test.ts +105 -105
- package/src/training/index.ts +36 -36
- package/src/training/logRLConfig.ts +7 -7
- package/src/training/pipeline.ts +13 -16
- package/src/training/storage/ModelStorageService.ts +32 -32
- package/src/training/storage/TrainingDataArchiver.ts +21 -21
- package/src/training/storage/index.ts +2 -2
- package/src/training/types.ts +6 -6
- package/src/training/window-utils.ts +14 -14
- package/src/utils/index.ts +7 -7
- package/src/utils/logger.ts +5 -5
- package/src/utils/snowflake.ts +1 -1
- package/src/utils/synthetic-detector.ts +7 -7
package/src/benchmark/index.ts
CHANGED
|
@@ -11,16 +11,16 @@ export type {
|
|
|
11
11
|
MatchupAgentResult,
|
|
12
12
|
MatchupBenchmarkConfig,
|
|
13
13
|
MatchupBenchmarkResult,
|
|
14
|
-
} from
|
|
14
|
+
} from "./ArchetypeMatchupBenchmark";
|
|
15
15
|
export {
|
|
16
16
|
ArchetypeMatchupBenchmark,
|
|
17
17
|
runQuickMatchupBenchmark,
|
|
18
|
-
} from
|
|
18
|
+
} from "./ArchetypeMatchupBenchmark";
|
|
19
19
|
export type {
|
|
20
20
|
BenchmarkHistoryEntry,
|
|
21
21
|
ModelComparisonData,
|
|
22
|
-
} from
|
|
23
|
-
export { BenchmarkChartGenerator } from
|
|
22
|
+
} from "./BenchmarkChartGenerator";
|
|
23
|
+
export { BenchmarkChartGenerator } from "./BenchmarkChartGenerator";
|
|
24
24
|
export type {
|
|
25
25
|
BenchmarkConfig,
|
|
26
26
|
BenchmarkGameSnapshot,
|
|
@@ -29,33 +29,33 @@ export type {
|
|
|
29
29
|
HiddenNarrativeFact,
|
|
30
30
|
ScheduledCausalEvent,
|
|
31
31
|
VolatilityBucket,
|
|
32
|
-
} from
|
|
33
|
-
export { BenchmarkDataGenerator, SeededRandom } from
|
|
34
|
-
export { BenchmarkDataViewer } from
|
|
32
|
+
} from "./BenchmarkDataGenerator";
|
|
33
|
+
export { BenchmarkDataGenerator, SeededRandom } from "./BenchmarkDataGenerator";
|
|
34
|
+
export { BenchmarkDataViewer } from "./BenchmarkDataViewer";
|
|
35
35
|
export type {
|
|
36
36
|
BenchmarkHistoryQuery,
|
|
37
37
|
BenchmarkResultInput,
|
|
38
38
|
BenchmarkTrendData,
|
|
39
|
-
} from
|
|
40
|
-
export { BenchmarkHistoryService } from
|
|
39
|
+
} from "./BenchmarkHistoryService";
|
|
40
|
+
export { BenchmarkHistoryService } from "./BenchmarkHistoryService";
|
|
41
41
|
export type {
|
|
42
42
|
BenchmarkComparisonResult,
|
|
43
43
|
BenchmarkRunConfig,
|
|
44
|
-
} from
|
|
45
|
-
export { BenchmarkRunner } from
|
|
46
|
-
export * as BenchmarkValidator from
|
|
47
|
-
export type { FastEvalConfig, FastEvalResult } from
|
|
48
|
-
export { FastEvalRunner } from
|
|
49
|
-
export { MetricsValidator } from
|
|
50
|
-
export { MetricsVisualizer } from
|
|
44
|
+
} from "./BenchmarkRunner";
|
|
45
|
+
export { BenchmarkRunner } from "./BenchmarkRunner";
|
|
46
|
+
export * as BenchmarkValidator from "./BenchmarkValidator";
|
|
47
|
+
export type { FastEvalConfig, FastEvalResult } from "./FastEvalRunner";
|
|
48
|
+
export { FastEvalRunner } from "./FastEvalRunner";
|
|
49
|
+
export { MetricsValidator } from "./MetricsValidator";
|
|
50
|
+
export { MetricsVisualizer } from "./MetricsVisualizer";
|
|
51
51
|
export type {
|
|
52
52
|
AverageMetrics,
|
|
53
53
|
ModelBenchmarkOptions,
|
|
54
54
|
ModelBenchmarkResult,
|
|
55
55
|
ModelComparisonResult,
|
|
56
|
-
} from
|
|
57
|
-
export { ModelBenchmarkService } from
|
|
58
|
-
export type { ModelConfig } from
|
|
56
|
+
} from "./ModelBenchmarkService";
|
|
57
|
+
export { ModelBenchmarkService } from "./ModelBenchmarkService";
|
|
58
|
+
export type { ModelConfig } from "./ModelRegistry";
|
|
59
59
|
export {
|
|
60
60
|
getBaselineModels,
|
|
61
61
|
getModelById,
|
|
@@ -65,12 +65,12 @@ export {
|
|
|
65
65
|
getModelsByTier,
|
|
66
66
|
MODEL_REGISTRY,
|
|
67
67
|
validateModelId,
|
|
68
|
-
} from
|
|
68
|
+
} from "./ModelRegistry";
|
|
69
69
|
// Shared utilities
|
|
70
70
|
export {
|
|
71
71
|
type JsonValue,
|
|
72
72
|
parseSimulationMetrics,
|
|
73
|
-
} from
|
|
73
|
+
} from "./parseSimulationMetrics";
|
|
74
74
|
export {
|
|
75
75
|
createRulerContext,
|
|
76
76
|
extractMarketOutcomesFromBenchmark,
|
|
@@ -79,13 +79,13 @@ export {
|
|
|
79
79
|
getTrueFacts,
|
|
80
80
|
scoreActionAgainstGroundTruth,
|
|
81
81
|
wasDecisionOptimal,
|
|
82
|
-
} from
|
|
83
|
-
export { SimulationA2AInterface } from
|
|
82
|
+
} from "./RulerBenchmarkIntegration";
|
|
83
|
+
export { SimulationA2AInterface } from "./SimulationA2AInterface";
|
|
84
84
|
export type {
|
|
85
85
|
SimulationConfig,
|
|
86
86
|
SimulationMetrics,
|
|
87
87
|
SimulationResult,
|
|
88
|
-
} from
|
|
89
|
-
export { SimulationEngine } from
|
|
90
|
-
export type { TaskRunnerConfig, TaskRunResult } from
|
|
91
|
-
export { TaskRunner } from
|
|
88
|
+
} from "./SimulationEngine";
|
|
89
|
+
export { SimulationEngine } from "./SimulationEngine";
|
|
90
|
+
export type { TaskRunnerConfig, TaskRunResult } from "./TaskRunner";
|
|
91
|
+
export { TaskRunner } from "./TaskRunner";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Used by ModelBenchmarkService and HuggingFaceModelUploader.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { SimulationMetrics } from
|
|
8
|
+
import type { SimulationMetrics } from "./SimulationEngine";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* JSON value type for parsing untyped data
|
|
@@ -27,38 +27,38 @@ export type JsonValue =
|
|
|
27
27
|
* @throws Error if data is invalid or missing required fields
|
|
28
28
|
*/
|
|
29
29
|
export function parseSimulationMetrics(data: JsonValue): SimulationMetrics {
|
|
30
|
-
if (typeof data !==
|
|
31
|
-
throw new Error(
|
|
30
|
+
if (typeof data !== "object" || data === null) {
|
|
31
|
+
throw new Error("Invalid SimulationMetrics: expected object");
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const metrics = data as Record<string, JsonValue>;
|
|
35
35
|
|
|
36
36
|
// Validate required fields
|
|
37
|
-
if (typeof metrics.totalPnl !==
|
|
38
|
-
throw new Error(
|
|
37
|
+
if (typeof metrics.totalPnl !== "number") {
|
|
38
|
+
throw new Error("Invalid SimulationMetrics: totalPnl must be a number");
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
if (
|
|
42
|
-
typeof metrics.predictionMetrics !==
|
|
42
|
+
typeof metrics.predictionMetrics !== "object" ||
|
|
43
43
|
metrics.predictionMetrics === null
|
|
44
44
|
) {
|
|
45
45
|
throw new Error(
|
|
46
|
-
|
|
46
|
+
"Invalid SimulationMetrics: predictionMetrics must be an object",
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
if (typeof metrics.perpMetrics !==
|
|
51
|
-
throw new Error(
|
|
50
|
+
if (typeof metrics.perpMetrics !== "object" || metrics.perpMetrics === null) {
|
|
51
|
+
throw new Error("Invalid SimulationMetrics: perpMetrics must be an object");
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
if (typeof metrics.optimalityScore !==
|
|
54
|
+
if (typeof metrics.optimalityScore !== "number") {
|
|
55
55
|
throw new Error(
|
|
56
|
-
|
|
56
|
+
"Invalid SimulationMetrics: optimalityScore must be a number",
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
if (typeof metrics.timing !==
|
|
61
|
-
throw new Error(
|
|
60
|
+
if (typeof metrics.timing !== "object" || metrics.timing === null) {
|
|
61
|
+
throw new Error("Invalid SimulationMetrics: timing must be an object");
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
// Validate nested structures
|
|
@@ -72,41 +72,41 @@ export function parseSimulationMetrics(data: JsonValue): SimulationMetrics {
|
|
|
72
72
|
// Helper to safely get number or default
|
|
73
73
|
const getNumber = (obj: Record<string, JsonValue>, key: string): number => {
|
|
74
74
|
const val = obj[key];
|
|
75
|
-
return typeof val ===
|
|
75
|
+
return typeof val === "number" ? val : 0;
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
// Parse socialMetrics if present
|
|
79
79
|
const socialMetricsData = metrics.socialMetrics;
|
|
80
80
|
const socialMetrics =
|
|
81
|
-
typeof socialMetricsData ===
|
|
81
|
+
typeof socialMetricsData === "object" && socialMetricsData !== null
|
|
82
82
|
? (socialMetricsData as Record<string, JsonValue>)
|
|
83
83
|
: null;
|
|
84
84
|
|
|
85
85
|
return {
|
|
86
86
|
totalPnl: metrics.totalPnl as number,
|
|
87
87
|
predictionMetrics: {
|
|
88
|
-
totalPositions: getNumber(predictionMetrics,
|
|
89
|
-
correctPredictions: getNumber(predictionMetrics,
|
|
88
|
+
totalPositions: getNumber(predictionMetrics, "totalPositions"),
|
|
89
|
+
correctPredictions: getNumber(predictionMetrics, "correctPredictions"),
|
|
90
90
|
incorrectPredictions: getNumber(
|
|
91
91
|
predictionMetrics,
|
|
92
|
-
|
|
92
|
+
"incorrectPredictions",
|
|
93
93
|
),
|
|
94
|
-
accuracy: getNumber(predictionMetrics,
|
|
95
|
-
avgPnlPerPosition: getNumber(predictionMetrics,
|
|
94
|
+
accuracy: getNumber(predictionMetrics, "accuracy"),
|
|
95
|
+
avgPnlPerPosition: getNumber(predictionMetrics, "avgPnlPerPosition"),
|
|
96
96
|
},
|
|
97
97
|
perpMetrics: {
|
|
98
|
-
totalTrades: getNumber(perpMetrics,
|
|
99
|
-
profitableTrades: getNumber(perpMetrics,
|
|
100
|
-
winRate: getNumber(perpMetrics,
|
|
101
|
-
avgPnlPerTrade: getNumber(perpMetrics,
|
|
102
|
-
maxDrawdown: getNumber(perpMetrics,
|
|
98
|
+
totalTrades: getNumber(perpMetrics, "totalTrades"),
|
|
99
|
+
profitableTrades: getNumber(perpMetrics, "profitableTrades"),
|
|
100
|
+
winRate: getNumber(perpMetrics, "winRate"),
|
|
101
|
+
avgPnlPerTrade: getNumber(perpMetrics, "avgPnlPerTrade"),
|
|
102
|
+
maxDrawdown: getNumber(perpMetrics, "maxDrawdown"),
|
|
103
103
|
},
|
|
104
104
|
socialMetrics: socialMetrics
|
|
105
105
|
? {
|
|
106
|
-
postsCreated: getNumber(socialMetrics,
|
|
107
|
-
groupsJoined: getNumber(socialMetrics,
|
|
108
|
-
messagesReceived: getNumber(socialMetrics,
|
|
109
|
-
reputationGained: getNumber(socialMetrics,
|
|
106
|
+
postsCreated: getNumber(socialMetrics, "postsCreated"),
|
|
107
|
+
groupsJoined: getNumber(socialMetrics, "groupsJoined"),
|
|
108
|
+
messagesReceived: getNumber(socialMetrics, "messagesReceived"),
|
|
109
|
+
reputationGained: getNumber(socialMetrics, "reputationGained"),
|
|
110
110
|
}
|
|
111
111
|
: {
|
|
112
112
|
postsCreated: 0,
|
|
@@ -115,9 +115,9 @@ export function parseSimulationMetrics(data: JsonValue): SimulationMetrics {
|
|
|
115
115
|
reputationGained: 0,
|
|
116
116
|
},
|
|
117
117
|
timing: {
|
|
118
|
-
avgResponseTime: getNumber(timing,
|
|
119
|
-
maxResponseTime: getNumber(timing,
|
|
120
|
-
totalDuration: getNumber(timing,
|
|
118
|
+
avgResponseTime: getNumber(timing, "avgResponseTime"),
|
|
119
|
+
maxResponseTime: getNumber(timing, "maxResponseTime"),
|
|
120
|
+
totalDuration: getNumber(timing, "totalDuration"),
|
|
121
121
|
},
|
|
122
122
|
optimalityScore: metrics.optimalityScore as number,
|
|
123
123
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { JsonValue } from
|
|
1
|
+
import type { JsonValue } from "../adapter";
|
|
2
2
|
|
|
3
3
|
export type AgentActionType =
|
|
4
|
-
|
|
|
5
|
-
|
|
|
6
|
-
|
|
|
7
|
-
|
|
|
8
|
-
|
|
|
9
|
-
|
|
|
10
|
-
|
|
|
11
|
-
|
|
|
4
|
+
| "query_state"
|
|
5
|
+
| "buy_prediction"
|
|
6
|
+
| "sell_prediction"
|
|
7
|
+
| "open_perp"
|
|
8
|
+
| "close_perp"
|
|
9
|
+
| "create_post"
|
|
10
|
+
| "join_group"
|
|
11
|
+
| "send_message";
|
|
12
12
|
|
|
13
13
|
export interface AgentAction {
|
|
14
14
|
tick: number;
|
|
@@ -27,7 +27,7 @@ export interface AgentAction {
|
|
|
27
27
|
perpCorrect?: boolean;
|
|
28
28
|
sentimentAtTrade?: number;
|
|
29
29
|
priceChange?: number;
|
|
30
|
-
expectedDirection?:
|
|
30
|
+
expectedDirection?: "up" | "down";
|
|
31
31
|
|
|
32
32
|
/** Sentiment analysis accuracy tracking */
|
|
33
33
|
sentimentAccuracy?: number;
|
package/src/dependencies.ts
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* @packageDocumentation
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import type { JsonValue } from
|
|
24
|
+
import type { JsonValue } from "./adapter";
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Minimal agent runtime interface.
|
|
@@ -58,7 +58,7 @@ export interface CreateAgentParams {
|
|
|
58
58
|
personality?: string;
|
|
59
59
|
tradingStrategy?: string;
|
|
60
60
|
initialDeposit?: number;
|
|
61
|
-
modelTier?:
|
|
61
|
+
modelTier?: "lite" | "standard" | "pro";
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
@@ -83,11 +83,11 @@ export interface ILLMCaller {
|
|
|
83
83
|
callGroqDirect(params: {
|
|
84
84
|
prompt: string;
|
|
85
85
|
system: string;
|
|
86
|
-
modelSize?:
|
|
86
|
+
modelSize?: "small" | "medium" | "large";
|
|
87
87
|
temperature?: number;
|
|
88
88
|
maxTokens?: number;
|
|
89
89
|
actionType?: string;
|
|
90
|
-
responseFormat?: { type:
|
|
90
|
+
responseFormat?: { type: "json_object" };
|
|
91
91
|
}): Promise<string>;
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -112,14 +112,14 @@ export type ExportGroupedForGRPOFn = (options: {
|
|
|
112
112
|
export type ExportToHuggingFaceFn = (options: {
|
|
113
113
|
datasetName: string;
|
|
114
114
|
trajectoryIds?: string[];
|
|
115
|
-
format?:
|
|
115
|
+
format?: "parquet" | "jsonl";
|
|
116
116
|
}) => Promise<{ success: boolean; url?: string; error?: string }>;
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* Convert trajectory to training format messages
|
|
120
120
|
*/
|
|
121
121
|
export type ToTrainingMessagesFn = (
|
|
122
|
-
trajectory: TrajectoryForTraining
|
|
122
|
+
trajectory: TrajectoryForTraining,
|
|
123
123
|
) => TrainingMessage[];
|
|
124
124
|
|
|
125
125
|
/**
|
|
@@ -175,7 +175,7 @@ export interface TrajectoryStepForTraining {
|
|
|
175
175
|
temperature: number;
|
|
176
176
|
maxTokens: number;
|
|
177
177
|
latencyMs?: number;
|
|
178
|
-
purpose:
|
|
178
|
+
purpose: "action" | "reasoning" | "evaluation" | "response" | "other";
|
|
179
179
|
actionType?: string;
|
|
180
180
|
}>;
|
|
181
181
|
action: {
|
|
@@ -195,7 +195,7 @@ export interface TrajectoryStepForTraining {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
export interface TrainingMessage {
|
|
198
|
-
role:
|
|
198
|
+
role: "system" | "user" | "assistant";
|
|
199
199
|
content: string;
|
|
200
200
|
}
|
|
201
201
|
|
|
@@ -218,9 +218,9 @@ let _toTrainingMessages: ToTrainingMessagesFn | null = null;
|
|
|
218
218
|
function assertFn(dep: unknown, name: string, methods: string[]): void {
|
|
219
219
|
if (dep == null) return; // allow explicit null/undefined (means "skip")
|
|
220
220
|
for (const method of methods) {
|
|
221
|
-
if (typeof (dep as Record<string, unknown>)[method] !==
|
|
221
|
+
if (typeof (dep as Record<string, unknown>)[method] !== "function") {
|
|
222
222
|
throw new TypeError(
|
|
223
|
-
`configureTrainingDependencies: ${name}.${method} must be a function, got ${typeof (dep as Record<string, unknown>)[method]}
|
|
223
|
+
`configureTrainingDependencies: ${name}.${method} must be a function, got ${typeof (dep as Record<string, unknown>)[method]}`,
|
|
224
224
|
);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
@@ -242,41 +242,41 @@ export function configureTrainingDependencies(config: {
|
|
|
242
242
|
toTrainingMessages?: ToTrainingMessagesFn;
|
|
243
243
|
}): void {
|
|
244
244
|
// Runtime shape checks – catch adapter mismatches early
|
|
245
|
-
assertFn(config.agentService,
|
|
246
|
-
assertFn(config.agentRuntimeManager,
|
|
247
|
-
|
|
248
|
-
|
|
245
|
+
assertFn(config.agentService, "agentService", ["createAgent"]);
|
|
246
|
+
assertFn(config.agentRuntimeManager, "agentRuntimeManager", [
|
|
247
|
+
"getRuntime",
|
|
248
|
+
"resetRuntime",
|
|
249
249
|
]);
|
|
250
|
-
assertFn(config.autonomousCoordinator,
|
|
251
|
-
|
|
250
|
+
assertFn(config.autonomousCoordinator, "autonomousCoordinator", [
|
|
251
|
+
"executeAutonomousTick",
|
|
252
252
|
]);
|
|
253
|
-
assertFn(config.llmCaller,
|
|
253
|
+
assertFn(config.llmCaller, "llmCaller", ["callGroqDirect"]);
|
|
254
254
|
|
|
255
255
|
if (
|
|
256
256
|
config.exportGroupedForGRPO !== undefined &&
|
|
257
257
|
config.exportGroupedForGRPO !== null &&
|
|
258
|
-
typeof config.exportGroupedForGRPO !==
|
|
258
|
+
typeof config.exportGroupedForGRPO !== "function"
|
|
259
259
|
) {
|
|
260
260
|
throw new TypeError(
|
|
261
|
-
|
|
261
|
+
"configureTrainingDependencies: exportGroupedForGRPO must be a function",
|
|
262
262
|
);
|
|
263
263
|
}
|
|
264
264
|
if (
|
|
265
265
|
config.exportToHuggingFace !== undefined &&
|
|
266
266
|
config.exportToHuggingFace !== null &&
|
|
267
|
-
typeof config.exportToHuggingFace !==
|
|
267
|
+
typeof config.exportToHuggingFace !== "function"
|
|
268
268
|
) {
|
|
269
269
|
throw new TypeError(
|
|
270
|
-
|
|
270
|
+
"configureTrainingDependencies: exportToHuggingFace must be a function",
|
|
271
271
|
);
|
|
272
272
|
}
|
|
273
273
|
if (
|
|
274
274
|
config.toTrainingMessages !== undefined &&
|
|
275
275
|
config.toTrainingMessages !== null &&
|
|
276
|
-
typeof config.toTrainingMessages !==
|
|
276
|
+
typeof config.toTrainingMessages !== "function"
|
|
277
277
|
) {
|
|
278
278
|
throw new TypeError(
|
|
279
|
-
|
|
279
|
+
"configureTrainingDependencies: toTrainingMessages must be a function",
|
|
280
280
|
);
|
|
281
281
|
}
|
|
282
282
|
|
|
@@ -310,7 +310,7 @@ export function configureTrainingDependencies(config: {
|
|
|
310
310
|
export function getAgentService(): IAgentService {
|
|
311
311
|
if (!_agentService) {
|
|
312
312
|
throw new Error(
|
|
313
|
-
|
|
313
|
+
"AgentService not configured. Call configureTrainingDependencies() first.",
|
|
314
314
|
);
|
|
315
315
|
}
|
|
316
316
|
return _agentService;
|
|
@@ -323,7 +323,7 @@ export function getAgentService(): IAgentService {
|
|
|
323
323
|
export function getAgentRuntimeManager(): IAgentRuntimeManager {
|
|
324
324
|
if (!_agentRuntimeManager) {
|
|
325
325
|
throw new Error(
|
|
326
|
-
|
|
326
|
+
"AgentRuntimeManager not configured. Call configureTrainingDependencies() first.",
|
|
327
327
|
);
|
|
328
328
|
}
|
|
329
329
|
return _agentRuntimeManager;
|
|
@@ -336,7 +336,7 @@ export function getAgentRuntimeManager(): IAgentRuntimeManager {
|
|
|
336
336
|
export function getAutonomousCoordinator(): IAutonomousCoordinator {
|
|
337
337
|
if (!_autonomousCoordinator) {
|
|
338
338
|
throw new Error(
|
|
339
|
-
|
|
339
|
+
"AutonomousCoordinator not configured. Call configureTrainingDependencies() first.",
|
|
340
340
|
);
|
|
341
341
|
}
|
|
342
342
|
return _autonomousCoordinator;
|
|
@@ -349,7 +349,7 @@ export function getAutonomousCoordinator(): IAutonomousCoordinator {
|
|
|
349
349
|
export function getLLMCaller(): ILLMCaller {
|
|
350
350
|
if (!_llmCaller) {
|
|
351
351
|
throw new Error(
|
|
352
|
-
|
|
352
|
+
"LLMCaller not configured. Call configureTrainingDependencies() first.",
|
|
353
353
|
);
|
|
354
354
|
}
|
|
355
355
|
return _llmCaller;
|
|
@@ -362,7 +362,7 @@ export function getLLMCaller(): ILLMCaller {
|
|
|
362
362
|
export function getExportGroupedForGRPO(): ExportGroupedForGRPOFn {
|
|
363
363
|
if (!_exportGroupedForGRPO) {
|
|
364
364
|
throw new Error(
|
|
365
|
-
|
|
365
|
+
"exportGroupedForGRPO not configured. Call configureTrainingDependencies() first.",
|
|
366
366
|
);
|
|
367
367
|
}
|
|
368
368
|
return _exportGroupedForGRPO;
|
|
@@ -375,7 +375,7 @@ export function getExportGroupedForGRPO(): ExportGroupedForGRPOFn {
|
|
|
375
375
|
export function getExportToHuggingFace(): ExportToHuggingFaceFn {
|
|
376
376
|
if (!_exportToHuggingFace) {
|
|
377
377
|
throw new Error(
|
|
378
|
-
|
|
378
|
+
"exportToHuggingFace not configured. Call configureTrainingDependencies() first.",
|
|
379
379
|
);
|
|
380
380
|
}
|
|
381
381
|
return _exportToHuggingFace;
|
|
@@ -388,7 +388,7 @@ export function getExportToHuggingFace(): ExportToHuggingFaceFn {
|
|
|
388
388
|
export function getToTrainingMessages(): ToTrainingMessagesFn {
|
|
389
389
|
if (!_toTrainingMessages) {
|
|
390
390
|
throw new Error(
|
|
391
|
-
|
|
391
|
+
"toTrainingMessages not configured. Call configureTrainingDependencies() first.",
|
|
392
392
|
);
|
|
393
393
|
}
|
|
394
394
|
return _toTrainingMessages;
|
|
@@ -422,7 +422,7 @@ export interface IAutonomousCoordinator {
|
|
|
422
422
|
executeAutonomousTick(
|
|
423
423
|
agentUserId: string,
|
|
424
424
|
agentRuntime: IAgentRuntimeLike,
|
|
425
|
-
recordTrajectories?: boolean
|
|
425
|
+
recordTrajectories?: boolean,
|
|
426
426
|
): Promise<{
|
|
427
427
|
success: boolean;
|
|
428
428
|
actionsExecuted?: {
|
|
@@ -448,7 +448,7 @@ export interface ITaskInteractor {
|
|
|
448
448
|
options?: {
|
|
449
449
|
maxTurns?: number;
|
|
450
450
|
temperature?: number;
|
|
451
|
-
}
|
|
451
|
+
},
|
|
452
452
|
): Promise<{
|
|
453
453
|
success: boolean;
|
|
454
454
|
response: string;
|
|
@@ -461,14 +461,14 @@ export interface ITaskInteractor {
|
|
|
461
461
|
let _taskInteractor: ITaskInteractor | null = null;
|
|
462
462
|
|
|
463
463
|
export function configureTaskInteractor(interactor: ITaskInteractor): void {
|
|
464
|
-
assertFn(interactor,
|
|
464
|
+
assertFn(interactor, "taskInteractor", ["executeTask"]);
|
|
465
465
|
_taskInteractor = interactor;
|
|
466
466
|
}
|
|
467
467
|
|
|
468
468
|
export function getTaskInteractor(): ITaskInteractor {
|
|
469
469
|
if (!_taskInteractor) {
|
|
470
470
|
throw new Error(
|
|
471
|
-
|
|
471
|
+
"TaskInteractor not configured. Call configureTaskInteractor() first.",
|
|
472
472
|
);
|
|
473
473
|
}
|
|
474
474
|
return _taskInteractor;
|