summaryrefslogtreecommitdiff
path: root/controllers/session.rb
diff options
context:
space:
mode:
authoricebaker <113217272+icebaker@users.noreply.github.com>2023-12-07 20:46:28 -0300
committerGitHub <noreply@github.com>2023-12-07 20:46:28 -0300
commitfc87c60558a085f1917068802767958eab8c3263 (patch)
tree165e52d98ade38c10eb7de91120208f0293a140c /controllers/session.rb
parent6a6b154f0453875d09bbf86127c475a2b9020aa7 (diff)
parent9d9702b39db67ab66894e5483a267a05ea0f6a2d (diff)
Merge pull request #8 from icebaker/ib-tools-meta
Adding tools medatada
Diffstat (limited to 'controllers/session.rb')
-rw-r--r--controllers/session.rb21
1 files changed, 17 insertions, 4 deletions
diff --git a/controllers/session.rb b/controllers/session.rb
index 378a11d..aabcb41 100644
--- a/controllers/session.rb
+++ b/controllers/session.rb
@@ -11,6 +11,7 @@ require_relative '../logic/cartridge/streaming'
require_relative '../logic/cartridge/interaction'
require_relative '../logic/cartridge/fetch'
require_relative 'interfaces/tools'
+require_relative '../components/stream'
require_relative '../components/storage'
require_relative '../components/adapter'
require_relative '../components/crypto'
@@ -56,11 +57,19 @@ module NanoBot
end
def boot(mode:)
- return unless Logic::Helpers::Hash.fetch(@cartridge, %i[behaviors boot instruction])
+ instruction = Logic::Helpers::Hash.fetch(@cartridge, %i[behaviors boot instruction])
+ return unless instruction
behavior = Logic::Helpers::Hash.fetch(@cartridge, %i[behaviors boot]) || {}
- input = { behavior:, history: [] }
+ @state[:history] << {
+ who: 'user',
+ mode: mode.to_s,
+ input: instruction,
+ message: instruction
+ }
+
+ input = { behavior:, history: @state[:history] }
process(input, mode:)
end
@@ -182,8 +191,12 @@ module NanoBot
@stream.flush
end
- def print(content)
- @stream.write(content)
+ def print(content, meta = nil)
+ if @stream.is_a?(NanoBot::Components::Stream)
+ @stream.write(content, meta)
+ else
+ @stream.write(content)
+ end
end
end
end