@digipair/skill-logger 0.28.4 → 0.28.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 +19 -19
- package/index.esm.js +19 -19
- package/package.json +1 -1
package/index.cjs.js
CHANGED
@@ -6,7 +6,7 @@ var fs = require('fs');
|
|
6
6
|
|
7
7
|
var _process_env_DIGIPAIR_LOGS_PATH;
|
8
8
|
let LoggerService = class LoggerService {
|
9
|
-
async initialize(path = (_process_env_DIGIPAIR_LOGS_PATH = process.env['DIGIPAIR_LOGS_PATH']) != null ? _process_env_DIGIPAIR_LOGS_PATH : './factory/
|
9
|
+
async initialize(path = (_process_env_DIGIPAIR_LOGS_PATH = process.env['DIGIPAIR_LOGS_PATH']) != null ? _process_env_DIGIPAIR_LOGS_PATH : './factory/logs') {
|
10
10
|
// create logs directory if it doesn't exist
|
11
11
|
await fs.promises.mkdir(`${path}/factory`, {
|
12
12
|
recursive: true
|
@@ -21,8 +21,8 @@ let LoggerService = class LoggerService {
|
|
21
21
|
});
|
22
22
|
}
|
23
23
|
async addConsumption(context, service, model, promptTokens, completionTokens) {
|
24
|
-
var
|
25
|
-
const DIGIPAIR_LOGS_PATH = (_ref = (
|
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
26
|
const current = new Date();
|
27
27
|
const line = {
|
28
28
|
date: current.getTime(),
|
@@ -36,8 +36,8 @@ let LoggerService = class LoggerService {
|
|
36
36
|
await fs.promises.appendFile(`${DIGIPAIR_LOGS_PATH}/consumption-daily/${current.toISOString().split('T')[0]}.jsonl`, '\n' + JSON.stringify(line), 'utf8');
|
37
37
|
}
|
38
38
|
async computeDailyConsumption(params, _pinsSettingsList, context) {
|
39
|
-
var
|
40
|
-
const { date, path = (_ref = (
|
39
|
+
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
40
|
+
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;
|
41
41
|
const text = await fs.promises.readFile(`${path}/consumption-daily/${date}.jsonl`, 'utf8');
|
42
42
|
const lines = text.split('\n').filter((line)=>line !== '');
|
43
43
|
const result = lines.map((line)=>JSON.parse(line));
|
@@ -60,28 +60,28 @@ let LoggerService = class LoggerService {
|
|
60
60
|
await fs.promises.appendFile(`${path}/consumption-monthly/${date.substring(0, 7)}.jsonl`, '\n' + dayLines.map((line)=>JSON.stringify(line)).join('\n'), 'utf8');
|
61
61
|
}
|
62
62
|
async consumptions(params, _pinsSettingsList, context) {
|
63
|
-
var
|
64
|
-
const { date, path = (_ref = (
|
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
65
|
const text = await fs.promises.readFile(`${path}/consumption-daily/${date}.jsonl`, 'utf8');
|
66
66
|
const lines = text.split('\n').filter((line)=>line !== '');
|
67
67
|
const result = lines.map((line)=>JSON.parse(line));
|
68
68
|
return result;
|
69
69
|
}
|
70
70
|
async dailyConsumptions(params, _pinsSettingsList, context) {
|
71
|
-
var
|
72
|
-
const { path = (_ref = (
|
71
|
+
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
73
|
const files = (await fs.promises.readdir(`${path}/consumption-daily`)).map((file)=>file.split('.')[0]);
|
74
74
|
return files;
|
75
75
|
}
|
76
76
|
async monthlyConsumptions(params, _pinsSettingsList, context) {
|
77
|
-
var
|
78
|
-
const { path = (_ref = (
|
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
79
|
const files = (await fs.promises.readdir(`${path}/consumption-monthly`)).map((file)=>file.split('.')[0]);
|
80
80
|
return files;
|
81
81
|
}
|
82
82
|
async addLog(context, type, message) {
|
83
|
-
var
|
84
|
-
const DIGIPAIR_LOGS_PATH = (_ref = (
|
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
85
|
const current = new Date();
|
86
86
|
const line = {
|
87
87
|
date: current.getTime(),
|
@@ -93,22 +93,22 @@ let LoggerService = class LoggerService {
|
|
93
93
|
await fs.promises.appendFile(`${DIGIPAIR_LOGS_PATH}/${current.toISOString().split('T')[0]}.jsonl`, '\n' + JSON.stringify(line), 'utf8');
|
94
94
|
}
|
95
95
|
async logs(params, _pinsSettingsList, context) {
|
96
|
-
var
|
97
|
-
const { date, path = (_ref = (
|
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
98
|
const text = await fs.promises.readFile(`${path}/factory/${date}.jsonl`, 'utf8');
|
99
99
|
const lines = text.split('\n').filter((line)=>line !== '');
|
100
100
|
const result = lines.map((line)=>JSON.parse(line));
|
101
101
|
return result;
|
102
102
|
}
|
103
103
|
async dailyLogs(params, _pinsSettingsList, context) {
|
104
|
-
var
|
105
|
-
const { path = (_ref = (
|
104
|
+
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
106
|
const files = (await fs.promises.readdir(`${path}/factory`)).filter((file)=>/\.jsonl$/g.test(file)).map((file)=>file.split('.')[0]);
|
107
107
|
return files;
|
108
108
|
}
|
109
109
|
async clearOldLogs(params, _pinsSettingsList, context) {
|
110
|
-
var
|
111
|
-
const { type, to, path = (_ref = (
|
110
|
+
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;
|
112
112
|
const files = await fs.promises.readdir(`${path}/${type}`);
|
113
113
|
for (const file of files){
|
114
114
|
const stats = await fs.promises.stat(`${path}/${type}/${file}`);
|
package/index.esm.js
CHANGED
@@ -2,7 +2,7 @@ import { promises } from 'fs';
|
|
2
2
|
|
3
3
|
var _process_env_DIGIPAIR_LOGS_PATH;
|
4
4
|
let LoggerService = class LoggerService {
|
5
|
-
async initialize(path = (_process_env_DIGIPAIR_LOGS_PATH = process.env['DIGIPAIR_LOGS_PATH']) != null ? _process_env_DIGIPAIR_LOGS_PATH : './factory/
|
5
|
+
async initialize(path = (_process_env_DIGIPAIR_LOGS_PATH = process.env['DIGIPAIR_LOGS_PATH']) != null ? _process_env_DIGIPAIR_LOGS_PATH : './factory/logs') {
|
6
6
|
// create logs directory if it doesn't exist
|
7
7
|
await promises.mkdir(`${path}/factory`, {
|
8
8
|
recursive: true
|
@@ -17,8 +17,8 @@ let LoggerService = class LoggerService {
|
|
17
17
|
});
|
18
18
|
}
|
19
19
|
async addConsumption(context, service, model, promptTokens, completionTokens) {
|
20
|
-
var
|
21
|
-
const DIGIPAIR_LOGS_PATH = (_ref = (
|
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
22
|
const current = new Date();
|
23
23
|
const line = {
|
24
24
|
date: current.getTime(),
|
@@ -32,8 +32,8 @@ let LoggerService = class LoggerService {
|
|
32
32
|
await promises.appendFile(`${DIGIPAIR_LOGS_PATH}/consumption-daily/${current.toISOString().split('T')[0]}.jsonl`, '\n' + JSON.stringify(line), 'utf8');
|
33
33
|
}
|
34
34
|
async computeDailyConsumption(params, _pinsSettingsList, context) {
|
35
|
-
var
|
36
|
-
const { date, path = (_ref = (
|
35
|
+
var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
|
36
|
+
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;
|
37
37
|
const text = await promises.readFile(`${path}/consumption-daily/${date}.jsonl`, 'utf8');
|
38
38
|
const lines = text.split('\n').filter((line)=>line !== '');
|
39
39
|
const result = lines.map((line)=>JSON.parse(line));
|
@@ -56,28 +56,28 @@ let LoggerService = class LoggerService {
|
|
56
56
|
await promises.appendFile(`${path}/consumption-monthly/${date.substring(0, 7)}.jsonl`, '\n' + dayLines.map((line)=>JSON.stringify(line)).join('\n'), 'utf8');
|
57
57
|
}
|
58
58
|
async consumptions(params, _pinsSettingsList, context) {
|
59
|
-
var
|
60
|
-
const { date, path = (_ref = (
|
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
61
|
const text = await promises.readFile(`${path}/consumption-daily/${date}.jsonl`, 'utf8');
|
62
62
|
const lines = text.split('\n').filter((line)=>line !== '');
|
63
63
|
const result = lines.map((line)=>JSON.parse(line));
|
64
64
|
return result;
|
65
65
|
}
|
66
66
|
async dailyConsumptions(params, _pinsSettingsList, context) {
|
67
|
-
var
|
68
|
-
const { path = (_ref = (
|
67
|
+
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
69
|
const files = (await promises.readdir(`${path}/consumption-daily`)).map((file)=>file.split('.')[0]);
|
70
70
|
return files;
|
71
71
|
}
|
72
72
|
async monthlyConsumptions(params, _pinsSettingsList, context) {
|
73
|
-
var
|
74
|
-
const { path = (_ref = (
|
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
75
|
const files = (await promises.readdir(`${path}/consumption-monthly`)).map((file)=>file.split('.')[0]);
|
76
76
|
return files;
|
77
77
|
}
|
78
78
|
async addLog(context, type, message) {
|
79
|
-
var
|
80
|
-
const DIGIPAIR_LOGS_PATH = (_ref = (
|
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
81
|
const current = new Date();
|
82
82
|
const line = {
|
83
83
|
date: current.getTime(),
|
@@ -89,22 +89,22 @@ let LoggerService = class LoggerService {
|
|
89
89
|
await promises.appendFile(`${DIGIPAIR_LOGS_PATH}/${current.toISOString().split('T')[0]}.jsonl`, '\n' + JSON.stringify(line), 'utf8');
|
90
90
|
}
|
91
91
|
async logs(params, _pinsSettingsList, context) {
|
92
|
-
var
|
93
|
-
const { date, path = (_ref = (
|
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
94
|
const text = await promises.readFile(`${path}/factory/${date}.jsonl`, 'utf8');
|
95
95
|
const lines = text.split('\n').filter((line)=>line !== '');
|
96
96
|
const result = lines.map((line)=>JSON.parse(line));
|
97
97
|
return result;
|
98
98
|
}
|
99
99
|
async dailyLogs(params, _pinsSettingsList, context) {
|
100
|
-
var
|
101
|
-
const { path = (_ref = (
|
100
|
+
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
102
|
const files = (await promises.readdir(`${path}/factory`)).filter((file)=>/\.jsonl$/g.test(file)).map((file)=>file.split('.')[0]);
|
103
103
|
return files;
|
104
104
|
}
|
105
105
|
async clearOldLogs(params, _pinsSettingsList, context) {
|
106
|
-
var
|
107
|
-
const { type, to, path = (_ref = (
|
106
|
+
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;
|
108
108
|
const files = await promises.readdir(`${path}/${type}`);
|
109
109
|
for (const file of files){
|
110
110
|
const stats = await promises.stat(`${path}/${type}/${file}`);
|