@elizaos/plugin-trajectory-logger 2.0.0-alpha.1 → 2.0.0-alpha.2
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/TrajectoryLoggerService.d.ts +39 -0
- package/dist/TrajectoryLoggerService.d.ts.map +1 -0
- package/dist/action-interceptor.d.ts +23 -0
- package/dist/action-interceptor.d.ts.map +1 -0
- package/dist/art-format.d.ts +32 -0
- package/dist/art-format.d.ts.map +1 -0
- package/dist/build.d.ts +3 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/export.d.ts +40 -0
- package/dist/export.d.ts.map +1 -0
- package/dist/game-rewards.d.ts +14 -0
- package/dist/game-rewards.d.ts.map +1 -0
- package/dist/generated/specs/specs.d.ts +55 -0
- package/dist/generated/specs/specs.d.ts.map +1 -0
- package/dist/index.browser.d.ts +4 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/integration.d.ts +58 -0
- package/dist/integration.d.ts.map +1 -0
- package/dist/node/tsconfig.build.tsbuildinfo +1 -0
- package/dist/reward-service.d.ts +24 -0
- package/dist/reward-service.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +241 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +6 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shaw Walters and elizaOS Contributors
|
|
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,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trajectory Logger Service
|
|
3
|
+
*
|
|
4
|
+
* In-memory collector for agent interaction trajectories.
|
|
5
|
+
*
|
|
6
|
+
* This implementation is intentionally storage-agnostic so it can be used in any elizaOS
|
|
7
|
+
* environment (Node, Bun, tests). If you want persistence, export trajectories and store them
|
|
8
|
+
* via your preferred database or file pipeline.
|
|
9
|
+
*/
|
|
10
|
+
import type { ActionAttempt, EnvironmentState, JsonValue, LLMCall, ProviderAccess, RewardComponents, Trajectory } from "./types";
|
|
11
|
+
export declare class TrajectoryLoggerService {
|
|
12
|
+
private activeTrajectories;
|
|
13
|
+
private activeStepIds;
|
|
14
|
+
startTrajectory(agentId: string, options?: {
|
|
15
|
+
scenarioId?: string;
|
|
16
|
+
episodeId?: string;
|
|
17
|
+
batchId?: string;
|
|
18
|
+
groupIndex?: number;
|
|
19
|
+
metadata?: Record<string, JsonValue>;
|
|
20
|
+
}): string;
|
|
21
|
+
startStep(trajectoryId: string, envState: EnvironmentState): string;
|
|
22
|
+
logLLMCall(stepId: string, llmCall: Omit<LLMCall, "callId" | "timestamp">): void;
|
|
23
|
+
logProviderAccess(stepId: string, access: Omit<ProviderAccess, "providerId" | "timestamp">): void;
|
|
24
|
+
logLLMCallByTrajectoryId(trajectoryId: string, llmCall: Omit<LLMCall, "callId" | "timestamp">): void;
|
|
25
|
+
logProviderAccessByTrajectoryId(trajectoryId: string, access: Omit<ProviderAccess, "providerId" | "timestamp">): void;
|
|
26
|
+
getCurrentStepId(trajectoryId: string): string | null;
|
|
27
|
+
completeStep(trajectoryId: string, stepId: string, action: Omit<ActionAttempt, "attemptId" | "timestamp">, rewardInfo?: {
|
|
28
|
+
reward?: number;
|
|
29
|
+
components?: Partial<RewardComponents>;
|
|
30
|
+
}): void;
|
|
31
|
+
completeCurrentStep(trajectoryId: string, action: Omit<ActionAttempt, "attemptId" | "timestamp">, rewardInfo?: {
|
|
32
|
+
reward?: number;
|
|
33
|
+
components?: Partial<RewardComponents>;
|
|
34
|
+
}): void;
|
|
35
|
+
endTrajectory(trajectoryId: string, status: "completed" | "terminated" | "error" | "timeout", finalMetrics?: Record<string, JsonValue>): Promise<void>;
|
|
36
|
+
getActiveTrajectory(trajectoryId: string): Trajectory | null;
|
|
37
|
+
private findTrajectoryByStepId;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=TrajectoryLoggerService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TrajectoryLoggerService.d.ts","sourceRoot":"","sources":["../TrajectoryLoggerService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,UAAU,EAEX,MAAM,SAAS,CAAC;AAEjB,qBAAa,uBAAuB;IAClC,OAAO,CAAC,kBAAkB,CAAsC;IAChE,OAAO,CAAC,aAAa,CAAkC;IAEvD,eAAe,CACb,OAAO,EAAE,MAAM,EACf,OAAO,GAA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AE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAA;KAAE,GACvE,IAAI;IASD,aAAa,CACjB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,WAAW,GAAG,YAAY,GAAG,OAAO,GAAG,SAAS,EACxD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GACvC,OAAO,CAAC,IAAI,CAAC;IAsBhB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAI5D,OAAO,CAAC,sBAAsB;CAQ/B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action-Level Instrumentation
|
|
3
|
+
*
|
|
4
|
+
* Wraps actions and providers with trajectory logging.
|
|
5
|
+
*/
|
|
6
|
+
import type { Action, IAgentRuntime, Plugin, Provider } from "@elizaos/core";
|
|
7
|
+
import type { TrajectoryLoggerService } from "./TrajectoryLoggerService";
|
|
8
|
+
import type { JsonValue } from "./types";
|
|
9
|
+
interface TrajectoryContext {
|
|
10
|
+
trajectoryId: string;
|
|
11
|
+
logger: TrajectoryLoggerService;
|
|
12
|
+
}
|
|
13
|
+
export declare function setTrajectoryContext(runtime: IAgentRuntime, trajectoryId: string, trajectoryLogger: TrajectoryLoggerService): void;
|
|
14
|
+
export declare function getTrajectoryContext(runtime: IAgentRuntime): TrajectoryContext | null;
|
|
15
|
+
export declare function clearTrajectoryContext(runtime: IAgentRuntime): void;
|
|
16
|
+
export declare function wrapActionWithLogging(action: Action, _trajectoryLogger: TrajectoryLoggerService): Action;
|
|
17
|
+
export declare function wrapPluginActions(plugin: Plugin, trajectoryLogger: TrajectoryLoggerService): Plugin;
|
|
18
|
+
export declare function logLLMCallFromAction(actionContext: Record<string, JsonValue | undefined>, trajectoryLogger: TrajectoryLoggerService, trajectoryId: string): void;
|
|
19
|
+
export declare function logProviderFromAction(actionContext: Record<string, JsonValue | undefined>, trajectoryLogger: TrajectoryLoggerService, trajectoryId: string): void;
|
|
20
|
+
export declare function wrapProviderWithLogging(provider: Provider, _trajectoryLogger: TrajectoryLoggerService): Provider;
|
|
21
|
+
export declare function wrapPluginProviders(plugin: Plugin, trajectoryLogger: TrajectoryLoggerService): Plugin;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=action-interceptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-interceptor.d.ts","sourceRoot":"","sources":["../action-interceptor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,MAAM,EAIN,aAAa,EAEb,MAAM,EACN,QAAQ,EAGT,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,UAAU,iBAAiB;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,uBAAuB,CAAC;CACjC;AAID,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,uBAAuB,GACxC,IAAI,CAEN;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,GAAG,iBAAiB,GAAG,IAAI,CAErF;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAEnE;AAID,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,uBAAuB,GACzC,MAAM,CA+FR;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,uBAAuB,GACxC,MAAM,CASR;AAED,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC,EACpD,gBAAgB,EAAE,uBAAuB,EACzC,YAAY,EAAE,MAAM,GACnB,IAAI,CAuBN;AAED,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC,EACpD,gBAAgB,EAAE,uBAAuB,EACzC,YAAY,EAAE,MAAM,GACnB,IAAI,CAaN;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,uBAAuB,GACzC,QAAQ,CA0CV;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,uBAAuB,GACxC,MAAM,CAWR"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ART Format Conversion
|
|
3
|
+
*
|
|
4
|
+
* Converts our rich trajectory format to ART-compatible format.
|
|
5
|
+
*
|
|
6
|
+
* Key insight from ART examples:
|
|
7
|
+
* - Trajectories are MESSAGE ARRAYS (system/user/assistant)
|
|
8
|
+
* - Metadata is separate (for judge context)
|
|
9
|
+
* - Single reward per trajectory
|
|
10
|
+
* - Grouping by scenario for GRPO
|
|
11
|
+
*/
|
|
12
|
+
import type { ARTTrajectory, ChatMessage, Trajectory, TrajectoryGroup } from "./types";
|
|
13
|
+
/**
|
|
14
|
+
* Convert rich trajectory to ART message format.
|
|
15
|
+
*/
|
|
16
|
+
export declare function toARTMessages(trajectory: Trajectory): ChatMessage[];
|
|
17
|
+
export declare function toARTTrajectory(trajectory: Trajectory): ARTTrajectory;
|
|
18
|
+
export declare function groupTrajectories(trajectories: Trajectory[]): TrajectoryGroup[];
|
|
19
|
+
export declare function extractSharedPrefix(trajectories: Trajectory[]): ChatMessage[];
|
|
20
|
+
export declare function removeSharedPrefix(messages: ChatMessage[], sharedPrefix: ChatMessage[]): ChatMessage[];
|
|
21
|
+
export declare function prepareForRULER(group: TrajectoryGroup): {
|
|
22
|
+
sharedPrefix: ChatMessage[];
|
|
23
|
+
suffixes: ChatMessage[][];
|
|
24
|
+
metadata: ARTTrajectory["metadata"][];
|
|
25
|
+
};
|
|
26
|
+
export declare function toARTJSONL(trajectory: Trajectory): string;
|
|
27
|
+
export declare function validateARTCompatibility(trajectory: Trajectory): {
|
|
28
|
+
valid: boolean;
|
|
29
|
+
errors: string[];
|
|
30
|
+
warnings: string[];
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=art-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"art-format.d.ts","sourceRoot":"","sources":["../art-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EAEX,UAAU,EACV,eAAe,EAEhB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,WAAW,EAAE,CAqBnE;AA0DD,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,aAAa,CAwBrE;AAkDD,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,UAAU,EAAE,GAAG,eAAe,EAAE,CAkB/E;AAED,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,UAAU,EAAE,GAAG,WAAW,EAAE,CAyB7E;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,WAAW,EAAE,EACvB,YAAY,EAAE,WAAW,EAAE,GAC1B,WAAW,EAAE,CAEf;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,GAAG;IACvD,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC;IAC1B,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;CACvC,CASA;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAEzD;AAED,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,UAAU,GAAG;IAChE,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAqCA"}
|
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../build.ts"],"names":[],"mappings":""}
|
package/dist/export.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trajectory Export Utilities
|
|
3
|
+
*
|
|
4
|
+
* The original implementation targeted a Babylon-specific database + HuggingFace upload pipeline.
|
|
5
|
+
* In elizaOS core, this module is storage-agnostic and focuses on preparing files for downstream
|
|
6
|
+
* training (JSONL / grouped JSON).
|
|
7
|
+
*/
|
|
8
|
+
import type { Trajectory } from "./types";
|
|
9
|
+
export interface ExportOptions {
|
|
10
|
+
datasetName: string;
|
|
11
|
+
huggingFaceToken?: string;
|
|
12
|
+
startDate?: Date;
|
|
13
|
+
endDate?: Date;
|
|
14
|
+
agentIds?: string[];
|
|
15
|
+
scenarioIds?: string[];
|
|
16
|
+
minReward?: number;
|
|
17
|
+
maxReward?: number;
|
|
18
|
+
includeJudged?: boolean;
|
|
19
|
+
maxTrajectories?: number;
|
|
20
|
+
format?: "jsonl" | "parquet" | "arrow";
|
|
21
|
+
splitRatio?: {
|
|
22
|
+
train: number;
|
|
23
|
+
validation: number;
|
|
24
|
+
test: number;
|
|
25
|
+
};
|
|
26
|
+
trajectories?: Trajectory[];
|
|
27
|
+
outputPath?: string;
|
|
28
|
+
outputDir?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ExportResult {
|
|
31
|
+
success: boolean;
|
|
32
|
+
trajectoriesExported: number;
|
|
33
|
+
datasetUrl?: string;
|
|
34
|
+
error?: string;
|
|
35
|
+
}
|
|
36
|
+
export declare function exportToHuggingFace(options: ExportOptions): Promise<ExportResult>;
|
|
37
|
+
export declare function exportGroupedByScenario(options: ExportOptions): Promise<ExportResult>;
|
|
38
|
+
export declare function exportForOpenPipeART(options: ExportOptions): Promise<ExportResult>;
|
|
39
|
+
export declare function exportGroupedForGRPO(options: ExportOptions): Promise<ExportResult>;
|
|
40
|
+
//# sourceMappingURL=export.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../export.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,SAAS,CAAC;AAE3D,MAAM,WAAW,aAAa;IAE5B,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAG1B,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IAGxB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;IACvC,UAAU,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAGjE,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;IAG5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAKvF;AAED,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAa3F;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAQxF;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAQxF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Game-Knowledge Rewards
|
|
3
|
+
*
|
|
4
|
+
* Compute rewards using perfect game information for RL training.
|
|
5
|
+
*
|
|
6
|
+
* @remarks These helpers are intentionally lightweight; environments can provide richer
|
|
7
|
+
* reward computation by writing into `trajectory.totalReward` and `step.reward`.
|
|
8
|
+
*/
|
|
9
|
+
import type { JsonValue, Trajectory, TrajectoryStep } from "./types";
|
|
10
|
+
export declare function computeTrajectoryReward(trajectory: Trajectory): number;
|
|
11
|
+
export declare function computeStepReward(step: TrajectoryStep): number;
|
|
12
|
+
export declare function buildGameStateFromDB(_trajectoryId: string): Promise<Record<string, JsonValue>>;
|
|
13
|
+
export declare function recomputeTrajectoryRewards(_trajectoryIds: string[]): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=game-rewards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"game-rewards.d.ts","sourceRoot":"","sources":["../game-rewards.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAErE,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAEtE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAE9D;AAED,wBAAsB,oBAAoB,CACxC,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAEpC;AAED,wBAAsB,0BAA0B,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAExF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated canonical action/provider/evaluator docs for plugin-trajectory-logger.
|
|
3
|
+
* DO NOT EDIT - Generated from prompts/specs/**.
|
|
4
|
+
*/
|
|
5
|
+
export type ActionDoc = {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
similes?: readonly string[];
|
|
9
|
+
parameters?: readonly unknown[];
|
|
10
|
+
examples?: readonly (readonly unknown[])[];
|
|
11
|
+
};
|
|
12
|
+
export type ProviderDoc = {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
position?: number;
|
|
16
|
+
dynamic?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type EvaluatorDoc = {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
similes?: readonly string[];
|
|
22
|
+
alwaysRun?: boolean;
|
|
23
|
+
examples?: readonly unknown[];
|
|
24
|
+
};
|
|
25
|
+
export declare const coreActionsSpec: {
|
|
26
|
+
readonly version: "1.0.0";
|
|
27
|
+
readonly actions: readonly [];
|
|
28
|
+
};
|
|
29
|
+
export declare const allActionsSpec: {
|
|
30
|
+
readonly version: "1.0.0";
|
|
31
|
+
readonly actions: readonly [];
|
|
32
|
+
};
|
|
33
|
+
export declare const coreProvidersSpec: {
|
|
34
|
+
readonly version: "1.0.0";
|
|
35
|
+
readonly providers: readonly [];
|
|
36
|
+
};
|
|
37
|
+
export declare const allProvidersSpec: {
|
|
38
|
+
readonly version: "1.0.0";
|
|
39
|
+
readonly providers: readonly [];
|
|
40
|
+
};
|
|
41
|
+
export declare const coreEvaluatorsSpec: {
|
|
42
|
+
readonly version: "1.0.0";
|
|
43
|
+
readonly evaluators: readonly [];
|
|
44
|
+
};
|
|
45
|
+
export declare const allEvaluatorsSpec: {
|
|
46
|
+
readonly version: "1.0.0";
|
|
47
|
+
readonly evaluators: readonly [];
|
|
48
|
+
};
|
|
49
|
+
export declare const coreActionDocs: readonly ActionDoc[];
|
|
50
|
+
export declare const allActionDocs: readonly ActionDoc[];
|
|
51
|
+
export declare const coreProviderDocs: readonly ProviderDoc[];
|
|
52
|
+
export declare const allProviderDocs: readonly ProviderDoc[];
|
|
53
|
+
export declare const coreEvaluatorDocs: readonly EvaluatorDoc[];
|
|
54
|
+
export declare const allEvaluatorDocs: readonly EvaluatorDoc[];
|
|
55
|
+
//# sourceMappingURL=specs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specs.d.ts","sourceRoot":"","sources":["../../../generated/specs/specs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,UAAU,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IAChC,QAAQ,CAAC,EAAE,SAAS,CAAC,SAAS,OAAO,EAAE,CAAC,EAAE,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,eAAe;;;CAGlB,CAAC;AACX,eAAO,MAAM,cAAc;;;CAGjB,CAAC;AACX,eAAO,MAAM,iBAAiB;;;CAGpB,CAAC;AACX,eAAO,MAAM,gBAAgB;;;CAGnB,CAAC;AACX,eAAO,MAAM,kBAAkB;;;CAGrB,CAAC;AACX,eAAO,MAAM,iBAAiB;;;CAGpB,CAAC;AAEX,eAAO,MAAM,cAAc,EAAE,SAAS,SAAS,EAA4B,CAAC;AAC5E,eAAO,MAAM,aAAa,EAAE,SAAS,SAAS,EAA2B,CAAC;AAC1E,eAAO,MAAM,gBAAgB,EAAE,SAAS,WAAW,EAAgC,CAAC;AACpF,eAAO,MAAM,eAAe,EAAE,SAAS,WAAW,EAA+B,CAAC;AAClF,eAAO,MAAM,iBAAiB,EAAE,SAAS,YAAY,EAAkC,CAAC;AACxF,eAAO,MAAM,gBAAgB,EAAE,SAAS,YAAY,EAAiC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../index.browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AAK3D,eAAO,MAAM,sBAAsB,EAAE,MAQpC,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Plugin } from "@elizaos/core";
|
|
2
|
+
/**
|
|
3
|
+
* Trajectory Logger Plugin
|
|
4
|
+
*
|
|
5
|
+
* Collects complete agent interaction trajectories for RL training.
|
|
6
|
+
* Records LLM calls, provider access, actions, environment state, and computes rewards.
|
|
7
|
+
*
|
|
8
|
+
* @remarks TrajectoryLoggerService is exported but not registered as a service
|
|
9
|
+
* since it doesn't implement the core Service interface. Use the exported helpers directly.
|
|
10
|
+
*/
|
|
11
|
+
export declare const trajectoryLoggerPlugin: Plugin;
|
|
12
|
+
export default trajectoryLoggerPlugin;
|
|
13
|
+
export * from "./action-interceptor";
|
|
14
|
+
export * from "./art-format";
|
|
15
|
+
export * from "./export";
|
|
16
|
+
export * from "./game-rewards";
|
|
17
|
+
export * from "./integration";
|
|
18
|
+
export * from "./reward-service";
|
|
19
|
+
export { TrajectoryLoggerService } from "./TrajectoryLoggerService";
|
|
20
|
+
export * from "./types";
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAMpC,CAAC;AAEF,eAAe,sBAAsB,CAAC;AAMtC,cAAc,sBAAsB,CAAC;AAIrC,cAAc,cAAc,CAAC;AAI7B,cAAc,UAAU,CAAC;AAKzB,cAAc,gBAAgB,CAAC;AAI/B,cAAc,eAAe,CAAC;AAI9B,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAIpE,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manual Instrumentation Helpers
|
|
3
|
+
*
|
|
4
|
+
* Advanced manual control for trajectory logging.
|
|
5
|
+
*/
|
|
6
|
+
import type { TrajectoryLoggerService } from "./TrajectoryLoggerService";
|
|
7
|
+
import type { JsonValue } from "./types";
|
|
8
|
+
export interface TrajectoryMetadata {
|
|
9
|
+
[key: string]: JsonValue;
|
|
10
|
+
}
|
|
11
|
+
export type FinalMetrics = Record<string, JsonValue> & {
|
|
12
|
+
totalReward?: number;
|
|
13
|
+
stepCount?: number;
|
|
14
|
+
successRate?: number;
|
|
15
|
+
};
|
|
16
|
+
export interface ProviderAccessData {
|
|
17
|
+
[key: string]: JsonValue;
|
|
18
|
+
}
|
|
19
|
+
export type WrappedFunctionArgs = JsonValue[];
|
|
20
|
+
export declare function startAutonomousTick(trajectoryLogger: TrajectoryLoggerService, context: {
|
|
21
|
+
agentId: string;
|
|
22
|
+
scenarioId?: string;
|
|
23
|
+
episodeId?: string;
|
|
24
|
+
batchId?: string;
|
|
25
|
+
metadata?: TrajectoryMetadata;
|
|
26
|
+
}): string;
|
|
27
|
+
export declare function endAutonomousTick(trajectoryLogger: TrajectoryLoggerService, trajectoryId: string, status?: "completed" | "terminated" | "error" | "timeout", finalMetrics?: FinalMetrics): Promise<void>;
|
|
28
|
+
export declare function loggedLLMCall(trajectoryLogger: TrajectoryLoggerService, trajectoryId: string, options: {
|
|
29
|
+
model: string;
|
|
30
|
+
modelVersion?: string;
|
|
31
|
+
systemPrompt: string;
|
|
32
|
+
userPrompt: string;
|
|
33
|
+
temperature?: number;
|
|
34
|
+
maxTokens?: number;
|
|
35
|
+
purpose?: "action" | "reasoning" | "evaluation" | "response" | "other";
|
|
36
|
+
actionType?: string;
|
|
37
|
+
}, llmCallFn: () => Promise<{
|
|
38
|
+
text: string;
|
|
39
|
+
reasoning?: string;
|
|
40
|
+
tokens?: {
|
|
41
|
+
prompt?: number;
|
|
42
|
+
completion?: number;
|
|
43
|
+
};
|
|
44
|
+
latencyMs?: number;
|
|
45
|
+
}>): Promise<string>;
|
|
46
|
+
export declare function logProviderAccess(trajectoryLogger: TrajectoryLoggerService, trajectoryId: string, access: {
|
|
47
|
+
providerName: string;
|
|
48
|
+
data: ProviderAccessData;
|
|
49
|
+
purpose: string;
|
|
50
|
+
query?: ProviderAccessData;
|
|
51
|
+
}): void;
|
|
52
|
+
type AsyncFunction<TArgs extends JsonValue[], TResult extends JsonValue> = (...args: TArgs) => Promise<TResult>;
|
|
53
|
+
export declare function withTrajectoryLogging<TArgs extends JsonValue[], TResult extends JsonValue>(fn: AsyncFunction<TArgs, TResult>, trajectoryLogger: TrajectoryLoggerService, trajectoryId: string, context?: {
|
|
54
|
+
actionType?: string;
|
|
55
|
+
purpose?: string;
|
|
56
|
+
}): AsyncFunction<TArgs, TResult>;
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=integration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../integration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,SAAS,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG;IACrD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,WAAW,kBAAkB;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED,MAAM,MAAM,mBAAmB,GAAG,SAAS,EAAE,CAAC;AAE9C,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,uBAAuB,EACzC,OAAO,EAAE;IACP,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B,GACA,MAAM,CAqBR;AAED,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,uBAAuB,EACzC,YAAY,EAAE,MAAM,EACpB,MAAM,GAAE,WAAW,GAAG,YAAY,GAAG,OAAO,GAAG,SAAuB,EACtE,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,IAAI,CAAC,CAIf;AAED,wBAAsB,aAAa,CACjC,gBAAgB,EAAE,uBAAuB,EACzC,YAAY,EAAE,MAAM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