ask-ruby-harness 0.3.14 → 0.4.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 +23 -0
- data/README.md +23 -0
- data/lib/ask/ruby/harness/version.rb +1 -1
- data/lib/ask/ruby/harness.rb +28 -11
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 988efe437821b4b14ef9df279c5fc9427890d44f5822e2bfe062aa133fa1d1d1
|
|
4
|
+
data.tar.gz: 8b4280e25274606e53c105852bb01faf483c1a64624048980d469d2f1c99826b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c456006a02bc6b0bb8b052c31c3a0e60411544a7ac87339327bd87083606e174f027d425ab1f0718088361282fbd1231b7ed9b5ef7960f99c5d51a031c6dbb04
|
|
7
|
+
data.tar.gz: 3c81deb034aee13707429204ead2dbbc200875953f7aff37b953689c17328e678602820232950f8249f5e060a3751b9cb1bccc3666ffcca0165376da752b4f8b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
## [Unreleased]
|
|
2
|
+
|
|
3
|
+
## [0.4.0] - 2026-09-23
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- **Environment mode flows through Ask Agent approvals** — `agent_session`
|
|
8
|
+
now passes `configuration.effective_mode` as `approval: {mode: ...}` to
|
|
9
|
+
`Ask::Agent::Session` (merging and preserving caller `approval:` options)
|
|
10
|
+
instead of building `Ask::Permissions` `before_tool` hooks. The session
|
|
11
|
+
owns the shared policy, approval queue, and approvals
|
|
12
|
+
(`session.approval_queue` for `:ask_before_changes`). A caller-supplied
|
|
13
|
+
`approval[:mode]` that conflicts with the environment mode raises
|
|
14
|
+
`ArgumentError`; with no environment mode the caller's approval passes
|
|
15
|
+
through unchanged.
|
|
16
|
+
## [0.3.14] — 2026-09-23
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **Permissions now come from `ask-permissions`** — the harness reads its
|
|
21
|
+
environment permission modes and command allow/deny lists from the
|
|
22
|
+
`ask-permissions` gem instead of maintaining them locally.
|
|
23
|
+
|
|
1
24
|
## [0.3.2] — 2026-08-12
|
|
2
25
|
|
|
3
26
|
### Fixed
|
data/README.md
CHANGED
|
@@ -53,6 +53,29 @@ Ask::Ruby::Harness.discover_tools!
|
|
|
53
53
|
session = Ask::Ruby::Harness.agent_session(model: "gpt-4o")
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
The configured `env.mode` is passed to the Ask Agent session as its
|
|
57
|
+
approval mode (`approval: {mode: ...}`); the session owns the shared
|
|
58
|
+
policy, approval queue, and approvals. With `env.mode = :ask_before_changes`,
|
|
59
|
+
state-changing tool calls wait on `session.approval_queue` — the host
|
|
60
|
+
drains it and answers each request to let the agent continue:
|
|
61
|
+
|
|
62
|
+
```ruby
|
|
63
|
+
session = Ask::Ruby::Harness.agent_session
|
|
64
|
+
# while the agent runs:
|
|
65
|
+
queue = session.approval_queue
|
|
66
|
+
queue.pending_actions.each do |action|
|
|
67
|
+
if permitted?(action)
|
|
68
|
+
queue.approve(action.id)
|
|
69
|
+
else
|
|
70
|
+
queue.reject(action.id, feedback: "not permitted in this environment")
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Callers may pass their own `approval:` options through `agent_session`;
|
|
76
|
+
extra options are preserved, and a caller-supplied `approval[:mode]` that
|
|
77
|
+
conflicts with the environment mode raises `ArgumentError`.
|
|
78
|
+
|
|
56
79
|
The Rails edition (`ask-rails-harness`) mounts an agent at `/ask` and adds
|
|
57
80
|
framework-native tools (routes, engine) on top of this gem.
|
|
58
81
|
|
data/lib/ask/ruby/harness.rb
CHANGED
|
@@ -41,8 +41,7 @@ module Ask
|
|
|
41
41
|
tools = configuration.tools.map { |t| t.is_a?(Class) ? t.new : t }
|
|
42
42
|
prompt = extra.delete(:system_prompt) || configuration.system_prompt || default_system_prompt
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
hooks = build_environment_hooks
|
|
44
|
+
apply_environment_approval!(extra)
|
|
46
45
|
|
|
47
46
|
Ask::Agent::Session.new(
|
|
48
47
|
model: configuration.default_model,
|
|
@@ -50,7 +49,6 @@ module Ask
|
|
|
50
49
|
system_prompt: prompt,
|
|
51
50
|
tools: tools,
|
|
52
51
|
state: configuration.persistence_adapter,
|
|
53
|
-
hooks: hooks,
|
|
54
52
|
**extra
|
|
55
53
|
)
|
|
56
54
|
end
|
|
@@ -126,15 +124,34 @@ module Ask
|
|
|
126
124
|
|
|
127
125
|
private
|
|
128
126
|
|
|
129
|
-
|
|
127
|
+
# Normalize the caller's approval against the resolved environment
|
|
128
|
+
# mode: nil/true becomes {mode: env_mode}; a Hash merges, preserving
|
|
129
|
+
# all entries and rejecting only a different supplied :mode; an
|
|
130
|
+
# Ask::Permissions::ApprovalQueue becomes {queue:, mode:}; false or
|
|
131
|
+
# unsupported types raise ArgumentError. With no environment mode the
|
|
132
|
+
# caller's approval passes through unchanged.
|
|
133
|
+
def apply_environment_approval!(extra)
|
|
130
134
|
env_mode = configuration.effective_mode
|
|
131
|
-
return
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
return unless env_mode
|
|
136
|
+
|
|
137
|
+
approval = extra[:approval]
|
|
138
|
+
extra[:approval] =
|
|
139
|
+
case approval
|
|
140
|
+
when nil, true
|
|
141
|
+
{mode: env_mode}
|
|
142
|
+
when Hash
|
|
143
|
+
caller_mode = approval[:mode]
|
|
144
|
+
if caller_mode && caller_mode != env_mode
|
|
145
|
+
raise ArgumentError,
|
|
146
|
+
"conflicting approval mode: caller specified #{caller_mode.inspect}, " \
|
|
147
|
+
"environment config specifies #{env_mode.inspect}"
|
|
148
|
+
end
|
|
149
|
+
approval.merge(mode: env_mode)
|
|
150
|
+
when Ask::Permissions::ApprovalQueue
|
|
151
|
+
{queue: approval, mode: env_mode}
|
|
152
|
+
else
|
|
153
|
+
raise ArgumentError, "unsupported approval: #{approval.inspect}"
|
|
154
|
+
end
|
|
138
155
|
end
|
|
139
156
|
|
|
140
157
|
def prune_old_sessions
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ask-ruby-harness
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kaka Ruto
|
|
@@ -71,14 +71,14 @@ dependencies:
|
|
|
71
71
|
requirements:
|
|
72
72
|
- - ">="
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: 0.
|
|
74
|
+
version: 0.2.0
|
|
75
75
|
type: :runtime
|
|
76
76
|
prerelease: false
|
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
78
78
|
requirements:
|
|
79
79
|
- - ">="
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: 0.
|
|
81
|
+
version: 0.2.0
|
|
82
82
|
- !ruby/object:Gem::Dependency
|
|
83
83
|
name: sqlite3
|
|
84
84
|
requirement: !ruby/object:Gem::Requirement
|