pinecall 0.11.23 → 0.11.25

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: 4cf54f61574f8a93569873af8d95c12b04979ad94477254f00af76210e40d00e
4
- data.tar.gz: 10019e51becc643b5a5c0913ca632702b1054aab3d37e947b58202cc724a3231
3
+ metadata.gz: d85827c49912eecbf934bb51af7b9e842e82e3d52937933ad1c9cd52771ceb36
4
+ data.tar.gz: 9f03d35a164cabe8d6728d7dff6e90922b93c8c05b10bc605ba39e532a5ce870
5
5
  SHA512:
6
- metadata.gz: 312591f67f128f3105d95a5b983bb2f46a782885b1bcbddabdde89be579ed1f1f5826b68349c1806fd18600b36c7557f105540899fe63b865c8b93029c14a407
7
- data.tar.gz: ddb4395ba9ea05edceb59e225625068f8698afe9b228c1b65154d42c971981afccfce7eccce416b35e18e444e0f74a8f93f08d5ffd1be9fd795f2474f4ddd9ff
6
+ metadata.gz: c06292f0191e7c33ae32b16bf8e0e63785ec8aa7242d7342de938f4f9e44036fd0666725a3e220d9d6d06ab22ecb1556fc1ca1a3d50c4a71c97fe4975d4326ae
7
+ data.tar.gz: 0c9421fed297b9bab8f0f5820c2008e729a0207512ad5cc7475d3dc11fd8918a09153dcdb73361e7b872c910205037965102687085e9228094babacce235e9ab
data/CHANGELOG.md CHANGED
@@ -4,7 +4,32 @@ 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
- ## [Unreleased]
7
+ ## [0.11.25] — the class owns its judges and callers as code, its docs, its melody, its look and its timeouts (2026-11-04)
8
+
9
+ - **`hold` and `widget`** macros: the hold melody — a file beside the class, shipped once the agent registers
10
+ unless the gateway holds it already, the wait before it, or `:off` — and how the widget presents the agent,
11
+ fixed over the console.
12
+
13
+ - **A class that declares `docs` pushes its folder.** Once the agent registers, every Markdown file under
14
+ `agents/<slug>/docs/` is written into the declared base by path, the base's other files kept, once per
15
+ process: `pinecall start` and a deploy need no `pinecall docs push`.
16
+
17
+ - **`max_duration` and `llm_timeout`** macros: the longest a voice call runs (minutes, or `:off`) and how long a
18
+ turn waits for the model's first word (seconds), fixed over the settings.
19
+
20
+ - **A class owns its judges and its personas, as code.** `judges on: %w[consent …], own: [OFFERS_NEXT_SLOT]`
21
+ names which of Pinecall's judges the agent's calls meet and the agent's own, each a
22
+ `Pinecall.own_judge(name:, asks:, answer:, choices:, when:, trigger:, reads:)`; `personas on:, own:`
23
+ the same for the callers `pinecall simulate` plays, each of its own a `Pinecall.own_persona(name:,
24
+ goal:, style:, …)`. `pinecall new` writes both in `agents/<slug>/harness.rb`. Both reach the gateway
25
+ on `agent.configure` (`judges`, `personas` on `AgentConfig`), the console shows them locked, and a
26
+ wrong one, or two of one name, is refused when the agent registers, by a sentence that names it.
27
+
28
+ - **`agent.waiting` is read.** The runtime writes it when the agent's turn is over: every sentence of the
29
+ reply played, every tool it called run. An app on an earlier version logged `unknown event type: agent.waiting`
30
+ on every turn; this one parses it and leaves it to `call.on`.
31
+
32
+ ## [0.11.24] — released with the dot's marked walk (2026-10-25)
8
33
 
9
34
  ## [0.11.23] — released with the dot's smaller face (2026-10-25)
10
35
 
@@ -13,13 +13,18 @@ module Pinecall
13
13
  AS_WRITTEN = %i[phone whatsapp web channel_rules].freeze
14
14
 
15
15
  # The settings a class may declare. Must match the TypeScript package's `ENVIRONMENT`.
16
- ENVIRONMENT = %i[language voice llm realtime stt judge greeting hangup turn says hears knowledge docs memory record].freeze
16
+ ENVIRONMENT = %i[language voice llm realtime stt judge greeting hangup turn says hears knowledge docs memory record judges
17
+ personas widget].freeze
17
18
 
18
- # The ones written as the wire's own fields, keyword by keyword: `greeting say: "…"`.
19
- AS_KEYWORDS = %i[turn knowledge docs memory].freeze
19
+ # The ones written as the wire's own fields, keyword by keyword: `docs base: "…"`, `judges on: [...]`.
20
+ AS_KEYWORDS = %i[turn knowledge docs memory judges personas widget].freeze
20
21
 
21
22
  NO_VOICE = "a voice the class declares names its vendor and the voice: voice \"<vendor>\", \"<voice id>\""
22
23
 
24
+ NOT_A_DURATION = "max_duration is the longest a voice call runs: 1 to 60 minutes, or :off for no limit"
25
+ NOT_A_TIMEOUT = "llm_timeout is how long a turn waits for the model's first word, in seconds, above 0"
26
+ LONGEST_MINUTES = 60
27
+
23
28
  NO_OPENING = "a greeting is the words, as a string, or :improvise for the model's own: improvise(\"…\") gives it an instruction"
24
29
  NO_ENDING = "hangup is when the model may end the call, in your words, or true whenever it judges the call done"
25
30
 
@@ -48,6 +53,14 @@ module Pinecall
48
53
  { when: ending }
49
54
  end
50
55
 
56
+ # The longest call as the wire counts it: minutes into seconds, :off into 0.
57
+ def self.seconds_of(minutes)
58
+ return 0 if minutes == :off || minutes == "off"
59
+ raise DeclarationRefused, NOT_A_DURATION unless minutes.is_a?(Integer) && minutes.between?(1, LONGEST_MINUTES)
60
+
61
+ minutes * 60
62
+ end
63
+
51
64
  # `vendor/model`, or a vendor alone; the model id keeps every slash after the vendor's.
52
65
  def self.model_of(named)
53
66
  provider, _slash, model = named.to_s.partition("/")
@@ -136,6 +149,29 @@ module Pinecall
136
149
  end
137
150
  end
138
151
 
152
+ # The hold melody: `hold file: "hold.mp3", after_s: 1.5`, `hold after_s: 1`, `hold off: true` or `hold :off`.
153
+ # Read back with no argument: what was declared, as written.
154
+ def hold(declared = NOTHING, **given)
155
+ return @hold if declared.equal?(NOTHING) && given.empty?
156
+
157
+ @hold = declared.equal?(NOTHING) ? given : declared
158
+ end
159
+
160
+ # The longest a voice call runs: `max_duration 20` (minutes), or `max_duration :off`; the wire counts seconds.
161
+ def max_duration(minutes = NOTHING)
162
+ return environment[:max_duration_s] if minutes.equal?(NOTHING)
163
+
164
+ environment[:max_duration_s] = Config.seconds_of(minutes)
165
+ end
166
+
167
+ # How long a turn waits for the model's first word: `llm_timeout 8` (seconds).
168
+ def llm_timeout(seconds = NOTHING)
169
+ return environment[:llm_timeout_s] if seconds.equal?(NOTHING)
170
+ raise DeclarationRefused, NOT_A_TIMEOUT unless seconds.is_a?(Numeric) && seconds.positive?
171
+
172
+ environment[:llm_timeout_s] = seconds.to_f
173
+ end
174
+
139
175
  # The words the ears must know: `hears "Vidal", "Sanitas"`.
140
176
  def hears(*words)
141
177
  return environment[:hears] if words.empty?
@@ -144,7 +180,8 @@ module Pinecall
144
180
  end
145
181
 
146
182
  # `turn endpointing_ms: 300`, `docs base: "…", k: 4`, `memory remember: […], forget: […]`,
147
- # `knowledge path: "…", text: "…"`.
183
+ # `knowledge path: "…", text: "…"`, `judges on: [...], own: [...]` and `personas on: [...], own: [...]`
184
+ # (which of Pinecall's, and the class's own: `Pinecall.own_judge`, `Pinecall.own_persona`).
148
185
  AS_KEYWORDS.each do |field|
149
186
  define_method(field) do |**given|
150
187
  return environment[field] if given.empty?
@@ -190,10 +227,14 @@ module Pinecall
190
227
  @slug = name
191
228
  end
192
229
 
193
- # The AgentConfig sent to the gateway: the contract, and the environment the class declares.
230
+ # The AgentConfig sent to the gateway: the contract, and the environment the class declares,
231
+ # the judges and the personas it owns checked once more.
194
232
  def wire_config(tools: nil)
233
+ here = source_file
195
234
  {
196
235
  **environment,
236
+ **Harness.declared(self),
237
+ hold: Melody.config_of(@hold, here),
197
238
  prompt: Prompt::FRAMEWORK,
198
239
  tools:,
199
240
  state_fields: state_field_specs,
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pinecall
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.
7
+ module Harness
8
+ # The name a judge or a persona is called by: lower-case words joined by hyphens.
9
+ A_NAME = /\A[a-z0-9]+(?:-[a-z0-9]+)*\z/
10
+
11
+ ANSWERS = %w[verdict choice score].freeze
12
+ WHENS = %w[always simulations trigger].freeze
13
+ READS = %w[prompt evidence facts].freeze
14
+ # Fewer than two is not a choice.
15
+ FEWEST_CHOICES = 2
16
+
17
+ NO_QUESTION = "a judge asks a question of a call: write it as asks"
18
+ NO_CHOICES = "a judge that answers one of several needs at least two choices"
19
+ CHOICES_ONLY = "only a judge that answers one of several takes choices"
20
+ NO_TRIGGER = "a judge that runs on a trigger needs the trigger's question"
21
+ NO_GOAL = "a persona wants something: write its goal, in the first person"
22
+ 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
+
25
+ module_function
26
+
27
+ # A judge of the agent's own, refused by sentence when wrong; `own:` of `judges` takes it. `when:` is
28
+ # always, simulations or trigger (asked only when `trigger:` is answered yes); `reads:` prompt, evidence, facts.
29
+ def own_judge(name:, asks:, answer: "verdict", choices: [], trigger: "", reads: [], **rest)
30
+ runs = rest.delete(:when) || "always"
31
+ raise DeclarationRefused, "a judge takes no #{rest.keys.join(', ')}" unless rest.empty?
32
+ raise DeclarationRefused, "\"#{name}\" is not a judge's name: lower-case words joined by hyphens, like offers-next-slot" unless name.is_a?(String) && A_NAME.match?(name)
33
+
34
+ question = asks.to_s.strip
35
+ refuse(name, NO_QUESTION) if question.empty?
36
+ picked = one_of(name, "answer", answer.to_s, ANSWERS)
37
+ listed = Array(choices).map(&:to_s)
38
+ refuse(name, NO_CHOICES) if picked == "choice" && listed.size < FEWEST_CHOICES
39
+ refuse(name, CHOICES_ONLY) if picked != "choice" && !listed.empty?
40
+ on = one_of(name, "when", runs.to_s, WHENS)
41
+ refuse(name, NO_TRIGGER) if on == "trigger" && trigger.to_s.strip.empty?
42
+ read = Array(reads).map { |one| one_of(name, "reads", one.to_s, READS) }
43
+ { name:, question:, answer: picked, choices: listed, when: on, trigger: trigger.to_s, reads: read }
44
+ end
45
+
46
+ # A caller of the agent's own — what `PUT …/personas/{name}` takes — refused by sentence when wrong.
47
+ def own_persona(name:, goal:, style:, **rest)
48
+ raise DeclarationRefused, "\"#{name}\" is not a persona's name: lower-case words joined by hyphens, like price-shopper" unless name.is_a?(String) && A_NAME.match?(name)
49
+
50
+ refuse(name, NO_GOAL) unless goal.is_a?(String) && !goal.strip.empty?
51
+ refuse(name, NO_STYLE) unless style.is_a?(String) && !style.strip.empty?
52
+ persona = Wire::Codec.symbolize({ name:, goal:, style:, **rest })
53
+ begin
54
+ Wire::Validate.call!("PersonaDeclaration", persona, where: name)
55
+ rescue Wire::WireError => e
56
+ refuse(name, e.message)
57
+ end
58
+ persona
59
+ end
60
+
61
+ # What `judges` and `personas` declare, as the declaration sends it; nothing for a class that declares neither.
62
+ def declared(klass)
63
+ found = {}
64
+ switches = klass.environment[:judges]
65
+ 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
68
+ found
69
+ end
70
+
71
+ # `on` as given, each of `own` checked once more and two of one name refused.
72
+ def roster(what, switches)
73
+ raise DeclarationRefused, NOT_DECLARED_SO unless switches.is_a?(Hash)
74
+
75
+ own = Array(switches[:own]).map { |one| yield(Wire::Codec.symbolize(one)) }
76
+ own.map { |one| one[:name] }.tally.each do |name, count|
77
+ raise DeclarationRefused, "two #{what}s called #{name}: a name is declared once" if count > 1
78
+ end
79
+ { on: Array(switches[:on]), own: }
80
+ end
81
+
82
+ # A judge already built reads back as its input.
83
+ def judge_input_of(one)
84
+ begin
85
+ Wire::Validate.call!("JudgeDeclaration", one, where: one[:name].to_s)
86
+ rescue Wire::WireError => e
87
+ refuse(one[:name], e.message)
88
+ end
89
+ { name: one[:name], asks: one[:question], answer: one.fetch(:answer, "verdict"), choices: one.fetch(:choices, []),
90
+ when: one.fetch(:when, "always"), trigger: one.fetch(:trigger, ""), reads: one.fetch(:reads, []) }
91
+ end
92
+
93
+ def one_of(name, field, value, allowed)
94
+ refuse(name, "#{field} is \"#{value}\", not one of #{allowed.join(', ')}") unless allowed.include?(value)
95
+ value
96
+ end
97
+
98
+ def refuse(name, sentence)
99
+ raise DeclarationRefused, "#{name}: #{sentence}"
100
+ end
101
+ end
102
+ end
103
+
104
+ class << self
105
+ # A judge of the agent's own, for `judges own: [...]`: `Pinecall.own_judge(name: "offers-next-slot", asks: "…")`.
106
+ def own_judge(**) = Agent::Harness.own_judge(**)
107
+
108
+ # A caller of the agent's own, for `personas own: [...]`: `Pinecall.own_persona(name:, goal:, style:, …)`.
109
+ def own_persona(**) = Agent::Harness.own_persona(**)
110
+ end
111
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "digest"
4
+
5
+ module Pinecall
6
+ class Agent
7
+ # The hold melody a class declares: `hold file: "hold.mp3", after_s: 1.5`, `hold after_s: 1`,
8
+ # `hold off: true` or `hold :off`. The file is read beside the class and named on the wire by its
9
+ # sha256; the serve entry ships it once the agent registers.
10
+ module Melody
11
+ NOT_A_HOLD = "hold is the melody: hold file: \"hold.mp3\", after_s: 1.5; hold after_s: …; hold off: true; or hold :off"
12
+ NO_SUCH_FILE = "hold names %s, and there is no such file beside the class"
13
+
14
+ module_function
15
+
16
+ # What the class declares, as the wire carries it: the file by hash, the wait, silence; nil for none.
17
+ def config_of(declared, source_file)
18
+ return nil if declared.nil?
19
+ return { off: true } if declared == :off || declared == "off"
20
+ raise DeclarationRefused, NOT_A_HOLD unless declared.is_a?(Hash)
21
+
22
+ hold = {}
23
+ hold[:after_s] = declared[:after_s] unless declared[:after_s].nil?
24
+ hold[:off] = true if declared[:off] == true
25
+ unless declared[:file].nil?
26
+ path, data = melody_of(declared, source_file)
27
+ hold[:clip] = Digest::SHA256.hexdigest(data)
28
+ hold[:name] = File.basename(path)
29
+ end
30
+ hold
31
+ end
32
+
33
+ # The file the class ships as its melody, read beside the class's own file: its path and its bytes.
34
+ def melody_of(declared, source_file)
35
+ named = declared[:file]
36
+ raise DeclarationRefused, NOT_A_HOLD unless named.is_a?(String) && !named.empty?
37
+
38
+ path = source_file.nil? ? File.expand_path(named) : File.expand_path(named, File.dirname(source_file))
39
+ raise DeclarationRefused, format(NO_SUCH_FILE, path) unless File.file?(path)
40
+
41
+ [path, File.binread(path)]
42
+ end
43
+ end
44
+ end
45
+ end
@@ -6,6 +6,8 @@ require_relative "agent/state"
6
6
  require_relative "agent/spec"
7
7
  require_relative "agent/tools"
8
8
  require_relative "agent/config"
9
+ require_relative "agent/harness"
10
+ require_relative "agent/melody"
9
11
  require_relative "agent/knowledge"
10
12
  require_relative "agent/searching"
11
13
 
@@ -19,6 +19,14 @@ module Pinecall
19
19
  ask(request, api_key:, env:)
20
20
  end
21
21
 
22
+ # The body is the file, as the hold melody's door takes it.
23
+ def put_bytes(url, bytes, api_key:, env: nil)
24
+ request = Net::HTTP::Put.new(URI.parse(url))
25
+ request["content-type"] = "application/octet-stream"
26
+ request.body = bytes
27
+ ask(request, api_key:, env:)
28
+ end
29
+
22
30
  def post(url, body, api_key:, env: nil)
23
31
  request = Net::HTTP::Post.new(URI.parse(url))
24
32
  request["content-type"] = "application/json"
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pinecall
4
+ module Serve
5
+ # The folder a class declares as its base, pushed once the agent registers: `docs/` beside the
6
+ # class, every Markdown file under it, by path, the base's other files kept. Nothing for a class
7
+ # that declares no base, a folder that is not there, or one with no Markdown in it.
8
+ module DeclaredDocs
9
+ DOCS_FOLDER = "docs"
10
+
11
+ module_function
12
+
13
+ # Every Markdown file under the folder, its path as the base keeps it; none for no folder.
14
+ def markdown_under(folder)
15
+ return [] unless File.directory?(folder)
16
+
17
+ Dir.glob("**/*.md", base: folder).sort.map do |path|
18
+ { path:, text: File.read(File.join(folder, path), encoding: "utf-8") }
19
+ end
20
+ end
21
+
22
+ # Push the class's folder into the base it declares, and say what landed on `err`; `put` is
23
+ # the request, the REST door's unless a test hands another.
24
+ def push(client, klass, file, err:, put: Client::Rest.method(:put))
25
+ base = klass.environment.dig(:docs, :base)
26
+ return if base.nil? || file.nil?
27
+
28
+ files = markdown_under(File.join(File.dirname(File.expand_path(file)), DOCS_FOLDER))
29
+ return if files.empty?
30
+
31
+ url = "#{client.url.sub(%r{/\z}, "")}/v1/knowledge/#{URI.encode_www_form_component(base.to_s)}"
32
+ pushed = put.call(url, { files: }, api_key: client.api_key, env: client.env) || {}
33
+ kept = pushed[:kept].to_i
34
+ line = "#{klass.slug} #{base} #{files.size} file(s) pushed · #{pushed[:chunks].to_i} chunk(s)"
35
+ err.puts(kept.positive? ? "#{line} · #{kept} kept" : line)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "digest"
4
+
5
+ module Pinecall
6
+ module Serve
7
+ # The melody a class ships, uploaded once the agent registers unless the gateway holds that file:
8
+ # the door keeps the hash of what was uploaded, so a second start with the same file sends nothing.
9
+ module DeclaredHold
10
+ module_function
11
+
12
+ def upload(client, klass, file, err:, get: Client::Rest.method(:get), put: Client::Rest.method(:put_bytes))
13
+ declared = klass.hold
14
+ return unless declared.is_a?(Hash) && !declared[:file].nil?
15
+
16
+ path, data = Agent::Melody.melody_of(declared, file)
17
+ sha256 = Digest::SHA256.hexdigest(data)
18
+ door = "#{client.url.sub(%r{/\z}, "")}/v1/agents/#{URI.encode_www_form_component(klass.slug)}/hold-audio"
19
+ held = get.call(door, api_key: client.api_key, env: client.env) || {}
20
+ return if held[:source_sha256] == sha256
21
+
22
+ landed = put.call("#{door}?name=#{URI.encode_www_form_component(File.basename(path))}", data, api_key: client.api_key, env: client.env) || {}
23
+ err.puts("#{klass.slug} #{File.basename(path)} uploaded as the hold melody · #{landed[:seconds] || "?"} s")
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "serve/loading"
4
+ require_relative "serve/declared_docs"
5
+ require_relative "serve/declared_hold"
4
6
  require_relative "serve/held"
5
7
  require_relative "serve/masking"
6
8
  require_relative "serve/viewing"
@@ -52,6 +54,11 @@ module Pinecall
52
54
  asked = signals || trapped
53
55
  client.on_stopped { |why| err.puts(why) || asked.push(:stopped) }
54
56
  client.connect
57
+ # The documents a class declares as its base, once per process, before any call.
58
+ classes.each do |served, klass|
59
+ DeclaredDocs.push(client, klass, served.file, err:)
60
+ DeclaredHold.upload(client, klass, served.file, err:)
61
+ end
55
62
  Thread.new { ended(input, asked) }
56
63
  leave(held, asked)
57
64
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Pinecall
4
4
  # Set by the maintainer at release time.
5
- VERSION = "0.11.23"
5
+ VERSION = "0.11.25"
6
6
  end
@@ -28,7 +28,7 @@ module Pinecall
28
28
  # asked, its memory goldens, the panel it draws beside a conversation (view), a call
29
29
  # promoted to a candidate file, the drift of the last two windows, and the reproductions a
30
30
  # broken run left on that disk. Everything else a console needs is a door of the gateway.
31
- DEV_VERB = %w[chat.roster chat.start chat.say chat.end view.render simulate.start goldens.roster goldens.run knowledge.roster knowledge.push knowledge.eval memory.roster memory.eval memory.extraction promote.roster promote.write drift.read reproductions.roster reproductions.read].freeze
31
+ DEV_VERB = %w[chat.roster chat.start chat.say chat.end view.render simulate.start goldens.roster goldens.run knowledge.roster knowledge.push knowledge.eval memory.roster memory.eval memory.extraction promote.roster promote.write personas.write drift.read reproductions.roster reproductions.read].freeze
32
32
  # Why the call is over. Who hung up, what failed before anybody could, drained: the platform
33
33
  # took the worker down (a deploy, a stop) with the call still on it, or app_detached: the
34
34
  # app holding the agent closed its socket mid-call, so nothing was rendering the prompt or
@@ -15,6 +15,7 @@ module Pinecall
15
15
  "agent.registered" => "AgentRegistered",
16
16
  "agent.state" => "AgentStateChanged",
17
17
  "agent.transcript" => "AgentTranscript",
18
+ "agent.waiting" => "AgentWaiting",
18
19
  "app.failed" => "AppFailed",
19
20
  "attention.answered" => "AttentionAnswered",
20
21
  "attention.requested" => "AttentionRequested",
@@ -127,7 +128,7 @@ module Pinecall
127
128
  }.freeze
128
129
 
129
130
  # Every event this protocol declares, in the schema's own order.
130
- EVENT_TYPES = %w[agent.configured agent.detached agent.draining agent.registered agent.state agent.transcript app.failed attention.answered attention.requested call.attached call.claimed call.dialing call.ended call.line call.ringing call.score call.started call.summary call.transferred callback.requested code.claimed code.issued confirm.declined confirm.granted confirm.request credits.exhausted custom dev.request docs.sources dtmf.received error evals.spent event.received fleet.full judge.broke log.caught_up log.gap memory.ops message.taken message.waiting metrics.avatar metrics.eot metrics.eou metrics.interruption metrics.llm metrics.realtime metrics.stt metrics.tts metrics.vad participant.joined participant.left participant.speaking pong prompt.changed release.changed room.opened room.sent run.changed spend.unusual state.changed supervisor.ended supervisor.released supervisor.said supervisor.took_over supervisor.transferred supervisor.whispered tool.call tool.failed tool.ran tool.result tools.changed track.published track.unpublished turn.agent turn.user user.state user.transcript vendor.switched worker.changed].freeze
131
+ EVENT_TYPES = %w[agent.configured agent.detached agent.draining agent.registered agent.state agent.transcript agent.waiting app.failed attention.answered attention.requested call.attached call.claimed call.dialing call.ended call.line call.ringing call.score call.started call.summary call.transferred callback.requested code.claimed code.issued confirm.declined confirm.granted confirm.request credits.exhausted custom dev.request docs.sources dtmf.received error evals.spent event.received fleet.full judge.broke log.caught_up log.gap memory.ops message.taken message.waiting metrics.avatar metrics.eot metrics.eou metrics.interruption metrics.llm metrics.realtime metrics.stt metrics.tts metrics.vad participant.joined participant.left participant.speaking pong prompt.changed release.changed room.opened room.sent run.changed spend.unusual state.changed supervisor.ended supervisor.released supervisor.said supervisor.took_over supervisor.transferred supervisor.whispered tool.call tool.failed tool.ran tool.result tools.changed track.published track.unpublished turn.agent turn.user user.state user.transcript vendor.switched worker.changed].freeze
131
132
 
132
133
  # Every command an app may send.
133
134
  COMMAND_TYPES = %w[agent.configure agent.drain agent.register agent.reply agent.say call.attention call.callback call.claim call.dial call.done call.dtmf call.event call.hangup call.hold call.log call.mute call.opt_out call.transfer call.unhold call.unmute dev.answer participant.mute participant.remove ping prompt.set room.invite room.send session.configure state.set supervisor.verb tool.result tools.set].freeze
@@ -136,6 +136,10 @@ module Pinecall
136
136
  interrupted: { kind: :bool, required: true },
137
137
  metrics: { kind: :ref, ref: "AgentTurnMetrics", required: true }
138
138
  }.freeze,
139
+ "AgentWaiting" => {
140
+ speech_id: { kind: :str, required: true },
141
+ interrupted: { kind: :bool, required: true }
142
+ }.freeze,
139
143
  }.freeze
140
144
  end
141
145
  end
@@ -6,6 +6,60 @@ module Pinecall
6
6
  module Wire
7
7
  module Shapes
8
8
  CONFIG = {
9
+ "JudgeDeclaration" => {
10
+ name: { kind: :str, required: true },
11
+ question: { kind: :str, required: true },
12
+ answer: { kind: :enum, values: %w[verdict choice score], default: "verdict" },
13
+ choices: { kind: :list, items: { kind: :str } },
14
+ when: { kind: :enum, values: %w[always simulations trigger], default: "always" },
15
+ trigger: { kind: :str },
16
+ reads: { kind: :list, items: { kind: :enum, values: %w[prompt evidence facts] } }
17
+ }.freeze,
18
+ "JudgesDeclared" => {
19
+ on: { kind: :list, items: { kind: :str } },
20
+ own: { kind: :list, items: { kind: :ref, ref: "JudgeDeclaration" } }
21
+ }.freeze,
22
+ "CallerBehavior" => {
23
+ interrupts: { kind: :float },
24
+ pause_s: { kind: :float },
25
+ interferer_db: { kind: :float, null: true },
26
+ packet_loss: { kind: :float },
27
+ backchannels: { kind: :float },
28
+ speed: { kind: :float },
29
+ ambience: { kind: :enum, values: %w[television cafe office street] }
30
+ }.freeze,
31
+ "PersonaDeclaration" => {
32
+ name: { kind: :str, required: true },
33
+ goal: { kind: :str, required: true },
34
+ style: { kind: :str, required: true },
35
+ about: { kind: :str },
36
+ facts: { kind: :map, items: { kind: :str } },
37
+ state: { kind: :json },
38
+ expects: { kind: :list, items: { kind: :str } },
39
+ tags: { kind: :list, items: { kind: :str } },
40
+ behavior: { kind: :ref, ref: "CallerBehavior" },
41
+ llm: { kind: :str, null: true },
42
+ tts: { kind: :str, null: true },
43
+ voice: { kind: :str, null: true }
44
+ }.freeze,
45
+ "PersonasDeclared" => {
46
+ on: { kind: :list, items: { kind: :str } },
47
+ own: { kind: :list, items: { kind: :ref, ref: "PersonaDeclaration" } }
48
+ }.freeze,
49
+ "HoldConfig" => {
50
+ clip: { kind: :str, null: true },
51
+ name: { kind: :str, null: true },
52
+ after_s: { kind: :float, null: true },
53
+ off: { kind: :bool, default: false }
54
+ }.freeze,
55
+ "WidgetLook" => {
56
+ title: { kind: :str, null: true },
57
+ tagline: { kind: :str, null: true },
58
+ greeting: { kind: :str, null: true },
59
+ accent: { kind: :str, null: true },
60
+ autostart: { kind: :bool, default: false },
61
+ theme: { kind: :enum, values: %w[auto light dark], null: true }
62
+ }.freeze,
9
63
  "PromptBlockSpec" => {
10
64
  name: { kind: :str, required: true, pattern: "^[a-z][a-z0-9_]*$" },
11
65
  region: { kind: :ref, ref: "PromptRegion", required: true }
@@ -33,11 +33,17 @@ module Pinecall
33
33
  memory: { kind: :ref, ref: "MemoryConfig" },
34
34
  hangup: { kind: :ref, ref: "HangupConfig" },
35
35
  record: { kind: :bool, default: true },
36
+ max_duration_s: { kind: :int },
37
+ llm_timeout_s: { kind: :float },
36
38
  tools: { kind: :list, items: { kind: :ref, ref: "ToolSpec" } },
37
39
  uses_knowledge: { kind: :bool, default: false },
38
40
  state_fields: { kind: :list, items: { kind: :ref, ref: "StateFieldSpec" } },
39
41
  view: { kind: :ref, ref: "ViewSpec" },
40
- events: { kind: :list, items: { kind: :ref, ref: "EventSpec" } }
42
+ events: { kind: :list, items: { kind: :ref, ref: "EventSpec" } },
43
+ judges: { kind: :ref, ref: "JudgesDeclared" },
44
+ personas: { kind: :ref, ref: "PersonasDeclared" },
45
+ hold: { kind: :ref, ref: "HoldConfig" },
46
+ widget: { kind: :ref, ref: "WidgetLook" }
41
47
  }.freeze,
42
48
  "KnowledgePush" => {
43
49
  files: { kind: :list, items: { kind: :ref, ref: "KnowledgeFile" }, required: true }
data/sig/pinecall.rbs CHANGED
@@ -92,6 +92,10 @@ module Pinecall
92
92
  def self.language: (?String) -> untyped
93
93
  def self.says: (?Array[Hash[Symbol, String]]) -> untyped
94
94
  def self.record: (?bool) -> untyped
95
+ def self.max_duration: (?(Integer | Symbol)) -> untyped
96
+ def self.hold: (?(Symbol | Hash[Symbol, untyped]), **untyped) -> untyped
97
+ def self.widget: (**untyped) -> untyped
98
+ def self.llm_timeout: (?Numeric) -> untyped
95
99
  def self.hears: (*String | Array[String]) -> untyped
96
100
  def self.greeting: (?(String | Symbol | untyped), ?interruptible: bool?) -> untyped
97
101
  def self.improvise: (?String, ?interruptible: bool?) -> untyped
@@ -99,6 +103,8 @@ module Pinecall
99
103
  def self.turn: (**untyped) -> untyped
100
104
  def self.knowledge: (**untyped) -> untyped
101
105
  def self.docs: (**untyped) -> untyped
106
+ def self.judges: (**untyped) -> untyped
107
+ def self.personas: (**untyped) -> untyped
102
108
  def self.memory: (**untyped) -> untyped
103
109
  def self.environment: () -> Hash[Symbol, untyped]
104
110
 
@@ -470,6 +476,8 @@ module Pinecall
470
476
  def self?.channel_rules_for: (String | Symbol, String | Symbol) -> String
471
477
  end
472
478
 
479
+ def self.own_judge: (**untyped) -> Hash[Symbol, untyped]
480
+ def self.own_persona: (**untyped) -> Hash[Symbol, untyped]
473
481
  def self.mount: (Class, client: untyped, **untyped) -> Bridge::Mounted
474
482
  def self.render: (Agent, **untyped) -> Blocks
475
483
  def self.show_prompt: (Agent, **untyped) -> String
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.23
4
+ version: 0.11.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pinecall
@@ -41,7 +41,9 @@ files:
41
41
  - lib/pinecall/agent/author.rb
42
42
  - lib/pinecall/agent/config.rb
43
43
  - lib/pinecall/agent/doc.rb
44
+ - lib/pinecall/agent/harness.rb
44
45
  - lib/pinecall/agent/knowledge.rb
46
+ - lib/pinecall/agent/melody.rb
45
47
  - lib/pinecall/agent/searching.rb
46
48
  - lib/pinecall/agent/spec.rb
47
49
  - lib/pinecall/agent/state.rb
@@ -64,6 +66,8 @@ files:
64
66
  - lib/pinecall/reading.rb
65
67
  - lib/pinecall/rules.rb
66
68
  - lib/pinecall/serve.rb
69
+ - lib/pinecall/serve/declared_docs.rb
70
+ - lib/pinecall/serve/declared_hold.rb
67
71
  - lib/pinecall/serve/held.rb
68
72
  - lib/pinecall/serve/loading.rb
69
73
  - lib/pinecall/serve/masking.rb