iagenify 0.3.3 → 0.4.1
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/README.md +385 -360
- package/dist/index.cjs +131 -37
- package/dist/index.js +131 -37
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3403,25 +3403,30 @@ function sendMailTool() {
|
|
|
3403
3403
|
return {
|
|
3404
3404
|
// Catégorie `send` (P39) : demandée à chaque envoi, même en Full access, sans « toujours ».
|
|
3405
3405
|
category: "send",
|
|
3406
|
-
|
|
3406
|
+
// P82 : `html` pour un message mis en forme, `attach` joint vraiment les fichiers (25 Mo au total). Avant,
|
|
3407
|
+
// `attach` lisait les fichiers puis les perdait — la route d'envoi n'en prenait pas — et l'agent disait « envoyé ».
|
|
3408
|
+
description: "Send a message FROM one of the account's own addresses, signed with their domain's key. The account must own a mailbox: there is no other way to send, so if it has none, say so and point at Mail rather than improvising. reply_to_message answers one: the subject, recipient and thread are kept and the original quoted. html sends a formatted message (inline styles only, tables for layout: mail clients ignore stylesheets); body is then the plain-text fallback. attach joins workspace files, 25 MB in all, executables refused. The user approves every send, in every mode. Accepted by the relay is not delivered \u2014 never tell them it arrived.",
|
|
3407
3409
|
parameters: {
|
|
3408
3410
|
box: { type: "string", description: "Which of its addresses writes; optional when it owns one" },
|
|
3409
3411
|
to: { type: "string", required: true, description: "Comma-separated, at most 5" },
|
|
3410
3412
|
cc: { type: "string", description: "Comma-separated" },
|
|
3413
|
+
bcc: { type: "string", description: "Comma-separated, hidden from the other recipients" },
|
|
3411
3414
|
subject: { type: "string", description: "Required unless replying" },
|
|
3412
|
-
body: { type: "string",
|
|
3415
|
+
body: { type: "string", description: "Plain text; blank lines separate paragraphs. Required unless html is given" },
|
|
3416
|
+
html: { type: "string", description: "Formatted message: inline styles, no script, no external stylesheet" },
|
|
3413
3417
|
reply_to_message: { type: "string", description: "Id of the message being answered" },
|
|
3414
|
-
attach: { type: "array", items: { type: "string" }, description: "Workspace files" },
|
|
3418
|
+
attach: { type: "array", items: { type: "string" }, description: "Workspace files to attach" },
|
|
3415
3419
|
signature: { type: "boolean", description: "false sends without the mailbox signature" }
|
|
3416
3420
|
},
|
|
3417
|
-
check({ to, subject, reply_to_message, body } = {}) {
|
|
3421
|
+
check({ to, cc, bcc, subject, reply_to_message, body, html } = {}) {
|
|
3418
3422
|
const recipients = addresses(to);
|
|
3419
3423
|
if (!recipients.length) fail4('"to" is required: at least one recipient.');
|
|
3420
3424
|
if (recipients.length > 5) fail4(`At most 5 recipients at a time; you gave ${recipients.length}.`);
|
|
3421
|
-
const bad = recipients.find((a) => !/^[^@\s]+@[^@\s.]+\.[^@\s]+$/.test(a));
|
|
3425
|
+
const bad = [...recipients, ...addresses(cc), ...addresses(bcc)].find((a) => !/^[^@\s]+@[^@\s.]+\.[^@\s]+$/.test(a));
|
|
3422
3426
|
if (bad) fail4(`"${bad}" is not an email address.`);
|
|
3423
3427
|
if (!text(subject) && !text(reply_to_message)) fail4('"subject" is required (or give reply_to_message to answer a message).');
|
|
3424
|
-
if (!text(body)) fail4('"body" is required: write the message in full, as the user would.');
|
|
3428
|
+
if (!text(body) && !text(html)) fail4('"body" or "html" is required: write the message in full, as the user would.');
|
|
3429
|
+
if (/<script\b|\son\w+\s*=|javascript:/i.test(String(html || ""))) fail4('"html" must not carry script, event handlers or javascript: links \u2014 mail clients strip them and spam filters punish them.');
|
|
3425
3430
|
},
|
|
3426
3431
|
async run(args, { api, files }) {
|
|
3427
3432
|
const box = await findBox(api, args.box);
|
|
@@ -3440,26 +3445,30 @@ ${quoted}`;
|
|
|
3440
3445
|
const attachments = [];
|
|
3441
3446
|
for (const path of Array.isArray(args.attach) ? args.attach : addresses(args.attach)) {
|
|
3442
3447
|
const file = await files.read(String(path));
|
|
3443
|
-
attachments.push({
|
|
3448
|
+
attachments.push({ filename: String(path).split("/").pop(), content: file.content, ...file.mimeType ? { contentType: file.mimeType } : {} });
|
|
3444
3449
|
}
|
|
3445
3450
|
const sent = await box.send({
|
|
3446
3451
|
to,
|
|
3447
3452
|
cc: addresses(args.cc),
|
|
3453
|
+
bcc: addresses(args.bcc),
|
|
3448
3454
|
subject,
|
|
3449
3455
|
text: body,
|
|
3456
|
+
...text(args.html) ? { html: text(args.html) } : {},
|
|
3450
3457
|
...attachments.length ? { attachments } : {},
|
|
3451
3458
|
...args.signature === false ? { signature: false } : {}
|
|
3452
3459
|
});
|
|
3460
|
+
const joined = sent.attachments || [];
|
|
3453
3461
|
const relay = sent.relay || {};
|
|
3454
3462
|
return {
|
|
3455
3463
|
output: [
|
|
3456
|
-
`Sent from ${relay.from || box.address} to ${to.join(", ")} \u2014 "${subject}" (${sent.creditsUsed ?? 1} credit).`,
|
|
3464
|
+
`Sent from ${relay.from || box.address} to ${to.join(", ")} \u2014 "${subject}" (${sent.credits ?? sent.creditsUsed ?? 1} credit).`,
|
|
3465
|
+
joined.length ? `Attached: ${joined.map((a) => `${a.filename} (${formatBytes(a.size || 0)})`).join(", ")}.` : "",
|
|
3457
3466
|
relay.name ? `Relay: ${relay.name}${relay.aligned ? ", aligned (the signature is the account's own domain)" : ", NOT aligned \u2014 the recipient sees the relay's address and it may be filtered as spam"}.` : "",
|
|
3458
3467
|
relay.warning || "",
|
|
3459
3468
|
"Accepted by the relay is not delivered: it hands back as soon as the message is queued, and what the recipient's provider then does with it is not reported to us."
|
|
3460
3469
|
].filter(Boolean).join("\n"),
|
|
3461
3470
|
summary: `Mail to ${to[0]}${to.length > 1 ? ` +${to.length - 1}` : ""}`,
|
|
3462
|
-
meta: { box: box.id, to, subject, relay: relay.name || null, aligned: relay.aligned === true, credits: sent.creditsUsed ?? 1 }
|
|
3471
|
+
meta: { box: box.id, to, subject, relay: relay.name || null, aligned: relay.aligned === true, credits: sent.credits ?? sent.creditsUsed ?? 1, attachments: joined.length, html: Boolean(text(args.html)) }
|
|
3463
3472
|
};
|
|
3464
3473
|
}
|
|
3465
3474
|
};
|
|
@@ -5072,20 +5081,26 @@ ${r.text}`).join("\n\n"), 3e4),
|
|
|
5072
5081
|
}
|
|
5073
5082
|
};
|
|
5074
5083
|
}
|
|
5075
|
-
var OMNI_MODELS = ["gemini-omni-1.1-flash-preview"
|
|
5084
|
+
var OMNI_MODELS = ["gemini-omni-1.1-flash-preview"];
|
|
5085
|
+
var OMNI_SECONDS = { min: 3, max: 10, default: 10 };
|
|
5076
5086
|
var IMAGE_MODELS = ["gemini-3.1-flash-image", "gemini-2.5-flash-image", ...OMNI_MODELS];
|
|
5077
5087
|
var VIDEO_MODELS = ["veo-3.1-lite", "veo-3.1-fast", "veo-3.1", ...OMNI_MODELS];
|
|
5078
5088
|
var VIDEO_RESOLUTIONS = {
|
|
5079
5089
|
"veo-3.1": ["720p", "1080p", "4K"],
|
|
5080
5090
|
"veo-3.1-fast": ["720p", "1080p", "4K"],
|
|
5081
5091
|
"veo-3.1-lite": ["720p", "1080p"],
|
|
5082
|
-
// Omni
|
|
5083
|
-
//
|
|
5084
|
-
"gemini-omni-1.1-flash-preview": []
|
|
5085
|
-
"gemini-omni-flash-preview": []
|
|
5092
|
+
// Omni (P83) : les deux résolutions mesurées. La 4K et le 360p existent dans les types de l'API,
|
|
5093
|
+
// mais aucune n'a été mesurée — donc aucune n'a de prix.
|
|
5094
|
+
"gemini-omni-1.1-flash-preview": ["720p", "1080p"]
|
|
5086
5095
|
};
|
|
5087
5096
|
var VIDEO_WITH_AUDIO = ["veo-3.1"];
|
|
5088
5097
|
var VIDEO_DURATIONS = [4, 6, 8];
|
|
5098
|
+
var VIDEO_DURATIONS_BY_MODEL = {
|
|
5099
|
+
"veo-3.1": VIDEO_DURATIONS,
|
|
5100
|
+
"veo-3.1-fast": VIDEO_DURATIONS,
|
|
5101
|
+
"veo-3.1-lite": VIDEO_DURATIONS,
|
|
5102
|
+
...Object.fromEntries(OMNI_MODELS.map((m) => [m, [3, 4, 5, 6, 7, 8, 9, 10]]))
|
|
5103
|
+
};
|
|
5089
5104
|
var MEDIA = {
|
|
5090
5105
|
create_image: {
|
|
5091
5106
|
type: "image",
|
|
@@ -5119,9 +5134,9 @@ var MEDIA = {
|
|
|
5119
5134
|
cost: "13 to 150 credits per second: 4s of veo-3.1-lite in 720p costs 52, 8s of veo-3.1 in 1080p with audio costs 800",
|
|
5120
5135
|
from: "Workspace image to animate: the video starts from it",
|
|
5121
5136
|
params: {
|
|
5122
|
-
model: { type: "string", enum: VIDEO_MODELS, description: "veo-3.1-lite (13-20 credits/s, default) \xB7 veo-3.1-fast (25-75) \xB7 veo-3.1 (50-150, the only one with sound)" },
|
|
5123
|
-
duration: { type: "number", description: "Seconds: 4, 6 or 8. The price is per second.
|
|
5124
|
-
resolution: { type: "string", enum: ["720p", "1080p", "4K"], description: "Default 720p. 4K needs veo-3.1 or veo-3.1-fast." },
|
|
5137
|
+
model: { type: "string", enum: VIDEO_MODELS, description: "veo-3.1-lite (13-20 credits/s, default) \xB7 veo-3.1-fast (25-75) \xB7 veo-3.1 (50-150, the only one with sound) \xB7 gemini-omni-1.1-flash-preview (about 25 credits/s in 720p, 38 in 1080p; any length from 3 to 10 s)" },
|
|
5138
|
+
duration: { type: "number", description: "Seconds. veo: 4, 6 or 8, default 4. omni: anything from 3 to 10 (10 is the provider's maximum), default 10. The price is per second." },
|
|
5139
|
+
resolution: { type: "string", enum: ["720p", "1080p", "4K"], description: "Default 720p. 4K needs veo-3.1 or veo-3.1-fast; omni does 720p or 1080p." },
|
|
5125
5140
|
audio: { type: "boolean", description: "Sound in the video. Only veo-3.1 makes it, and it doubles the price. Default false." },
|
|
5126
5141
|
aspect: { type: "string", enum: ["16:9", "9:16"], description: "Landscape or portrait. Default 16:9." }
|
|
5127
5142
|
},
|
|
@@ -5129,11 +5144,17 @@ var MEDIA = {
|
|
|
5129
5144
|
// produire doit se dire tout de suite, pas revenir en erreur du fournisseur une fois payé.
|
|
5130
5145
|
verify: (a, model) => {
|
|
5131
5146
|
if (OMNI_MODELS.includes(model)) {
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5147
|
+
if (a.audio === true) fail5(`"${model}" has no sound option. Use veo-3.1 for sound.`);
|
|
5148
|
+
if (a.duration !== void 0 && a.duration !== null && a.duration !== "") {
|
|
5149
|
+
const d = Number(a.duration);
|
|
5150
|
+
if (!Number.isFinite(d) || d < OMNI_SECONDS.min || d > OMNI_SECONDS.max) {
|
|
5151
|
+
fail5(`"${model}" makes videos of ${OMNI_SECONDS.min} to ${OMNI_SECONDS.max} seconds (the provider's limit); you asked for ${a.duration}.`);
|
|
5135
5152
|
}
|
|
5136
5153
|
}
|
|
5154
|
+
const permises = VIDEO_RESOLUTIONS[model] || [];
|
|
5155
|
+
if (filled2(a.resolution) && !permises.includes(a.resolution)) {
|
|
5156
|
+
fail5(`"${model}" has no ${a.resolution}. It does ${permises.join(", ")}.`);
|
|
5157
|
+
}
|
|
5137
5158
|
return;
|
|
5138
5159
|
}
|
|
5139
5160
|
if (a.audio === true && !VIDEO_WITH_AUDIO.includes(model)) {
|
|
@@ -5147,13 +5168,19 @@ var MEDIA = {
|
|
|
5147
5168
|
fail5(`"${model}" has no ${a.resolution}. It does ${allowed.join(", ")} \u2014 change the resolution, or pick another model.`);
|
|
5148
5169
|
}
|
|
5149
5170
|
},
|
|
5150
|
-
|
|
5171
|
+
// Omni : seulement ce qui a été demandé — sans durée, le modèle fait ses 10 s par défaut, et un
|
|
5172
|
+
// défaut de 4 s imposé ici changerait en silence ce qu'un appel sans option produisait.
|
|
5173
|
+
settings: (a, model) => OMNI_MODELS.includes(model) ? {
|
|
5174
|
+
...Number(a.duration) > 0 ? { duration: Number(a.duration) } : {},
|
|
5175
|
+
...filled2(a.resolution) ? { resolution: a.resolution } : {},
|
|
5176
|
+
...filled2(a.aspect) ? { aspectRatio: a.aspect } : {}
|
|
5177
|
+
} : {
|
|
5151
5178
|
duration: Number(a.duration) > 0 ? Number(a.duration) : 4,
|
|
5152
5179
|
resolution: a.resolution || "720p",
|
|
5153
5180
|
audio: a.audio === true,
|
|
5154
5181
|
...filled2(a.aspect) ? { aspectRatio: a.aspect } : {}
|
|
5155
|
-
}
|
|
5156
|
-
detail: (a) => [`${Number(a.duration) > 0 ? Number(a.duration) : 4}s`, a.resolution || "720p", a.audio === true ? "with audio" : "silent"]
|
|
5182
|
+
},
|
|
5183
|
+
detail: (a, model) => OMNI_MODELS.includes(model) ? [`${Number(a.duration) > 0 ? Number(a.duration) : OMNI_SECONDS.default}s`, a.resolution || "720p", ...filled2(a.aspect) ? [a.aspect] : []] : [`${Number(a.duration) > 0 ? Number(a.duration) : 4}s`, a.resolution || "720p", a.audio === true ? "with audio" : "silent"]
|
|
5157
5184
|
},
|
|
5158
5185
|
create_voice: {
|
|
5159
5186
|
type: "audio",
|
|
@@ -5199,7 +5226,7 @@ var MEDIA_OPTIONS = Object.fromEntries(Object.entries(MEDIA).map(([nom, spec]) =
|
|
|
5199
5226
|
model: spec.model,
|
|
5200
5227
|
models: spec.models,
|
|
5201
5228
|
params: Object.fromEntries(Object.entries(spec.params || {}).map(([cle, p]) => [cle, { type: p.type, values: p.enum || null }])),
|
|
5202
|
-
...nom === "create_video" ? { resolutionsByModel: VIDEO_RESOLUTIONS, audioModels: VIDEO_WITH_AUDIO, durations: VIDEO_DURATIONS } : {}
|
|
5229
|
+
...nom === "create_video" ? { resolutionsByModel: VIDEO_RESOLUTIONS, audioModels: VIDEO_WITH_AUDIO, durations: VIDEO_DURATIONS, durationsByModel: VIDEO_DURATIONS_BY_MODEL } : {}
|
|
5203
5230
|
}
|
|
5204
5231
|
]));
|
|
5205
5232
|
var MEDIA_KINDS = Object.fromEntries(Object.keys(MEDIA).map((n) => [n, n.replace(/^create_/, "")]));
|
|
@@ -5243,7 +5270,7 @@ function createMediaTools({ client, media = {} }) {
|
|
|
5243
5270
|
if (source.size > ATTACHMENT_MAX) fail5(`"${source.path}" is ${(source.size / 1048576).toFixed(1)} MB; the starting image must be under ${ATTACHMENT_MAX / 1048576} MB.`);
|
|
5244
5271
|
inputs.push({ type: "image", content: Buffer.from(source.content).toString("base64"), mime });
|
|
5245
5272
|
}
|
|
5246
|
-
const session = await models.create({ model, settings: spec.settings(args), memory: false });
|
|
5273
|
+
const session = await models.create({ model, settings: spec.settings(args, model), memory: false });
|
|
5247
5274
|
try {
|
|
5248
5275
|
const result = await session.generate({ inputs, outputs: [{ type: spec.output }] });
|
|
5249
5276
|
const output = result.outputs?.find((o) => o.content);
|
|
@@ -5251,7 +5278,7 @@ function createMediaTools({ client, media = {} }) {
|
|
|
5251
5278
|
const ext = output.mime?.split("/")[1]?.split(";")[0]?.replace("mpeg", "mp3") || spec.ext;
|
|
5252
5279
|
const target = path || `Agent/${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}/${Date.now()}.${ext}`;
|
|
5253
5280
|
const item = await files.write(target, Buffer.from(output.content, "base64"));
|
|
5254
|
-
const fait = [model, ...spec.detail(args)].join(", ");
|
|
5281
|
+
const fait = [model, ...spec.detail(args, model)].join(", ");
|
|
5255
5282
|
return {
|
|
5256
5283
|
output: `Saved ${spec.type} to ${item.path} (${item.size} bytes, ${result.usage?.credits ?? "?"} credits \u2014 ${fait}).`,
|
|
5257
5284
|
summary: `Created ${item.path}`,
|
|
@@ -6222,8 +6249,10 @@ async function sha256(content) {
|
|
|
6222
6249
|
var signature = (item) => `${item.size ?? 0}:${item.modifiedAt || ""}`;
|
|
6223
6250
|
var blobPath = (hash) => `${CHECKPOINT_DIR}/objects/${hash.slice(0, 2)}/${hash.slice(2)}`;
|
|
6224
6251
|
var missing = (err) => err?.code === "path_not_found" || err?.status === 404;
|
|
6225
|
-
function createCheckpoints({ files, sessionId, keep = KEEP_CHECKPOINTS }) {
|
|
6252
|
+
function createCheckpoints({ files, sessionId, keep = KEEP_CHECKPOINTS, excludePaths = [] }) {
|
|
6226
6253
|
const folder = `${CHECKPOINT_DIR}/${sessionId}`;
|
|
6254
|
+
const excluded = excludePaths.map((path) => String(path || "").replace(/\\/g, "/").replace(/^\/+|\/+$/g, ""));
|
|
6255
|
+
const excludedFromSnapshot = (path) => isOurs(path) || excluded.some((entry) => path === entry || path.startsWith(`${entry}/`));
|
|
6227
6256
|
async function scan() {
|
|
6228
6257
|
const found = [];
|
|
6229
6258
|
const heavy = [];
|
|
@@ -6239,7 +6268,7 @@ function createCheckpoints({ files, sessionId, keep = KEEP_CHECKPOINTS }) {
|
|
|
6239
6268
|
}
|
|
6240
6269
|
for (const item of items || []) {
|
|
6241
6270
|
const path = String(item.path || "").replace(/\\/g, "/").replace(/\/$/, "");
|
|
6242
|
-
if (!path ||
|
|
6271
|
+
if (!path || excludedFromSnapshot(path)) continue;
|
|
6243
6272
|
if (item.type === "folder") {
|
|
6244
6273
|
if (HEAVY_FOLDERS.has(item.name)) {
|
|
6245
6274
|
heavy.push(path);
|
|
@@ -6630,7 +6659,7 @@ function createJournal(agent2) {
|
|
|
6630
6659
|
}
|
|
6631
6660
|
var CLEAR_RESULTS_ABOVE = 4e4;
|
|
6632
6661
|
var DEFAULT_CONTEXT_TOKENS = 2e5;
|
|
6633
|
-
var catalogues = /* @__PURE__ */ new
|
|
6662
|
+
var catalogues = /* @__PURE__ */ new Map();
|
|
6634
6663
|
var KEEP_RESULTS_FOR_TURNS = 3;
|
|
6635
6664
|
var MIN_RESULT_TO_CLEAR = 400;
|
|
6636
6665
|
var SUBAGENT_MAX_STEPS = 40;
|
|
@@ -6864,10 +6893,11 @@ var LocalAgent = class _LocalAgent {
|
|
|
6864
6893
|
if (typeof this.api.catalogue !== "function" || !this.model) return;
|
|
6865
6894
|
let entry = null;
|
|
6866
6895
|
try {
|
|
6867
|
-
|
|
6896
|
+
const key = this.api.baseUrl || this.api;
|
|
6897
|
+
let cached = catalogues.get(key);
|
|
6868
6898
|
if (!cached || Date.now() - cached.at > 6e5) {
|
|
6869
6899
|
cached = { at: Date.now(), prices: await this.api.catalogue() };
|
|
6870
|
-
catalogues.set(
|
|
6900
|
+
catalogues.set(key, cached);
|
|
6871
6901
|
}
|
|
6872
6902
|
entry = cached.prices.find((p) => p.model === this.model && p.contextWindow);
|
|
6873
6903
|
} catch {
|
|
@@ -7508,7 +7538,10 @@ ${header.summary.text}` }, { role: "assistant", content: "Understood. Continuing
|
|
|
7508
7538
|
/** Le magasin de points de cette session, créé au premier besoin. */
|
|
7509
7539
|
_checkpoints() {
|
|
7510
7540
|
if (!this.checkpointsOption || !this.memory || this.role) return null;
|
|
7511
|
-
if (!this.checkpointStore)
|
|
7541
|
+
if (!this.checkpointStore) {
|
|
7542
|
+
const excludePaths = this.machine?.managedBy === "iagenify" && this.machine?.service === "object" ? ["Chats"] : [];
|
|
7543
|
+
this.checkpointStore = createCheckpoints({ files: this._files(), sessionId: this.id, excludePaths });
|
|
7544
|
+
}
|
|
7512
7545
|
return this.checkpointStore;
|
|
7513
7546
|
}
|
|
7514
7547
|
/** Enregistre l'espace de travail avant ce message. Un instantané impossible n'empêche jamais de répondre. */
|
|
@@ -7971,8 +8004,7 @@ ${summary.message.content}` }, { role: "assistant", content: "Understood. Contin
|
|
|
7971
8004
|
emit({ type: "rewound", ...rewound });
|
|
7972
8005
|
}
|
|
7973
8006
|
const root = await this._root();
|
|
7974
|
-
await this._loadLibrary();
|
|
7975
|
-
await this._loadMcp();
|
|
8007
|
+
await Promise.all([this._loadLibrary(), this._loadMcp()]);
|
|
7976
8008
|
const parsed = await this._parseInput(raw);
|
|
7977
8009
|
const restore = this._applyRunOptions(parsed.options);
|
|
7978
8010
|
try {
|
|
@@ -8006,8 +8038,7 @@ ${summary.message.content}` }, { role: "assistant", content: "Understood. Contin
|
|
|
8006
8038
|
emit({ type: "question_result", id, answer: answer ?? "" });
|
|
8007
8039
|
return answer;
|
|
8008
8040
|
} : null;
|
|
8009
|
-
this.storageContext = this.parent ? this.parent.storageContext : await this._loadStorageContext();
|
|
8010
|
-
this.memories = this.parent ? this.parent.memories : await this._loadMemories();
|
|
8041
|
+
[this.storageContext, this.memories] = this.parent ? [this.parent.storageContext, this.parent.memories] : await Promise.all([this._loadStorageContext(), this._loadMemories()]);
|
|
8011
8042
|
const context = { files: this._files(), shell: this.shell, terminals: this._terminals(), mode: () => this.mode, root, api: this.api, todos: this.todos, signal: this.controller.signal, askUser };
|
|
8012
8043
|
const usage = this.usage = { credits: 0, turns: 0, toolCalls: 0 };
|
|
8013
8044
|
let stopReason = "end_turn";
|
|
@@ -9092,6 +9123,49 @@ var ComputeResource = class {
|
|
|
9092
9123
|
};
|
|
9093
9124
|
|
|
9094
9125
|
// src/resources/mail.js
|
|
9126
|
+
function octetsEnBase64(octets) {
|
|
9127
|
+
if (typeof Buffer !== "undefined") return Buffer.from(octets.buffer, octets.byteOffset, octets.byteLength).toString("base64");
|
|
9128
|
+
let binaire = "";
|
|
9129
|
+
for (let i = 0; i < octets.length; i += 32768) binaire += String.fromCharCode(...octets.subarray(i, i + 32768));
|
|
9130
|
+
return btoa(binaire);
|
|
9131
|
+
}
|
|
9132
|
+
var nomDe = (chemin) => String(chemin).split(/[\\/]/).pop();
|
|
9133
|
+
async function encoderPiece(piece, index) {
|
|
9134
|
+
if (!piece || typeof piece !== "object") {
|
|
9135
|
+
throw new TypeError(`attachments[${index}] doit \xEAtre un objet { filename, content } ou { path }.`);
|
|
9136
|
+
}
|
|
9137
|
+
let { filename, content } = piece;
|
|
9138
|
+
if (content == null && piece.path) {
|
|
9139
|
+
if (typeof process === "undefined" || !process.versions?.node) {
|
|
9140
|
+
throw new TypeError(`attachments[${index}].path ne fonctionne que dans Node : passez content (octets ou Blob) ailleurs.`);
|
|
9141
|
+
}
|
|
9142
|
+
const { readFile } = await import("node:fs/promises");
|
|
9143
|
+
content = await readFile(piece.path);
|
|
9144
|
+
filename ??= nomDe(piece.path);
|
|
9145
|
+
}
|
|
9146
|
+
if (content == null) throw new TypeError(`attachments[${index}] n'a ni content ni path.`);
|
|
9147
|
+
let base64;
|
|
9148
|
+
if (typeof content === "string") {
|
|
9149
|
+
base64 = piece.encoding === "base64" ? content.replace(/\s+/g, "") : octetsEnBase64(new TextEncoder().encode(content));
|
|
9150
|
+
} else if (typeof Blob !== "undefined" && content instanceof Blob) {
|
|
9151
|
+
base64 = octetsEnBase64(new Uint8Array(await content.arrayBuffer()));
|
|
9152
|
+
filename ??= content.name;
|
|
9153
|
+
} else if (content instanceof ArrayBuffer) {
|
|
9154
|
+
base64 = octetsEnBase64(new Uint8Array(content));
|
|
9155
|
+
} else if (ArrayBuffer.isView(content)) {
|
|
9156
|
+
base64 = octetsEnBase64(new Uint8Array(content.buffer, content.byteOffset, content.byteLength));
|
|
9157
|
+
} else {
|
|
9158
|
+
throw new TypeError(`attachments[${index}].content doit \xEAtre un Buffer, un Uint8Array, un ArrayBuffer, un Blob ou une cha\xEEne.`);
|
|
9159
|
+
}
|
|
9160
|
+
const sortie = { filename: filename || `piece-${index + 1}`, content: base64 };
|
|
9161
|
+
if (piece.contentType) sortie.contentType = piece.contentType;
|
|
9162
|
+
if (piece.cid) sortie.cid = piece.cid;
|
|
9163
|
+
return sortie;
|
|
9164
|
+
}
|
|
9165
|
+
async function encodeAttachments(attachments) {
|
|
9166
|
+
if (!Array.isArray(attachments)) throw new TypeError("attachments doit \xEAtre une liste.");
|
|
9167
|
+
return Promise.all(attachments.map(encoderPiece));
|
|
9168
|
+
}
|
|
9095
9169
|
var Aliases = class {
|
|
9096
9170
|
constructor(client, mailbox) {
|
|
9097
9171
|
this.client = client;
|
|
@@ -9206,9 +9280,29 @@ var Mailbox = class {
|
|
|
9206
9280
|
* envoi-là. Quand elle demande l'image de la boîte, celle-ci voyage **dans** le message (`cid:`) : c'est la
|
|
9207
9281
|
* seule façon qu'un destinataire la voie, la pastille de son client étant dessinée depuis ses données à lui.
|
|
9208
9282
|
*/
|
|
9209
|
-
|
|
9283
|
+
/*
|
|
9284
|
+
* P82 (approuvé le 2026-11-18) — pièces jointes et Cci, dans la forme de nodemailer :
|
|
9285
|
+
*
|
|
9286
|
+
* await boite.send({
|
|
9287
|
+
* to: ["client@acme.com"], bcc: ["compta@moi.com"],
|
|
9288
|
+
* subject: "Votre facture",
|
|
9289
|
+
* html: '<h1>Merci</h1><img src="cid:logo">',
|
|
9290
|
+
* attachments: [
|
|
9291
|
+
* { filename: "facture.pdf", content: buffer, contentType: "application/pdf" },
|
|
9292
|
+
* { filename: "logo.png", content: png, cid: "logo" },
|
|
9293
|
+
* { filename: "devis.pdf", path: "./devis.pdf" }, // Node seulement
|
|
9294
|
+
* ],
|
|
9295
|
+
* });
|
|
9296
|
+
* // → { …, attachments: [{ filename, size, contentType, inline }] }
|
|
9297
|
+
*
|
|
9298
|
+
* `content` : Buffer, Uint8Array, ArrayBuffer, Blob, ou une chaîne — du texte UTF-8, sauf avec
|
|
9299
|
+
* `encoding: "base64"`, exactement comme nodemailer. 25 Mo au total ; les exécutables sont refusés.
|
|
9300
|
+
*/
|
|
9301
|
+
async send({ to = [], cc = [], bcc = [], subject = "", text: text2 = "", html = "", replyTo = null, signature: signature2, attachments } = {}) {
|
|
9210
9302
|
const corps = { to, cc, subject, text: text2, html, replyTo };
|
|
9303
|
+
if (bcc && (!Array.isArray(bcc) || bcc.length)) corps.bcc = bcc;
|
|
9211
9304
|
if (signature2 === false) corps.signature = false;
|
|
9305
|
+
if (attachments != null) corps.attachments = await encodeAttachments(attachments);
|
|
9212
9306
|
const res = await this.client.post(`/api/mail/${this.id}/send`, corps);
|
|
9213
9307
|
return res.sent;
|
|
9214
9308
|
}
|