@volcengine/tls-observer-trae 0.0.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.
@@ -0,0 +1,8 @@
1
+ import type { TurnStartState, TurnStateFile } from './types';
2
+ export declare function loadState(stateFilePath: string): TurnStateFile;
3
+ export declare function getSessionState(state: TurnStateFile, sessionId: string): TurnStartState;
4
+ export declare function pruneOldSessions(state: TurnStateFile, now?: number): TurnStateFile;
5
+ export declare function atomicUpdateState(stateFilePath: string, fn: (state: TurnStateFile) => TurnStateFile): Promise<void>;
6
+ export declare function clearedActiveSession(session: TurnStartState, updates?: Partial<TurnStartState>): TurnStartState;
7
+ export declare function saveTurnStartState(stateFilePath: string, turn: TurnStartState): Promise<void>;
8
+ export declare function readTurnStartState(stateFilePath: string, sessionId: string): TurnStartState | undefined;
@@ -0,0 +1 @@
1
+ export declare function readStdinJson<T>(): Promise<T>;
@@ -0,0 +1,3 @@
1
+ import type { Config, TraceTraeOptions } from './types';
2
+ export declare function writeSendLog(config: Config, record: Record<string, unknown>): Promise<void>;
3
+ export declare function traceTraeSession(options: TraceTraeOptions): Promise<Record<string, unknown>>;
@@ -0,0 +1,78 @@
1
+ export type HookInput = Record<string, any>;
2
+ export interface Config {
3
+ enabled: boolean;
4
+ dataRoot: string;
5
+ turnStateFilePath: string;
6
+ sendLogsDir: string;
7
+ diagnosticLogMaxBytes: number;
8
+ diagnosticLogMaxFiles: number;
9
+ captureContent: boolean;
10
+ debugArtifacts: boolean;
11
+ serviceName: string;
12
+ serviceInstanceId: string;
13
+ ctxCli: string;
14
+ ctxCliTimeoutMs: number;
15
+ tlsEndpoint?: string;
16
+ otelEndpoint?: string;
17
+ region?: string;
18
+ traceTopicId?: string;
19
+ apiKey?: string;
20
+ ak?: string;
21
+ sk?: string;
22
+ authMode: 'header' | 'resource';
23
+ exportTimeoutMs: number;
24
+ exportTimeoutRetries: number;
25
+ }
26
+ export interface ContextFsTurn {
27
+ files: string[];
28
+ messages: Record<string, any>[];
29
+ errors: string[];
30
+ missingEnv?: string[];
31
+ envStatus?: {
32
+ ready: boolean;
33
+ cfsTokenPresent: boolean;
34
+ cfsIpcNamePresent: boolean;
35
+ cfsTransport: string;
36
+ };
37
+ }
38
+ export interface TraceTraeOptions {
39
+ input: HookInput;
40
+ config: Config;
41
+ }
42
+ export interface TokenUsage {
43
+ input_tokens?: number;
44
+ output_tokens?: number;
45
+ cache_read_input_tokens?: number;
46
+ reasoning_output_tokens?: number;
47
+ total_tokens?: number;
48
+ estimated?: boolean;
49
+ token_estimate_method?: string;
50
+ }
51
+ export interface PendingToolUse {
52
+ tool_call_id: string;
53
+ tool_name?: string;
54
+ llm_tool_name?: string;
55
+ tool_input?: unknown;
56
+ start_time_ms?: number;
57
+ timestamp?: string;
58
+ }
59
+ export interface TurnStartState {
60
+ sessionId: string;
61
+ active?: boolean;
62
+ turnId?: string;
63
+ cwd?: string;
64
+ agentId?: string;
65
+ agentName?: string;
66
+ userName?: string;
67
+ model?: string;
68
+ hookEventName?: string;
69
+ messages?: Record<string, any>[];
70
+ usage?: TokenUsage;
71
+ pendingToolUses?: Record<string, PendingToolUse>;
72
+ createdAt: string;
73
+ updatedAt: string;
74
+ }
75
+ export interface TurnStateFile {
76
+ version: 1;
77
+ sessions: Record<string, TurnStartState>;
78
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "version": 1,
3
+ "hooks": {
4
+ "UserPromptSubmit": [
5
+ {
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "node ./dist/index.js",
10
+ "timeout": 30
11
+ }
12
+ ]
13
+ }
14
+ ],
15
+ "PreToolUse": [
16
+ {
17
+ "hooks": [
18
+ {
19
+ "type": "command",
20
+ "command": "node ./dist/index.js",
21
+ "timeout": 30
22
+ }
23
+ ]
24
+ }
25
+ ],
26
+ "PostToolUse": [
27
+ {
28
+ "hooks": [
29
+ {
30
+ "type": "command",
31
+ "command": "node ./dist/index.js",
32
+ "timeout": 30
33
+ }
34
+ ]
35
+ }
36
+ ],
37
+ "Stop": [
38
+ {
39
+ "hooks": [
40
+ {
41
+ "type": "command",
42
+ "command": "node ./dist/index.js",
43
+ "timeout": 30
44
+ }
45
+ ]
46
+ }
47
+ ]
48
+ }
49
+ }
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@volcengine/tls-observer-trae",
3
+ "version": "0.0.2",
4
+ "description": "Export Trae hook telemetry to Volcengine TLS with OTLP traces.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
13
+ "types": "./dist/index.d.ts",
14
+ "engines": {
15
+ "node": ">=18"
16
+ },
17
+ "keywords": [
18
+ "trae",
19
+ "hooks",
20
+ "observability",
21
+ "opentelemetry",
22
+ "tls"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "dependencies": {
28
+ "@volcengine/openapi": "^1.36.1"
29
+ }
30
+ }