forked from odysseus-dev/odysseus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool_schemas.py
More file actions
1595 lines (1574 loc) · 92.5 KB
/
Copy pathtool_schemas.py
File metadata and controls
1595 lines (1574 loc) · 92.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
tool_schemas.py
OpenAI-compatible function tool schemas and the converter that turns
native function calls back into ToolBlocks for the execution pipeline.
Extracted from agent_tools.py to keep schema definitions separate from
tool parsing / execution logic.
"""
import json
import logging
from typing import Optional
from src.agent_tools import ToolBlock, TOOL_TAGS
from src.tool_parsing import _TOOL_NAME_MAP
from src.tool_security import BUILTIN_EMAIL_TOOLS
logger = logging.getLogger(__name__)
_REQUIRED_NATIVE_TOOL_ARGS = {
"web_search": ("query", "queries"),
"web_fetch": ("url",),
"read_file": ("path",),
"write_file": ("path",),
"edit_file": ("path",),
"apply_patch": ("patch_text", "patchText", "patch"),
}
# ---------------------------------------------------------------------------
# OpenAI-compatible function tool schemas
# ---------------------------------------------------------------------------
FUNCTION_TOOL_SCHEMAS = [
{
"type": "function",
"function": {
"name": "bash",
"description": "Run a shell command (full access). Prefer a dedicated tool whenever one fits the job (reading, writing, editing, searching, or listing files); use bash only for what no dedicated tool covers (installs, git, builds, running programs, system info). Do NOT create or edit files via bash redirects/heredocs/sed -- use the dedicated file tools.",
"parameters": {
"type": "object",
"properties": {
"command": {"type": "string", "description": "The shell command to execute"}
},
"required": ["command"]
}
}
},
{
"type": "function",
"function": {
"name": "python",
"description": "Execute Python code to compute a result or test something. Prefer a dedicated tool whenever one fits the job (reading, writing, or searching files); use python only for computation, data processing, or scripting no dedicated tool covers.",
"parameters": {
"type": "object",
"properties": {
"code": {"type": "string", "description": "Python code to execute"}
},
"required": ["code"]
}
}
},
{
"type": "function",
"function": {
"name": "web_search",
"description": "Quick single web lookup for a fact or current event mid-task. NOT for 'research X' / 'do research on X' — those are deep-research jobs; use trigger_research instead.",
"parameters": {
"type": "object",
"properties": {
"query": {"type": "string", "description": "Search query"},
"time_filter": {"type": "string", "enum": ["day", "week", "month", "year"], "description": "Optional freshness filter for news/latest/today queries"}
},
"required": ["query"]
}
}
},
{
"type": "function",
"function": {
"name": "web_fetch",
"description": "Fetch and read the text content of a specific URL the user names (e.g. 'check example.com', 'what's on this page <url>'). Use when you already have a concrete URL/domain. NOT for open-ended searches (use web_search) or 'research X' jobs (use trigger_research). Downloads are size-budgeted; a '[partial content: ...]' notice in the result means the body was cut short and you can re-call with full=true for the rest.",
"parameters": {
"type": "object",
"properties": {
"url": {"type": "string", "description": "The URL or domain to fetch (http/https; a bare domain like example.com is fine)"},
"full": {"type": "boolean", "description": "Raise the download budget to the hard cap for large pages/files. Use only after a result reported partial content."}
},
"required": ["url"]
}
}
},
{
"type": "function",
"function": {
"name": "read_file",
"description": "Read a file from disk. Optionally read a line range with offset/limit for large files.",
"parameters": {
"type": "object",
"properties": {
"path": {"type": "string", "description": "File path to read"},
"offset": {"type": "integer", "description": "1-based line to start reading from (optional)"},
"limit": {"type": "integer", "description": "Max number of lines to read from offset (optional)"}
},
"required": ["path"]
}
}
},
{
"type": "function",
"function": {
"name": "grep",
"description": "Search file contents for a regular expression across a directory tree (uses ripgrep when available, respecting .gitignore). Returns file:line:match. PREFER this over `bash grep/rg` for code search — confined to the allowed roots, structured output.",
"parameters": {
"type": "object",
"properties": {
"pattern": {"type": "string", "description": "Regular expression to search for"},
"path": {"type": "string", "description": "Directory or file to search (optional; defaults to the project root)"},
"glob": {"type": "string", "description": "Only search files matching this glob, e.g. '*.py' (optional)"},
"ignore_case": {"type": "boolean", "description": "Case-insensitive match (optional)"},
"max_results": {"type": "integer", "description": "Max matches to return (optional)"}
},
"required": ["pattern"]
}
}
},
{
"type": "function",
"function": {
"name": "glob",
"description": "Find files by glob pattern (recursive), newest first. e.g. '**/*.py'. PREFER this over `bash find/ls` for locating files — confined to the allowed roots.",
"parameters": {
"type": "object",
"properties": {
"pattern": {"type": "string", "description": "Glob pattern, e.g. '**/*.ts' or 'src/**/test_*.py'"},
"path": {"type": "string", "description": "Base directory (optional; defaults to the project root)"}
},
"required": ["pattern"]
}
}
},
{
"type": "function",
"function": {
"name": "ls",
"description": "List the entries of a directory (folders first, then files with sizes). PREFER this over `bash ls` — confined to the allowed roots.",
"parameters": {
"type": "object",
"properties": {
"path": {"type": "string", "description": "Directory to list (optional; defaults to the project root)"}
},
"required": []
}
}
},
{
"type": "function",
"function": {
"name": "get_workspace",
"description": "Return the absolute path of the active workspace folder the user is working in. File tools are confined to it; the shell starts there but is not sandboxed. Call this first when the user refers to 'the project'/'the code'/'this folder' without a path, instead of asking them. Takes no arguments.",
"parameters": {"type": "object", "properties": {}, "required": []}
}
},
{
"type": "function",
"function": {
"name": "write_file",
"description": "Write/save a file to disk",
"parameters": {
"type": "object",
"properties": {
"path": {"type": "string", "description": "File path to write to"},
"content": {"type": "string", "description": "File content to write"}
},
"required": ["path", "content"]
}
}
},
{
"type": "function",
"function": {
"name": "edit_file",
"description": "Edit a file ON DISK by exact string replacement (home folder, project files, any real path like ~/sweden.txt or /path/to/file). This is the right tool for files on disk — NOT edit_document (that's for editor-panel documents). PREFER this over bash (sed/echo) — it shows a diff. old_string must match the file exactly and be unique (or set replace_all). Use write_file to create a new file.",
"parameters": {
"type": "object",
"properties": {
"path": {"type": "string", "description": "File path to edit"},
"old_string": {"type": "string", "description": "Exact text to replace (must match the file, including indentation)"},
"new_string": {"type": "string", "description": "Replacement text"},
"replace_all": {"type": "boolean", "description": "Replace all occurrences instead of requiring a unique match"}
},
"required": ["path", "old_string", "new_string"]
}
}
},
{
"type": "function",
"function": {
"name": "apply_patch",
"description": "Apply a multi-file source-code patch to disk. Use for real project files in the workspace when several edits belong together. Patch must use *** Begin Patch / *** End Patch with Add File, Update File, or Delete File sections. Prefer this over bash redirects/heredocs/sed.",
"parameters": {
"type": "object",
"properties": {
"patch_text": {
"type": "string",
"description": "Patch text beginning with *** Begin Patch and ending with *** End Patch"
}
},
"required": ["patch_text"]
}
}
},
{
"type": "function",
"function": {
"name": "todowrite",
"description": "Create and maintain a structured task list for the current coding session. Use during multi-step implementation/debug/refactor work and keep statuses current.",
"parameters": {
"type": "object",
"properties": {
"todos": {
"type": "array",
"description": "Current task list. Only one item should be in_progress.",
"items": {
"type": "object",
"properties": {
"content": {"type": "string", "description": "Task description"},
"status": {"type": "string", "enum": ["pending", "in_progress", "completed"]},
"priority": {"type": "string", "enum": ["low", "medium", "high"]}
},
"required": ["content", "status"]
}
}
},
"required": ["todos"]
}
}
},
{
"type": "function",
"function": {
"name": "create_document",
"description": "Create a new document in the editor panel. Use this when the user asks to write, create, build, make, or generate code, scripts, programs, games, apps, or any long-form or structured content that is more than a short paragraph, AND there is no already-open document/email draft that the request refers to. If an email compose draft is open, edit that draft instead of creating another document. NEVER put large generated content directly in chat — use this tool instead.",
"parameters": {
"type": "object",
"properties": {
"title": {"type": "string", "description": "Document title"},
"language": {"type": "string", "description": "Programming language or format (e.g. python, javascript, markdown, text)"},
"content": {"type": "string", "description": "The document content"}
},
"required": ["title", "content"]
}
}
},
{
"type": "function",
"function": {
"name": "edit_document",
"description": "Edit a document OPEN IN THE EDITOR PANEL (created via create_document) — NOT a file on disk. For files on disk (home folder, project files, anything with a path like ~/x.txt or /path/to/file) use edit_file instead. Targeted find-and-replace with multiple FIND/REPLACE pairs per call; use for any edit smaller than a full rewrite. Do NOT send the whole file back via update_document for small edits.",
"parameters": {
"type": "object",
"properties": {
"edits": {
"type": "array",
"description": "List of find/replace edits (first match only per edit)",
"items": {
"type": "object",
"properties": {
"find": {"type": "string", "description": "Exact text to find in the document"},
"replace": {"type": "string", "description": "Text to replace it with"}
},
"required": ["find", "replace"]
}
}
},
"required": ["edits"]
}
}
},
{
"type": "function",
"function": {
"name": "suggest_document",
"description": "Suggest improvements to the active document WITHOUT editing it. Creates inline comment bubbles the user can accept or reject. Use when the user asks for suggestions, review, improvements, or feedback.",
"parameters": {
"type": "object",
"properties": {
"suggestions": {
"type": "array",
"description": "List of suggested changes with reasons",
"items": {
"type": "object",
"properties": {
"find": {"type": "string", "description": "Exact text in the document to suggest changing"},
"replace": {"type": "string", "description": "Suggested replacement text"},
"reason": {"type": "string", "description": "Brief explanation of why this change helps"}
},
"required": ["find", "replace", "reason"]
}
}
},
"required": ["suggestions"]
}
}
},
{
"type": "function",
"function": {
"name": "update_document",
"description": "Replace the ENTIRE active document. ONLY use for genuine full rewrites (>50% of lines changed). For any smaller change, use edit_document — echoing back the whole file for small edits is wasteful.",
"parameters": {
"type": "object",
"properties": {
"content": {"type": "string", "description": "Complete new document content"}
},
"required": ["content"]
}
}
},
{
"type": "function",
"function": {
"name": "search_chats",
"description": "Search the user's past session transcripts by keyword. Use when the user asks about previous chats, past conversations, or when direct transcript evidence is better than persistent memory. Returns matching sessions with clickable links and nearby context.",
"parameters": {
"type": "object",
"properties": {
"query": {"type": "string", "description": "Search keyword(s) to find in past conversations"}
},
"required": ["query"]
}
}
},
{
"type": "function",
"function": {
"name": "chat_with_model",
"description": "Send a message to another AI model and get its response. Use for getting a second opinion, delegating subtasks, or AI-to-AI communication.",
"parameters": {
"type": "object",
"properties": {
"model": {"type": "string", "description": "Model name (e.g. 'qwen3-32b') or model@endpoint_name"},
"message": {"type": "string", "description": "The message to send to the model"}
},
"required": ["model", "message"]
}
}
},
{
"type": "function",
"function": {
"name": "create_session",
"description": "Create a new chat for ongoing conversations with a specific model. (The UI calls these 'chats'; 'session' is the internal term.)",
"parameters": {
"type": "object",
"properties": {
"name": {"type": "string", "description": "Name for the new chat"},
"model": {"type": "string", "description": "Model name or model@endpoint_name"}
},
"required": ["name", "model"]
}
}
},
{
"type": "function",
"function": {
"name": "list_sessions",
"description": "List the user's chats (the UI calls them 'chats') as clickable markdown links. Use this to enumerate chats before opening, renaming, archiving, or deleting them. When replying to the user, preserve the returned [title](#session-id) links; do not strip them into plain text. Optionally filter by keyword.",
"parameters": {
"type": "object",
"properties": {
"filter": {"type": "string", "description": "Optional keyword to filter chats by name"}
},
"required": []
}
}
},
{
"type": "function",
"function": {
"name": "send_to_session",
"description": "Send a new message to an existing live chat and get that chat model's response. Do not use this to retrieve, read, summarize, or inspect old chats; use search_chats or list_sessions for past chat evidence.",
"parameters": {
"type": "object",
"properties": {
"session_id": {"type": "string", "description": "The id of the chat to send the message to"},
"message": {"type": "string", "description": "The message to send"}
},
"required": ["session_id", "message"]
}
}
},
{
"type": "function",
"function": {
"name": "pipeline",
"description": "Run a multi-step AI pipeline where each model's output feeds the next. Example: Draft -> Critique -> Revise.",
"parameters": {
"type": "object",
"properties": {
"steps": {
"type": "array",
"description": "Pipeline steps in order",
"items": {
"type": "object",
"properties": {
"model": {"type": "string", "description": "Model name for this step"},
"instruction": {"type": "string", "description": "What this step should do"}
},
"required": ["model", "instruction"]
}
}
},
"required": ["steps"]
}
}
},
{
"type": "function",
"function": {
"name": "manage_session",
"description": "Manage a chat: rename, archive, unarchive, delete, mark important, truncate history, or fork it. (The UI calls these 'chats'; 'session' is the internal term.) For destructive actions like delete, call list_sessions first and pass the exact id returned there; never invent ids.",
"parameters": {
"type": "object",
"properties": {
"action": {"type": "string", "enum": ["rename", "archive", "unarchive", "delete", "important", "unimportant", "truncate", "fork"],
"description": "The action to perform"},
"session_id": {"type": "string", "description": "Exact target chat id from list_sessions, or 'current' for the active chat where supported"},
"value": {"type": "string", "description": "Action parameter: new name (rename), keep_count (truncate/fork)"}
},
"required": ["action", "session_id"]
}
}
},
{
"type": "function",
"function": {
"name": "manage_memory",
"description": "Manage the user's memory system: list, add, edit, delete, or search memories. Memories persist across sessions.",
"parameters": {
"type": "object",
"properties": {
"action": {"type": "string", "enum": ["list", "add", "edit", "delete", "search"],
"description": "The action to perform"},
"text": {"type": "string", "description": "Memory text (for add/edit) or search query (for search)"},
"memory_id": {"type": "string", "description": "Memory ID (for edit/delete)"},
"category": {"type": "string", "enum": ["fact", "event", "contact", "preference"],
"description": "Memory category (for add/list filter)"}
},
"required": ["action"]
}
}
},
{
"type": "function",
"function": {
"name": "list_models",
"description": "List all available AI models across configured endpoints. Optionally filter by keyword.",
"parameters": {
"type": "object",
"properties": {
"filter": {"type": "string", "description": "Optional keyword to filter models"}
},
"required": []
}
}
},
{
"type": "function",
"function": {
"name": "ui_control",
"description": "Control the user interface. Actions: toggle (turn tools on/off), open_panel (open a modal: documents/library, gallery, email, sessions, notes, memories/brain, skills, settings, cookbook), open_email_reply (open an email reply draft document; DOES NOT send. For 'write/draft a reply saying X', include body with the drafted reply), set_mode, switch_model, set_theme (built-in presets: dark, light, midnight, paper, cyberpunk, retrowave, forest, ocean, ume, copper, terminal, organs, lavender, gpt, claude, cute), create_theme (CREATE any custom theme with a name + colors object — pick distinctive, evocative hex colors that match the requested aesthetic, NOT generic defaults. The theme auto-applies after creation). When a user asks for ANY theme not in the built-in preset list, ALWAYS use create_theme.",
"parameters": {
"type": "object",
"properties": {
"action": {"type": "string", "enum": ["toggle", "open_panel", "open_email_reply", "set_mode", "switch_model", "set_theme", "create_theme", "get_toggles"],
"description": "The UI action. Use set_theme for presets, create_theme to build a custom theme with any hex colors"},
"name": {"type": "string", "description": "For toggle: web, bash, research, incognito, document_editor (aliases: shell, search, deepresearch, documents). For open_panel: documents, gallery, email, sessions, notes, brain/memories, skills, settings, cookbook. For open_email_reply: email UID. For set_theme: a preset theme name. For create_theme: the custom theme name."},
"value": {"type": "string", "description": "Value: on/off for toggle, agent/chat for set_mode, model name for switch_model, theme name for set_theme, or folder for open_email_reply"},
"uid": {"type": "string", "description": "Email UID for open_email_reply"},
"folder": {"type": "string", "description": "Email folder for open_email_reply (default INBOX)"},
"mode": {"type": "string", "description": "Reply draft mode for open_email_reply: reply, reply-all, or ai-reply"},
"body": {"type": "string", "description": "For open_email_reply: reply body to pre-fill. Required whenever the user told you what the reply should say. Opens a draft, does not send."},
"colors": {"type": "object", "description": "For create_theme: the theme colors",
"properties": {
"bg": {"type": "string", "description": "Background color (hex, e.g. #1a1a2e)"},
"fg": {"type": "string", "description": "Foreground/text color (hex)"},
"panel": {"type": "string", "description": "Panel/sidebar background color (hex)"},
"border": {"type": "string", "description": "Border/divider color (hex)"},
"accent": {"type": "string", "description": "Accent color for buttons, brand, highlights (hex)"},
"userBubbleBg": {"type": "string", "description": "User chat bubble background (hex, optional)"},
"aiBubbleBg": {"type": "string", "description": "AI chat bubble background (hex, optional)"},
"bubbleBorder": {"type": "string", "description": "Chat bubble border color (hex, optional)"},
"sidebarBg": {"type": "string", "description": "Sidebar background override (hex, optional)"},
"sectionAccent": {"type": "string", "description": "Section header accent color (hex, optional)"},
"brandColor": {"type": "string", "description": "Brand/logo color (hex, optional)"},
"inputBg": {"type": "string", "description": "Chat input background (hex, optional)"},
"inputBorder": {"type": "string", "description": "Chat input border (hex, optional)"},
"sendBtnBg": {"type": "string", "description": "Send button background (hex, optional)"},
"sendBtnHover": {"type": "string", "description": "Send button hover color (hex, optional)"},
"codeBg": {"type": "string", "description": "Code block background (hex, optional)"},
"codeFg": {"type": "string", "description": "Code block text color (hex, optional)"},
"toggleBg": {"type": "string", "description": "Toggle switch off background (hex, optional)"},
"toggleActive": {"type": "string", "description": "Toggle switch on color (hex, optional)"},
"accentPrimary": {"type": "string", "description": "Primary accent override (hex, optional)"},
"accentError": {"type": "string", "description": "Error/danger color (hex, optional)"}
},
"required": ["bg", "fg", "panel", "border", "accent"]}
},
"required": ["action"]
}
}
},
{
"type": "function",
"function": {
"name": "ask_user",
"description": "Ask the user a multiple-choice question to get a decision or clarification when the task is genuinely ambiguous and the answer changes what you do next (e.g. pick between approaches, confirm an assumption, choose a target). The user sees clickable option buttons; calling this ENDS your turn and their selection arrives as your next message. Prefer sensible defaults over asking — only ask when you truly cannot proceed well without the user's input. Do NOT use it to confirm irreversible/destructive actions that have a dedicated confirmation flow.",
"parameters": {
"type": "object",
"properties": {
"question": {"type": "string", "description": "The question to ask. Be specific and self-contained."},
"options": {
"type": "array",
"description": "2-6 choices. Each is an object with a short `label` and an optional `description` explaining the trade-off.",
"items": {
"type": "object",
"properties": {
"label": {"type": "string", "description": "Concise choice text the user clicks (1-5 words)."},
"description": {"type": "string", "description": "Optional one-line explanation of this choice."}
},
"required": ["label"]
}
},
"multi": {"type": "boolean", "description": "Set true ONLY when the question explicitly allows choosing more than one option. Otherwise omit it or set false. Default false."}
},
"required": ["question", "options"]
}
}
},
{
"type": "function",
"function": {
"name": "update_plan",
"description": "Write back to the ACTIVE PLAN: mark steps done or revise them. Use this while executing an approved plan — after you finish a step, call update_plan with the full checklist and that step marked `- [x]`; when the user asks to change the plan, call it with the revised checklist. The user's docked plan window updates live. Pass the COMPLETE checklist every time (not a diff). No effect if there is no active plan.",
"parameters": {
"type": "object",
"properties": {
"plan": {"type": "string", "description": "The full updated plan as a GitHub-style markdown checklist — one step per line, `- [ ]` for pending and `- [x]` for done. Always send the whole list."}
},
"required": ["plan"]
}
}
},
{
"type": "function",
"function": {
"name": "manage_tasks",
"description": "Manage scheduled/automated tasks: list, create, edit, delete, pause, resume, or run tasks. Use this for ANY recurring/scheduled request ('every morning…', 'each day at 7:30', 'daily summarize…') — create a task rather than doing it once. Task types: llm (AI runs a prompt), research (runs the deep-research pipeline on a question), or action (built-in automation). Triggers can be time-based or event-based.",
"parameters": {
"type": "object",
"properties": {
"action": {"type": "string", "enum": ["list", "create", "edit", "delete", "pause", "resume", "run"],
"description": "The action to perform"},
"task_id": {"type": "string", "description": "Task ID (for edit/delete/pause/resume/run)"},
"name": {"type": "string", "description": "Task name"},
"prompt": {"type": "string", "description": "The instruction (for task_type=llm) or the research question (for task_type=research). Required for both."},
"task_type": {"type": "string", "enum": ["llm", "research", "action"],
"description": "llm = AI runs your prompt; research = runs the deep-research pipeline on the prompt as a question; action = direct built-in function"},
"action_name": {"type": "string", "enum": [
"tidy_sessions", "tidy_documents", "consolidate_memory", "tidy_research",
"summarize_emails", "draft_email_replies", "extract_email_events",
"classify_events", "learn_sender_signatures",
"test_skills", "audit_skills", "check_email_urgency"
],
"description": "Built-in action (for task_type=action)"},
"trigger_type": {"type": "string", "enum": ["schedule", "event"],
"description": "schedule = time-based, event = count-based"},
"schedule": {"type": "string", "enum": ["once", "daily", "weekly", "monthly"],
"description": "Schedule frequency (for trigger_type=schedule)"},
"scheduled_time": {"type": "string", "description": "HH:MM in UTC (for schedule triggers). Convert the user's stated local time using the UTC offset given in the 'Current date and time' context."},
"scheduled_day": {"type": "integer", "description": "Day of week 0=Mon (weekly) or day of month (monthly)"},
"trigger_event": {"type": "string", "enum": ["session_created", "message_sent", "document_created", "memory_added", "research_completed", "email_received", "skill_added"],
"description": "Event name (for trigger_type=event)"},
"trigger_count": {"type": "integer", "description": "Fire every N events (for trigger_type=event)"},
"output_target": {"type": "string", "description": "Where results go. Defaults to 'session' (results land in a dedicated chat session the user reads) — this is the right choice for 'summarize for me' / 'send to me'. Do NOT go hunting for the user's email address; only use an email MCP tool name here if the user explicitly asked to be emailed AND an address is already known."}
},
"required": ["action"]
}
}
},
{
"type": "function",
"function": {
"name": "manage_calendar",
"description": "Manage calendar events: list events in a date range, create, update, delete. Each event can carry a tag/category (event_type) and importance level. Resolve relative dates like today/tomorrow against the 'Current date and time' system context, then pass ISO 8601 datetimes in the user's local wall time; for all-day events set all_day=true and pass YYYY-MM-DD. For event reminders/alarms, pass reminder_minutes; the tool creates the Odysseus note reminder, so do not also call manage_notes for the same reminder. Do not set rrule for single-occurrence requests such as 'next Wednesday only'; use rrule only when the user explicitly wants recurrence.",
"parameters": {
"type": "object",
"properties": {
"action": {"type": "string",
"enum": ["list_events", "create_event", "update_event", "delete_event", "list_calendars"],
"description": "Action to perform"},
"summary": {"type": "string", "description": "Event title (for create/update)"},
"dtstart": {"type": "string", "description": "Start ISO datetime, or YYYY-MM-DD if all_day"},
"dtend": {"type": "string", "description": "End ISO datetime; defaults to +1h (or +1 day for all_day)"},
"all_day": {"type": "boolean", "description": "Whether this is an all-day event"},
"description": {"type": "string", "description": "Event description / notes"},
"location": {"type": "string", "description": "Event location"},
"uid": {"type": "string", "description": "Event UID (for update/delete)"},
"calendar_href": {"type": "string", "description": "Specific calendar URL (optional; defaults to first calendar)"},
"calendar": {"type": "string", "description": "Filter list_events by calendar name or href"},
"start": {"type": "string", "description": "list_events range start (ISO datetime). Use this for month/week requests after resolving the date range; do not pass a loose query string. Prefer start; backend also accepts start_time, start_date, range_start, from, dtstart, since."},
"end": {"type": "string", "description": "list_events range end (ISO datetime). Use this for month/week requests after resolving the date range; defaults to +14 days only when no range is requested. Prefer end; backend also accepts end_time, end_date, range_end, to, dtend, until."},
"event_type": {"type": "string", "description": "Tag / category for the event. Common values: work, personal, health, travel, meal, social, admin, other. Aliases accepted: tag, category, type."},
"importance": {"type": "string", "enum": ["low", "normal", "high", "critical"], "description": "Priority level (defaults to 'normal')"},
"reminder_minutes": {"type": "integer", "description": "For create_event: create an Odysseus reminder this many minutes before the event, e.g. 5 for 'reminder 5 min before'."},
"rrule": {"type": "string", "description": "Recurrence rule in iCalendar RRULE format, e.g. 'FREQ=WEEKLY;BYDAY=MO' for weekly on Monday. Use with create_event or update_event. For update_event, pass an explicit empty string to remove recurrence and make the event single-occurrence."}
},
"required": ["action"]
}
}
},
{
"type": "function",
"function": {
"name": "manage_notes",
"description": "Manage notes and checklists (Google Keep-style): list, view, add, update, delete, toggle_item. Use list/search to find candidate notes, then view with the note id when you need the full body. IMPORTANT: For to-do lists / checklists, set note_type='checklist' and pass the items as the `checklist_items` array — do NOT serialize them into `content` as plain text. For freeform notes, use note_type='note' and put the body in `content`. `due_date` accepts natural language like 'tomorrow at 9am' (parsed in the user's timezone) and fires a notification — do not also create a calendar event for the same reminder.",
"parameters": {
"type": "object",
"properties": {
"action": {"type": "string",
"enum": ["list", "search", "view", "add", "update", "delete", "toggle_item"],
"description": "The action to perform"},
"id": {"type": "string", "description": "Note id (for update/delete/toggle_item); 8-char prefix is fine"},
"query": {"type": "string", "description": "Search text for action='search'"},
"title": {"type": "string", "description": "Note title (for add/update)"},
"content": {"type": "string", "description": "Freeform body text. Use this for note_type='note'. Do NOT use this for checklists — pass `checklist_items` instead."},
"note_type": {"type": "string", "enum": ["note", "checklist"],
"description": "'note' = freeform text in `content`. 'checklist' = structured to-do items in `checklist_items`. Defaults to 'checklist' if checklist_items is supplied, else 'note'."},
"checklist_items": {"type": "array",
"items": {"type": "object",
"properties": {
"text": {"type": "string", "description": "The to-do item text"},
"done": {"type": "boolean", "description": "Whether the item is checked off"}
},
"required": ["text"]},
"description": "Checklist items for note_type='checklist'. Each item is {text, done}. REQUIRED for checklists — leaving this empty produces a blank note."},
"color": {"type": "string", "description": "Optional color label (e.g. 'yellow', 'blue', 'green')"},
"label": {"type": "string", "description": "Optional category label (also used as a list filter)"},
"pinned": {"type": "boolean", "description": "Pin the note to the top"},
"archived": {"type": "boolean", "description": "For update: archive/unarchive. For list: show archived notes when true."},
"due_date": {"type": "string", "description": "Reminder time. Accepts natural language ('tomorrow at 9am', '11pm today') or ISO 8601. Fires a notification at that time."},
"index": {"type": "integer", "description": "Checklist item index (for toggle_item, 0-based)"}
},
"required": ["action"]
}
}
},
{
"type": "function",
"function": {
"name": "api_call",
"description": "Call a registered API integration (RSS reader, git forge, bookmark manager, smart home, etc.). Check the system context for available integrations and their endpoints.",
"parameters": {
"type": "object",
"properties": {
"integration": {"type": "string", "description": "Integration name or ID (e.g. 'Miniflux', 'Gitea')"},
"method": {"type": "string", "enum": ["GET", "POST", "PUT", "PATCH", "DELETE"], "description": "HTTP method"},
"path": {"type": "string", "description": "API endpoint path (e.g. '/v1/entries?status=unread&limit=20')"},
"body": {"type": "object", "description": "JSON request body (for POST/PUT/PATCH)"}
},
"required": ["integration", "method", "path"]
}
}
},
{
"type": "function",
"function": {
"name": "ask_teacher",
"description": "Ask a more capable AI model for help when stuck on a difficult problem. The teacher provides guidance that can be saved as a learned skill.",
"parameters": {
"type": "object",
"properties": {
"model": {"type": "string", "description": "Teacher model name (e.g. 'claude-sonnet-4') or 'auto' for configured default"},
"problem": {"type": "string", "description": "Describe the problem or question you need help with"}
},
"required": ["problem"]
}
}
},
{
"type": "function",
"function": {
"name": "manage_skills",
"description": (
"Read or modify the user's skill library. Skills are SKILL.md files "
"(YAML frontmatter + structured body: When to Use / Procedure / "
"Pitfalls / Verification) and follow a draft → published lifecycle. "
"Use progressive disclosure: 'list' to see what exists, 'view' to "
"load full content for a single skill, 'view_ref' for sub-files. "
"Use 'patch' for surgical text edits and 'edit' for full rewrites. "
"'publish' once you've verified the procedure works. For add, "
"always provide an explicit name slug and only tell the user the "
"exact name returned by the tool."
),
"parameters": {
"type": "object",
"properties": {
"action": {"type": "string", "enum": ["list", "view", "view_ref", "add", "edit", "patch", "publish", "delete", "search"], "description": "list = name+description summary; view = full SKILL.md; view_ref = sub-file under the skill dir; add = create; edit = full rewrite (content); patch = old_string→new_string; publish = flip status; delete; search = relevance match on published skills."},
"name": {"type": "string", "description": "Slug/name of the skill. Required for add/view/view_ref/edit/patch/publish/delete. For add, choose the exact kebab-case name the user should see and report only the returned name."},
"path": {"type": "string", "description": "Sub-path under the skill directory for view_ref (e.g. 'references/example.md')."},
"description": {"type": "string", "description": "One-line summary surfaced in the skills index (for add)."},
"category": {"type": "string", "description": "Organizational grouping like 'dev', 'email', 'system' (for add)."},
"when_to_use": {"type": "string", "description": "Trigger conditions in plain English (for add)."},
"procedure": {"type": "array", "items": {"type": "string"}, "description": "Numbered steps (for add)."},
"pitfalls": {"type": "array", "items": {"type": "string"}, "description": "Known failure modes + recovery (for add)."},
"verification": {"type": "array", "items": {"type": "string"}, "description": "How to confirm the procedure succeeded (for add)."},
"tags": {"type": "array", "items": {"type": "string"}, "description": "Keyword tags (for add)."},
"platforms": {"type": "array", "items": {"type": "string"}, "description": "Restrict to OSes (for add)."},
"requires_toolsets": {"type": "array", "items": {"type": "string"}, "description": "Hide unless these toolsets are active (for add)."},
"fallback_for_toolsets": {"type": "array", "items": {"type": "string"}, "description": "Hide when these toolsets are active (for add)."},
"status": {"type": "string", "enum": ["draft", "published"], "description": "Defaults to 'draft' on add."},
"version": {"type": "string", "description": "Semver-ish, e.g. '1.0.0' (for add)."},
"confidence": {"type": "number", "description": "0-1 (for add/publish)."},
"content": {"type": "string", "description": "Full SKILL.md text (for edit)."},
"old_string": {"type": "string", "description": "Exact substring to replace (for patch). Must appear exactly once."},
"new_string": {"type": "string", "description": "Replacement text (for patch)."},
"query": {"type": "string", "description": "Search query (for search)."}
},
"required": ["action"]
}
}
},
{
"type": "function",
"function": {
"name": "manage_endpoints",
"description": "Manage model API endpoints: list configured endpoints, add new ones, delete, enable or disable them.",
"parameters": {
"type": "object",
"properties": {
"action": {"type": "string", "enum": ["list", "add", "delete", "enable", "disable"]},
"endpoint_id": {"type": "string", "description": "Endpoint ID (for delete/enable/disable)"},
"name": {"type": "string", "description": "Display name (for add)"},
"base_url": {"type": "string", "description": "API base URL e.g. https://api.openai.com/v1 (for add)"},
"api_key": {"type": "string", "description": "API key (for add)"}
},
"required": ["action"]
}
}
},
{
"type": "function",
"function": {
"name": "manage_mcp",
"description": "Manage MCP (Model Context Protocol) tool servers: list servers and their tools, add new servers, delete, enable/disable, reconnect, or list all available tools.",
"parameters": {
"type": "object",
"properties": {
"action": {"type": "string", "enum": ["list", "add", "delete", "enable", "disable", "reconnect", "list_tools"]},
"server_id": {"type": "string", "description": "Server ID (for delete/enable/disable/reconnect)"},
"name": {"type": "string", "description": "Server name (for add)"},
"command": {"type": "string", "description": "Command to run e.g. npx (for add)"},
"args": {"type": "array", "items": {"type": "string"}, "description": "Command arguments (for add)"},
"env": {"type": "object", "description": "Environment variables (for add)"}
},
"required": ["action"]
}
}
},
{
"type": "function",
"function": {
"name": "manage_webhooks",
"description": "Manage webhooks: list, add, delete, enable or disable webhook endpoints.",
"parameters": {
"type": "object",
"properties": {
"action": {"type": "string", "enum": ["list", "add", "delete", "enable", "disable"]},
"webhook_id": {"type": "string", "description": "Webhook ID (for delete/enable/disable)"},
"name": {"type": "string", "description": "Webhook name (for add)"},
"url": {"type": "string", "description": "Webhook URL (for add)"},
"events": {"type": "string", "description": "Comma-separated event names (for add)"}
},
"required": ["action"]
}
}
},
{
"type": "function",
"function": {
"name": "manage_tokens",
"description": "Manage API access tokens: list existing tokens, create new ones, or delete them.",
"parameters": {
"type": "object",
"properties": {
"action": {"type": "string", "enum": ["list", "create", "delete"]},
"token_id": {"type": "string", "description": "Token ID (for delete)"},
"name": {"type": "string", "description": "Token name (for create)"}
},
"required": ["action"]
}
}
},
{
"type": "function",
"function": {
"name": "manage_documents",
"description": "Manage documents: list all documents (with optional search/language filter), delete documents, or run tidy cleanup.",
"parameters": {
"type": "object",
"properties": {
"action": {"type": "string", "enum": ["list", "delete", "tidy"]},
"document_id": {"type": "string", "description": "Document ID (for delete)"},
"search": {"type": "string", "description": "Search query (for list)"},
"language": {"type": "string", "description": "Filter by language (for list)"},
"limit": {"type": "integer", "description": "Max results (for list, default 50)"}
},
"required": ["action"]
}
}
},
{
"type": "function",
"function": {
"name": "manage_settings",
"description": "Manage user preferences and settings. Use `disable_tool`/`enable_tool`/`list_tools` to turn individual tools on or off globally (e.g. shell, search, browser, documents, memory, skills, images, tasks, notes, calendar, email). Use list/get/set/delete for free-form preferences.",
"parameters": {
"type": "object",
"properties": {
"action": {"type": "string", "enum": ["list", "get", "set", "delete", "disable_tool", "enable_tool", "list_tools"]},
"key": {"type": "string", "description": "Setting key (for get/set/delete)"},
"value": {"description": "Setting value (for set) — can be string, number, boolean, or object"},
"tool": {"type": "string", "description": "Tool name to disable/enable (for disable_tool/enable_tool). Accepts aliases: shell, search, browser, documents, memory, skills, images, tasks, notes, calendar, email — or a raw tool name like 'bash' or 'web_search'."}
},
"required": ["action"]
}
}
},
{
"type": "function",
"function": {
"name": "download_model",
"description": "Download a HuggingFace model to a server. If `host` is omitted, defaults to the cookbook's currently-selected server (NOT localhost) — call list_cookbook_servers first if you're unsure where it should go.",
"parameters": {
"type": "object",
"properties": {
"repo_id": {"type": "string", "description": "HuggingFace repo (e.g. 'Qwen/Qwen3-8B')"},
"host": {"type": "string", "description": "Target server — use the friendly NAME from list_cookbook_servers (e.g. 'gpu-box', 'workstation') or a raw user@host. Omit to use the cookbook's selected default server."},
"local": {"type": "boolean", "description": "Force download to THIS machine (localhost) instead of the default remote server."},
"include": {"type": "string", "description": "Glob filter for specific files (e.g. '*Q4_K_M*')"},
},
"required": ["repo_id"]
}
}
},
{
"type": "function",
"function": {
"name": "serve_model",
"description": "Start serving a model with vLLM, SGLang, llama.cpp, Ollama, MLX Image, or Diffusers. If `host` is omitted, defaults to the cookbook's selected server (not localhost). For MLX image models on Apple Silicon use `python3 scripts/mlx_image_server.py --model <repo> --port 8100`; for non-MLX image/inpainting/diffusion models use `python3 scripts/diffusion_server.py --model <repo> --port 8100`. Never serve image models with `mlx_lm.server`; that is only for text/chat MLX models. After launching, call list_served_models to check readiness/errors; if it reports a diagnosis with retry suggestions, retry via serve_model using the suggested adjusted cmd.",
"parameters": {
"type": "object",
"properties": {
"repo_id": {"type": "string", "description": "Model repo (e.g. 'Qwen/Qwen3-8B')"},
"cmd": {"type": "string", "description": "Full serve command (e.g. 'vllm serve <repo> --port 8000 --tp 2', 'python3 -m sglang.launch_server --model-path <repo> --port 30000', for MLX image models: 'python3 scripts/mlx_image_server.py --model <repo> --port 8100', or for non-MLX image models: 'python3 scripts/diffusion_server.py --model <repo> --port 8100')"},
"host": {"type": "string", "description": "Target server — friendly NAME from list_cookbook_servers (e.g. 'gpu-box', 'workstation') or raw user@host. Omit to use the cookbook's selected default."},
"local": {"type": "boolean", "description": "Force serve on THIS machine instead of the default remote server."},
},
"required": ["repo_id", "cmd"]
}
}
},
{
"type": "function",
"function": {
"name": "list_served_models",
"description": "List currently running model servers with status, model name, port, throughput, and structured Cookbook diagnoses. If a serve failed, this includes recent logs plus retry suggestions/adjusted commands the agent can use with serve_model.",
"parameters": {"type": "object", "properties": {}}
}
},
{
"type": "function",
"function": {
"name": "stop_served_model",
"description": "Stop a running model server.",
"parameters": {
"type": "object",
"properties": {
"session_id": {"type": "string", "description": "Tmux session ID of the server to stop"},
},
"required": ["session_id"]
}
}
},
{
"type": "function",
"function": {
"name": "tail_serve_output",
"description": "Read the last N lines of a cookbook serve/download task's tmux pane. Use ONLY in this exact sequence: (1) the user asked to serve a model, (2) you launched it via serve_model, (3) list_served_models reports the NEW task as crashed/error, (4) call tail_serve_output on the new sessionId to find the root cause, (5) call serve_model again with adjusted flags. DO NOT call this on old stopped/completed download tasks — they are historical and won't tell you anything about the current attempt. DO NOT investigate past failures before launching; the environment may have changed since.",
"parameters": {
"type": "object",
"properties": {
"session_id": {"type": "string", "description": "Tmux session id from list_served_models (e.g. 'serve-abc12345', 'cookbook-a1b2c3d4')."},
"tail": {"type": "integer", "description": "How many lines of pane scrollback to fetch (default 300, max 4000). Bump this if the error in the visible tail references an earlier line ('see root cause above')."},
},
"required": ["session_id"]
}
}
},
{
"type": "function",
"function": {
"name": "list_downloads",
"description": "List in-progress model downloads in the Cookbook. Shows each download's model name, phase, percent (if available), session ID, and remote host.",
"parameters": {"type": "object", "properties": {}}
}
},
{
"type": "function",
"function": {
"name": "cancel_download",
"description": "Cancel an in-progress model download by killing its tmux session. Use list_downloads first to get the session_id.",
"parameters": {
"type": "object",
"properties": {
"session_id": {"type": "string", "description": "Tmux session ID from list_downloads (e.g. 'cookbook-a1b2c3d4')"},
},
"required": ["session_id"]
}
}
},
{
"type": "function",
"function": {
"name": "search_hf_models",
"description": "Search HuggingFace for models matching a query. Returns a ranked list of repo IDs, sizes (when available), and download counts. Use this when the user wants to find a model to download.",
"parameters": {
"type": "object",
"properties": {
"query": {"type": "string", "description": "Search terms (e.g. 'Qwen 8B', 'flux', 'llama-3 instruct')"},
"limit": {"type": "integer", "description": "Max results (default 10)"},
},
"required": []
}
}
},
{
"type": "function",
"function": {
"name": "list_cookbook_servers",
"description": "List the cookbook's configured servers (remote GPU boxes + local) and the current default host. Call this before download_model/serve_model when the user didn't specify a host, so models go to the right machine (where the GPUs and model cache are) instead of localhost. If multiple servers and intent is ambiguous, show them and ask the user which.",
"parameters": {"type": "object", "properties": {}}
}
},
{
"type": "function",
"function": {
"name": "list_serve_presets",
"description": "List saved Cookbook serve presets. Each preset is a launch template (name, model, host, port, tmux cmd) the user previously saved from the UI. Call this BEFORE raw serve_model when the user asks to launch a model by name manually.",
"parameters": {"type": "object", "properties": {}}
}
},
{
"type": "function",
"function": {
"name": "adopt_served_model",
"description": "Register an existing tmux model server (started manually or outside the cookbook flow) into Cookbook tracking, AND add it as a chat endpoint. Use when the user (or you) launched something via ssh+tmux and now want it visible in the UI / stoppable via stop_served_model / usable in the model picker. Verifies the tmux session + port respond before adding.",
"parameters": {
"type": "object",
"properties": {
"host": {"type": "string", "description": "Remote host in user@host form (e.g. 'user@192.0.2.10'). Omit for localhost."},
"tmux_session": {"type": "string", "description": "Existing tmux session name (e.g. 'minimax-m27')"},
"model": {"type": "string", "description": "Model repo_id or display name (e.g. 'cyankiwi/MiniMax-M2.7-AWQ-4bit')"},
"port": {"type": "integer", "description": "Port the server is listening on (default 8000)"},
"name": {"type": "string", "description": "Optional display name (defaults to model basename)"},
"add_endpoint": {"type": "boolean", "description": "Also register as a chat endpoint (default true)"}
},
"required": ["tmux_session", "model"]
}
}
},
{
"type": "function",
"function": {
"name": "serve_preset",
"description": "Launch a saved Cookbook serve preset by name. Reuses the exact tmux command + host the user saved before. This is the preferred way to start a known model (SD3.5, vLLM presets, etc.) — don't fabricate launch commands when a preset exists.",
"parameters": {
"type": "object",
"properties": {
"name": {"type": "string", "description": "Preset name (exact or case-insensitive substring of one returned by list_serve_presets)"},
},
"required": ["name"]
}
}
},
{
"type": "function",
"function": {
"name": "list_cached_models",