create-loopengine 0.1.46 → 0.1.47
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 +1 -1
- package/template/adapters/http.ts +30 -0
package/package.json
CHANGED
|
@@ -93,6 +93,7 @@ import {
|
|
|
93
93
|
SkillNotFoundError,
|
|
94
94
|
listDeclaredEnvVars,
|
|
95
95
|
setEnvVar,
|
|
96
|
+
unsetEnvVar,
|
|
96
97
|
EnvVarNameError,
|
|
97
98
|
readActauthConfig,
|
|
98
99
|
addActauthRule,
|
|
@@ -1067,6 +1068,31 @@ async function handleEnvPut(req: IncomingMessage, res: ServerResponse, agentName
|
|
|
1067
1068
|
res.writeHead(200, { 'content-type': 'application/json' }).end(JSON.stringify({ ok: true }))
|
|
1068
1069
|
}
|
|
1069
1070
|
|
|
1071
|
+
// Same auth requirement as handleEnvPut above and the same reasoning —
|
|
1072
|
+
// removing a secret from .env is still a secrets-management action,
|
|
1073
|
+
// not just config, so this refuses outright rather than proceeding
|
|
1074
|
+
// open when LOOPENGINE_ADMIN_AUTH isn't configured at all.
|
|
1075
|
+
async function handleEnvDelete(res: ServerResponse, agentName: string, varName: string): Promise<void> {
|
|
1076
|
+
if (!adminAuth) {
|
|
1077
|
+
res.writeHead(403, { 'content-type': 'application/json' }).end(
|
|
1078
|
+
JSON.stringify({ error: 'Refusing to unset an env var without LOOPENGINE_ADMIN_AUTH configured — set it before managing secrets through this route.' }),
|
|
1079
|
+
)
|
|
1080
|
+
return
|
|
1081
|
+
}
|
|
1082
|
+
if (!getEntry(agentName)) {
|
|
1083
|
+
res.writeHead(404, { 'content-type': 'application/json' }).end(JSON.stringify({ error: `unknown agent '${agentName}'` }))
|
|
1084
|
+
return
|
|
1085
|
+
}
|
|
1086
|
+
try {
|
|
1087
|
+
unsetEnvVar(varName)
|
|
1088
|
+
} catch (err) {
|
|
1089
|
+
const status = err instanceof EnvVarNameError ? 400 : 500
|
|
1090
|
+
res.writeHead(status, { 'content-type': 'application/json' }).end(JSON.stringify({ error: err instanceof Error ? err.message : String(err) }))
|
|
1091
|
+
return
|
|
1092
|
+
}
|
|
1093
|
+
res.writeHead(200, { 'content-type': 'application/json' }).end(JSON.stringify({ ok: true }))
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1070
1096
|
// A cheap, good-enough presence check — existsSync(node_modules/<dep>)
|
|
1071
1097
|
// — rather than an actual module resolution (require.resolve/
|
|
1072
1098
|
// import.meta.resolve): this only ever decides whether to show an
|
|
@@ -2570,6 +2596,10 @@ const server = createServer(async (req, res) => {
|
|
|
2570
2596
|
await handleEnvPut(req, res, decodeURIComponent(envVarMatch[1]), decodeURIComponent(envVarMatch[2]))
|
|
2571
2597
|
return
|
|
2572
2598
|
}
|
|
2599
|
+
if (envVarMatch && req.method === 'DELETE') {
|
|
2600
|
+
await handleEnvDelete(res, decodeURIComponent(envVarMatch[1]), decodeURIComponent(envVarMatch[2]))
|
|
2601
|
+
return
|
|
2602
|
+
}
|
|
2573
2603
|
|
|
2574
2604
|
// Backs the Admin UI's Abilities tab — see handleAbilitiesGet/
|
|
2575
2605
|
// handleAbilitiesSearchGet/handleAbilityInstallPost's own doc
|