feat(hololake): ship language platform 0.7.0
This commit is contained in:
parent
a360982a9b
commit
5105ec5e32
47 changed files with 4566 additions and 398 deletions
|
|
@ -9,11 +9,11 @@ import express from 'express';
|
|||
import cors from 'cors';
|
||||
import { GitEngine } from './git-engine.js';
|
||||
import { PersonaAgent, createDefaultPersona } from './persona-agent.js';
|
||||
import { projectHumanKnowledgeTree } from './language-protocol-kernel.js';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
// __dirname 兼容 CJS 和 ESM
|
||||
const _dirname = typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));
|
||||
const _dirname = typeof __dirname !== 'undefined' ? __dirname : process.cwd();
|
||||
|
||||
// ─── 配置 ───
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ app.get('/api/health', (_req, res) => {
|
|||
app.get('/api/tree', async (_req, res) => {
|
||||
try {
|
||||
const tree = await engine.getTree();
|
||||
res.json({ ok: true, tree });
|
||||
res.json({ ok: true, tree: projectHumanKnowledgeTree(tree) });
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ ok: false, error: err.message });
|
||||
}
|
||||
|
|
@ -205,6 +205,14 @@ app.put('/api/forgejo/remote', async (req, res) => {
|
|||
}
|
||||
});
|
||||
|
||||
app.delete('/api/forgejo/remote', async (_req, res) => {
|
||||
try {
|
||||
res.json({ ok: true, status: await engine.removeRemote() });
|
||||
} catch (err: any) {
|
||||
res.status(400).json({ ok: false, error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/forgejo/fetch', async (_req, res) => {
|
||||
try {
|
||||
res.json({ ok: true, status: await engine.fetchRemote() });
|
||||
|
|
@ -280,12 +288,35 @@ app.post('/api/agent/chat', async (req, res) => {
|
|||
ok: true,
|
||||
reply,
|
||||
conversationLength: agent.getConversation().length,
|
||||
pendingActions: agent.getPendingActions(),
|
||||
});
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ ok: false, error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/api/agent/actions', (_req, res) => {
|
||||
res.json({ ok: true, actions: getAgent().getPendingActions() });
|
||||
});
|
||||
|
||||
app.post('/api/agent/actions/:actionId/confirm', async (req, res) => {
|
||||
try {
|
||||
const result = await getAgent().confirmAction(req.params.actionId);
|
||||
res.json({ ok: true, result, actions: getAgent().getPendingActions() });
|
||||
} catch (err: any) {
|
||||
res.status(409).json({ ok: false, error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/agent/actions/:actionId/reject', (req, res) => {
|
||||
try {
|
||||
getAgent().rejectAction(req.params.actionId);
|
||||
res.json({ ok: true, actions: getAgent().getPendingActions() });
|
||||
} catch (err: any) {
|
||||
res.status(409).json({ ok: false, error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Agent 对话历史
|
||||
app.get('/api/agent/conversation', (_req, res) => {
|
||||
const agent = getAgent();
|
||||
|
|
|
|||
Loading…
Reference in a new issue