create-loopengine 0.1.26 → 0.1.30
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 +1 -85
- package/template/package.json +2 -3
package/package.json
CHANGED
|
@@ -88,10 +88,6 @@ import {
|
|
|
88
88
|
listDeclaredEnvVars,
|
|
89
89
|
setEnvVar,
|
|
90
90
|
EnvVarNameError,
|
|
91
|
-
listSkillgardenCatalog,
|
|
92
|
-
readSkillgardenCatalogEntry,
|
|
93
|
-
addSkillgardenSkillToAgent,
|
|
94
|
-
SkillgardenUnavailableError,
|
|
95
91
|
readActauthConfig,
|
|
96
92
|
addActauthRule,
|
|
97
93
|
updateActauthRule,
|
|
@@ -122,7 +118,7 @@ import {
|
|
|
122
118
|
type PendingQuestion,
|
|
123
119
|
WebhookNotifier,
|
|
124
120
|
} from 'loopengine'
|
|
125
|
-
import { SkillGarden } from '
|
|
121
|
+
import { SkillGarden } from 'loopengine'
|
|
126
122
|
import type { Decision, PendingApproval } from 'actauth'
|
|
127
123
|
import type { LoopEvent } from 'loopengine'
|
|
128
124
|
|
|
@@ -971,69 +967,6 @@ async function handleEnvPut(req: IncomingMessage, res: ServerResponse, agentName
|
|
|
971
967
|
res.writeHead(200, { 'content-type': 'application/json' }).end(JSON.stringify({ ok: true }))
|
|
972
968
|
}
|
|
973
969
|
|
|
974
|
-
// Backs the Skills tab's "Browse skillgarden catalog" section — a
|
|
975
|
-
// read-only, agent-independent list of everything skillgarden ships in
|
|
976
|
-
// its own bundled registry (see loopengine's own web/skillgarden-admin.ts).
|
|
977
|
-
// Not wrapped in a per-agent :name segment since the catalog itself
|
|
978
|
-
// isn't scoped to any one agent; only the POST below (actually
|
|
979
|
-
// installing an entry) is.
|
|
980
|
-
function handleSkillgardenCatalogGet(res: ServerResponse): void {
|
|
981
|
-
try {
|
|
982
|
-
// Computed before writeHead, not inlined into .end()'s own argument —
|
|
983
|
-
// res.writeHead(200, ...) commits the status line the instant it's
|
|
984
|
-
// called, so a throw evaluated *after* it (as it would be if it were
|
|
985
|
-
// inlined as .end()'s argument) leaves headers already sent as 200
|
|
986
|
-
// with no body, and the catch block's own writeHead(status, ...)
|
|
987
|
-
// then fails outright (ERR_HTTP_HEADERS_SENT) instead of ever
|
|
988
|
-
// reaching the client.
|
|
989
|
-
const catalog = listSkillgardenCatalog()
|
|
990
|
-
res.writeHead(200, { 'content-type': 'application/json' }).end(JSON.stringify(catalog))
|
|
991
|
-
} catch (err) {
|
|
992
|
-
const status = err instanceof SkillgardenUnavailableError ? 503 : 500
|
|
993
|
-
res.writeHead(status, { 'content-type': 'application/json' }).end(JSON.stringify({ error: err instanceof Error ? err.message : String(err) }))
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
// Full SKILL.md body for the catalog's own "View" toggle — kept as a
|
|
998
|
-
// separate route from the list above (rather than inlining every body
|
|
999
|
-
// into it) for the same reason the Skills tab's own edit form fetches a
|
|
1000
|
-
// skill's body lazily instead of shipping it in the initial list.
|
|
1001
|
-
function handleSkillgardenCatalogEntryGet(res: ServerResponse, category: string, id: string): void {
|
|
1002
|
-
try {
|
|
1003
|
-
// See handleSkillgardenCatalogGet's own comment for why this is
|
|
1004
|
-
// computed before writeHead rather than inlined into .end()'s
|
|
1005
|
-
// argument.
|
|
1006
|
-
const entry = readSkillgardenCatalogEntry(category, id)
|
|
1007
|
-
res.writeHead(200, { 'content-type': 'application/json' }).end(JSON.stringify(entry))
|
|
1008
|
-
} catch (err) {
|
|
1009
|
-
const status = err instanceof SkillgardenUnavailableError ? 503 : 404
|
|
1010
|
-
res.writeHead(status, { 'content-type': 'application/json' }).end(JSON.stringify({ error: err instanceof Error ? err.message : String(err) }))
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
// Installs a catalog entry into agents/:name/skills/ — delegates to
|
|
1015
|
-
// skillgarden's own addSkill (see skillgarden-admin.ts), which throws
|
|
1016
|
-
// plain Errors (no typed classes) for "unknown skill"/"already exists",
|
|
1017
|
-
// so those two are told apart by message shape rather than instanceof,
|
|
1018
|
-
// same as any other dependency that doesn't export typed errors for its
|
|
1019
|
-
// own failure modes.
|
|
1020
|
-
async function handleSkillgardenCatalogAdd(req: IncomingMessage, res: ServerResponse, agentName: string, category: string, id: string): Promise<void> {
|
|
1021
|
-
if (!getEntry(agentName)) {
|
|
1022
|
-
res.writeHead(404, { 'content-type': 'application/json' }).end(JSON.stringify({ error: `unknown agent '${agentName}'` }))
|
|
1023
|
-
return
|
|
1024
|
-
}
|
|
1025
|
-
const body = await readJsonBody(req)
|
|
1026
|
-
const force = body.force === true
|
|
1027
|
-
try {
|
|
1028
|
-
const result = addSkillgardenSkillToAgent(agentName, category, id, force)
|
|
1029
|
-
res.writeHead(200, { 'content-type': 'application/json' }).end(JSON.stringify({ ok: true, id: result.id }))
|
|
1030
|
-
} catch (err) {
|
|
1031
|
-
const message = err instanceof Error ? err.message : String(err)
|
|
1032
|
-
const status = err instanceof SkillgardenUnavailableError ? 503 : /already exists/.test(message) ? 409 : /^Unknown skill/.test(message) ? 404 : 500
|
|
1033
|
-
res.writeHead(status, { 'content-type': 'application/json' }).end(JSON.stringify({ error: message }))
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
970
|
// Backs the Actauth tab's rule editor — parses a rule body shared by both
|
|
1038
971
|
// the add (POST) and update (PUT, minus `name`) routes below.
|
|
1039
972
|
function parseActauthRuleBody(body: Record<string, unknown>, requireName: boolean): { ok: true; value: { name: string; scope: string; tool: string; decision: Decision } } | { ok: false; error: string } {
|
|
@@ -2183,23 +2116,6 @@ const server = createServer(async (req, res) => {
|
|
|
2183
2116
|
return
|
|
2184
2117
|
}
|
|
2185
2118
|
|
|
2186
|
-
// Backs the Skills tab's "Browse skillgarden catalog" section — see
|
|
2187
|
-
// the three handlers above it.
|
|
2188
|
-
if (req.method === 'GET' && pathname === '/skillgarden-catalog') {
|
|
2189
|
-
handleSkillgardenCatalogGet(res)
|
|
2190
|
-
return
|
|
2191
|
-
}
|
|
2192
|
-
const skillgardenEntryMatch = req.method === 'GET' && pathname.match(/^\/skillgarden-catalog\/([^/]+)\/([^/]+)$/)
|
|
2193
|
-
if (skillgardenEntryMatch) {
|
|
2194
|
-
handleSkillgardenCatalogEntryGet(res, decodeURIComponent(skillgardenEntryMatch[1]), decodeURIComponent(skillgardenEntryMatch[2]))
|
|
2195
|
-
return
|
|
2196
|
-
}
|
|
2197
|
-
const skillgardenAddMatch = req.method === 'POST' && pathname.match(/^\/agents\/([^/]+)\/skillgarden-catalog\/([^/]+)\/([^/]+)$/)
|
|
2198
|
-
if (skillgardenAddMatch) {
|
|
2199
|
-
await handleSkillgardenCatalogAdd(req, res, decodeURIComponent(skillgardenAddMatch[1]), decodeURIComponent(skillgardenAddMatch[2]), decodeURIComponent(skillgardenAddMatch[3]))
|
|
2200
|
-
return
|
|
2201
|
-
}
|
|
2202
|
-
|
|
2203
2119
|
// Backs the Actauth tab's rule editor and default_decision control.
|
|
2204
2120
|
// The default-decision route is checked before the :ruleName routes
|
|
2205
2121
|
// right below since 'default-decision' would otherwise itself match
|
package/template/package.json
CHANGED