Module: Insika::Commands::AgentPayload
- Defined in:
- lib/insika/commands/agent_payload.rb
Overview
Shared normalization for the agent-authoring payload. The transport delivers string keys (JSON); internal dispatch uses symbols. Here: symbolize the top level, keep only the fields buildable by AgentProfile, and re-symbolize the fields the runtime consumes as symbols (provider, policies, limits keys) — same rule as StoredProfileSource.
Constant Summary collapse
- FIELDS =
Fields accepted by AgentProfile.build (order irrelevant).
%i[id model provider base_prompt prompt_files tools_allow tools_deny tools_allow_groups skills skills_eager context_providers workflows_allow policies prompt_refs limits approvals_required capabilities subagents tools_deferred memory prompt_caching tool_output_compression budget reliability alerts stuck_signal params model_policy guardrails refinement capabilities_declared edge_stream metadata].freeze
Class Method Summary collapse
-
.attrs(payload) ⇒ Object
payload (string|symbol keys) -> Hash of attrs ready for AgentProfile.build.
-
.presence(str) ⇒ Object
Stable name used by the handlers; the rule lives in Insika::Coercion.
- .symbolize(payload) ⇒ Object
Class Method Details
.attrs(payload) ⇒ Object
payload (string|symbol keys) -> Hash of attrs ready for AgentProfile.build.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/insika/commands/agent_payload.rb', line 23 def attrs(payload) h = symbolize(payload) out = {} FIELDS.each { |f| out[f] = h[f] if h.key?(f) } out[:provider] = presence(out[:provider])&.to_sym if out.key?(:provider) out[:policies] = Array(out[:policies]).map(&:to_sym) if out.key?(:policies) out[:limits] = out[:limits].transform_keys(&:to_sym) if out[:limits].is_a?(Hash) # generation params consumed by symbol key (temperature/max_tokens/thinking). out[:params] = out[:params].transform_keys(&:to_sym) if out[:params].is_a?(Hash) out end |
.presence(str) ⇒ Object
Stable name used by the handlers; the rule lives in Insika::Coercion.
40 |
# File 'lib/insika/commands/agent_payload.rb', line 40 def presence(str) = Insika::Coercion.presence(str) |
.symbolize(payload) ⇒ Object
35 36 37 |
# File 'lib/insika/commands/agent_payload.rb', line 35 def symbolize(payload) (payload || {}).each_with_object({}) { |(k, v), acc| acc[k.to_sym] = v } end |