openclacky 1.5.22 → 1.5.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +104 -0
- data/docs/secretary-prototype.md +286 -0
- data/lib/clacky/agent/cost_tracker.rb +55 -36
- data/lib/clacky/agent/hook_manager.rb +4 -1
- data/lib/clacky/agent/llm_caller.rb +46 -12
- data/lib/clacky/agent/memory_injector.rb +209 -0
- data/lib/clacky/agent/memory_updater.rb +16 -0
- data/lib/clacky/agent/session_serializer.rb +15 -11
- data/lib/clacky/agent/skill_manager.rb +30 -8
- data/lib/clacky/agent.rb +124 -17
- data/lib/clacky/agent_config.rb +7 -3
- data/lib/clacky/agent_profile.rb +33 -6
- data/lib/clacky/anthropic_stream_aggregator.rb +11 -1
- data/lib/clacky/bedrock_stream_aggregator.rb +11 -1
- data/lib/clacky/billing/platform_billing.rb +7 -0
- data/lib/clacky/cli.rb +4 -3
- data/lib/clacky/client.rb +30 -25
- data/lib/clacky/default_extensions/advisor/README.md +25 -0
- data/lib/clacky/default_extensions/advisor/README.zh.md +25 -0
- data/lib/clacky/default_extensions/advisor/ext.yml +1 -1
- data/lib/clacky/default_extensions/advisor/icon.svg +14 -0
- data/lib/clacky/default_extensions/advisor/panels/advisor/view.js +7 -1
- data/lib/clacky/default_extensions/coding/ext.yml +0 -1
- data/lib/clacky/default_extensions/computer-use/README.md +48 -0
- data/lib/clacky/default_extensions/computer-use/README.zh.md +48 -0
- data/lib/clacky/default_extensions/computer-use/ext.yml +1 -1
- data/lib/clacky/default_extensions/computer-use/icon.svg +16 -0
- data/lib/clacky/default_extensions/ext-studio/ext.yml +0 -1
- data/lib/clacky/default_extensions/general/ext.yml +0 -1
- data/lib/clacky/default_extensions/git/README.md +41 -0
- data/lib/clacky/default_extensions/git/README.zh.md +41 -0
- data/lib/clacky/default_extensions/git/ext.yml +1 -1
- data/lib/clacky/default_extensions/git/icon.svg +15 -0
- data/lib/clacky/default_extensions/git/panels/git/view.js +106 -27
- data/lib/clacky/default_extensions/meeting/README.md +46 -0
- data/lib/clacky/default_extensions/meeting/README.zh.md +47 -0
- data/lib/clacky/default_extensions/meeting/ext.yml +1 -1
- data/lib/clacky/default_extensions/meeting/icon.svg +13 -0
- data/lib/clacky/default_extensions/preview/README.md +29 -0
- data/lib/clacky/default_extensions/preview/README.zh.md +29 -0
- data/lib/clacky/default_extensions/preview/ext.yml +1 -1
- data/lib/clacky/default_extensions/preview/icon.svg +13 -0
- data/lib/clacky/default_extensions/secretary/README.md +69 -0
- data/lib/clacky/default_extensions/secretary/README.zh.md +69 -0
- data/lib/clacky/default_extensions/secretary/agents/secretary.md +41 -0
- data/lib/clacky/default_extensions/secretary/agents/worker.md +35 -0
- data/lib/clacky/default_extensions/secretary/api/handler.rb +8 -0
- data/lib/clacky/default_extensions/secretary/ext.yml +42 -0
- data/lib/clacky/default_extensions/secretary/icon.svg +17 -0
- data/lib/clacky/default_extensions/secretary/panels/work/view.js +344 -0
- data/lib/clacky/default_extensions/secretary/tools/delegate_work.rb +37 -0
- data/lib/clacky/default_extensions/secretary/tools/manage_work.rb +22 -0
- data/lib/clacky/default_extensions/secretary/tools/yield_work.rb +35 -0
- data/lib/clacky/default_extensions/time_machine/README.md +32 -0
- data/lib/clacky/default_extensions/time_machine/README.zh.md +32 -0
- data/lib/clacky/default_extensions/time_machine/ext.yml +1 -1
- data/lib/clacky/default_extensions/time_machine/icon.svg +14 -0
- data/lib/clacky/default_skills/channel-manager/SKILL.md +103 -13
- data/lib/clacky/default_skills/channel-manager/dingtalk_setup.rb +4 -2
- data/lib/clacky/default_skills/channel-manager/discord_setup.rb +9 -2
- data/lib/clacky/default_skills/channel-manager/weixin_setup.rb +10 -1
- data/lib/clacky/default_skills/cron-task-creator/SKILL.md +183 -206
- data/lib/clacky/default_skills/cron-task-creator/evals/evals.json +45 -0
- data/lib/clacky/default_skills/media-gen/SKILL.md +31 -14
- data/lib/clacky/default_skills/onboard/SKILL.md +5 -7
- data/lib/clacky/default_skills/persist-memory/SKILL.md +15 -1
- data/lib/clacky/extension/api_extension.rb +23 -2
- data/lib/clacky/extension/loader.rb +2 -0
- data/lib/clacky/extension/verifier.rb +2 -2
- data/lib/clacky/json_ui_controller.rb +14 -1
- data/lib/clacky/locales/en.rb +14 -0
- data/lib/clacky/locales/i18n.rb +25 -3
- data/lib/clacky/locales/zh.rb +14 -0
- data/lib/clacky/message_history.rb +15 -2
- data/lib/clacky/openai_responses_stream_aggregator.rb +11 -1
- data/lib/clacky/openai_stream_aggregator.rb +11 -1
- data/lib/clacky/prompts/base.md +1 -1
- data/lib/clacky/providers.rb +32 -17
- data/lib/clacky/server/backup_manager.rb +98 -2
- data/lib/clacky/server/browser_manager.rb +10 -5
- data/lib/clacky/server/channel/adapters/base.rb +18 -0
- data/lib/clacky/server/channel/adapters/feishu/message_parser.rb +1 -0
- data/lib/clacky/server/channel/adapters/telegram/adapter.rb +1 -0
- data/lib/clacky/server/channel/channel_config.rb +185 -48
- data/lib/clacky/server/channel/channel_manager.rb +247 -110
- data/lib/clacky/server/git_panel.rb +2 -1
- data/lib/clacky/server/http_server.rb +517 -175
- data/lib/clacky/server/preview.rb +26 -5
- data/lib/clacky/server/scheduler.rb +166 -85
- data/lib/clacky/server/web_ui_controller.rb +12 -0
- data/lib/clacky/session_manager.rb +4 -1
- data/lib/clacky/skill.rb +1 -1
- data/lib/clacky/tools/base.rb +7 -1
- data/lib/clacky/ui_interface.rb +5 -0
- data/lib/clacky/utils/file_processor.rb +23 -11
- data/lib/clacky/utils/model_pricing.rb +19 -0
- data/lib/clacky/version.rb +1 -1
- data/lib/clacky/web/app.css +621 -52
- data/lib/clacky/web/app.js +103 -9
- data/lib/clacky/web/components/code-editor.js +73 -4
- data/lib/clacky/web/components/custom-select.js +7 -18
- data/lib/clacky/web/components/hint-tip.js +172 -0
- data/lib/clacky/web/components/model-picker.js +1 -1
- data/lib/clacky/web/components/notify.js +37 -10
- data/lib/clacky/web/components/onboard.js +1 -1
- data/lib/clacky/web/components/sidebar.js +70 -0
- data/lib/clacky/web/features/backup/store.js +64 -27
- data/lib/clacky/web/features/backup/view.js +42 -11
- data/lib/clacky/web/features/channels/store.js +19 -4
- data/lib/clacky/web/features/channels/view.js +94 -33
- data/lib/clacky/web/features/extensions/view.js +15 -8
- data/lib/clacky/web/features/new-session/view.js +33 -22
- data/lib/clacky/web/features/profile/view.js +4 -4
- data/lib/clacky/web/features/tasks/store.js +5 -3
- data/lib/clacky/web/features/tasks/view.js +99 -26
- data/lib/clacky/web/features/trash/view.js +4 -4
- data/lib/clacky/web/features/workspace/view.js +193 -57
- data/lib/clacky/web/i18n.js +189 -17
- data/lib/clacky/web/index.html +165 -53
- data/lib/clacky/web/projects.js +15 -2
- data/lib/clacky/web/sessions.js +316 -86
- data/lib/clacky/web/settings.js +304 -75
- data/lib/clacky/web/utils.js +261 -0
- data/lib/clacky/web/ws-dispatcher.js +24 -3
- data/lib/clacky/web/ws.js +16 -4
- data/lib/clacky/work/service.rb +544 -0
- data/lib/clacky/work/store.rb +57 -0
- data/lib/clacky.rb +1 -0
- metadata +35 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0de5997e8f1b998b5e57c588e232c0bbb6f96664f9dcd2c36ff2577d566b445b
|
|
4
|
+
data.tar.gz: 25108838302b0137589a14b320ee7374202a1601c897333fc1cb632226366462
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ecaa16a7b3a69d5932b0f878abc9fa0d0a6fe0c10898eb509a3ad92959a90f5bfb78e2610b55608bd5687128de48b587f11e0b2aff29b4c00629093704020afe
|
|
7
|
+
data.tar.gz: 54c69db9fcbe7aa5e34eca12a5c1171f893fff2d8833a0c99814eb7a50dcdc91388f04758f81cfb1041facf2bb7698d85ce7e5245a33911d26c6117aeb03b2af
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,110 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
|
|
7
|
+
## [1.5.24] - 2026-11-13
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Stream assistant replies as they are written
|
|
11
|
+
- Point first-time users at Settings with a hint
|
|
12
|
+
- Add a first-run hint on the model picker in the session info bar
|
|
13
|
+
- Recall relevant memories automatically before each message (opt-in)
|
|
14
|
+
- Collapse the Config and My Data sidebar sections
|
|
15
|
+
- Preview files an AI turn leaves in the system temp directory
|
|
16
|
+
- Dismiss the OpenClacky AI Keys promo and keep it dismissed
|
|
17
|
+
- Show progress while packing and downloading a backup
|
|
18
|
+
- Add model hints for audio, speech-to-text and video understanding
|
|
19
|
+
- Add Claude Fable 5.2 to the hosted model picker
|
|
20
|
+
- Give the secretary extension an icon and a detail page
|
|
21
|
+
- Let extensions follow WebSocket events and run before the first think
|
|
22
|
+
|
|
23
|
+
### Improved
|
|
24
|
+
- Unify the settings section headings and their icons
|
|
25
|
+
- Tighten the long-term memory write rules so stored facts stay worth keeping
|
|
26
|
+
- Keep the memories listing compact and flag the files it leaves out
|
|
27
|
+
- Move Web Search above Network in the general tab
|
|
28
|
+
- Keep memories timestamped by file mtime
|
|
29
|
+
- Use the shared tooltip on memory and recycle-bin row actions
|
|
30
|
+
- Stream backup restore uploads instead of buffering them
|
|
31
|
+
- Reveal overlong project names on hover
|
|
32
|
+
- Rename auto recall to plainer wording
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
- Switch sessions with one click in Safari
|
|
36
|
+
- Keep backend text in the client's language
|
|
37
|
+
- Rewrite hosted-platform file references to local links
|
|
38
|
+
- Render non-media image references as plain links instead of broken thumbnails
|
|
39
|
+
- Show media with a single inline reference
|
|
40
|
+
- Keep dropdown lists inside the viewport
|
|
41
|
+
- Keep the flipped new-session popover glued to its chip
|
|
42
|
+
- Localise the channel platform names
|
|
43
|
+
- Open channel setup in the session that started it
|
|
44
|
+
- Keep the git panel diffs rendered when switching layout
|
|
45
|
+
- Pin the git panel file header while scrolling a long diff
|
|
46
|
+
- Order the git panel diff stream like the file tree
|
|
47
|
+
- Show actionable browser toggle state and errors in settings
|
|
48
|
+
- Stop the scheduled tasks view from opening with no active menu item
|
|
49
|
+
|
|
50
|
+
### More
|
|
51
|
+
- Move GLM 5.3 and Kimi K3 to the end of the model picker
|
|
52
|
+
|
|
53
|
+
## [1.5.23] - 2026-11-06
|
|
54
|
+
|
|
55
|
+
### Added
|
|
56
|
+
- Add durable delegated work and a secretary extension
|
|
57
|
+
- Run multiple instances of the same IM channel platform
|
|
58
|
+
- Show linked local media inline in the Web UI
|
|
59
|
+
- Open Markdown images in the lightbox
|
|
60
|
+
- Add file actions to the image lightbox toolbar
|
|
61
|
+
- Add an open-with submenu to file context menus
|
|
62
|
+
- Sync scrolling between the Markdown editor and preview
|
|
63
|
+
- Persist composer text drafts across reloads, stored per session
|
|
64
|
+
- Offer starter examples when no scheduled task exists
|
|
65
|
+
- Show a readable title for scheduled tasks instead of the ASCII name
|
|
66
|
+
- Name the session in desktop notifications
|
|
67
|
+
- Give builtin extensions icons and full detail pages
|
|
68
|
+
- Refresh the OpenClacky image and video model lineup
|
|
69
|
+
- Advertise OpenClacky AI Keys above the secondary models
|
|
70
|
+
- Explain the Recommended provider badge on hover
|
|
71
|
+
- Mention media capabilities on the onboarding key card
|
|
72
|
+
- Infer no-vision for custom models from known model names
|
|
73
|
+
- Explain the last-turn scope in the Git panel on hover
|
|
74
|
+
|
|
75
|
+
### Improved
|
|
76
|
+
- Improve worker conversations, report context and debug exports
|
|
77
|
+
- Order scheduled tasks by enabled state, then newest first
|
|
78
|
+
- Make the secondary-model rows readable at a glance
|
|
79
|
+
- Restyle the provider promo and sharpen its copy
|
|
80
|
+
- Explain broken images in the workspace preview
|
|
81
|
+
- Tighten the Git changes toolbar and left-align the tool row when it wraps
|
|
82
|
+
- Unify session info bar tooltips and move the session file id to the end of the bar
|
|
83
|
+
- Tint destructive row menu items red only on hover
|
|
84
|
+
|
|
85
|
+
### Fixed
|
|
86
|
+
- Show the pane scrollbar on hover in the split diff view
|
|
87
|
+
- Keep the open-with submenu attached to its parent menu
|
|
88
|
+
- Title attachment-only turns with file names in the time machine
|
|
89
|
+
- Close the Git panel file menu on revert and refresh
|
|
90
|
+
- Show the untracked-files hint when checkout is blocked by untracked files
|
|
91
|
+
- Force English git output so checkout errors are recognised
|
|
92
|
+
- Drop a pushed commit pick on Git panel refresh
|
|
93
|
+
- Refetch the commit list on Git panel refresh, and stop the empty list from saying it twice
|
|
94
|
+
- Raise the scope menu and finder above the mobile aside overlay
|
|
95
|
+
- Drop the sub-model when the session's model card is gone
|
|
96
|
+
- Refresh the new-session model list every time the panel opens
|
|
97
|
+
- Resync the modal API-key link with the selected provider
|
|
98
|
+
- Exit address mode in the directory picker after entering the current path
|
|
99
|
+
- Skip sidebar transitions while restoring layout on load
|
|
100
|
+
- Keep the real path when opening file:// links in preview
|
|
101
|
+
- Refresh open file tabs after edits
|
|
102
|
+
- Reveal the file tree when the last file tab closes
|
|
103
|
+
- Start housekeeping phase cards collapsed
|
|
104
|
+
- Keep token usage detail fields always visible
|
|
105
|
+
- Show the collapse tooltip to the left of the button
|
|
106
|
+
- Drop tooltips from the open-with split button
|
|
107
|
+
|
|
108
|
+
### More
|
|
109
|
+
- Rename the MCP panel to connectors in Chinese
|
|
110
|
+
|
|
7
111
|
## [1.5.22] - 2026-10-30
|
|
8
112
|
|
|
9
113
|
### Added
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
# Secretary prototype
|
|
2
|
+
|
|
3
|
+
This version uses ordinary sessions: one secretary conversation owns a set of
|
|
4
|
+
background worker sessions. No extra daemon, database or extension installation
|
|
5
|
+
is required. The built-in `secretary` extension supplies the two profiles, three
|
|
6
|
+
model tools, API and Work panel. The server supplies persistence and coordination.
|
|
7
|
+
|
|
8
|
+
## Try it
|
|
9
|
+
|
|
10
|
+
Restart the server from this checkout (`bundle exec ruby bin/openclacky server`),
|
|
11
|
+
refresh the Web UI, and create a **生活秘书 / Secretary** session. Open its
|
|
12
|
+
**工作事项** side panel.
|
|
13
|
+
|
|
14
|
+
1. Say: “帮我查一下杭州适合带父母去的景点,整理一份建议,交给工作助手做。”
|
|
15
|
+
2. While it works, continue chatting with the secretary. The worker has a separate
|
|
16
|
+
session, and the secretary receives its result when available.
|
|
17
|
+
3. Try: “准备一条约张三下周吃饭的邀请,优先周四。先给我草稿,我来发送。”
|
|
18
|
+
4. When the work requests your input, tell the secretary “我发出去了,请等待回复”,
|
|
19
|
+
then relay “张三说只有周五有空”. The panel’s discussion button inserts a work
|
|
20
|
+
session reference into the normal composer; it does not submit automatically.
|
|
21
|
+
5. Change requirements, pause, cancel or resume by talking to the secretary.
|
|
22
|
+
Completed/cancelled items require new delegation.
|
|
23
|
+
6. Restart while waiting. The card and wait survive. A run interrupted while
|
|
24
|
+
executing becomes “需要处理”; it is not blindly replayed.
|
|
25
|
+
|
|
26
|
+
## Scope
|
|
27
|
+
|
|
28
|
+
- Workers use their profile's normal tools and existing permission checks. Work
|
|
29
|
+
coordination does not impose a separate read-only allowlist. The built-in worker
|
|
30
|
+
can create files; additional integrations depend on its configured tools.
|
|
31
|
+
- Automatic incoming association requires an exact `reply_to`, channel and chat
|
|
32
|
+
match. Telegram and Feishu normalize reply references. No heuristic matching
|
|
33
|
+
or autonomous outbound messaging is included. Other replies can be relayed
|
|
34
|
+
manually through the secretary conversation; never invent a sent message ID.
|
|
35
|
+
- `check_at` accepts future ISO8601 timestamps including an explicit UTC offset.
|
|
36
|
+
A deadline wakes the worker to assess next steps; it does not authorize sending.
|
|
37
|
+
- This is a single-server local store. Do not run two servers against the same
|
|
38
|
+
sessions directory. CLI conversations do not host the coordinator.
|
|
39
|
+
- The default background capacity leaves one slot available when the configured
|
|
40
|
+
maximum is greater than one. A maximum of one cannot provide simultaneous
|
|
41
|
+
foreground/background execution.
|
|
42
|
+
|
|
43
|
+
## Persistence and execution
|
|
44
|
+
|
|
45
|
+
`<sessions_dir>/work/state.json` contains cards, per-card result outboxes, and
|
|
46
|
+
threaded incoming events. Writes are mutex-protected atomic replacements with
|
|
47
|
+
mode 0600. Cards and result notifications are saved together. Active work and
|
|
48
|
+
pending notifications protect their associated sessions from automatic cleanup.
|
|
49
|
+
Explicit deletion of sessions is not a work cancellation API: cancel work first.
|
|
50
|
+
|
|
51
|
+
The coordinator runs once per second. It delivers pending secretary notifications
|
|
52
|
+
before dispatching queued workers. Only one execution per session is admitted.
|
|
53
|
+
Waiting uses no worker thread. A generation check rejects tools from an execution
|
|
54
|
+
whose requirements changed, was cancelled or already yielded. `yield_work` stops
|
|
55
|
+
execution even if the model returned additional tool calls in the same batch.
|
|
56
|
+
|
|
57
|
+
Notifications carry an event ID. The secretary history is persisted before outbox
|
|
58
|
+
acknowledgement; a replay checks history for that ID. This guarantees durable
|
|
59
|
+
receipt within retained history, not exactly-once model reasoning or external
|
|
60
|
+
side effects. External side effects still require tool-specific retry/idempotency handling.
|
|
61
|
+
|
|
62
|
+
The host captures recent verbatim user messages (with original message IDs) at
|
|
63
|
+
delegation and injects current card summaries into secretary turns. It does not
|
|
64
|
+
copy the entire parent conversation. Older necessary context must be supplied
|
|
65
|
+
explicitly; external replies are labelled separately from owner instructions.
|
|
66
|
+
|
|
67
|
+
## Extension API
|
|
68
|
+
|
|
69
|
+
Server-attached tools access `agent.work_service`; API handlers access
|
|
70
|
+
`work_service`. The service implements delegation, management and yielding without
|
|
71
|
+
requiring extensions to access the HTTP server's private execution methods.
|
|
72
|
+
|
|
73
|
+
- Secretary: `delegate_work`, `manage_work` (list/get/update/reply/pause/resume/cancel).
|
|
74
|
+
- Worker: `yield_work` (completed/needs_input/waiting_event).
|
|
75
|
+
- UI: read-only `GET /api/ext/secretary/work?session_id=...`. All changes go
|
|
76
|
+
through the secretary's tools in the main conversation.
|
|
77
|
+
|
|
78
|
+
## Presentation boundary
|
|
79
|
+
|
|
80
|
+
WorkService submits both worker tasks and secretary wakeups through the shared
|
|
81
|
+
`run_session_task` entry point. It does not call `Agent#run`, access agent UI,
|
|
82
|
+
render messages, or rewrite old history for presentation. `display_message` names
|
|
83
|
+
worker input/turns; the prompt contains the full work data.
|
|
84
|
+
|
|
85
|
+
Work reports are ordinary session inputs: `display_message` becomes `display_text`
|
|
86
|
+
for friendly live display and history replay. Full work data stays in the actual message content. No new hidden-turn API or rollback semantics are needed.
|
|
87
|
+
|
|
88
|
+
The panel owns English/Chinese strings and responds to the host language event.
|
|
89
|
+
Server-generated messages use Ruby i18n and the locale captured at delegation;
|
|
90
|
+
stored history, user text and worker results retain their original language.
|
|
91
|
+
|
|
92
|
+
The coordinator emits transient `ext.work.changed` invalidations scoped to the
|
|
93
|
+
owner session. The extension subscribes through `Clacky.ext`, fetches the durable
|
|
94
|
+
card snapshot, and shares it between the existing `session.aside` and
|
|
95
|
+
`session.composer` slots. Mount and reconnect also refresh. The composer slot
|
|
96
|
+
shows ongoing/waiting/decision counts while the normal session remains idle and
|
|
97
|
+
available for conversation. No extra global WS message flags or host rendering
|
|
98
|
+
branches are added. Panel actions use the existing Composer session-reference
|
|
99
|
+
API and preserve drafts. Historical prototype notifications are left untouched;
|
|
100
|
+
there is no string-based history repair.
|
|
101
|
+
|
|
102
|
+
## Recurring secretary work
|
|
103
|
+
|
|
104
|
+
The existing cron-task-creator skill and cron-task API own all plan management.
|
|
105
|
+
The secretary supplies owner_session_id from CLACKY_SESSION_ID, a friendly title,
|
|
106
|
+
a self-contained content prompt, cron when creating
|
|
107
|
+
through POST /api/cron-tasks. The API validates the owner and saves an execution
|
|
108
|
+
target. Existing GET/PATCH/DELETE/RUN routes manage the same plan; PATCH preserves
|
|
109
|
+
its target. The global API remains the user's management surface; the skill selects
|
|
110
|
+
plans by target.owner_session_id before changing them. Duplicate creates cannot
|
|
111
|
+
overwrite a secretary plan; use PATCH or a distinct name. manage_work remains
|
|
112
|
+
limited to individual work cards; there are no schedule-management tool actions.
|
|
113
|
+
|
|
114
|
+
For example, ask the secretary to prepare a morning report at 09:00 and an evening
|
|
115
|
+
report at 20:00 in server-local time. Specify sources and report scope; the prototype
|
|
116
|
+
has no automatic mailbox/calendar access. Each occurrence creates a fresh worker
|
|
117
|
+
session and durable work card; results return through the ordinary outbox and
|
|
118
|
+
friendly display_text path. Workers receive the plan instruction, occurrence time
|
|
119
|
+
and up to 50 recent work summaries. The work aside shows plans and their next due
|
|
120
|
+
time; changes are discussed in the existing conversation. Existing cron-task
|
|
121
|
+
management APIs also list/manage these plans; Run Now follows the work-card path.
|
|
122
|
+
|
|
123
|
+
Plans and prompts reuse schedules.yml and tasks/*.md. Next occurrence timestamps
|
|
124
|
+
are saved atomically. A restored process or resumed sandbox catches up only the
|
|
125
|
+
latest missed occurrence. A secretary occurrence is deduplicated by plan ID and
|
|
126
|
+
scheduled UTC instant in the work store, including when the plan cursor failed to
|
|
127
|
+
save after card creation. One unfinished card per plan is allowed: queued, running,
|
|
128
|
+
waiting, paused, failed and decision-needed work blocks the next occurrence until
|
|
129
|
+
resolved or cancelled. Pausing/deleting a plan does not cancel existing cards;
|
|
130
|
+
re-enabling or changing its timing starts from the next future occurrence.
|
|
131
|
+
|
|
132
|
+
Schedules use server-local time. Legacy plans without a cursor
|
|
133
|
+
begin tracking at the first scheduler tick (no invented pre-upgrade backlog).
|
|
134
|
+
Existing cron DOM/DOW AND semantics are retained. Receipt-based crash deduplication
|
|
135
|
+
is provided by secretary work cards; ordinary cron sessions keep their existing
|
|
136
|
+
execution path and do not gain an exactly-once execution guarantee.
|
|
137
|
+
|
|
138
|
+
No external wakeup service is introduced. Cron cannot execute while the sandbox is
|
|
139
|
+
paused; once something resumes it, due scanning continues. Existing yield_work
|
|
140
|
+
and check_at behavior is unchanged. Email subscriptions and cloud lifecycle APIs
|
|
141
|
+
remain outside this change.
|
|
142
|
+
|
|
143
|
+
## Custom secretary profiles
|
|
144
|
+
|
|
145
|
+
Use the existing user-agent directory and agent picker. No separate identity
|
|
146
|
+
store or management page is required. For example, create
|
|
147
|
+
`~/.clacky/agents/my-secretary/profile.yml`:
|
|
148
|
+
|
|
149
|
+
```yaml
|
|
150
|
+
name: my-secretary
|
|
151
|
+
title: My secretary
|
|
152
|
+
title_zh: 我的秘书
|
|
153
|
+
base_agent: secretary
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
In the same directory, write `system_prompt.md` with the user's responsibilities,
|
|
157
|
+
preferences and output expectations. The loader composes the secretary extension's
|
|
158
|
+
shared rules followed by this file. Existing base rules, global `SOUL.md` and
|
|
159
|
+
`USER.md` continue to load normally. The profile uses the secretary's declared
|
|
160
|
+
tool set and Work panel. `base_agent` can reference any agent contributed by an
|
|
161
|
+
enabled extension (for example `coding` or a third-party agent), not just
|
|
162
|
+
`secretary`. Only one direct reference is supported: no chains, user-only bases
|
|
163
|
+
or arbitrary cross-container tool merging. Base disabled-skill restrictions are
|
|
164
|
+
retained; custom profiles may disable additional skills. Skills scoped to the
|
|
165
|
+
base agent and panels attached to it also remain available. Extensions can use
|
|
166
|
+
`agent.agent_profile.based_on?(id)` to recognize customized profiles.
|
|
167
|
+
|
|
168
|
+
Restart the service after upgrading, then refresh the WebUI. The custom agent
|
|
169
|
+
appears in the existing new-conversation picker. Conversations retain the custom
|
|
170
|
+
profile name and keep work isolated by owner session. Scheduled work can belong
|
|
171
|
+
to these conversations too; workers use the configured work_agent profile.
|
|
172
|
+
|
|
173
|
+
Prompt edits follow ordinary profile behavior: new/restored agent instances load
|
|
174
|
+
current files. Already loaded instances are not hot-updated. This feature adds no
|
|
175
|
+
prompt snapshots, identity-specific memory, new session fields or outbound tools.
|
|
176
|
+
|
|
177
|
+
## Choosing a worker
|
|
178
|
+
|
|
179
|
+
An agent opts into delegation with `work_agent: <profile-id>` in its extension
|
|
180
|
+
agent declaration or user `profile.yml`. The built-in secretary sets
|
|
181
|
+
`work_agent: secretary-worker`. Custom `base_agent` profiles inherit this setting;
|
|
182
|
+
an explicit value overrides it and an empty string disables delegation.
|
|
183
|
+
The target must be an available profile. Its normal built-in and declared
|
|
184
|
+
extension tools load without an additional work-specific allowlist.
|
|
185
|
+
|
|
186
|
+
Third-party tools can call `agent.work_service.delegate`, `manage`, and
|
|
187
|
+
`yield_work`. A worker must report its outcome through `yield_work` (or its own
|
|
188
|
+
tool calling that service method). The service commits the outcome and returns
|
|
189
|
+
`end_turn: true`. Any tool can return this generic flag to finish the current turn
|
|
190
|
+
after recording its result; remaining tool calls in the batch are settled without
|
|
191
|
+
execution. The flag does not itself schedule a wakeup or pause a work card.
|
|
192
|
+
Work sessions retain revision/cancellation checks regardless of profile name.
|
|
193
|
+
|
|
194
|
+
## Handoffs, session status and alerts
|
|
195
|
+
|
|
196
|
+
`yield_work` uses `needs_input` for a question to the main agent and
|
|
197
|
+
`waiting_event` for an external reply or timed checkpoint. The main agent answers
|
|
198
|
+
from existing information/authorization when possible; otherwise it asks the user
|
|
199
|
+
and relays the answer. Legacy `needs_user` / `waiting_reply` calls and stored
|
|
200
|
+
`waiting_user` / `waiting_reply` cards remain readable and normalize to the new names.
|
|
201
|
+
|
|
202
|
+
Ending a tool turn does not imply awaiting an answer. `completed` and
|
|
203
|
+
`waiting_event` leave the worker session idle; `needs_input` leaves it
|
|
204
|
+
awaiting_feedback. The work card retains the durable outcome/wait state.
|
|
205
|
+
Worker turns do not alert the user directly. Delegation and reply/update handoffs
|
|
206
|
+
return `notify_user: false` to suppress completion alerts and done markers; an
|
|
207
|
+
explicit user question in the same owner turn takes precedence. Main-agent reports
|
|
208
|
+
retain normal notification behavior. The composer shows background work and task
|
|
209
|
+
titles without pretending the main agent is still executing.
|
|
210
|
+
|
|
211
|
+
User interruption pauses the work card. `manage_work resume` requeues paused or
|
|
212
|
+
failed work in its existing worker session, retaining history and progress; no
|
|
213
|
+
new delegation is created. It accepts optional additional instructions and the
|
|
214
|
+
usual expected_revision check. Repeating resume on queued/running work is a no-op.
|
|
215
|
+
Completed work accepts `reply`/`update` to refine the result in the same session;
|
|
216
|
+
completion means there is no work pending, not that the user has accepted it.
|
|
217
|
+
`resume` remains for interrupted work. Cancelled work cannot be restarted by feedback.
|
|
218
|
+
|
|
219
|
+
Users can also speak directly in a worker conversation. These inputs use the
|
|
220
|
+
ordinary session input queue, attachment/reference processing and queue/steer
|
|
221
|
+
setting. Pending messages are shown by the existing queue UI and reconnect snapshot;
|
|
222
|
+
Work does not keep a second chat queue in its cards. The existing on_start and
|
|
223
|
+
on_complete hooks establish and clean up revision protection for direct turns.
|
|
224
|
+
Direct conversation preserves the work's business status, result and wait condition.
|
|
225
|
+
A normal successful reply creates no work report. New deliverables, blockers and
|
|
226
|
+
external waits still use `yield_work`; background executions must yield.
|
|
227
|
+
|
|
228
|
+
The worker profile defines how to answer user-initiated conversation and when to
|
|
229
|
+
yield an outcome. Users may provide feedback directly; worker requests for missing
|
|
230
|
+
information, decisions or authorization still go to the main agent via needs_input.
|
|
231
|
+
The worker does not call ask_user or directly ask the user to unblock the work.
|
|
232
|
+
Direct chat uses the existing conversation history; the core injects no extra
|
|
233
|
+
worker conversation instructions or work-card snapshot. Ordinary answers render
|
|
234
|
+
as assistant messages. Ending a tool turn does not pause explicit queued user messages; awaiting
|
|
235
|
+
user input and interruptions still pause the queue.
|
|
236
|
+
|
|
237
|
+
## Debug downloads
|
|
238
|
+
|
|
239
|
+
Session downloads retain the existing top-level session, archive chunks and log.
|
|
240
|
+
When the session owns work, the ZIP additionally contains `work/cards.json`,
|
|
241
|
+
`work/events.json` (matched events only), `work/manifest.json`, and the associated
|
|
242
|
+
worker session files under `work/sessions/<session-id>/`. The manifest preserves
|
|
243
|
+
existing work/session identifiers and marks unavailable worker files as missing.
|
|
244
|
+
Downloading a worker includes its own card but does not expand to its owner's
|
|
245
|
+
conversation or sibling workers. Session files are the latest persisted versions;
|
|
246
|
+
the work snapshot and session files are not an atomic snapshot of a running system.
|
|
247
|
+
|
|
248
|
+
## Work identity and report references
|
|
249
|
+
|
|
250
|
+
A work card's `id` is its worker session ID; no separate work identifier is
|
|
251
|
+
allocated. Updates and resume keep this identity. `owner_session_id` identifies
|
|
252
|
+
the receiving conversation, and outbox event IDs still identify individual
|
|
253
|
+
notifications for deduplication. No legacy work-ID migration is provided.
|
|
254
|
+
|
|
255
|
+
Work reports reuse the existing session reference payload (`type`, `session_id`,
|
|
256
|
+
`name`) on their visible input message. `reference_contexts` is passed through
|
|
257
|
+
the server execution entry point and saved as `display_references`; the same
|
|
258
|
+
reference renders live and on history replay. Session badges link through the
|
|
259
|
+
existing `#session/<id>` route. `display_text` remains the friendly notification
|
|
260
|
+
body; full results are the prompt, while referenced sessions/quotes produce their
|
|
261
|
+
model context in the server before input delivery. Existing history fields are unchanged;
|
|
262
|
+
old ordinary sessions retain their reference badges and hidden context on replay.
|
|
263
|
+
|
|
264
|
+
The Ruby input parameter remains `reference_contexts`. Existing string entries
|
|
265
|
+
are still injected as model-only text. Structured reference entries additionally
|
|
266
|
+
render as badges using the existing `display_references` history field. The
|
|
267
|
+
browser request/event field remains `references`; no separate Ruby display
|
|
268
|
+
parameter is required.
|
|
269
|
+
|
|
270
|
+
Reference lookup stays in the HTTP server, which already owns the session store.
|
|
271
|
+
It adds a model-only `context` value to each resolved reference in the existing
|
|
272
|
+
`reference_contexts` argument. Agent consumes that text and strips `context` from
|
|
273
|
+
UI/history reference metadata; it does not look up sessions or require a server
|
|
274
|
+
SessionManager injection. Legacy text-only contexts and saved queued inputs remain
|
|
275
|
+
supported.
|
|
276
|
+
|
|
277
|
+
Work reports contain the work title/ID, event time, revision and outcome.
|
|
278
|
+
Manual stops are identified as user actions, distinct from worker reports and
|
|
279
|
+
execution failures. Historical feedback, original instructions and generic
|
|
280
|
+
next-step instructions are not replayed. Existing work tools and the worker session
|
|
281
|
+
reference provide details on demand.
|
|
282
|
+
Outbox event IDs remain in the work store, not in model-visible content or session
|
|
283
|
+
message IDs. Delivery uses pending/delivered state without scanning session history.
|
|
284
|
+
A crash after session persistence but before acknowledgement can repeat a report.
|
|
285
|
+
When capturing verbatim user context, host submissions carrying `display_text`
|
|
286
|
+
are excluded so generated reports are not treated as user authorization.
|
|
@@ -34,42 +34,7 @@ module Clacky
|
|
|
34
34
|
# @param raw_api_usage [Hash, nil] Raw API usage data for debugging
|
|
35
35
|
# @param model [String, nil] Model name to use for billing (defaults to current_model)
|
|
36
36
|
def track_cost(usage, raw_api_usage: nil, model: nil)
|
|
37
|
-
|
|
38
|
-
iteration_cost = nil
|
|
39
|
-
if usage[:api_cost]
|
|
40
|
-
add_cost(usage[:api_cost])
|
|
41
|
-
@cost_source = :api
|
|
42
|
-
@task_cost_source = :api
|
|
43
|
-
iteration_cost = usage[:api_cost]
|
|
44
|
-
@ui&.log("Using API-provided cost: $#{usage[:api_cost]}", level: :debug) if @config.verbose
|
|
45
|
-
else
|
|
46
|
-
# Priority 2: Calculate from tokens using ModelPricing
|
|
47
|
-
# Use provided model name (from API call time) to ensure accurate billing
|
|
48
|
-
# even if the user switches models during the API call
|
|
49
|
-
billing_model = model || current_model
|
|
50
|
-
result = ModelPricing.calculate_cost(model: billing_model, usage: usage)
|
|
51
|
-
cost = result[:cost]
|
|
52
|
-
pricing_source = result[:source]
|
|
53
|
-
|
|
54
|
-
# Only accumulate cost when the model has known pricing.
|
|
55
|
-
# Unknown models return nil — display N/A, don't add to total.
|
|
56
|
-
if cost
|
|
57
|
-
add_cost(cost)
|
|
58
|
-
iteration_cost = cost
|
|
59
|
-
@cost_source = pricing_source
|
|
60
|
-
@task_cost_source = pricing_source
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
if @config.verbose
|
|
64
|
-
if cost
|
|
65
|
-
source_label = pricing_source == :price ? "model pricing" : "default pricing"
|
|
66
|
-
@ui&.log("Calculated cost for #{@config.model_name} using #{source_label}: $#{cost.round(6)}", level: :debug)
|
|
67
|
-
else
|
|
68
|
-
@ui&.log("No pricing data available for #{@config.model_name} — cost is unknown", level: :debug)
|
|
69
|
-
end
|
|
70
|
-
@ui&.log("Usage breakdown: prompt=#{usage[:prompt_tokens]}, completion=#{usage[:completion_tokens]}, cache_write=#{usage[:cache_creation_input_tokens] || 0}, cache_read=#{usage[:cache_read_input_tokens] || 0}", level: :debug)
|
|
71
|
-
end
|
|
72
|
-
end
|
|
37
|
+
iteration_cost = accumulate_cost(usage, model)
|
|
73
38
|
|
|
74
39
|
# Collect token usage data for this iteration (returned to caller for deferred display)
|
|
75
40
|
token_data = collect_iteration_tokens(usage, iteration_cost)
|
|
@@ -127,6 +92,60 @@ module Clacky
|
|
|
127
92
|
token_data
|
|
128
93
|
end
|
|
129
94
|
|
|
95
|
+
# Bill a side LLM call (e.g. the memory picker) into the session total.
|
|
96
|
+
# Unlike track_cost it leaves @previous_total_tokens and the cache stats
|
|
97
|
+
# alone: those describe the main conversation and drive compression.
|
|
98
|
+
# @return [Float, nil] cost of the call, nil when pricing is unknown
|
|
99
|
+
def track_auxiliary_cost(usage, model:)
|
|
100
|
+
cost = accumulate_cost(usage, model)
|
|
101
|
+
unless @is_subagent
|
|
102
|
+
@ui&.update_sessionbar(cost: @total_cost, cost_source: @cost_source)
|
|
103
|
+
persist_billing_record(usage, cost, model: model)
|
|
104
|
+
end
|
|
105
|
+
cost
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Add one call's cost to the running total.
|
|
109
|
+
# @return [Float, nil] the call's cost, nil when pricing is unknown
|
|
110
|
+
private def accumulate_cost(usage, model)
|
|
111
|
+
# Priority 1: Use API-provided cost if available (OpenRouter, LiteLLM, etc.)
|
|
112
|
+
if usage[:api_cost]
|
|
113
|
+
add_cost(usage[:api_cost])
|
|
114
|
+
@cost_source = :api
|
|
115
|
+
@task_cost_source = :api
|
|
116
|
+
@ui&.log("Using API-provided cost: $#{usage[:api_cost]}", level: :debug) if @config.verbose
|
|
117
|
+
return usage[:api_cost]
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Priority 2: Calculate from tokens using ModelPricing
|
|
121
|
+
# Use provided model name (from API call time) to ensure accurate billing
|
|
122
|
+
# even if the user switches models during the API call
|
|
123
|
+
billing_model = model || current_model
|
|
124
|
+
result = ModelPricing.calculate_cost(model: billing_model, usage: usage)
|
|
125
|
+
cost = result[:cost]
|
|
126
|
+
pricing_source = result[:source]
|
|
127
|
+
|
|
128
|
+
# Only accumulate cost when the model has known pricing.
|
|
129
|
+
# Unknown models return nil — display N/A, don't add to total.
|
|
130
|
+
if cost
|
|
131
|
+
add_cost(cost)
|
|
132
|
+
@cost_source = pricing_source
|
|
133
|
+
@task_cost_source = pricing_source
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
if @config.verbose
|
|
137
|
+
if cost
|
|
138
|
+
source_label = pricing_source == :price ? "model pricing" : "default pricing"
|
|
139
|
+
@ui&.log("Calculated cost for #{billing_model} using #{source_label}: $#{cost.round(6)}", level: :debug)
|
|
140
|
+
else
|
|
141
|
+
@ui&.log("No pricing data available for #{billing_model} — cost is unknown", level: :debug)
|
|
142
|
+
end
|
|
143
|
+
@ui&.log("Usage breakdown: prompt=#{usage[:prompt_tokens]}, completion=#{usage[:completion_tokens]}, cache_write=#{usage[:cache_creation_input_tokens] || 0}, cache_read=#{usage[:cache_read_input_tokens] || 0}", level: :debug)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
cost
|
|
147
|
+
end
|
|
148
|
+
|
|
130
149
|
# Persist a billing record to the billing store
|
|
131
150
|
# @param usage [Hash] Usage data from API
|
|
132
151
|
# @param cost [Float, nil] Calculated cost for this iteration
|
|
@@ -10,6 +10,7 @@ module Clacky
|
|
|
10
10
|
:on_start,
|
|
11
11
|
:on_complete,
|
|
12
12
|
:on_iteration,
|
|
13
|
+
:before_think,
|
|
13
14
|
:session_rollback
|
|
14
15
|
].freeze
|
|
15
16
|
|
|
@@ -39,6 +40,8 @@ module Clacky
|
|
|
39
40
|
# display/countdown. It may extend questions, display context and model-only
|
|
40
41
|
# answer_context in place; answer_context is never sent to UI subscribers.
|
|
41
42
|
# return values are ignored. Keep work bounded; no separate UI events.
|
|
43
|
+
# before_think receives (agent) after steering, before model reasoning.
|
|
44
|
+
# Its return value is ignored, like other observation/preparation hooks.
|
|
42
45
|
def trigger(event, *args)
|
|
43
46
|
validate_event!(event)
|
|
44
47
|
# Keep payload hashes positional: Ruby 2.6 otherwise promotes their keys
|
|
@@ -51,7 +54,7 @@ module Clacky
|
|
|
51
54
|
callback_args = [*args, @agent]
|
|
52
55
|
callback_args << context.dup if context
|
|
53
56
|
hook_result = hook.call(*callback_args)
|
|
54
|
-
next if [:on_complete, :prepare_feedback].include?(event)
|
|
57
|
+
next if [:on_complete, :prepare_feedback, :before_think].include?(event)
|
|
55
58
|
next unless hook_result.is_a?(Hash)
|
|
56
59
|
# First deny wins and stops the chain: a weaker later verdict must
|
|
57
60
|
# never clobber a stronger earlier one, and the first deny's reason
|
|
@@ -45,7 +45,8 @@ module Clacky
|
|
|
45
45
|
# Inside call_llm we only *update in place* during retries, so the
|
|
46
46
|
# already-live progress slot shows meaningful transient status
|
|
47
47
|
# ("Network failed… attempt 2/10", etc.).
|
|
48
|
-
|
|
48
|
+
# Only user-facing replies opt in; compression calls stay silent.
|
|
49
|
+
private def call_llm(agent_upstream_fails: nil, agent_upgrade_fails: nil, stream_reply: false)
|
|
49
50
|
# Transition :fallback_active → :probing if cooling-off has expired.
|
|
50
51
|
@config.maybe_start_probing
|
|
51
52
|
refresh_client_if_card_changed!
|
|
@@ -118,17 +119,20 @@ module Clacky
|
|
|
118
119
|
@history.to_api(force_reasoning_content_pad: force_reasoning_content_pad)
|
|
119
120
|
end
|
|
120
121
|
|
|
121
|
-
response =
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
122
|
+
response = with_assistant_text_stream(enabled: stream_reply) do |on_text_delta|
|
|
123
|
+
@client.send_messages_with_tools(
|
|
124
|
+
messages_to_send,
|
|
125
|
+
model: api_call_model,
|
|
126
|
+
tools: tools_to_send,
|
|
127
|
+
max_tokens: @config.max_tokens,
|
|
128
|
+
enable_caching: @config.enable_prompt_caching,
|
|
129
|
+
reasoning_effort: @reasoning_effort,
|
|
130
|
+
on_chunk: build_progress_on_chunk,
|
|
131
|
+
**(on_text_delta ? { on_text_delta: on_text_delta } : {}),
|
|
132
|
+
agent_upstream_fails: (agent_upstream_fails || 0) + floor_fails,
|
|
133
|
+
agent_upgrade_fails: (agent_upgrade_fails || 0) + upgrade_fails
|
|
134
|
+
)
|
|
135
|
+
end
|
|
132
136
|
|
|
133
137
|
# Successful response — if we were probing, confirm primary is healthy.
|
|
134
138
|
handle_probe_success if @config.probing?
|
|
@@ -841,6 +845,36 @@ module Clacky
|
|
|
841
845
|
)
|
|
842
846
|
end
|
|
843
847
|
|
|
848
|
+
# Each attempt owns a preview. Always close it, including cancellation and retry.
|
|
849
|
+
private def with_assistant_text_stream(enabled: true)
|
|
850
|
+
return yield(nil) unless enabled
|
|
851
|
+
return yield(nil) unless @ui && @ui.respond_to?(:stream_assistant_text?) && @ui.stream_assistant_text?
|
|
852
|
+
|
|
853
|
+
message_id = SecureRandom.uuid
|
|
854
|
+
seq = 0
|
|
855
|
+
pending = +""
|
|
856
|
+
last_emit = 0.0
|
|
857
|
+
flush = lambda do
|
|
858
|
+
unless pending.empty?
|
|
859
|
+
seq += 1
|
|
860
|
+
@ui.show_assistant_delta(message_id: message_id, seq: seq, delta: pending.dup)
|
|
861
|
+
pending.clear
|
|
862
|
+
last_emit = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
863
|
+
end
|
|
864
|
+
end
|
|
865
|
+
callback = lambda do |text|
|
|
866
|
+
pending << text
|
|
867
|
+
flush.call if Process.clock_gettime(Process::CLOCK_MONOTONIC) - last_emit >= 0.05
|
|
868
|
+
end
|
|
869
|
+
begin
|
|
870
|
+
result = yield(callback)
|
|
871
|
+
flush.call
|
|
872
|
+
result
|
|
873
|
+
ensure
|
|
874
|
+
@ui.end_assistant_stream(message_id: message_id)
|
|
875
|
+
end
|
|
876
|
+
end
|
|
877
|
+
|
|
844
878
|
# Build a streaming progress callback for Client#send_messages_with_tools.
|
|
845
879
|
# Returns nil when no UI is attached, so the client skips the streaming
|
|
846
880
|
# plumbing entirely. Callback throttles UI updates to avoid flooding the
|