language-operator 0.1.70 → 0.1.80

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.
@@ -4,6 +4,7 @@ require_relative 'agent/base'
4
4
  require_relative 'agent/executor'
5
5
  require_relative 'agent/task_executor'
6
6
  require_relative 'agent/web_server'
7
+ require_relative 'agent/execution_state'
7
8
  require_relative 'agent/instrumentation'
8
9
  require_relative 'dsl'
9
10
  require_relative 'logger'
@@ -162,15 +163,14 @@ module LanguageOperator
162
163
  # Hybrid mode: All agents now run main work AND web server (chat endpoints always enabled)
163
164
  logger.info('Starting hybrid agent (autonomous + web server)',
164
165
  agent_name: agent_def.name,
165
- chat_endpoint_enabled: true, # Always true now
166
+ chat_endpoint_enabled: true, # Always true now
166
167
  has_webhooks: agent_def.webhooks.any?,
167
- has_mcp_tools: !!(agent_def.mcp_server&.tools?))
168
+ has_mcp_tools: !!agent_def.mcp_server&.tools?)
168
169
 
169
170
  # Start web server in background thread
170
171
  web_server = LanguageOperator::Agent::WebServer.new(agent)
171
172
  agent_def.webhooks.each { |webhook_def| webhook_def.register(web_server) }
172
- web_server.register_mcp_tools(agent_def.mcp_server) if agent_def.mcp_server&.tools?
173
- web_server.register_chat_endpoint(agent_def.chat_endpoint, agent) # Always register chat endpoint
173
+ register_standard_endpoints(web_server, agent, agent_def)
174
174
 
175
175
  web_thread = Thread.new do
176
176
  web_server.start
@@ -199,33 +199,30 @@ module LanguageOperator
199
199
  raise 'Agent definition must have either main block (DSL v1) or workflow (DSL v0)'
200
200
  end
201
201
  when 'scheduled', 'event-driven'
202
- # Scheduled mode: Execute once and exit (Kubernetes CronJob handles scheduling)
203
- logger.info('Agent running in scheduled mode - executing once',
202
+ # Standby mode - web server only, wait for /api/v1/execute triggers
203
+ logger.info('Starting agent in standby mode (scheduled) - waiting for HTTP triggers',
204
204
  agent_name: agent_def.name,
205
- dsl_version: uses_dsl_v1 ? 'v1' : 'v0')
206
-
207
- if uses_dsl_v1
208
- # DSL v1: Execute main block once
209
- execute_main_block(agent, agent_def)
210
- elsif uses_dsl_v0
211
- # DSL v0: Execute workflow once
212
- executor = LanguageOperator::Agent::Executor.new(agent)
213
- executor.execute_workflow(agent_def)
214
- else
215
- raise 'Agent definition must have either main block (DSL v1) or workflow (DSL v0)'
216
- end
205
+ chat_endpoint_enabled: true,
206
+ has_webhooks: agent_def.webhooks.any?,
207
+ has_mcp_tools: !!agent_def.mcp_server&.tools?)
217
208
 
218
- logger.info('Scheduled execution completed - exiting',
219
- agent_name: agent_def.name)
209
+ web_server = LanguageOperator::Agent::WebServer.new(agent)
210
+ agent_def.webhooks.each { |webhook_def| webhook_def.register(web_server) }
211
+ register_standard_endpoints(web_server, agent, agent_def)
212
+ web_server.register_execute_endpoint(agent, agent_def)
220
213
 
221
- # Flush telemetry for short-lived processes
222
- agent.send(:flush_telemetry)
214
+ web_server.start # Blocks here, waiting for requests
223
215
  when 'reactive', 'http', 'webhook'
224
- # Start web server with webhooks, MCP tools, and chat endpoint
216
+ # Standby mode - web server with webhooks, MCP tools, chat, and execute endpoint
217
+ logger.info('Starting agent in standby mode (reactive)',
218
+ agent_name: agent_def.name,
219
+ has_webhooks: agent_def.webhooks.any?)
220
+
225
221
  web_server = LanguageOperator::Agent::WebServer.new(agent)
226
222
  agent_def.webhooks.each { |webhook_def| webhook_def.register(web_server) }
227
- web_server.register_mcp_tools(agent_def.mcp_server) if agent_def.mcp_server&.tools?
228
- web_server.register_chat_endpoint(agent_def.chat_endpoint, agent) if agent_def.chat_endpoint
223
+ register_standard_endpoints(web_server, agent, agent_def)
224
+ web_server.register_execute_endpoint(agent, agent_def)
225
+
229
226
  web_server.start
230
227
  else
231
228
  raise "Unknown agent mode: #{agent.mode}"
@@ -233,6 +230,18 @@ module LanguageOperator
233
230
  end
234
231
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
235
232
 
233
+ # Register standard endpoints for web server
234
+ #
235
+ # @param web_server [LanguageOperator::Agent::WebServer] The web server instance
236
+ # @param agent [LanguageOperator::Agent::Base] The agent instance
237
+ # @param agent_def [LanguageOperator::Dsl::AgentDefinition] The agent definition
238
+ # @return [void]
239
+ def self.register_standard_endpoints(web_server, agent, agent_def)
240
+ web_server.register_mcp_tools(agent_def.mcp_server) if agent_def.mcp_server&.tools?
241
+ web_server.register_chat_endpoint(agent)
242
+ web_server.register_workspace_endpoints(agent)
243
+ end
244
+
236
245
  # Execute main block (DSL v1) in autonomous mode
237
246
  #
238
247
  # @param agent [LanguageOperator::Agent::Base] The agent instance
@@ -4,7 +4,6 @@ require_relative 'main_definition'
4
4
  require_relative 'task_definition'
5
5
  require_relative 'webhook_definition'
6
6
  require_relative 'mcp_server_definition'
7
- require_relative 'chat_endpoint_definition'
8
7
  require_relative '../logger'
9
8
  require_relative '../loggable'
10
9
 
@@ -64,7 +63,6 @@ module LanguageOperator
64
63
  @execution_mode = :autonomous
65
64
  @webhooks = []
66
65
  @mcp_server = nil
67
- @chat_endpoint = nil
68
66
 
69
67
  logger.debug('Agent definition initialized',
70
68
  name: name,
@@ -314,29 +312,6 @@ module LanguageOperator
314
312
  @mcp_server
315
313
  end
316
314
 
317
- # Get chat endpoint definition (always available)
318
- #
319
- # Returns the chat endpoint definition. If none was explicitly configured,
320
- # returns a default chat endpoint with basic configuration.
321
- #
322
- # @return [ChatEndpointDefinition] The chat endpoint definition
323
- def chat_endpoint
324
- @chat_endpoint ||= create_default_chat_endpoint
325
- end
326
-
327
- # Define chat endpoint capabilities
328
- #
329
- # Allows this agent to respond to OpenAI-compatible chat completion requests.
330
- # Other systems can treat this agent as a language model.
331
- #
332
- # @yield Chat endpoint configuration block
333
- # @return [ChatEndpointDefinition] The chat endpoint definition
334
- def as_chat_endpoint(&block)
335
- @chat_endpoint ||= ChatEndpointDefinition.new(@name)
336
- @chat_endpoint.instance_eval(&block) if block
337
- # Note: Don't force mode change - agents can be autonomous AND have chat endpoints
338
- @chat_endpoint
339
- end
340
315
 
341
316
  # Execute the agent
342
317
  #
@@ -363,31 +338,6 @@ module LanguageOperator
363
338
 
364
339
  private
365
340
 
366
- # Create default chat endpoint configuration
367
- #
368
- # @return [ChatEndpointDefinition] Default chat endpoint
369
- def create_default_chat_endpoint
370
- endpoint = ChatEndpointDefinition.new(@name)
371
-
372
- # Set default system prompt based on agent description
373
- default_prompt = if @description
374
- "You are #{@description.downcase}. Provide helpful assistance based on your capabilities."
375
- else
376
- "You are an AI agent named #{@name}. Provide helpful assistance to users."
377
- end
378
-
379
- endpoint.system_prompt(default_prompt)
380
- endpoint.model(@name) # Use agent name as model name
381
- endpoint.temperature(0.7) # Balanced default
382
- endpoint.max_tokens(2000) # Reasonable default
383
-
384
- logger.debug('Created default chat endpoint',
385
- agent_name: @name,
386
- model_name: @name,
387
- system_prompt: default_prompt[0..100])
388
-
389
- endpoint
390
- end
391
341
 
392
342
  def logger_component
393
343
  "Agent:#{@name}"
@@ -403,7 +353,7 @@ module LanguageOperator
403
353
  name: @name,
404
354
  webhooks: @webhooks.size,
405
355
  mcp_tools: @mcp_server&.tools&.size || 0,
406
- chat_endpoint: !@chat_endpoint.nil?)
356
+ chat_endpoint: true)
407
357
 
408
358
  # Create an Agent::Base instance with this definition
409
359
  require_relative '../agent/base'
@@ -427,8 +377,8 @@ module LanguageOperator
427
377
  # Register MCP tools
428
378
  web_server.register_mcp_tools(@mcp_server) if @mcp_server&.tools?
429
379
 
430
- # Register chat endpoint
431
- web_server.register_chat_endpoint(@chat_endpoint, agent) if @chat_endpoint
380
+ # Register chat endpoint - automatic for all agents
381
+ web_server.register_chat_endpoint(agent)
432
382
 
433
383
  # Start the server
434
384
  web_server.start
@@ -3,11 +3,15 @@
3
3
  module LanguageOperator
4
4
  module Dsl
5
5
  # Chat endpoint definition for agents
6
+ #
7
+ # DEPRECATED: This class is deprecated. All agents now automatically get
8
+ # identity-aware chat endpoints without configuration. The `as_chat_endpoint`
9
+ # DSL method is no longer needed.
6
10
  #
7
11
  # Allows agents to expose an OpenAI-compatible chat completion endpoint.
8
12
  # Other systems can treat the agent as a language model.
9
13
  #
10
- # @example Define chat endpoint in an agent
14
+ # @example Define basic chat endpoint
11
15
  # agent "github-expert" do
12
16
  # as_chat_endpoint do
13
17
  # system_prompt "You are a GitHub API expert"
@@ -15,9 +19,26 @@ module LanguageOperator
15
19
  # max_tokens 2000
16
20
  # end
17
21
  # end
22
+ #
23
+ # @example Define chat endpoint with identity awareness
24
+ # agent "support-bot" do
25
+ # as_chat_endpoint do
26
+ # system_prompt "You are a helpful customer support assistant"
27
+ #
28
+ # # Configure identity awareness and context injection
29
+ # identity_awareness do
30
+ # enabled true
31
+ # prompt_template :detailed
32
+ # context_injection :standard
33
+ # end
34
+ #
35
+ # temperature 0.8
36
+ # end
37
+ # end
18
38
  class ChatEndpointDefinition
19
39
  attr_reader :system_prompt, :temperature, :max_tokens, :model_name,
20
- :top_p, :frequency_penalty, :presence_penalty, :stop_sequences
40
+ :top_p, :frequency_penalty, :presence_penalty, :stop_sequences,
41
+ :identity_awareness_enabled, :prompt_template_level, :context_injection_level
21
42
 
22
43
  def initialize(agent_name)
23
44
  @agent_name = agent_name
@@ -29,6 +50,11 @@ module LanguageOperator
29
50
  @frequency_penalty = 0.0
30
51
  @presence_penalty = 0.0
31
52
  @stop_sequences = nil
53
+
54
+ # Identity awareness and context injection settings
55
+ @identity_awareness_enabled = true
56
+ @prompt_template_level = :standard
57
+ @context_injection_level = :standard
32
58
  end
33
59
 
34
60
  # Set system prompt for chat mode
@@ -110,6 +136,90 @@ module LanguageOperator
110
136
 
111
137
  @stop_sequences = sequences
112
138
  end
139
+
140
+ # Enable or disable identity awareness and context injection
141
+ #
142
+ # When enabled, the system prompt will be dynamically enhanced with
143
+ # agent identity, operational context, and environment information.
144
+ #
145
+ # @param enabled [Boolean] Whether to enable identity awareness
146
+ # @return [Boolean] Current setting
147
+ def enable_identity_awareness(enabled = nil)
148
+ return @identity_awareness_enabled if enabled.nil?
149
+
150
+ @identity_awareness_enabled = enabled
151
+ end
152
+
153
+ # Set the prompt template level for context injection
154
+ #
155
+ # Available levels:
156
+ # - :minimal - Basic agent identity only
157
+ # - :standard - Identity + basic operational context (default)
158
+ # - :detailed - Full context with capabilities
159
+ # - :comprehensive - All available context and guidelines
160
+ #
161
+ # @param level [Symbol] Template level
162
+ # @return [Symbol] Current template level
163
+ def prompt_template(level = nil)
164
+ return @prompt_template_level if level.nil?
165
+
166
+ valid_levels = [:minimal, :standard, :detailed, :comprehensive]
167
+ unless valid_levels.include?(level)
168
+ raise ArgumentError, "Invalid template level: #{level}. Must be one of: #{valid_levels.join(', ')}"
169
+ end
170
+
171
+ @prompt_template_level = level
172
+ end
173
+
174
+ # Set the context injection level for conversations
175
+ #
176
+ # Controls how much operational context is injected into ongoing conversations.
177
+ #
178
+ # Available levels:
179
+ # - :none - No context injection
180
+ # - :minimal - Basic status only
181
+ # - :standard - Standard operational context (default)
182
+ # - :detailed - Full context with metrics
183
+ #
184
+ # @param level [Symbol] Context injection level
185
+ # @return [Symbol] Current context injection level
186
+ def context_injection(level = nil)
187
+ return @context_injection_level if level.nil?
188
+
189
+ valid_levels = [:none, :minimal, :standard, :detailed]
190
+ unless valid_levels.include?(level)
191
+ raise ArgumentError, "Invalid context level: #{level}. Must be one of: #{valid_levels.join(', ')}"
192
+ end
193
+
194
+ @context_injection_level = level
195
+ end
196
+
197
+ # Configure identity awareness with options block
198
+ #
199
+ # @example
200
+ # identity_awareness do
201
+ # enabled true
202
+ # prompt_template :detailed
203
+ # context_injection :standard
204
+ # end
205
+ #
206
+ # @yield Block for configuring identity awareness options
207
+ def identity_awareness(&block)
208
+ if block_given?
209
+ instance_eval(&block)
210
+ else
211
+ {
212
+ enabled: @identity_awareness_enabled,
213
+ prompt_template: @prompt_template_level,
214
+ context_injection: @context_injection_level
215
+ }
216
+ end
217
+ end
218
+
219
+ # Alias methods for convenience
220
+ alias_method :enabled, :enable_identity_awareness
221
+ alias_method :template, :prompt_template
222
+ alias_method :context, :context_injection
113
223
  end
114
224
  end
115
225
  end
@@ -2,7 +2,7 @@
2
2
  :openapi: 3.0.3
3
3
  :info:
4
4
  :title: Language Operator Agent API
5
- :version: 0.1.70
5
+ :version: 0.1.73
6
6
  :description: HTTP API endpoints exposed by Language Operator reactive agents
7
7
  :contact:
8
8
  :name: Language Operator
@@ -3,7 +3,7 @@
3
3
  "$id": "https://github.com/language-operator/language-operator-gem/schema/agent-dsl.json",
4
4
  "title": "Language Operator Agent DSL",
5
5
  "description": "Schema for defining autonomous AI agents using the Language Operator DSL",
6
- "version": "0.1.70",
6
+ "version": "0.1.73",
7
7
  "type": "object",
8
8
  "properties": {
9
9
  "name": {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LanguageOperator
4
- VERSION = '0.1.70'
4
+ VERSION = '0.1.80'
5
5
  end
data/synth/003/Makefile CHANGED
@@ -27,11 +27,17 @@ inspect:
27
27
  learning-status:
28
28
  $(AICTL) learning status $(AGENT)
29
29
 
30
+ learn:
31
+ kubectl patch languageagent $(AGENT) --type='merge' -p='{"status":{"runsPendingLearning":10}}'
32
+
33
+
30
34
  logs:
31
35
  $(AICTL) logs $(AGENT)
32
36
 
33
37
  clean:
34
38
  $(AICTL) delete $(AGENT) --force
39
+ kubectl delete configmaps -l app.kubernetes.io/name=$(AGENT) --ignore-not-found=true
40
+ kubectl delete configmaps --field-selector metadata.name~=$(AGENT)-v --ignore-not-found=true
35
41
 
36
42
  save:
37
43
  $(AICTL) code $(AGENT) --raw > agent.rb
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: language-operator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.70
4
+ version: 0.1.80
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Ryan
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 2025-12-26 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: mcp
@@ -517,22 +517,28 @@ files:
517
517
  - docs/how-agents-work.md
518
518
  - docs/installation.md
519
519
  - docs/observability.md
520
+ - docs/persona-driven-system-prompts.md
520
521
  - docs/quickstart.md
521
522
  - docs/schema-versioning.md
522
523
  - docs/understanding-generated-code.md
523
524
  - docs/using-tools.md
524
525
  - docs/webhooks.md
526
+ - examples/basic_agent_with_default_chat.rb
525
527
  - examples/chat_endpoint_agent.rb
526
528
  - examples/hybrid_agent.rb
529
+ - examples/identity_aware_chat_agent.rb
527
530
  - examples/pure_agent_test.rb
528
531
  - examples/ux_helpers_demo.rb
529
532
  - lib/language_operator.rb
530
533
  - lib/language_operator/agent.rb
531
534
  - lib/language_operator/agent/base.rb
532
535
  - lib/language_operator/agent/event_config.rb
536
+ - lib/language_operator/agent/execution_state.rb
533
537
  - lib/language_operator/agent/executor.rb
534
538
  - lib/language_operator/agent/instrumentation.rb
539
+ - lib/language_operator/agent/metadata_collector.rb
535
540
  - lib/language_operator/agent/metrics_tracker.rb
541
+ - lib/language_operator/agent/prompt_builder.rb
536
542
  - lib/language_operator/agent/safety/ast_validator.rb
537
543
  - lib/language_operator/agent/safety/audit_logger.rb
538
544
  - lib/language_operator/agent/safety/budget_tracker.rb
@@ -693,7 +699,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
693
699
  - !ruby/object:Gem::Version
694
700
  version: '0'
695
701
  requirements: []
696
- rubygems_version: 3.6.9
702
+ rubygems_version: 3.6.6
697
703
  specification_version: 4
698
704
  summary: Ruby SDK for Language Operator
699
705
  test_files: []