weboql 0.1.1__tar.gz

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.
weboql-0.1.1/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
weboql-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: weboql
3
+ Version: 0.1.1
4
+ Summary: WebOQL — Web-based OQL scenario editor and executor
5
+ License-Expression: Apache-2.0
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: fastapi>=0.110
10
+ Requires-Dist: uvicorn>=0.28
11
+ Requires-Dist: pydantic>=2.0
12
+ Requires-Dist: oqlos>=0.1.0
13
+ Requires-Dist: goal>=2.1.0
14
+ Requires-Dist: costs>=0.1.20
15
+ Requires-Dist: pfix>=0.1.60
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest; extra == "dev"
18
+ Requires-Dist: pytest-asyncio; extra == "dev"
19
+ Requires-Dist: httpx; extra == "dev"
20
+ Requires-Dist: goal>=2.1.0; extra == "dev"
21
+ Requires-Dist: costs>=0.1.20; extra == "dev"
22
+ Requires-Dist: pfix>=0.1.60; extra == "dev"
23
+ Dynamic: license-file
24
+
25
+ # WebOQL — Web-based OQL Scenario Editor
26
+
27
+
28
+ ## AI Cost Tracking
29
+
30
+ ![PyPI](https://img.shields.io/badge/pypi-costs-blue) ![Version](https://img.shields.io/badge/version-0.1.1-blue) ![Python](https://img.shields.io/badge/python-3.9+-blue) ![License](https://img.shields.io/badge/license-Apache--2.0-green)
31
+ ![AI Cost](https://img.shields.io/badge/AI%20Cost-$0.45-orange) ![Human Time](https://img.shields.io/badge/Human%20Time-3.1h-blue) ![Model](https://img.shields.io/badge/Model-openrouter%2Fqwen%2Fqwen3--coder--next-lightgrey)
32
+
33
+ - 🤖 **LLM usage:** $0.4500 (3 commits)
34
+ - 👤 **Human dev:** ~$310 (3.1h @ $100/h, 30min dedup)
35
+
36
+ Generated on 2026-04-15 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)
37
+
38
+ ---
39
+
40
+
41
+
42
+ Web-based editor and executor for OQL (Operation Query Language) scenarios.
43
+
44
+ ## Features
45
+
46
+ - **File Browser**: Browse and select OQL scenario files from the scenarios directory
47
+ - **Code Editor**: Edit scenario files with syntax highlighting
48
+ - **Execution**: Run scenarios using OqlOS runtime in mock or real mode
49
+ - **Live Preview**: Real-time execution logs and status updates
50
+
51
+ ## Installation
52
+
53
+ ### Development Mode
54
+
55
+ ```bash
56
+ make install
57
+ ```
58
+
59
+ ### With Development Dependencies
60
+
61
+ ```bash
62
+ make dev
63
+ ```
64
+
65
+ ## Usage
66
+
67
+ ### Start the Server
68
+
69
+ ```bash
70
+ make run
71
+ ```
72
+
73
+ The editor will be available at `http://localhost:8203`
74
+
75
+ ### Production Mode
76
+
77
+ ```bash
78
+ make run-prod
79
+ ```
80
+
81
+ ## API Endpoints
82
+
83
+ - `GET /api/v1/editor/files` - List all scenario files
84
+ - `GET /api/v1/editor/file/{path}` - Read file content
85
+ - `POST /api/v1/editor/file/{path}` - Write file content
86
+ - `POST /api/v1/editor/execute` - Execute a scenario
87
+
88
+ ## Configuration
89
+
90
+ Environment variables:
91
+ - `WEB_PORT` - Server port (default: 8203)
92
+ - `HARDWARE_MODE` - Hardware mode: mock|real (default: mock)
93
+
94
+ ## Development
95
+
96
+ ### Build Distribution Packages
97
+
98
+ ```bash
99
+ make build
100
+ ```
101
+
102
+ ### Run Tests
103
+
104
+ ```bash
105
+ make test
106
+ ```
107
+
108
+ ### Clean Build Artifacts
109
+
110
+ ```bash
111
+ make clean
112
+ ```
113
+
114
+ ## Publishing
115
+
116
+ ### Publish to PyPI
117
+
118
+ ```bash
119
+ make publish
120
+ ```
121
+
122
+ ### Publish to Test PyPI
123
+
124
+ ```bash
125
+ make publish-test
126
+ ```
127
+
128
+ ## Project Structure
129
+
130
+ ```
131
+ weboql/
132
+ ├── weboql/
133
+ │ ├── __init__.py
134
+ │ ├── main.py # FastAPI application entry point
135
+ │ └── api/
136
+ │ ├── __init__.py
137
+ │ ├── editor.py # Editor API endpoints
138
+ │ └── static/
139
+ │ └── editor.html # Web interface
140
+ ├── pyproject.toml # Project configuration
141
+ ├── Makefile # Build and deployment automation
142
+ └── README.md # This file
143
+ ```
144
+
145
+ ## License
146
+
147
+ Licensed under Apache-2.0.
weboql-0.1.1/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # WebOQL — Web-based OQL Scenario Editor
2
+
3
+
4
+ ## AI Cost Tracking
5
+
6
+ ![PyPI](https://img.shields.io/badge/pypi-costs-blue) ![Version](https://img.shields.io/badge/version-0.1.1-blue) ![Python](https://img.shields.io/badge/python-3.9+-blue) ![License](https://img.shields.io/badge/license-Apache--2.0-green)
7
+ ![AI Cost](https://img.shields.io/badge/AI%20Cost-$0.45-orange) ![Human Time](https://img.shields.io/badge/Human%20Time-3.1h-blue) ![Model](https://img.shields.io/badge/Model-openrouter%2Fqwen%2Fqwen3--coder--next-lightgrey)
8
+
9
+ - 🤖 **LLM usage:** $0.4500 (3 commits)
10
+ - 👤 **Human dev:** ~$310 (3.1h @ $100/h, 30min dedup)
11
+
12
+ Generated on 2026-04-15 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)
13
+
14
+ ---
15
+
16
+
17
+
18
+ Web-based editor and executor for OQL (Operation Query Language) scenarios.
19
+
20
+ ## Features
21
+
22
+ - **File Browser**: Browse and select OQL scenario files from the scenarios directory
23
+ - **Code Editor**: Edit scenario files with syntax highlighting
24
+ - **Execution**: Run scenarios using OqlOS runtime in mock or real mode
25
+ - **Live Preview**: Real-time execution logs and status updates
26
+
27
+ ## Installation
28
+
29
+ ### Development Mode
30
+
31
+ ```bash
32
+ make install
33
+ ```
34
+
35
+ ### With Development Dependencies
36
+
37
+ ```bash
38
+ make dev
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ ### Start the Server
44
+
45
+ ```bash
46
+ make run
47
+ ```
48
+
49
+ The editor will be available at `http://localhost:8203`
50
+
51
+ ### Production Mode
52
+
53
+ ```bash
54
+ make run-prod
55
+ ```
56
+
57
+ ## API Endpoints
58
+
59
+ - `GET /api/v1/editor/files` - List all scenario files
60
+ - `GET /api/v1/editor/file/{path}` - Read file content
61
+ - `POST /api/v1/editor/file/{path}` - Write file content
62
+ - `POST /api/v1/editor/execute` - Execute a scenario
63
+
64
+ ## Configuration
65
+
66
+ Environment variables:
67
+ - `WEB_PORT` - Server port (default: 8203)
68
+ - `HARDWARE_MODE` - Hardware mode: mock|real (default: mock)
69
+
70
+ ## Development
71
+
72
+ ### Build Distribution Packages
73
+
74
+ ```bash
75
+ make build
76
+ ```
77
+
78
+ ### Run Tests
79
+
80
+ ```bash
81
+ make test
82
+ ```
83
+
84
+ ### Clean Build Artifacts
85
+
86
+ ```bash
87
+ make clean
88
+ ```
89
+
90
+ ## Publishing
91
+
92
+ ### Publish to PyPI
93
+
94
+ ```bash
95
+ make publish
96
+ ```
97
+
98
+ ### Publish to Test PyPI
99
+
100
+ ```bash
101
+ make publish-test
102
+ ```
103
+
104
+ ## Project Structure
105
+
106
+ ```
107
+ weboql/
108
+ ├── weboql/
109
+ │ ├── __init__.py
110
+ │ ├── main.py # FastAPI application entry point
111
+ │ └── api/
112
+ │ ├── __init__.py
113
+ │ ├── editor.py # Editor API endpoints
114
+ │ └── static/
115
+ │ └── editor.html # Web interface
116
+ ├── pyproject.toml # Project configuration
117
+ ├── Makefile # Build and deployment automation
118
+ └── README.md # This file
119
+ ```
120
+
121
+ ## License
122
+
123
+ Licensed under Apache-2.0.
@@ -0,0 +1,62 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "weboql"
7
+ version = "0.1.1"
8
+ description = "WebOQL — Web-based OQL scenario editor and executor"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "Apache-2.0"
12
+ dependencies = [
13
+ "fastapi>=0.110",
14
+ "uvicorn>=0.28",
15
+ "pydantic>=2.0",
16
+ "oqlos>=0.1.0",
17
+ "goal>=2.1.0",
18
+ "costs>=0.1.20",
19
+ "pfix>=0.1.60",
20
+ ]
21
+
22
+ [project.scripts]
23
+ weboql-server = "weboql.main:run"
24
+
25
+ [project.optional-dependencies]
26
+ dev = ["pytest", "pytest-asyncio", "httpx",
27
+ "goal>=2.1.0",
28
+ "costs>=0.1.20",
29
+ "pfix>=0.1.60",
30
+ ]
31
+
32
+ [tool.setuptools.packages.find]
33
+ include = ["weboql*"]
34
+
35
+ [tool.pfix]
36
+ # Self-healing Python configuration
37
+ model = "openrouter/qwen/qwen3-coder-next"
38
+ auto_apply = true
39
+ auto_install_deps = true
40
+ auto_restart = false
41
+ max_retries = 3
42
+ create_backups = false
43
+ git_auto_commit = false
44
+
45
+ [tool.pfix.runtime_todo]
46
+ enabled = true
47
+ todo_file = "TODO.md"
48
+ min_severity = "low"
49
+ deduplicate = true
50
+
51
+ [tool.costs]
52
+ # AI Cost tracking configuration
53
+ badge = true
54
+ update_readme = true
55
+ readme_path = "README.md"
56
+ default_model = "openrouter/qwen/qwen3-coder-next"
57
+ analysis_mode = "byok"
58
+ full_history = true
59
+ max_commits = 500
60
+
61
+ # Cost thresholds for badge colors (USD)
62
+ badge_color_thresholds = { low = 1.0, medium = 5.0, high = 10.0, critical = 50.0 }
weboql-0.1.1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,11 @@
1
+ """Sample test — auto-generated by goal."""
2
+
3
+
4
+ def test_placeholder():
5
+ """Placeholder test to verify the test setup works."""
6
+ assert True
7
+
8
+
9
+ def test_import():
10
+ """Verify the main package can be imported."""
11
+ import weboql # noqa: F401
@@ -0,0 +1 @@
1
+ """WebOQL - Web-based OQL scenario editor and executor"""
@@ -0,0 +1 @@
1
+ """WebOQL API module"""
@@ -0,0 +1,232 @@
1
+ """File editor service for managing and executing OQL scenarios"""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ import os
7
+ import pathlib
8
+ from typing import Any
9
+
10
+ from fastapi import APIRouter, HTTPException
11
+ from pydantic import BaseModel
12
+
13
+ logger = logging.getLogger(__name__)
14
+ router = APIRouter(prefix="/api/v1/editor", tags=["editor"])
15
+
16
+ SCENARIOS_DIR = pathlib.Path(os.getenv("SCENARIOS_DIR", "/home/tom/github/oqlos/oqlos/oqlos/scenarios"))
17
+
18
+
19
+ class SystemStatus(BaseModel):
20
+ """System status information"""
21
+ scenarios_dir: str
22
+ scenarios_dir_exists: bool
23
+ scenarios_count: int
24
+ hardware_mode: str
25
+ piadc_url: str | None
26
+ motor_url: str | None
27
+ modbus_serial: str | None
28
+ modbus_host: str | None
29
+ modbus_port: int | None
30
+ piadc_available: bool = False
31
+ motor_available: bool = False
32
+ modbus_available: bool = False
33
+
34
+
35
+ class FileInfo(BaseModel):
36
+ name: str
37
+ path: str
38
+ size: int
39
+ is_directory: bool
40
+
41
+
42
+ class FileContent(BaseModel):
43
+ path: str
44
+ content: str
45
+
46
+
47
+ class ExecutionRequest(BaseModel):
48
+ scenario_file: str
49
+ mode: str = "mock"
50
+ speed: float = 1.0
51
+ execution_id: str | None = None
52
+ timestamp: str | None = None
53
+
54
+
55
+ def _ensure_safe_path(file_path: str) -> pathlib.Path:
56
+ """Ensure the file path is within the scenarios directory"""
57
+ full_path = (SCENARIOS_DIR / file_path).resolve()
58
+ if not str(full_path).startswith(str(SCENARIOS_DIR.resolve())):
59
+ raise HTTPException(status_code=403, detail="Access denied: path outside scenarios directory")
60
+ return full_path
61
+
62
+
63
+ @router.get("/files")
64
+ async def list_files() -> dict[str, Any]:
65
+ """List all files in the scenarios directory"""
66
+ try:
67
+ files = []
68
+ for item in SCENARIOS_DIR.iterdir():
69
+ relative_path = item.relative_to(SCENARIOS_DIR)
70
+ files.append(FileInfo(
71
+ name=item.name,
72
+ path=str(relative_path),
73
+ size=item.stat().st_size if item.is_file() else 0,
74
+ is_directory=item.is_dir()
75
+ ))
76
+ return {"files": sorted(files, key=lambda x: (not x.is_directory, x.name))}
77
+ except Exception as e:
78
+ logger.error(f"Error listing files: {e}")
79
+ raise HTTPException(status_code=500, detail=str(e))
80
+
81
+
82
+ @router.get("/status")
83
+ async def get_system_status() -> SystemStatus:
84
+ """Get system status and configuration"""
85
+ try:
86
+ # Load settings from environment and .env
87
+ from weboql.main import settings
88
+ import httpx
89
+
90
+ # Count scenario files
91
+ scenarios_count = 0
92
+ if SCENARIOS_DIR.exists():
93
+ scenarios_count = len([f for f in SCENARIOS_DIR.iterdir() if f.is_file() and f.suffix == '.oql'])
94
+
95
+ # Check hardware service availability
96
+ piadc_available = False
97
+ motor_available = False
98
+ modbus_available = False
99
+
100
+ # Check PIADC service
101
+ if settings.piadc_url:
102
+ try:
103
+ async with httpx.AsyncClient(timeout=2.0) as client:
104
+ response = await client.get(f"{settings.piadc_url}/health")
105
+ piadc_available = response.status_code == 200
106
+ except:
107
+ piadc_available = False
108
+
109
+ # Check Motor service
110
+ if settings.motor_url:
111
+ try:
112
+ async with httpx.AsyncClient(timeout=2.0) as client:
113
+ response = await client.get(f"{settings.motor_url}/health")
114
+ motor_available = response.status_code == 200
115
+ except:
116
+ motor_available = False
117
+
118
+ # Check Modbus (basic serial port check)
119
+ if settings.modbus_serial_port:
120
+ try:
121
+ import serial.tools.list_ports
122
+ ports = [port.device for port in serial.tools.list_ports.comports()]
123
+ modbus_available = settings.modbus_serial_port in ports
124
+ except:
125
+ modbus_available = False
126
+
127
+ return SystemStatus(
128
+ scenarios_dir=str(SCENARIOS_DIR),
129
+ scenarios_dir_exists=SCENARIOS_DIR.exists(),
130
+ scenarios_count=scenarios_count,
131
+ hardware_mode=settings.hardware_mode,
132
+ piadc_url=settings.piadc_url if hasattr(settings, 'piadc_url') else None,
133
+ motor_url=settings.motor_url if hasattr(settings, 'motor_url') else None,
134
+ modbus_serial=settings.modbus_serial_port if hasattr(settings, 'modbus_serial_port') else None,
135
+ modbus_host=settings.modbus_host if hasattr(settings, 'modbus_host') else None,
136
+ modbus_port=settings.modbus_port if hasattr(settings, 'modbus_port') else None,
137
+ piadc_available=piadc_available,
138
+ motor_available=motor_available,
139
+ modbus_available=modbus_available
140
+ )
141
+ except Exception as e:
142
+ logger.error(f"Error getting system status: {e}")
143
+ raise HTTPException(status_code=500, detail=str(e))
144
+
145
+
146
+ @router.get("/file/{file_path:path}")
147
+ async def read_file(file_path: str) -> FileContent:
148
+ """Read a file's content"""
149
+ try:
150
+ full_path = _ensure_safe_path(file_path)
151
+ if not full_path.exists():
152
+ raise HTTPException(status_code=404, detail="File not found")
153
+ if full_path.is_dir():
154
+ raise HTTPException(status_code=400, detail="Path is a directory")
155
+
156
+ content = full_path.read_text(encoding="utf-8")
157
+ return FileContent(path=file_path, content=content)
158
+ except HTTPException:
159
+ raise
160
+ except Exception as e:
161
+ logger.error(f"Error reading file: {e}")
162
+ raise HTTPException(status_code=500, detail=str(e))
163
+
164
+
165
+ @router.post("/file/{file_path:path}")
166
+ async def write_file(file_path: str, file_content: FileContent) -> dict[str, str]:
167
+ """Write content to a file"""
168
+ try:
169
+ full_path = _ensure_safe_path(file_path)
170
+
171
+ # Create parent directories if they don't exist
172
+ full_path.parent.mkdir(parents=True, exist_ok=True)
173
+
174
+ full_path.write_text(file_content.content, encoding="utf-8")
175
+ return {"status": "success", "path": file_path}
176
+ except HTTPException:
177
+ raise
178
+ except Exception as e:
179
+ logger.error(f"Error writing file: {e}")
180
+ raise HTTPException(status_code=500, detail=str(e))
181
+
182
+
183
+ @router.post("/execute")
184
+ async def execute_scenario(request: ExecutionRequest) -> dict[str, Any]:
185
+ """Execute a scenario file using oqlos runtime"""
186
+ try:
187
+ # Log execution parameters
188
+ logger.info(f"Executing scenario: file={request.scenario_file}, mode={request.mode}, speed={request.speed}, execution_id={request.execution_id}, timestamp={request.timestamp}")
189
+
190
+ from oqlos.core.interpreter import CqlInterpreter
191
+
192
+ # Read the scenario file
193
+ full_path = _ensure_safe_path(request.scenario_file)
194
+ if not full_path.exists():
195
+ logger.error(f"Scenario file not found: {request.scenario_file}")
196
+ raise HTTPException(status_code=404, detail="Scenario file not found")
197
+
198
+ content = full_path.read_text(encoding="utf-8")
199
+
200
+ # Create interpreter with appropriate mode
201
+ interpreter_mode = "dry-run" if request.mode == "mock" else "execute"
202
+ logger.info(f"Using interpreter mode: {interpreter_mode}")
203
+
204
+ interpreter = CqlInterpreter(
205
+ mode=interpreter_mode,
206
+ quiet=False,
207
+ skip_waits=request.speed > 2.0
208
+ )
209
+
210
+ # Parse and execute the scenario
211
+ doc = interpreter.parse(content, request.scenario_file)
212
+ logger.info(f"Parsed scenario: {doc.metadata.scenario_name}")
213
+
214
+ result = interpreter.execute(doc)
215
+ logger.info(f"Execution result: ok={result.ok}, steps={len(result.steps)}, duration_ms={result.duration_ms}")
216
+
217
+ return {
218
+ "status": "success",
219
+ "ok": result.ok,
220
+ "scenario_name": doc.metadata.scenario_name or request.scenario_file,
221
+ "steps_executed": len(result.steps),
222
+ "duration_ms": result.duration_ms,
223
+ "errors": result.errors,
224
+ "warnings": result.warnings,
225
+ "execution_id": request.execution_id,
226
+ "timestamp": request.timestamp
227
+ }
228
+ except HTTPException:
229
+ raise
230
+ except Exception as e:
231
+ logger.error(f"Error executing scenario: {e}", exc_info=True)
232
+ raise HTTPException(status_code=500, detail=str(e))
@@ -0,0 +1,119 @@
1
+ """WebOQL — Web-based OQL scenario editor and executor"""
2
+
3
+ import logging
4
+ import os
5
+ from pathlib import Path
6
+
7
+ from fastapi import FastAPI
8
+ from fastapi.middleware.cors import CORSMiddleware
9
+ from fastapi.responses import HTMLResponse, FileResponse
10
+ import uvicorn
11
+ from pydantic_settings import BaseSettings, SettingsConfigDict
12
+
13
+ from weboql.api.editor import router as editor_router
14
+
15
+ logging.basicConfig(level=logging.INFO)
16
+ logger = logging.getLogger(__name__)
17
+
18
+
19
+ class Settings(BaseSettings):
20
+ """Application settings loaded from environment variables and .env file"""
21
+ model_config = SettingsConfigDict(
22
+ env_file=".env",
23
+ env_file_encoding="utf-8",
24
+ case_sensitive=False,
25
+ extra="ignore"
26
+ )
27
+
28
+ # Server Configuration
29
+ web_port: int = 8203
30
+ web_host: str = "0.0.0.0"
31
+
32
+ # Scenarios Directory
33
+ scenarios_dir: str = "/home/tom/github/oqlos/oqlos/oqlos/scenarios"
34
+
35
+ # Hardware Mode
36
+ hardware_mode: str = "mock"
37
+
38
+ # Hardware Service URLs
39
+ piadc_url: str | None = None
40
+ motor_url: str | None = None
41
+
42
+ # Modbus Configuration
43
+ modbus_serial_port: str | None = None
44
+ modbus_host: str | None = None
45
+ modbus_port: int | None = None
46
+
47
+ # Logging
48
+ log_level: str = "INFO"
49
+
50
+ # CORS Settings
51
+ cors_origins: str = "*"
52
+
53
+ # Service Metadata
54
+ service_name: str = "weboql"
55
+ service_version: str = "0.1.0"
56
+
57
+
58
+ # Load settings
59
+ settings = Settings()
60
+ SCENARIOS_DIR = Path(settings.scenarios_dir)
61
+ WEB_PORT = settings.web_port
62
+
63
+ # Create FastAPI app
64
+ app = FastAPI(title="WebOQL Editor", version="0.1.0")
65
+
66
+ # CORS configuration
67
+ app.add_middleware(
68
+ CORSMiddleware,
69
+ allow_origins=settings.cors_origins.split(",") if settings.cors_origins != "*" else ["*"],
70
+ allow_credentials=True,
71
+ allow_methods=["*"],
72
+ allow_headers=["*"],
73
+ )
74
+
75
+ # Include API routers
76
+ app.include_router(editor_router)
77
+
78
+ # Static files
79
+ STATIC_DIR = Path(__file__).parent / "api" / "static"
80
+
81
+
82
+ @app.get("/", response_class=HTMLResponse)
83
+ async def index_page():
84
+ """Serve the editor UI at root"""
85
+ editor_path = STATIC_DIR / "editor.html"
86
+ if editor_path.exists():
87
+ return FileResponse(editor_path)
88
+ return HTMLResponse("<h1>WebOQL Editor</h1><p>editor.html not found.</p>")
89
+
90
+
91
+ @app.get("/editor", response_class=HTMLResponse)
92
+ async def editor_page():
93
+ """Serve the editor UI"""
94
+ editor_path = STATIC_DIR / "editor.html"
95
+ if editor_path.exists():
96
+ return FileResponse(editor_path)
97
+ return HTMLResponse("<h1>WebOQL Editor</h1><p>editor.html not found.</p>")
98
+
99
+
100
+ @app.get("/health")
101
+ async def health_check():
102
+ """Health check endpoint"""
103
+ return {
104
+ "status": "ok",
105
+ "service": settings.service_name,
106
+ "version": settings.service_version,
107
+ "port": WEB_PORT,
108
+ "scenarios_dir": str(SCENARIOS_DIR),
109
+ "hardware_mode": settings.hardware_mode
110
+ }
111
+
112
+
113
+ def run():
114
+ """Entry point for weboql-server console script."""
115
+ uvicorn.run(app, host=settings.web_host, port=WEB_PORT)
116
+
117
+
118
+ if __name__ == "__main__":
119
+ run()
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: weboql
3
+ Version: 0.1.1
4
+ Summary: WebOQL — Web-based OQL scenario editor and executor
5
+ License-Expression: Apache-2.0
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: fastapi>=0.110
10
+ Requires-Dist: uvicorn>=0.28
11
+ Requires-Dist: pydantic>=2.0
12
+ Requires-Dist: oqlos>=0.1.0
13
+ Requires-Dist: goal>=2.1.0
14
+ Requires-Dist: costs>=0.1.20
15
+ Requires-Dist: pfix>=0.1.60
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest; extra == "dev"
18
+ Requires-Dist: pytest-asyncio; extra == "dev"
19
+ Requires-Dist: httpx; extra == "dev"
20
+ Requires-Dist: goal>=2.1.0; extra == "dev"
21
+ Requires-Dist: costs>=0.1.20; extra == "dev"
22
+ Requires-Dist: pfix>=0.1.60; extra == "dev"
23
+ Dynamic: license-file
24
+
25
+ # WebOQL — Web-based OQL Scenario Editor
26
+
27
+
28
+ ## AI Cost Tracking
29
+
30
+ ![PyPI](https://img.shields.io/badge/pypi-costs-blue) ![Version](https://img.shields.io/badge/version-0.1.1-blue) ![Python](https://img.shields.io/badge/python-3.9+-blue) ![License](https://img.shields.io/badge/license-Apache--2.0-green)
31
+ ![AI Cost](https://img.shields.io/badge/AI%20Cost-$0.45-orange) ![Human Time](https://img.shields.io/badge/Human%20Time-3.1h-blue) ![Model](https://img.shields.io/badge/Model-openrouter%2Fqwen%2Fqwen3--coder--next-lightgrey)
32
+
33
+ - 🤖 **LLM usage:** $0.4500 (3 commits)
34
+ - 👤 **Human dev:** ~$310 (3.1h @ $100/h, 30min dedup)
35
+
36
+ Generated on 2026-04-15 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)
37
+
38
+ ---
39
+
40
+
41
+
42
+ Web-based editor and executor for OQL (Operation Query Language) scenarios.
43
+
44
+ ## Features
45
+
46
+ - **File Browser**: Browse and select OQL scenario files from the scenarios directory
47
+ - **Code Editor**: Edit scenario files with syntax highlighting
48
+ - **Execution**: Run scenarios using OqlOS runtime in mock or real mode
49
+ - **Live Preview**: Real-time execution logs and status updates
50
+
51
+ ## Installation
52
+
53
+ ### Development Mode
54
+
55
+ ```bash
56
+ make install
57
+ ```
58
+
59
+ ### With Development Dependencies
60
+
61
+ ```bash
62
+ make dev
63
+ ```
64
+
65
+ ## Usage
66
+
67
+ ### Start the Server
68
+
69
+ ```bash
70
+ make run
71
+ ```
72
+
73
+ The editor will be available at `http://localhost:8203`
74
+
75
+ ### Production Mode
76
+
77
+ ```bash
78
+ make run-prod
79
+ ```
80
+
81
+ ## API Endpoints
82
+
83
+ - `GET /api/v1/editor/files` - List all scenario files
84
+ - `GET /api/v1/editor/file/{path}` - Read file content
85
+ - `POST /api/v1/editor/file/{path}` - Write file content
86
+ - `POST /api/v1/editor/execute` - Execute a scenario
87
+
88
+ ## Configuration
89
+
90
+ Environment variables:
91
+ - `WEB_PORT` - Server port (default: 8203)
92
+ - `HARDWARE_MODE` - Hardware mode: mock|real (default: mock)
93
+
94
+ ## Development
95
+
96
+ ### Build Distribution Packages
97
+
98
+ ```bash
99
+ make build
100
+ ```
101
+
102
+ ### Run Tests
103
+
104
+ ```bash
105
+ make test
106
+ ```
107
+
108
+ ### Clean Build Artifacts
109
+
110
+ ```bash
111
+ make clean
112
+ ```
113
+
114
+ ## Publishing
115
+
116
+ ### Publish to PyPI
117
+
118
+ ```bash
119
+ make publish
120
+ ```
121
+
122
+ ### Publish to Test PyPI
123
+
124
+ ```bash
125
+ make publish-test
126
+ ```
127
+
128
+ ## Project Structure
129
+
130
+ ```
131
+ weboql/
132
+ ├── weboql/
133
+ │ ├── __init__.py
134
+ │ ├── main.py # FastAPI application entry point
135
+ │ └── api/
136
+ │ ├── __init__.py
137
+ │ ├── editor.py # Editor API endpoints
138
+ │ └── static/
139
+ │ └── editor.html # Web interface
140
+ ├── pyproject.toml # Project configuration
141
+ ├── Makefile # Build and deployment automation
142
+ └── README.md # This file
143
+ ```
144
+
145
+ ## License
146
+
147
+ Licensed under Apache-2.0.
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ tests/test_weboql.py
5
+ weboql/__init__.py
6
+ weboql/main.py
7
+ weboql.egg-info/PKG-INFO
8
+ weboql.egg-info/SOURCES.txt
9
+ weboql.egg-info/dependency_links.txt
10
+ weboql.egg-info/entry_points.txt
11
+ weboql.egg-info/requires.txt
12
+ weboql.egg-info/top_level.txt
13
+ weboql/api/__init__.py
14
+ weboql/api/editor.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ weboql-server = weboql.main:run
@@ -0,0 +1,15 @@
1
+ fastapi>=0.110
2
+ uvicorn>=0.28
3
+ pydantic>=2.0
4
+ oqlos>=0.1.0
5
+ goal>=2.1.0
6
+ costs>=0.1.20
7
+ pfix>=0.1.60
8
+
9
+ [dev]
10
+ pytest
11
+ pytest-asyncio
12
+ httpx
13
+ goal>=2.1.0
14
+ costs>=0.1.20
15
+ pfix>=0.1.60
@@ -0,0 +1 @@
1
+ weboql