poe-code 3.0.273 → 3.0.274
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
|
@@ -15,6 +15,32 @@ export class UnsupportedAgentError extends Error {
|
|
|
15
15
|
function isConfigObject(value) {
|
|
16
16
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
17
17
|
}
|
|
18
|
+
function assertNonEmptyString(value, message) {
|
|
19
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
20
|
+
throw new Error(message);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function assertHttpUrl(value) {
|
|
24
|
+
assertNonEmptyString(value, "MCP HTTP URL must be a valid http or https URL.");
|
|
25
|
+
let parsed;
|
|
26
|
+
try {
|
|
27
|
+
parsed = new URL(value);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
throw new Error("MCP HTTP URL must be a valid http or https URL.");
|
|
31
|
+
}
|
|
32
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
33
|
+
throw new Error("MCP HTTP URL must be a valid http or https URL.");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function validateServerEntry(server) {
|
|
37
|
+
assertNonEmptyString(server.name, "MCP server name must be a non-empty string.");
|
|
38
|
+
if (server.config.transport === "stdio") {
|
|
39
|
+
assertNonEmptyString(server.config.command, "MCP stdio command must be a non-empty string.");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
assertHttpUrl(server.config.url);
|
|
43
|
+
}
|
|
18
44
|
function resolveServerMap(document, configKey) {
|
|
19
45
|
const value = document[configKey];
|
|
20
46
|
if (value === undefined) {
|
|
@@ -32,12 +58,15 @@ export async function configure(agentId, server, options) {
|
|
|
32
58
|
if (!isSupported(agentId)) {
|
|
33
59
|
throw new UnsupportedAgentError(agentId);
|
|
34
60
|
}
|
|
61
|
+
validateServerEntry(server);
|
|
35
62
|
const config = getAgentConfig(agentId);
|
|
36
63
|
const configPath = resolveConfigPath(config, options.platform);
|
|
37
64
|
const shapeTransformer = getShapeTransformer(config.shape);
|
|
38
65
|
const shaped = shapeTransformer(server);
|
|
66
|
+
const enabledServer = { ...server, enabled: true };
|
|
67
|
+
const enabledShaped = shapeTransformer(enabledServer);
|
|
39
68
|
if (shaped === undefined) {
|
|
40
|
-
await unconfigure(agentId,
|
|
69
|
+
await unconfigure(agentId, enabledServer, options);
|
|
41
70
|
return;
|
|
42
71
|
}
|
|
43
72
|
const configDir = getConfigDirectory(configPath);
|
|
@@ -57,10 +86,13 @@ export async function configure(agentId, server, options) {
|
|
|
57
86
|
? servers[server.name]
|
|
58
87
|
: undefined;
|
|
59
88
|
const shapedServer = shaped;
|
|
89
|
+
const enabledShapedServer = enabledShaped;
|
|
60
90
|
if (existingServer !== undefined && isDeepStrictEqual(existingServer, shapedServer)) {
|
|
61
91
|
return { changed: false, content: document };
|
|
62
92
|
}
|
|
63
|
-
if (existingServer !== undefined &&
|
|
93
|
+
if (existingServer !== undefined &&
|
|
94
|
+
(enabledShapedServer === undefined ||
|
|
95
|
+
!isDeepStrictEqual(existingServer, enabledShapedServer))) {
|
|
64
96
|
throw new Error(`MCP server "${server.name}" already exists with different configuration in ${configPath}.`);
|
|
65
97
|
}
|
|
66
98
|
const newServers = {
|
|
@@ -98,7 +130,8 @@ export async function unconfigure(agentId, server, options) {
|
|
|
98
130
|
if (!Object.hasOwn(servers, serverName)) {
|
|
99
131
|
return { changed: false, content: document };
|
|
100
132
|
}
|
|
101
|
-
if (expectedServer !== undefined &&
|
|
133
|
+
if (expectedServer !== undefined &&
|
|
134
|
+
!isDeepStrictEqual(servers[serverName], expectedServer)) {
|
|
102
135
|
return { changed: false, content: document };
|
|
103
136
|
}
|
|
104
137
|
const newServers = { ...servers };
|
|
@@ -16121,6 +16121,31 @@ var UnsupportedAgentError2 = class extends Error {
|
|
|
16121
16121
|
function isConfigObject6(value) {
|
|
16122
16122
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
16123
16123
|
}
|
|
16124
|
+
function assertNonEmptyString(value, message2) {
|
|
16125
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
16126
|
+
throw new Error(message2);
|
|
16127
|
+
}
|
|
16128
|
+
}
|
|
16129
|
+
function assertHttpUrl(value) {
|
|
16130
|
+
assertNonEmptyString(value, "MCP HTTP URL must be a valid http or https URL.");
|
|
16131
|
+
let parsed;
|
|
16132
|
+
try {
|
|
16133
|
+
parsed = new URL(value);
|
|
16134
|
+
} catch {
|
|
16135
|
+
throw new Error("MCP HTTP URL must be a valid http or https URL.");
|
|
16136
|
+
}
|
|
16137
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
16138
|
+
throw new Error("MCP HTTP URL must be a valid http or https URL.");
|
|
16139
|
+
}
|
|
16140
|
+
}
|
|
16141
|
+
function validateServerEntry(server) {
|
|
16142
|
+
assertNonEmptyString(server.name, "MCP server name must be a non-empty string.");
|
|
16143
|
+
if (server.config.transport === "stdio") {
|
|
16144
|
+
assertNonEmptyString(server.config.command, "MCP stdio command must be a non-empty string.");
|
|
16145
|
+
return;
|
|
16146
|
+
}
|
|
16147
|
+
assertHttpUrl(server.config.url);
|
|
16148
|
+
}
|
|
16124
16149
|
function resolveServerMap(document, configKey) {
|
|
16125
16150
|
const value = document[configKey];
|
|
16126
16151
|
if (value === void 0) {
|
|
@@ -16138,12 +16163,15 @@ async function configure2(agentId, server, options) {
|
|
|
16138
16163
|
if (!isSupported(agentId)) {
|
|
16139
16164
|
throw new UnsupportedAgentError2(agentId);
|
|
16140
16165
|
}
|
|
16166
|
+
validateServerEntry(server);
|
|
16141
16167
|
const config2 = getAgentConfig3(agentId);
|
|
16142
16168
|
const configPath = resolveConfigPath2(config2, options.platform);
|
|
16143
16169
|
const shapeTransformer = getShapeTransformer(config2.shape);
|
|
16144
16170
|
const shaped = shapeTransformer(server);
|
|
16171
|
+
const enabledServer = { ...server, enabled: true };
|
|
16172
|
+
const enabledShaped = shapeTransformer(enabledServer);
|
|
16145
16173
|
if (shaped === void 0) {
|
|
16146
|
-
await unconfigure2(agentId,
|
|
16174
|
+
await unconfigure2(agentId, enabledServer, options);
|
|
16147
16175
|
return;
|
|
16148
16176
|
}
|
|
16149
16177
|
const configDir = getConfigDirectory(configPath);
|
|
@@ -16162,10 +16190,11 @@ async function configure2(agentId, server, options) {
|
|
|
16162
16190
|
const servers = resolveServerMap(document, config2.configKey);
|
|
16163
16191
|
const existingServer = Object.hasOwn(servers, server.name) ? servers[server.name] : void 0;
|
|
16164
16192
|
const shapedServer = shaped;
|
|
16193
|
+
const enabledShapedServer = enabledShaped;
|
|
16165
16194
|
if (existingServer !== void 0 && isDeepStrictEqual(existingServer, shapedServer)) {
|
|
16166
16195
|
return { changed: false, content: document };
|
|
16167
16196
|
}
|
|
16168
|
-
if (existingServer !== void 0 &&
|
|
16197
|
+
if (existingServer !== void 0 && (enabledShapedServer === void 0 || !isDeepStrictEqual(existingServer, enabledShapedServer))) {
|
|
16169
16198
|
throw new Error(
|
|
16170
16199
|
`MCP server "${server.name}" already exists with different configuration in ${configPath}.`
|
|
16171
16200
|
);
|