@myagentroam/agent 0.11.22 → 0.11.23
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.
|
@@ -122,9 +122,11 @@ export function inspectContextGc(input) {
|
|
|
122
122
|
const media = input.inlineMedia;
|
|
123
123
|
if (!media || (media.reason === 'TEXT_GC' && !text.plan))
|
|
124
124
|
return text;
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
|
|
125
|
+
const currentUsage = modelContextUsage(input.usage);
|
|
126
|
+
const usageRecord = (currentUsage === undefined ? undefined : latestUsageRecord(input.records, input.modelId)) ??
|
|
127
|
+
input.records.at(-1);
|
|
128
|
+
const contextUsageTokens = currentUsage ?? 0;
|
|
129
|
+
if (!usageRecord)
|
|
128
130
|
return text;
|
|
129
131
|
input = {
|
|
130
132
|
...input,
|
|
@@ -500,7 +502,8 @@ function finalizePlan(input, evaluated, includeMedia = false) {
|
|
|
500
502
|
boundarySequence: evaluated.boundarySequence,
|
|
501
503
|
replacements,
|
|
502
504
|
trigger: {
|
|
503
|
-
usageSequence:
|
|
505
|
+
usageSequence: modelContextUsage(input.usage) !== undefined &&
|
|
506
|
+
isRecord(evaluated.usageRecord.payload) &&
|
|
504
507
|
evaluated.usageRecord.payload.type === 'usage.updated'
|
|
505
508
|
? evaluated.usageRecord.sequence
|
|
506
509
|
: null,
|
|
@@ -650,6 +650,8 @@ function triggerMatchesRecords(records, recordsBySequence, payload) {
|
|
|
650
650
|
modelId = record.payload.modelId;
|
|
651
651
|
if (isPositiveInteger(record.payload.contextWindowTokens))
|
|
652
652
|
contextWindowTokens = record.payload.contextWindowTokens;
|
|
653
|
+
if (withoutUsage)
|
|
654
|
+
latestMatchingUsageSequence = undefined;
|
|
653
655
|
}
|
|
654
656
|
const matchingConfiguration = modelId === payload.trigger.modelId &&
|
|
655
657
|
contextWindowTokens === payload.trigger.contextWindowTokens;
|
|
@@ -7,12 +7,13 @@ export interface ImageMetadata {
|
|
|
7
7
|
width: number;
|
|
8
8
|
height: number;
|
|
9
9
|
pages: number;
|
|
10
|
+
mimeType: ViewImageResult['mimeType'];
|
|
10
11
|
}
|
|
11
12
|
export interface ProcessedImage {
|
|
12
13
|
bytes: Buffer;
|
|
13
14
|
width: number;
|
|
14
15
|
height: number;
|
|
15
|
-
mimeType: '
|
|
16
|
+
mimeType: ViewImageResult['mimeType'];
|
|
16
17
|
sourceWidth?: number;
|
|
17
18
|
sourceHeight?: number;
|
|
18
19
|
region?: ViewImageRegion;
|
|
@@ -17,7 +17,7 @@ export async function readImageMetadata(data, mimeType, signal) {
|
|
|
17
17
|
const width = metadata.autoOrient?.width ?? metadata.width;
|
|
18
18
|
const height = metadata.autoOrient?.height ?? metadata.height;
|
|
19
19
|
assertPixelLimit(width, height);
|
|
20
|
-
return { width, height, pages: metadata.pages ?? 1 };
|
|
20
|
+
return { width, height, pages: metadata.pages ?? 1, mimeType };
|
|
21
21
|
}
|
|
22
22
|
catch (error) {
|
|
23
23
|
throwIfAborted(signal);
|
|
@@ -61,7 +61,18 @@ export async function processImage(data, metadata, options, signal) {
|
|
|
61
61
|
withoutEnlargement: true
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
switch (metadata.mimeType) {
|
|
65
|
+
case 'image/png':
|
|
66
|
+
image.png();
|
|
67
|
+
break;
|
|
68
|
+
case 'image/jpeg':
|
|
69
|
+
image.jpeg({ quality: 90 });
|
|
70
|
+
break;
|
|
71
|
+
case 'image/webp':
|
|
72
|
+
image.webp({ quality: 90 });
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
const output = await image.toBuffer({ resolveWithObject: true });
|
|
65
76
|
throwIfAborted(signal);
|
|
66
77
|
if (output.data.byteLength > TOOL_EXECUTION_LIMITS.viewImageMaxBytes)
|
|
67
78
|
throw imageOutputLimit();
|
|
@@ -75,7 +86,7 @@ export async function processImage(data, metadata, options, signal) {
|
|
|
75
86
|
bytes: output.data,
|
|
76
87
|
width: output.info.width,
|
|
77
88
|
height: output.info.height,
|
|
78
|
-
mimeType:
|
|
89
|
+
mimeType: metadata.mimeType,
|
|
79
90
|
...(changedRegion || changedSize
|
|
80
91
|
? { sourceWidth: metadata.width, sourceHeight: metadata.height }
|
|
81
92
|
: {}),
|