@mebular/mcp 0.2.4 → 0.3.0
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/bin/mebular.mjs +401 -1
- package/package.json +4 -3
- package/src/admin.mjs +60 -44
- package/src/clients.mjs +699 -33
- package/src/config-schema.mjs +7 -0
- package/src/detail-maintenance.mjs +134 -0
- package/src/fleet-events.mjs +1 -1
- package/src/memory-capability.mjs +4734 -0
- package/src/memory-runtime-config.mjs +86 -0
- package/src/memory-runtime-supervisor.mjs +1844 -0
- package/src/memory-runtime-token.mjs +193 -0
- package/src/serve.mjs +817 -6
- package/src/server.mjs +19 -0
- package/src/task-tools.mjs +10 -1
- package/src/version.mjs +1 -1
package/src/server.mjs
CHANGED
|
@@ -376,6 +376,7 @@ export async function startServeServer(options = {}) {
|
|
|
376
376
|
runtime: current?.runtime ?? null,
|
|
377
377
|
// D2:写端点默认开启(仍需 memory.admin scope + CSRF 双提交);`MEBULAR_CONSOLE_WRITES=0` 可降级为 D1 只读
|
|
378
378
|
writesEnabled: options.writesEnabled ?? process.env.MEBULAR_CONSOLE_WRITES !== '0',
|
|
379
|
+
manageMemoryRuntime: true,
|
|
379
380
|
provision: provisionStart,
|
|
380
381
|
initializeRuntime: async ({ action, result, server }) => {
|
|
381
382
|
const next = await startRuntime({ action, result, serverContext: server, hot: true });
|
|
@@ -404,6 +405,24 @@ export async function startServeServer(options = {}) {
|
|
|
404
405
|
}
|
|
405
406
|
})
|
|
406
407
|
.catch((error) => console.error(`SKILL_ENSURE_FAILED ${error?.code ?? 'ERROR'}`));
|
|
408
|
+
// 自动自愈(主路径):实际端口已确定 → 只把已存在的本机 loopback Mebular HTTP 条目
|
|
409
|
+
// 幂等更新到当前 /mcp;不 force Skill、不创建新客户端配置、不改远端自定义 URL。
|
|
410
|
+
void import('./clients.mjs')
|
|
411
|
+
.then(({ reconcileClientEndpoints, assistantUserHome, daemonMcpUrl }) => {
|
|
412
|
+
const reconcileHost = httpServer.host === '0.0.0.0' || httpServer.host === '::' ? '127.0.0.1' : httpServer.host;
|
|
413
|
+
return reconcileClientEndpoints({
|
|
414
|
+
home,
|
|
415
|
+
userHome: assistantUserHome(),
|
|
416
|
+
cwd: process.cwd(),
|
|
417
|
+
mcpUrl: daemonMcpUrl({ host: `${reconcileHost}:${httpServer.port}`, encrypted: serverTls }),
|
|
418
|
+
});
|
|
419
|
+
})
|
|
420
|
+
.then((result) => {
|
|
421
|
+
if (result?.summary?.failed > 0) {
|
|
422
|
+
console.error(`CLIENT_ENDPOINT_RECONCILE_PARTIAL ${result.summary.failed} client(s)`);
|
|
423
|
+
}
|
|
424
|
+
})
|
|
425
|
+
.catch((error) => console.error(`CLIENT_ENDPOINT_RECONCILE_FAILED ${error?.code ?? 'ERROR'}`));
|
|
407
426
|
}
|
|
408
427
|
|
|
409
428
|
const shutdown = async () => {
|
package/src/task-tools.mjs
CHANGED
|
@@ -17,11 +17,17 @@ export const TASK_TOOL_SCOPES = Object.fromEntries(
|
|
|
17
17
|
TASK_TOOLS.map((tool) => [tool.name, tool.scope]),
|
|
18
18
|
);
|
|
19
19
|
|
|
20
|
+
/** 任务工具在 MCP 无稳定 Agent 身份时的显式默认 actor(与 fleet CLI 缺省一致)。 */
|
|
21
|
+
export const DEFAULT_TASK_AGENT = 'board';
|
|
22
|
+
|
|
20
23
|
/**
|
|
21
24
|
* 任务工具规格:与记忆面同形(name/title/description/inputSchema/handler(service,args,context))。
|
|
22
25
|
*
|
|
23
26
|
* `context.home`:工具上下文目录(默认 homeDir())。
|
|
24
27
|
* `context.mebular`:运行中 daemon 的 live app(缺省 = 离线新建)。
|
|
28
|
+
* `context.agent`:可选的稳定 Agent 身份(宿主注入时使用);MCP 协议本身没有
|
|
29
|
+
* Agent 身份,因此缺省 **显式** 为 `board`,不允许隐式分叉。fleet CLI 的
|
|
30
|
+
* `--agent` 是同一 handler 的显式操作者覆盖,缺省同样是 `board`。
|
|
25
31
|
*/
|
|
26
32
|
export const TASK_TOOL_SPECS = TASK_TOOLS.map((tool) => ({
|
|
27
33
|
name: tool.name,
|
|
@@ -31,9 +37,12 @@ export const TASK_TOOL_SPECS = TASK_TOOLS.map((tool) => ({
|
|
|
31
37
|
surface: 'task',
|
|
32
38
|
handler: async (_service, args, context = {}) => {
|
|
33
39
|
try {
|
|
40
|
+
const agent = typeof context.agent === 'string' && context.agent.trim() !== ''
|
|
41
|
+
? context.agent
|
|
42
|
+
: DEFAULT_TASK_AGENT;
|
|
34
43
|
const result = await tool.handler(args ?? {}, {
|
|
35
44
|
dir: context.home ?? homeDir(),
|
|
36
|
-
agent
|
|
45
|
+
agent,
|
|
37
46
|
...(context.mebular ? { mebular: context.mebular } : {}),
|
|
38
47
|
});
|
|
39
48
|
return json(result);
|
package/src/version.mjs
CHANGED