poe-code 9.0.0 → 10.0.0
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/cli/commands/harness.js +32 -3
- package/dist/cli/commands/harness.js.map +1 -1
- package/dist/index.js +117 -5
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/chunks/{chunk-GQBEEFVQ.js → chunk-E6LJNTDX.js} +2 -2
- package/packages/safejs/dist/chunks/{chunk-GQBEEFVQ.js.map → chunk-E6LJNTDX.js.map} +2 -2
- package/packages/safejs/dist/chunks/{chunk-55ZK3CR7.js → chunk-SDKCGJW4.js} +89 -2
- package/packages/safejs/dist/chunks/chunk-SDKCGJW4.js.map +7 -0
- package/packages/safejs/dist/cli.d.ts +2 -0
- package/packages/safejs/dist/cli.js +25 -2
- package/packages/safejs/dist/cli.js.map +2 -2
- package/packages/safejs/dist/core.js +1 -1
- package/packages/safejs/dist/index.d.ts +2 -1
- package/packages/safejs/dist/index.js +16 -43
- package/packages/safejs/dist/index.js.map +4 -4
- package/packages/safejs/dist/interp/host-bridge.js +3 -2
- package/packages/safejs/dist/modules/env.d.ts +12 -1
- package/packages/safejs/dist/modules/env.js +74 -18
- package/packages/safejs/dist/chunks/chunk-55ZK3CR7.js.map +0 -7
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
safeEndSpan,
|
|
15
15
|
safeRecordException,
|
|
16
16
|
safeStartSpan
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-E6LJNTDX.js";
|
|
18
18
|
|
|
19
19
|
// packages/safejs/src/error/format.ts
|
|
20
20
|
var DEFAULT_MAX_MESSAGE_LENGTH = 1e4;
|
|
@@ -2608,6 +2608,90 @@ function isRecord2(value) {
|
|
|
2608
2608
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2609
2609
|
}
|
|
2610
2610
|
|
|
2611
|
+
// packages/safejs/src/modules/env.ts
|
|
2612
|
+
var EnvAccessError = class extends Error {
|
|
2613
|
+
code = "ENV_ACCESS_DENIED";
|
|
2614
|
+
variable;
|
|
2615
|
+
constructor(variable) {
|
|
2616
|
+
super(`Environment access denied for ${JSON.stringify(variable)}.`);
|
|
2617
|
+
this.name = "EnvAccessError";
|
|
2618
|
+
this.variable = variable;
|
|
2619
|
+
hostErrorData.set(this, { code: this.code, variable });
|
|
2620
|
+
}
|
|
2621
|
+
};
|
|
2622
|
+
function makeEnvModule(input) {
|
|
2623
|
+
const options = normalizeEnvOptions(Array.isArray(input) ? { allow: input } : input);
|
|
2624
|
+
const allowedNames = new Set(options.allow);
|
|
2625
|
+
const values = options.values ?? process.env;
|
|
2626
|
+
return {
|
|
2627
|
+
get(name) {
|
|
2628
|
+
const variable = readEnvName(name, "Environment variable name");
|
|
2629
|
+
if (!allowedNames.has(variable)) throw new EnvAccessError(variable);
|
|
2630
|
+
return readEnvValue(values, variable);
|
|
2631
|
+
}
|
|
2632
|
+
};
|
|
2633
|
+
}
|
|
2634
|
+
function parseEnvConfig(json) {
|
|
2635
|
+
return normalizeEnvOptions(JSON.parse(json));
|
|
2636
|
+
}
|
|
2637
|
+
function normalizeEnvOptions(input) {
|
|
2638
|
+
if (input === null || typeof input !== "object" || Array.isArray(input)) {
|
|
2639
|
+
throw new TypeError("Environment options must be an object.");
|
|
2640
|
+
}
|
|
2641
|
+
const fields = Object.getOwnPropertyDescriptors(input);
|
|
2642
|
+
for (const key2 of Reflect.ownKeys(fields)) {
|
|
2643
|
+
if (key2 !== "allow" && key2 !== "values") {
|
|
2644
|
+
throw new TypeError("Unknown environment option.");
|
|
2645
|
+
}
|
|
2646
|
+
if (!("value" in fields[key2])) {
|
|
2647
|
+
throw new TypeError("Environment options must not contain accessors.");
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
const inputAllow = Object.getOwnPropertyDescriptor(input, "allow")?.value;
|
|
2651
|
+
if (!Array.isArray(inputAllow)) {
|
|
2652
|
+
throw new TypeError("Environment allow list must be an array of non-empty strings.");
|
|
2653
|
+
}
|
|
2654
|
+
const allow = [];
|
|
2655
|
+
for (let index = 0; index < inputAllow.length; index += 1) {
|
|
2656
|
+
const descriptor = Object.getOwnPropertyDescriptor(inputAllow, index);
|
|
2657
|
+
if (descriptor === void 0 || !("value" in descriptor)) {
|
|
2658
|
+
throw new TypeError("Environment allow list must contain only own data entries.");
|
|
2659
|
+
}
|
|
2660
|
+
allow.push(readEnvName(descriptor.value, `Environment allow list[${index}]`));
|
|
2661
|
+
}
|
|
2662
|
+
const inputValues = Object.getOwnPropertyDescriptor(input, "values")?.value;
|
|
2663
|
+
if (inputValues === void 0) return { allow };
|
|
2664
|
+
if (inputValues === null || typeof inputValues !== "object" || Array.isArray(inputValues)) {
|
|
2665
|
+
throw new TypeError("Environment values must be an object.");
|
|
2666
|
+
}
|
|
2667
|
+
return {
|
|
2668
|
+
allow,
|
|
2669
|
+
values: Object.fromEntries(allow.map((name) => [name, readEnvValue(inputValues, name)]))
|
|
2670
|
+
};
|
|
2671
|
+
}
|
|
2672
|
+
function readEnvValue(values, name) {
|
|
2673
|
+
const descriptor = Object.getOwnPropertyDescriptor(values, name);
|
|
2674
|
+
if (descriptor === void 0) return void 0;
|
|
2675
|
+
if (!("value" in descriptor)) {
|
|
2676
|
+
throw new TypeError(`Environment value for ${JSON.stringify(name)} must not be an accessor.`);
|
|
2677
|
+
}
|
|
2678
|
+
if (descriptor.value !== void 0 && typeof descriptor.value !== "string") {
|
|
2679
|
+
throw new TypeError(
|
|
2680
|
+
`Environment value for ${JSON.stringify(name)} must be a string or undefined.`
|
|
2681
|
+
);
|
|
2682
|
+
}
|
|
2683
|
+
return descriptor.value;
|
|
2684
|
+
}
|
|
2685
|
+
function readEnvName(value, label) {
|
|
2686
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
2687
|
+
throw new TypeError(`${label} must be a non-empty string.`);
|
|
2688
|
+
}
|
|
2689
|
+
if (value.includes("\0") || value.includes("=")) {
|
|
2690
|
+
throw new TypeError(`${label} must not contain NUL or equals signs.`);
|
|
2691
|
+
}
|
|
2692
|
+
return value;
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2611
2695
|
// packages/safejs/src/modules/fail.ts
|
|
2612
2696
|
var HarnessFailure = class extends Error {
|
|
2613
2697
|
constructor(message) {
|
|
@@ -7785,6 +7869,9 @@ export {
|
|
|
7785
7869
|
createSpawnUsageAccumulator,
|
|
7786
7870
|
runWithSpawnUsageAccumulator,
|
|
7787
7871
|
makeAgentModule,
|
|
7872
|
+
EnvAccessError,
|
|
7873
|
+
makeEnvModule,
|
|
7874
|
+
parseEnvConfig,
|
|
7788
7875
|
makeFailModule,
|
|
7789
7876
|
resolveCanonicalPath,
|
|
7790
7877
|
containsPath,
|
|
@@ -7799,4 +7886,4 @@ export {
|
|
|
7799
7886
|
parseMcpConfig,
|
|
7800
7887
|
makeMcpModule
|
|
7801
7888
|
};
|
|
7802
|
-
//# sourceMappingURL=chunk-
|
|
7889
|
+
//# sourceMappingURL=chunk-SDKCGJW4.js.map
|