@plosson/agentio 0.5.12 → 0.5.13

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plosson/agentio",
3
- "version": "0.5.12",
3
+ "version": "0.5.13",
4
4
  "description": "CLI for LLM agents to interact with communication and tracking services",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -5,6 +5,13 @@ import type { GmailMessage, GmailListOptions, GmailSendOptions, GmailAttachment,
5
5
  import type { ServiceClient, ValidationResult } from '../../types/service';
6
6
  import { CliError } from '../../utils/errors';
7
7
 
8
+ // RFC 2047 encode a header value if it contains non-ASCII characters
9
+ function encodeHeaderValue(value: string): string {
10
+ // eslint-disable-next-line no-control-regex
11
+ if (/^[\x00-\x7F]*$/.test(value)) return value;
12
+ return `=?UTF-8?B?${Buffer.from(value, 'utf-8').toString('base64')}?=`;
13
+ }
14
+
8
15
  // Common MIME types by extension
9
16
  const MIME_TYPES: Record<string, string> = {
10
17
  '.txt': 'text/plain',
@@ -333,7 +340,7 @@ export class GmailClient implements ServiceClient {
333
340
  `To: ${to.join(', ')}`,
334
341
  cc?.length ? `Cc: ${cc.join(', ')}` : null,
335
342
  bcc?.length ? `Bcc: ${bcc.join(', ')}` : null,
336
- `Subject: ${subject}`,
343
+ `Subject: ${encodeHeaderValue(subject)}`,
337
344
  ...(extraHeaders || []),
338
345
  `Content-Type: ${isHtml ? 'text/html' : 'text/plain'}; charset=utf-8`,
339
346
  '',
@@ -422,7 +429,7 @@ export class GmailClient implements ServiceClient {
422
429
  lines.push(`To: ${to.join(', ')}`);
423
430
  if (cc?.length) lines.push(`Cc: ${cc.join(', ')}`);
424
431
  if (bcc?.length) lines.push(`Bcc: ${bcc.join(', ')}`);
425
- lines.push(`Subject: ${subject}`);
432
+ lines.push(`Subject: ${encodeHeaderValue(subject)}`);
426
433
  if (extraHeaders) {
427
434
  for (const header of extraHeaders) {
428
435
  lines.push(header);