poe-code 11.0.6 → 11.0.8
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 +7 -4
- package/dist/index.js.map +2 -2
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/chunks/{chunk-NP42RTIU.js → chunk-776EUEUM.js} +15 -8
- package/packages/safejs/dist/chunks/chunk-776EUEUM.js.map +7 -0
- package/packages/safejs/dist/chunks/{chunk-OPNWSDXC.js → chunk-TVZKHJOO.js} +7 -4
- package/packages/safejs/dist/chunks/{chunk-OPNWSDXC.js.map → chunk-TVZKHJOO.js.map} +2 -2
- package/packages/safejs/dist/cli.js +9 -12
- package/packages/safejs/dist/cli.js.map +2 -2
- package/packages/safejs/dist/core.js +1 -1
- package/packages/safejs/dist/example-runner.js +6 -6
- package/packages/safejs/dist/index.js +8 -10
- package/packages/safejs/dist/index.js.map +2 -2
- package/packages/safejs/dist/interp/globals/object-array.js +3 -3
- package/packages/safejs/dist/loader/extract-block.d.ts +1 -0
- package/packages/safejs/dist/loader/extract-block.js +9 -6
- package/packages/safejs/dist/runner/run-harness.js +6 -9
- package/packages/safejs/dist/chunks/chunk-NP42RTIU.js.map +0 -7
|
@@ -10,12 +10,12 @@ export function createObjectArrayGlobals(options) {
|
|
|
10
10
|
}),
|
|
11
11
|
values: createSandboxClosure({
|
|
12
12
|
sandbox: true,
|
|
13
|
-
call: ([value]) =>
|
|
13
|
+
call: ([value]) => allocateProducedSandboxValue(getOwnEnumerableValues(value), options.budget),
|
|
14
14
|
name: "values"
|
|
15
15
|
}),
|
|
16
16
|
entries: createSandboxClosure({
|
|
17
17
|
sandbox: true,
|
|
18
|
-
call: ([value]) =>
|
|
18
|
+
call: ([value]) => allocateProducedSandboxValue(getOwnEnumerableEntries(value), options.budget),
|
|
19
19
|
name: "entries"
|
|
20
20
|
}),
|
|
21
21
|
hasOwn: createSandboxClosure({
|
|
@@ -30,7 +30,7 @@ export function createObjectArrayGlobals(options) {
|
|
|
30
30
|
}),
|
|
31
31
|
fromEntries: createSandboxClosure({
|
|
32
32
|
sandbox: true,
|
|
33
|
-
call: ([value]) =>
|
|
33
|
+
call: ([value]) => allocateProducedSandboxValue(Object.setPrototypeOf(Reflect.apply(Object.fromEntries, Object, [value]), null), options.budget),
|
|
34
34
|
name: "fromEntries"
|
|
35
35
|
}),
|
|
36
36
|
freeze: createSandboxClosure({
|
|
@@ -6,4 +6,5 @@ export interface ExtractBlockResult {
|
|
|
6
6
|
ranges: readonly (readonly [number, number])[];
|
|
7
7
|
}
|
|
8
8
|
export declare function extractBlock(markdown: string, startLine?: number): ExtractBlockResult;
|
|
9
|
+
export declare function maskSource(source: string): string;
|
|
9
10
|
export declare function countLineBreaks(markdown: string, start?: number, end?: number): number;
|
|
@@ -39,12 +39,7 @@ export function extractBlock(markdown, startLine = 1) {
|
|
|
39
39
|
const parts = [];
|
|
40
40
|
let cursor = first.start;
|
|
41
41
|
for (const block of blocks) {
|
|
42
|
-
|
|
43
|
-
for (let offset = cursor; offset < block.start; offset++) {
|
|
44
|
-
const character = markdown[offset];
|
|
45
|
-
gap += character === "\n" || character === "\r" ? character : " ";
|
|
46
|
-
}
|
|
47
|
-
parts.push(gap, markdown.slice(block.start, block.end));
|
|
42
|
+
parts.push(maskSource(markdown.slice(cursor, block.start)), markdown.slice(block.start, block.end));
|
|
48
43
|
cursor = block.end;
|
|
49
44
|
}
|
|
50
45
|
return {
|
|
@@ -55,6 +50,14 @@ export function extractBlock(markdown, startLine = 1) {
|
|
|
55
50
|
ranges: blocks.map((block) => [block.start, block.end])
|
|
56
51
|
};
|
|
57
52
|
}
|
|
53
|
+
export function maskSource(source) {
|
|
54
|
+
let masked = "";
|
|
55
|
+
for (let offset = 0; offset < source.length; offset++) {
|
|
56
|
+
const character = source[offset];
|
|
57
|
+
masked += character === "\n" || character === "\r" ? character : " ";
|
|
58
|
+
}
|
|
59
|
+
return masked;
|
|
60
|
+
}
|
|
58
61
|
function readOpeningFence(line) {
|
|
59
62
|
const fenceStart = readFenceStart(line);
|
|
60
63
|
if (fenceStart === undefined) {
|
|
@@ -3,7 +3,7 @@ import { extname } from "node:path";
|
|
|
3
3
|
import { supportsSpawnMode } from "@poe-code/agent-spawn/configs";
|
|
4
4
|
import { SPAWN_MODES } from "@poe-code/agent-spawn/types";
|
|
5
5
|
import { hasOwnErrorCode } from "../error-codes.js";
|
|
6
|
-
import { countLineBreaks, extractBlock } from "../loader/extract-block.js";
|
|
6
|
+
import { countLineBreaks, extractBlock, maskSource } from "../loader/extract-block.js";
|
|
7
7
|
import { splitFrontmatter } from "../loader/frontmatter.js";
|
|
8
8
|
import { lint } from "../lint.js";
|
|
9
9
|
import { createLintModulesFromRuntimeRegistry } from "../lint/runtime-modules.js";
|
|
@@ -52,7 +52,7 @@ export class LintError extends Error {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
export async function runHarness(filepath, options) {
|
|
55
|
-
const rawSource =
|
|
55
|
+
const rawSource = await readHarnessFile(filepath);
|
|
56
56
|
const { executableSource, frontmatter, isRawScript } = loadExecutableSource(filepath, rawSource);
|
|
57
57
|
assertFrontmatterAgentModes(frontmatter);
|
|
58
58
|
const meta = createHarnessMeta(filepath, frontmatter);
|
|
@@ -137,11 +137,12 @@ async function readHarnessFile(filepath) {
|
|
|
137
137
|
}
|
|
138
138
|
function loadExecutableSource(filepath, source) {
|
|
139
139
|
if (isRawScriptPath(filepath)) {
|
|
140
|
-
|
|
140
|
+
const executableSource = stripByteOrderMark(source);
|
|
141
|
+
if (executableSource.length === 0) {
|
|
141
142
|
throw new Error(`No code block found in empty harness file: ${filepath}`);
|
|
142
143
|
}
|
|
143
144
|
return {
|
|
144
|
-
executableSource
|
|
145
|
+
executableSource,
|
|
145
146
|
frontmatter: {},
|
|
146
147
|
isRawScript: true
|
|
147
148
|
};
|
|
@@ -152,9 +153,8 @@ function loadExecutableSource(filepath, source) {
|
|
|
152
153
|
}
|
|
153
154
|
const bodyStartOffset = source.length - body.length;
|
|
154
155
|
const { source: executableBlock, startOffset } = extractBlock(body, countLineBreaks(source, 0, bodyStartOffset) + 1);
|
|
155
|
-
const absoluteLineOffset = countLineBreaks(source, 0, bodyStartOffset + startOffset);
|
|
156
156
|
return {
|
|
157
|
-
executableSource:
|
|
157
|
+
executableSource: maskSource(source.slice(0, bodyStartOffset + startOffset)) + stripHashbang(executableBlock),
|
|
158
158
|
frontmatter,
|
|
159
159
|
isRawScript: false
|
|
160
160
|
};
|
|
@@ -238,9 +238,6 @@ function stripHashbang(source) {
|
|
|
238
238
|
end += 1;
|
|
239
239
|
return `${" ".repeat(end)}${source.slice(end)}`;
|
|
240
240
|
}
|
|
241
|
-
function createLineOffsetSource(source, lineOffset) {
|
|
242
|
-
return `${"\n".repeat(Math.max(lineOffset, 0))}${source}`;
|
|
243
|
-
}
|
|
244
241
|
function formatLintErrorMessage(diagnostics) {
|
|
245
242
|
if (diagnostics.length === 0) {
|
|
246
243
|
return "Script lint failed.";
|