-
Notifications
You must be signed in to change notification settings - Fork 210
Expand file tree
/
Copy pathagent_tools.py
More file actions
3357 lines (3122 loc) · 125 KB
/
agent_tools.py
File metadata and controls
3357 lines (3122 loc) · 125 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
from __future__ import annotations
import hashlib
import json
import os
import re
import selectors
import subprocess
import time
import urllib.error
import urllib.parse
import urllib.request
from dataclasses import dataclass, field
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, Iterator, Union
from .agent_types import AgentPermissions, AgentRuntimeConfig, ToolExecutionResult
from .session_env_vars import get_session_env_vars
if TYPE_CHECKING:
from .account_runtime import AccountRuntime
from .ask_user_runtime import AskUserRuntime
from .config_runtime import ConfigRuntime
from .lsp_runtime import LSPRuntime
from .mcp_runtime import MCPRuntime
from .plan_runtime import PlanRuntime
from .remote_runtime import RemoteRuntime
from .remote_trigger_runtime import RemoteTriggerRuntime
from .search_runtime import SearchRuntime
from .task_runtime import TaskRuntime
from .team_runtime import TeamRuntime
from .workflow_runtime import WorkflowRuntime
from .worktree_runtime import WorktreeRuntime
class ToolPermissionError(RuntimeError):
"""Raised when the runtime configuration does not allow a tool action."""
class ToolExecutionError(RuntimeError):
"""Raised when a tool cannot complete because of invalid input or state."""
@dataclass(frozen=True)
class ToolExecutionContext:
root: Path
command_timeout_seconds: float
max_output_chars: int
permissions: AgentPermissions
extra_env: dict[str, str] = field(default_factory=dict)
tool_registry: dict[str, 'AgentTool'] | None = None
search_runtime: 'SearchRuntime | None' = None
account_runtime: 'AccountRuntime | None' = None
ask_user_runtime: 'AskUserRuntime | None' = None
config_runtime: 'ConfigRuntime | None' = None
lsp_runtime: 'LSPRuntime | None' = None
mcp_runtime: 'MCPRuntime | None' = None
remote_runtime: 'RemoteRuntime | None' = None
remote_trigger_runtime: 'RemoteTriggerRuntime | None' = None
plan_runtime: 'PlanRuntime | None' = None
task_runtime: 'TaskRuntime | None' = None
team_runtime: 'TeamRuntime | None' = None
workflow_runtime: 'WorkflowRuntime | None' = None
worktree_runtime: 'WorktreeRuntime | None' = None
ToolHandler = Callable[
[dict[str, Any], ToolExecutionContext],
Union[str, tuple[str, dict[str, Any]]],
]
@dataclass(frozen=True)
class AgentTool:
name: str
description: str
parameters: dict[str, Any]
handler: ToolHandler
def to_openai_tool(self) -> dict[str, object]:
return {
'type': 'function',
'function': {
'name': self.name,
'description': self.description,
'parameters': self.parameters,
},
}
def execute(self, arguments: dict[str, Any], context: ToolExecutionContext) -> ToolExecutionResult:
try:
result = self.handler(arguments, context)
if isinstance(result, tuple):
content, metadata = result
else:
content, metadata = result, {}
return ToolExecutionResult(name=self.name, ok=True, content=content, metadata=metadata)
except ToolPermissionError as exc:
return ToolExecutionResult(
name=self.name,
ok=False,
content=str(exc),
metadata={'error_kind': 'permission_denied'},
)
except (ToolExecutionError, OSError, subprocess.SubprocessError) as exc:
return ToolExecutionResult(
name=self.name,
ok=False,
content=str(exc),
metadata={'error_kind': 'tool_execution_error'},
)
@dataclass(frozen=True)
class ToolStreamUpdate:
kind: str
content: str = ''
stream: str | None = None
result: ToolExecutionResult | None = None
metadata: dict[str, Any] = field(default_factory=dict)
def build_tool_context(
config: AgentRuntimeConfig,
*,
extra_env: dict[str, str] | None = None,
tool_registry: dict[str, AgentTool] | None = None,
search_runtime: 'SearchRuntime | None' = None,
account_runtime: 'AccountRuntime | None' = None,
ask_user_runtime: 'AskUserRuntime | None' = None,
config_runtime: 'ConfigRuntime | None' = None,
lsp_runtime: 'LSPRuntime | None' = None,
mcp_runtime: 'MCPRuntime | None' = None,
remote_runtime: 'RemoteRuntime | None' = None,
remote_trigger_runtime: 'RemoteTriggerRuntime | None' = None,
plan_runtime: 'PlanRuntime | None' = None,
task_runtime: 'TaskRuntime | None' = None,
team_runtime: 'TeamRuntime | None' = None,
workflow_runtime: 'WorkflowRuntime | None' = None,
worktree_runtime: 'WorktreeRuntime | None' = None,
) -> ToolExecutionContext:
return ToolExecutionContext(
root=config.cwd.resolve(),
command_timeout_seconds=config.command_timeout_seconds,
max_output_chars=config.max_output_chars,
permissions=config.permissions,
extra_env=dict(extra_env or {}),
tool_registry=tool_registry,
search_runtime=search_runtime,
account_runtime=account_runtime,
ask_user_runtime=ask_user_runtime,
config_runtime=config_runtime,
lsp_runtime=lsp_runtime,
mcp_runtime=mcp_runtime,
remote_runtime=remote_runtime,
remote_trigger_runtime=remote_trigger_runtime,
plan_runtime=plan_runtime,
task_runtime=task_runtime,
team_runtime=team_runtime,
workflow_runtime=workflow_runtime,
worktree_runtime=worktree_runtime,
)
def execute_tool(
tool_registry: dict[str, AgentTool],
name: str,
arguments: dict[str, Any],
context: ToolExecutionContext,
) -> ToolExecutionResult:
tool = tool_registry.get(name)
if tool is None:
return ToolExecutionResult(
name=name,
ok=False,
content=f'Unknown tool: {name}',
)
return tool.execute(arguments, context)
def execute_tool_streaming(
tool_registry: dict[str, AgentTool],
name: str,
arguments: dict[str, Any],
context: ToolExecutionContext,
) -> Iterator[ToolStreamUpdate]:
tool = tool_registry.get(name)
if tool is None:
yield ToolStreamUpdate(
kind='result',
result=ToolExecutionResult(
name=name,
ok=False,
content=f'Unknown tool: {name}',
),
)
return
if name == 'bash':
yield from _stream_bash(arguments, context)
return
result = tool.execute(arguments, context)
if result.ok and result.content and name != 'delegate_agent':
yield from _stream_static_text_result(result)
return
yield ToolStreamUpdate(kind='result', result=result)
def default_tool_registry() -> dict[str, AgentTool]:
tools = [
AgentTool(
name='list_dir',
description='List files and directories under a workspace path.',
parameters={
'type': 'object',
'properties': {
'path': {'type': 'string', 'description': 'Relative path from workspace root.'},
'max_entries': {'type': 'integer', 'minimum': 1, 'maximum': 500},
},
},
handler=_list_dir,
),
AgentTool(
name='read_file',
description='Read the contents of a UTF-8 text file inside the workspace.',
parameters={
'type': 'object',
'properties': {
'path': {'type': 'string', 'description': 'Relative file path from workspace root.'},
'start_line': {'type': 'integer', 'minimum': 1},
'end_line': {'type': 'integer', 'minimum': 1},
},
'required': ['path'],
},
handler=_read_file,
),
AgentTool(
name='write_file',
description='Write a complete file inside the workspace. Creates parent directories when needed.',
parameters={
'type': 'object',
'properties': {
'path': {'type': 'string'},
'content': {'type': 'string'},
},
'required': ['path', 'content'],
},
handler=_write_file,
),
AgentTool(
name='edit_file',
description='Replace text inside a workspace file using exact string matching.',
parameters={
'type': 'object',
'properties': {
'path': {'type': 'string'},
'old_text': {'type': 'string'},
'new_text': {'type': 'string'},
'replace_all': {'type': 'boolean'},
},
'required': ['path', 'old_text', 'new_text'],
},
handler=_edit_file,
),
AgentTool(
name='notebook_edit',
description='Edit a Jupyter notebook cell by replacing or appending source in a .ipynb file.',
parameters={
'type': 'object',
'properties': {
'path': {'type': 'string'},
'cell_index': {'type': 'integer', 'minimum': 0},
'source': {'type': 'string'},
'cell_type': {'type': 'string'},
'create_cell': {'type': 'boolean'},
},
'required': ['path', 'cell_index', 'source'],
},
handler=_notebook_edit,
),
AgentTool(
name='glob_search',
description='Find files matching a glob pattern inside the workspace.',
parameters={
'type': 'object',
'properties': {
'pattern': {'type': 'string'},
},
'required': ['pattern'],
},
handler=_glob_search,
),
AgentTool(
name='grep_search',
description='Search for a string or regular expression inside workspace files.',
parameters={
'type': 'object',
'properties': {
'pattern': {'type': 'string'},
'path': {'type': 'string'},
'literal': {'type': 'boolean'},
'max_matches': {'type': 'integer', 'minimum': 1, 'maximum': 500},
},
'required': ['pattern'],
},
handler=_grep_search,
),
AgentTool(
name='bash',
description='Run a shell command in the workspace. Use sparingly and prefer dedicated file tools for edits.',
parameters={
'type': 'object',
'properties': {
'command': {'type': 'string'},
},
'required': ['command'],
},
handler=_run_bash,
),
AgentTool(
name='LSP',
description='Use local LSP-style code intelligence for definitions, references, hover, symbols, and call hierarchy.',
parameters={
'type': 'object',
'properties': {
'operation': {
'type': 'string',
'enum': [
'goToDefinition',
'findReferences',
'hover',
'documentSymbol',
'workspaceSymbol',
'goToImplementation',
'prepareCallHierarchy',
'incomingCalls',
'outgoingCalls',
],
},
'file_path': {'type': 'string'},
'line': {'type': 'integer', 'minimum': 1},
'character': {'type': 'integer', 'minimum': 1},
'query': {'type': 'string'},
'max_results': {'type': 'integer', 'minimum': 1, 'maximum': 200},
},
'required': ['operation', 'file_path', 'line', 'character'],
},
handler=_lsp_query,
),
AgentTool(
name='web_fetch',
description='Fetch a text resource from http, https, or file URLs and return a truncated text response.',
parameters={
'type': 'object',
'properties': {
'url': {'type': 'string'},
'max_chars': {'type': 'integer', 'minimum': 1, 'maximum': 100000},
},
'required': ['url'],
},
handler=_web_fetch,
),
AgentTool(
name='search_status',
description='Show the local search runtime summary or a specific configured search provider.',
parameters={
'type': 'object',
'properties': {
'provider': {'type': 'string'},
},
},
handler=_search_status,
),
AgentTool(
name='search_list_providers',
description='List configured local search providers from workspace search manifests and environment configuration.',
parameters={
'type': 'object',
'properties': {
'query': {'type': 'string'},
'max_providers': {'type': 'integer', 'minimum': 1, 'maximum': 200},
},
},
handler=_search_list_providers,
),
AgentTool(
name='search_activate_provider',
description='Set the active local search provider for the current workspace.',
parameters={
'type': 'object',
'properties': {
'provider': {'type': 'string'},
},
'required': ['provider'],
},
handler=_search_activate_provider,
),
AgentTool(
name='web_search',
description='Run a real web search against a configured search backend and return ranked results.',
parameters={
'type': 'object',
'properties': {
'query': {'type': 'string'},
'provider': {'type': 'string'},
'domains': {
'type': 'array',
'items': {'type': 'string'},
},
'max_results': {'type': 'integer', 'minimum': 1, 'maximum': 20},
},
'required': ['query'],
},
handler=_web_search,
),
AgentTool(
name='tool_search',
description='Search the active tool registry by tool name or description.',
parameters={
'type': 'object',
'properties': {
'query': {'type': 'string'},
'max_results': {'type': 'integer', 'minimum': 1, 'maximum': 100},
},
'required': ['query'],
},
handler=_tool_search,
),
AgentTool(
name='sleep',
description='Pause execution briefly for bounded local wait flows.',
parameters={
'type': 'object',
'properties': {
'seconds': {'type': 'number', 'minimum': 0.0, 'maximum': 5.0},
},
'required': ['seconds'],
},
handler=_sleep,
),
AgentTool(
name='ask_user_question',
description='Request an answer from the local ask-user runtime using queued or interactive answers.',
parameters={
'type': 'object',
'properties': {
'question': {'type': 'string'},
'header': {'type': 'string'},
'question_id': {'type': 'string'},
'choices': {
'type': 'array',
'items': {'type': 'string'},
},
'allow_free_text': {'type': 'boolean'},
},
'required': ['question'],
},
handler=_ask_user_question,
),
AgentTool(
name='account_status',
description='Show local account runtime summary or a specific configured account profile.',
parameters={
'type': 'object',
'properties': {
'profile': {'type': 'string'},
},
},
handler=_account_status,
),
AgentTool(
name='account_list_profiles',
description='List configured local account profiles from workspace account manifests.',
parameters={
'type': 'object',
'properties': {
'query': {'type': 'string'},
'max_profiles': {'type': 'integer', 'minimum': 1, 'maximum': 200},
},
},
handler=_account_list_profiles,
),
AgentTool(
name='account_login',
description='Activate a local account profile or ephemeral account identity and persist it as the active account session.',
parameters={
'type': 'object',
'properties': {
'target': {'type': 'string'},
'provider': {'type': 'string'},
'auth_mode': {'type': 'string'},
},
'required': ['target'],
},
handler=_account_login,
),
AgentTool(
name='account_logout',
description='Clear the active local account session state.',
parameters={
'type': 'object',
'properties': {
'reason': {'type': 'string'},
},
},
handler=_account_logout,
),
AgentTool(
name='config_list',
description='List merged or source-specific workspace config keys from local settings files.',
parameters={
'type': 'object',
'properties': {
'source': {'type': 'string'},
'prefix': {'type': 'string'},
'limit': {'type': 'integer', 'minimum': 1, 'maximum': 500},
},
},
handler=_config_list,
),
AgentTool(
name='config_get',
description='Read a merged or source-specific workspace config value by dotted key path.',
parameters={
'type': 'object',
'properties': {
'key_path': {'type': 'string'},
'source': {'type': 'string'},
},
'required': ['key_path'],
},
handler=_config_get,
),
AgentTool(
name='config_set',
description='Write a workspace config value by dotted key path into a chosen config source.',
parameters={
'type': 'object',
'properties': {
'key_path': {'type': 'string'},
'source': {'type': 'string'},
'value': {
'oneOf': [
{'type': 'string'},
{'type': 'number'},
{'type': 'integer'},
{'type': 'boolean'},
{'type': 'array'},
{'type': 'object'},
{'type': 'null'},
]
},
},
'required': ['key_path', 'value'],
},
handler=_config_set,
),
AgentTool(
name='mcp_list_resources',
description='List local MCP resources discovered from workspace MCP manifests.',
parameters={
'type': 'object',
'properties': {
'query': {'type': 'string'},
'max_resources': {'type': 'integer', 'minimum': 1, 'maximum': 200},
},
},
handler=_mcp_list_resources,
),
AgentTool(
name='mcp_read_resource',
description='Read a local MCP resource by URI from workspace MCP manifests.',
parameters={
'type': 'object',
'properties': {
'uri': {'type': 'string'},
'max_chars': {'type': 'integer', 'minimum': 1, 'maximum': 50000},
},
'required': ['uri'],
},
handler=_mcp_read_resource,
),
AgentTool(
name='mcp_list_tools',
description='List MCP tools exposed by configured MCP servers over real transport.',
parameters={
'type': 'object',
'properties': {
'query': {'type': 'string'},
'server': {'type': 'string'},
'max_tools': {'type': 'integer', 'minimum': 1, 'maximum': 200},
},
},
handler=_mcp_list_tools,
),
AgentTool(
name='mcp_call_tool',
description='Call an MCP tool exposed by a configured MCP server over real transport.',
parameters={
'type': 'object',
'properties': {
'tool_name': {'type': 'string'},
'server': {'type': 'string'},
'arguments': {'type': 'object'},
'max_chars': {'type': 'integer', 'minimum': 1, 'maximum': 50000},
},
'required': ['tool_name'],
},
handler=_mcp_call_tool,
),
AgentTool(
name='remote_status',
description='Show the local remote runtime summary or a specific configured remote profile.',
parameters={
'type': 'object',
'properties': {
'profile': {'type': 'string'},
},
},
handler=_remote_status,
),
AgentTool(
name='remote_list_profiles',
description='List configured local remote profiles from workspace remote manifests.',
parameters={
'type': 'object',
'properties': {
'query': {'type': 'string'},
'mode': {'type': 'string'},
'max_profiles': {'type': 'integer', 'minimum': 1, 'maximum': 200},
},
},
handler=_remote_list_profiles,
),
AgentTool(
name='remote_connect',
description='Activate a local remote target or configured remote profile and persist it as the active connection.',
parameters={
'type': 'object',
'properties': {
'target': {'type': 'string'},
'mode': {'type': 'string'},
},
'required': ['target'],
},
handler=_remote_connect,
),
AgentTool(
name='remote_disconnect',
description='Clear the active local remote connection state.',
parameters={
'type': 'object',
'properties': {
'reason': {'type': 'string'},
},
},
handler=_remote_disconnect,
),
AgentTool(
name='worktree_status',
description='Show the current managed git worktree session status.',
parameters={
'type': 'object',
'properties': {},
},
handler=_worktree_status,
),
AgentTool(
name='worktree_enter',
description='Create an isolated git worktree and switch the current agent session into it.',
parameters={
'type': 'object',
'properties': {
'name': {'type': 'string'},
},
},
handler=_worktree_enter,
),
AgentTool(
name='worktree_exit',
description='Leave the active managed worktree session and optionally remove the worktree.',
parameters={
'type': 'object',
'properties': {
'action': {'type': 'string'},
'discard_changes': {'type': 'boolean'},
},
},
handler=_worktree_exit,
),
AgentTool(
name='workflow_list',
description='List local workflow definitions discovered from workspace workflow manifests.',
parameters={
'type': 'object',
'properties': {
'query': {'type': 'string'},
'max_workflows': {'type': 'integer', 'minimum': 1, 'maximum': 200},
},
},
handler=_workflow_list,
),
AgentTool(
name='workflow_get',
description='Show one local workflow definition by name.',
parameters={
'type': 'object',
'properties': {
'workflow_name': {'type': 'string'},
},
'required': ['workflow_name'],
},
handler=_workflow_get,
),
AgentTool(
name='workflow_run',
description='Record and render a local workflow execution request from a workflow manifest.',
parameters={
'type': 'object',
'properties': {
'workflow_name': {'type': 'string'},
'arguments': {'type': 'object'},
},
'required': ['workflow_name'],
},
handler=_workflow_run,
),
AgentTool(
name='remote_trigger',
description='List, inspect, create, update, or run local remote triggers similar to the npm remote trigger tool.',
parameters={
'type': 'object',
'properties': {
'action': {'type': 'string'},
'trigger_id': {'type': 'string'},
'body': {'type': 'object'},
'query': {'type': 'string'},
'max_triggers': {'type': 'integer', 'minimum': 1, 'maximum': 200},
},
'required': ['action'],
},
handler=_remote_trigger,
),
AgentTool(
name='plan_get',
description='Show the current local runtime plan.',
parameters={
'type': 'object',
'properties': {},
},
handler=_plan_get,
),
AgentTool(
name='update_plan',
description='Replace the current local runtime plan with a structured multi-step plan and optionally sync it to tasks.',
parameters={
'type': 'object',
'properties': {
'explanation': {'type': 'string'},
'sync_tasks': {'type': 'boolean'},
'items': {
'type': 'array',
'items': {
'type': 'object',
'properties': {
'step': {'type': 'string'},
'status': {'type': 'string'},
'task_id': {'type': 'string'},
'description': {'type': 'string'},
'priority': {'type': 'string'},
'active_form': {'type': 'string'},
'owner': {'type': 'string'},
'depends_on': {
'type': 'array',
'items': {'type': 'string'},
},
},
'required': ['step'],
},
},
},
'required': ['items'],
},
handler=_update_plan,
),
AgentTool(
name='plan_clear',
description='Clear the current local runtime plan and optionally sync the task runtime.',
parameters={
'type': 'object',
'properties': {
'sync_tasks': {'type': 'boolean'},
},
},
handler=_plan_clear,
),
AgentTool(
name='task_next',
description='Show the next actionable tasks from the local runtime task list.',
parameters={
'type': 'object',
'properties': {
'max_tasks': {'type': 'integer', 'minimum': 1, 'maximum': 50},
},
},
handler=_task_next,
),
AgentTool(
name='team_list',
description='List locally configured collaboration teams.',
parameters={
'type': 'object',
'properties': {
'query': {'type': 'string'},
'max_teams': {'type': 'integer', 'minimum': 1, 'maximum': 200},
},
},
handler=_team_list,
),
AgentTool(
name='team_get',
description='Show a locally configured collaboration team by name.',
parameters={
'type': 'object',
'properties': {
'team_name': {'type': 'string'},
},
'required': ['team_name'],
},
handler=_team_get,
),
AgentTool(
name='team_create',
description='Create a locally stored collaboration team.',
parameters={
'type': 'object',
'properties': {
'team_name': {'type': 'string'},
'description': {'type': 'string'},
'members': {'type': 'array', 'items': {'type': 'string'}},
'metadata': {'type': 'object'},
},
'required': ['team_name'],
},
handler=_team_create,
),
AgentTool(
name='team_delete',
description='Delete a locally stored collaboration team and its recorded messages.',
parameters={
'type': 'object',
'properties': {
'team_name': {'type': 'string'},
},
'required': ['team_name'],
},
handler=_team_delete,
),
AgentTool(
name='send_message',
description='Send a local collaboration message to a team or teammate and persist it in the team runtime.',
parameters={
'type': 'object',
'properties': {
'team_name': {'type': 'string'},
'message': {'type': 'string'},
'sender': {'type': 'string'},
'recipient': {'type': 'string'},
'metadata': {'type': 'object'},
},
'required': ['team_name', 'message'],
},
handler=_send_message,
),
AgentTool(
name='team_messages',
description='Show locally recorded collaboration messages for all teams or one team.',
parameters={
'type': 'object',
'properties': {
'team_name': {'type': 'string'},
'limit': {'type': 'integer', 'minimum': 1, 'maximum': 200},
},
},
handler=_team_messages,
),
AgentTool(
name='task_list',
description='List locally stored runtime tasks.',
parameters={
'type': 'object',
'properties': {
'status': {'type': 'string'},
'owner': {'type': 'string'},
'actionable_only': {'type': 'boolean'},
'max_tasks': {'type': 'integer', 'minimum': 1, 'maximum': 200},
},
},
handler=_task_list,
),
AgentTool(
name='task_get',
description='Show a locally stored runtime task by id.',
parameters={
'type': 'object',
'properties': {
'task_id': {'type': 'string'},
},
'required': ['task_id'],
},
handler=_task_get,
),
AgentTool(
name='task_create',
description='Create a locally stored runtime task.',
parameters={
'type': 'object',
'properties': {
'title': {'type': 'string'},
'description': {'type': 'string'},
'status': {'type': 'string'},
'priority': {'type': 'string'},
'task_id': {'type': 'string'},
'active_form': {'type': 'string'},
'owner': {'type': 'string'},
'blocks': {'type': 'array', 'items': {'type': 'string'}},
'blocked_by': {'type': 'array', 'items': {'type': 'string'}},
'metadata': {'type': 'object'},
},
'required': ['title'],
},
handler=_task_create,
),
AgentTool(
name='task_update',
description='Update a locally stored runtime task by id.',
parameters={
'type': 'object',
'properties': {
'task_id': {'type': 'string'},
'title': {'type': 'string'},
'description': {'type': 'string'},
'status': {'type': 'string'},
'priority': {'type': 'string'},
'active_form': {'type': 'string'},
'owner': {'type': 'string'},
'blocks': {'type': 'array', 'items': {'type': 'string'}},
'blocked_by': {'type': 'array', 'items': {'type': 'string'}},
'metadata': {'type': 'object'},
},
'required': ['task_id'],
},
handler=_task_update,
),
AgentTool(
name='task_start',
description='Mark a task as in progress, or blocked if dependencies are unresolved.',
parameters={
'type': 'object',
'properties': {
'task_id': {'type': 'string'},
'owner': {'type': 'string'},
'active_form': {'type': 'string'},
},
'required': ['task_id'],
},
handler=_task_start,
),
AgentTool(
name='task_complete',
description='Mark a task as completed and release blocked dependents when possible.',
parameters={
'type': 'object',
'properties': {
'task_id': {'type': 'string'},
},
'required': ['task_id'],
},
handler=_task_complete,
),
AgentTool(
name='task_block',
description='Mark a task as blocked with optional dependencies and reason.',
parameters={
'type': 'object',
'properties': {
'task_id': {'type': 'string'},
'blocked_by': {'type': 'array', 'items': {'type': 'string'}},
'reason': {'type': 'string'},
},
'required': ['task_id'],
},
handler=_task_block,
),
AgentTool(
name='task_cancel',
description='Mark a task as cancelled with an optional reason.',
parameters={
'type': 'object',