@crypto512/jicon-mcp 2.2.0 → 2.3.0
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/.env.example +2 -2
- package/README.md +16 -138
- package/TOOL_LIST.md +361 -296
- package/dist/config/constants.d.ts +15 -0
- package/dist/config/constants.d.ts.map +1 -1
- package/dist/config/constants.js +19 -0
- package/dist/config/constants.js.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +7 -1
- package/dist/config/loader.js.map +1 -1
- package/dist/config/types.d.ts +38 -6
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +16 -0
- package/dist/config/types.js.map +1 -1
- package/dist/confluence/formatters.d.ts +20 -0
- package/dist/confluence/formatters.d.ts.map +1 -1
- package/dist/confluence/formatters.js +74 -8
- package/dist/confluence/formatters.js.map +1 -1
- package/dist/confluence/tools.d.ts +8 -7
- package/dist/confluence/tools.d.ts.map +1 -1
- package/dist/confluence/tools.js +52 -31
- package/dist/confluence/tools.js.map +1 -1
- package/dist/credentials/extractor.d.ts +1 -2
- package/dist/credentials/extractor.d.ts.map +1 -1
- package/dist/credentials/extractor.js +21 -4
- package/dist/credentials/extractor.js.map +1 -1
- package/dist/credentials/index.d.ts +3 -2
- package/dist/credentials/index.d.ts.map +1 -1
- package/dist/credentials/index.js +3 -2
- package/dist/credentials/index.js.map +1 -1
- package/dist/index.js +43 -20
- package/dist/index.js.map +1 -1
- package/dist/jira/activity-tools.d.ts +8 -11
- package/dist/jira/activity-tools.d.ts.map +1 -1
- package/dist/jira/activity-tools.js +91 -27
- package/dist/jira/activity-tools.js.map +1 -1
- package/dist/jira/client.d.ts +12 -0
- package/dist/jira/client.d.ts.map +1 -1
- package/dist/jira/client.js +35 -0
- package/dist/jira/client.js.map +1 -1
- package/dist/jira/formatters.d.ts +58 -0
- package/dist/jira/formatters.d.ts.map +1 -1
- package/dist/jira/formatters.js +80 -11
- package/dist/jira/formatters.js.map +1 -1
- package/dist/jira/tools.d.ts +30 -12
- package/dist/jira/tools.d.ts.map +1 -1
- package/dist/jira/tools.js +127 -37
- package/dist/jira/tools.js.map +1 -1
- package/dist/permissions/tool-registry.d.ts +6 -6
- package/dist/permissions/tool-registry.d.ts.map +1 -1
- package/dist/permissions/tool-registry.js +4 -3
- package/dist/permissions/tool-registry.js.map +1 -1
- package/dist/session/context.d.ts +81 -0
- package/dist/session/context.d.ts.map +1 -0
- package/dist/session/context.js +107 -0
- package/dist/session/context.js.map +1 -0
- package/dist/session/index.d.ts +12 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +22 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/manager.d.ts +155 -0
- package/dist/session/manager.d.ts.map +1 -0
- package/dist/session/manager.js +285 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/tempo/client.d.ts +14 -0
- package/dist/tempo/client.d.ts.map +1 -1
- package/dist/tempo/client.js +55 -0
- package/dist/tempo/client.js.map +1 -1
- package/dist/tempo/formatters.d.ts +13 -0
- package/dist/tempo/formatters.d.ts.map +1 -1
- package/dist/tempo/formatters.js +106 -20
- package/dist/tempo/formatters.js.map +1 -1
- package/dist/tempo/tools.d.ts +10 -9
- package/dist/tempo/tools.d.ts.map +1 -1
- package/dist/tempo/tools.js +188 -33
- package/dist/tempo/tools.js.map +1 -1
- package/dist/tempo/types.d.ts +20 -6
- package/dist/tempo/types.d.ts.map +1 -1
- package/dist/transport/http.d.ts +20 -3
- package/dist/transport/http.d.ts.map +1 -1
- package/dist/transport/http.js +171 -15
- package/dist/transport/http.js.map +1 -1
- package/dist/transport/types.d.ts +2 -0
- package/dist/transport/types.d.ts.map +1 -1
- package/dist/transport/types.js.map +1 -1
- package/dist/utils/buffer-tools.d.ts +46 -722
- package/dist/utils/buffer-tools.d.ts.map +1 -1
- package/dist/utils/buffer-tools.js +303 -158
- package/dist/utils/buffer-tools.js.map +1 -1
- package/dist/utils/content-buffer.d.ts +10 -31
- package/dist/utils/content-buffer.d.ts.map +1 -1
- package/dist/utils/content-buffer.js +12 -86
- package/dist/utils/content-buffer.js.map +1 -1
- package/dist/utils/jicon-help.d.ts +3 -3
- package/dist/utils/jicon-help.d.ts.map +1 -1
- package/dist/utils/jicon-help.js +163 -101
- package/dist/utils/jicon-help.js.map +1 -1
- package/dist/utils/plantuml/tools.d.ts.map +1 -1
- package/dist/utils/plantuml/tools.js +8 -7
- package/dist/utils/plantuml/tools.js.map +1 -1
- package/dist/utils/response-formatter.d.ts +12 -2
- package/dist/utils/response-formatter.d.ts.map +1 -1
- package/dist/utils/response-formatter.js +85 -13
- package/dist/utils/response-formatter.js.map +1 -1
- package/dist/utils/sandbox/formatters.d.ts +25 -0
- package/dist/utils/sandbox/formatters.d.ts.map +1 -0
- package/dist/utils/sandbox/formatters.js +690 -0
- package/dist/utils/sandbox/formatters.js.map +1 -0
- package/dist/utils/sandbox/helpers.d.ts +16 -0
- package/dist/utils/sandbox/helpers.d.ts.map +1 -0
- package/dist/utils/sandbox/helpers.js +252 -0
- package/dist/utils/sandbox/helpers.js.map +1 -0
- package/dist/utils/sandbox/index.d.ts +19 -0
- package/dist/utils/sandbox/index.d.ts.map +1 -0
- package/dist/utils/sandbox/index.js +269 -0
- package/dist/utils/sandbox/index.js.map +1 -0
- package/dist/utils/sandbox/schema.d.ts +55 -0
- package/dist/utils/sandbox/schema.d.ts.map +1 -0
- package/dist/utils/sandbox/schema.js +39 -0
- package/dist/utils/sandbox/schema.js.map +1 -0
- package/dist/utils/sandbox/types.d.ts +179 -0
- package/dist/utils/sandbox/types.d.ts.map +1 -0
- package/dist/utils/sandbox/types.js +8 -0
- package/dist/utils/sandbox/types.js.map +1 -0
- package/dist/utils/schemas/confluence.d.ts +41 -0
- package/dist/utils/schemas/confluence.d.ts.map +1 -0
- package/dist/utils/schemas/confluence.js +105 -0
- package/dist/utils/schemas/confluence.js.map +1 -0
- package/dist/utils/schemas/index.d.ts +66 -0
- package/dist/utils/schemas/index.d.ts.map +1 -0
- package/dist/utils/schemas/index.js +107 -0
- package/dist/utils/schemas/index.js.map +1 -0
- package/dist/utils/schemas/jira.d.ts +49 -0
- package/dist/utils/schemas/jira.d.ts.map +1 -0
- package/dist/utils/schemas/jira.js +151 -0
- package/dist/utils/schemas/jira.js.map +1 -0
- package/dist/utils/schemas/tempo.d.ts +29 -0
- package/dist/utils/schemas/tempo.d.ts.map +1 -0
- package/dist/utils/schemas/tempo.js +72 -0
- package/dist/utils/schemas/tempo.js.map +1 -0
- package/dist/utils/xhtml/error-locator.js +5 -5
- package/dist/utils/xhtml/error-locator.js.map +1 -1
- package/package.json +10 -9
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox Helpers
|
|
3
|
+
*
|
|
4
|
+
* Data manipulation helper functions injected into the QuickJS sandbox.
|
|
5
|
+
* These are defined as JavaScript code strings that get evaluated in the sandbox.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* JavaScript code for all helper functions.
|
|
9
|
+
* This gets evaluated in the sandbox to define global helper functions.
|
|
10
|
+
*/
|
|
11
|
+
export declare const HELPER_FUNCTIONS_JS = "\n// ============================================================================\n// Aggregation Helpers\n// ============================================================================\n\n/**\n * Group array items by a key or function\n * @param {Array} array - Array to group\n * @param {string|Function} keyOrFn - Field name or function returning group key\n * @returns {Object} Object with keys as group names and values as arrays\n */\nfunction groupBy(array, keyOrFn) {\n if (!Array.isArray(array)) return {};\n const result = {};\n for (const item of array) {\n const key = typeof keyOrFn === 'function'\n ? keyOrFn(item)\n : get(item, keyOrFn);\n const keyStr = String(key ?? 'undefined');\n if (!result[keyStr]) {\n result[keyStr] = [];\n }\n result[keyStr].push(item);\n }\n return result;\n}\n\n/**\n * Sum numeric values in array\n * @param {Array} array - Array to sum\n * @param {string} [field] - Optional field path to extract numbers from\n * @returns {number}\n */\nfunction sum(array, field) {\n if (!Array.isArray(array)) return 0;\n return array.reduce((acc, item) => {\n const value = field ? get(item, field) : item;\n const num = typeof value === 'number' ? value : parseFloat(value);\n return acc + (isNaN(num) ? 0 : num);\n }, 0);\n}\n\n/**\n * Calculate average of numeric values\n * @param {Array} array - Array to average\n * @param {string} [field] - Optional field path\n * @returns {number}\n */\nfunction avg(array, field) {\n if (!Array.isArray(array) || array.length === 0) return 0;\n return sum(array, field) / array.length;\n}\n\n/**\n * Find minimum value\n * @param {Array} array - Array to search\n * @param {string} [field] - Optional field path\n * @returns {*}\n */\nfunction min(array, field) {\n if (!Array.isArray(array) || array.length === 0) return undefined;\n let minVal = undefined;\n for (const item of array) {\n const value = field ? get(item, field) : item;\n if (minVal === undefined || value < minVal) {\n minVal = value;\n }\n }\n return minVal;\n}\n\n/**\n * Find maximum value\n * @param {Array} array - Array to search\n * @param {string} [field] - Optional field path\n * @returns {*}\n */\nfunction max(array, field) {\n if (!Array.isArray(array) || array.length === 0) return undefined;\n let maxVal = undefined;\n for (const item of array) {\n const value = field ? get(item, field) : item;\n if (maxVal === undefined || value > maxVal) {\n maxVal = value;\n }\n }\n return maxVal;\n}\n\n/**\n * Count array items\n * @param {Array} array - Array to count\n * @returns {number}\n */\nfunction count(array) {\n if (!Array.isArray(array)) return 0;\n return array.length;\n}\n\n/**\n * Get unique values from array\n * @param {Array} array - Array to dedupe\n * @param {string} [field] - Optional field path\n * @returns {Array}\n */\nfunction unique(array, field) {\n if (!Array.isArray(array)) return [];\n const seen = new Set();\n const result = [];\n for (const item of array) {\n const value = field ? get(item, field) : item;\n const key = JSON.stringify(value);\n if (!seen.has(key)) {\n seen.add(key);\n result.push(value);\n }\n }\n return result;\n}\n\n// ============================================================================\n// Object Access Helpers\n// ============================================================================\n\n/**\n * Get nested value using dot notation path\n * @param {Object} obj - Object to access\n * @param {string} path - Dot notation path (e.g., \"priority.name\")\n * @returns {*}\n */\nfunction get(obj, path) {\n if (obj == null || typeof path !== 'string') return undefined;\n const parts = path.split('.');\n let current = obj;\n for (const part of parts) {\n if (current == null) return undefined;\n // Handle array index notation (e.g., \"items.0.name\")\n const index = parseInt(part, 10);\n if (!isNaN(index) && Array.isArray(current)) {\n current = current[index];\n } else {\n current = current[part];\n }\n }\n return current;\n}\n\n/**\n * Create object with only specified keys\n * @param {Object} obj - Source object\n * @param {Array<string>} keys - Keys to include\n * @returns {Object}\n */\nfunction pick(obj, keys) {\n if (obj == null || !Array.isArray(keys)) return {};\n const result = {};\n for (const key of keys) {\n if (key in obj) {\n result[key] = obj[key];\n }\n }\n return result;\n}\n\n/**\n * Create object without specified keys\n * @param {Object} obj - Source object\n * @param {Array<string>} keys - Keys to exclude\n * @returns {Object}\n */\nfunction omit(obj, keys) {\n if (obj == null) return {};\n const keysSet = new Set(keys || []);\n const result = {};\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key) && !keysSet.has(key)) {\n result[key] = obj[key];\n }\n }\n return result;\n}\n\n// ============================================================================\n// Date Helpers\n// ============================================================================\n\n/**\n * Parse date string to timestamp (milliseconds)\n * @param {string|number|Date} value - Date value to parse\n * @returns {number|null}\n */\nfunction parseDate(value) {\n if (value == null) return null;\n if (typeof value === 'number') return value;\n const ts = Date.parse(value);\n return isNaN(ts) ? null : ts;\n}\n\n/**\n * Format timestamp to string\n * @param {number|string|Date} ts - Timestamp or date\n * @param {string} [format] - Format string (simplified: 'iso', 'date', 'time', or 'datetime')\n * @returns {string}\n */\nfunction formatDate(ts, format) {\n const date = new Date(typeof ts === 'number' ? ts : Date.parse(ts));\n if (isNaN(date.getTime())) return '';\n\n switch (format) {\n case 'date':\n return date.toISOString().split('T')[0];\n case 'time':\n return date.toISOString().split('T')[1].split('.')[0];\n case 'datetime':\n return date.toISOString().replace('T', ' ').split('.')[0];\n case 'iso':\n default:\n return date.toISOString();\n }\n}\n\n/**\n * Calculate days between two dates\n * @param {string|number|Date} date1 - First date\n * @param {string|number|Date} date2 - Second date\n * @returns {number}\n */\nfunction daysBetween(date1, date2) {\n const ts1 = parseDate(date1);\n const ts2 = parseDate(date2);\n if (ts1 == null || ts2 == null) return 0;\n const msPerDay = 24 * 60 * 60 * 1000;\n return Math.round(Math.abs(ts2 - ts1) / msPerDay);\n}\n";
|
|
12
|
+
/**
|
|
13
|
+
* Get the JavaScript code for helper functions
|
|
14
|
+
*/
|
|
15
|
+
export declare function getHelperFunctionsCode(): string;
|
|
16
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/sandbox/helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,47MA0O/B,CAAC;AAEF;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox Helpers
|
|
3
|
+
*
|
|
4
|
+
* Data manipulation helper functions injected into the QuickJS sandbox.
|
|
5
|
+
* These are defined as JavaScript code strings that get evaluated in the sandbox.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* JavaScript code for all helper functions.
|
|
9
|
+
* This gets evaluated in the sandbox to define global helper functions.
|
|
10
|
+
*/
|
|
11
|
+
export const HELPER_FUNCTIONS_JS = `
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Aggregation Helpers
|
|
14
|
+
// ============================================================================
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Group array items by a key or function
|
|
18
|
+
* @param {Array} array - Array to group
|
|
19
|
+
* @param {string|Function} keyOrFn - Field name or function returning group key
|
|
20
|
+
* @returns {Object} Object with keys as group names and values as arrays
|
|
21
|
+
*/
|
|
22
|
+
function groupBy(array, keyOrFn) {
|
|
23
|
+
if (!Array.isArray(array)) return {};
|
|
24
|
+
const result = {};
|
|
25
|
+
for (const item of array) {
|
|
26
|
+
const key = typeof keyOrFn === 'function'
|
|
27
|
+
? keyOrFn(item)
|
|
28
|
+
: get(item, keyOrFn);
|
|
29
|
+
const keyStr = String(key ?? 'undefined');
|
|
30
|
+
if (!result[keyStr]) {
|
|
31
|
+
result[keyStr] = [];
|
|
32
|
+
}
|
|
33
|
+
result[keyStr].push(item);
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Sum numeric values in array
|
|
40
|
+
* @param {Array} array - Array to sum
|
|
41
|
+
* @param {string} [field] - Optional field path to extract numbers from
|
|
42
|
+
* @returns {number}
|
|
43
|
+
*/
|
|
44
|
+
function sum(array, field) {
|
|
45
|
+
if (!Array.isArray(array)) return 0;
|
|
46
|
+
return array.reduce((acc, item) => {
|
|
47
|
+
const value = field ? get(item, field) : item;
|
|
48
|
+
const num = typeof value === 'number' ? value : parseFloat(value);
|
|
49
|
+
return acc + (isNaN(num) ? 0 : num);
|
|
50
|
+
}, 0);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Calculate average of numeric values
|
|
55
|
+
* @param {Array} array - Array to average
|
|
56
|
+
* @param {string} [field] - Optional field path
|
|
57
|
+
* @returns {number}
|
|
58
|
+
*/
|
|
59
|
+
function avg(array, field) {
|
|
60
|
+
if (!Array.isArray(array) || array.length === 0) return 0;
|
|
61
|
+
return sum(array, field) / array.length;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Find minimum value
|
|
66
|
+
* @param {Array} array - Array to search
|
|
67
|
+
* @param {string} [field] - Optional field path
|
|
68
|
+
* @returns {*}
|
|
69
|
+
*/
|
|
70
|
+
function min(array, field) {
|
|
71
|
+
if (!Array.isArray(array) || array.length === 0) return undefined;
|
|
72
|
+
let minVal = undefined;
|
|
73
|
+
for (const item of array) {
|
|
74
|
+
const value = field ? get(item, field) : item;
|
|
75
|
+
if (minVal === undefined || value < minVal) {
|
|
76
|
+
minVal = value;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return minVal;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Find maximum value
|
|
84
|
+
* @param {Array} array - Array to search
|
|
85
|
+
* @param {string} [field] - Optional field path
|
|
86
|
+
* @returns {*}
|
|
87
|
+
*/
|
|
88
|
+
function max(array, field) {
|
|
89
|
+
if (!Array.isArray(array) || array.length === 0) return undefined;
|
|
90
|
+
let maxVal = undefined;
|
|
91
|
+
for (const item of array) {
|
|
92
|
+
const value = field ? get(item, field) : item;
|
|
93
|
+
if (maxVal === undefined || value > maxVal) {
|
|
94
|
+
maxVal = value;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return maxVal;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Count array items
|
|
102
|
+
* @param {Array} array - Array to count
|
|
103
|
+
* @returns {number}
|
|
104
|
+
*/
|
|
105
|
+
function count(array) {
|
|
106
|
+
if (!Array.isArray(array)) return 0;
|
|
107
|
+
return array.length;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Get unique values from array
|
|
112
|
+
* @param {Array} array - Array to dedupe
|
|
113
|
+
* @param {string} [field] - Optional field path
|
|
114
|
+
* @returns {Array}
|
|
115
|
+
*/
|
|
116
|
+
function unique(array, field) {
|
|
117
|
+
if (!Array.isArray(array)) return [];
|
|
118
|
+
const seen = new Set();
|
|
119
|
+
const result = [];
|
|
120
|
+
for (const item of array) {
|
|
121
|
+
const value = field ? get(item, field) : item;
|
|
122
|
+
const key = JSON.stringify(value);
|
|
123
|
+
if (!seen.has(key)) {
|
|
124
|
+
seen.add(key);
|
|
125
|
+
result.push(value);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// ============================================================================
|
|
132
|
+
// Object Access Helpers
|
|
133
|
+
// ============================================================================
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Get nested value using dot notation path
|
|
137
|
+
* @param {Object} obj - Object to access
|
|
138
|
+
* @param {string} path - Dot notation path (e.g., "priority.name")
|
|
139
|
+
* @returns {*}
|
|
140
|
+
*/
|
|
141
|
+
function get(obj, path) {
|
|
142
|
+
if (obj == null || typeof path !== 'string') return undefined;
|
|
143
|
+
const parts = path.split('.');
|
|
144
|
+
let current = obj;
|
|
145
|
+
for (const part of parts) {
|
|
146
|
+
if (current == null) return undefined;
|
|
147
|
+
// Handle array index notation (e.g., "items.0.name")
|
|
148
|
+
const index = parseInt(part, 10);
|
|
149
|
+
if (!isNaN(index) && Array.isArray(current)) {
|
|
150
|
+
current = current[index];
|
|
151
|
+
} else {
|
|
152
|
+
current = current[part];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return current;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Create object with only specified keys
|
|
160
|
+
* @param {Object} obj - Source object
|
|
161
|
+
* @param {Array<string>} keys - Keys to include
|
|
162
|
+
* @returns {Object}
|
|
163
|
+
*/
|
|
164
|
+
function pick(obj, keys) {
|
|
165
|
+
if (obj == null || !Array.isArray(keys)) return {};
|
|
166
|
+
const result = {};
|
|
167
|
+
for (const key of keys) {
|
|
168
|
+
if (key in obj) {
|
|
169
|
+
result[key] = obj[key];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Create object without specified keys
|
|
177
|
+
* @param {Object} obj - Source object
|
|
178
|
+
* @param {Array<string>} keys - Keys to exclude
|
|
179
|
+
* @returns {Object}
|
|
180
|
+
*/
|
|
181
|
+
function omit(obj, keys) {
|
|
182
|
+
if (obj == null) return {};
|
|
183
|
+
const keysSet = new Set(keys || []);
|
|
184
|
+
const result = {};
|
|
185
|
+
for (const key in obj) {
|
|
186
|
+
if (Object.prototype.hasOwnProperty.call(obj, key) && !keysSet.has(key)) {
|
|
187
|
+
result[key] = obj[key];
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// ============================================================================
|
|
194
|
+
// Date Helpers
|
|
195
|
+
// ============================================================================
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Parse date string to timestamp (milliseconds)
|
|
199
|
+
* @param {string|number|Date} value - Date value to parse
|
|
200
|
+
* @returns {number|null}
|
|
201
|
+
*/
|
|
202
|
+
function parseDate(value) {
|
|
203
|
+
if (value == null) return null;
|
|
204
|
+
if (typeof value === 'number') return value;
|
|
205
|
+
const ts = Date.parse(value);
|
|
206
|
+
return isNaN(ts) ? null : ts;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Format timestamp to string
|
|
211
|
+
* @param {number|string|Date} ts - Timestamp or date
|
|
212
|
+
* @param {string} [format] - Format string (simplified: 'iso', 'date', 'time', or 'datetime')
|
|
213
|
+
* @returns {string}
|
|
214
|
+
*/
|
|
215
|
+
function formatDate(ts, format) {
|
|
216
|
+
const date = new Date(typeof ts === 'number' ? ts : Date.parse(ts));
|
|
217
|
+
if (isNaN(date.getTime())) return '';
|
|
218
|
+
|
|
219
|
+
switch (format) {
|
|
220
|
+
case 'date':
|
|
221
|
+
return date.toISOString().split('T')[0];
|
|
222
|
+
case 'time':
|
|
223
|
+
return date.toISOString().split('T')[1].split('.')[0];
|
|
224
|
+
case 'datetime':
|
|
225
|
+
return date.toISOString().replace('T', ' ').split('.')[0];
|
|
226
|
+
case 'iso':
|
|
227
|
+
default:
|
|
228
|
+
return date.toISOString();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Calculate days between two dates
|
|
234
|
+
* @param {string|number|Date} date1 - First date
|
|
235
|
+
* @param {string|number|Date} date2 - Second date
|
|
236
|
+
* @returns {number}
|
|
237
|
+
*/
|
|
238
|
+
function daysBetween(date1, date2) {
|
|
239
|
+
const ts1 = parseDate(date1);
|
|
240
|
+
const ts2 = parseDate(date2);
|
|
241
|
+
if (ts1 == null || ts2 == null) return 0;
|
|
242
|
+
const msPerDay = 24 * 60 * 60 * 1000;
|
|
243
|
+
return Math.round(Math.abs(ts2 - ts1) / msPerDay);
|
|
244
|
+
}
|
|
245
|
+
`;
|
|
246
|
+
/**
|
|
247
|
+
* Get the JavaScript code for helper functions
|
|
248
|
+
*/
|
|
249
|
+
export function getHelperFunctionsCode() {
|
|
250
|
+
return HELPER_FUNCTIONS_JS;
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/utils/sandbox/helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0OlC,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox Executor
|
|
3
|
+
*
|
|
4
|
+
* Main entry point for executing LLM-generated JavaScript transformations
|
|
5
|
+
* in a secure QuickJS WebAssembly sandbox.
|
|
6
|
+
*/
|
|
7
|
+
import type { TransformInput, TransformResult, TransformError, TransformContext } from "./types.js";
|
|
8
|
+
export type { TransformInput, TransformResult, TransformError, TransformContext, SandboxLimits, TableConfig, ListConfig, TableColumn, LinkConfig, StyleConfig, ConditionalFormat, FilterCondition, } from "./types.js";
|
|
9
|
+
export { BufferTransformInputSchema, type BufferTransformInput } from "./schema.js";
|
|
10
|
+
/**
|
|
11
|
+
* Execute JavaScript code in a QuickJS sandbox
|
|
12
|
+
*
|
|
13
|
+
* @param input - Transform input (inputs, code, limits)
|
|
14
|
+
* @param context - Transform context (URLs for link generation)
|
|
15
|
+
* @param inputData - Pre-loaded input data (buffer contents as parsed JSON)
|
|
16
|
+
* @returns Transform result or error
|
|
17
|
+
*/
|
|
18
|
+
export declare function executeTransform(input: TransformInput, context: TransformContext, inputData: Record<string, unknown>): Promise<TransformResult | TransformError>;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,cAAc,EACd,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,cAAc,EACd,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,0BAA0B,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAsCpF;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,gBAAgB,EACzB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,OAAO,CAAC,eAAe,GAAG,cAAc,CAAC,CA8K3C"}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox Executor
|
|
3
|
+
*
|
|
4
|
+
* Main entry point for executing LLM-generated JavaScript transformations
|
|
5
|
+
* in a secure QuickJS WebAssembly sandbox.
|
|
6
|
+
*/
|
|
7
|
+
import { getQuickJS } from "quickjs-emscripten";
|
|
8
|
+
import { getHelperFunctionsCode } from "./helpers.js";
|
|
9
|
+
import { getFormatterFunctionsCode } from "./formatters.js";
|
|
10
|
+
export { BufferTransformInputSchema } from "./schema.js";
|
|
11
|
+
/** Default execution timeout in milliseconds */
|
|
12
|
+
const DEFAULT_TIMEOUT_MS = 5000;
|
|
13
|
+
/** Default memory limit in bytes (50MB) */
|
|
14
|
+
const DEFAULT_MEMORY_LIMIT = 50 * 1024 * 1024;
|
|
15
|
+
/** Maximum string length for JSON serialization */
|
|
16
|
+
const MAX_JSON_LENGTH = 10 * 1024 * 1024; // 10MB
|
|
17
|
+
/**
|
|
18
|
+
* Create a transform error
|
|
19
|
+
*/
|
|
20
|
+
function createError(message, code, details) {
|
|
21
|
+
return {
|
|
22
|
+
error: true,
|
|
23
|
+
message,
|
|
24
|
+
code,
|
|
25
|
+
details,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Serialize a value for injection into sandbox
|
|
30
|
+
*/
|
|
31
|
+
function serializeForSandbox(value) {
|
|
32
|
+
const json = JSON.stringify(value);
|
|
33
|
+
if (json.length > MAX_JSON_LENGTH) {
|
|
34
|
+
throw new Error(`Value too large to serialize (${json.length} bytes)`);
|
|
35
|
+
}
|
|
36
|
+
return json;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Execute JavaScript code in a QuickJS sandbox
|
|
40
|
+
*
|
|
41
|
+
* @param input - Transform input (inputs, code, limits)
|
|
42
|
+
* @param context - Transform context (URLs for link generation)
|
|
43
|
+
* @param inputData - Pre-loaded input data (buffer contents as parsed JSON)
|
|
44
|
+
* @returns Transform result or error
|
|
45
|
+
*/
|
|
46
|
+
export async function executeTransform(input, context, inputData) {
|
|
47
|
+
const QuickJS = await getQuickJS();
|
|
48
|
+
// Get limits with defaults
|
|
49
|
+
const timeout = input.limits?.timeout ?? DEFAULT_TIMEOUT_MS;
|
|
50
|
+
const memoryLimit = input.limits?.memory ?? DEFAULT_MEMORY_LIMIT;
|
|
51
|
+
// Create runtime with memory limit
|
|
52
|
+
const runtime = QuickJS.newRuntime();
|
|
53
|
+
runtime.setMemoryLimit(memoryLimit);
|
|
54
|
+
// Set up interrupt handler for timeout
|
|
55
|
+
const startTime = Date.now();
|
|
56
|
+
let interrupted = false;
|
|
57
|
+
runtime.setInterruptHandler(() => {
|
|
58
|
+
if (Date.now() - startTime > timeout) {
|
|
59
|
+
interrupted = true;
|
|
60
|
+
return true; // Interrupt execution
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
});
|
|
64
|
+
// Create context
|
|
65
|
+
const ctx = runtime.newContext();
|
|
66
|
+
try {
|
|
67
|
+
// Inject helper functions
|
|
68
|
+
const helperCode = getHelperFunctionsCode();
|
|
69
|
+
const helperResult = ctx.evalCode(helperCode);
|
|
70
|
+
if (helperResult.error) {
|
|
71
|
+
const errorValue = ctx.dump(helperResult.error);
|
|
72
|
+
helperResult.error.dispose();
|
|
73
|
+
return createError(`Failed to initialize helpers: ${errorValue}`, "RUNTIME_ERROR");
|
|
74
|
+
}
|
|
75
|
+
helperResult.value.dispose();
|
|
76
|
+
// Inject formatter functions
|
|
77
|
+
const formatterCode = getFormatterFunctionsCode();
|
|
78
|
+
const formatterResult = ctx.evalCode(formatterCode);
|
|
79
|
+
if (formatterResult.error) {
|
|
80
|
+
const errorValue = ctx.dump(formatterResult.error);
|
|
81
|
+
formatterResult.error.dispose();
|
|
82
|
+
return createError(`Failed to initialize formatters: ${errorValue}`, "RUNTIME_ERROR");
|
|
83
|
+
}
|
|
84
|
+
formatterResult.value.dispose();
|
|
85
|
+
// Inject context variables (URLs)
|
|
86
|
+
if (context.jiraUrl) {
|
|
87
|
+
const jiraUrlResult = ctx.evalCode(`const JIRA_URL = ${JSON.stringify(context.jiraUrl)};`);
|
|
88
|
+
if (jiraUrlResult.error) {
|
|
89
|
+
jiraUrlResult.error.dispose();
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
jiraUrlResult.value.dispose();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
const jiraUrlResult = ctx.evalCode(`const JIRA_URL = undefined;`);
|
|
97
|
+
if (jiraUrlResult.error) {
|
|
98
|
+
jiraUrlResult.error.dispose();
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
jiraUrlResult.value.dispose();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (context.confluenceUrl) {
|
|
105
|
+
const confUrlResult = ctx.evalCode(`const CONFLUENCE_URL = ${JSON.stringify(context.confluenceUrl)};`);
|
|
106
|
+
if (confUrlResult.error) {
|
|
107
|
+
confUrlResult.error.dispose();
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
confUrlResult.value.dispose();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
const confUrlResult = ctx.evalCode(`const CONFLUENCE_URL = undefined;`);
|
|
115
|
+
if (confUrlResult.error) {
|
|
116
|
+
confUrlResult.error.dispose();
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
confUrlResult.value.dispose();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Inject input data as globals
|
|
123
|
+
for (const [name, data] of Object.entries(inputData)) {
|
|
124
|
+
// Validate variable name
|
|
125
|
+
if (!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)) {
|
|
126
|
+
return createError(`Invalid input name: "${name}". Must be a valid JavaScript identifier.`, "INVALID_INPUT", { name });
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
const serialized = serializeForSandbox(data);
|
|
130
|
+
const injectCode = `const ${name} = ${serialized};`;
|
|
131
|
+
const injectResult = ctx.evalCode(injectCode);
|
|
132
|
+
if (injectResult.error) {
|
|
133
|
+
const errorValue = ctx.dump(injectResult.error);
|
|
134
|
+
injectResult.error.dispose();
|
|
135
|
+
return createError(`Failed to inject input "${name}": ${errorValue}`, "INVALID_INPUT", { name });
|
|
136
|
+
}
|
|
137
|
+
injectResult.value.dispose();
|
|
138
|
+
}
|
|
139
|
+
catch (e) {
|
|
140
|
+
return createError(`Failed to serialize input "${name}": ${e.message}`, "INVALID_INPUT", { name });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Wrap user code in IIFE
|
|
144
|
+
const wrappedCode = `(function() {\n${input.code}\n})()`;
|
|
145
|
+
// Execute user code
|
|
146
|
+
const result = ctx.evalCode(wrappedCode);
|
|
147
|
+
// Check for timeout
|
|
148
|
+
if (interrupted) {
|
|
149
|
+
if (result.error)
|
|
150
|
+
result.error.dispose();
|
|
151
|
+
else if (result.value)
|
|
152
|
+
result.value.dispose();
|
|
153
|
+
return createError(`Execution timeout: code took longer than ${timeout}ms`, "TIMEOUT", { timeout });
|
|
154
|
+
}
|
|
155
|
+
// Check for runtime error
|
|
156
|
+
if (result.error) {
|
|
157
|
+
const errorValue = ctx.dump(result.error);
|
|
158
|
+
result.error.dispose();
|
|
159
|
+
// Try to extract line/column info
|
|
160
|
+
let details = {};
|
|
161
|
+
if (typeof errorValue === "object" && errorValue !== null) {
|
|
162
|
+
const errObj = errorValue;
|
|
163
|
+
if ("stack" in errObj) {
|
|
164
|
+
details.stack = String(errObj.stack);
|
|
165
|
+
// Try to parse line number from stack
|
|
166
|
+
const lineMatch = String(errObj.stack).match(/:(\d+):(\d+)/);
|
|
167
|
+
if (lineMatch) {
|
|
168
|
+
details.line = parseInt(lineMatch[1], 10) - 1; // Adjust for IIFE wrapper
|
|
169
|
+
details.column = parseInt(lineMatch[2], 10);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return createError(`Runtime error: ${typeof errorValue === "object" ? JSON.stringify(errorValue) : errorValue}`, "RUNTIME_ERROR", details);
|
|
174
|
+
}
|
|
175
|
+
// Extract return value
|
|
176
|
+
const returnValue = ctx.dump(result.value);
|
|
177
|
+
result.value.dispose();
|
|
178
|
+
// Process return value
|
|
179
|
+
return processReturnValue(returnValue);
|
|
180
|
+
}
|
|
181
|
+
finally {
|
|
182
|
+
// Clean up
|
|
183
|
+
ctx.dispose();
|
|
184
|
+
runtime.dispose();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Check if value is a marked XHTML object
|
|
189
|
+
*/
|
|
190
|
+
function isXhtmlMarked(value) {
|
|
191
|
+
return (typeof value === "object" &&
|
|
192
|
+
value !== null &&
|
|
193
|
+
"__xhtml" in value &&
|
|
194
|
+
value.__xhtml === true);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Check if value is a marked Markdown object
|
|
198
|
+
*/
|
|
199
|
+
function isMarkdownMarked(value) {
|
|
200
|
+
return (typeof value === "object" &&
|
|
201
|
+
value !== null &&
|
|
202
|
+
"__markdown" in value &&
|
|
203
|
+
value.__markdown === true);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Process the return value from sandbox execution
|
|
207
|
+
* Determines if it's XHTML, Markdown, single output, or multiple outputs
|
|
208
|
+
*/
|
|
209
|
+
function processReturnValue(value) {
|
|
210
|
+
// Handle undefined/null
|
|
211
|
+
if (value === undefined || value === null) {
|
|
212
|
+
return createError("Code must return a value. Use 'return' to specify the output.", "INVALID_RETURN");
|
|
213
|
+
}
|
|
214
|
+
// Check for XHTML marker (from toTable/toList)
|
|
215
|
+
if (isXhtmlMarked(value)) {
|
|
216
|
+
return {
|
|
217
|
+
contentType: "xhtml",
|
|
218
|
+
xhtmlContent: value.content,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
// Check for Markdown marker (from toMarkdownTable/toMarkdownList)
|
|
222
|
+
if (isMarkdownMarked(value)) {
|
|
223
|
+
return {
|
|
224
|
+
contentType: "markdown",
|
|
225
|
+
markdownContent: value.content,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
// Check for multiple outputs (object with at least one __xhtml or __markdown value)
|
|
229
|
+
// We only split into multiple outputs when there are format markers to avoid
|
|
230
|
+
// misinterpreting regular objects (like groupBy results) as multiple outputs
|
|
231
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
232
|
+
const obj = value;
|
|
233
|
+
const keys = Object.keys(obj);
|
|
234
|
+
// Check if any values are XHTML or Markdown objects
|
|
235
|
+
const hasFormatted = keys.some((k) => isXhtmlMarked(obj[k]) || isMarkdownMarked(obj[k]));
|
|
236
|
+
if (hasFormatted) {
|
|
237
|
+
// Multiple outputs - return as multipleOutputs
|
|
238
|
+
const outputs = {};
|
|
239
|
+
for (const [key, val] of Object.entries(obj)) {
|
|
240
|
+
if (isXhtmlMarked(val)) {
|
|
241
|
+
outputs[key] = {
|
|
242
|
+
contentType: "xhtml",
|
|
243
|
+
content: val.content,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
else if (isMarkdownMarked(val)) {
|
|
247
|
+
outputs[key] = {
|
|
248
|
+
contentType: "markdown",
|
|
249
|
+
content: val.content,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
outputs[key] = { contentType: "json", content: val };
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
contentType: "json",
|
|
258
|
+
multipleOutputs: outputs,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
// Single JSON output (array or object)
|
|
263
|
+
return {
|
|
264
|
+
contentType: "json",
|
|
265
|
+
jsonContent: value,
|
|
266
|
+
itemCount: Array.isArray(value) ? value.length : undefined,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAA4C,MAAM,oBAAo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ACN,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;gBACvD,CAAC;YACH,CAAC;YACD,OAAO;gBACL,WAAW,EAAE,MAAM;gBACnB,eAAe,EAAE,OAAO;aAGzB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,uCAAuC;IACvC,OAAO;QACL,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE,KAAK;QAClB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;KACb,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox Schemas
|
|
3
|
+
*
|
|
4
|
+
* Zod validation schemas for buffer_transform tool input.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
/**
|
|
8
|
+
* Schema for execution limits
|
|
9
|
+
*/
|
|
10
|
+
export declare const SandboxLimitsSchema: z.ZodObject<{
|
|
11
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
memory: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
timeout?: number | undefined;
|
|
15
|
+
memory?: number | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
timeout?: number | undefined;
|
|
18
|
+
memory?: number | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Schema for buffer_transform tool input
|
|
22
|
+
*/
|
|
23
|
+
export declare const BufferTransformInputSchema: z.ZodObject<{
|
|
24
|
+
inputs: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
25
|
+
code: z.ZodString;
|
|
26
|
+
limits: z.ZodOptional<z.ZodObject<{
|
|
27
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
memory: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
timeout?: number | undefined;
|
|
31
|
+
memory?: number | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
timeout?: number | undefined;
|
|
34
|
+
memory?: number | undefined;
|
|
35
|
+
}>>;
|
|
36
|
+
}, "strip", z.ZodTypeAny, {
|
|
37
|
+
code: string;
|
|
38
|
+
inputs: Record<string, string>;
|
|
39
|
+
limits?: {
|
|
40
|
+
timeout?: number | undefined;
|
|
41
|
+
memory?: number | undefined;
|
|
42
|
+
} | undefined;
|
|
43
|
+
}, {
|
|
44
|
+
code: string;
|
|
45
|
+
inputs: Record<string, string>;
|
|
46
|
+
limits?: {
|
|
47
|
+
timeout?: number | undefined;
|
|
48
|
+
memory?: number | undefined;
|
|
49
|
+
} | undefined;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Type for validated input
|
|
53
|
+
*/
|
|
54
|
+
export type BufferTransformInput = z.infer<typeof BufferTransformInputSchema>;
|
|
55
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/utils/sandbox/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;EAa9B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWrC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
|