pi-ext
bugabingas pi extensions
owned by bugabinga
fix(web): activate extension tools on session start
af24d79b3f323f2918347fe5007a56f32cb744b8
Oliver Krylow <o.krylow@isp-insoft.de> ·
SSH signature · not checked
Browse filesCompare with HEAD
Changed files (2)
extensions/web/__tests__/harness.test.ts
Modified 51 51 expect([
...extension.tools.
keys()]).
toContain(
"understand_image");
54 + it(
"activates its tools when a host session starts with a narrower set",
async ()
=> {
55 + t.session.
setActiveToolsByName([
"read"]);
56 + await extension.handlers.
get(
"session_start")[
0](
57 + { type:
"session_start", reason:
"startup" },
58 + t.session.extensionRunner.
createCommandContext(),
61 + expect(t.session.
getActiveToolNames()).
toEqual([
54 70 it(
"keeps web_fetch preview hidden until tool output is expanded",
async ()
=> {
55 71 const tool
= extension.tools.
get(
"web_fetch");
extensions/web/index.ts
Modified 757 +const WEB_TOOL_NAMES
= [
761 + "understand_image",
757 764 export default function webExtension(pi
: ExtensionAPI) {
759 766 const spotlightMarkers
: SpotlightMarkers = createMarkers();
760 767 let generation
= 0;
762 769 pi.
on(
"session_start", (_event, ctx)
=> {
770 + const active
= pi.
getActiveTools();
771 + const missing
= WEB_TOOL_NAMES.
filter((name)
=> !active.
includes(name));
772 + if (missing.
length > 0) pi.
setActiveTools([
...active,
...missing]);
763 774 const ticket
= ++generation;
764 775 void notifyMissingPlatformTools(ctx, ()
=> ticket
=== generation).
catch(
765 776 (error)
=> console.
error(
"web platform tool check failed:", error),