@gakim-digital/dexter-bridge 0.11.11 → 0.11.12
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/package.json +1 -1
- package/src/framerAgentTools.js +67 -14
package/package.json
CHANGED
package/src/framerAgentTools.js
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
const require = createRequire(import.meta.url);
|
|
21
21
|
const MAX_OUTPUT_BYTES = 2 * 1024 * 1024;
|
|
22
22
|
const MAX_MODEL_RESULT_BYTES = 120 * 1024;
|
|
23
|
+
const MAX_CODE_FILE_CONTENT_CHARS = 200_000;
|
|
23
24
|
const MAX_SCREENSHOT_BYTES = 4 * 1024 * 1024;
|
|
24
25
|
const MAX_SCREENSHOTS_PER_CALL = 4;
|
|
25
26
|
const SCREENSHOT_FETCH_TIMEOUT_MS = 20_000;
|
|
@@ -479,7 +480,7 @@ export const FRAMER_AGENT_TOOL_DEFINITIONS = [
|
|
|
479
480
|
{
|
|
480
481
|
name: 'framer_read_code_file',
|
|
481
482
|
description:
|
|
482
|
-
'Read an existing Framer code file by its exact project path. Use this instead of generic JavaScript when inspecting a code component or override.
|
|
483
|
+
'Read the complete source of an existing Framer code file by its exact project path. Use this instead of generic JavaScript when inspecting a code component or override. Files up to 200,000 characters are returned without the general Framer result cap, together with completeness metadata, a source hash, and the version ID required for a safe update.',
|
|
483
484
|
inputSchema: {
|
|
484
485
|
type: 'object',
|
|
485
486
|
properties: {
|
|
@@ -498,7 +499,10 @@ export const FRAMER_AGENT_TOOL_DEFINITIONS = [
|
|
|
498
499
|
properties: {
|
|
499
500
|
path: { type: 'string', minLength: 1, maxLength: 1_000 },
|
|
500
501
|
expectedVersionId: { type: 'string', minLength: 1, maxLength: 300 },
|
|
501
|
-
content: {
|
|
502
|
+
content: {
|
|
503
|
+
type: 'string',
|
|
504
|
+
maxLength: MAX_CODE_FILE_CONTENT_CHARS,
|
|
505
|
+
},
|
|
502
506
|
},
|
|
503
507
|
required: ['path', 'expectedVersionId', 'content'],
|
|
504
508
|
additionalProperties: false,
|
|
@@ -738,6 +742,8 @@ function codeFileResultError(result, fallbackCode, fallbackMessage) {
|
|
|
738
742
|
? 404
|
|
739
743
|
: code === 'FRAMER_CODE_FILE_VERSION_CONFLICT'
|
|
740
744
|
? 409
|
|
745
|
+
: code === 'FRAMER_CODE_FILE_TOO_LARGE'
|
|
746
|
+
? 413
|
|
741
747
|
: 400;
|
|
742
748
|
return toolError(code, message, statusCode);
|
|
743
749
|
}
|
|
@@ -1897,6 +1903,13 @@ export function createFramerAgentToolRuntime({
|
|
|
1897
1903
|
...(branchChange ? { branch: branchChange } : {}),
|
|
1898
1904
|
};
|
|
1899
1905
|
};
|
|
1906
|
+
const normalizedCodeFileReadResult = (result) => ({
|
|
1907
|
+
result: parseStructuredOutput(result.stdout),
|
|
1908
|
+
...(result.stderr.trim()
|
|
1909
|
+
? { diagnostics: boundedText(result.stderr, 20_000) }
|
|
1910
|
+
: {}),
|
|
1911
|
+
...(branchChange ? { branch: branchChange } : {}),
|
|
1912
|
+
});
|
|
1900
1913
|
|
|
1901
1914
|
const markInspection = ({
|
|
1902
1915
|
visual = false,
|
|
@@ -2843,17 +2856,29 @@ export function createFramerAgentToolRuntime({
|
|
|
2843
2856
|
' },',
|
|
2844
2857
|
' }));',
|
|
2845
2858
|
' } else {',
|
|
2846
|
-
'
|
|
2847
|
-
|
|
2848
|
-
'
|
|
2849
|
-
'
|
|
2850
|
-
'
|
|
2851
|
-
'
|
|
2852
|
-
'
|
|
2853
|
-
'
|
|
2854
|
-
'
|
|
2855
|
-
' }
|
|
2856
|
-
' }
|
|
2859
|
+
' const content = typeof file.content === "string" ? file.content : "";',
|
|
2860
|
+
` const maximumContentChars = ${MAX_CODE_FILE_CONTENT_CHARS};`,
|
|
2861
|
+
' if (content.length > maximumContentChars) {',
|
|
2862
|
+
' console.log(JSON.stringify({',
|
|
2863
|
+
' ok: false,',
|
|
2864
|
+
' error: {',
|
|
2865
|
+
' code: "FRAMER_CODE_FILE_TOO_LARGE",',
|
|
2866
|
+
' message: `The Framer code file contains ${content.length} characters; Dexter supports complete code-file reads up to ${maximumContentChars} characters.`,',
|
|
2867
|
+
' },',
|
|
2868
|
+
' }));',
|
|
2869
|
+
' } else {',
|
|
2870
|
+
' console.log(JSON.stringify({',
|
|
2871
|
+
' ok: true,',
|
|
2872
|
+
' file: {',
|
|
2873
|
+
' id: file.id,',
|
|
2874
|
+
' name: file.name,',
|
|
2875
|
+
' path: file.path,',
|
|
2876
|
+
' versionId: file.versionId,',
|
|
2877
|
+
' content,',
|
|
2878
|
+
' exports: file.exports,',
|
|
2879
|
+
' },',
|
|
2880
|
+
' }));',
|
|
2881
|
+
' }',
|
|
2857
2882
|
' }',
|
|
2858
2883
|
'} catch (error) {',
|
|
2859
2884
|
' console.log(JSON.stringify({',
|
|
@@ -2874,6 +2899,31 @@ export function createFramerAgentToolRuntime({
|
|
|
2874
2899
|
`Dexter could not read ${filePath}.`,
|
|
2875
2900
|
);
|
|
2876
2901
|
}
|
|
2902
|
+
const content =
|
|
2903
|
+
typeof parsed.file?.content === 'string'
|
|
2904
|
+
? parsed.file.content
|
|
2905
|
+
: '';
|
|
2906
|
+
result = {
|
|
2907
|
+
...result,
|
|
2908
|
+
stdout: JSON.stringify({
|
|
2909
|
+
...parsed,
|
|
2910
|
+
file: {
|
|
2911
|
+
...parsed.file,
|
|
2912
|
+
content,
|
|
2913
|
+
complete: true,
|
|
2914
|
+
contentChars: content.length,
|
|
2915
|
+
contentBytes: Buffer.byteLength(content, 'utf8'),
|
|
2916
|
+
lineCount:
|
|
2917
|
+
content.length === 0
|
|
2918
|
+
? 0
|
|
2919
|
+
: content.split(/\r\n|\r|\n/).length,
|
|
2920
|
+
sourceHash: crypto
|
|
2921
|
+
.createHash('sha256')
|
|
2922
|
+
.update(content)
|
|
2923
|
+
.digest('hex'),
|
|
2924
|
+
},
|
|
2925
|
+
}),
|
|
2926
|
+
};
|
|
2877
2927
|
markInspection();
|
|
2878
2928
|
} else if (name === 'framer_update_code_file') {
|
|
2879
2929
|
const filePath = normalizeCodeFilePath(rawArguments.path);
|
|
@@ -3129,7 +3179,10 @@ export function createFramerAgentToolRuntime({
|
|
|
3129
3179
|
: 'Finished inspecting the Framer project',
|
|
3130
3180
|
durationMs,
|
|
3131
3181
|
});
|
|
3132
|
-
const normalized =
|
|
3182
|
+
const normalized =
|
|
3183
|
+
name === 'framer_read_code_file'
|
|
3184
|
+
? normalizedCodeFileReadResult(result)
|
|
3185
|
+
: normalizedResult(result);
|
|
3133
3186
|
if (name !== 'framer_read_project') return normalized;
|
|
3134
3187
|
const screenshotCount = screenshotQueries(rawArguments).length;
|
|
3135
3188
|
return {
|