ask-tools 0.5.0 → 0.6.0
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 +32 -0
- data/lib/ask/tools/tool.rb +56 -0
- data/lib/ask/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aff9f4752095dc3224f21ed08a1bc6768ff211af1f48dcfc51bb1b7c41cab0e3
|
|
4
|
+
data.tar.gz: acccd4fc9f40e57520e51c55cb71faf302dfd05fa4c7ca4159ffacf4da8b8d19
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5f37ccab34db3b16d504eb980830dae8ae1acb27c9de568fd3654a4da8604efcf5e27d6b917f280a74c4e6d3815862d54ebcd4bb6e9d2395ecbde0c3aa5730f3
|
|
7
|
+
data.tar.gz: ca97d4e8122b3d3ae161318f23780b0539c64d450d746a05e88fe56ab32a791ed3d161568ad8288d3d8ef4913a0b7e3bc7812e9c90ab68bb87df1630634bd20c
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
## [0.6.0] — 2026-08-06
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- **`Ask::Tool.approval_required` — declare that a tool needs human approval.**
|
|
6
|
+
Combined with `Ask::Agent::ApprovalQueue` (ask-agent), calls to the tool are
|
|
7
|
+
queued instead of executed — the agent gets a pending result and continues,
|
|
8
|
+
and the tool only runs after a human approves it. Defaults to false; the
|
|
9
|
+
flag is not inherited by subclasses.
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
class SendEmail < Ask::Tool
|
|
13
|
+
approval_required true
|
|
14
|
+
def execute(to:, body:) ... end
|
|
15
|
+
end
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- **`Ask::Tool.auto_approvable` — declare that a tool may be auto-approved.**
|
|
19
|
+
A per-action verdict only: the session's user-enabled rule is still the
|
|
20
|
+
binding gate (dual signal). A tool that requires approval but is NOT marked
|
|
21
|
+
auto-approvable always queues for human review.
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
class Ping < Ask::Tool
|
|
25
|
+
approval_required true
|
|
26
|
+
auto_approvable true
|
|
27
|
+
def execute ... end
|
|
28
|
+
end
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- Instance predicates `#approval_required?` and `#auto_approvable?`.
|
|
32
|
+
|
|
1
33
|
## [0.5.0] — 2026-08-03
|
|
2
34
|
|
|
3
35
|
### Changed
|
data/lib/ask/tools/tool.rb
CHANGED
|
@@ -21,6 +21,8 @@ module Ask
|
|
|
21
21
|
subclass.instance_variable_set(:@parameters, {})
|
|
22
22
|
subclass.instance_variable_set(:@params_schema_definition, nil)
|
|
23
23
|
subclass.instance_variable_set(:@tool_name, nil)
|
|
24
|
+
subclass.instance_variable_set(:@approval_required, nil)
|
|
25
|
+
subclass.instance_variable_set(:@auto_approvable, nil)
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
def description(text = nil)
|
|
@@ -41,6 +43,49 @@ module Ask
|
|
|
41
43
|
end
|
|
42
44
|
end
|
|
43
45
|
|
|
46
|
+
# Declare that calling this tool requires human approval.
|
|
47
|
+
#
|
|
48
|
+
# The tool is still registered and described to the LLM normally, but
|
|
49
|
+
# when an agent session runs with an approval queue enabled, calls to
|
|
50
|
+
# it are queued instead of executed — the agent gets a pending result,
|
|
51
|
+
# and the tool only runs after a human approves it.
|
|
52
|
+
#
|
|
53
|
+
# Called with no argument returns the current value (default false).
|
|
54
|
+
#
|
|
55
|
+
# @example
|
|
56
|
+
# class SendEmail < Ask::Tool
|
|
57
|
+
# approval_required true
|
|
58
|
+
# def execute(to:, body:) ... end
|
|
59
|
+
# end
|
|
60
|
+
#
|
|
61
|
+
# @param value [Boolean, nil]
|
|
62
|
+
# @return [Boolean]
|
|
63
|
+
def approval_required(value = :_no_arg_given)
|
|
64
|
+
if value == :_no_arg_given
|
|
65
|
+
@approval_required == true
|
|
66
|
+
else
|
|
67
|
+
@approval_required = !!value
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Declare that this tool may be auto-approved when the session's
|
|
72
|
+
# approval policy has auto-approval enabled for it. This is a
|
|
73
|
+
# per-action verdict only — the session-level user rule is still the
|
|
74
|
+
# binding gate. A tool that requires approval but is NOT marked
|
|
75
|
+
# auto-approvable always queues for human review.
|
|
76
|
+
#
|
|
77
|
+
# Called with no argument returns the current value (default false).
|
|
78
|
+
#
|
|
79
|
+
# @param value [Boolean, nil]
|
|
80
|
+
# @return [Boolean]
|
|
81
|
+
def auto_approvable(value = :_no_arg_given)
|
|
82
|
+
if value == :_no_arg_given
|
|
83
|
+
@auto_approvable == true
|
|
84
|
+
else
|
|
85
|
+
@auto_approvable = !!value
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
44
89
|
def param(name, type:, desc: nil, description: nil, required: true)
|
|
45
90
|
type = type.to_s.downcase.to_sym
|
|
46
91
|
validate_param_type!(type, name)
|
|
@@ -149,6 +194,17 @@ module Ask
|
|
|
149
194
|
self.class.parameters
|
|
150
195
|
end
|
|
151
196
|
|
|
197
|
+
# @return [Boolean] whether calling this tool requires human approval
|
|
198
|
+
def approval_required?
|
|
199
|
+
self.class.approval_required
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# @return [Boolean] whether this tool may be auto-approved under a
|
|
203
|
+
# session-level auto-approval rule
|
|
204
|
+
def auto_approvable?
|
|
205
|
+
self.class.auto_approvable
|
|
206
|
+
end
|
|
207
|
+
|
|
152
208
|
def call(args = {}, abort_controller = nil)
|
|
153
209
|
normalized = normalize_args(args)
|
|
154
210
|
validation = validate(normalized)
|
data/lib/ask/version.rb
CHANGED