Class: LanguageOperator::Dsl::Schema
- Inherits:
-
Object
- Object
- LanguageOperator::Dsl::Schema
- Defined in:
- lib/language_operator/dsl/schema.rb
Overview
JSON Schema generator for the Agent DSL
Generates a JSON Schema v7 representation of the Language Operator Agent DSL. This schema documents all available DSL methods, their parameters, validation patterns, and structure.
Used for:
- Template validation
- Documentation generation
- IDE autocomplete/IntelliSense
- CLI introspection commands
rubocop:disable Metrics/ClassLength
Class Method Summary collapse
-
.agent_properties ⇒ Hash
Agent top-level properties.
-
.all_definitions ⇒ Hash
All nested definition schemas.
-
.chat_choice_schema ⇒ Hash
Chat choice schema.
-
.chat_completion_request_schema ⇒ Hash
Chat completion request schema.
-
.chat_completion_response_schema ⇒ Hash
Chat completion response schema.
-
.chat_completions_endpoint_spec ⇒ Hash
Chat completions endpoint spec (OpenAI-compatible).
-
.chat_endpoint_definition_schema ⇒ Hash
Chat endpoint definition schema.
-
.chat_message_schema ⇒ Hash
Chat message schema.
-
.chat_usage_schema ⇒ Hash
Chat usage schema.
-
.constraints_definition_schema ⇒ Hash
Constraints definition schema.
-
.error_response_schema ⇒ Hash
Error response schema.
-
.health_endpoint_spec ⇒ Hash
Health check endpoint spec.
-
.health_response_schema ⇒ Hash
Health response schema.
-
.main_definition_schema ⇒ Hash
Main definition schema (DSL v1).
-
.mcp_server_definition_schema ⇒ Hash
MCP server definition schema.
-
.model_list_schema ⇒ Hash
Model list schema.
-
.model_schema ⇒ Hash
Model schema.
-
.models_endpoint_spec ⇒ Hash
Models list endpoint spec (OpenAI-compatible).
-
.openapi_components ⇒ Hash
OpenAPI components section - reusable schemas.
-
.openapi_info ⇒ Hash
OpenAPI info section.
-
.openapi_paths ⇒ Hash
OpenAPI paths section - documents all HTTP endpoints.
-
.openapi_servers ⇒ Array<Hash>
OpenAPI servers section.
-
.output_definition_schema ⇒ Hash
Output definition schema.
-
.parameter_definition_schema ⇒ Hash
Parameter definition schema.
-
.ready_endpoint_spec ⇒ Hash
Readiness check endpoint spec.
-
.safe_agent_methods ⇒ Array<String>
Returns array of safe agent DSL methods allowed in agent definitions.
-
.safe_helper_methods ⇒ Array<String>
Returns array of safe helper methods available in execute blocks.
-
.safe_tool_methods ⇒ Array<String>
Returns array of safe tool DSL methods allowed in tool definitions.
-
.task_definition_schema ⇒ Hash
Task definition schema (DSL v1).
-
.to_json_schema ⇒ Hash
Generate complete JSON Schema v7 representation.
-
.to_openapi ⇒ Hash
Generate OpenAPI 3.0 specification for agent HTTP endpoints.
-
.tool_definition_schema ⇒ Hash
Tool definition schema.
-
.type_schema_definition ⇒ Hash
Type schema definition (DSL v1).
-
.version ⇒ String
Returns the schema version.
-
.webhook_authentication_schema ⇒ Hash
Webhook authentication schema.
-
.webhook_definition_schema ⇒ Hash
Webhook definition schema.
Class Method Details
.agent_properties ⇒ Hash
Agent top-level properties
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/language_operator/dsl/schema.rb', line 143 def self.agent_properties { name: { type: 'string', description: 'Unique agent identifier (lowercase, alphanumeric, hyphens)', pattern: '^[a-z0-9-]+$', minLength: 1, maxLength: 63 }, description: { type: 'string', description: 'Human-readable description of agent purpose' }, persona: { type: 'string', description: 'System prompt or persona defining agent behavior and expertise' }, schedule: { type: 'string', description: 'Cron expression for scheduled execution (sets mode to :scheduled)', pattern: '^\s*(\S+\s+){4}\S+\s*$' }, mode: { type: 'string', description: 'Execution mode for the agent', enum: Constants::PRIMARY_MODES }, objectives: { type: 'array', description: 'List of goals the agent should achieve', items: { type: 'string' }, minItems: 0 }, # DSL v1 (task/main model) tasks: { type: 'array', description: 'Task definitions (organic functions with stable contracts)', items: { '$ref': '#/definitions/TaskDefinition' } }, main: { '$ref': '#/definitions/MainDefinition', description: 'Main execution block (imperative entry point)' }, # Common properties constraints: { '$ref': '#/definitions/ConstraintsDefinition' }, output: { '$ref': '#/definitions/OutputDefinition' }, webhooks: { type: 'array', description: 'Webhook endpoints for reactive agents', items: { '$ref': '#/definitions/WebhookDefinition' } }, mcp_server: { '$ref': '#/definitions/McpServerDefinition' }, chat_endpoint: { '$ref': '#/definitions/ChatEndpointDefinition' } } end |
.all_definitions ⇒ Hash
All nested definition schemas
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/language_operator/dsl/schema.rb', line 216 def self.all_definitions { # DSL v1 (task/main model) TaskDefinition: task_definition_schema, MainDefinition: main_definition_schema, TypeSchema: type_schema_definition, # Common definitions ConstraintsDefinition: constraints_definition_schema, OutputDefinition: output_definition_schema, WebhookDefinition: webhook_definition_schema, WebhookAuthentication: webhook_authentication_schema, McpServerDefinition: mcp_server_definition_schema, ChatEndpointDefinition: chat_endpoint_definition_schema, ToolDefinition: tool_definition_schema, ParameterDefinition: parameter_definition_schema } end |
.chat_choice_schema ⇒ Hash
Chat choice schema
991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 |
# File 'lib/language_operator/dsl/schema.rb', line 991 def self.chat_choice_schema { type: 'object', required: %w[index message finish_reason], properties: { index: { type: 'integer', description: 'Choice index' }, message: { '$ref': '#/components/schemas/ChatMessage' }, finish_reason: { type: 'string', description: 'Reason for completion finish', enum: %w[stop length content_filter null] } } } end |
.chat_completion_request_schema ⇒ Hash
Chat completion request schema
855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 |
# File 'lib/language_operator/dsl/schema.rb', line 855 def self.chat_completion_request_schema { type: 'object', required: %w[model messages], properties: { model: { type: 'string', description: 'Model name to use for completion' }, messages: { type: 'array', description: 'List of messages in the conversation', items: { '$ref': '#/components/schemas/ChatMessage' } }, temperature: { type: 'number', description: 'Sampling temperature (0.0-2.0)', minimum: 0.0, maximum: 2.0, default: 0.7 }, max_tokens: { type: 'integer', description: 'Maximum tokens in response', minimum: 1, default: 2000 }, stream: { type: 'boolean', description: 'Stream responses as server-sent events', default: false }, top_p: { type: 'number', description: 'Nucleus sampling parameter', minimum: 0.0, maximum: 1.0, default: 1.0 }, frequency_penalty: { type: 'number', description: 'Frequency penalty (-2.0 to 2.0)', minimum: -2.0, maximum: 2.0, default: 0.0 }, presence_penalty: { type: 'number', description: 'Presence penalty (-2.0 to 2.0)', minimum: -2.0, maximum: 2.0, default: 0.0 }, stop: { oneOf: [ { type: 'string' }, { type: 'array', items: { type: 'string' } } ], description: 'Stop sequences for generation' } } } end |
.chat_completion_response_schema ⇒ Hash
Chat completion response schema
927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 |
# File 'lib/language_operator/dsl/schema.rb', line 927 def self.chat_completion_response_schema { type: 'object', required: %w[id object created model choices], properties: { id: { type: 'string', description: 'Unique identifier for the completion' }, object: { type: 'string', description: 'Object type (always "chat.completion")', enum: ['chat.completion'] }, created: { type: 'integer', description: 'Unix timestamp of creation' }, model: { type: 'string', description: 'Model used for completion' }, choices: { type: 'array', description: 'List of completion choices', items: { '$ref': '#/components/schemas/ChatChoice' } }, usage: { '$ref': '#/components/schemas/ChatUsage' } } } end |
.chat_completions_endpoint_spec ⇒ Hash
Chat completions endpoint spec (OpenAI-compatible)
777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 |
# File 'lib/language_operator/dsl/schema.rb', line 777 def self.chat_completions_endpoint_spec { post: { summary: 'Create chat completion', description: 'Creates a chat completion response (OpenAI-compatible endpoint)', operationId: 'createChatCompletion', tags: ['Chat'], requestBody: { required: true, content: { 'application/json': { schema: { '$ref': '#/components/schemas/ChatCompletionRequest' } } } }, responses: { '200': { description: 'Successful chat completion response', content: { 'application/json': { schema: { '$ref': '#/components/schemas/ChatCompletionResponse' } }, 'text/event-stream': { description: 'Server-sent events stream (when stream=true)', schema: { type: 'string' } } } }, '400': { description: 'Invalid request', content: { 'application/json': { schema: { '$ref': '#/components/schemas/ErrorResponse' } } } } } } } end |
.chat_endpoint_definition_schema ⇒ Hash
Chat endpoint definition schema
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
# File 'lib/language_operator/dsl/schema.rb', line 530 def self.chat_endpoint_definition_schema { type: 'object', description: 'OpenAI-compatible chat endpoint configuration', properties: { system_prompt: { type: 'string', description: 'System prompt for chat mode' }, temperature: { type: 'number', description: 'Sampling temperature (0.0-2.0)', minimum: 0.0, maximum: 2.0, default: 0.7 }, max_tokens: { type: 'integer', description: 'Maximum tokens in response', minimum: 1, default: 2000 }, model_name: { type: 'string', description: 'Model name exposed in API' }, top_p: { type: 'number', description: 'Nucleus sampling parameter (0.0-1.0)', minimum: 0.0, maximum: 1.0, default: 1.0 }, frequency_penalty: { type: 'number', description: 'Frequency penalty (-2.0 to 2.0)', minimum: -2.0, maximum: 2.0, default: 0.0 }, presence_penalty: { type: 'number', description: 'Presence penalty (-2.0 to 2.0)', minimum: -2.0, maximum: 2.0, default: 0.0 }, stop_sequences: { type: 'array', description: 'Sequences that stop generation', items: { type: 'string' } } } } end |
.chat_message_schema ⇒ Hash
Chat message schema
966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 |
# File 'lib/language_operator/dsl/schema.rb', line 966 def self. { type: 'object', required: %w[role content], properties: { role: { type: 'string', description: 'Message role', enum: %w[system user assistant] }, content: { type: 'string', description: 'Message content' }, name: { type: 'string', description: 'Optional name of the message author' } } } end |
.chat_usage_schema ⇒ Hash
Chat usage schema
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 |
# File 'lib/language_operator/dsl/schema.rb', line 1015 def self.chat_usage_schema { type: 'object', required: %w[prompt_tokens completion_tokens total_tokens], properties: { prompt_tokens: { type: 'integer', description: 'Tokens in the prompt' }, completion_tokens: { type: 'integer', description: 'Tokens in the completion' }, total_tokens: { type: 'integer', description: 'Total tokens used' } } } end |
.constraints_definition_schema ⇒ Hash
Constraints definition schema
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
# File 'lib/language_operator/dsl/schema.rb', line 323 def self.constraints_definition_schema { type: 'object', description: 'Execution constraints and limits', properties: { max_iterations: { type: 'integer', description: 'Maximum number of execution iterations', minimum: 1 }, timeout: { type: 'string', description: 'Execution timeout (e.g., "30s", "5m", "1h")', pattern: '^\d+[smh]$' }, memory: { type: 'string', description: 'Memory limit (e.g., "512Mi", "1Gi")' }, rate_limit: { type: 'integer', description: 'Maximum requests per time period', minimum: 1 }, daily_budget: { type: 'number', description: 'Maximum daily cost in USD', minimum: 0 }, hourly_budget: { type: 'number', description: 'Maximum hourly cost in USD', minimum: 0 }, token_budget: { type: 'integer', description: 'Maximum total tokens allowed', minimum: 1 }, requests_per_minute: { type: 'integer', description: 'Maximum requests per minute', minimum: 1 }, requests_per_hour: { type: 'integer', description: 'Maximum requests per hour', minimum: 1 }, requests_per_day: { type: 'integer', description: 'Maximum requests per day', minimum: 1 }, blocked_patterns: { type: 'array', description: 'Content patterns to block', items: { type: 'string' } }, blocked_topics: { type: 'array', description: 'Topics to avoid', items: { type: 'string' } } } } end |
.error_response_schema ⇒ Hash
Error response schema
1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 |
# File 'lib/language_operator/dsl/schema.rb', line 1114 def self.error_response_schema { type: 'object', required: %w[error], properties: { error: { type: 'object', required: %w[message type], properties: { message: { type: 'string', description: 'Error message' }, type: { type: 'string', description: 'Error type' }, code: { type: 'string', description: 'Error code' } } } } } end |
.health_endpoint_spec ⇒ Hash
Health check endpoint spec
715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 |
# File 'lib/language_operator/dsl/schema.rb', line 715 def self.health_endpoint_spec { get: { summary: 'Health check', description: 'Returns the health status of the agent', operationId: 'getHealth', tags: ['Health'], responses: { '200': { description: 'Agent is healthy', content: { 'application/json': { schema: { '$ref': '#/components/schemas/HealthResponse' } } } } } } } end |
.health_response_schema ⇒ Hash
Health response schema
1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 |
# File 'lib/language_operator/dsl/schema.rb', line 1092 def self.health_response_schema { type: 'object', required: %w[status], properties: { status: { type: 'string', description: 'Health status', enum: %w[ok ready] }, timestamp: { type: 'string', format: 'date-time', description: 'Timestamp of health check' } } } end |
.main_definition_schema ⇒ Hash
Main definition schema (DSL v1)
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/language_operator/dsl/schema.rb', line 272 def self.main_definition_schema { type: 'object', description: 'Imperative entry point for agent execution', properties: { type: { type: 'string', description: 'Block type', enum: ['main'] }, description: { type: 'string', description: 'Main block executes tasks using execute_task() with Ruby control flow' } }, additionalProperties: false } end |
.mcp_server_definition_schema ⇒ Hash
MCP server definition schema
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
# File 'lib/language_operator/dsl/schema.rb', line 507 def self.mcp_server_definition_schema { type: 'object', description: 'MCP (Model Context Protocol) server configuration', properties: { name: { type: 'string', description: 'MCP server name' }, tools: { type: 'object', description: 'Tools exposed via MCP', additionalProperties: { '$ref': '#/definitions/ToolDefinition' } } } } end |
.model_list_schema ⇒ Hash
Model list schema
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 |
# File 'lib/language_operator/dsl/schema.rb', line 1039 def self.model_list_schema { type: 'object', required: %w[object data], properties: { object: { type: 'string', description: 'Object type (always "list")', enum: ['list'] }, data: { type: 'array', description: 'List of available models', items: { '$ref': '#/components/schemas/Model' } } } } end |
.model_schema ⇒ Hash
Model schema
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 |
# File 'lib/language_operator/dsl/schema.rb', line 1063 def self.model_schema { type: 'object', required: %w[id object], properties: { id: { type: 'string', description: 'Model identifier' }, object: { type: 'string', description: 'Object type (always "model")', enum: ['model'] }, created: { type: 'integer', description: 'Unix timestamp of model creation' }, owned_by: { type: 'string', description: 'Organization that owns the model' } } } end |
.models_endpoint_spec ⇒ Hash
Models list endpoint spec (OpenAI-compatible)
829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 |
# File 'lib/language_operator/dsl/schema.rb', line 829 def self.models_endpoint_spec { get: { summary: 'List models', description: 'Lists available models (OpenAI-compatible endpoint)', operationId: 'listModels', tags: ['Models'], responses: { '200': { description: 'List of available models', content: { 'application/json': { schema: { '$ref': '#/components/schemas/ModelList' } } } } } } } end |
.openapi_components ⇒ Hash
OpenAPI components section - reusable schemas
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 |
# File 'lib/language_operator/dsl/schema.rb', line 696 def self.openapi_components { schemas: { ChatCompletionRequest: chat_completion_request_schema, ChatCompletionResponse: chat_completion_response_schema, ChatMessage: , ChatChoice: chat_choice_schema, ChatUsage: chat_usage_schema, ModelList: model_list_schema, Model: model_schema, HealthResponse: health_response_schema, ErrorResponse: error_response_schema } } end |
.openapi_info ⇒ Hash
OpenAPI info section
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 |
# File 'lib/language_operator/dsl/schema.rb', line 653 def self.openapi_info { title: 'Language Operator Agent API', version: LanguageOperator::VERSION, description: 'HTTP API endpoints exposed by Language Operator reactive agents', contact: { name: 'Language Operator', url: 'https://github.com/language-operator/language-operator-gem' }, license: { name: 'FSL-1.1-Apache-2.0', url: 'https://github.com/language-operator/language-operator-gem/blob/main/LICENSE' } } end |
.openapi_paths ⇒ Hash
OpenAPI paths section - documents all HTTP endpoints
684 685 686 687 688 689 690 691 |
# File 'lib/language_operator/dsl/schema.rb', line 684 def self.openapi_paths { '/health' => health_endpoint_spec, '/ready' => ready_endpoint_spec, '/v1/chat/completions' => chat_completions_endpoint_spec, '/v1/models' => models_endpoint_spec } end |
.openapi_servers ⇒ Array<Hash>
OpenAPI servers section
672 673 674 675 676 677 678 679 |
# File 'lib/language_operator/dsl/schema.rb', line 672 def self.openapi_servers [ { url: 'http://localhost:8080', description: 'Local development server' } ] end |
.output_definition_schema ⇒ Hash
Output definition schema
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
# File 'lib/language_operator/dsl/schema.rb', line 394 def self.output_definition_schema { type: 'object', description: 'Output destination configuration', properties: { workspace: { type: 'string', description: 'Workspace directory path for file outputs' }, slack: { type: 'object', description: 'Slack integration configuration', properties: { channel: { type: 'string', description: 'Slack channel name or ID' } }, required: %w[channel] }, email: { type: 'object', description: 'Email notification configuration', properties: { to: { type: 'string', description: 'Email recipient address', format: 'email' } }, required: %w[to] } } } end |
.parameter_definition_schema ⇒ Hash
Parameter definition schema
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
# File 'lib/language_operator/dsl/schema.rb', line 618 def self.parameter_definition_schema { type: 'object', description: 'Tool parameter definition', properties: { type: { type: 'string', description: 'Parameter type', enum: %w[string number integer boolean array object] }, description: { type: 'string', description: 'Parameter description' }, required: { type: 'boolean', description: 'Whether parameter is required', default: false }, default: { description: 'Default value if not provided' }, enum: { type: 'array', description: 'Allowed values', items: {} } }, required: %w[type] } end |
.ready_endpoint_spec ⇒ Hash
Readiness check endpoint spec
741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 |
# File 'lib/language_operator/dsl/schema.rb', line 741 def self.ready_endpoint_spec { get: { summary: 'Readiness check', description: 'Returns whether the agent is ready to accept requests', operationId: 'getReady', tags: ['Health'], responses: { '200': { description: 'Agent is ready', content: { 'application/json': { schema: { '$ref': '#/components/schemas/HealthResponse' } } } }, '503': { description: 'Agent is not ready', content: { 'application/json': { schema: { '$ref': '#/components/schemas/ErrorResponse' } } } } } } } end |
.safe_agent_methods ⇒ Array<String>
Returns array of safe agent DSL methods allowed in agent definitions
Reads from Agent::Safety::ASTValidator::SAFE_AGENT_METHODS constant. These methods are validated as safe for use in synthesized agent code.
Includes methods for:
- Agent metadata (description, persona, objectives)
- Execution modes (mode, schedule)
- Workflows (workflow, step, depends_on, prompt)
- Constraints (budget, max_requests, rate_limit, content_filter)
- Output destinations (output)
- Endpoints (webhook, as_mcp_server, as_chat_endpoint)
94 95 96 97 |
# File 'lib/language_operator/dsl/schema.rb', line 94 def self.safe_agent_methods require_relative '../agent/safety/ast_validator' Agent::Safety::ASTValidator::SAFE_AGENT_METHODS.sort end |
.safe_helper_methods ⇒ Array<String>
Returns array of safe helper methods available in execute blocks
Reads from Agent::Safety::ASTValidator::SAFE_HELPER_METHODS constant. These helper methods are validated as safe for use in tool execute blocks.
Includes helpers for:
- HTTP requests (HTTP.*)
- Shell commands (Shell.run)
- Validation (validate_url, validate_phone, validate_email)
- Environment variables (env_required, env_get)
- Utilities (truncate, parse_csv)
- Response formatting (error, success)
135 136 137 138 |
# File 'lib/language_operator/dsl/schema.rb', line 135 def self.safe_helper_methods require_relative '../agent/safety/ast_validator' Agent::Safety::ASTValidator::SAFE_HELPER_METHODS.sort end |
.safe_tool_methods ⇒ Array<String>
Returns array of safe tool DSL methods allowed in tool definitions
Reads from Agent::Safety::ASTValidator::SAFE_TOOL_METHODS constant. These methods are validated as safe for use in synthesized tool code.
Includes methods for:
- Tool definition (tool, description)
- Parameters (parameter, type, required, default)
- Execution (execute)
113 114 115 116 |
# File 'lib/language_operator/dsl/schema.rb', line 113 def self.safe_tool_methods require_relative '../agent/safety/ast_validator' Agent::Safety::ASTValidator::SAFE_TOOL_METHODS.sort end |
.task_definition_schema ⇒ Hash
Task definition schema (DSL v1)
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/language_operator/dsl/schema.rb', line 237 def self.task_definition_schema { type: 'object', description: 'Organic function with stable contract (inputs/outputs) and evolving implementation', properties: { name: { type: 'string', description: 'Task identifier (symbol)', pattern: '^[a-z_][a-z0-9_]*$' }, inputs: { '$ref': '#/definitions/TypeSchema', description: 'Input contract (parameter types)' }, outputs: { '$ref': '#/definitions/TypeSchema', description: 'Output contract (return value types)' }, instructions: { type: 'string', description: 'Natural language instructions for neural implementation (optional)' }, implementation_type: { type: 'string', description: 'Implementation approach', enum: %w[neural symbolic hybrid undefined] } }, required: %w[name inputs outputs] } end |
.to_json_schema ⇒ Hash
Generate complete JSON Schema v7 representation
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/language_operator/dsl/schema.rb', line 28 def self.to_json_schema { '$schema': 'http://json-schema.org/draft-07/schema#', '$id': 'https://github.com/language-operator/language-operator-gem/schema/agent-dsl.json', title: 'Language Operator Agent DSL', description: 'Schema for defining autonomous AI agents using the Language Operator DSL', version: LanguageOperator::VERSION, type: 'object', properties: agent_properties, required: %w[name], definitions: all_definitions } end |
.to_openapi ⇒ Hash
Generate OpenAPI 3.0 specification for agent HTTP endpoints
Generates an OpenAPI 3.0.3 spec documenting the HTTP API exposed by reactive agents. This includes chat endpoints, webhooks, and health checks.
51 52 53 54 55 56 57 58 59 |
# File 'lib/language_operator/dsl/schema.rb', line 51 def self.to_openapi { openapi: '3.0.3', info: openapi_info, servers: openapi_servers, paths: openapi_paths, components: openapi_components } end |
.tool_definition_schema ⇒ Hash
Tool definition schema
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 |
# File 'lib/language_operator/dsl/schema.rb', line 589 def self.tool_definition_schema { type: 'object', description: 'MCP tool definition', properties: { name: { type: 'string', description: 'Tool name (lowercase, alphanumeric, underscores)', pattern: '^[a-z0-9_]+$' }, description: { type: 'string', description: 'Human-readable tool description' }, parameters: { type: 'object', description: 'Tool parameters', additionalProperties: { '$ref': '#/definitions/ParameterDefinition' } } }, required: %w[name description] } end |
.type_schema_definition ⇒ Hash
Type schema definition (DSL v1)
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/language_operator/dsl/schema.rb', line 294 def self.type_schema_definition { type: 'object', description: 'Type schema for task contract validation', patternProperties: { '^[a-z_][a-z0-9_]*$': { type: 'string', description: 'Parameter type', enum: %w[string integer number boolean array hash any] } }, additionalProperties: false, examples: [ { user_id: 'integer', name: 'string', active: 'boolean' }, { data: 'array', metadata: 'hash' } ] } end |
.version ⇒ String
Returns the schema version
The schema version is directly linked to the gem version and follows semantic versioning. Schema changes follow these rules:
- MAJOR: Breaking changes to DSL structure or behavior
- MINOR: New features, backward-compatible additions
- PATCH: Bug fixes, documentation improvements
73 74 75 |
# File 'lib/language_operator/dsl/schema.rb', line 73 def self.version LanguageOperator::VERSION end |
.webhook_authentication_schema ⇒ Hash
Webhook authentication schema
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 |
# File 'lib/language_operator/dsl/schema.rb', line 473 def self.webhook_authentication_schema { type: 'object', description: 'Webhook authentication configuration', properties: { type: { type: 'string', description: 'Authentication type', enum: %w[hmac api_key bearer custom] }, secret: { type: 'string', description: 'Secret key for authentication' }, header: { type: 'string', description: 'Header name containing signature/token' }, algorithm: { type: 'string', description: 'HMAC algorithm', enum: %w[sha1 sha256 sha512] }, prefix: { type: 'string', description: 'Signature prefix (e.g., "sha256=")' } } } end |
.webhook_definition_schema ⇒ Hash
Webhook definition schema
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
# File 'lib/language_operator/dsl/schema.rb', line 433 def self.webhook_definition_schema { type: 'object', description: 'Webhook endpoint configuration', properties: { path: { type: 'string', description: 'URL path for webhook endpoint', pattern: '^/' }, method: { type: 'string', description: 'HTTP method', enum: %w[get post put delete patch], default: 'post' }, authentication: { '$ref': '#/definitions/WebhookAuthentication' }, validations: { type: 'array', description: 'Request validation rules', items: { type: 'object', properties: { type: { type: 'string', enum: %w[headers content_type custom] } } } } }, required: %w[path] } end |