@magclaw/cli-core 0.1.36 → 0.1.37
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/cli.js +20 -6
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -1785,6 +1785,15 @@ function contextArray(value) {
|
|
|
1785
1785
|
return Array.isArray(value) ? value : [];
|
|
1786
1786
|
}
|
|
1787
1787
|
|
|
1788
|
+
function errorDetail(error) {
|
|
1789
|
+
const parts = [
|
|
1790
|
+
error?.message,
|
|
1791
|
+
error?.cause?.code,
|
|
1792
|
+
error?.cause?.message,
|
|
1793
|
+
].map((item) => String(item || '').trim()).filter(Boolean);
|
|
1794
|
+
return [...new Set(parts)].join(' / ') || 'unknown error';
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1788
1797
|
function contextText(value, limit = 1200) {
|
|
1789
1798
|
return String(value || '').replace(/\s+/g, ' ').trim().slice(0, limit);
|
|
1790
1799
|
}
|
|
@@ -3233,17 +3242,13 @@ class CodexAgentSession {
|
|
|
3233
3242
|
input: { type: 'image', url: dataUrl },
|
|
3234
3243
|
};
|
|
3235
3244
|
} catch (error) {
|
|
3236
|
-
logWarning('attachments', `Could not read image attachment ${attachmentId} for agent ${this.agent.id}: ${error
|
|
3245
|
+
logWarning('attachments', `Could not read image attachment ${attachmentId} for agent ${this.agent.id}: ${errorDetail(error)}`);
|
|
3237
3246
|
return null;
|
|
3238
3247
|
}
|
|
3239
3248
|
}
|
|
3240
3249
|
|
|
3241
3250
|
async imageInputFromContextReference(reference = {}, { preferReadAttachment = false } = {}) {
|
|
3242
3251
|
if (!isContextImageReference(reference)) return null;
|
|
3243
|
-
if (preferReadAttachment) {
|
|
3244
|
-
const resolved = await this.readAttachmentImageInput(reference);
|
|
3245
|
-
if (resolved) return resolved;
|
|
3246
|
-
}
|
|
3247
3252
|
const dataUrl = contextDataImageUrl(reference.dataUrl || reference.url || reference.downloadUrl);
|
|
3248
3253
|
if (dataUrl) {
|
|
3249
3254
|
return {
|
|
@@ -3251,6 +3256,10 @@ class CodexAgentSession {
|
|
|
3251
3256
|
input: { type: 'image', url: dataUrl },
|
|
3252
3257
|
};
|
|
3253
3258
|
}
|
|
3259
|
+
if (preferReadAttachment) {
|
|
3260
|
+
const resolved = await this.readAttachmentImageInput(reference);
|
|
3261
|
+
if (resolved) return resolved;
|
|
3262
|
+
}
|
|
3254
3263
|
const url = remoteImageUrl(reference.url || reference.downloadUrl || '', this.serverUrl, reference.description);
|
|
3255
3264
|
if (url) {
|
|
3256
3265
|
return {
|
|
@@ -3272,7 +3281,12 @@ class CodexAgentSession {
|
|
|
3272
3281
|
const inputs = [];
|
|
3273
3282
|
const seen = new Set();
|
|
3274
3283
|
const pack = message?.contextPack || {};
|
|
3275
|
-
const
|
|
3284
|
+
const allAttachments = contextArray(pack.attachments);
|
|
3285
|
+
const currentAttachmentIds = new Set(contextArray(message?.attachmentIds).map((id) => String(id || '').trim()).filter(Boolean));
|
|
3286
|
+
const attachmentsById = new Map(allAttachments.map((attachment) => [String(attachment?.id || '').trim(), attachment]));
|
|
3287
|
+
const attachments = currentAttachmentIds.size
|
|
3288
|
+
? [...currentAttachmentIds].map((id) => attachmentsById.get(id) || { id, type: 'image/*' })
|
|
3289
|
+
: allAttachments;
|
|
3276
3290
|
for (const attachment of attachments) {
|
|
3277
3291
|
const resolved = await this.imageInputFromContextReference(attachment, { preferReadAttachment: true });
|
|
3278
3292
|
if (!resolved || seen.has(resolved.key)) continue;
|