@digipair/skill-logger 0.113.1 → 0.114.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.
@@ -1 +1,2 @@
1
1
  export * from './lib/skill-logger';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -6,3 +6,4 @@ export declare const computeDailyConsumption: (params: any, pinsSettingsList: Pi
6
6
  export declare const read: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any[]>;
7
7
  export declare const list: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<string[]>;
8
8
  export declare const cleaning: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<void>;
9
+ //# sourceMappingURL=skill-logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-logger.d.ts","sourceRoot":"","sources":["../../../src/lib/skill-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAU,MAAM,kBAAkB,CAAC;AA0KxD,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,kBAAyC,CAAC;AAElF,eAAO,MAAM,MAAM,GAAI,SAAS,GAAG,EAAE,MAAM,MAAM,EAAE,SAAS,MAAM,kBACd,CAAC;AAErD,eAAO,MAAM,cAAc,GACzB,SAAS,GAAG,EACZ,SAAS,MAAM,EACf,OAAO,MAAM,EACb,cAAc,MAAM,EACpB,kBAAkB,MAAM,kBACsE,CAAC;AAMjG,eAAO,MAAM,uBAAuB,GAClC,QAAQ,GAAG,EACX,kBAAkB,YAAY,EAAE,EAChC,SAAS,GAAG,kBACqE,CAAC;AAEpF,eAAO,MAAM,IAAI,GAAI,QAAQ,GAAG,EAAE,kBAAkB,YAAY,EAAE,EAAE,SAAS,GAAG,mBACnB,CAAC;AAE9D,eAAO,MAAM,IAAI,GAAI,QAAQ,GAAG,EAAE,kBAAkB,YAAY,EAAE,EAAE,SAAS,GAAG,sBACnB,CAAC;AAE9D,eAAO,MAAM,QAAQ,GAAI,QAAQ,GAAG,EAAE,kBAAkB,YAAY,EAAE,EAAE,SAAS,GAAG,kBACnB,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,33 @@
1
1
  {
2
2
  "name": "@digipair/skill-logger",
3
- "version": "0.113.1",
3
+ "version": "0.114.2",
4
+ "main": "./dist/index.cjs.js",
5
+ "module": "./dist/index.esm.js",
6
+ "types": "./dist/index.d.ts",
4
7
  "keywords": [
5
8
  "digipair",
6
9
  "service",
7
10
  "util"
8
11
  ],
9
- "dependencies": {},
10
- "main": "./index.cjs.js",
11
- "module": "./index.esm.js"
12
- }
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.esm.js",
16
+ "default": "./dist/index.cjs.js"
17
+ },
18
+ "./index.esm.js": "./dist/index.esm.js",
19
+ "./index.cjs.js": "./dist/index.cjs.js",
20
+ "./package.json": "./package.json",
21
+ "./schema.json": "./dist/schema.json",
22
+ "./schema.fr.json": "./dist/schema.fr.json"
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "README.md",
27
+ "package.json"
28
+ ],
29
+ "nx": {
30
+ "name": "skill-logger"
31
+ },
32
+ "dependencies": {}
33
+ }
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './libs/skill-logger/src/index';
package/index.esm.js DELETED
@@ -1,122 +0,0 @@
1
- import { config } from '@digipair/engine';
2
- import { promises } from 'fs';
3
-
4
- var _process_env_DIGIPAIR_LOGS_PATH;
5
- let LoggerService = class LoggerService {
6
- async initialize(path = (_process_env_DIGIPAIR_LOGS_PATH = process.env['DIGIPAIR_LOGS_PATH']) != null ? _process_env_DIGIPAIR_LOGS_PATH : './factory/logs') {
7
- // create logs directory if it doesn't exist
8
- await promises.mkdir(`${path}/factory`, {
9
- recursive: true
10
- });
11
- // create consumption-daily directory if it doesn't exist
12
- await promises.mkdir(`${path}/consumption-daily`, {
13
- recursive: true
14
- });
15
- // create consumption-monthly directory if it doesn't exist
16
- await promises.mkdir(`${path}/consumption-monthly`, {
17
- recursive: true
18
- });
19
- }
20
- async addLog(context, type, message, data) {
21
- var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
22
- 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';
23
- const current = new Date();
24
- const line = {
25
- date: current.getTime(),
26
- digipair: context.request.digipair,
27
- reasoning: context.request.reasoning,
28
- type,
29
- message
30
- };
31
- config.log(type, context.__PATH__, message, context, data);
32
- await promises.appendFile(`${DIGIPAIR_LOGS_PATH}/factory/${current.toISOString().split('T')[0]}.jsonl`, '\n' + JSON.stringify(line), 'utf8');
33
- }
34
- async addConsumption(context, service, model, promptTokens, completionTokens) {
35
- var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
36
- 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';
37
- const current = new Date();
38
- const line = {
39
- date: current.getTime(),
40
- digipair: context.request.digipair,
41
- reasoning: context.request.reasoning,
42
- service,
43
- model,
44
- promptTokens,
45
- completionTokens
46
- };
47
- await promises.appendFile(`${DIGIPAIR_LOGS_PATH}/consumption-daily/${current.toISOString().split('T')[0]}.jsonl`, '\n' + JSON.stringify(line), 'utf8');
48
- }
49
- async computeDailyConsumption(params, _pinsSettingsList, context) {
50
- var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
51
- 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;
52
- let result;
53
- try {
54
- const text = await promises.readFile(`${path}/consumption-daily/${date}.jsonl`, 'utf8');
55
- const lines = text.split('\n').filter((line)=>line !== '');
56
- result = lines.map((line)=>JSON.parse(line));
57
- } catch (error) {
58
- result = [];
59
- }
60
- const dayLines = result.reduce((acc, curr)=>{
61
- let line = acc.find((line)=>line.digipair === curr.digipair && line.reasoning === curr.reasoning && line.service === curr.service && line.model === curr.model);
62
- if (!line) {
63
- line = {
64
- date,
65
- digipair: curr.digipair,
66
- reasoning: curr.reasoning,
67
- service: curr.service,
68
- model: curr.model,
69
- promptTokens: 0,
70
- completionTokens: 0
71
- };
72
- acc.push(line);
73
- }
74
- line.promptTokens += curr.promptTokens;
75
- line.completionTokens += curr.completionTokens;
76
- return acc;
77
- }, []);
78
- await promises.appendFile(`${path}/consumption-monthly/${date.substring(0, 7)}.jsonl`, '\n' + dayLines.map((line)=>JSON.stringify(line)).join('\n'), 'utf8');
79
- }
80
- async read(params, _pinsSettingsList, context) {
81
- var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
82
- 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;
83
- let result;
84
- try {
85
- const text = await promises.readFile(`${path}/${type}/${date}.jsonl`, 'utf8');
86
- const lines = text.split('\n').filter((line)=>line !== '');
87
- result = lines.map((line)=>JSON.parse(line));
88
- } catch (error) {
89
- result = [];
90
- }
91
- return result;
92
- }
93
- async list(params, _pinsSettingsList, context) {
94
- var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
95
- 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;
96
- const files = (await promises.readdir(`${path}/${type}`)).filter((file)=>/\.jsonl$/g.test(file)).map((file)=>file.split('.')[0]);
97
- return files;
98
- }
99
- async cleaning(params, _pinsSettingsList, context) {
100
- var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
101
- 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;
102
- const files = await promises.readdir(`${path}/${type}`);
103
- for (const file of files){
104
- const stats = await promises.stat(`${path}/${type}/${file}`);
105
- if (stats.mtime.getTime() < to) {
106
- promises.unlink(`${path}/${type}/${file}`);
107
- }
108
- }
109
- }
110
- };
111
- const initialize = (path)=>new LoggerService().initialize(path);
112
- const addLog = (context, type, message)=>new LoggerService().addLog(context, type, message);
113
- const addConsumption = (context, service, model, promptTokens, completionTokens)=>new LoggerService().addConsumption(context, service, model, promptTokens, completionTokens);
114
- // ----------------------------
115
- // Methods for the skill
116
- // ----------------------------
117
- const computeDailyConsumption = (params, pinsSettingsList, context)=>new LoggerService().computeDailyConsumption(params, pinsSettingsList, context);
118
- const read = (params, pinsSettingsList, context)=>new LoggerService().read(params, pinsSettingsList, context);
119
- const list = (params, pinsSettingsList, context)=>new LoggerService().list(params, pinsSettingsList, context);
120
- const cleaning = (params, pinsSettingsList, context)=>new LoggerService().cleaning(params, pinsSettingsList, context);
121
-
122
- export { addConsumption, addLog, cleaning, computeDailyConsumption, initialize, list, read };
File without changes
File without changes
File without changes