create-loopengine 0.1.74 → 0.1.75
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 +20 -6
- package/template/package.json +1 -1
package/package.json
CHANGED
|
@@ -973,23 +973,37 @@ async function handleStarterTemplates(req: IncomingMessage, res: ServerResponse,
|
|
|
973
973
|
res.writeHead(status, { 'content-type': 'application/json', 'cache-control': 'no-store' }).end(JSON.stringify(body))
|
|
974
974
|
}
|
|
975
975
|
const [id, action] = pathname.split('/').slice(2).map(decodeURIComponent) // after /starter-templates
|
|
976
|
-
const
|
|
976
|
+
const dirOf = (name: string) => join(projectDir(), 'agents', name)
|
|
977
|
+
const exists = (name: string) => Boolean(getEntry(name)) || existsSync(dirOf(name))
|
|
978
|
+
const envValue = (name: string, variable: string) => createAgentEnv(name, dirOf(name)).get(variable)
|
|
977
979
|
try {
|
|
978
980
|
if (!id) {
|
|
979
|
-
if (req.method === 'GET') return json(200, { templates: listTemplates() })
|
|
981
|
+
if (req.method === 'GET') return json(200, { templates: listTemplates(), canInstallAbilities: secretsProtected })
|
|
980
982
|
return json(405, { error: 'method not allowed' })
|
|
981
983
|
}
|
|
982
|
-
if (action === 'preview' && req.method === 'GET') return json(200, previewTemplate(id, { agentExists: exists }))
|
|
984
|
+
if (action === 'preview' && req.method === 'GET') return json(200, previewTemplate(id, { agentExists: exists, envValue }))
|
|
983
985
|
if (action === 'create' && req.method === 'POST') {
|
|
984
986
|
const model = pickAgentModel(interviewAgents())
|
|
985
987
|
const created = await createFromTemplate(id, {
|
|
986
988
|
agentExists: exists,
|
|
987
|
-
|
|
989
|
+
scaffoldAgent: async (name, systemPrompt) => {
|
|
988
990
|
const parsed = parseAgentTemplateOptions({ systemPrompt, ...(model ? { model } : {}) })
|
|
989
991
|
if (!parsed.ok) throw new TemplateError(parsed.error)
|
|
990
|
-
|
|
992
|
+
await scaffoldAgent(projectDir(), name, parsed.value)
|
|
993
|
+
},
|
|
994
|
+
registerAgent: async (name) => {
|
|
995
|
+
const indexPath = join(dirOf(name), 'index.ts')
|
|
991
996
|
registerAgent(await loadAgentModule(indexPath, indexPath))
|
|
992
997
|
},
|
|
998
|
+
// Same rule as the Abilities tab: installing runs third-party code,
|
|
999
|
+
// so only behind the admin login. The agent isn't loaded yet, so
|
|
1000
|
+
// nothing needs a restart.
|
|
1001
|
+
...(secretsProtected ? { installAbility: async (name: string, spec: string) => void (await installAbility(name, spec)) } : {}),
|
|
1002
|
+
envValue,
|
|
1003
|
+
messagingConfigured: (name) => {
|
|
1004
|
+
const entry = getEntry(name)
|
|
1005
|
+
return entry ? describeAgentNotifier(entry.config, defaultWebhook).source !== 'none' : false
|
|
1006
|
+
},
|
|
993
1007
|
})
|
|
994
1008
|
return json(200, created)
|
|
995
1009
|
}
|
|
@@ -1290,7 +1304,7 @@ async function handleSchedulesPost(req: IncomingMessage, res: ServerResponse, ag
|
|
|
1290
1304
|
const task = await createScheduledTask({
|
|
1291
1305
|
agent: agentName,
|
|
1292
1306
|
message: String(body.message ?? ''),
|
|
1293
|
-
schedule: (body.schedule ?? {}) as { run_at?: unknown; every?: unknown },
|
|
1307
|
+
schedule: (body.schedule ?? {}) as { run_at?: unknown; every?: unknown; start_at?: unknown },
|
|
1294
1308
|
task_name: typeof body.task_name === 'string' ? body.task_name : undefined,
|
|
1295
1309
|
notify: body.notify === true,
|
|
1296
1310
|
})
|