This commit is contained in:
@@ -14,6 +14,8 @@ from .local_commands import (
|
||||
LocalCommandEngine,
|
||||
local_command_parts,
|
||||
utc_now,
|
||||
pack_reply_parts,
|
||||
unpack_reply_parts,
|
||||
)
|
||||
|
||||
|
||||
@@ -74,7 +76,11 @@ class LocalServiceBroker:
|
||||
"question": f"{command} {arguments}".rstrip(),
|
||||
"created_at": str(event.get("observed_at") or utc_now()),
|
||||
}
|
||||
return {"text": self.engine.handle(row, event)}
|
||||
text = self.engine.handle(row, event)
|
||||
parts = unpack_reply_parts(text)
|
||||
if parts is not None:
|
||||
return {"text": parts[0], "texts": parts}
|
||||
return {"text": text}
|
||||
|
||||
|
||||
class _Context:
|
||||
@@ -162,6 +168,8 @@ class LocalExtensionRuntime:
|
||||
result = handler(sdk_event, arguments)
|
||||
if not isinstance(result, ExtensionResult):
|
||||
raise LocalExtensionError("local adapter returned invalid result")
|
||||
if result.reply.kind is PlanKind.MULTI_TEXT:
|
||||
return pack_reply_parts(list(result.reply.messages))
|
||||
if result.reply.kind is not PlanKind.TEXT:
|
||||
raise LocalExtensionError("local command returned no visible reply")
|
||||
return result.reply.message
|
||||
|
||||
Reference in New Issue
Block a user