mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
fix(dsh-plugin-browserskill): register the lazy suite from any fiber
Cordis contexts are fiber-owned: assigning onto an Object.create() overlay of the apply-time context fails with 'cannot set property tools in multiple fibers' when the reveal fires from the tools/result listener fiber (caught by the e2e: the skill invocation matched but the suite never registered). registerTools now tracks disposers through a plain closure over the captured context — no context mutation anywhere. Also documents lazyTools in the README and hardens the reveal against a failed registration (log and stay hidden instead of latching). Verified end to end against the real stack: first request carries 0 browser_* schemas (skill catalog entry only); after the scripted skill invocation the next request carries exactly the 11 browser_* tools and browser_session_start dispatches for real.
This commit is contained in:
@@ -103,7 +103,16 @@ export function armLazyTools(ctx: Context, registerSuite: () => () => void): ()
|
||||
const disposers: (() => void)[] = [];
|
||||
const ensureSuite = (): void => {
|
||||
if (suiteDisposer !== undefined) return;
|
||||
suiteDisposer = registerSuite();
|
||||
try {
|
||||
suiteDisposer = registerSuite();
|
||||
} catch (error) {
|
||||
// A failed reveal must not strand the plugin: stay hidden, log, retry on
|
||||
// the next trigger instead of latching a half-registered suite.
|
||||
suiteDisposer = undefined;
|
||||
console.warn(
|
||||
`[dsh-plugin-browserskill] lazy tool registration failed: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// Live trigger: a successful model invocation of skill/browser-skill.
|
||||
|
||||
Reference in New Issue
Block a user