@digipair/skill-debug 0.29.4 → 0.29.6
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/index.cjs.js +23 -41
- package/index.esm.js +23 -41
- package/libs/skill-logger/src/lib/skill-logger.d.ts +4 -7
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -20,6 +20,19 @@ let LoggerService = class LoggerService {
|
|
|
20
20
|
recursive: true
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
+
async addLog(context, type, message) {
|
|
24
|
+
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
25
|
+
const DIGIPAIR_LOGS_PATH = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs';
|
|
26
|
+
const current = new Date();
|
|
27
|
+
const line = {
|
|
28
|
+
date: current.getTime(),
|
|
29
|
+
digipair: context.request.digipair,
|
|
30
|
+
reasoning: context.request.reasoning,
|
|
31
|
+
type,
|
|
32
|
+
message
|
|
33
|
+
};
|
|
34
|
+
await fs.promises.appendFile(`${DIGIPAIR_LOGS_PATH}/factory/${current.toISOString().split('T')[0]}.jsonl`, '\n' + JSON.stringify(line), 'utf8');
|
|
35
|
+
}
|
|
23
36
|
async addConsumption(context, service, model, promptTokens, completionTokens) {
|
|
24
37
|
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
25
38
|
const DIGIPAIR_LOGS_PATH = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs';
|
|
@@ -45,6 +58,7 @@ let LoggerService = class LoggerService {
|
|
|
45
58
|
let line = acc.find((line)=>line.digipair === curr.digipair && line.reasoning === curr.reasoning && line.service === curr.service && line.model === curr.model);
|
|
46
59
|
if (!line) {
|
|
47
60
|
line = {
|
|
61
|
+
date,
|
|
48
62
|
digipair: curr.digipair,
|
|
49
63
|
reasoning: curr.reasoning,
|
|
50
64
|
service: curr.service,
|
|
@@ -56,59 +70,27 @@ let LoggerService = class LoggerService {
|
|
|
56
70
|
}
|
|
57
71
|
line.promptTokens += curr.promptTokens;
|
|
58
72
|
line.completionTokens += curr.completionTokens;
|
|
73
|
+
return acc;
|
|
59
74
|
}, []);
|
|
60
75
|
await fs.promises.appendFile(`${path}/consumption-monthly/${date.substring(0, 7)}.jsonl`, '\n' + dayLines.map((line)=>JSON.stringify(line)).join('\n'), 'utf8');
|
|
61
76
|
}
|
|
62
|
-
async
|
|
63
|
-
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
64
|
-
const { date, path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
65
|
-
const text = await fs.promises.readFile(`${path}/consumption-daily/${date}.jsonl`, 'utf8');
|
|
66
|
-
const lines = text.split('\n').filter((line)=>line !== '');
|
|
67
|
-
const result = lines.map((line)=>JSON.parse(line));
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
async dailyConsumptions(params, _pinsSettingsList, context) {
|
|
77
|
+
async read(params, _pinsSettingsList, context) {
|
|
71
78
|
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
72
|
-
const { path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
73
|
-
const
|
|
74
|
-
return files;
|
|
75
|
-
}
|
|
76
|
-
async monthlyConsumptions(params, _pinsSettingsList, context) {
|
|
77
|
-
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
78
|
-
const { path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
79
|
-
const files = (await fs.promises.readdir(`${path}/consumption-monthly`)).map((file)=>file.split('.')[0]);
|
|
80
|
-
return files;
|
|
81
|
-
}
|
|
82
|
-
async addLog(context, type, message) {
|
|
83
|
-
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
84
|
-
const DIGIPAIR_LOGS_PATH = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs';
|
|
85
|
-
const current = new Date();
|
|
86
|
-
const line = {
|
|
87
|
-
date: current.getTime(),
|
|
88
|
-
digipair: context.request.digipair,
|
|
89
|
-
reasoning: context.request.reasoning,
|
|
90
|
-
type,
|
|
91
|
-
message
|
|
92
|
-
};
|
|
93
|
-
await fs.promises.appendFile(`${DIGIPAIR_LOGS_PATH}/factory/${current.toISOString().split('T')[0]}.jsonl`, '\n' + JSON.stringify(line), 'utf8');
|
|
94
|
-
}
|
|
95
|
-
async logs(params, _pinsSettingsList, context) {
|
|
96
|
-
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
97
|
-
const { date, path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
98
|
-
const text = await fs.promises.readFile(`${path}/factory/${date}.jsonl`, 'utf8');
|
|
79
|
+
const { date, type = 'factory', path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
80
|
+
const text = await fs.promises.readFile(`${path}/${type}/${date}.jsonl`, 'utf8');
|
|
99
81
|
const lines = text.split('\n').filter((line)=>line !== '');
|
|
100
82
|
const result = lines.map((line)=>JSON.parse(line));
|
|
101
83
|
return result;
|
|
102
84
|
}
|
|
103
|
-
async
|
|
85
|
+
async list(params, _pinsSettingsList, context) {
|
|
104
86
|
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
105
|
-
const { path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
106
|
-
const files = (await fs.promises.readdir(`${path}
|
|
87
|
+
const { type = 'factory', path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
88
|
+
const files = (await fs.promises.readdir(`${path}/${type}`)).filter((file)=>/\.jsonl$/g.test(file)).map((file)=>file.split('.')[0]);
|
|
107
89
|
return files;
|
|
108
90
|
}
|
|
109
|
-
async
|
|
91
|
+
async cleaning(params, _pinsSettingsList, context) {
|
|
110
92
|
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
111
|
-
const { type, to, path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
93
|
+
const { type = 'factory', to, path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
112
94
|
const files = await fs.promises.readdir(`${path}/${type}`);
|
|
113
95
|
for (const file of files){
|
|
114
96
|
const stats = await fs.promises.stat(`${path}/${type}/${file}`);
|
package/index.esm.js
CHANGED
|
@@ -16,6 +16,19 @@ let LoggerService = class LoggerService {
|
|
|
16
16
|
recursive: true
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
+
async addLog(context, type, message) {
|
|
20
|
+
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
21
|
+
const DIGIPAIR_LOGS_PATH = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs';
|
|
22
|
+
const current = new Date();
|
|
23
|
+
const line = {
|
|
24
|
+
date: current.getTime(),
|
|
25
|
+
digipair: context.request.digipair,
|
|
26
|
+
reasoning: context.request.reasoning,
|
|
27
|
+
type,
|
|
28
|
+
message
|
|
29
|
+
};
|
|
30
|
+
await promises.appendFile(`${DIGIPAIR_LOGS_PATH}/factory/${current.toISOString().split('T')[0]}.jsonl`, '\n' + JSON.stringify(line), 'utf8');
|
|
31
|
+
}
|
|
19
32
|
async addConsumption(context, service, model, promptTokens, completionTokens) {
|
|
20
33
|
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
21
34
|
const DIGIPAIR_LOGS_PATH = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs';
|
|
@@ -41,6 +54,7 @@ let LoggerService = class LoggerService {
|
|
|
41
54
|
let line = acc.find((line)=>line.digipair === curr.digipair && line.reasoning === curr.reasoning && line.service === curr.service && line.model === curr.model);
|
|
42
55
|
if (!line) {
|
|
43
56
|
line = {
|
|
57
|
+
date,
|
|
44
58
|
digipair: curr.digipair,
|
|
45
59
|
reasoning: curr.reasoning,
|
|
46
60
|
service: curr.service,
|
|
@@ -52,59 +66,27 @@ let LoggerService = class LoggerService {
|
|
|
52
66
|
}
|
|
53
67
|
line.promptTokens += curr.promptTokens;
|
|
54
68
|
line.completionTokens += curr.completionTokens;
|
|
69
|
+
return acc;
|
|
55
70
|
}, []);
|
|
56
71
|
await promises.appendFile(`${path}/consumption-monthly/${date.substring(0, 7)}.jsonl`, '\n' + dayLines.map((line)=>JSON.stringify(line)).join('\n'), 'utf8');
|
|
57
72
|
}
|
|
58
|
-
async
|
|
59
|
-
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
60
|
-
const { date, path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
61
|
-
const text = await promises.readFile(`${path}/consumption-daily/${date}.jsonl`, 'utf8');
|
|
62
|
-
const lines = text.split('\n').filter((line)=>line !== '');
|
|
63
|
-
const result = lines.map((line)=>JSON.parse(line));
|
|
64
|
-
return result;
|
|
65
|
-
}
|
|
66
|
-
async dailyConsumptions(params, _pinsSettingsList, context) {
|
|
73
|
+
async read(params, _pinsSettingsList, context) {
|
|
67
74
|
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
68
|
-
const { path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
69
|
-
const
|
|
70
|
-
return files;
|
|
71
|
-
}
|
|
72
|
-
async monthlyConsumptions(params, _pinsSettingsList, context) {
|
|
73
|
-
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
74
|
-
const { path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
75
|
-
const files = (await promises.readdir(`${path}/consumption-monthly`)).map((file)=>file.split('.')[0]);
|
|
76
|
-
return files;
|
|
77
|
-
}
|
|
78
|
-
async addLog(context, type, message) {
|
|
79
|
-
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
80
|
-
const DIGIPAIR_LOGS_PATH = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs';
|
|
81
|
-
const current = new Date();
|
|
82
|
-
const line = {
|
|
83
|
-
date: current.getTime(),
|
|
84
|
-
digipair: context.request.digipair,
|
|
85
|
-
reasoning: context.request.reasoning,
|
|
86
|
-
type,
|
|
87
|
-
message
|
|
88
|
-
};
|
|
89
|
-
await promises.appendFile(`${DIGIPAIR_LOGS_PATH}/factory/${current.toISOString().split('T')[0]}.jsonl`, '\n' + JSON.stringify(line), 'utf8');
|
|
90
|
-
}
|
|
91
|
-
async logs(params, _pinsSettingsList, context) {
|
|
92
|
-
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
93
|
-
const { date, path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
94
|
-
const text = await promises.readFile(`${path}/factory/${date}.jsonl`, 'utf8');
|
|
75
|
+
const { date, type = 'factory', path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
76
|
+
const text = await promises.readFile(`${path}/${type}/${date}.jsonl`, 'utf8');
|
|
95
77
|
const lines = text.split('\n').filter((line)=>line !== '');
|
|
96
78
|
const result = lines.map((line)=>JSON.parse(line));
|
|
97
79
|
return result;
|
|
98
80
|
}
|
|
99
|
-
async
|
|
81
|
+
async list(params, _pinsSettingsList, context) {
|
|
100
82
|
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
101
|
-
const { path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
102
|
-
const files = (await promises.readdir(`${path}
|
|
83
|
+
const { type = 'factory', path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
84
|
+
const files = (await promises.readdir(`${path}/${type}`)).filter((file)=>/\.jsonl$/g.test(file)).map((file)=>file.split('.')[0]);
|
|
103
85
|
return files;
|
|
104
86
|
}
|
|
105
|
-
async
|
|
87
|
+
async cleaning(params, _pinsSettingsList, context) {
|
|
106
88
|
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
|
107
|
-
const { type, to, path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
89
|
+
const { type = 'factory', to, path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
108
90
|
const files = await promises.readdir(`${path}/${type}`);
|
|
109
91
|
for (const file of files){
|
|
110
92
|
const stats = await promises.stat(`${path}/${type}/${file}`);
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { PinsSettings } from '@digipair/engine';
|
|
2
2
|
export declare const initialize: (path?: string) => Promise<void>;
|
|
3
|
+
export declare const addLog: (context: any, type: string, message: string) => Promise<void>;
|
|
3
4
|
export declare const addConsumption: (context: any, service: string, model: string, promptTokens: number, completionTokens: number) => Promise<void>;
|
|
4
5
|
export declare const computeDailyConsumption: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<void>;
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const addLog: (context: any, type: string, message: string) => Promise<void>;
|
|
9
|
-
export declare const logs: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any[]>;
|
|
10
|
-
export declare const dailyLogs: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<string[]>;
|
|
11
|
-
export declare const clearOldLogs: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<void>;
|
|
6
|
+
export declare const read: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any[]>;
|
|
7
|
+
export declare const list: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<string[]>;
|
|
8
|
+
export declare const cleaning: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<void>;
|