feat: add single-call action protocol and Android stage interfaces

This commit is contained in:
zenord
2026-10-13 00:41:55 +08:00
parent dfd1372ba2
commit e91354c9e8
41 changed files with 1438 additions and 70 deletions
+5 -3
View File
@@ -1,6 +1,7 @@
"""Request-local wall clock. Durations/deadlines must continue using monotonic time."""
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
import re
class ServerClock:
@@ -10,12 +11,13 @@ class ServerClock:
def messages(self, messages):
copied = [dict(message) for message in messages]
systems = [message['content'] for message in copied if message.get('role') == 'system']
systems = [re.sub(r'\n*\[gateway_request_clock\].*?\[/gateway_request_clock\]', '',
message['content'], flags=re.S) for message in copied if message.get('role') == 'system']
# Do not mutate the caller's persona/history, or accept a client time as authority.
instant = self.now()
if instant.tzinfo is None:
raise ValueError('server wall clock must be timezone aware')
reference = ('当前服务器时间:' + instant.astimezone(self.zone).isoformat(timespec='seconds') +
'\n时区:' + self.zone.key + '。这是本次请求的时间参考,不代表用户所在地。')
reference = ('[gateway_request_clock]\n当前服务器时间:' + instant.astimezone(self.zone).isoformat(timespec='seconds') +
'\n时区:' + self.zone.key + '。这是本次请求的时间参考,不代表用户所在地。\n[/gateway_request_clock]')
return [{'role': 'system', 'content': '\n\n'.join(systems + [reference])}] + [
message for message in copied if message.get('role') != 'system']