@standardagents/builder 0.11.0-next.c3b4490 → 0.11.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.
@@ -16528,7 +16528,10 @@ __export(files_exports2, {
16528
16528
  rowToFileRecord: () => rowToFileRecord
16529
16529
  });
16530
16530
  function isTextMimeType(mimeType) {
16531
- return TEXT_MIME_TYPES.some((prefix) => mimeType.startsWith(prefix));
16531
+ if (mimeType.startsWith("text/")) return true;
16532
+ return TEXT_APPLICATION_TYPES.some(
16533
+ (type) => mimeType === type || mimeType.startsWith(type + ";")
16534
+ );
16532
16535
  }
16533
16536
  function detectStorageBackend(location) {
16534
16537
  if (location.startsWith("s3://")) return "s3";
@@ -16605,17 +16608,67 @@ function inferMimeType(filename) {
16605
16608
  };
16606
16609
  return mimeTypes[ext || ""] || "application/octet-stream";
16607
16610
  }
16608
- var CHUNK_SIZE2, TEXT_MIME_TYPES, FileStorage;
16611
+ var CHUNK_SIZE2, TEXT_APPLICATION_TYPES, FileStorage;
16609
16612
  var init_files2 = __esm({
16610
16613
  "src/durable-objects/files.ts"() {
16611
16614
  CHUNK_SIZE2 = 1.75 * 1024 * 1024;
16612
- TEXT_MIME_TYPES = [
16613
- "text/",
16615
+ TEXT_APPLICATION_TYPES = [
16616
+ // Data formats
16614
16617
  "application/json",
16615
- "application/javascript",
16618
+ "application/ld+json",
16619
+ "application/json5",
16620
+ "application/jsonl",
16621
+ "application/x-ndjson",
16616
16622
  "application/xml",
16623
+ "application/xhtml+xml",
16624
+ "application/rss+xml",
16625
+ "application/atom+xml",
16626
+ "application/soap+xml",
16627
+ "application/yaml",
16617
16628
  "application/x-yaml",
16618
- "application/yaml"
16629
+ "application/toml",
16630
+ "application/x-toml",
16631
+ // Programming languages
16632
+ "application/javascript",
16633
+ "application/x-javascript",
16634
+ "application/ecmascript",
16635
+ "application/typescript",
16636
+ "application/x-typescript",
16637
+ "application/x-python",
16638
+ "application/x-ruby",
16639
+ "application/x-perl",
16640
+ "application/x-php",
16641
+ "application/x-sh",
16642
+ "application/x-bash",
16643
+ "application/x-csh",
16644
+ "application/x-zsh",
16645
+ "application/x-powershell",
16646
+ "application/x-lua",
16647
+ "application/x-tcl",
16648
+ // Query/config languages
16649
+ "application/sql",
16650
+ "application/x-sql",
16651
+ "application/graphql",
16652
+ "application/x-graphql",
16653
+ "application/sparql-query",
16654
+ "application/sparql-results+json",
16655
+ "application/sparql-results+xml",
16656
+ // Markup/templates
16657
+ "application/x-httpd-php",
16658
+ "application/x-latex",
16659
+ "application/x-tex",
16660
+ "application/rtf",
16661
+ "application/xslt+xml",
16662
+ // Web
16663
+ "application/x-www-form-urlencoded",
16664
+ "application/manifest+json",
16665
+ "application/webmanifest+json",
16666
+ "application/x-web-app-manifest+json",
16667
+ // Config files
16668
+ "application/x-ini",
16669
+ "application/x-properties",
16670
+ "application/plist",
16671
+ "application/x-plist"
16619
16672
  ];
16620
16673
  FileStorage = class {
16621
16674
  constructor(sql) {
@@ -20446,8 +20499,105 @@ var init_ThreadStateImpl = __esm({
20446
20499
  // File System
20447
20500
  // ─────────────────────────────────────────────────────────────────────────
20448
20501
  async writeFile(path, data, mimeType, options) {
20449
- const result = await this._threadInstance.writeFile(path, data, mimeType, options);
20450
- return this._mapFileRecord(result);
20502
+ const isText = this._isTextMimeType(mimeType);
20503
+ if (isText) {
20504
+ let textContent;
20505
+ if (typeof data === "string") {
20506
+ textContent = data;
20507
+ } else {
20508
+ textContent = new TextDecoder().decode(data);
20509
+ }
20510
+ const result = await this._threadInstance.writeTextFile(path, textContent, mimeType, options);
20511
+ return this._mapFileRecord(result.file);
20512
+ } else {
20513
+ let base64Data;
20514
+ if (typeof data === "string") {
20515
+ const encoder = new TextEncoder();
20516
+ const bytes = encoder.encode(data);
20517
+ let binary = "";
20518
+ for (let i = 0; i < bytes.length; i++) {
20519
+ binary += String.fromCharCode(bytes[i]);
20520
+ }
20521
+ base64Data = btoa(binary);
20522
+ } else {
20523
+ const bytes = new Uint8Array(data);
20524
+ let binary = "";
20525
+ for (let i = 0; i < bytes.length; i++) {
20526
+ binary += String.fromCharCode(bytes[i]);
20527
+ }
20528
+ base64Data = btoa(binary);
20529
+ }
20530
+ const result = await this._threadInstance.writeFile(path, base64Data, mimeType, options);
20531
+ return this._mapFileRecord(result.file);
20532
+ }
20533
+ }
20534
+ /**
20535
+ * Check if a MIME type should be stored as searchable text.
20536
+ * Matches the logic in FileStorage for consistency.
20537
+ */
20538
+ _isTextMimeType(mimeType) {
20539
+ if (mimeType.startsWith("text/")) return true;
20540
+ const TEXT_APPLICATION_TYPES2 = [
20541
+ // Data formats
20542
+ "application/json",
20543
+ "application/ld+json",
20544
+ "application/json5",
20545
+ "application/jsonl",
20546
+ "application/x-ndjson",
20547
+ "application/xml",
20548
+ "application/xhtml+xml",
20549
+ "application/rss+xml",
20550
+ "application/atom+xml",
20551
+ "application/soap+xml",
20552
+ "application/yaml",
20553
+ "application/x-yaml",
20554
+ "application/toml",
20555
+ "application/x-toml",
20556
+ // Programming languages
20557
+ "application/javascript",
20558
+ "application/x-javascript",
20559
+ "application/ecmascript",
20560
+ "application/typescript",
20561
+ "application/x-typescript",
20562
+ "application/x-python",
20563
+ "application/x-ruby",
20564
+ "application/x-perl",
20565
+ "application/x-php",
20566
+ "application/x-sh",
20567
+ "application/x-bash",
20568
+ "application/x-csh",
20569
+ "application/x-zsh",
20570
+ "application/x-powershell",
20571
+ "application/x-lua",
20572
+ "application/x-tcl",
20573
+ // Query/config languages
20574
+ "application/sql",
20575
+ "application/x-sql",
20576
+ "application/graphql",
20577
+ "application/x-graphql",
20578
+ "application/sparql-query",
20579
+ "application/sparql-results+json",
20580
+ "application/sparql-results+xml",
20581
+ // Markup/templates
20582
+ "application/x-httpd-php",
20583
+ "application/x-latex",
20584
+ "application/x-tex",
20585
+ "application/rtf",
20586
+ "application/xslt+xml",
20587
+ // Web
20588
+ "application/x-www-form-urlencoded",
20589
+ "application/manifest+json",
20590
+ "application/webmanifest+json",
20591
+ "application/x-web-app-manifest+json",
20592
+ // Config files
20593
+ "application/x-ini",
20594
+ "application/x-properties",
20595
+ "application/plist",
20596
+ "application/x-plist"
20597
+ ];
20598
+ return TEXT_APPLICATION_TYPES2.some(
20599
+ (type) => mimeType === type || mimeType.startsWith(type + ";")
20600
+ );
20451
20601
  }
20452
20602
  async readFile(path) {
20453
20603
  const result = await this._threadInstance.readFile(path);