Class: Insika::DSL::Definition
- Inherits:
-
Object
- Object
- Insika::DSL::Definition
- Defined in:
- lib/insika/dsl/definition.rb
Overview
The result of Insika.agent("id") { … }. Holds the generated Pack and knows
how to run it — but stays gem-free until you actually chat/serve/introspect:
the runtime (ruby_llm + the HTTP server) is required lazily inside Runtime.
Every runtime path goes through the SAME config-over-code import: the pack is
imported (create_agent + write_agent_file/skill/data_tool) into a StoredProfileSource,
exactly like any other pack. That is what makes #profile identical to a
hand-written equivalent pack (the parity spec) — there is only one path.
Instance Attribute Summary collapse
-
#pack ⇒ Object
readonly
Returns the value of attribute pack.
-
#runtime_options ⇒ Object
readonly
Returns the value of attribute runtime_options.
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(pack:, runtime: {}) ⇒ Definition
constructor
A new instance of Definition.
-
#profile ⇒ Object
The AgentProfile the engine runs, read back from the store after import — so it is byte-for-byte what a hand-written equivalent pack produces.
-
#reply(message, session: nil, timeout: nil) ⇒ Object
(also: #chat)
One turn, in-process, returns the assistant's text.
-
#runtime ⇒ Object
The live runtime graph (Executor + bus + stores) with the pack imported.
-
#serve(port: 9292, host: "localhost", token: nil, **opts) ⇒ Object
Boot the control UI (/studio) + the drop-in API (/v1) — the "1 command" of the quickstart.
-
#to_pack ⇒ Object
The generated portable artifact — hand it to any PackImporter and you get this same agent.
Constructor Details
#initialize(pack:, runtime: {}) ⇒ Definition
Returns a new instance of Definition.
16 17 18 19 |
# File 'lib/insika/dsl/definition.rb', line 16 def initialize(pack:, runtime: {}) @pack = pack @runtime_options = runtime end |
Instance Attribute Details
#pack ⇒ Object (readonly)
Returns the value of attribute pack.
14 15 16 |
# File 'lib/insika/dsl/definition.rb', line 14 def pack @pack end |
#runtime_options ⇒ Object (readonly)
Returns the value of attribute runtime_options.
14 15 16 |
# File 'lib/insika/dsl/definition.rb', line 14 def @runtime_options end |
Instance Method Details
#id ⇒ Object
21 |
# File 'lib/insika/dsl/definition.rb', line 21 def id = pack.config[:id].to_s |
#profile ⇒ Object
The AgentProfile the engine runs, read back from the store after import — so it is byte-for-byte what a hand-written equivalent pack produces.
29 |
# File 'lib/insika/dsl/definition.rb', line 29 def profile = runtime.profile |
#reply(message, session: nil, timeout: nil) ⇒ Object Also known as: chat
One turn, in-process, returns the assistant's text. session: threads
multi-turn memory (a session is created on first use); omit it for a
stateless one-shot. Raises on a failed/cancelled turn.
34 35 36 |
# File 'lib/insika/dsl/definition.rb', line 34 def reply(, session: nil, timeout: nil) runtime.chat(, session_id: session, timeout: timeout) end |
#runtime ⇒ Object
The live runtime graph (Executor + bus + stores) with the pack imported. Memoized: chat/serve/profile share one graph. Pulls in ruby_llm here.
47 48 49 50 51 52 |
# File 'lib/insika/dsl/definition.rb', line 47 def runtime @runtime ||= begin require_relative "runtime" Runtime.new(self) end end |
#serve(port: 9292, host: "localhost", token: nil, **opts) ⇒ Object
Boot the control UI (/studio) + the drop-in API (/v1) — the "1 command" of the quickstart. Blocks (runs the reactor) until interrupted.
41 42 43 |
# File 'lib/insika/dsl/definition.rb', line 41 def serve(port: 9292, host: "localhost", token: nil, **opts) runtime.serve(port: port, host: host, token: token, **opts) end |
#to_pack ⇒ Object
The generated portable artifact — hand it to any PackImporter and you get this same agent. This is the DSL's real output.
25 |
# File 'lib/insika/dsl/definition.rb', line 25 def to_pack = @pack |