@digipair/skill-debug 0.29.4 → 0.29.5
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 +22 -41
- package/index.esm.js +22 -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,
|
|
@@ -59,56 +73,23 @@ let LoggerService = class LoggerService {
|
|
|
59
73
|
}, []);
|
|
60
74
|
await fs.promises.appendFile(`${path}/consumption-monthly/${date.substring(0, 7)}.jsonl`, '\n' + dayLines.map((line)=>JSON.stringify(line)).join('\n'), 'utf8');
|
|
61
75
|
}
|
|
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) {
|
|
76
|
+
async read(params, _pinsSettingsList, context) {
|
|
71
77
|
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');
|
|
78
|
+
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;
|
|
79
|
+
const text = await fs.promises.readFile(`${path}/${type}/${date}.jsonl`, 'utf8');
|
|
99
80
|
const lines = text.split('\n').filter((line)=>line !== '');
|
|
100
81
|
const result = lines.map((line)=>JSON.parse(line));
|
|
101
82
|
return result;
|
|
102
83
|
}
|
|
103
|
-
async
|
|
84
|
+
async list(params, _pinsSettingsList, context) {
|
|
104
85
|
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}
|
|
86
|
+
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;
|
|
87
|
+
const files = (await fs.promises.readdir(`${path}/${type}`)).filter((file)=>/\.jsonl$/g.test(file)).map((file)=>file.split('.')[0]);
|
|
107
88
|
return files;
|
|
108
89
|
}
|
|
109
|
-
async
|
|
90
|
+
async cleaning(params, _pinsSettingsList, context) {
|
|
110
91
|
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;
|
|
92
|
+
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
93
|
const files = await fs.promises.readdir(`${path}/${type}`);
|
|
113
94
|
for (const file of files){
|
|
114
95
|
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,
|
|
@@ -55,56 +69,23 @@ let LoggerService = class LoggerService {
|
|
|
55
69
|
}, []);
|
|
56
70
|
await promises.appendFile(`${path}/consumption-monthly/${date.substring(0, 7)}.jsonl`, '\n' + dayLines.map((line)=>JSON.stringify(line)).join('\n'), 'utf8');
|
|
57
71
|
}
|
|
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) {
|
|
72
|
+
async read(params, _pinsSettingsList, context) {
|
|
67
73
|
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');
|
|
74
|
+
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;
|
|
75
|
+
const text = await promises.readFile(`${path}/${type}/${date}.jsonl`, 'utf8');
|
|
95
76
|
const lines = text.split('\n').filter((line)=>line !== '');
|
|
96
77
|
const result = lines.map((line)=>JSON.parse(line));
|
|
97
78
|
return result;
|
|
98
79
|
}
|
|
99
|
-
async
|
|
80
|
+
async list(params, _pinsSettingsList, context) {
|
|
100
81
|
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}
|
|
82
|
+
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;
|
|
83
|
+
const files = (await promises.readdir(`${path}/${type}`)).filter((file)=>/\.jsonl$/g.test(file)).map((file)=>file.split('.')[0]);
|
|
103
84
|
return files;
|
|
104
85
|
}
|
|
105
|
-
async
|
|
86
|
+
async cleaning(params, _pinsSettingsList, context) {
|
|
106
87
|
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;
|
|
88
|
+
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
89
|
const files = await promises.readdir(`${path}/${type}`);
|
|
109
90
|
for (const file of files){
|
|
110
91
|
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>;
|