@poe-platform/safe-js 0.1.805 → 0.1.806

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.
Files changed (64) hide show
  1. package/README.md +17 -1
  2. package/dist/agent-harness-tools/execution-env.d.ts +1 -1
  3. package/dist/agent-harness-tools/harness-dashboard.d.ts +2 -1
  4. package/dist/agent-harness-tools/poe-command-execution.d.ts +5 -3
  5. package/dist/agent-harness-tools/runner.d.ts +1 -1
  6. package/dist/agent-harness-tools/workspace-transfer.d.ts +2 -2
  7. package/dist/poe-acp-client/acp-transport.d.ts +1 -1
  8. package/dist/poe-code-config/memory.d.ts +1 -0
  9. package/dist/poe-code-config/runtime.d.ts +5 -2
  10. package/dist/process-runner/types.d.ts +1 -1
  11. package/dist/process-runner/workspace-transfer.d.ts +6 -5
  12. package/dist/safe-js/chunks/{chunk-KMBCLXER.js → chunk-2IYZK337.js} +1 -1
  13. package/dist/safe-js/chunks/{chunk-WNCT5WTP.js → chunk-3W4JJFK6.js} +1 -1
  14. package/dist/safe-js/chunks/{chunk-GJPD4ALZ.js → chunk-425IYA26.js} +1 -1
  15. package/dist/safe-js/chunks/{chunk-2LI4AP6C.js → chunk-5FPEN6AM.js} +8 -7
  16. package/dist/safe-js/chunks/{chunk-NOS76GMS.js → chunk-5ZVTZBH2.js} +1 -1
  17. package/dist/safe-js/chunks/{chunk-N3EL5B4L.js → chunk-7RGEML7S.js} +5 -4
  18. package/dist/safe-js/chunks/{chunk-VQKUOXQ2.js → chunk-BEA7FA5M.js} +9 -2
  19. package/dist/safe-js/chunks/{chunk-WZ27FAD3.js → chunk-C5NG3LHQ.js} +3 -3
  20. package/dist/safe-js/chunks/{chunk-HFCSCNZN.js → chunk-E7V44LSN.js} +54 -47
  21. package/dist/safe-js/chunks/{chunk-VVOPJZRG.js → chunk-H25SH6HQ.js} +3 -1
  22. package/dist/safe-js/chunks/{chunk-AN6Z3R6M.js → chunk-MJH5AYEK.js} +1 -1
  23. package/dist/safe-js/chunks/{chunk-JQ5QJV5Q.js → chunk-P5Y4UF4L.js} +2 -2
  24. package/dist/safe-js/chunks/{chunk-JVE54EBX.js → chunk-ROIZEQTS.js} +7 -4
  25. package/dist/safe-js/chunks/{chunk-HR3HSM26.js → chunk-SAYUBVHD.js} +2 -2
  26. package/dist/safe-js/chunks/{chunk-IRCZI6HL.js → chunk-SV37HEM5.js} +4 -4
  27. package/dist/safe-js/chunks/{chunk-RPGCF4KE.js → chunk-TG7TRXYG.js} +49 -2
  28. package/dist/safe-js/chunks/{chunk-ECMGBHAB.js → chunk-XQOJJA4C.js} +11 -65
  29. package/dist/safe-js/chunks/{cli-runtime-6EBUM6AL.js → cli-runtime-EV4DQ7UW.js} +16 -16
  30. package/dist/safe-js/chunks/{dump-S6HOPYA6.js → dump-OX7M4C56.js} +3 -3
  31. package/dist/safe-js/chunks/{harness-GQGDTZ5P.js → harness-4BETCNJY.js} +3 -3
  32. package/dist/safe-js/chunks/mcp-DSJET2K4.js +12 -0
  33. package/dist/safe-js/chunks/{migration-file-BJVZMCID.js → migration-file-6LFFQLZN.js} +5 -5
  34. package/dist/safe-js/chunks/{restore-GU6CISV6.js → restore-BFVCW6H4.js} +4 -4
  35. package/dist/safe-js/chunks/{run-STNASYDW.js → run-PWX3SVTF.js} +7 -7
  36. package/dist/safe-js/chunks/{runtime-modules-5MQCTIB5.js → runtime-modules-UOVJSSD7.js} +3 -3
  37. package/dist/safe-js/chunks/{source-files-A2WSOO6G.js → source-files-QT24SQTE.js} +3 -3
  38. package/dist/safe-js/cli.js +2 -2
  39. package/dist/safe-js/core.d.ts +3 -0
  40. package/dist/safe-js/core.js +19 -13
  41. package/dist/safe-js/host-context.d.ts +5 -0
  42. package/dist/safe-js/index.d.ts +1 -0
  43. package/dist/safe-js/index.js +22 -20
  44. package/dist/safe-js/interp/host-bridge.d.ts +2 -0
  45. package/dist/safe-js/interp/resources.d.ts +23 -0
  46. package/dist/safe-js/modules/fs-config.d.ts +1 -1
  47. package/dist/safe-js/modules/fs.js +4 -4
  48. package/dist/safe-js/modules/mcp-transport.d.ts +1 -1
  49. package/dist/safe-js/modules/registry.d.ts +2 -0
  50. package/dist/safe-js/platform/context.js +19 -8
  51. package/dist/safe-js/platform/node.d.ts +1 -0
  52. package/dist/safe-js/platform/node.js +1 -0
  53. package/dist/safe-js/platform/workerd.d.ts +1 -0
  54. package/dist/safe-js/platform/workerd.js +1 -0
  55. package/dist/safe-js/portable/chunks/{chunk-W6MZOTYR.js → chunk-LCUQNFD2.js} +17 -7
  56. package/dist/safe-js/portable/chunks/{chunk-NLGXLZCK.js → chunk-MKRVEJD6.js} +1 -1
  57. package/dist/safe-js/portable/chunks/{chunk-OCBLPMJE.js → chunk-OCBYWLKS.js} +7 -4
  58. package/dist/safe-js/portable/chunks/{source-files-AEDWESAJ.js → source-files-HMG6KJLP.js} +2 -2
  59. package/dist/safe-js/portable/core.js +56 -4
  60. package/dist/safe-js/portable/modules/fs.js +2 -2
  61. package/dist/safe-js/workerd.d.ts +1 -2
  62. package/dist/safe-js/workerd.js +11645 -831
  63. package/package.json +2 -2
  64. package/dist/safe-js/chunks/mcp-MILSUBPS.js +0 -11
@@ -1,3 +1,7 @@
1
+ import {
2
+ paths_default
3
+ } from "./chunk-2IYZK337.js";
4
+
1
5
  // packages/tiny-mcp-client/src/http-json-budget.ts
2
6
  function assertHttpJsonBudget(text) {
3
7
  let nodes = 0;
@@ -222,6 +226,9 @@ function dialectFor(schema, inherited) {
222
226
  return inherited;
223
227
  }
224
228
  function resolveUri(reference, baseUri) {
229
+ if (typeof URL === "undefined" && (reference === "" || reference.startsWith("#"))) {
230
+ return `${withoutFragment(baseUri)}${reference}`;
231
+ }
225
232
  try {
226
233
  return new URL(reference, baseUri).href;
227
234
  } catch {
@@ -270,8 +277,8 @@ function receivedType(value) {
270
277
  }
271
278
  return typeof value;
272
279
  }
273
- function issue(path6, expected, value, message, keyword = keywordFor(expected)) {
274
- return { path: path6, expected, received: receivedType(value), message, keyword };
280
+ function issue(path5, expected, value, message, keyword = keywordFor(expected)) {
281
+ return { path: path5, expected, received: receivedType(value), message, keyword };
275
282
  }
276
283
  function keywordFor(expected) {
277
284
  if (["null", "boolean", "object", "array", "number", "integer", "string"].includes(expected)) {
@@ -1102,41 +1109,41 @@ function evaluateArrayApplicators(graph, node, schema, value, context) {
1102
1109
  }
1103
1110
  return results;
1104
1111
  }
1105
- function evaluateValidationKeywords(node, schema, value, path6) {
1112
+ function evaluateValidationKeywords(node, schema, value, path5) {
1106
1113
  const results = [];
1107
1114
  const types = typeof schema.type === "string" ? [schema.type] : Array.isArray(schema.type) ? schema.type : [];
1108
1115
  if (types.length > 0 && !types.some((type) => typeof type === "string" && typeMatches(type, value))) {
1109
- results.push(invalidResult(issue(path6, types.join(","), value, `must be ${types.join(",")}`)));
1116
+ results.push(invalidResult(issue(path5, types.join(","), value, `must be ${types.join(",")}`)));
1110
1117
  return results;
1111
1118
  }
1112
1119
  if (schema.const !== void 0 && !deepEqual(schema.const, value)) {
1113
- results.push(invalidResult(issue(path6, "const", value, "must be equal to constant")));
1120
+ results.push(invalidResult(issue(path5, "const", value, "must be equal to constant")));
1114
1121
  }
1115
1122
  if (Array.isArray(schema.enum) && !schema.enum.some((entry) => deepEqual(entry, value))) {
1116
1123
  results.push(
1117
- invalidResult(issue(path6, "enum", value, "must be equal to one of the allowed values"))
1124
+ invalidResult(issue(path5, "enum", value, "must be equal to one of the allowed values"))
1118
1125
  );
1119
1126
  }
1120
1127
  if (typeof value === "number" && Number.isFinite(value)) {
1121
- evaluateNumberKeywords(schema, value, path6, results);
1128
+ evaluateNumberKeywords(schema, value, path5, results);
1122
1129
  }
1123
1130
  if (typeof value === "string") {
1124
- evaluateStringKeywords(schema, value, path6, results);
1131
+ evaluateStringKeywords(schema, value, path5, results);
1125
1132
  }
1126
1133
  if (Array.isArray(value)) {
1127
- evaluateArrayKeywords(schema, value, path6, results);
1134
+ evaluateArrayKeywords(schema, value, path5, results);
1128
1135
  }
1129
1136
  if (isObject(value)) {
1130
- evaluateObjectKeywords(node, schema, value, path6, results);
1137
+ evaluateObjectKeywords(node, schema, value, path5, results);
1131
1138
  }
1132
1139
  return results;
1133
1140
  }
1134
- function evaluateNumberKeywords(schema, value, path6, results) {
1141
+ function evaluateNumberKeywords(schema, value, path5, results) {
1135
1142
  if (typeof schema.multipleOf === "number" && !isMultipleOf(value, schema.multipleOf)) {
1136
1143
  results.push(
1137
1144
  invalidResult(
1138
1145
  issue(
1139
- path6,
1146
+ path5,
1140
1147
  `multiple of ${schema.multipleOf}`,
1141
1148
  value,
1142
1149
  `must be multiple of ${schema.multipleOf}`
@@ -1146,36 +1153,36 @@ function evaluateNumberKeywords(schema, value, path6, results) {
1146
1153
  }
1147
1154
  if (typeof schema.maximum === "number" && value > schema.maximum) {
1148
1155
  results.push(
1149
- invalidResult(issue(path6, `<= ${schema.maximum}`, value, `must be <= ${schema.maximum}`))
1156
+ invalidResult(issue(path5, `<= ${schema.maximum}`, value, `must be <= ${schema.maximum}`))
1150
1157
  );
1151
1158
  }
1152
1159
  if (typeof schema.minimum === "number" && value < schema.minimum) {
1153
1160
  results.push(
1154
- invalidResult(issue(path6, `>= ${schema.minimum}`, value, `must be >= ${schema.minimum}`))
1161
+ invalidResult(issue(path5, `>= ${schema.minimum}`, value, `must be >= ${schema.minimum}`))
1155
1162
  );
1156
1163
  }
1157
1164
  if (typeof schema.exclusiveMaximum === "number" && value >= schema.exclusiveMaximum) {
1158
1165
  results.push(
1159
1166
  invalidResult(
1160
- issue(path6, `< ${schema.exclusiveMaximum}`, value, `must be < ${schema.exclusiveMaximum}`)
1167
+ issue(path5, `< ${schema.exclusiveMaximum}`, value, `must be < ${schema.exclusiveMaximum}`)
1161
1168
  )
1162
1169
  );
1163
1170
  }
1164
1171
  if (typeof schema.exclusiveMinimum === "number" && value <= schema.exclusiveMinimum) {
1165
1172
  results.push(
1166
1173
  invalidResult(
1167
- issue(path6, `> ${schema.exclusiveMinimum}`, value, `must be > ${schema.exclusiveMinimum}`)
1174
+ issue(path5, `> ${schema.exclusiveMinimum}`, value, `must be > ${schema.exclusiveMinimum}`)
1168
1175
  )
1169
1176
  );
1170
1177
  }
1171
1178
  }
1172
- function evaluateStringKeywords(schema, value, path6, results) {
1179
+ function evaluateStringKeywords(schema, value, path5, results) {
1173
1180
  const length = unicodeLength(value);
1174
1181
  if (typeof schema.maxLength === "number" && length > schema.maxLength) {
1175
1182
  results.push(
1176
1183
  invalidResult(
1177
1184
  issue(
1178
- path6,
1185
+ path5,
1179
1186
  `length <= ${schema.maxLength}`,
1180
1187
  value,
1181
1188
  `must NOT have more than ${schema.maxLength} characters`
@@ -1187,7 +1194,7 @@ function evaluateStringKeywords(schema, value, path6, results) {
1187
1194
  results.push(
1188
1195
  invalidResult(
1189
1196
  issue(
1190
- path6,
1197
+ path5,
1191
1198
  `length >= ${schema.minLength}`,
1192
1199
  value,
1193
1200
  `must NOT have fewer than ${schema.minLength} characters`
@@ -1198,17 +1205,17 @@ function evaluateStringKeywords(schema, value, path6, results) {
1198
1205
  if (typeof schema.pattern === "string" && !new RegExp(schema.pattern, "u").test(value)) {
1199
1206
  results.push(
1200
1207
  invalidResult(
1201
- issue(path6, `pattern ${schema.pattern}`, value, `must match pattern ${schema.pattern}`)
1208
+ issue(path5, `pattern ${schema.pattern}`, value, `must match pattern ${schema.pattern}`)
1202
1209
  )
1203
1210
  );
1204
1211
  }
1205
1212
  }
1206
- function evaluateArrayKeywords(schema, value, path6, results) {
1213
+ function evaluateArrayKeywords(schema, value, path5, results) {
1207
1214
  if (typeof schema.maxItems === "number" && value.length > schema.maxItems) {
1208
1215
  results.push(
1209
1216
  invalidResult(
1210
1217
  issue(
1211
- path6,
1218
+ path5,
1212
1219
  `items <= ${schema.maxItems}`,
1213
1220
  value,
1214
1221
  `must NOT have more than ${schema.maxItems} items`
@@ -1220,7 +1227,7 @@ function evaluateArrayKeywords(schema, value, path6, results) {
1220
1227
  results.push(
1221
1228
  invalidResult(
1222
1229
  issue(
1223
- path6,
1230
+ path5,
1224
1231
  `items >= ${schema.minItems}`,
1225
1232
  value,
1226
1233
  `must NOT have fewer than ${schema.minItems} items`
@@ -1233,7 +1240,7 @@ function evaluateArrayKeywords(schema, value, path6, results) {
1233
1240
  for (let right = left + 1; right < value.length; right += 1) {
1234
1241
  if (deepEqual(value[left], value[right])) {
1235
1242
  results.push(
1236
- invalidResult(issue(path6, "unique items", value, "must NOT have duplicate items"))
1243
+ invalidResult(issue(path5, "unique items", value, "must NOT have duplicate items"))
1237
1244
  );
1238
1245
  return;
1239
1246
  }
@@ -1241,13 +1248,13 @@ function evaluateArrayKeywords(schema, value, path6, results) {
1241
1248
  }
1242
1249
  }
1243
1250
  }
1244
- function evaluateObjectKeywords(node, schema, value, path6, results) {
1251
+ function evaluateObjectKeywords(node, schema, value, path5, results) {
1245
1252
  const keys = Object.keys(value);
1246
1253
  if (typeof schema.maxProperties === "number" && keys.length > schema.maxProperties) {
1247
1254
  results.push(
1248
1255
  invalidResult(
1249
1256
  issue(
1250
- path6,
1257
+ path5,
1251
1258
  `properties <= ${schema.maxProperties}`,
1252
1259
  value,
1253
1260
  `must NOT have more than ${schema.maxProperties} properties`
@@ -1259,7 +1266,7 @@ function evaluateObjectKeywords(node, schema, value, path6, results) {
1259
1266
  results.push(
1260
1267
  invalidResult(
1261
1268
  issue(
1262
- path6,
1269
+ path5,
1263
1270
  `properties >= ${schema.minProperties}`,
1264
1271
  value,
1265
1272
  `must NOT have fewer than ${schema.minProperties} properties`
@@ -1272,7 +1279,7 @@ function evaluateObjectKeywords(node, schema, value, path6, results) {
1272
1279
  if (typeof key2 === "string" && !Object.prototype.hasOwnProperty.call(value, key2)) {
1273
1280
  results.push(
1274
1281
  invalidResult(
1275
- issue([...path6, key2], "required", void 0, `must have required property '${key2}'`)
1282
+ issue([...path5, key2], "required", void 0, `must have required property '${key2}'`)
1276
1283
  )
1277
1284
  );
1278
1285
  }
@@ -1281,24 +1288,24 @@ function evaluateObjectKeywords(node, schema, value, path6, results) {
1281
1288
  const dependentRequired = isObject(schema.dependentRequired) ? schema.dependentRequired : {};
1282
1289
  for (const [key2, dependencies] of Object.entries(dependentRequired)) {
1283
1290
  if (Object.prototype.hasOwnProperty.call(value, key2) && Array.isArray(dependencies)) {
1284
- addMissingDependencies(value, dependencies, path6, results);
1291
+ addMissingDependencies(value, dependencies, path5, results);
1285
1292
  }
1286
1293
  }
1287
1294
  if (node.dialect === "draft7" && isObject(schema.dependencies)) {
1288
1295
  for (const [key2, dependencies] of Object.entries(schema.dependencies)) {
1289
1296
  if (Object.prototype.hasOwnProperty.call(value, key2) && Array.isArray(dependencies)) {
1290
- addMissingDependencies(value, dependencies, path6, results);
1297
+ addMissingDependencies(value, dependencies, path5, results);
1291
1298
  }
1292
1299
  }
1293
1300
  }
1294
1301
  }
1295
- function addMissingDependencies(value, dependencies, path6, results) {
1302
+ function addMissingDependencies(value, dependencies, path5, results) {
1296
1303
  for (const dependency of dependencies) {
1297
1304
  if (typeof dependency === "string" && !Object.prototype.hasOwnProperty.call(value, dependency)) {
1298
1305
  results.push(
1299
1306
  invalidResult(
1300
1307
  issue(
1301
- [...path6, dependency],
1308
+ [...path5, dependency],
1302
1309
  "dependency",
1303
1310
  void 0,
1304
1311
  `must have property '${dependency}'`
@@ -6504,7 +6511,7 @@ function getParameterHeaders(schema) {
6504
6511
  const names = /* @__PURE__ */ new Set();
6505
6512
  const ancestors = /* @__PURE__ */ new Set();
6506
6513
  let nodes = 0;
6507
- const visit = (value, path6, reachable, depth) => {
6514
+ const visit = (value, path5, reachable, depth) => {
6508
6515
  if (++nodes > 1e4 || depth > 64)
6509
6516
  throw new Error("MCP header schema traversal limit exceeded");
6510
6517
  if (typeof value === "boolean") return;
@@ -6513,7 +6520,7 @@ function getParameterHeaders(schema) {
6513
6520
  try {
6514
6521
  if (Object.prototype.hasOwnProperty.call(value, "x-mcp-header")) {
6515
6522
  const name = value["x-mcp-header"];
6516
- if (!reachable || path6.length === 0 || typeof name !== "string" || name.length === 0 || [...name].some((character) => {
6523
+ if (!reachable || path5.length === 0 || typeof name !== "string" || name.length === 0 || [...name].some((character) => {
6517
6524
  const code = character.charCodeAt(0);
6518
6525
  return !tokenPunctuation.has(character) && !(code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122);
6519
6526
  }))
@@ -6523,7 +6530,7 @@ function getParameterHeaders(schema) {
6523
6530
  const key2 = name.toLowerCase();
6524
6531
  if (names.has(key2)) throw new Error("Duplicate x-mcp-header name");
6525
6532
  names.add(key2);
6526
- headers.push({ name: `Mcp-Param-${name}`, path: [...path6], type: value.type });
6533
+ headers.push({ name: `Mcp-Param-${name}`, path: [...path5], type: value.type });
6527
6534
  }
6528
6535
  for (const [keyword, child] of Object.entries(value)) {
6529
6536
  if (schemaMaps.has(keyword)) {
@@ -6531,17 +6538,17 @@ function getParameterHeaders(schema) {
6531
6538
  for (const [key2, nested] of Object.entries(child))
6532
6539
  visit(
6533
6540
  nested,
6534
- keyword === "properties" ? [...path6, key2] : path6,
6541
+ keyword === "properties" ? [...path5, key2] : path5,
6535
6542
  reachable && keyword === "properties",
6536
6543
  depth + 1
6537
6544
  );
6538
6545
  } else if (schemaArrays.has(keyword)) {
6539
6546
  if (!Array.isArray(child)) throw new Error("Invalid schema array");
6540
- for (const nested of child) visit(nested, path6, false, depth + 1);
6547
+ for (const nested of child) visit(nested, path5, false, depth + 1);
6541
6548
  } else if (schemaChildren.has(keyword)) {
6542
6549
  if (Array.isArray(child))
6543
- for (const nested of child) visit(nested, path6, false, depth + 1);
6544
- else visit(child, path6, false, depth + 1);
6550
+ for (const nested of child) visit(nested, path5, false, depth + 1);
6551
+ else visit(child, path5, false, depth + 1);
6545
6552
  }
6546
6553
  }
6547
6554
  } finally {
@@ -6753,8 +6760,8 @@ function authorizationServerMetadataLocations(issuer) {
6753
6760
  ];
6754
6761
  const issuerUrl = new URL(issuer);
6755
6762
  if (issuerUrl.pathname !== "/") {
6756
- const path6 = issuerUrl.pathname.endsWith("/") ? issuerUrl.pathname.slice(0, -1) : issuerUrl.pathname;
6757
- issuerUrl.pathname = `${path6}/.well-known/openid-configuration`;
6763
+ const path5 = issuerUrl.pathname.endsWith("/") ? issuerUrl.pathname.slice(0, -1) : issuerUrl.pathname;
6764
+ issuerUrl.pathname = `${path5}/.well-known/openid-configuration`;
6758
6765
  locations.push(issuerUrl.toString());
6759
6766
  }
6760
6767
  return locations;
@@ -9354,8 +9361,10 @@ function parseJsonRpcPayload(parsed) {
9354
9361
  };
9355
9362
  }
9356
9363
 
9357
- // packages/tiny-mcp-client/src/stdio-transport.ts
9364
+ // packages/tiny-mcp-client/src/spawn.node.ts
9358
9365
  import { spawn as spawn2 } from "node:child_process";
9366
+
9367
+ // packages/tiny-mcp-client/src/stdio-transport.ts
9359
9368
  function defaultStdioSpawn(command, args, options) {
9360
9369
  return spawn2(command, args, options);
9361
9370
  }
@@ -9460,8 +9469,6 @@ var StdioTransport = class _StdioTransport {
9460
9469
  };
9461
9470
 
9462
9471
  // packages/safe-js/src/modules/mcp-transport.ts
9463
- import { spawn as spawn3 } from "node:child_process";
9464
- import path5 from "node:path";
9465
9472
  function parseMcpConfig(source, directory) {
9466
9473
  const parsed = JSON.parse(source);
9467
9474
  const options = normalizeMcpOptions(parsed, [
@@ -9472,9 +9479,9 @@ function parseMcpConfig(source, directory) {
9472
9479
  ]);
9473
9480
  for (const server of Object.values(options.servers)) {
9474
9481
  if ("command" in server) {
9475
- server.cwd = path5.resolve(directory, server.cwd ?? ".");
9482
+ server.cwd = paths_default.resolve(directory, server.cwd ?? ".");
9476
9483
  if (server.command.includes("/") || server.command.includes("\\")) {
9477
- server.command = path5.resolve(directory, server.command);
9484
+ server.command = paths_default.resolve(directory, server.command);
9478
9485
  }
9479
9486
  }
9480
9487
  }
@@ -9583,7 +9590,7 @@ function connectMcpTransport(server, options, signal) {
9583
9590
  const transport = "command" in server ? new StdioTransport({
9584
9591
  ...server,
9585
9592
  spawn(command, args, spawnOptions) {
9586
- child = options.spawn === void 0 ? spawn3(command, args, spawnOptions) : options.spawn(command, args, spawnOptions);
9593
+ child = options.spawn === void 0 ? defaultStdioSpawn(command, args, spawnOptions) : options.spawn(command, args, spawnOptions);
9587
9594
  return child;
9588
9595
  }
9589
9596
  }) : new HttpTransport({
@@ -7,6 +7,7 @@ import { setImmediate } from "node:timers/promises";
7
7
  import { inspect } from "node:util";
8
8
  import { formatWithOptions } from "node:util";
9
9
  import { constants } from "node:fs";
10
+ import { createNodeFileSystemAdapterRegistry } from "@poe-platform/safe-fs";
10
11
  var nativeClone = structuredClone;
11
12
  var sharedByteLength = Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get;
12
13
  var postMessage = MessagePort.prototype.postMessage;
@@ -69,5 +70,6 @@ export {
69
70
  setImmediate,
70
71
  inspect,
71
72
  formatWithOptions,
72
- constants
73
+ constants,
74
+ createNodeFileSystemAdapterRegistry
73
75
  };
@@ -2,7 +2,7 @@ import {
2
2
  HostCallJournal,
3
3
  decodeReplayData,
4
4
  validateSnapshotData
5
- } from "./chunk-JVE54EBX.js";
5
+ } from "./chunk-ROIZEQTS.js";
6
6
  import {
7
7
  CompileScope,
8
8
  SandboxError,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  paths_default
3
- } from "./chunk-KMBCLXER.js";
3
+ } from "./chunk-2IYZK337.js";
4
4
  import {
5
5
  constants,
6
6
  hostFs
7
- } from "./chunk-VVOPJZRG.js";
7
+ } from "./chunk-H25SH6HQ.js";
8
8
 
9
9
  // packages/safe-js/src/modules/source-files.ts
10
10
  import { resolvePath } from "@poe-platform/safe-fs/core";
@@ -47,7 +47,7 @@ import {
47
47
  cloneSharedBufferWrapper,
48
48
  setImmediate,
49
49
  types
50
- } from "./chunk-VVOPJZRG.js";
50
+ } from "./chunk-H25SH6HQ.js";
51
51
 
52
52
  // packages/safe-js/src/interp/native-promise-properties.ts
53
53
  var admittedSymbols = /* @__PURE__ */ new WeakMap();
@@ -23773,7 +23773,7 @@ function readHostOperationPolicy(operation) {
23773
23773
  }
23774
23774
  function wrapCallerInjectedBindings(bindings, options) {
23775
23775
  const operation = options.budget.acquireCompileOwner(false, options.compileOwner);
23776
- options = { ...options, registerCapabilities: true, compileOwner: operation.owner };
23776
+ options = { ...options, resources: options.resources ?? runResources.getStore(), registerCapabilities: true, compileOwner: operation.owner };
23777
23777
  try {
23778
23778
  const state = { seen: /* @__PURE__ */ new WeakMap() };
23779
23779
  const copied = Object.fromEntries(
@@ -23924,10 +23924,12 @@ function wrapCallerInjectedFunction(name, value, options, state, validateResult)
23924
23924
  const captured = options.realm?.captureArguments(callable, args, copyArguments);
23925
23925
  const hostArgs = captured?.args ?? copyArguments(args);
23926
23926
  const budgetedOperation = budgetedHostOperations.get(callable);
23927
- const callOperation = () => {
23927
+ const invokeOperation = () => {
23928
23928
  const result2 = budgetedOperation === void 0 ? Reflect.apply(callable, void 0, hostArgs) : budgetedOperation(hostArgs, options.budget);
23929
23929
  return validateResult === void 0 ? result2 : validateResult(result2);
23930
23930
  };
23931
+ const resources = options.resources;
23932
+ const callOperation = resources === void 0 ? invokeOperation : () => runResources.run(resources, invokeOperation);
23931
23933
  const hostCalls = options.hostCalls;
23932
23934
  const operation = options.operation ?? bindingName;
23933
23935
  const moduleId = options.moduleId ?? "<bindings>";
@@ -25155,7 +25157,7 @@ function createModuleEnvironment(modules, options, restored) {
25155
25157
  namespaces: createBindingRecord(Object.fromEntries(options.wrappedModules ?? []))
25156
25158
  };
25157
25159
  revokeImmutableEmptyModuleEnvironment(environment);
25158
- moduleEnvironments.set(environment, { registry, options, prepared: /* @__PURE__ */ new Set(), capabilities: /* @__PURE__ */ new Map() });
25160
+ moduleEnvironments.set(environment, { registry, options, resources: options.resources ?? runResources.getStore(), prepared: /* @__PURE__ */ new Set(), capabilities: /* @__PURE__ */ new Map() });
25159
25161
  return environment;
25160
25162
  }
25161
25163
  function createImmutableEmptyModuleEnvironment(options) {
@@ -25188,6 +25190,7 @@ function resolveModuleNamespace(environment, moduleName, prepare = true) {
25188
25190
  if (exports === void 0) throw new Error(createUnknownModuleMessage(moduleName, [...backend.registry.keys()]));
25189
25191
  let namespace = createModuleNamespace(wrapCancelableBindings(
25190
25192
  wrapCallerInjectedBindings(Object.fromEntries(exports), {
25193
+ resources: backend.resources,
25191
25194
  realm: options.realm,
25192
25195
  budget: options.budget,
25193
25196
  compileOwner: options.compileOwner,
@@ -2,7 +2,7 @@ import {
2
2
  hashParsedAst,
3
3
  hashSource,
4
4
  validateSnapshotMigration
5
- } from "./chunk-AN6Z3R6M.js";
5
+ } from "./chunk-MJH5AYEK.js";
6
6
  import {
7
7
  SnapshotValidationError,
8
8
  assertSnapshotInactive,
@@ -11,7 +11,7 @@ import {
11
11
  validateDumpEnvelope,
12
12
  validateGuestHeapSource,
13
13
  validateRuntimeSnapshotDescriptors
14
- } from "./chunk-JVE54EBX.js";
14
+ } from "./chunk-ROIZEQTS.js";
15
15
  import {
16
16
  SandboxError,
17
17
  parseExecutableModule,
@@ -10,7 +10,7 @@ import {
10
10
  validateMigrationReconciliation,
11
11
  validateMigrationSemantics,
12
12
  validateSnapshotMigration
13
- } from "./chunk-AN6Z3R6M.js";
13
+ } from "./chunk-MJH5AYEK.js";
14
14
  import {
15
15
  DUMP_FORMAT_VERSION,
16
16
  EXECUTION_SEMANTICS,
@@ -20,17 +20,17 @@ import {
20
20
  serializeSafeJSSnapshot,
21
21
  validateDumpEnvelope,
22
22
  validateSnapshotData
23
- } from "./chunk-JVE54EBX.js";
23
+ } from "./chunk-ROIZEQTS.js";
24
24
  import {
25
25
  parseModule
26
26
  } from "./chunk-EQUBWQJN.js";
27
27
  import {
28
28
  paths_default
29
- } from "./chunk-KMBCLXER.js";
29
+ } from "./chunk-2IYZK337.js";
30
30
  import {
31
31
  hostCwd,
32
32
  hostFs
33
- } from "./chunk-VVOPJZRG.js";
33
+ } from "./chunk-H25SH6HQ.js";
34
34
 
35
35
  // packages/safe-js/src/migration-file.ts
36
36
  import { createFsBridge } from "@poe-platform/safe-fs/core";
@@ -16,8 +16,9 @@ import {
16
16
  tokenize
17
17
  } from "./chunk-EQUBWQJN.js";
18
18
  import {
19
+ createNodeFileSystemAdapterRegistry,
19
20
  hostEnv
20
- } from "./chunk-VVOPJZRG.js";
21
+ } from "./chunk-H25SH6HQ.js";
21
22
 
22
23
  // packages/safe-js/src/lint/rules/AS001.ts
23
24
  function AS001(source, options = {}) {
@@ -11447,6 +11448,50 @@ function toJsonValue(value, seen) {
11447
11448
  return String(value);
11448
11449
  }
11449
11450
 
11451
+ // packages/safe-js/src/modules/fs-config.ts
11452
+ import {
11453
+ createFileSystem,
11454
+ readConfigRecord,
11455
+ validateFileSystemConfig
11456
+ } from "@poe-platform/safe-fs/core";
11457
+ function validateFsConfig(value) {
11458
+ const config = readConfigRecord(value, "fs config", ["adapter", "root", "cwd", "readFileMaxBytes", "hostReadMemoryLimit", "maxSymlinkFollows"]);
11459
+ const paths = {};
11460
+ for (const key of ["root", "cwd"]) {
11461
+ const path = config[key];
11462
+ if (path === void 0) continue;
11463
+ if (typeof path !== "string" || !path.startsWith("/") || path.includes("\0")) {
11464
+ throw new TypeError(`${key} must be an absolute virtual path`);
11465
+ }
11466
+ paths[key] = path;
11467
+ }
11468
+ const limits = {};
11469
+ for (const key of ["readFileMaxBytes", "hostReadMemoryLimit", "maxSymlinkFollows"]) {
11470
+ const value2 = config[key];
11471
+ if (value2 === void 0) continue;
11472
+ if (value2 !== Infinity && (typeof value2 !== "number" || !Number.isSafeInteger(value2) || value2 < 0))
11473
+ throw new TypeError(`${key} must be a non-negative safe integer or Infinity`);
11474
+ Object.assign(limits, { [key]: value2 });
11475
+ }
11476
+ return {
11477
+ adapter: validateFileSystemConfig(config.adapter),
11478
+ ...paths,
11479
+ ...limits
11480
+ };
11481
+ }
11482
+ function parseFsConfig(json) {
11483
+ return validateFsConfig(JSON.parse(json));
11484
+ }
11485
+ async function resolveFsConfig(config, options = {}) {
11486
+ const { adapter: adapterConfig, ...paths } = validateFsConfig(config);
11487
+ const resolution = readConfigRecord(options, "fs resolution option", ["registry"]);
11488
+ const registry = createNodeFileSystemAdapterRegistry(
11489
+ resolution.registry
11490
+ );
11491
+ const adapter = await createFileSystem(adapterConfig, { registry });
11492
+ return { adapter, ...paths };
11493
+ }
11494
+
11450
11495
  export {
11451
11496
  lint,
11452
11497
  EnvAccessError,
@@ -11455,5 +11500,7 @@ export {
11455
11500
  HarnessFailure,
11456
11501
  makeFailModule,
11457
11502
  makeMetricModule,
11458
- makeLogModule
11503
+ makeLogModule,
11504
+ parseFsConfig,
11505
+ resolveFsConfig
11459
11506
  };