Commit Graph

138 Commits

Author SHA1 Message Date
EugeneTes
f0c511f953 docs(docker): Docker and Coolify deployment guide
Image contents, build arguments, the environment table with what the agent's processes can't see, volumes, Coolify steps, first Claude login, updating (the npm layer is cached: build without cache or pin CLAUDE_CODE_VERSION), extensions, troubleshooting and security.
2026-09-27 12:15:45 +02:00
EugeneTes
2461dfebce feat(docker): compose file and .env.example for Coolify
One bot service with init: true, 1 GB /dev/shm, three named volumes and every setting as an environment variable; PLAYWRIGHT_ENABLED follows INSTALL_PLAYWRIGHT. .env is git-ignored.
2026-09-27 12:12:49 +02:00
EugeneTes
9a9e55f783 feat(docker): optional Playwright MCP and Chromium in the image
INSTALL_PLAYWRIGHT=true installs @playwright/mcp@0.0.82 globally and runs its own playwright dependency's installer (install --with-deps chromium) into /opt/ms-playwright, readable by all users. The build fails if playwright-mcp --version does not run.
2026-09-27 12:09:52 +02:00
EugeneTes
4ed3758f9c feat(docker): Dockerfile for the Telegram host
Two-stage build, agent tools, Node 24, claude CLI, data dirs owned by app, DOTNET_EnableDiagnostics=0. Adds the MCP spec's deferred test that the Dockerfile's PLAYWRIGHT_MCP_VERSION equals PlaywrightPreset.DefaultPackage.

Spec change: the image keeps root as its user and the entrypoint drops to app with setpriv. With USER app, compose's docker-init (PID 1) runs as app and its /proc/1/environ exposes every secret to the agent's bash. The spec also lists the csprojs the restore layer copies (GoogleCalendar, Mcp, Scheduler included) and sets HOME=/home/app in the image.
2026-09-27 12:04:42 +02:00
EugeneTes
80358784ac docs(plan): docker-deployment implementation plan 2026-09-27 11:58:42 +02:00
EugeneTes
1353717ca0 test(telegram): relogin test deactivates host tools such as set_timezone
The fake claude never starts the proposal bridge, so the test needs a
session with no active tools. Since the scheduler spec every chat
registers set_timezone, which made the provider wait for the bridge and
fail with mcp_startup on Linux (the test returns early on Windows).
2026-09-27 11:07:56 +02:00
EugeneTes
7879969c5f Merge branch 'feat/scheduler' 2026-09-27 11:00:31 +02:00
EugeneTes
fd6b9027b6 fix(scheduler): address review findings
- JobScheduler: a stored job whose zone lookup throws no longer fails StartAsync; timer re-armed under the lock;
  a delivery cut off by shutdown isn't recorded (one-offs fire again after restart); CancelJobAsync in one step
- Schedules.ParseAt: ISO 8601 with a date only (no machine-clock date for a bare 09:00)
- core: a FollowUp prompt that loses the race to a starting run joins it as a follow-up, not steering
- Telegram: TimeZoneFor tolerates non-numeric targets; RunPromptAsync waits only when queued; one agent dir
- ScriptRunner: bad workspace paths are Failed, not exceptions; zone id helpers share TimeZoneIds.ToIana's rule
- tests: no wall-clock sleeps in scheduler tests; transcript-entry, disabled-scheduler and failing-prompt coverage
- docs: spec notes for the above; README row for the scheduler
2026-09-27 10:56:45 +02:00
EugeneTes
126d3afff1 docs(scheduler): scheduling, per-chat time zones and the session zone 2026-09-27 10:40:43 +02:00
EugeneTes
709b2d2513 test(telegram): scheduled prompts, watcher matches, restart and zone changes end to end 2026-09-27 10:36:27 +02:00
EugeneTes
8dd874a83f feat(telegram): scheduler delivery, hosted service, /jobs and /cancel
Spec: /jobs and /cancel explain when scheduling is off; Scheduler options validation.
2026-09-27 10:33:38 +02:00
EugeneTes
5b780fac36 feat(telegram): per-chat time zones with /timezone, set_timezone and Telegram:DefaultTimeZone
ChatSettingsStore keeps each chat's IANA zone in <AgentDir>/telegram/chat-settings.json;
ChatTimeZoneService is the one path for a change (store, live session, scheduler re-evaluation,
reply text). ChatRegistry.TimeZoneFor now reads the store and new sessions start in the chat's zone.
/timezone, the set_timezone tool (ChatSettingsExtension), /status zone line, DEFAULT_TIMEZONE.

The store updates its cache under the write gate so the last file written is the newest state.
2026-09-27 10:29:29 +02:00
EugeneTes
a0d886eef3 feat(scheduler): schedule tool and per-session SchedulerExtension 2026-09-27 10:23:10 +02:00
EugeneTes
4bf99dc57c feat(scheduler): JobScheduler on TimeProvider with watcher, reminder and prompt firing
Spec: a skipped one-off fires after the next start; the late note's placement and no-exit-code failure wording are pinned down; IsDeliverable is part of the watcher invariant and must not create a session; saves snapshot inside a serialising gate.
2026-09-27 10:20:22 +02:00
EugeneTes
51bc0cedf1 feat(scheduler): ScriptRunner through the process spawn policy
Spec: on Windows the command goes through Arguments like the bash tool, since cmd.exe doesn't parse ArgumentList quoting; the workspace is created if missing, and a timeout vs cancellation outcome is spelled out.
2026-09-27 10:14:33 +02:00
EugeneTes
1cc60267f9 feat(scheduler): atomic JSON job store
jobs.json is { "version": 1, "jobs": [...] } in VolcanicJson camelCase,
written to jobs.json.<pid>.tmp and moved into place through one semaphore.
A corrupt file is renamed jobs.json.corrupt-<timestamp> and loading starts
empty. Each entry is deserialised on its own, so an entry with an unknown
kind or a missing required field is dropped with a warning like any other
invalid job instead of setting the whole file aside.
2026-09-27 10:10:33 +02:00
EugeneTes
8b642885f0 test(claude-code): guard SetUnixFileMode in the TZ test (CA1416) 2026-09-27 10:10:33 +02:00
EugeneTes
d699593458 feat(scheduler): extension project, job model, cron and at parsing, validation 2026-09-27 10:07:28 +02:00
EugeneTes
96a6a5518b feat(claude-code): pass the session time zone to claude -p as TZ 2026-09-27 10:03:25 +02:00
EugeneTes
64e67b00d7 feat(core): session SetTimeZone and the date and zone in the system prompt 2026-09-27 09:58:26 +02:00
EugeneTes
da60ddb536 docs(plan): scheduler implementation plan 2026-09-27 09:54:10 +02:00
EugeneTes
b49b3eea00 Merge branch 'feat/telegram-attachments' 2026-09-26 22:37:40 +02:00
EugeneTes
6ab98a8155 fix(telegram): address review findings
- A speech or download timeout (TaskCanceledException nobody asked for) is a failure
  with the user notice, not a silent shutdown; OpenAiSpeechToText maps it to
  "the request timed out."; UpdateRouter only treats the caller's cancellation as shutdown.
- send: WorkspacePaths resolves the real path component by component (realpath),
  closing the directory-link-inside-target bypass; `.` reports a directory.
- Image documents are attached inline only when their magic bytes are JPEG/PNG/GIF/WebP,
  under the detected type.
- Audio goes to STT as an ASCII audio.<ext> name.
- MCP Browser section mentions send only when it is active.
- RunInOrderAsync takes a cancellation token; queued work is skipped once disposal gives up;
  SendReplyAsync stays private behind ReplyInOrderAsync.
- Speech HttpClient handler recycles pooled connections; BuiltInTools.Send();
  IExtensionHost.Channel is abstract; WorkspacePaths in its own file.
- Tests: timeouts, symlink chains (Linux), sniffing, channel delivery failures,
  queued-work cancellation, gated voice ordering. Spec and docs updated.
2026-09-26 22:35:20 +02:00
EugeneTes
c5ecd017a0 docs(telegram): attachments, voice, send and IChatChannel
telegram-bot.md: what you can send, files from the agent, speech settings, security notes. ui-integration.md: document/voice input rows and a new section 5 on IChatChannel. architecture, extensions and CLAUDE.md list IChatChannel. Drop the interim paragraph from the message-context spec; mark the attachments spec implemented with resolved questions.
2026-09-26 22:16:29 +02:00
EugeneTes
f90731baf0 feat(telegram): transcribe voice notes and audio with an echo
Content step 3 (InboundMedia.AddSpeechAsync): voice and audio go through ISpeechToText, the transcript is echoed as '🎤 …' and prompted as '[Voice message] …'. Spec §4 edited: audio is transcribed from the file step 2 saved (one download); an oversize or undownloadable voice note sends its notice and isn't prompted.
2026-09-26 22:13:10 +02:00
EugeneTes
a0cd2975b8 feat(telegram): save documents, videos and audio to the chat inbox
Content step 2 (InboundMedia.AddFilesAsync, InboxFiles): files land in <cwd>/inbox/<date>-<safe name>[-N], image documents within Telegram:InlineImageMaxBytes are attached inline, oversize files and failed downloads get a notice and no run. Documents, videos, audio and voice are accepted; the unsupported reply is now 'I can read text, photos, files and voice messages.'

Spec: Updates helpers are named DocumentMessage/VideoMessage/VoiceMessage/AudioMessage; the getFile 'file is too big' notice reads 'over 20 MB'; the too-large inline note is a parenthesised suffix after the size; size formats spelled out.
2026-09-26 22:09:16 +02:00
EugeneTes
8758f4b3d1 feat(telegram): OpenAI speech to text service and speech options
Spec 5: the HttpClient registration is named as AddHttpClient<ISpeechToText, OpenAiSpeechToText>() (package Microsoft.Extensions.Http), which is how Program.cs registers it.
2026-09-26 22:04:27 +02:00
EugeneTes
ee3049e47a feat(telegram): TelegramChatChannel delivers send files and scheduler texts in order
Add TelegramLimits, TelegramChatChannel (every delivery through
ChatRenderer.RunInOrderAsync, auto photo falls back to a document on a 400)
and wire it into ChatRegistry as AgentSessionOptions.Channel and
ChatContext.Channel. Spec: SendTextAsync names its failure text
("Telegram did not accept the message.") and throws when any chunk fails.
2026-09-26 22:00:16 +02:00
EugeneTes
1eed03e851 feat(telegram): ordered renderer work items and file uploads 2026-09-26 21:56:05 +02:00
EugeneTes
b22d0d159e feat(core): register send for sessions with a chat channel 2026-09-26 21:52:22 +02:00
EugeneTes
7dce84ddc5 feat(core): send tool delivers workspace files through IChatChannel
SendTool (Tool<SendArgs>, sequential) confines the path to the workspace including symlinked files and parent directories (WorkspacePaths), checks caption, photo and document limits before sending, and picks Document for non-photo extensions (.gif included) or oversized images under kind auto. Not registered yet; that is the next task.
2026-09-26 21:49:02 +02:00
EugeneTes
f2d6b7e5dc feat(core): IChatChannel contract and AgentSessionOptions.Channel
Adds the host-agnostic IChatChannel contract (ChatFile, ChatDelivery, ChatChannelLimits, ChatDeliveryException) to Abstractions/Ui, AgentSessionOptions.Channel, AgentSession.Channel and IExtensionContext.Channel. IExtensionHost.Channel is an internal plumbing default member that ExtensionContext forwards. Test support: FakeChatChannel and the TestHost builder's Channel.
2026-09-26 21:45:57 +02:00
EugeneTes
a21f3be733 docs(plan): telegram-attachments implementation plan 2026-09-26 21:43:04 +02:00
EugeneTes
0b28b9627d Merge branch 'feat/google-calendar' 2026-09-26 21:24:34 +02:00
EugeneTes
4cfe3cec47 Merge branch 'feat/mcp-client-playwright' 2026-09-26 21:20:52 +02:00
EugeneTes
e726b7c220 Merge branch 'feat/telegram-message-context' 2026-09-26 21:20:40 +02:00
EugeneTes
2a201f7d95 fix(mcp): address review findings
- redact /mcp output, and stderr lines as they arrive (log, errors, tail)
- take host servers by name: configuration binding sorts keys anyway
- dispose kills the tree only without an exit code and only if the pid's
  start time matches the spawn (no kill of a reused pid)
- idle timer generation guards stale callbacks; catalogue check runs in
  the background with a 10 s cap; shutdown stops servers concurrently
- stop resets a failed status; /mcp shows an exited process; ordinal names
- spec: ${workspace} in command, ordering, dispose and /mcp wording
2026-09-26 21:18:12 +02:00
EugeneTes
c9fd58372a docs(mcp): MCP client and Playwright preset 2026-09-26 21:05:17 +02:00
EugeneTes
7900b26e28 test(mcp): give the hang-on-start discovery test a 3 s startup timeout
The fake logs its start only after the .NET runtime is up; under full-suite
load that took over 1 s, the client killed it first and the start entry was
missing.
2026-09-26 21:05:16 +02:00
EugeneTes
4fb8f39ab4 feat(telegram): MCP servers and the Playwright preset in the bot 2026-09-26 21:05:16 +02:00
EugeneTes
963301efc4 test(mcp): environment, redaction and end to end through the core
The TZ test checks TZ is absent on Windows: the process policy never sets TZ there (process-environment-hook spec §3). Spec testing bullet and plan updated to match.
2026-09-26 20:54:20 +02:00
EugeneTes
2c5d5dfcb4 feat(mcp): extension activation, prompt section, lifecycle and /mcp
Spec: /mcp shows no pid (the SDK doesn't expose it) and never shows env values; the prompt section follows the server's own tools; the built-in collision check covers inactive built-ins.
2026-09-26 20:49:21 +02:00
EugeneTes
83ad683bd1 feat(mcp): per-session server connection and MCP tools
McpServerConnection starts the session's server lazily through
PrepareProcessAsync, applies the call timeout, reports exits with the
stderr tail and restarts on the next call, stops when idle, and supports
StopAsync (reusable) and idempotent DisposeAsync. McpTool exposes a
catalogue entry as an ITool and maps results with McpResultMapper.

Spec change (§5, Decisions): ModelContextProtocol.Core 2.2.0 does not send
notifications/cancelled when a request's token fires (verified against the
fake server), so calls go out through SendRequestAsync with their own
request id and the connection sends notifications/cancelled itself on abort
and timeout. Also documents exit detection, StopAsync vs DisposeAsync and
JSON-RPC errors as ordinary error results, per the plan.
2026-09-26 20:44:15 +02:00
EugeneTes
ed026ac6c8 feat(mcp): process-wide tool catalogue discovery
McpProcess starts a server through the SDK stdio client under the startup
timeout and keeps a stderr tail for its errors. McpCatalogCache runs one shared
discovery per server config in a temp dir, with the environment from the process
spawn policy. It keeps successes for the process lifetime and failures for 60 s.

Deviation from the plan: the discovery process is disposed and its temp dir
deleted in the background, after the catalogue is returned. SDK 2.2 waits the
whole ShutdownTimeout (5 s) with stdin still open before it kills the process,
so an awaited dispose held every first activation for 5 s. A new test
(Discovery_returns_without_waiting_for_the_server_shutdown) covers this. Spec
section 3 gets the new GetAsync signature, the detached discovery and the
background cleanup. Section 5 now describes the SDK's shutdown order correctly.
2026-09-26 20:31:43 +02:00
EugeneTes
881e7f0be9 fix(google-calendar): address review findings
- log an unknown stored zone once even when the tool description reads it first
- serialise the flow's token write with /calendar_disconnect under the flow gate
- a cancelled or expired pending flow is cleared, not re-sent or shown
- chat keys anchor with \z so a trailing newline is hashed
- a timeMax date includes that whole day (spec updated)
- dispose the flow's CancellationTokenSource, drop ConnectFlow.Token, Begin is a plain write
- GoogleCalendarOptions.IsConfigured replaces the host's copy of the rule; StoredToken is internal
- test BotSetupService's menu through DI, tokens absent from tool results
- Telegram.Tests csproj reference placed as in telegram-message-context; ChatHost passes calendar by name
- docs: per-event timeZone, both config sources for /calendar_*
2026-09-26 20:30:56 +02:00
EugeneTes
52f9d88575 test(mcp): fake stdio MCP server
Spec: the fake uses the SDK's server API from ModelContextProtocol.Core and gains the tools and modes the tests need (weird_name_x, a >48-char name, builtin-clash, --output-dir browser tools, die message and exit code, count-starts details, slow cancellation log).
2026-09-26 20:24:42 +02:00
EugeneTes
8ece6f303d docs(google-calendar): setup guide, Telegram configuration and architecture notes
Spec: the unverified-app screen is described in text; open question 1 resolved (full calendar scope); status implemented.
2026-09-26 20:20:32 +02:00
EugeneTes
fb314a5d87 docs(mcp): align plan's truncation note separator with the mapper 2026-09-26 20:19:17 +02:00
EugeneTes
da6068c5dc feat(mcp): map MCP tool results to core tool results
The truncation note follows the kept text after a single newline, as the built-in read/grep tools do (plan snippet updated).
2026-09-26 20:19:03 +02:00
EugeneTes
a635e9761b feat(telegram): Google Calendar per chat (config, secret value, menu, help)
Spec §8: extension added when either value is set, menu and /help only when both are; host code in GoogleCalendarSetup.cs.
2026-09-26 20:18:00 +02:00