libero-mcp 0.2.25 → 0.2.26

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.
@@ -11,7 +11,7 @@ import { createProfileTools } from "./src/profile/index.js";
11
11
  import { createProfileConfirmTools } from "./src/profile/confirm-default.js";
12
12
  import { createReminderTools } from "./src/reminder/index.js";
13
13
  import { createSchedulerTools } from "./src/scheduler/index.js";
14
- import { getActiveAdapter } from "./src/host-adapters/index.js";
14
+ import { createAdaptersWithDb, selectAdapter } from "./src/host-adapters/index.js";
15
15
  import { createTaskTools } from "./src/task/index.js";
16
16
  import { createCoachModTools } from "./src/coachmod/index.js";
17
17
  import { FsYamlKnowledgeRepo } from "../knowledge/src/repo/fs-yaml.js";
@@ -1117,7 +1117,7 @@ export function buildServer(db) {
1117
1117
  const profile = createProfileTools(repos.profileRepo, repos.identityRepo);
1118
1118
  const profileConfirm = createProfileConfirmTools(db);
1119
1119
  const reminder = createReminderTools(repos.reminderRepo, undefined, db);
1120
- const scheduler = createSchedulerTools(repos.timeblockRepo, repos.reminderRepo, repos.categoryRepo, getActiveAdapter(), // MV-COACH-5 slice 1: 3F 架构宿主适配层
1120
+ const scheduler = createSchedulerTools(repos.timeblockRepo, repos.reminderRepo, repos.categoryRepo, selectAdapter(createAdaptersWithDb(db)), // MV-COACH-5 slice 1: 3F 架构宿主适配层(带 db)
1121
1121
  db);
1122
1122
  const task = createTaskTools(db);
1123
1123
  // ── COACH-MOD slice 1: knowledge repo + coachmod tools ──
@@ -102,7 +102,15 @@ export function parseOffset(offset) {
102
102
  * publish/cancel 走 spawn CLI(spike 结论)。
103
103
  */
104
104
  export class HermesCronAdapter {
105
+ db;
105
106
  kind = "hermes_cron";
107
+ /**
108
+ * @param db 可选——relative_to=schedule.start 时查 schedule.start_time 用。
109
+ * slice 1 单测不传(只测 trigger 纯函数);server-core 实装时传生产 db。
110
+ */
111
+ constructor(db) {
112
+ this.db = db;
113
+ }
106
114
  detect() {
107
115
  // ① 显式指定
108
116
  if (process.env.LIBERO_HOST === "hermes")
@@ -123,10 +131,25 @@ export class HermesCronAdapter {
123
131
  }
124
132
  }
125
133
  async publish(intent) {
134
+ // relative_to=schedule.start 时查 DB 拿 start_time(slice 1 单测只覆盖纯函数,
135
+ // 这里是 publish 时真查 DB——tracer 暴露的必要修正)
126
136
  const ctx = {};
127
- // relative_to=schedule.start 时,需查 schedule 开始时间(caller 应在调 publish 前注入)
128
- // 此处简化:caller 传 trigger 时若是 schedule.start,应在 intent.action_prompt 或 trigger
129
- // 里已含 scheduleStartIso(slice 3 skill 迁移时标准化)
137
+ if (intent.trigger.kind === "relative" &&
138
+ intent.trigger.relative_to === "schedule.start") {
139
+ if (!intent.schedule_id) {
140
+ throw new Error("relative_to=schedule.start 需要 schedule_id 才能算触发时间");
141
+ }
142
+ if (!this.db) {
143
+ throw new Error("HermesCronAdapter 未注入 db,无法查 schedule.start_time");
144
+ }
145
+ const row = this.db
146
+ .prepare("SELECT start_time FROM time_blocks WHERE id=?")
147
+ .get(intent.schedule_id);
148
+ if (!row) {
149
+ throw new Error(`schedule ${intent.schedule_id} 不存在`);
150
+ }
151
+ ctx.scheduleStartIso = row.start_time;
152
+ }
130
153
  const { schedule, repeat } = translateTriggerToHermesSchedule(intent.trigger, ctx);
131
154
  const args = ["cron", "create", schedule, intent.action_prompt];
132
155
  args.push("--name", `${intent.intent_type}:${intent.id.slice(0, 8)}`);
@@ -11,9 +11,18 @@
11
11
  import { HermesCronAdapter } from "./hermes-cron.js";
12
12
  /** 所有内置 adapter(按 detect 优先级排序)。 */
13
13
  export const ADAPTERS = [
14
+ // 注:这里 new 的 adapter 不带 db——relative_to=schedule.start 查不了
15
+ // server-core 实装时用 createAdaptersWithDb(db) 拿带 db 的实例
14
16
  new HermesCronAdapter(),
15
17
  // slice 2 之后加:new OpenclawAdapter(),
16
18
  ];
19
+ /** server-core 实装时用这个——传入 db,adapter 才能查 schedule.start_time。 */
20
+ export function createAdaptersWithDb(db) {
21
+ return [
22
+ new HermesCronAdapter(db),
23
+ // slice 2 之后加:new OpenclawAdapter(),
24
+ ];
25
+ }
17
26
  /**
18
27
  * 选当前环境能用的 adapter。
19
28
  * 1. env LIBERO_HOST 显式指定 → 直接匹配 kind
@@ -50,3 +59,4 @@ export function getActiveAdapter() {
50
59
  export function _resetActiveAdapterForTest() {
51
60
  _activeAdapter = undefined;
52
61
  }
62
+ void _resetActiveAdapterForTest;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libero-mcp",
3
- "version": "0.2.25",
3
+ "version": "0.2.26",
4
4
  "description": "AI 时间管理教练 MCP 工具集——时间块记录、统计、矩阵诊断、计时、分类、profile",
5
5
  "license": "MIT",
6
6
  "author": "amosyuan",