codebuff 1.0.201 → 1.0.203
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/dist/cli.d.ts +2 -0
- package/dist/cli.js +46 -0
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +13 -8
- package/dist/client.js +108 -11
- package/dist/client.js.map +1 -1
- package/dist/code-map/tsconfig.tsbuildinfo +1 -1
- package/dist/common/actions.d.ts +98 -116
- package/dist/common/actions.d.ts.map +1 -0
- package/dist/common/actions.js +0 -1
- package/dist/common/actions.js.map +1 -1
- package/dist/common/api-keys/constants.d.ts +8 -0
- package/dist/common/api-keys/constants.d.ts.map +1 -0
- package/dist/common/api-keys/constants.js +26 -0
- package/dist/common/api-keys/constants.js.map +1 -0
- package/dist/common/api-keys/crypto.d.ts +24 -0
- package/dist/common/api-keys/crypto.d.ts.map +1 -0
- package/dist/common/api-keys/crypto.js +186 -0
- package/dist/common/api-keys/crypto.js.map +1 -0
- package/dist/common/billing/quota-manager.d.ts.map +1 -0
- package/dist/common/browser-actions.d.ts.map +1 -0
- package/dist/common/constants/tools.d.ts.map +1 -0
- package/dist/common/constants.d.ts +2 -1
- package/dist/common/constants.d.ts.map +1 -0
- package/dist/common/constants.js +8 -3
- package/dist/common/constants.js.map +1 -1
- package/dist/common/db/drizzle.config.d.ts.map +1 -0
- package/dist/common/db/env.d.mts.map +1 -0
- package/dist/common/db/index.d.ts.map +1 -0
- package/dist/common/db/schema.d.ts +76 -0
- package/dist/common/db/schema.d.ts.map +1 -0
- package/dist/common/db/schema.js +19 -1
- package/dist/common/db/schema.js.map +1 -1
- package/dist/common/env.d.mts.map +1 -0
- package/dist/common/env.mjs +2 -1
- package/dist/common/env.mjs.map +1 -1
- package/dist/common/project-file-tree.d.ts +1 -1
- package/dist/common/project-file-tree.d.ts.map +1 -0
- package/dist/common/project-file-tree.js +39 -25
- package/dist/common/project-file-tree.js.map +1 -1
- package/dist/common/types/agent-state.d.ts +2 -2
- package/dist/common/types/agent-state.d.ts.map +1 -0
- package/dist/common/types/message.d.ts +14 -14
- package/dist/common/types/message.d.ts.map +1 -0
- package/dist/common/types/plan.d.ts.map +1 -0
- package/dist/common/types/referral.d.ts.map +1 -0
- package/dist/common/types/tools.d.ts.map +1 -0
- package/dist/common/types/usage.d.ts.map +1 -0
- package/dist/common/util/__tests__/messages.test.d.ts.map +1 -0
- package/dist/common/util/__tests__/string.test.d.ts.map +1 -0
- package/dist/common/util/array.d.ts.map +1 -0
- package/dist/common/util/changes.d.ts.map +1 -0
- package/dist/common/util/credentials.d.ts +2 -2
- package/dist/common/util/credentials.d.ts.map +1 -0
- package/dist/common/util/crypto.d.ts +27 -0
- package/dist/common/util/crypto.js +174 -0
- package/dist/common/util/crypto.js.map +1 -0
- package/dist/common/util/dates.d.ts.map +1 -0
- package/dist/common/util/file.d.ts.map +1 -0
- package/dist/common/util/git.d.ts.map +1 -0
- package/dist/common/util/logger.d.ts +8 -0
- package/dist/common/util/logger.d.ts.map +1 -0
- package/dist/common/util/logger.js +34 -0
- package/dist/common/util/logger.js.map +1 -0
- package/dist/common/util/lru-cache.d.ts.map +1 -0
- package/dist/common/util/messages.d.ts.map +1 -0
- package/dist/common/util/min-heap.d.ts.map +1 -0
- package/dist/common/util/object.d.ts.map +1 -0
- package/dist/common/util/patch.d.ts.map +1 -0
- package/dist/common/util/promise.d.ts.map +1 -0
- package/dist/common/util/referral.d.ts.map +1 -0
- package/dist/common/util/saxy.d.ts.map +1 -0
- package/dist/common/util/server/referral.d.ts.map +1 -0
- package/dist/common/util/string.d.ts.map +1 -0
- package/dist/common/util/stripe.d.ts.map +1 -0
- package/dist/common/websockets/websocket-client.d.ts.map +1 -0
- package/dist/common/websockets/websocket-schema.d.ts +180 -210
- package/dist/common/websockets/websocket-schema.d.ts.map +1 -0
- package/dist/project-files.js +1 -1
- package/dist/project-files.js.map +1 -1
- package/package.json +2 -2
- package/dist/common/advanced-analyzer.d.ts +0 -19
- package/dist/common/advanced-analyzer.js +0 -140
- package/dist/common/advanced-analyzer.js.map +0 -1
- package/dist/common/message-image-handling.d.ts +0 -41
- package/dist/common/message-image-handling.js +0 -57
- package/dist/common/message-image-handling.js.map +0 -1
- package/dist/common/util/process-stream.d.ts +0 -8
- package/dist/common/util/process-stream.js +0 -102
- package/dist/common/util/process-stream.js.map +0 -1
- package/dist/common/util/referral-credits.d.ts +0 -1
- package/dist/common/util/referral-credits.js +0 -48
- package/dist/common/util/referral-credits.js.map +0 -1
package/dist/common/env.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.mjs","sourceRoot":"","sources":["../src/env.mjs"],"names":[],"mappings":";;;;;;AAAA,+CAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"env.mjs","sourceRoot":"","sources":["../src/env.mjs"],"names":[],"mappings":";;;;;;AAAA,+CAA4C;AAC5C,oDAA2B;AAC3B,6BAAuB;AAEvB,gBAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAA;AACvC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,CAAC;IACzC,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAA;IACjE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAED,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAA;AACzE,MAAM,IAAI,GAAG,GAAG,WAAW,SAAS,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,CAAA;AACzE,OAAO,CAAC,GAAG,CACT,sBAAsB,OAAO,CAAC,GAAG,CAAC,uBAAuB,WAAW,IAAI,GAAG,CAC5E,CAAA;AACD,gBAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;AAEV,QAAA,GAAG,GAAG,IAAA,oBAAS,EAAC;IAC3B,MAAM,EAAE;QACN,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9B,uBAAuB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1C,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/B,iBAAiB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACpC,yBAAyB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5C,yBAAyB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,sDAAsD,CAAC;KACzG;IACD,MAAM,EAAE;QACN,uBAAuB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1C,mBAAmB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACtC,yBAAyB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;KAC7C;IACD,UAAU,EAAE,OAAO,CAAC,GAAG;CACxB,CAAC,CAAA"}
|
|
@@ -4,7 +4,7 @@ export declare const DEFAULT_MAX_FILES = 10000;
|
|
|
4
4
|
export declare function getProjectFileTree(projectRoot: string, { maxFiles }?: {
|
|
5
5
|
maxFiles?: number;
|
|
6
6
|
}): FileTreeNode[];
|
|
7
|
-
export declare function parseGitignore(
|
|
7
|
+
export declare function parseGitignore(fullDirPath: string, projectRoot: string): ignore.Ignore;
|
|
8
8
|
export declare function getAllFilePaths(nodes: FileTreeNode[], basePath?: string): string[];
|
|
9
9
|
export declare function flattenTree(nodes: FileTreeNode[]): FileTreeNode[];
|
|
10
10
|
export declare function getLastReadFilePaths(flattenedNodes: FileTreeNode[], count: number): string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-file-tree.d.ts","sourceRoot":"","sources":["../src/project-file-tree.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAiB,YAAY,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,iBAAiB,QAAS,CAAA;AAEvC,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,EACnB,EAAE,QAA4B,EAAE,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAC3D,YAAY,EAAE,CAiFhB;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CA+B7D;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,YAAY,EAAE,EACrB,QAAQ,GAAE,MAAW,GACpB,MAAM,EAAE,CAOV;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAOjE;AAED,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,YAAY,EAAE,EAC9B,KAAK,EAAE,MAAM,YASd"}
|
|
@@ -63,11 +63,11 @@ function getProjectFileTree(projectRoot, { maxFiles = exports.DEFAULT_MAX_FILES
|
|
|
63
63
|
];
|
|
64
64
|
let totalFiles = 0;
|
|
65
65
|
while (queue.length > 0 && totalFiles < maxFiles) {
|
|
66
|
-
const { node, fullPath, ignore: currentIgnore } = queue.shift();
|
|
66
|
+
const { node, fullPath, ignore: currentIgnore, } = queue.shift();
|
|
67
67
|
const mergedIgnore = ignore
|
|
68
68
|
.default()
|
|
69
69
|
.add(currentIgnore)
|
|
70
|
-
.add(parseGitignore(fullPath));
|
|
70
|
+
.add(parseGitignore(fullPath, projectRoot));
|
|
71
71
|
try {
|
|
72
72
|
const files = fs_1.default.readdirSync(fullPath);
|
|
73
73
|
for (const file of files) {
|
|
@@ -115,30 +115,44 @@ function getProjectFileTree(projectRoot, { maxFiles = exports.DEFAULT_MAX_FILES
|
|
|
115
115
|
}
|
|
116
116
|
return root.children;
|
|
117
117
|
}
|
|
118
|
-
function parseGitignore(
|
|
118
|
+
function parseGitignore(fullDirPath, projectRoot) {
|
|
119
119
|
const ig = ignore.default();
|
|
120
|
-
const
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
120
|
+
const relativeDirPath = path_1.default.relative(projectRoot, fullDirPath);
|
|
121
|
+
const ignoreFiles = [
|
|
122
|
+
path_1.default.join(fullDirPath, '.gitignore'),
|
|
123
|
+
path_1.default.join(fullDirPath, '.codebuffignore'),
|
|
124
|
+
path_1.default.join(fullDirPath, '.manicodeignore'), // Legacy support
|
|
125
|
+
];
|
|
126
|
+
for (const ignoreFilePath of ignoreFiles) {
|
|
127
|
+
if (fs_1.default.existsSync(ignoreFilePath)) {
|
|
128
|
+
const ignoreContent = fs_1.default.readFileSync(ignoreFilePath, 'utf8');
|
|
129
|
+
const lines = ignoreContent.split('\n');
|
|
130
|
+
for (let line of lines) {
|
|
131
|
+
line = line.trim();
|
|
132
|
+
if (line === '' || line.startsWith('#')) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
let isNegated = false;
|
|
136
|
+
let pattern = line;
|
|
137
|
+
if (pattern.startsWith('!')) {
|
|
138
|
+
isNegated = true;
|
|
139
|
+
pattern = pattern.slice(1);
|
|
140
|
+
}
|
|
141
|
+
let finalPattern = pattern;
|
|
142
|
+
if (pattern.startsWith('/')) {
|
|
143
|
+
finalPattern = pattern.slice(1);
|
|
144
|
+
if (relativeDirPath !== '') {
|
|
145
|
+
finalPattern = path_1.default.join(relativeDirPath, finalPattern);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
finalPattern = finalPattern.replace(/\\/g, '/');
|
|
149
|
+
if (isNegated) {
|
|
150
|
+
ig.add(`!${finalPattern}`);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
ig.add(finalPattern);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
142
156
|
}
|
|
143
157
|
}
|
|
144
158
|
return ig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-file-tree.js","sourceRoot":"","sources":["../src/project-file-tree.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,
|
|
1
|
+
{"version":3,"file":"project-file-tree.js","sourceRoot":"","sources":["../src/project-file-tree.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,gDAwFC;AAED,wCAgDC;AAED,0CAUC;AAED,kCAOC;AAED,oDAWC;AAtLD,4CAAmB;AACnB,gDAAuB;AACvB,4CAAmB;AACnB,+CAAgC;AAEhC,mCAA+B;AAC/B,2CAAmD;AAEtC,QAAA,iBAAiB,GAAG,MAAM,CAAA;AAEvC,SAAgB,kBAAkB,CAChC,WAAmB,EACnB,EAAE,QAAQ,GAAG,yBAAiB,KAA4B,EAAE;IAE5D,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;IACtC,KAAK,MAAM,OAAO,IAAI,iCAAqB,EAAE,CAAC;QAC5C,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;IAED,IAAI,WAAW,KAAK,YAAE,CAAC,OAAO,EAAE,EAAE,CAAC;QACjC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACvB,QAAQ,GAAG,IAAI,CAAA;IACjB,CAAC;IAED,MAAM,IAAI,GAAkB;QAC1B,IAAI,EAAE,cAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;QAChC,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,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AAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC5B,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACzB,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QACzC,CAAC;QACD,OAAO,eAAe,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,EAAE,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAC7E,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAgB,WAAW,CAAC,KAAqB;IAC/C,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC5B,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,CAAA;QACf,CAAC;QACD,OAAO,WAAW,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAgB,oBAAoB,CAClC,cAA8B,EAC9B,KAAa;IAEb,OAAO,IAAA,eAAM,EACX,cAAc,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,EAClD,cAAc,CACf;SACE,OAAO,EAAE;SACT,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;SACf,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AACjC,CAAC"}
|
|
@@ -6,12 +6,12 @@ export declare const ToolCallSchema: z.ZodObject<{
|
|
|
6
6
|
id: z.ZodString;
|
|
7
7
|
}, "strip", z.ZodTypeAny, {
|
|
8
8
|
name: string;
|
|
9
|
-
parameters: Record<string, string>;
|
|
10
9
|
id: string;
|
|
10
|
+
parameters: Record<string, string>;
|
|
11
11
|
}, {
|
|
12
12
|
name: string;
|
|
13
|
-
parameters: Record<string, string>;
|
|
14
13
|
id: string;
|
|
14
|
+
parameters: Record<string, string>;
|
|
15
15
|
}>;
|
|
16
16
|
export type ToolCall = z.infer<typeof ToolCallSchema>;
|
|
17
17
|
export declare const ToolResultSchema: z.ZodObject<{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-state.d.ts","sourceRoot":"","sources":["../../src/types/agent-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,kBAAkB,EAA4B,MAAM,cAAc,CAAA;AAG3E,eAAO,MAAM,cAAc;;;;;;;;;;;;EAIzB,CAAA;AACF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AACrD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;EAI3B,CAAA;AACF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAEzD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK3B,CAAA;AACF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAEzD,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,kBAAkB,GAC9B,UAAU,CAOZ"}
|
|
@@ -35,16 +35,16 @@ declare const MessageContentObjectSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
35
35
|
}>>;
|
|
36
36
|
}, "strip", z.ZodTypeAny, {
|
|
37
37
|
type: "tool_use";
|
|
38
|
-
id: string;
|
|
39
38
|
name: string;
|
|
39
|
+
id: string;
|
|
40
40
|
input: Record<string, any>;
|
|
41
41
|
cache_control?: {
|
|
42
42
|
type: "ephemeral";
|
|
43
43
|
} | undefined;
|
|
44
44
|
}, {
|
|
45
45
|
type: "tool_use";
|
|
46
|
-
id: string;
|
|
47
46
|
name: string;
|
|
47
|
+
id: string;
|
|
48
48
|
input: Record<string, any>;
|
|
49
49
|
cache_control?: {
|
|
50
50
|
type: "ephemeral";
|
|
@@ -61,15 +61,15 @@ declare const MessageContentObjectSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
61
61
|
type: "ephemeral";
|
|
62
62
|
}>>;
|
|
63
63
|
}, "strip", z.ZodTypeAny, {
|
|
64
|
-
type: "tool_result";
|
|
65
64
|
content: string;
|
|
65
|
+
type: "tool_result";
|
|
66
66
|
tool_use_id: string;
|
|
67
67
|
cache_control?: {
|
|
68
68
|
type: "ephemeral";
|
|
69
69
|
} | undefined;
|
|
70
70
|
}, {
|
|
71
|
-
type: "tool_result";
|
|
72
71
|
content: string;
|
|
72
|
+
type: "tool_result";
|
|
73
73
|
tool_use_id: string;
|
|
74
74
|
cache_control?: {
|
|
75
75
|
type: "ephemeral";
|
|
@@ -155,16 +155,16 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
155
155
|
}>>;
|
|
156
156
|
}, "strip", z.ZodTypeAny, {
|
|
157
157
|
type: "tool_use";
|
|
158
|
-
id: string;
|
|
159
158
|
name: string;
|
|
159
|
+
id: string;
|
|
160
160
|
input: Record<string, any>;
|
|
161
161
|
cache_control?: {
|
|
162
162
|
type: "ephemeral";
|
|
163
163
|
} | undefined;
|
|
164
164
|
}, {
|
|
165
165
|
type: "tool_use";
|
|
166
|
-
id: string;
|
|
167
166
|
name: string;
|
|
167
|
+
id: string;
|
|
168
168
|
input: Record<string, any>;
|
|
169
169
|
cache_control?: {
|
|
170
170
|
type: "ephemeral";
|
|
@@ -181,15 +181,15 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
181
181
|
type: "ephemeral";
|
|
182
182
|
}>>;
|
|
183
183
|
}, "strip", z.ZodTypeAny, {
|
|
184
|
-
type: "tool_result";
|
|
185
184
|
content: string;
|
|
185
|
+
type: "tool_result";
|
|
186
186
|
tool_use_id: string;
|
|
187
187
|
cache_control?: {
|
|
188
188
|
type: "ephemeral";
|
|
189
189
|
} | undefined;
|
|
190
190
|
}, {
|
|
191
|
-
type: "tool_result";
|
|
192
191
|
content: string;
|
|
192
|
+
type: "tool_result";
|
|
193
193
|
tool_use_id: string;
|
|
194
194
|
cache_control?: {
|
|
195
195
|
type: "ephemeral";
|
|
@@ -238,7 +238,6 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
238
238
|
} | undefined;
|
|
239
239
|
}>]>, "many">]>;
|
|
240
240
|
}, "strip", z.ZodTypeAny, {
|
|
241
|
-
role: "user" | "assistant";
|
|
242
241
|
content: string | ({
|
|
243
242
|
type: "text";
|
|
244
243
|
text: string;
|
|
@@ -247,15 +246,15 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
247
246
|
} | undefined;
|
|
248
247
|
} | {
|
|
249
248
|
type: "tool_use";
|
|
250
|
-
id: string;
|
|
251
249
|
name: string;
|
|
250
|
+
id: string;
|
|
252
251
|
input: Record<string, any>;
|
|
253
252
|
cache_control?: {
|
|
254
253
|
type: "ephemeral";
|
|
255
254
|
} | undefined;
|
|
256
255
|
} | {
|
|
257
|
-
type: "tool_result";
|
|
258
256
|
content: string;
|
|
257
|
+
type: "tool_result";
|
|
259
258
|
tool_use_id: string;
|
|
260
259
|
cache_control?: {
|
|
261
260
|
type: "ephemeral";
|
|
@@ -271,8 +270,8 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
271
270
|
type: "ephemeral";
|
|
272
271
|
} | undefined;
|
|
273
272
|
})[];
|
|
274
|
-
}, {
|
|
275
273
|
role: "user" | "assistant";
|
|
274
|
+
}, {
|
|
276
275
|
content: string | ({
|
|
277
276
|
type: "text";
|
|
278
277
|
text: string;
|
|
@@ -281,15 +280,15 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
281
280
|
} | undefined;
|
|
282
281
|
} | {
|
|
283
282
|
type: "tool_use";
|
|
284
|
-
id: string;
|
|
285
283
|
name: string;
|
|
284
|
+
id: string;
|
|
286
285
|
input: Record<string, any>;
|
|
287
286
|
cache_control?: {
|
|
288
287
|
type: "ephemeral";
|
|
289
288
|
} | undefined;
|
|
290
289
|
} | {
|
|
291
|
-
type: "tool_result";
|
|
292
290
|
content: string;
|
|
291
|
+
type: "tool_result";
|
|
293
292
|
tool_use_id: string;
|
|
294
293
|
cache_control?: {
|
|
295
294
|
type: "ephemeral";
|
|
@@ -305,6 +304,7 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
305
304
|
type: "ephemeral";
|
|
306
305
|
} | undefined;
|
|
307
306
|
})[];
|
|
307
|
+
role: "user" | "assistant";
|
|
308
308
|
}>;
|
|
309
309
|
export type Message = z.infer<typeof MessageSchema>;
|
|
310
310
|
export type MessageContentObject = z.infer<typeof MessageContentObjectSchema>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/types/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,QAAA,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referral.d.ts","sourceRoot":"","sources":["../../src/types/referral.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,CAAA;AAEpD,eAAO,MAAM,oBAAoB,EAAE,cAAc,EAA6B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/types/tools.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAChC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/types/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;EAO1B,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.test.d.ts","sourceRoot":"","sources":["../../../src/util/__tests__/messages.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.test.d.ts","sourceRoot":"","sources":["../../../src/util/__tests__/string.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/util/array.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GACQ,CAAC,EAAE,CAC1E;AAED,KAAK,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,CAAA;AAC/C,KAAK,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAA;AAE7D,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,GACrB,CAAC,EAAE,CAC3C;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAiB/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changes.d.ts","sourceRoot":"","sources":["../../src/util/changes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAGxC,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW;;;EAiCrE;AAED,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,iBA2B7B"}
|
|
@@ -7,15 +7,15 @@ export declare const userSchema: z.ZodObject<{
|
|
|
7
7
|
fingerprintId: z.ZodString;
|
|
8
8
|
fingerprintHash: z.ZodString;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
|
-
name: string | null;
|
|
11
10
|
email: string;
|
|
11
|
+
name: string | null;
|
|
12
12
|
id: string;
|
|
13
13
|
fingerprintId: string;
|
|
14
14
|
authToken: string;
|
|
15
15
|
fingerprintHash: string;
|
|
16
16
|
}, {
|
|
17
|
-
name: string | null;
|
|
18
17
|
email: string;
|
|
18
|
+
name: string | null;
|
|
19
19
|
id: string;
|
|
20
20
|
fingerprintId: string;
|
|
21
21
|
authToken: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/util/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;EAOrB,CAAA;AAEF,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAA;AAE7C,eAAO,MAAM,WAAW,kBACP,MAAM,aACV,MAAM,UACT,MAAM,WAOE,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as schema from '../db/schema';
|
|
2
|
+
export type ApiKeyType = (typeof schema.apiKeyTypeEnum.enumValues)[number];
|
|
3
|
+
/**
|
|
4
|
+
* Encrypts an API key using the provided secret and stores it in the database
|
|
5
|
+
* for a specific user and key type. Overwrites any existing key of the same type
|
|
6
|
+
* for that user.
|
|
7
|
+
* @param userId The ID of the user.
|
|
8
|
+
* @param keyType The type of the API key (e.g., 'gemini').
|
|
9
|
+
* @param apiKey The plaintext API key to encrypt.
|
|
10
|
+
* @param secretKey The 32-byte encryption secret key.
|
|
11
|
+
*/
|
|
12
|
+
export declare function encryptAndStoreApiKey(userId: string, keyType: ApiKeyType, apiKey: string, secretKey: string): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves and decrypts the stored API key for a specific user and key type
|
|
15
|
+
* using the provided secret. Validates the format for Gemini keys.
|
|
16
|
+
* @param userId The ID of the user.
|
|
17
|
+
* @param keyType The type of the API key (e.g., 'gemini').
|
|
18
|
+
* @param secretKey The 32-byte encryption secret key.
|
|
19
|
+
* @returns The decrypted API key, or null if not found, decryption fails, or validation fails.
|
|
20
|
+
*/
|
|
21
|
+
export declare function retrieveAndDecryptApiKey(userId: string, keyType: ApiKeyType, secretKey: string): Promise<string | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Deletes a specific API key entry for a given user and key type.
|
|
24
|
+
* @param userId The ID of the user.
|
|
25
|
+
* @param keyType The type of the API key to delete (e.g., 'gemini').
|
|
26
|
+
*/
|
|
27
|
+
export declare function clearApiKey(userId: string, keyType: ApiKeyType): Promise<void>;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.encryptAndStoreApiKey = encryptAndStoreApiKey;
|
|
30
|
+
exports.retrieveAndDecryptApiKey = retrieveAndDecryptApiKey;
|
|
31
|
+
exports.clearApiKey = clearApiKey;
|
|
32
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
33
|
+
const db_1 = __importDefault(require("../db"));
|
|
34
|
+
const schema = __importStar(require("../db/schema"));
|
|
35
|
+
const drizzle_orm_1 = require("drizzle-orm");
|
|
36
|
+
const ALGORITHM = 'aes-256-gcm';
|
|
37
|
+
const IV_LENGTH = 12;
|
|
38
|
+
const AUTH_TAG_LENGTH = 16;
|
|
39
|
+
// --- Constants for Gemini Key Validation ---
|
|
40
|
+
const GEMINI_API_KEY_PREFIX = 'AIzaSy';
|
|
41
|
+
const GEMINI_API_KEY_LENGTH = 39;
|
|
42
|
+
/**
|
|
43
|
+
* Encrypts an API key using the provided secret.
|
|
44
|
+
* @param apiKey The plaintext API key to encrypt.
|
|
45
|
+
* @param secretKey The 32-byte encryption secret key.
|
|
46
|
+
* @returns The encrypted string including iv and authTag, or throws error.
|
|
47
|
+
*/
|
|
48
|
+
function encryptApiKeyInternal(apiKey, secretKey) {
|
|
49
|
+
if (Buffer.from(secretKey, 'utf8').length !== 32) {
|
|
50
|
+
throw new Error('Invalid secret key length. Must be 32 bytes.');
|
|
51
|
+
}
|
|
52
|
+
const iv = node_crypto_1.default.randomBytes(IV_LENGTH);
|
|
53
|
+
const cipher = node_crypto_1.default.createCipheriv(ALGORITHM, Buffer.from(secretKey, 'utf8'), iv, {
|
|
54
|
+
authTagLength: AUTH_TAG_LENGTH,
|
|
55
|
+
});
|
|
56
|
+
let encrypted = cipher.update(apiKey, 'utf8', 'hex');
|
|
57
|
+
encrypted += cipher.final('hex');
|
|
58
|
+
const authTag = cipher.getAuthTag();
|
|
59
|
+
// Return IV, encrypted data, and auth tag together
|
|
60
|
+
return `${iv.toString('hex')}:${encrypted}:${authTag.toString('hex')}`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Decrypts an API key string using the provided secret.
|
|
64
|
+
* @param storedValue The encrypted string in format "iv:encrypted:authTag".
|
|
65
|
+
* @param secretKey The 32-byte encryption secret key.
|
|
66
|
+
* @returns The decrypted API key string, or null if decryption fails.
|
|
67
|
+
*/
|
|
68
|
+
function decryptApiKeyInternal(storedValue, secretKey) {
|
|
69
|
+
try {
|
|
70
|
+
if (Buffer.from(secretKey, 'utf8').length !== 32) {
|
|
71
|
+
throw new Error('Invalid secret key length. Must be 32 bytes.');
|
|
72
|
+
}
|
|
73
|
+
const parts = storedValue.split(':');
|
|
74
|
+
if (parts.length !== 3) {
|
|
75
|
+
return null; // Invalid format
|
|
76
|
+
}
|
|
77
|
+
const [ivHex, encryptedHex, authTagHex] = parts;
|
|
78
|
+
const iv = Buffer.from(ivHex, 'hex');
|
|
79
|
+
const encrypted = Buffer.from(encryptedHex, 'hex');
|
|
80
|
+
const authTag = Buffer.from(authTagHex, 'hex');
|
|
81
|
+
if (iv.length !== IV_LENGTH) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const decipher = node_crypto_1.default.createDecipheriv(ALGORITHM, Buffer.from(secretKey, 'utf8'), iv, {
|
|
85
|
+
authTagLength: AUTH_TAG_LENGTH,
|
|
86
|
+
});
|
|
87
|
+
decipher.setAuthTag(authTag);
|
|
88
|
+
let decryptedBuffer = decipher.update(encrypted);
|
|
89
|
+
decryptedBuffer = Buffer.concat([decryptedBuffer, decipher.final()]);
|
|
90
|
+
return decryptedBuffer.toString('utf8');
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return null; // Decryption failed
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Encrypts an API key using the provided secret and stores it in the database
|
|
98
|
+
* for a specific user and key type. Overwrites any existing key of the same type
|
|
99
|
+
* for that user.
|
|
100
|
+
* @param userId The ID of the user.
|
|
101
|
+
* @param keyType The type of the API key (e.g., 'gemini').
|
|
102
|
+
* @param apiKey The plaintext API key to encrypt.
|
|
103
|
+
* @param secretKey The 32-byte encryption secret key.
|
|
104
|
+
*/
|
|
105
|
+
async function encryptAndStoreApiKey(userId, keyType, apiKey, secretKey) {
|
|
106
|
+
try {
|
|
107
|
+
const encryptedValue = encryptApiKeyInternal(apiKey, secretKey);
|
|
108
|
+
// Use upsert logic based on the composite primary key (user_id, type)
|
|
109
|
+
await db_1.default
|
|
110
|
+
.insert(schema.encryptedApiKeys)
|
|
111
|
+
.values({ user_id: userId, type: keyType, api_key: encryptedValue })
|
|
112
|
+
.onConflictDoUpdate({
|
|
113
|
+
target: [schema.encryptedApiKeys.user_id, schema.encryptedApiKeys.type],
|
|
114
|
+
set: { api_key: encryptedValue },
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
throw new Error(`API key encryption and storage failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Retrieves and decrypts the stored API key for a specific user and key type
|
|
123
|
+
* using the provided secret. Validates the format for Gemini keys.
|
|
124
|
+
* @param userId The ID of the user.
|
|
125
|
+
* @param keyType The type of the API key (e.g., 'gemini').
|
|
126
|
+
* @param secretKey The 32-byte encryption secret key.
|
|
127
|
+
* @returns The decrypted API key, or null if not found, decryption fails, or validation fails.
|
|
128
|
+
*/
|
|
129
|
+
async function retrieveAndDecryptApiKey(userId, keyType, secretKey) {
|
|
130
|
+
try {
|
|
131
|
+
const result = await db_1.default.query.encryptedApiKeys.findFirst({
|
|
132
|
+
where: (0, drizzle_orm_1.and)((0, drizzle_orm_1.eq)(schema.encryptedApiKeys.user_id, userId), (0, drizzle_orm_1.eq)(schema.encryptedApiKeys.type, keyType)),
|
|
133
|
+
columns: {
|
|
134
|
+
api_key: true, // Select only the encrypted key column
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
const storedValue = result?.api_key;
|
|
138
|
+
if (!storedValue) {
|
|
139
|
+
return null; // No key stored for this user/type
|
|
140
|
+
}
|
|
141
|
+
const decryptedKey = decryptApiKeyInternal(storedValue, secretKey);
|
|
142
|
+
if (decryptedKey === null) {
|
|
143
|
+
return null; // Decryption failed
|
|
144
|
+
}
|
|
145
|
+
// --- Add validation specific to Gemini API keys ---
|
|
146
|
+
if (keyType === 'gemini') {
|
|
147
|
+
if (!decryptedKey.startsWith(GEMINI_API_KEY_PREFIX) ||
|
|
148
|
+
decryptedKey.length !== GEMINI_API_KEY_LENGTH) {
|
|
149
|
+
return null; // Validation failed
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// --- End validation ---
|
|
153
|
+
return decryptedKey;
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
return null; // Error during DB query or other unexpected issue
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Deletes a specific API key entry for a given user and key type.
|
|
161
|
+
* @param userId The ID of the user.
|
|
162
|
+
* @param keyType The type of the API key to delete (e.g., 'gemini').
|
|
163
|
+
*/
|
|
164
|
+
async function clearApiKey(userId, keyType) {
|
|
165
|
+
try {
|
|
166
|
+
await db_1.default
|
|
167
|
+
.delete(schema.encryptedApiKeys)
|
|
168
|
+
.where((0, drizzle_orm_1.and)((0, drizzle_orm_1.eq)(schema.encryptedApiKeys.user_id, userId), (0, drizzle_orm_1.eq)(schema.encryptedApiKeys.type, keyType)));
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
throw new Error(`Failed to clear API key: ${error instanceof Error ? error.message : String(error)}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/util/crypto.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsGA,sDAoBC;AAUD,4DA0CC;AAOD,kCAgBC;AArMD,8DAAgC;AAChC,+CAAsB;AACtB,qDAAsC;AACtC,6CAAqC;AAErC,MAAM,SAAS,GAAG,aAAa,CAAA;AAC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M,2BAUjD,CAAA;AAED,eAAO,MAAM,uBAAuB,aAAc,MAAM,WAAW,MAAM,WAExE,CAAA;AAED,eAAO,MAAM,sBAAsB,YAAa,MAAM,WAMrD,CAAA;AAED,eAAO,MAAM,wBAAwB,WAAY,MAAM,WAAW,MAAM,WAEvE,CAAA;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,YAAY,EAAE,EACrB,KAAK,GAAE,MAAU,GAChB,MAAM,CAUR;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,YAAY,EAAE,EACrB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACvD,IAAI,GAAE,MAAM,EAAO,GAClB,MAAM,CA+BR;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,aACtB,MAAM,GAAG,IAAI,KACtB,MAAM,GAAG,IASX,CAAA;AAED,eAAO,MAAM,qBAAqB,YAAa,MAAM,SAIpD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,YAAa,MAAM,KAAG,MAKxD,CAAA;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,WAW3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/util/git.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,wBAAgB,gBAAgB,IAAI,OAAO,CAO1C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAMzC;AAED,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,QAIlD;AAED,wBAAgB,eAAe,IAAI,OAAO,CAOzC;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAiBvE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface LoggerContext {
|
|
2
|
+
userId?: string;
|
|
3
|
+
userEmail?: string;
|
|
4
|
+
clientSessionId?: string;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
export declare const withLoggerContext: <T>(additionalContext: Partial<LoggerContext>, fn: () => Promise<T>) => Promise<T>;
|
|
8
|
+
export declare const logger: import("pino").Logger<never, boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/util/logger.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB;AAID,eAAO,MAAM,iBAAiB,GAAI,CAAC,qBACd,OAAO,CAAC,aAAa,CAAC,MACrC,MAAM,OAAO,CAAC,CAAC,CAAC,eAIrB,CAAA;AAQD,eAAO,MAAM,MAAM,uCAclB,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.logger = exports.withLoggerContext = void 0;
|
|
7
|
+
const pino_1 = __importDefault(require("pino"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const async_hooks_1 = require("async_hooks");
|
|
10
|
+
const env_mjs_1 = require("../env.mjs");
|
|
11
|
+
const loggerAsyncStorage = new async_hooks_1.AsyncLocalStorage();
|
|
12
|
+
const withLoggerContext = (additionalContext, fn) => {
|
|
13
|
+
const store = loggerAsyncStorage.getStore() ?? {};
|
|
14
|
+
return loggerAsyncStorage.run({ ...store, ...additionalContext }, fn);
|
|
15
|
+
};
|
|
16
|
+
exports.withLoggerContext = withLoggerContext;
|
|
17
|
+
const fileTransport = pino_1.default.transport({
|
|
18
|
+
target: 'pino/file',
|
|
19
|
+
options: { destination: path_1.default.join(__dirname, '..', 'debug.log') },
|
|
20
|
+
level: 'debug',
|
|
21
|
+
});
|
|
22
|
+
exports.logger = (0, pino_1.default)({
|
|
23
|
+
level: 'debug',
|
|
24
|
+
mixin() {
|
|
25
|
+
return { logTrace: loggerAsyncStorage.getStore() };
|
|
26
|
+
},
|
|
27
|
+
formatters: {
|
|
28
|
+
level: (label) => {
|
|
29
|
+
return { level: label.toUpperCase() };
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
timestamp: () => `,"timestamp":"${new Date(Date.now()).toISOString()}"`,
|
|
33
|
+
}, env_mjs_1.env.ENVIRONMENT === 'production' ? undefined : fileTransport);
|
|
34
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/util/logger.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,gDAAuB;AACvB,6CAA+C;AAC/C,wCAAgC;AAShC,MAAM,kBAAkB,GAAG,IAAI,+BAAiB,EAAiB,CAAA;AAE1D,MAAM,iBAAiB,GAAG,CAC/B,iBAAyC,EACzC,EAAoB,EACpB,EAAE;IACF,MAAM,KAAK,GAAG,kBAAkB,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAA;IACjD,OAAO,kBAAkB,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,iBAAiB,EAAE,EAAE,EAAE,CAAC,CAAA;AACvE,CAAC,CAAA;AANY,QAAA,iBAAiB,qBAM7B;AAED,MAAM,aAAa,GAAG,cAAI,CAAC,SAAS,CAAC;IACnC,MAAM,EAAE,WAAW;IACnB,OAAO,EAAE,EAAE,WAAW,EAAE,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,EAAE;IACjE,KAAK,EAAE,OAAO;CACf,CAAC,CAAA;AAEW,QAAA,MAAM,GAAG,IAAA,cAAI,EACxB;IACE,KAAK,EAAE,OAAO;IACd,KAAK;QACH,OAAO,EAAE,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,EAAE,EAAE,CAAA;IACpD,CAAC;IACD,UAAU,EAAE;QACV,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;YACf,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,EAAE,CAAA;QACvC,CAAC;KACF;IACD,SAAS,EAAE,GAAG,EAAE,CAAC,iBAAiB,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,WAAW,EAAE,GAAG;CACxE,EACD,aAAG,CAAC,WAAW,KAAK,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAC7D,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lru-cache.d.ts","sourceRoot":"","sources":["../../src/util/lru-cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,QAAQ,CAAC,CAAC,EAAE,CAAC;IAGZ,OAAO,CAAC,OAAO;IAF3B,OAAO,CAAC,KAAK,CAAkB;gBAEX,OAAO,EAAE,MAAM;IAMnC;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAW1B;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAiB3B;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/util/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAO1C;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,OAAO,EAAE,EACnB,QAAQ,EAAE,MAAM,GACf,OAAO,EAAE,CA4BX;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAIpD;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAsBtD;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAa1D"}
|