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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56ac490231ae158243f39f33cb6344c4422829f93baa63738ef26a2f7e1b1ada
4
- data.tar.gz: 5dcdc9117b825cf4c6c8e7b1c7873b35c4a90bbbfc08d34cb89e982e52d0ca0d
3
+ metadata.gz: 988efe437821b4b14ef9df279c5fc9427890d44f5822e2bfe062aa133fa1d1d1
4
+ data.tar.gz: 8b4280e25274606e53c105852bb01faf483c1a64624048980d469d2f1c99826b
5
5
  SHA512:
6
- metadata.gz: e02775a7c2b6d39f1ee6d6961bdd103bbd33af2a085fca8427b7cea4ea47da47e286aa3e5726ee131ff6b50363ecddb8890dd90b388995d536baeca59b59de9a
7
- data.tar.gz: eb2f9d5aee1f97ccfb13ea4c8c66dedf8c58309a182476fc56b57720fc840bf8b4a1ed146dc3ce8124fe9254d7404561032fc9fe1e2626b3738d30b58454a1f8
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
 
@@ -3,7 +3,7 @@
3
3
  module Ask
4
4
  module Ruby
5
5
  module Harness
6
- VERSION = "0.3.14"
6
+ VERSION = "0.4.0"
7
7
  end
8
8
  end
9
9
  end
@@ -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
- # Resolve environment-specific permissions and wire into agent hooks
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
- def build_environment_hooks
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 {} unless env_mode
132
-
133
- perms = Ask::Permissions::Permissions.new(mode: env_mode)
134
- { before_tool: [perms.method(:before_tool_call)] }
135
- rescue ArgumentError => e
136
- warn "[ask-ruby-harness] Invalid environment mode: #{e.message}"
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.3.14
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.1.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.1.0
81
+ version: 0.2.0
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: sqlite3
84
84
  requirement: !ruby/object:Gem::Requirement