poe-code 3.0.342 → 3.0.343
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/package.json
CHANGED
|
@@ -46,11 +46,12 @@ export function resolveConfig(raw, cwd) {
|
|
|
46
46
|
intervalMs: readPositiveInteger(getOwnEntry(polling, "interval_ms"), 30_000, "polling.interval_ms")
|
|
47
47
|
},
|
|
48
48
|
workspace: {
|
|
49
|
-
root: resolvePathValue(readString(getOwnEntry(workspace, "root")
|
|
49
|
+
root: resolvePathValue(readString(getOwnEntry(workspace, "root"), "workspace.root") ??
|
|
50
|
+
path.join(os.tmpdir(), "poe-code-maestro"), cwd)
|
|
50
51
|
},
|
|
51
52
|
agent: {
|
|
52
|
-
service: readString(getOwnEntry(agent, "service")) ?? "codex",
|
|
53
|
-
list: readString(resolveStringValue(getOwnEntry(agent, "list"))),
|
|
53
|
+
service: readString(getOwnEntry(agent, "service"), "agent.service") ?? "codex",
|
|
54
|
+
list: readString(resolveStringValue(getOwnEntry(agent, "list")), "agent.list"),
|
|
54
55
|
maxConcurrentAgents: readPositiveInteger(getOwnEntry(agent, "max_concurrent_agents"), 1, "agent.max_concurrent_agents"),
|
|
55
56
|
maxRetryBackoffMs: readNonNegativeInteger(getOwnEntry(agent, "max_retry_backoff_ms"), 300_000, "agent.max_retry_backoff_ms")
|
|
56
57
|
}
|
|
@@ -154,25 +155,34 @@ function expandHome(value) {
|
|
|
154
155
|
}
|
|
155
156
|
return value;
|
|
156
157
|
}
|
|
157
|
-
function readString(value) {
|
|
158
|
-
if (
|
|
158
|
+
function readString(value, field) {
|
|
159
|
+
if (value === undefined) {
|
|
159
160
|
return undefined;
|
|
160
161
|
}
|
|
162
|
+
if (typeof value !== "string") {
|
|
163
|
+
throw new Error(`Expected "${field}" to be a string.`);
|
|
164
|
+
}
|
|
161
165
|
const trimmed = value.trim();
|
|
162
166
|
return trimmed.length > 0 ? value : undefined;
|
|
163
167
|
}
|
|
164
|
-
function readNumber(value, fallback) {
|
|
165
|
-
|
|
168
|
+
function readNumber(value, fallback, field) {
|
|
169
|
+
if (value === undefined) {
|
|
170
|
+
return fallback;
|
|
171
|
+
}
|
|
172
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
173
|
+
throw new Error(`Expected "${field}" to be a number.`);
|
|
174
|
+
}
|
|
175
|
+
return value;
|
|
166
176
|
}
|
|
167
177
|
function readPositiveInteger(value, fallback, field) {
|
|
168
|
-
const numberValue = readNumber(value, fallback);
|
|
178
|
+
const numberValue = readNumber(value, fallback, field);
|
|
169
179
|
if (!Number.isInteger(numberValue) || numberValue <= 0) {
|
|
170
180
|
throw new Error(`Expected "${field}" to be a positive integer.`);
|
|
171
181
|
}
|
|
172
182
|
return numberValue;
|
|
173
183
|
}
|
|
174
184
|
function readNonNegativeInteger(value, fallback, field) {
|
|
175
|
-
const numberValue = readNumber(value, fallback);
|
|
185
|
+
const numberValue = readNumber(value, fallback, field);
|
|
176
186
|
if (!Number.isInteger(numberValue) || numberValue < 0) {
|
|
177
187
|
throw new Error(`Expected "${field}" to be a non-negative integer.`);
|
|
178
188
|
}
|
|
@@ -8,10 +8,14 @@ export function validateStateDefinitions(value) {
|
|
|
8
8
|
throw new Error("Workflow config requires at least one state.");
|
|
9
9
|
}
|
|
10
10
|
for (const [name, definition] of entries) {
|
|
11
|
+
const stateName = String(name);
|
|
12
|
+
if (stateName.trim().length === 0) {
|
|
13
|
+
throw new Error("State names must not be empty.");
|
|
14
|
+
}
|
|
11
15
|
if (!isRecord(definition)) {
|
|
12
|
-
throw new Error(`State "${
|
|
16
|
+
throw new Error(`State "${stateName}" must be an object.`);
|
|
13
17
|
}
|
|
14
|
-
validateStateDefinition(
|
|
18
|
+
validateStateDefinition(stateName, definition);
|
|
15
19
|
}
|
|
16
20
|
}
|
|
17
21
|
export async function validateDispatch(cfg, taskList) {
|
|
@@ -86,6 +90,9 @@ function validateStateDefinition(name, definition) {
|
|
|
86
90
|
if (prompt !== undefined && typeof prompt !== "string") {
|
|
87
91
|
throw new Error(`State "${name}" prompt must be a string.`);
|
|
88
92
|
}
|
|
93
|
+
if (typeof prompt === "string" && prompt.trim().length === 0) {
|
|
94
|
+
throw new Error(`State "${name}" prompt must not be empty.`);
|
|
95
|
+
}
|
|
89
96
|
if (terminal !== undefined && typeof terminal !== "boolean") {
|
|
90
97
|
throw new Error(`State "${name}" terminal must be a boolean.`);
|
|
91
98
|
}
|
|
@@ -7,5 +7,20 @@ export function resolveWorkflowPath(name, cwd) {
|
|
|
7
7
|
return path.resolve(cwd, filename);
|
|
8
8
|
}
|
|
9
9
|
function isValidWorkflowName(name) {
|
|
10
|
-
|
|
10
|
+
if (name.length === 0 || name.trim() !== name || name === "." || name === "..") {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
for (const character of name) {
|
|
14
|
+
if (!isWorkflowNameCharacter(character)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
function isWorkflowNameCharacter(character) {
|
|
21
|
+
const code = character.charCodeAt(0);
|
|
22
|
+
const isUppercase = code >= 65 && code <= 90;
|
|
23
|
+
const isLowercase = code >= 97 && code <= 122;
|
|
24
|
+
const isDigit = code >= 48 && code <= 57;
|
|
25
|
+
return isUppercase || isLowercase || isDigit || character === "_" || character === "-";
|
|
11
26
|
}
|