feat(runner): authorize contextual platform APIs

This commit is contained in:
RockChinQ
2026-09-11 00:02:44 +08:00
parent f24a7c9bb2
commit d93e44d82d
5 changed files with 307 additions and 7 deletions
+3 -1
View File
@@ -194,7 +194,9 @@ def _write_qa_runner_plugin(plugin_root: Path) -> None:
@self.handler(MemberJoinedEvent)
async def handle(ctx: RunnerContext):
await ctx.log('Handling ' + str(ctx.platform_event.member.id))
result = await ctx.reply(ctx.config['greeting'] + ', ' + (ctx.platform_event.member.nickname or str(ctx.platform_event.member.id)))
tools = await ctx.get_available_tools()
assert any(tool['name'] == 'event_reply' for tool in tools)
result = await self.plugin.call_tool('event_reply', {'text': ctx.config['greeting'] + ', ' + (ctx.platform_event.member.nickname or str(ctx.platform_event.member.id))})
await ctx.log('Reply simulated: ' + str(result.get('mock')))
""")
)