hyacinth-ai 0.9.13 → 0.9.15
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/dist/gateway/factory.js +4 -2
- package/dist/machine/runner.js +19 -20
- package/package.json +1 -1
package/dist/gateway/factory.js
CHANGED
|
@@ -551,7 +551,7 @@ export async function createAgent(options, supervisor) {
|
|
|
551
551
|
// ── 旁路Agent 管理器 ──────────────────────────────────────────
|
|
552
552
|
const bypassManager = new (await import('../bypass/manager.js')).BypassManager();
|
|
553
553
|
bypassManager.setModelRouter(modelRouter);
|
|
554
|
-
// 注册 WorldEngine(陪伴模式旁路Agent
|
|
554
|
+
// 注册 WorldEngine(陪伴模式旁路Agent)— 未设置角色时跳过
|
|
555
555
|
const companionCharName = (() => {
|
|
556
556
|
try {
|
|
557
557
|
const last = fs.readFileSync(path.join(os.homedir(), '.agent', 'companion', '.last-character'), 'utf-8').trim();
|
|
@@ -561,7 +561,9 @@ export async function createAgent(options, supervisor) {
|
|
|
561
561
|
return '';
|
|
562
562
|
}
|
|
563
563
|
})();
|
|
564
|
-
|
|
564
|
+
if (companionCharName) {
|
|
565
|
+
bypassManager.register(new (await import('../bypass/agents/companion/index.js')).WorldEngine(companionCharName));
|
|
566
|
+
}
|
|
565
567
|
// 注册 Orchestrator(普通模式旁路Agent)— 已暂停(2026-07-10)
|
|
566
568
|
// 待分层过滤策略成熟后重新启用,设计方案见:桌面/旁路Agent重构构想.md
|
|
567
569
|
// bypassManager.register(new (await import('../bypass/agents/orchestrator/index.js')).ContextOrchestrator(memoryFilePath));
|
package/dist/machine/runner.js
CHANGED
|
@@ -77,46 +77,45 @@ export class MachineRunner {
|
|
|
77
77
|
if (this.status !== 'active') {
|
|
78
78
|
return { ok: false, reason: `Machine "${this.definition.id}" is not active (status: ${this.status}).` };
|
|
79
79
|
}
|
|
80
|
-
// 1.
|
|
81
|
-
|
|
80
|
+
// 1. 找匹配的转移(按优先级——跳过 guard 不通过的)
|
|
81
|
+
let transition;
|
|
82
|
+
for (const t of this.definition.transitions) {
|
|
82
83
|
const fromMatch = Array.isArray(t.from)
|
|
83
84
|
? t.from.includes(this.currentState)
|
|
84
85
|
: t.from === this.currentState;
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
if (fromMatch && t.event === event) {
|
|
87
|
+
if (t.guard) {
|
|
88
|
+
const guardResult = t.guard(this.context);
|
|
89
|
+
if (!guardResult.ok)
|
|
90
|
+
continue; // guard 不通过,试下一个
|
|
91
|
+
}
|
|
92
|
+
transition = t;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
87
96
|
if (!transition) {
|
|
88
97
|
return {
|
|
89
98
|
ok: false,
|
|
90
99
|
reason: `Event "${event}" is not valid in state "${this.currentState}" of machine "${this.definition.id}". Available events: [${this.getAvailableEvents().join(', ')}]`,
|
|
91
100
|
};
|
|
92
101
|
}
|
|
93
|
-
// 2.
|
|
94
|
-
if (transition.guard) {
|
|
95
|
-
const guardResult = transition.guard(this.context);
|
|
96
|
-
if (!guardResult.ok) {
|
|
97
|
-
return {
|
|
98
|
-
ok: false,
|
|
99
|
-
reason: guardResult.reason ?? `Guard rejected transition from "${this.currentState}" to "${transition.to}" via "${event}".`,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// 3. onExit 副作用(fire-and-forget)
|
|
102
|
+
// 2. onExit 副作用(fire-and-forget)
|
|
104
103
|
const oldState = this.currentState;
|
|
105
104
|
const oldDef = this.definition.states[oldState];
|
|
106
105
|
safeFire(oldDef?.onExit, this.context);
|
|
107
|
-
//
|
|
106
|
+
// 3. onTransition 副作用(同步执行——可阻塞)
|
|
108
107
|
transition.onTransition?.(this.context);
|
|
109
|
-
//
|
|
108
|
+
// 4. 更新状态
|
|
110
109
|
this.currentState = transition.to;
|
|
111
|
-
//
|
|
110
|
+
// 5. onEnter 副作用(fire-and-forget)
|
|
112
111
|
const newDef = this.definition.states[this.currentState];
|
|
113
112
|
safeFire(newDef?.onEnter, this.context);
|
|
114
|
-
//
|
|
113
|
+
// 6. 记录历史
|
|
115
114
|
this.transitionHistory.push({ from: oldState, to: transition.to, event });
|
|
116
115
|
if (this.transitionHistory.length > MAX_HISTORY) {
|
|
117
116
|
this.transitionHistory = this.transitionHistory.slice(-MAX_HISTORY);
|
|
118
117
|
}
|
|
119
|
-
//
|
|
118
|
+
// 7. 终端状态检查
|
|
120
119
|
const isTerminal = this.definition.terminalStates?.includes(this.currentState) ?? false;
|
|
121
120
|
if (isTerminal) {
|
|
122
121
|
this.status = 'completed';
|