@standardagents/builder 0.37.5 → 0.37.6

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/dist/index.js CHANGED
@@ -14095,7 +14095,7 @@ var init_ThreadStateImpl = __esm({
14095
14095
  return bytes.buffer;
14096
14096
  }
14097
14097
  async readFileStream(path21, options) {
14098
- const fileInfo = await this._threadInstance.statFile(path21);
14098
+ const fileInfo = this._unwrapStatRecord(await this._threadInstance.statFile(path21));
14099
14099
  if (!fileInfo) {
14100
14100
  return null;
14101
14101
  }
@@ -14150,12 +14150,32 @@ var init_ThreadStateImpl = __esm({
14150
14150
  }
14151
14151
  };
14152
14152
  }
14153
+ /**
14154
+ * Unwrap the thread DO's `{ success, file }` stat envelope (older shapes
14155
+ * returned the record directly). A failed or absent lookup is NULL — the
14156
+ * old code mapped the envelope itself, producing a truthy record with
14157
+ * every field defaulted (size 0, application/octet-stream) even for
14158
+ * NONEXISTENT paths, which let a phantom asset pass an existence check and
14159
+ * a real 1.2MB image read as "0 bytes" (2026-08-11).
14160
+ */
14161
+ _unwrapStatRecord(result) {
14162
+ const record = result?.file ?? result;
14163
+ if (!record || typeof record !== "object") return null;
14164
+ if (!("path" in record) && !("name" in record)) return null;
14165
+ return record;
14166
+ }
14153
14167
  async statFile(path21) {
14154
- const result = await this._threadInstance.statFile(path21);
14155
- return result ? this._mapFileRecord(result) : null;
14168
+ const record = this._unwrapStatRecord(await this._threadInstance.statFile(path21));
14169
+ return record ? this._mapFileRecord(record) : null;
14156
14170
  }
14157
14171
  async readdirFile(path21) {
14158
- const entries = await this._threadInstance.readdirFile(path21);
14172
+ const result = await this._threadInstance.readdirFile(path21);
14173
+ const entries = Array.isArray(result) ? result : result?.files;
14174
+ if (!Array.isArray(entries)) {
14175
+ throw new Error(
14176
+ result?.error || `Could not list directory: ${path21}`
14177
+ );
14178
+ }
14159
14179
  return {
14160
14180
  entries: entries.map((e) => this._mapFileRecord(e))
14161
14181
  };