little_ghost 0.1.0

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.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +22 -0
  3. data/README.md +122 -0
  4. data/docs/guides/Core Concepts.md +203 -0
  5. data/docs/guides/Getting Started.md +187 -0
  6. data/lib/little_ghost/ag_ui/adapter.rb +194 -0
  7. data/lib/little_ghost/ag_ui.rb +5 -0
  8. data/lib/little_ghost/agent/context_management.rb +285 -0
  9. data/lib/little_ghost/agent/delegation.rb +128 -0
  10. data/lib/little_ghost/agent/skills.rb +96 -0
  11. data/lib/little_ghost/agent/tool_loop.rb +239 -0
  12. data/lib/little_ghost/agent.rb +2111 -0
  13. data/lib/little_ghost/agent_builder.rb +191 -0
  14. data/lib/little_ghost/agent_interruptions.rb +197 -0
  15. data/lib/little_ghost/configuration.rb +337 -0
  16. data/lib/little_ghost/content.rb +324 -0
  17. data/lib/little_ghost/default_model_registry.rb +71 -0
  18. data/lib/little_ghost/errors.rb +48 -0
  19. data/lib/little_ghost/events.rb +264 -0
  20. data/lib/little_ghost/execution_state.rb +58 -0
  21. data/lib/little_ghost/instrumentation.rb +475 -0
  22. data/lib/little_ghost/invocation.rb +285 -0
  23. data/lib/little_ghost/lookup.rb +37 -0
  24. data/lib/little_ghost/mcp/client.rb +396 -0
  25. data/lib/little_ghost/mcp.rb +5 -0
  26. data/lib/little_ghost/message.rb +75 -0
  27. data/lib/little_ghost/model.rb +88 -0
  28. data/lib/little_ghost/model_capabilities.rb +126 -0
  29. data/lib/little_ghost/model_registry.rb +173 -0
  30. data/lib/little_ghost/model_request.rb +107 -0
  31. data/lib/little_ghost/model_response.rb +48 -0
  32. data/lib/little_ghost/path_set.rb +32 -0
  33. data/lib/little_ghost/prompt_resolver.rb +251 -0
  34. data/lib/little_ghost/providers/bedrock.rb +506 -0
  35. data/lib/little_ghost/providers/http_transport.rb +149 -0
  36. data/lib/little_ghost/providers/open_router.rb +171 -0
  37. data/lib/little_ghost/providers/openai.rb +27 -0
  38. data/lib/little_ghost/providers/openai_compatible.rb +745 -0
  39. data/lib/little_ghost/providers/sse_parser.rb +35 -0
  40. data/lib/little_ghost/run.rb +607 -0
  41. data/lib/little_ghost/run_context.rb +129 -0
  42. data/lib/little_ghost/run_result.rb +111 -0
  43. data/lib/little_ghost/runtime/hook.rb +31 -0
  44. data/lib/little_ghost/runtime.rb +392 -0
  45. data/lib/little_ghost/sandbox.rb +138 -0
  46. data/lib/little_ghost/session.rb +229 -0
  47. data/lib/little_ghost/session_store.rb +96 -0
  48. data/lib/little_ghost/session_stores/agent_core_memory.rb +1086 -0
  49. data/lib/little_ghost/session_stores/memory.rb +86 -0
  50. data/lib/little_ghost/skills/catalog.rb +283 -0
  51. data/lib/little_ghost/skills/skill.rb +60 -0
  52. data/lib/little_ghost/skills.rb +4 -0
  53. data/lib/little_ghost/stream_event.rb +49 -0
  54. data/lib/little_ghost/structured_output.rb +126 -0
  55. data/lib/little_ghost/subagents/agent_path.rb +63 -0
  56. data/lib/little_ghost/subagents/definition.rb +42 -0
  57. data/lib/little_ghost/subagents/manager.rb +1615 -0
  58. data/lib/little_ghost/support/callbacks.rb +151 -0
  59. data/lib/little_ghost/support/cancellation_token.rb +86 -0
  60. data/lib/little_ghost/support/class_attributes.rb +40 -0
  61. data/lib/little_ghost/support/content_capture.rb +150 -0
  62. data/lib/little_ghost/support/executor.rb +75 -0
  63. data/lib/little_ghost/support/interruptible_stream.rb +103 -0
  64. data/lib/little_ghost/support/loader.rb +263 -0
  65. data/lib/little_ghost/support/output_truncation.rb +71 -0
  66. data/lib/little_ghost/support/redactor.rb +66 -0
  67. data/lib/little_ghost/support.rb +34 -0
  68. data/lib/little_ghost/tool.rb +448 -0
  69. data/lib/little_ghost/tool_execution.rb +59 -0
  70. data/lib/little_ghost/tool_registry.rb +156 -0
  71. data/lib/little_ghost/tools/filesystem.rb +119 -0
  72. data/lib/little_ghost/tools/shell.rb +45 -0
  73. data/lib/little_ghost/tools/write_todos.rb +91 -0
  74. data/lib/little_ghost/tools.rb +6 -0
  75. data/lib/little_ghost/tracing/open_telemetry.rb +517 -0
  76. data/lib/little_ghost/unrestricted_sandbox.rb +306 -0
  77. data/lib/little_ghost/usage.rb +47 -0
  78. data/lib/little_ghost/version.rb +6 -0
  79. data/lib/little_ghost/workflow.rb +351 -0
  80. data/lib/little_ghost/workspace.rb +31 -0
  81. data/lib/little_ghost.rb +120 -0
  82. metadata +225 -0
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LittleGhost
4
+ # A Workspace gives an agent a concrete home for files. Pair it with a Sandbox
5
+ # to decide how those files may be read, changed, or used by commands.
6
+ #
7
+ # workspace = LittleGhost::Workspace.new(root: "./tmp/support-run")
8
+ # workspace.root # => an absolute path ending in "/tmp/support-run"
9
+ #
10
+ # Workspaces participate in the run resource lifecycle. A custom workspace can
11
+ # provision storage in #open and release it in #close.
12
+ class Workspace
13
+ # Expands +root+ to an absolute path.
14
+ def initialize(root:)
15
+ @root = File.expand_path(root)
16
+ end
17
+
18
+ # Absolute filesystem root assigned to this workspace.
19
+ attr_reader :root
20
+
21
+ # Opens any run-scoped resources and yields this workspace to the run.
22
+ def open(run: nil)
23
+ self
24
+ end
25
+
26
+ # Releases workspace resources. The default workspace has nothing to close.
27
+ def close
28
+ nil
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "little_ghost/version"
4
+ require_relative "little_ghost/errors"
5
+ require_relative "little_ghost/execution_state"
6
+ require_relative "little_ghost/support"
7
+ require_relative "little_ghost/events"
8
+ require_relative "little_ghost/instrumentation"
9
+ require_relative "little_ghost/tracing/open_telemetry"
10
+ require_relative "little_ghost/invocation"
11
+ require_relative "little_ghost/lookup"
12
+ require_relative "little_ghost/path_set"
13
+ require_relative "little_ghost/usage"
14
+ require_relative "little_ghost/content"
15
+ require_relative "little_ghost/message"
16
+ require_relative "little_ghost/stream_event"
17
+ require_relative "little_ghost/model_request"
18
+ require_relative "little_ghost/model_response"
19
+ require_relative "little_ghost/run_result"
20
+ require_relative "little_ghost/model_capabilities"
21
+ require_relative "little_ghost/model"
22
+ require_relative "little_ghost/model_registry"
23
+ require_relative "little_ghost/providers/sse_parser"
24
+ require_relative "little_ghost/providers/http_transport"
25
+ require_relative "little_ghost/providers/openai_compatible"
26
+ require_relative "little_ghost/providers/openai"
27
+ require_relative "little_ghost/providers/open_router"
28
+ require_relative "little_ghost/providers/bedrock"
29
+ require_relative "little_ghost/default_model_registry"
30
+ require_relative "little_ghost/run_context"
31
+ require_relative "little_ghost/workspace"
32
+ require_relative "little_ghost/sandbox"
33
+ require_relative "little_ghost/unrestricted_sandbox"
34
+ require_relative "little_ghost/tool"
35
+ require_relative "little_ghost/tool_execution"
36
+ require_relative "little_ghost/tool_registry"
37
+ require_relative "little_ghost/structured_output"
38
+ require_relative "little_ghost/prompt_resolver"
39
+ require_relative "little_ghost/session_store"
40
+ require_relative "little_ghost/session_stores/memory"
41
+ require_relative "little_ghost/session"
42
+ require_relative "little_ghost/skills"
43
+ require_relative "little_ghost/tools/write_todos"
44
+ require_relative "little_ghost/run"
45
+ require_relative "little_ghost/subagents/definition"
46
+ require_relative "little_ghost/subagents/agent_path"
47
+ require_relative "little_ghost/subagents/manager"
48
+ require_relative "little_ghost/agent_interruptions"
49
+ require_relative "little_ghost/agent"
50
+ require_relative "little_ghost/agent_builder"
51
+ require_relative "little_ghost/workflow"
52
+ require_relative "little_ghost/runtime/hook"
53
+ require_relative "little_ghost/runtime"
54
+
55
+ # Build AI features with reusable agents and agentic workflows. LittleGhost can
56
+ # sit inside an existing Ruby system or support a dedicated AI service, keeping
57
+ # models, prompts, tools, sessions, streaming, and instrumentation behind a
58
+ # cohesive set of Ruby conventions.
59
+ #
60
+ # A customer support agent can answer directly, use an application tool, or ask a
61
+ # specialist for research while the caller observes one run:
62
+ #
63
+ # LittleGhost.configure do |config|
64
+ # config.models CustomerSupportModels
65
+ # config.default_model :customer_support
66
+ # end
67
+ #
68
+ # class ResearchAgent < LittleGhost::Agent
69
+ # description "Researches difficult support questions"
70
+ # model "customer_support.research"
71
+ # end
72
+ #
73
+ # class CustomerSupportAgent < LittleGhost::Agent
74
+ # description "Handles support requests"
75
+ # model :customer_support
76
+ # tools AccountTool
77
+ # subagent ResearchAgent, kind: "research"
78
+ # end
79
+ #
80
+ # run = CustomerSupportAgent.ask("Why is transfer 481 still pending?")
81
+ # run.completed? # => true
82
+ # run.response # => "Transfer 481 is waiting for the receiving bank."
83
+ #
84
+ # Agent subclasses hold reusable behavior; Invocation objects carry one request,
85
+ # and Run objects own execution and cleanup. Workflow subclasses can compose
86
+ # several agents when ordinary Ruby branching is clearer than one agent loop.
87
+ #
88
+ # LittleGhost.configuration is process-wide unless LittleGhost.with_configuration
89
+ # supplies an execution-scoped replacement. Configuration is loaded lazily and
90
+ # snapshotted into a Runtime, so make application changes before the first agent
91
+ # runtime is built.
92
+ module LittleGhost
93
+ class << self
94
+ # The configuration active in the current execution context, falling back to
95
+ # the process-wide default.
96
+ def configuration
97
+ ExecutionState[:configuration] || (@configuration ||= Configuration.new)
98
+ end
99
+
100
+ # Alias for .configuration. Without an execution-scoped override, this is the
101
+ # process-wide default Configuration.
102
+ alias_method :default_configuration, :configuration
103
+
104
+ # Opens the active Configuration for application setup and returns it.
105
+ #
106
+ # Configuration files are loaded lazily when a runtime is first built, so
107
+ # make application-level changes before invoking an agent.
108
+ def configure(&block)
109
+ configuration.configure(&block)
110
+ end
111
+
112
+ # Makes +configuration+ current only while the block runs.
113
+ #
114
+ # Execution state restores the previous configuration even when the block
115
+ # raises. Other execution contexts continue to see their own configuration.
116
+ def with_configuration(configuration)
117
+ ExecutionState.with(configuration:) { yield }
118
+ end
119
+ end
120
+ end
metadata ADDED
@@ -0,0 +1,225 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: little_ghost
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Matt Robinson
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: base64
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: opentelemetry-api
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: minitest
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '5.25'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '5.25'
54
+ - !ruby/object:Gem::Dependency
55
+ name: rake
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '13.2'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '13.2'
68
+ - !ruby/object:Gem::Dependency
69
+ name: rdoc
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '8.0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '8.0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: standard
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '1.44'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '1.44'
96
+ - !ruby/object:Gem::Dependency
97
+ name: webrick
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.9'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '1.9'
110
+ description: Add agents, tools, and agentic workflows to existing Ruby systems or
111
+ dedicated AI services.
112
+ email:
113
+ - robinson.matty@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - LICENSE.txt
119
+ - README.md
120
+ - docs/guides/Core Concepts.md
121
+ - docs/guides/Getting Started.md
122
+ - lib/little_ghost.rb
123
+ - lib/little_ghost/ag_ui.rb
124
+ - lib/little_ghost/ag_ui/adapter.rb
125
+ - lib/little_ghost/agent.rb
126
+ - lib/little_ghost/agent/context_management.rb
127
+ - lib/little_ghost/agent/delegation.rb
128
+ - lib/little_ghost/agent/skills.rb
129
+ - lib/little_ghost/agent/tool_loop.rb
130
+ - lib/little_ghost/agent_builder.rb
131
+ - lib/little_ghost/agent_interruptions.rb
132
+ - lib/little_ghost/configuration.rb
133
+ - lib/little_ghost/content.rb
134
+ - lib/little_ghost/default_model_registry.rb
135
+ - lib/little_ghost/errors.rb
136
+ - lib/little_ghost/events.rb
137
+ - lib/little_ghost/execution_state.rb
138
+ - lib/little_ghost/instrumentation.rb
139
+ - lib/little_ghost/invocation.rb
140
+ - lib/little_ghost/lookup.rb
141
+ - lib/little_ghost/mcp.rb
142
+ - lib/little_ghost/mcp/client.rb
143
+ - lib/little_ghost/message.rb
144
+ - lib/little_ghost/model.rb
145
+ - lib/little_ghost/model_capabilities.rb
146
+ - lib/little_ghost/model_registry.rb
147
+ - lib/little_ghost/model_request.rb
148
+ - lib/little_ghost/model_response.rb
149
+ - lib/little_ghost/path_set.rb
150
+ - lib/little_ghost/prompt_resolver.rb
151
+ - lib/little_ghost/providers/bedrock.rb
152
+ - lib/little_ghost/providers/http_transport.rb
153
+ - lib/little_ghost/providers/open_router.rb
154
+ - lib/little_ghost/providers/openai.rb
155
+ - lib/little_ghost/providers/openai_compatible.rb
156
+ - lib/little_ghost/providers/sse_parser.rb
157
+ - lib/little_ghost/run.rb
158
+ - lib/little_ghost/run_context.rb
159
+ - lib/little_ghost/run_result.rb
160
+ - lib/little_ghost/runtime.rb
161
+ - lib/little_ghost/runtime/hook.rb
162
+ - lib/little_ghost/sandbox.rb
163
+ - lib/little_ghost/session.rb
164
+ - lib/little_ghost/session_store.rb
165
+ - lib/little_ghost/session_stores/agent_core_memory.rb
166
+ - lib/little_ghost/session_stores/memory.rb
167
+ - lib/little_ghost/skills.rb
168
+ - lib/little_ghost/skills/catalog.rb
169
+ - lib/little_ghost/skills/skill.rb
170
+ - lib/little_ghost/stream_event.rb
171
+ - lib/little_ghost/structured_output.rb
172
+ - lib/little_ghost/subagents/agent_path.rb
173
+ - lib/little_ghost/subagents/definition.rb
174
+ - lib/little_ghost/subagents/manager.rb
175
+ - lib/little_ghost/support.rb
176
+ - lib/little_ghost/support/callbacks.rb
177
+ - lib/little_ghost/support/cancellation_token.rb
178
+ - lib/little_ghost/support/class_attributes.rb
179
+ - lib/little_ghost/support/content_capture.rb
180
+ - lib/little_ghost/support/executor.rb
181
+ - lib/little_ghost/support/interruptible_stream.rb
182
+ - lib/little_ghost/support/loader.rb
183
+ - lib/little_ghost/support/output_truncation.rb
184
+ - lib/little_ghost/support/redactor.rb
185
+ - lib/little_ghost/tool.rb
186
+ - lib/little_ghost/tool_execution.rb
187
+ - lib/little_ghost/tool_registry.rb
188
+ - lib/little_ghost/tools.rb
189
+ - lib/little_ghost/tools/filesystem.rb
190
+ - lib/little_ghost/tools/shell.rb
191
+ - lib/little_ghost/tools/write_todos.rb
192
+ - lib/little_ghost/tracing/open_telemetry.rb
193
+ - lib/little_ghost/unrestricted_sandbox.rb
194
+ - lib/little_ghost/usage.rb
195
+ - lib/little_ghost/version.rb
196
+ - lib/little_ghost/workflow.rb
197
+ - lib/little_ghost/workspace.rb
198
+ homepage: https://github.com/mattyr/little_ghost
199
+ licenses:
200
+ - MIT
201
+ metadata:
202
+ bug_tracker_uri: https://github.com/mattyr/little_ghost/issues
203
+ changelog_uri: https://github.com/mattyr/little_ghost/releases
204
+ documentation_uri: https://mattyr.github.io/little_ghost/docs/
205
+ source_code_uri: https://github.com/mattyr/little_ghost
206
+ allowed_push_host: https://rubygems.org
207
+ rubygems_mfa_required: 'true'
208
+ rdoc_options: []
209
+ require_paths:
210
+ - lib
211
+ required_ruby_version: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '3.3'
216
+ required_rubygems_version: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - ">="
219
+ - !ruby/object:Gem::Version
220
+ version: '0'
221
+ requirements: []
222
+ rubygems_version: 4.0.10
223
+ specification_version: 4
224
+ summary: A Ruby framework for AI features with agents and agentic workflows
225
+ test_files: []