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.js
CHANGED
|
@@ -3345,25 +3345,30 @@ function sendMailTool() {
|
|
|
3345
3345
|
return {
|
|
3346
3346
|
// Catégorie `send` (P39) : demandée à chaque envoi, même en Full access, sans « toujours ».
|
|
3347
3347
|
category: "send",
|
|
3348
|
-
|
|
3348
|
+
// P82 : `html` pour un message mis en forme, `attach` joint vraiment les fichiers (25 Mo au total). Avant,
|
|
3349
|
+
// `attach` lisait les fichiers puis les perdait — la route d'envoi n'en prenait pas — et l'agent disait « envoyé ».
|
|
3350
|
+
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.",
|
|
3349
3351
|
parameters: {
|
|
3350
3352
|
box: { type: "string", description: "Which of its addresses writes; optional when it owns one" },
|
|
3351
3353
|
to: { type: "string", required: true, description: "Comma-separated, at most 5" },
|
|
3352
3354
|
cc: { type: "string", description: "Comma-separated" },
|
|
3355
|
+
bcc: { type: "string", description: "Comma-separated, hidden from the other recipients" },
|
|
3353
3356
|
subject: { type: "string", description: "Required unless replying" },
|
|
3354
|
-
body: { type: "string",
|
|
3357
|
+
body: { type: "string", description: "Plain text; blank lines separate paragraphs. Required unless html is given" },
|
|
3358
|
+
html: { type: "string", description: "Formatted message: inline styles, no script, no external stylesheet" },
|
|
3355
3359
|
reply_to_message: { type: "string", description: "Id of the message being answered" },
|
|
3356
|
-
attach: { type: "array", items: { type: "string" }, description: "Workspace files" },
|
|
3360
|
+
attach: { type: "array", items: { type: "string" }, description: "Workspace files to attach" },
|
|
3357
3361
|
signature: { type: "boolean", description: "false sends without the mailbox signature" }
|
|
3358
3362
|
},
|
|
3359
|
-
check({ to, subject, reply_to_message, body } = {}) {
|
|
3363
|
+
check({ to, cc, bcc, subject, reply_to_message, body, html } = {}) {
|
|
3360
3364
|
const recipients = addresses(to);
|
|
3361
3365
|
if (!recipients.length) fail4('"to" is required: at least one recipient.');
|
|
3362
3366
|
if (recipients.length > 5) fail4(`At most 5 recipients at a time; you gave ${recipients.length}.`);
|
|
3363
|
-
const bad = recipients.find((a) => !/^[^@\s]+@[^@\s.]+\.[^@\s]+$/.test(a));
|
|
3367
|
+
const bad = [...recipients, ...addresses(cc), ...addresses(bcc)].find((a) => !/^[^@\s]+@[^@\s.]+\.[^@\s]+$/.test(a));
|
|
3364
3368
|
if (bad) fail4(`"${bad}" is not an email address.`);
|
|
3365
3369
|
if (!text(subject) && !text(reply_to_message)) fail4('"subject" is required (or give reply_to_message to answer a message).');
|
|
3366
|
-
if (!text(body)) fail4('"body" is required: write the message in full, as the user would.');
|
|
3370
|
+
if (!text(body) && !text(html)) fail4('"body" or "html" is required: write the message in full, as the user would.');
|
|
3371
|
+
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.');
|
|
3367
3372
|
},
|
|
3368
3373
|
async run(args, { api, files }) {
|
|
3369
3374
|
const box = await findBox(api, args.box);
|
|
@@ -3382,26 +3387,30 @@ ${quoted}`;
|
|
|
3382
3387
|
const attachments = [];
|
|
3383
3388
|
for (const path of Array.isArray(args.attach) ? args.attach : addresses(args.attach)) {
|
|
3384
3389
|
const file = await files.read(String(path));
|
|
3385
|
-
attachments.push({
|
|
3390
|
+
attachments.push({ filename: String(path).split("/").pop(), content: file.content, ...file.mimeType ? { contentType: file.mimeType } : {} });
|
|
3386
3391
|
}
|
|
3387
3392
|
const sent = await box.send({
|
|
3388
3393
|
to,
|
|
3389
3394
|
cc: addresses(args.cc),
|
|
3395
|
+
bcc: addresses(args.bcc),
|
|
3390
3396
|
subject,
|
|
3391
3397
|
text: body,
|
|
3398
|
+
...text(args.html) ? { html: text(args.html) } : {},
|
|
3392
3399
|
...attachments.length ? { attachments } : {},
|
|
3393
3400
|
...args.signature === false ? { signature: false } : {}
|
|
3394
3401
|
});
|
|
3402
|
+
const joined = sent.attachments || [];
|
|
3395
3403
|
const relay = sent.relay || {};
|
|
3396
3404
|
return {
|
|
3397
3405
|
output: [
|
|
3398
|
-
`Sent from ${relay.from || box.address} to ${to.join(", ")} \u2014 "${subject}" (${sent.creditsUsed ?? 1} credit).`,
|
|
3406
|
+
`Sent from ${relay.from || box.address} to ${to.join(", ")} \u2014 "${subject}" (${sent.credits ?? sent.creditsUsed ?? 1} credit).`,
|
|
3407
|
+
joined.length ? `Attached: ${joined.map((a) => `${a.filename} (${formatBytes(a.size || 0)})`).join(", ")}.` : "",
|
|
3399
3408
|
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"}.` : "",
|
|
3400
3409
|
relay.warning || "",
|
|
3401
3410
|
"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."
|
|
3402
3411
|
].filter(Boolean).join("\n"),
|
|
3403
3412
|
summary: `Mail to ${to[0]}${to.length > 1 ? ` +${to.length - 1}` : ""}`,
|
|
3404
|
-
meta: { box: box.id, to, subject, relay: relay.name || null, aligned: relay.aligned === true, credits: sent.creditsUsed ?? 1 }
|
|
3413
|
+
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)) }
|
|
3405
3414
|
};
|
|
3406
3415
|
}
|
|
3407
3416
|
};
|
|
@@ -5014,20 +5023,26 @@ ${r.text}`).join("\n\n"), 3e4),
|
|
|
5014
5023
|
}
|
|
5015
5024
|
};
|
|
5016
5025
|
}
|
|
5017
|
-
var OMNI_MODELS = ["gemini-omni-1.1-flash-preview"
|
|
5026
|
+
var OMNI_MODELS = ["gemini-omni-1.1-flash-preview"];
|
|
5027
|
+
var OMNI_SECONDS = { min: 3, max: 10, default: 10 };
|
|
5018
5028
|
var IMAGE_MODELS = ["gemini-3.1-flash-image", "gemini-2.5-flash-image", ...OMNI_MODELS];
|
|
5019
5029
|
var VIDEO_MODELS = ["veo-3.1-lite", "veo-3.1-fast", "veo-3.1", ...OMNI_MODELS];
|
|
5020
5030
|
var VIDEO_RESOLUTIONS = {
|
|
5021
5031
|
"veo-3.1": ["720p", "1080p", "4K"],
|
|
5022
5032
|
"veo-3.1-fast": ["720p", "1080p", "4K"],
|
|
5023
5033
|
"veo-3.1-lite": ["720p", "1080p"],
|
|
5024
|
-
// Omni
|
|
5025
|
-
//
|
|
5026
|
-
"gemini-omni-1.1-flash-preview": []
|
|
5027
|
-
"gemini-omni-flash-preview": []
|
|
5034
|
+
// Omni (P83) : les deux résolutions mesurées. La 4K et le 360p existent dans les types de l'API,
|
|
5035
|
+
// mais aucune n'a été mesurée — donc aucune n'a de prix.
|
|
5036
|
+
"gemini-omni-1.1-flash-preview": ["720p", "1080p"]
|
|
5028
5037
|
};
|
|
5029
5038
|
var VIDEO_WITH_AUDIO = ["veo-3.1"];
|
|
5030
5039
|
var VIDEO_DURATIONS = [4, 6, 8];
|
|
5040
|
+
var VIDEO_DURATIONS_BY_MODEL = {
|
|
5041
|
+
"veo-3.1": VIDEO_DURATIONS,
|
|
5042
|
+
"veo-3.1-fast": VIDEO_DURATIONS,
|
|
5043
|
+
"veo-3.1-lite": VIDEO_DURATIONS,
|
|
5044
|
+
...Object.fromEntries(OMNI_MODELS.map((m) => [m, [3, 4, 5, 6, 7, 8, 9, 10]]))
|
|
5045
|
+
};
|
|
5031
5046
|
var MEDIA = {
|
|
5032
5047
|
create_image: {
|
|
5033
5048
|
type: "image",
|
|
@@ -5061,9 +5076,9 @@ var MEDIA = {
|
|
|
5061
5076
|
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",
|
|
5062
5077
|
from: "Workspace image to animate: the video starts from it",
|
|
5063
5078
|
params: {
|
|
5064
|
-
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)" },
|
|
5065
|
-
duration: { type: "number", description: "Seconds: 4, 6 or 8. The price is per second.
|
|
5066
|
-
resolution: { type: "string", enum: ["720p", "1080p", "4K"], description: "Default 720p. 4K needs veo-3.1 or veo-3.1-fast." },
|
|
5079
|
+
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)" },
|
|
5080
|
+
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." },
|
|
5081
|
+
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." },
|
|
5067
5082
|
audio: { type: "boolean", description: "Sound in the video. Only veo-3.1 makes it, and it doubles the price. Default false." },
|
|
5068
5083
|
aspect: { type: "string", enum: ["16:9", "9:16"], description: "Landscape or portrait. Default 16:9." }
|
|
5069
5084
|
},
|
|
@@ -5071,11 +5086,17 @@ var MEDIA = {
|
|
|
5071
5086
|
// produire doit se dire tout de suite, pas revenir en erreur du fournisseur une fois payé.
|
|
5072
5087
|
verify: (a, model) => {
|
|
5073
5088
|
if (OMNI_MODELS.includes(model)) {
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5089
|
+
if (a.audio === true) fail5(`"${model}" has no sound option. Use veo-3.1 for sound.`);
|
|
5090
|
+
if (a.duration !== void 0 && a.duration !== null && a.duration !== "") {
|
|
5091
|
+
const d = Number(a.duration);
|
|
5092
|
+
if (!Number.isFinite(d) || d < OMNI_SECONDS.min || d > OMNI_SECONDS.max) {
|
|
5093
|
+
fail5(`"${model}" makes videos of ${OMNI_SECONDS.min} to ${OMNI_SECONDS.max} seconds (the provider's limit); you asked for ${a.duration}.`);
|
|
5077
5094
|
}
|
|
5078
5095
|
}
|
|
5096
|
+
const permises = VIDEO_RESOLUTIONS[model] || [];
|
|
5097
|
+
if (filled2(a.resolution) && !permises.includes(a.resolution)) {
|
|
5098
|
+
fail5(`"${model}" has no ${a.resolution}. It does ${permises.join(", ")}.`);
|
|
5099
|
+
}
|
|
5079
5100
|
return;
|
|
5080
5101
|
}
|
|
5081
5102
|
if (a.audio === true && !VIDEO_WITH_AUDIO.includes(model)) {
|
|
@@ -5089,13 +5110,19 @@ var MEDIA = {
|
|
|
5089
5110
|
fail5(`"${model}" has no ${a.resolution}. It does ${allowed.join(", ")} \u2014 change the resolution, or pick another model.`);
|
|
5090
5111
|
}
|
|
5091
5112
|
},
|
|
5092
|
-
|
|
5113
|
+
// Omni : seulement ce qui a été demandé — sans durée, le modèle fait ses 10 s par défaut, et un
|
|
5114
|
+
// défaut de 4 s imposé ici changerait en silence ce qu'un appel sans option produisait.
|
|
5115
|
+
settings: (a, model) => OMNI_MODELS.includes(model) ? {
|
|
5116
|
+
...Number(a.duration) > 0 ? { duration: Number(a.duration) } : {},
|
|
5117
|
+
...filled2(a.resolution) ? { resolution: a.resolution } : {},
|
|
5118
|
+
...filled2(a.aspect) ? { aspectRatio: a.aspect } : {}
|
|
5119
|
+
} : {
|
|
5093
5120
|
duration: Number(a.duration) > 0 ? Number(a.duration) : 4,
|
|
5094
5121
|
resolution: a.resolution || "720p",
|
|
5095
5122
|
audio: a.audio === true,
|
|
5096
5123
|
...filled2(a.aspect) ? { aspectRatio: a.aspect } : {}
|
|
5097
|
-
}
|
|
5098
|
-
detail: (a) => [`${Number(a.duration) > 0 ? Number(a.duration) : 4}s`, a.resolution || "720p", a.audio === true ? "with audio" : "silent"]
|
|
5124
|
+
},
|
|
5125
|
+
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"]
|
|
5099
5126
|
},
|
|
5100
5127
|
create_voice: {
|
|
5101
5128
|
type: "audio",
|
|
@@ -5141,7 +5168,7 @@ var MEDIA_OPTIONS = Object.fromEntries(Object.entries(MEDIA).map(([nom, spec]) =
|
|
|
5141
5168
|
model: spec.model,
|
|
5142
5169
|
models: spec.models,
|
|
5143
5170
|
params: Object.fromEntries(Object.entries(spec.params || {}).map(([cle, p]) => [cle, { type: p.type, values: p.enum || null }])),
|
|
5144
|
-
...nom === "create_video" ? { resolutionsByModel: VIDEO_RESOLUTIONS, audioModels: VIDEO_WITH_AUDIO, durations: VIDEO_DURATIONS } : {}
|
|
5171
|
+
...nom === "create_video" ? { resolutionsByModel: VIDEO_RESOLUTIONS, audioModels: VIDEO_WITH_AUDIO, durations: VIDEO_DURATIONS, durationsByModel: VIDEO_DURATIONS_BY_MODEL } : {}
|
|
5145
5172
|
}
|
|
5146
5173
|
]));
|
|
5147
5174
|
var MEDIA_KINDS = Object.fromEntries(Object.keys(MEDIA).map((n) => [n, n.replace(/^create_/, "")]));
|
|
@@ -5185,7 +5212,7 @@ function createMediaTools({ client, media = {} }) {
|
|
|
5185
5212
|
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.`);
|
|
5186
5213
|
inputs.push({ type: "image", content: Buffer.from(source.content).toString("base64"), mime });
|
|
5187
5214
|
}
|
|
5188
|
-
const session = await models.create({ model, settings: spec.settings(args), memory: false });
|
|
5215
|
+
const session = await models.create({ model, settings: spec.settings(args, model), memory: false });
|
|
5189
5216
|
try {
|
|
5190
5217
|
const result = await session.generate({ inputs, outputs: [{ type: spec.output }] });
|
|
5191
5218
|
const output = result.outputs?.find((o) => o.content);
|
|
@@ -5193,7 +5220,7 @@ function createMediaTools({ client, media = {} }) {
|
|
|
5193
5220
|
const ext = output.mime?.split("/")[1]?.split(";")[0]?.replace("mpeg", "mp3") || spec.ext;
|
|
5194
5221
|
const target = path || `Agent/${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}/${Date.now()}.${ext}`;
|
|
5195
5222
|
const item = await files.write(target, Buffer.from(output.content, "base64"));
|
|
5196
|
-
const fait = [model, ...spec.detail(args)].join(", ");
|
|
5223
|
+
const fait = [model, ...spec.detail(args, model)].join(", ");
|
|
5197
5224
|
return {
|
|
5198
5225
|
output: `Saved ${spec.type} to ${item.path} (${item.size} bytes, ${result.usage?.credits ?? "?"} credits \u2014 ${fait}).`,
|
|
5199
5226
|
summary: `Created ${item.path}`,
|
|
@@ -6164,8 +6191,10 @@ async function sha256(content) {
|
|
|
6164
6191
|
var signature = (item) => `${item.size ?? 0}:${item.modifiedAt || ""}`;
|
|
6165
6192
|
var blobPath = (hash) => `${CHECKPOINT_DIR}/objects/${hash.slice(0, 2)}/${hash.slice(2)}`;
|
|
6166
6193
|
var missing = (err) => err?.code === "path_not_found" || err?.status === 404;
|
|
6167
|
-
function createCheckpoints({ files, sessionId, keep = KEEP_CHECKPOINTS }) {
|
|
6194
|
+
function createCheckpoints({ files, sessionId, keep = KEEP_CHECKPOINTS, excludePaths = [] }) {
|
|
6168
6195
|
const folder = `${CHECKPOINT_DIR}/${sessionId}`;
|
|
6196
|
+
const excluded = excludePaths.map((path) => String(path || "").replace(/\\/g, "/").replace(/^\/+|\/+$/g, ""));
|
|
6197
|
+
const excludedFromSnapshot = (path) => isOurs(path) || excluded.some((entry) => path === entry || path.startsWith(`${entry}/`));
|
|
6169
6198
|
async function scan() {
|
|
6170
6199
|
const found = [];
|
|
6171
6200
|
const heavy = [];
|
|
@@ -6181,7 +6210,7 @@ function createCheckpoints({ files, sessionId, keep = KEEP_CHECKPOINTS }) {
|
|
|
6181
6210
|
}
|
|
6182
6211
|
for (const item of items || []) {
|
|
6183
6212
|
const path = String(item.path || "").replace(/\\/g, "/").replace(/\/$/, "");
|
|
6184
|
-
if (!path ||
|
|
6213
|
+
if (!path || excludedFromSnapshot(path)) continue;
|
|
6185
6214
|
if (item.type === "folder") {
|
|
6186
6215
|
if (HEAVY_FOLDERS.has(item.name)) {
|
|
6187
6216
|
heavy.push(path);
|
|
@@ -6572,7 +6601,7 @@ function createJournal(agent2) {
|
|
|
6572
6601
|
}
|
|
6573
6602
|
var CLEAR_RESULTS_ABOVE = 4e4;
|
|
6574
6603
|
var DEFAULT_CONTEXT_TOKENS = 2e5;
|
|
6575
|
-
var catalogues = /* @__PURE__ */ new
|
|
6604
|
+
var catalogues = /* @__PURE__ */ new Map();
|
|
6576
6605
|
var KEEP_RESULTS_FOR_TURNS = 3;
|
|
6577
6606
|
var MIN_RESULT_TO_CLEAR = 400;
|
|
6578
6607
|
var SUBAGENT_MAX_STEPS = 40;
|
|
@@ -6806,10 +6835,11 @@ var LocalAgent = class _LocalAgent {
|
|
|
6806
6835
|
if (typeof this.api.catalogue !== "function" || !this.model) return;
|
|
6807
6836
|
let entry = null;
|
|
6808
6837
|
try {
|
|
6809
|
-
|
|
6838
|
+
const key = this.api.baseUrl || this.api;
|
|
6839
|
+
let cached = catalogues.get(key);
|
|
6810
6840
|
if (!cached || Date.now() - cached.at > 6e5) {
|
|
6811
6841
|
cached = { at: Date.now(), prices: await this.api.catalogue() };
|
|
6812
|
-
catalogues.set(
|
|
6842
|
+
catalogues.set(key, cached);
|
|
6813
6843
|
}
|
|
6814
6844
|
entry = cached.prices.find((p) => p.model === this.model && p.contextWindow);
|
|
6815
6845
|
} catch {
|
|
@@ -7450,7 +7480,10 @@ ${header.summary.text}` }, { role: "assistant", content: "Understood. Continuing
|
|
|
7450
7480
|
/** Le magasin de points de cette session, créé au premier besoin. */
|
|
7451
7481
|
_checkpoints() {
|
|
7452
7482
|
if (!this.checkpointsOption || !this.memory || this.role) return null;
|
|
7453
|
-
if (!this.checkpointStore)
|
|
7483
|
+
if (!this.checkpointStore) {
|
|
7484
|
+
const excludePaths = this.machine?.managedBy === "iagenify" && this.machine?.service === "object" ? ["Chats"] : [];
|
|
7485
|
+
this.checkpointStore = createCheckpoints({ files: this._files(), sessionId: this.id, excludePaths });
|
|
7486
|
+
}
|
|
7454
7487
|
return this.checkpointStore;
|
|
7455
7488
|
}
|
|
7456
7489
|
/** Enregistre l'espace de travail avant ce message. Un instantané impossible n'empêche jamais de répondre. */
|
|
@@ -7913,8 +7946,7 @@ ${summary.message.content}` }, { role: "assistant", content: "Understood. Contin
|
|
|
7913
7946
|
emit({ type: "rewound", ...rewound });
|
|
7914
7947
|
}
|
|
7915
7948
|
const root = await this._root();
|
|
7916
|
-
await this._loadLibrary();
|
|
7917
|
-
await this._loadMcp();
|
|
7949
|
+
await Promise.all([this._loadLibrary(), this._loadMcp()]);
|
|
7918
7950
|
const parsed = await this._parseInput(raw);
|
|
7919
7951
|
const restore = this._applyRunOptions(parsed.options);
|
|
7920
7952
|
try {
|
|
@@ -7948,8 +7980,7 @@ ${summary.message.content}` }, { role: "assistant", content: "Understood. Contin
|
|
|
7948
7980
|
emit({ type: "question_result", id, answer: answer ?? "" });
|
|
7949
7981
|
return answer;
|
|
7950
7982
|
} : null;
|
|
7951
|
-
this.storageContext = this.parent ? this.parent.storageContext : await this._loadStorageContext();
|
|
7952
|
-
this.memories = this.parent ? this.parent.memories : await this._loadMemories();
|
|
7983
|
+
[this.storageContext, this.memories] = this.parent ? [this.parent.storageContext, this.parent.memories] : await Promise.all([this._loadStorageContext(), this._loadMemories()]);
|
|
7953
7984
|
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 };
|
|
7954
7985
|
const usage = this.usage = { credits: 0, turns: 0, toolCalls: 0 };
|
|
7955
7986
|
let stopReason = "end_turn";
|
|
@@ -9034,6 +9065,49 @@ var ComputeResource = class {
|
|
|
9034
9065
|
};
|
|
9035
9066
|
|
|
9036
9067
|
// src/resources/mail.js
|
|
9068
|
+
function octetsEnBase64(octets) {
|
|
9069
|
+
if (typeof Buffer !== "undefined") return Buffer.from(octets.buffer, octets.byteOffset, octets.byteLength).toString("base64");
|
|
9070
|
+
let binaire = "";
|
|
9071
|
+
for (let i = 0; i < octets.length; i += 32768) binaire += String.fromCharCode(...octets.subarray(i, i + 32768));
|
|
9072
|
+
return btoa(binaire);
|
|
9073
|
+
}
|
|
9074
|
+
var nomDe = (chemin) => String(chemin).split(/[\\/]/).pop();
|
|
9075
|
+
async function encoderPiece(piece, index) {
|
|
9076
|
+
if (!piece || typeof piece !== "object") {
|
|
9077
|
+
throw new TypeError(`attachments[${index}] doit \xEAtre un objet { filename, content } ou { path }.`);
|
|
9078
|
+
}
|
|
9079
|
+
let { filename, content } = piece;
|
|
9080
|
+
if (content == null && piece.path) {
|
|
9081
|
+
if (typeof process === "undefined" || !process.versions?.node) {
|
|
9082
|
+
throw new TypeError(`attachments[${index}].path ne fonctionne que dans Node : passez content (octets ou Blob) ailleurs.`);
|
|
9083
|
+
}
|
|
9084
|
+
const { readFile } = await import("node:fs/promises");
|
|
9085
|
+
content = await readFile(piece.path);
|
|
9086
|
+
filename ??= nomDe(piece.path);
|
|
9087
|
+
}
|
|
9088
|
+
if (content == null) throw new TypeError(`attachments[${index}] n'a ni content ni path.`);
|
|
9089
|
+
let base64;
|
|
9090
|
+
if (typeof content === "string") {
|
|
9091
|
+
base64 = piece.encoding === "base64" ? content.replace(/\s+/g, "") : octetsEnBase64(new TextEncoder().encode(content));
|
|
9092
|
+
} else if (typeof Blob !== "undefined" && content instanceof Blob) {
|
|
9093
|
+
base64 = octetsEnBase64(new Uint8Array(await content.arrayBuffer()));
|
|
9094
|
+
filename ??= content.name;
|
|
9095
|
+
} else if (content instanceof ArrayBuffer) {
|
|
9096
|
+
base64 = octetsEnBase64(new Uint8Array(content));
|
|
9097
|
+
} else if (ArrayBuffer.isView(content)) {
|
|
9098
|
+
base64 = octetsEnBase64(new Uint8Array(content.buffer, content.byteOffset, content.byteLength));
|
|
9099
|
+
} else {
|
|
9100
|
+
throw new TypeError(`attachments[${index}].content doit \xEAtre un Buffer, un Uint8Array, un ArrayBuffer, un Blob ou une cha\xEEne.`);
|
|
9101
|
+
}
|
|
9102
|
+
const sortie = { filename: filename || `piece-${index + 1}`, content: base64 };
|
|
9103
|
+
if (piece.contentType) sortie.contentType = piece.contentType;
|
|
9104
|
+
if (piece.cid) sortie.cid = piece.cid;
|
|
9105
|
+
return sortie;
|
|
9106
|
+
}
|
|
9107
|
+
async function encodeAttachments(attachments) {
|
|
9108
|
+
if (!Array.isArray(attachments)) throw new TypeError("attachments doit \xEAtre une liste.");
|
|
9109
|
+
return Promise.all(attachments.map(encoderPiece));
|
|
9110
|
+
}
|
|
9037
9111
|
var Aliases = class {
|
|
9038
9112
|
constructor(client, mailbox) {
|
|
9039
9113
|
this.client = client;
|
|
@@ -9148,9 +9222,29 @@ var Mailbox = class {
|
|
|
9148
9222
|
* envoi-là. Quand elle demande l'image de la boîte, celle-ci voyage **dans** le message (`cid:`) : c'est la
|
|
9149
9223
|
* seule façon qu'un destinataire la voie, la pastille de son client étant dessinée depuis ses données à lui.
|
|
9150
9224
|
*/
|
|
9151
|
-
|
|
9225
|
+
/*
|
|
9226
|
+
* P82 (approuvé le 2026-11-18) — pièces jointes et Cci, dans la forme de nodemailer :
|
|
9227
|
+
*
|
|
9228
|
+
* await boite.send({
|
|
9229
|
+
* to: ["client@acme.com"], bcc: ["compta@moi.com"],
|
|
9230
|
+
* subject: "Votre facture",
|
|
9231
|
+
* html: '<h1>Merci</h1><img src="cid:logo">',
|
|
9232
|
+
* attachments: [
|
|
9233
|
+
* { filename: "facture.pdf", content: buffer, contentType: "application/pdf" },
|
|
9234
|
+
* { filename: "logo.png", content: png, cid: "logo" },
|
|
9235
|
+
* { filename: "devis.pdf", path: "./devis.pdf" }, // Node seulement
|
|
9236
|
+
* ],
|
|
9237
|
+
* });
|
|
9238
|
+
* // → { …, attachments: [{ filename, size, contentType, inline }] }
|
|
9239
|
+
*
|
|
9240
|
+
* `content` : Buffer, Uint8Array, ArrayBuffer, Blob, ou une chaîne — du texte UTF-8, sauf avec
|
|
9241
|
+
* `encoding: "base64"`, exactement comme nodemailer. 25 Mo au total ; les exécutables sont refusés.
|
|
9242
|
+
*/
|
|
9243
|
+
async send({ to = [], cc = [], bcc = [], subject = "", text: text2 = "", html = "", replyTo = null, signature: signature2, attachments } = {}) {
|
|
9152
9244
|
const corps = { to, cc, subject, text: text2, html, replyTo };
|
|
9245
|
+
if (bcc && (!Array.isArray(bcc) || bcc.length)) corps.bcc = bcc;
|
|
9153
9246
|
if (signature2 === false) corps.signature = false;
|
|
9247
|
+
if (attachments != null) corps.attachments = await encodeAttachments(attachments);
|
|
9154
9248
|
const res = await this.client.post(`/api/mail/${this.id}/send`, corps);
|
|
9155
9249
|
return res.sent;
|
|
9156
9250
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iagenify",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "IaGenify client and agent engine — the agent loop runs inside the SDK (tools, skills, sub-agents, terminals, sessions, memory) in Node, the browser and Cloudflare Workers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|