pikuri-core 0.0.3 → 0.0.5

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.
@@ -41,10 +41,10 @@ module Pikuri
41
41
  #
42
42
  # msg #1: ctx=6.8k/32.0k Δ+6.8k ↑6.8k ↓0.0k
43
43
  #
44
- # When the owning {Agent} has a non-empty {Agent#name} (i.e.
45
- # a sub-agent), the line is prefixed with +[name] +:
44
+ # When the owning {Agent} has a non-empty {Agent#id} (i.e. a
45
+ # sub-agent), the line is prefixed with +[id] +:
46
46
  #
47
- # [sub_agent 0] msg #1: ctx=4.2k Δ+4.2k ↑4.2k ↓0.0k
47
+ # [researcher 0] msg #1: ctx=4.2k Δ+4.2k ↑4.2k ↓0.0k
48
48
  #
49
49
  # +ctx+ is the snapshot
50
50
  # (+input + cached + cache_creation + output+; see
@@ -89,16 +89,15 @@ module Pikuri
89
89
  # @return [Integer, nil]
90
90
  attr_accessor :context_window_cap
91
91
 
92
- # @return [String] owning agent's identifier. Empty by
92
+ # @return [String] owning agent's id ({Agent#id}). Empty by
93
93
  # default (main agent); set by {#for_sub_agent} from the
94
- # sub-agent's generated name so the log lines can be
95
- # prefixed with +[<name>] +. Read-only — for a
96
- # sub-agent's listener you get a fresh instance via
97
- # {#for_sub_agent}.
98
- attr_reader :name
94
+ # sub-agent's generated id so the log lines can be
95
+ # prefixed with +[<id>] +. Read-only — for a sub-agent's
96
+ # listener you get a fresh instance via {#for_sub_agent}.
97
+ attr_reader :id
99
98
 
100
99
  # The most recent log line, in the exact format written to
101
- # {LOGGER} (including any +[<name>] + prefix). Empty until
100
+ # {LOGGER} (including any +[<id>] + prefix). Empty until
102
101
  # the first {Event::Tokens} has been processed. Hosts that
103
102
  # want to surface the current context-window snapshot in
104
103
  # their own UI (e.g. a TUI status footer) read this
@@ -113,12 +112,12 @@ module Pikuri
113
112
  # @return [String]
114
113
  attr_reader :status_line
115
114
 
116
- # @param name [String] agent identifier prepended to each
117
- # log line as +[<name>] + when non-empty. Defaults to
118
- # +""+ for the main agent.
119
- def initialize(name: '')
115
+ # @param id [String] owning agent's id, prepended to each
116
+ # log line as +[<id>] + when non-empty. Defaults to +""+
117
+ # for the main agent.
118
+ def initialize(id: '')
120
119
  super()
121
- @name = name
120
+ @id = id
122
121
  @msg = 0
123
122
  @context_window_size = 0
124
123
  @context_window_cap = nil
@@ -128,17 +127,17 @@ module Pikuri
128
127
  # Sub-agent variant: a fresh +TokenLog+ with a zeroed
129
128
  # snapshot so the sub-agent's context-window readings
130
129
  # track its own +RubyLLM::Chat+ rather than continuing the
131
- # parent's. Picks the sub-agent's +name:+ out of the
132
- # forwarded params so its log lines carry the +[<name>] +
130
+ # parent's. Picks the sub-agent's +id:+ out of the
131
+ # forwarded params so its log lines carry the +[<id>] +
133
132
  # prefix; defaults to +""+ when absent. The cap is left
134
133
  # +nil+ here; the sub-agent's {Agent#initialize} emits a
135
134
  # fresh {Event::ContextCap} immediately after construction
136
135
  # and this listener picks it up off the stream.
137
136
  #
138
- # @param name [String] sub-agent's identifier
137
+ # @param id [String] sub-agent's id
139
138
  # @return [TokenLog]
140
- def for_sub_agent(name: '', **)
141
- self.class.new(name: name)
139
+ def for_sub_agent(id: '', **)
140
+ self.class.new(id: id)
142
141
  end
143
142
 
144
143
  # @param event [Agent::Event]
@@ -184,7 +183,7 @@ module Pikuri
184
183
 
185
184
  def format_line(input, output, delta)
186
185
  sign = delta.negative? ? '-' : '+'
187
- prefix = @name.empty? ? '' : "[#{@name}] "
186
+ prefix = @id.empty? ? '' : "[#{@id}] "
188
187
  "#{prefix}msg ##{@msg}: ctx=#{format_ctx} Δ#{sign}#{format_k(delta.abs)} ↑#{format_k(input)} ↓#{format_k(output)}"
189
188
  end
190
189
 
@@ -35,8 +35,9 @@ module Pikuri
35
35
 
36
36
  # Iterate over the wrapped listeners in registration order. The
37
37
  # method exists so a ListenerList can be passed directly to
38
- # {Configurator#add_listeners} (used by {Tool::SubAgent} when
39
- # seeding a sub-agent's Configurator from the parent's list).
38
+ # {Configurator#add_listeners} (used by the +agent+ tool from
39
+ # +pikuri-subagents+ when seeding a sub-agent's Configurator
40
+ # from the parent's list).
40
41
  #
41
42
  # @yield [listener]
42
43
  # @yieldparam listener [Listener::Base]
@@ -59,13 +60,14 @@ module Pikuri
59
60
  # change this class — see {Listener::Terminal#for_sub_agent}
60
61
  # (fresh padded instance) and
61
62
  # {Listener::TokenLog#for_sub_agent} (fresh, zeroed snapshot
62
- # with the forwarded +name:+).
63
+ # with the forwarded +id:+).
63
64
  #
64
65
  # +params+ is a flat hash forwarded as kwargs to every
65
66
  # listener's hook; each listener picks the keys it cares about
66
67
  # and ignores the rest. The only key currently consumed by
67
- # bundled listeners is +name:+ (used by {Listener::TokenLog}).
68
- # Calling with no params is always valid.
68
+ # bundled listeners is +id:+ (used by {Listener::TokenLog} to
69
+ # prefix its log lines with the sub-agent's id). Calling with
70
+ # no params is always valid.
69
71
  #
70
72
  # @param params [Hash{Symbol => Object}]
71
73
  # @return [ListenerList]
@@ -45,7 +45,7 @@ module Pikuri
45
45
  # reasoning and answer flow through the same listener
46
46
  # surface the parent agent uses — terminal renders them
47
47
  # inline (padded under sub-agent), an in-memory recorder
48
- # picks them up, a TokenLog tags them with the synth name.
48
+ # picks them up, a TokenLog tags them with the synth id.
49
49
  #
50
50
  # @param chat [RubyLLM::Chat] a *fresh* chat with no tools.
51
51
  # The caller is responsible for constructing it with the
@@ -58,7 +58,7 @@ module Pikuri
58
58
  # @param listeners [Agent::ListenerList] listeners to wire
59
59
  # the synth chat into. Typically the parent agent's list
60
60
  # run through {ListenerList#for_sub_agent} with the
61
- # synth's +name:+ so any +TokenLog+ tags its lines with
61
+ # synth's +id:+ so any +TokenLog+ tags its lines with
62
62
  # the synth bracket and any +Terminal+ pads its output.
63
63
  # @param step_limit [Control::StepLimit, nil] defensive
64
64
  # step budget. The synth has no tools so it should never