pinecall 0.11.51 → 0.11.52

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: 1e98e4cf78457c3d8a393065fe5aa42c05527bbc1d9838bc40c75c939a54aa16
4
- data.tar.gz: df253825e02443fd3734bb1880e1774cf2564b31e1f5c08c5cc19d618e0027d9
3
+ metadata.gz: 6b141db8b3873ad9cf37d20469af2d81890c4a7b6cccd15ba0342fdadd1c0580
4
+ data.tar.gz: 041323c0f0e2f70c8fd70bd0530530972bb6cc6e117cb60da5054fb3f523f6cf
5
5
  SHA512:
6
- metadata.gz: fb0851710a6e10ae2824710d6bcc19b172c22ac0ea6c5ae95cf369ba6edb349b11e612dc2e3ac4cb4c135d994c2e1377eef836e06cdfe497a961454602d47243
7
- data.tar.gz: 510580fff6806a737aa3fef786da9335d9a8ca5d3fd0f0f213ad5d0bb876182a278e125d2b5961dedc15881c0e8855c35ced6ea2ac775b8f62bdf302d916e568
6
+ metadata.gz: ab73aa8eaec4b92627225c2e6575b69c4838676c72e150d1c0cb601ede0f897c69be5431a076a562d7f7c08cb01946e9a5cc36c88693990232fcc7b04f4d2089
7
+ data.tar.gz: b89d5c16966a8aef8211e75a28f89550d05668c4bef3b62a071b6dcbb33a43f6f1e2cf218a7f1b09ffe3465234eb6730e2b8974abc6675e1dd197e05dc76dbd1
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ Every change a person using this gem would notice. The format is
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); version numbers and tags are the
5
5
  maintainer's call.
6
6
 
7
+ ## [0.11.52] — the callers an agent is tested with live in its test folder, beside its goldens; one Calls page lists every conversation (2026-11-19)
8
+
9
+ - **An agent's test callers are held in `agents/<slug>/test/personas.rb`, beside its goldens, and no longer in the class.**
10
+ Every constant there made by `Pinecall.own_persona` is the agent's own and `ON` names Pinecall's; the file is read in
11
+ a module of its own as the class loads. `personas on:, own:` in the class still works for an agent with no such file,
12
+ and `pinecall start` says once where their place is; a class that names them beside the file is refused.
13
+
7
14
  ## [0.11.51] — live is somebody on the line and never a written conversation; Emails is a page of its own, with a mailbox's server and the org's template in an agent's channels (2026-11-19)
8
15
 
9
16
  - Released with the runtime: nothing of this package changed.
@@ -208,8 +208,9 @@ module Pinecall
208
208
  end
209
209
 
210
210
  # `turn endpointing_ms: 300`, `docs base: "…", k: 4`, `memory remember: […], forget: […]`,
211
- # `knowledge path: "…", text: "…"`, `judges on: [...], own: [...]` and `personas on: [...], own: [...]`
212
- # (which of Pinecall's, and the class's own: `Pinecall.own_judge`, `Pinecall.own_persona`).
211
+ # `knowledge path: "…", text: "…"` and `judges on: [...], own: [...]` (which of Pinecall's, and the class's
212
+ # own: `Pinecall.own_judge`). `personas on: [...], own: [...]` still works for a class with no
213
+ # `test/personas.rb`, the file its callers are held in.
213
214
  AS_KEYWORDS.each do |field|
214
215
  define_method(field) do |**given|
215
216
  return environment[field] if given.empty?
@@ -218,6 +219,13 @@ module Pinecall
218
219
  end
219
220
  end
220
221
 
222
+ # The callers its `test/personas.rb` holds, as whoever loaded the class read them; nil with no such file.
223
+ def tested_with(roster = NOTHING)
224
+ return @tested_with if roster.equal?(NOTHING)
225
+
226
+ @tested_with = roster
227
+ end
228
+
221
229
  # What a teammate passes it, as a model reads it: `takes "a question about a bill"`.
222
230
  def takes(what = NOTHING)
223
231
  return declared_takes if what.equal?(NOTHING)
@@ -285,8 +293,8 @@ module Pinecall
285
293
  @slug = name
286
294
  end
287
295
 
288
- # The AgentConfig sent to the gateway: the contract, and the environment the class declares,
289
- # the judges and the personas it owns checked once more.
296
+ # The AgentConfig sent to the gateway: the contract, and the environment the class declares, its judges
297
+ # and the personas of its `test/personas.rb` (or the class's own, with no such file) checked once more.
290
298
  def wire_config(tools: nil)
291
299
  here = source_file
292
300
  {
@@ -2,8 +2,9 @@
2
2
 
3
3
  module Pinecall
4
4
  class Agent
5
- # The judges and the personas a class owns: `Pinecall.own_judge`, `Pinecall.own_persona`, each refused by
6
- # sentence when wrong, and what `judges on:, own:` and `personas on:, own:` declare, as the declaration sends it.
5
+ # The judges a class owns and the callers its test folder holds: `Pinecall.own_judge`, `Pinecall.own_persona`,
6
+ # each refused by sentence when wrong; what `judges on:, own:` declares and what `test/personas.rb` holds, as
7
+ # the declaration sends it.
7
8
  module Harness
8
9
  # The name a judge or a persona is called by: lower-case words joined by hyphens.
9
10
  A_NAME = /\A[a-z0-9]+(?:-[a-z0-9]+)*\z/
@@ -20,7 +21,18 @@ module Pinecall
20
21
  NO_TRIGGER = "a judge that runs on a trigger needs the trigger's question"
21
22
  NO_GOAL = "a persona wants something: write its goal, in the first person"
22
23
  NO_STYLE = "a persona talks some way: write its style"
23
- NOT_DECLARED_SO = "judges and personas are declared with judges on: [...], own: [...] and personas on: [...], own: [...]"
24
+ NOT_DECLARED_SO = "personas are held in test/personas.rb beside the goldens, ON for Pinecall's and each Pinecall.own_persona " \
25
+ "the agent's own, and judges are declared in the class with judges on: [...], own: [...]; " \
26
+ "a class that still names its personas writes personas on: [...], own: [...]"
27
+ NOT_NAMES = "ON is the names of Pinecall's callers the agent is tested with, an array of strings"
28
+ # What a served agent is told once when its class still names its callers: they play, and their place is the file.
29
+ CALLERS_MOVED = "its personas are declared in the class, which still works: their place is now test/personas.rb beside the " \
30
+ "goldens — every Pinecall.own_persona it defines is the agent's own, and ON names Pinecall's"
31
+
32
+ # What `own_persona` makes: a persona as the wire carries it, told by its class from whatever else a
33
+ # `test/personas.rb` defines.
34
+ class OwnPersona < Hash
35
+ end
24
36
 
25
37
  module_function
26
38
 
@@ -55,19 +67,54 @@ module Pinecall
55
67
  rescue Wire::WireError => e
56
68
  refuse(name, e.message)
57
69
  end
58
- persona
70
+ OwnPersona[persona]
59
71
  end
60
72
 
61
- # What `judges` and `personas` declare, as the declaration sends it; nothing for a class that declares neither.
73
+ # The judges a class declares and the callers it is tested with, as the declaration sends them; nothing for a
74
+ # class with neither.
62
75
  def declared(klass)
63
76
  found = {}
64
77
  switches = klass.environment[:judges]
65
78
  found[:judges] = roster("judge", switches) { |one| own_judge(**judge_input_of(one)) } if switches
66
- switches = klass.environment[:personas]
67
- found[:personas] = roster("persona", switches) { |one| own_persona(**one) } if switches
79
+ callers = personas_of(klass)
80
+ found[:personas] = callers unless callers.nil?
68
81
  found
69
82
  end
70
83
 
84
+ # The roster its `test/personas.rb` holds, or the class's own for one that still names its callers and has no file.
85
+ def personas_of(klass)
86
+ return klass.tested_with unless klass.tested_with.nil?
87
+
88
+ switches = klass.environment[:personas]
89
+ roster("persona", switches) { |one| own_persona(**one) } if switches
90
+ end
91
+
92
+ # The roster a `test/personas.rb` holds, read off the module it was loaded in: every `Pinecall.own_persona`
93
+ # among its constants is the agent's own, in the order written, and `ON` names Pinecall's. Any other
94
+ # constant is not a caller.
95
+ def roster_in(held, file)
96
+ on = held.const_defined?(:ON, false) ? held.const_get(:ON, false) : []
97
+ raise DeclarationRefused, "#{file}: #{NOT_NAMES}" unless on.is_a?(Array) && on.all?(String)
98
+
99
+ # `constants` answers in no order of its own.
100
+ written = held.constants(false).sort_by { |name| held.const_source_location(name, false) }
101
+ own = written.map { |name| held.const_get(name, false) }.grep(OwnPersona)
102
+ roster("persona", { on:, own: }) { |one| own_persona(**one) }
103
+ end
104
+
105
+ # The class is tested with the roster its `test/personas.rb` holds; one that names its callers too is refused.
106
+ def tested_with(klass, roster, file)
107
+ if names_its_callers?(klass)
108
+ raise DeclarationRefused, "#{klass} declares personas in the class and #{file} holds them too: " \
109
+ "the file is their place — take personas out of the class"
110
+ end
111
+
112
+ klass.tested_with(roster)
113
+ end
114
+
115
+ # Whether the class names its callers itself, the old place for them.
116
+ def names_its_callers?(klass) = !klass.environment[:personas].nil?
117
+
71
118
  # `on` as given, each of `own` checked once more and two of one name refused.
72
119
  def roster(what, switches)
73
120
  raise DeclarationRefused, NOT_DECLARED_SO unless switches.is_a?(Hash)
@@ -105,7 +152,7 @@ module Pinecall
105
152
  # A judge of the agent's own, for `judges own: [...]`: `Pinecall.own_judge(name: "offers-next-slot", asks: "…")`.
106
153
  def own_judge(**) = Agent::Harness.own_judge(**)
107
154
 
108
- # A caller of the agent's own, for `personas own: [...]`: `Pinecall.own_persona(name:, goal:, style:, …)`.
155
+ # A caller of the agent's own, a constant of its `test/personas.rb`: `HURRIED = Pinecall.own_persona(name:, goal:, style:, …)`.
109
156
  def own_persona(**) = Agent::Harness.own_persona(**)
110
157
  end
111
158
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # What the serve entry is told and loads: its flags, the class in a file, and a state field by field.
3
+ # What the serve entry is told and loads: its flags, the class in a file with the callers of its test folder, and
4
+ # a state field by field.
4
5
 
5
6
  module Pinecall
6
7
  module Serve
@@ -14,6 +15,9 @@ module Pinecall
14
15
  Flags = Data.define(:served, :console, :events, :prod, :state, :channel, :medium, :show_machine, :app)
15
16
 
16
17
  module Loading
18
+ # The file an agent's test callers are held in, beside its goldens: `agents/<slug>/test/personas.rb`.
19
+ CALLERS = File.join("test", "personas.rb")
20
+
17
21
  module_function
18
22
 
19
23
  # `--file` and `--slug` paired by place; the rest by name. A flag nobody declared is refused.
@@ -60,9 +64,27 @@ module Pinecall
60
64
  # Until 0.11.36 a class named otherwise than its folder looked for a view by its own name,
61
65
  # found none and answered every call with no view.
62
66
  klass.slug(served.slug)
67
+ callers_of(klass, served.file)
63
68
  klass
64
69
  end
65
70
 
71
+ # The agent's test callers are the ones its test folder holds: read once the class is, so the declaration
72
+ # carries them. The file loads in a module of its own, since two agents' files may each write an ON.
73
+ def callers_of(klass, agent_file)
74
+ file = File.join(File.dirname(File.expand_path(agent_file)), CALLERS)
75
+ return unless File.exist?(file)
76
+
77
+ held = Module.new
78
+ begin
79
+ load(file, held)
80
+ rescue ScriptError, StandardError => e
81
+ raise if e.is_a?(DeclarationRefused)
82
+
83
+ raise CannotServe, "#{file} did not load: #{e.message}"
84
+ end
85
+ Agent::Harness.tested_with(klass, Agent::Harness.roster_in(held, file), file)
86
+ end
87
+
66
88
  # The last `Pinecall::Agent` the file defines.
67
89
  def load_agent(file)
68
90
  path = File.expand_path(file)
@@ -50,6 +50,7 @@ module Pinecall
50
50
  classes, app = App.loaded(flags)
51
51
  slugs = classes.to_h { |served, klass| [klass, served.slug] }
52
52
  mounted = classes.map do |served, klass|
53
+ err.puts("#{served.slug} #{Agent::Harness::CALLERS_MOVED}") if Agent::Harness.names_its_callers?(klass)
53
54
  held = App.held(client, klass, served.slug, app, slugs, console: flags.console, err:)
54
55
  held.agent.on_dev { |verb, data| Viewing.answer(klass, served.slug, verb, data) }
55
56
  held
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Pinecall
4
4
  # Set by the maintainer at release time.
5
- VERSION = "0.11.51"
5
+ VERSION = "0.11.52"
6
6
  end
data/sig/pinecall.rbs CHANGED
@@ -112,6 +112,7 @@ module Pinecall
112
112
  def self.docs: (**untyped) -> untyped
113
113
  def self.judges: (**untyped) -> untyped
114
114
  def self.personas: (**untyped) -> untyped
115
+ def self.tested_with: (?Hash[Symbol, untyped]) -> Hash[Symbol, untyped]?
115
116
  def self.memory: (**untyped) -> untyped
116
117
  def self.environment: () -> Hash[Symbol, untyped]
117
118
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pinecall
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.51
4
+ version: 0.11.52
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pinecall