ask-coding-providers 0.3.1 → 0.3.2
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/lib/ask/coding_providers/acp/adapter.rb +1 -1
- data/lib/ask/coding_providers/adapter.rb +1 -1
- data/lib/ask/coding_providers/ask_agent/adapter.rb +60 -18
- data/lib/ask/coding_providers/claude/adapter.rb +1 -1
- data/lib/ask/coding_providers/codex/adapter.rb +1 -1
- data/lib/ask/coding_providers/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: 5af7db1f38c3b4d11a223269116e1b7c83da716a6e5c4ef0120f321a9f566241
|
|
4
|
+
data.tar.gz: af4be91462e45a4b5fc07119976d098b439daae44714cdcfe302902bd4db5f64
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 06be52e4d472be0c6456842884cb3ccdeb07da10322683de138de6a638cb14e8ba198c5649f57eca1e17e142e752382234bdba8e971cacf664c96f49e821d3fb
|
|
7
|
+
data.tar.gz: 81beeba55e7d5b6cdd197d615f0f3926bf44ee36a87a781aba9197fe301e22ac7e7e72520fa6635f239fe266a9b13cdedc33450653ff47b8a1d3afcaa6d89215
|
|
@@ -64,7 +64,7 @@ module Ask
|
|
|
64
64
|
@client&.running? || false
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
def create_session(workspace_path, mode: nil)
|
|
67
|
+
def create_session(workspace_path, mode: nil, system_prompt: nil, **)
|
|
68
68
|
ensure_running
|
|
69
69
|
params = { cwd: workspace_path || @cwd }
|
|
70
70
|
session = @client.session_new(**params)
|
|
@@ -14,7 +14,7 @@ module Ask
|
|
|
14
14
|
# @param workspace_path [String] the working directory
|
|
15
15
|
# @param mode [String, nil] permission mode
|
|
16
16
|
# @return [String] the session ID
|
|
17
|
-
def create_session(workspace_path, mode: nil)
|
|
17
|
+
def create_session(workspace_path, mode: nil, system_prompt: nil, **)
|
|
18
18
|
raise NotImplementedError, "#{self.class} must implement #create_session"
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -149,7 +149,13 @@ module Ask
|
|
|
149
149
|
# @param model [String, nil] model override for this session
|
|
150
150
|
# @param system_prompt [String, nil] system prompt override for this
|
|
151
151
|
# session (takes precedence over any system_prompt in session_opts)
|
|
152
|
-
|
|
152
|
+
# @param agent [String, nil] declarative agent name (ask-agent
|
|
153
|
+
# convention: agents/<name>/agent.rb + instructions.md, discovered
|
|
154
|
+
# from the workspace's working directory). When given, the session
|
|
155
|
+
# is built via Ask::Agent.new so the definition's tools, skills,
|
|
156
|
+
# and instructions apply; the harness-level options (model,
|
|
157
|
+
# system_prompt, approval, plan mode, todos) still win.
|
|
158
|
+
def create_session(workspace_path, mode: nil, model: nil, system_prompt: nil, agent: nil)
|
|
153
159
|
ensure_started
|
|
154
160
|
sid = "sess_#{SecureRandom.uuid}"
|
|
155
161
|
@mutex.synchronize do
|
|
@@ -158,6 +164,7 @@ module Ask
|
|
|
158
164
|
mode: mode,
|
|
159
165
|
model: model || @model_id,
|
|
160
166
|
system_prompt: system_prompt,
|
|
167
|
+
agent: agent,
|
|
161
168
|
created_at: Time.now,
|
|
162
169
|
session: nil,
|
|
163
170
|
subscribers: [],
|
|
@@ -367,36 +374,71 @@ module Ask
|
|
|
367
374
|
# ── Session construction ──
|
|
368
375
|
|
|
369
376
|
def build_session(entry)
|
|
370
|
-
|
|
371
|
-
|
|
377
|
+
session = entry[:agent] ? build_agent_session(entry) : build_plain_session(entry)
|
|
378
|
+
session.on_event { |event| translate_event(entry, session, event) }
|
|
379
|
+
session
|
|
380
|
+
end
|
|
372
381
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
382
|
+
# Build a session from a declarative agent definition (ask-agent
|
|
383
|
+
# convention). The definition's tools, skills (agent_dir), and
|
|
384
|
+
# instructions apply; harness-level options win where set. Agents
|
|
385
|
+
# are discovered from the working directory (the harness runs the
|
|
386
|
+
# session inside its workspace).
|
|
387
|
+
#
|
|
388
|
+
# The emitting approval queue is passed through Ask::Agent.new's
|
|
389
|
+
# opts, so Session#build_approval wires it with the session's
|
|
390
|
+
# apply/reject/register callbacks — approval events stream exactly
|
|
391
|
+
# like the plain path.
|
|
392
|
+
def build_agent_session(entry)
|
|
393
|
+
queue = emitting_queue(entry)
|
|
394
|
+
opts = {
|
|
395
|
+
approval: approval_config(queue),
|
|
396
|
+
plan_mode: @plan_mode,
|
|
397
|
+
todos: @todos,
|
|
398
|
+
max_turns: @max_turns,
|
|
399
|
+
# Caller options win over the definition; a nil model lets the
|
|
400
|
+
# definition's own model apply.
|
|
401
|
+
model: (entry[:model] unless entry[:model] == @model_id)
|
|
402
|
+
}.compact
|
|
403
|
+
opts[:system_prompt] = entry[:system_prompt] if entry[:system_prompt]
|
|
404
|
+
Ask::Agent.new(entry[:agent], **opts)
|
|
405
|
+
end
|
|
377
406
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
when APPROVAL_OFF then nil
|
|
383
|
-
else
|
|
384
|
-
raise ArgumentError, "approval must be one of #{APPROVAL_MODES.inspect}, got #{@approval.inspect}"
|
|
385
|
-
end
|
|
407
|
+
# Build the default session (no declarative agent).
|
|
408
|
+
def build_plain_session(entry)
|
|
409
|
+
prompt = entry[:system_prompt] || @session_opts[:system_prompt]
|
|
410
|
+
chat = build_chat(entry[:model], prompt)
|
|
386
411
|
|
|
387
412
|
Ask::Agent::Session.new(
|
|
388
413
|
model: chat,
|
|
389
414
|
tools: @tools,
|
|
390
415
|
max_turns: @max_turns,
|
|
391
|
-
approval:
|
|
416
|
+
approval: approval_config(emitting_queue(entry)),
|
|
392
417
|
plan_mode: @plan_mode,
|
|
393
418
|
todos: @todos,
|
|
394
419
|
**@session_opts
|
|
395
|
-
)
|
|
396
|
-
|
|
420
|
+
)
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
def emitting_queue(entry)
|
|
424
|
+
EmittingApprovalQueue.new(
|
|
425
|
+
on_submit: ->(a) { emit_approval(entry, a, :pending) },
|
|
426
|
+
on_status: ->(a) { emit_approval(entry, a, a.status) }
|
|
427
|
+
)
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
def approval_config(queue)
|
|
431
|
+
case @approval
|
|
432
|
+
when APPROVAL_REQUIRE then { queue: queue, require_approval: @approval_required }
|
|
433
|
+
when APPROVAL_AUTO then { queue: queue }
|
|
434
|
+
when APPROVAL_OFF then nil
|
|
435
|
+
else
|
|
436
|
+
raise ArgumentError, "approval must be one of #{APPROVAL_MODES.inspect}, got #{@approval.inspect}"
|
|
397
437
|
end
|
|
398
438
|
end
|
|
399
439
|
|
|
440
|
+
|
|
441
|
+
|
|
400
442
|
def build_chat(model_id, system_prompt = nil)
|
|
401
443
|
chat = Ask::Agent::Chat.new(
|
|
402
444
|
model: model_id,
|
|
@@ -38,7 +38,7 @@ module Ask
|
|
|
38
38
|
@started
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
def create_session(workspace_path, mode: nil)
|
|
41
|
+
def create_session(workspace_path, mode: nil, system_prompt: nil, **)
|
|
42
42
|
ensure_started
|
|
43
43
|
sid = "sess_#{SecureRandom.uuid}"
|
|
44
44
|
@sessions[sid] = { workspace: workspace_path, mode: mode, created_at: Time.now }
|
|
@@ -42,7 +42,7 @@ module Ask
|
|
|
42
42
|
@client&.running? || false
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
def create_session(workspace_path, mode: nil)
|
|
45
|
+
def create_session(workspace_path, mode: nil, system_prompt: nil, **)
|
|
46
46
|
ensure_running
|
|
47
47
|
thread = @client.thread_start(cwd: workspace_path)
|
|
48
48
|
tid = thread["id"] || thread[:id]
|