onako 0.2.1__tar.gz → 0.4.0__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.
- {onako-0.2.1 → onako-0.4.0}/PKG-INFO +11 -17
- onako-0.4.0/README.md +35 -0
- {onako-0.2.1 → onako-0.4.0}/pyproject.toml +1 -2
- onako-0.4.0/src/onako/__init__.py +1 -0
- onako-0.4.0/src/onako/cli.py +223 -0
- {onako-0.2.1 → onako-0.4.0}/src/onako/server.py +20 -3
- {onako-0.2.1 → onako-0.4.0}/src/onako/static/index.html +58 -3
- {onako-0.2.1 → onako-0.4.0}/src/onako/tmux_orchestrator.py +63 -17
- {onako-0.2.1 → onako-0.4.0}/src/onako.egg-info/PKG-INFO +11 -17
- {onako-0.2.1 → onako-0.4.0}/src/onako.egg-info/SOURCES.txt +0 -2
- onako-0.4.0/tests/test_api.py +169 -0
- onako-0.4.0/tests/test_cli.py +40 -0
- {onako-0.2.1 → onako-0.4.0}/tests/test_cli_service.py +7 -0
- onako-0.4.0/tests/test_tmux_orchestrator.py +145 -0
- onako-0.2.1/README.md +0 -41
- onako-0.2.1/src/onako/__init__.py +0 -1
- onako-0.2.1/src/onako/cli.py +0 -208
- onako-0.2.1/src/onako/templates/com.onako.server.plist.tpl +0 -34
- onako-0.2.1/src/onako/templates/onako.service.tpl +0 -12
- onako-0.2.1/tests/test_api.py +0 -74
- onako-0.2.1/tests/test_cli.py +0 -19
- onako-0.2.1/tests/test_tmux_orchestrator.py +0 -73
- {onako-0.2.1 → onako-0.4.0}/setup.cfg +0 -0
- {onako-0.2.1 → onako-0.4.0}/src/onako.egg-info/dependency_links.txt +0 -0
- {onako-0.2.1 → onako-0.4.0}/src/onako.egg-info/entry_points.txt +0 -0
- {onako-0.2.1 → onako-0.4.0}/src/onako.egg-info/requires.txt +0 -0
- {onako-0.2.1 → onako-0.4.0}/src/onako.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: onako
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Dispatch and monitor Claude Code tasks from your phone
|
|
5
5
|
Author: Amir
|
|
6
6
|
License-Expression: MIT
|
|
@@ -32,27 +32,21 @@ Requires [tmux](https://github.com/tmux/tmux) and [Claude Code](https://docs.ant
|
|
|
32
32
|
## Usage
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
|
|
36
|
-
onako
|
|
35
|
+
onako # starts server, drops you into tmux
|
|
36
|
+
onako --session my-project # custom session name
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
Open http://localhost:8787 on your phone (same network) or set up [Tailscale](https://tailscale.com) for access from anywhere.
|
|
40
|
-
|
|
41
|
-
### Run in the background
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
onako serve --background
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
This installs a system service (launchd on macOS, systemd on Linux) that starts on boot. Tasks run in the directory where you ran the command.
|
|
39
|
+
If you're already inside tmux, onako auto-detects your session and skips the attach. Open http://localhost:8787 on your phone (same network) or set up [Tailscale](https://tailscale.com) for access from anywhere.
|
|
48
40
|
|
|
49
41
|
```bash
|
|
50
|
-
onako
|
|
51
|
-
onako status
|
|
52
|
-
onako
|
|
53
|
-
onako version
|
|
42
|
+
onako stop # stop the server
|
|
43
|
+
onako status # check if running
|
|
44
|
+
onako serve # foreground server (for development)
|
|
45
|
+
onako version # print version
|
|
54
46
|
```
|
|
55
47
|
|
|
56
48
|
## How it works
|
|
57
49
|
|
|
58
|
-
|
|
50
|
+
Onako monitors all tmux windows in the configured session. Windows it creates (via the dashboard) are "managed" tasks. Windows created by you or other tools are discovered automatically as "external" — both get full dashboard support: view output, send messages, kill.
|
|
51
|
+
|
|
52
|
+
Task state is persisted in SQLite so it survives server restarts.
|
onako-0.4.0/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Onako
|
|
2
|
+
|
|
3
|
+
Dispatch and monitor Claude Code tasks from your phone.
|
|
4
|
+
|
|
5
|
+
Onako is a lightweight server that runs on your machine. It spawns Claude Code sessions in tmux, and you monitor them through a mobile-friendly web dashboard. Fire off tasks from an iOS Shortcut or the dashboard, check in from anywhere.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pipx install onako
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Requires [tmux](https://github.com/tmux/tmux) and [Claude Code](https://docs.anthropic.com/en/docs/claude-code).
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
onako # starts server, drops you into tmux
|
|
19
|
+
onako --session my-project # custom session name
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
If you're already inside tmux, onako auto-detects your session and skips the attach. Open http://localhost:8787 on your phone (same network) or set up [Tailscale](https://tailscale.com) for access from anywhere.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
onako stop # stop the server
|
|
26
|
+
onako status # check if running
|
|
27
|
+
onako serve # foreground server (for development)
|
|
28
|
+
onako version # print version
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## How it works
|
|
32
|
+
|
|
33
|
+
Onako monitors all tmux windows in the configured session. Windows it creates (via the dashboard) are "managed" tasks. Windows created by you or other tools are discovered automatically as "external" — both get full dashboard support: view output, send messages, kill.
|
|
34
|
+
|
|
35
|
+
Task state is persisted in SQLite so it survives server restarts.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "onako"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.0"
|
|
8
8
|
description = "Dispatch and monitor Claude Code tasks from your phone"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -37,7 +37,6 @@ where = ["src"]
|
|
|
37
37
|
[tool.setuptools.package-data]
|
|
38
38
|
onako = [
|
|
39
39
|
"static/**/*",
|
|
40
|
-
"templates/*",
|
|
41
40
|
]
|
|
42
41
|
|
|
43
42
|
[tool.pytest.ini_options]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.4.0"
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import socket
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
import click
|
|
9
|
+
|
|
10
|
+
ONAKO_DIR = Path.home() / ".onako"
|
|
11
|
+
LOG_DIR = ONAKO_DIR / "logs"
|
|
12
|
+
PID_FILE = ONAKO_DIR / "onako.pid"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@click.group(invoke_without_command=True)
|
|
16
|
+
@click.option("--host", default="0.0.0.0", help="Host to bind to.")
|
|
17
|
+
@click.option("--port", default=8787, type=int, help="Port to bind to.")
|
|
18
|
+
@click.option("--session", default="onako", help="tmux session name (auto-detected if inside tmux).")
|
|
19
|
+
@click.option("--dir", "working_dir", default=None, type=click.Path(exists=True), help="Working directory for tasks (default: current directory).")
|
|
20
|
+
@click.option("--dangerously-skip-permissions", "skip_permissions", is_flag=True, default=False, help="Pass --dangerously-skip-permissions to all Claude Code tasks.")
|
|
21
|
+
@click.pass_context
|
|
22
|
+
def main(ctx, host, port, session, working_dir, skip_permissions):
|
|
23
|
+
"""Onako — Dispatch and monitor Claude Code tasks from your phone."""
|
|
24
|
+
if ctx.invoked_subcommand is not None:
|
|
25
|
+
return
|
|
26
|
+
|
|
27
|
+
_check_prerequisites()
|
|
28
|
+
working_dir = str(Path(working_dir).resolve()) if working_dir else os.getcwd()
|
|
29
|
+
|
|
30
|
+
# Auto-detect current tmux session if inside one
|
|
31
|
+
if os.environ.get("TMUX"):
|
|
32
|
+
try:
|
|
33
|
+
result = subprocess.run(
|
|
34
|
+
["tmux", "display-message", "-p", "#S"],
|
|
35
|
+
capture_output=True, text=True,
|
|
36
|
+
)
|
|
37
|
+
if result.returncode == 0 and result.stdout.strip():
|
|
38
|
+
detected = result.stdout.strip()
|
|
39
|
+
click.echo(f"Detected tmux session: {detected}")
|
|
40
|
+
session = detected
|
|
41
|
+
except FileNotFoundError:
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
_start_server(host, port, session, working_dir, skip_permissions)
|
|
45
|
+
|
|
46
|
+
# If not inside tmux, ensure session exists and attach
|
|
47
|
+
if not os.environ.get("TMUX"):
|
|
48
|
+
result = subprocess.run(
|
|
49
|
+
["tmux", "has-session", "-t", session],
|
|
50
|
+
capture_output=True,
|
|
51
|
+
)
|
|
52
|
+
if result.returncode != 0:
|
|
53
|
+
subprocess.run(
|
|
54
|
+
["tmux", "new-session", "-d", "-s", session],
|
|
55
|
+
check=True,
|
|
56
|
+
)
|
|
57
|
+
os.execvp("tmux", ["tmux", "attach-session", "-t", session])
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@main.command()
|
|
61
|
+
def version():
|
|
62
|
+
"""Print the version."""
|
|
63
|
+
from onako import __version__
|
|
64
|
+
click.echo(f"onako {__version__}")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@main.command()
|
|
68
|
+
@click.option("--host", default="0.0.0.0", help="Host to bind to.")
|
|
69
|
+
@click.option("--port", default=8787, type=int, help="Port to bind to.")
|
|
70
|
+
@click.option("--session", default="onako", help="tmux session name.")
|
|
71
|
+
@click.option("--dir", "working_dir", default=None, type=click.Path(exists=True), help="Working directory for tasks (default: current directory).")
|
|
72
|
+
@click.option("--dangerously-skip-permissions", "skip_permissions", is_flag=True, default=False, help="Pass --dangerously-skip-permissions to all Claude Code tasks.")
|
|
73
|
+
def serve(host, port, session, working_dir, skip_permissions):
|
|
74
|
+
"""Start the Onako server."""
|
|
75
|
+
working_dir = str(Path(working_dir).resolve()) if working_dir else os.getcwd()
|
|
76
|
+
|
|
77
|
+
_check_prerequisites()
|
|
78
|
+
|
|
79
|
+
os.environ["ONAKO_WORKING_DIR"] = working_dir
|
|
80
|
+
os.environ["ONAKO_SESSION"] = session
|
|
81
|
+
if skip_permissions:
|
|
82
|
+
os.environ["ONAKO_SKIP_PERMISSIONS"] = "1"
|
|
83
|
+
|
|
84
|
+
from onako import __version__
|
|
85
|
+
click.echo(f"Onako v{__version__}")
|
|
86
|
+
click.echo(f"Starting server at http://{host}:{port}")
|
|
87
|
+
click.echo(f"Working directory: {working_dir}")
|
|
88
|
+
click.echo(f"Session: {session}")
|
|
89
|
+
click.echo()
|
|
90
|
+
|
|
91
|
+
import uvicorn
|
|
92
|
+
from onako.server import app
|
|
93
|
+
uvicorn.run(app, host=host, port=port)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@main.command()
|
|
97
|
+
def stop():
|
|
98
|
+
"""Stop the background Onako service."""
|
|
99
|
+
stopped = False
|
|
100
|
+
|
|
101
|
+
# Try pid file first (from `onako start`)
|
|
102
|
+
if PID_FILE.exists():
|
|
103
|
+
try:
|
|
104
|
+
pid = int(PID_FILE.read_text().strip())
|
|
105
|
+
os.kill(pid, 15) # SIGTERM
|
|
106
|
+
click.echo(f"Onako server stopped (pid {pid}).")
|
|
107
|
+
stopped = True
|
|
108
|
+
except (ValueError, ProcessLookupError):
|
|
109
|
+
click.echo("Stale pid file found, cleaning up.")
|
|
110
|
+
PID_FILE.unlink(missing_ok=True)
|
|
111
|
+
|
|
112
|
+
if not stopped:
|
|
113
|
+
click.echo("Onako service is not running.")
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@main.command()
|
|
117
|
+
def status():
|
|
118
|
+
"""Check if Onako is running."""
|
|
119
|
+
import urllib.request
|
|
120
|
+
try:
|
|
121
|
+
r = urllib.request.urlopen("http://127.0.0.1:8787/health", timeout=2)
|
|
122
|
+
data = r.read().decode()
|
|
123
|
+
if '"ok"' in data:
|
|
124
|
+
click.echo("Onako server: running")
|
|
125
|
+
click.echo(" URL: http://127.0.0.1:8787")
|
|
126
|
+
else:
|
|
127
|
+
click.echo("Onako server: not responding correctly")
|
|
128
|
+
except Exception:
|
|
129
|
+
click.echo("Onako server: not running")
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def _is_server_running():
|
|
133
|
+
"""Check if the onako server is already running via pid file."""
|
|
134
|
+
if not PID_FILE.exists():
|
|
135
|
+
return False
|
|
136
|
+
try:
|
|
137
|
+
pid = int(PID_FILE.read_text().strip())
|
|
138
|
+
os.kill(pid, 0) # signal 0 = check if process exists
|
|
139
|
+
return True
|
|
140
|
+
except (ValueError, ProcessLookupError, PermissionError):
|
|
141
|
+
PID_FILE.unlink(missing_ok=True)
|
|
142
|
+
return False
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def _start_server(host, port, session, working_dir, skip_permissions=False):
|
|
146
|
+
"""Start the Onako server in the background if not already running.
|
|
147
|
+
|
|
148
|
+
Returns True if the server was started or is already running.
|
|
149
|
+
"""
|
|
150
|
+
if _is_server_running():
|
|
151
|
+
click.echo(f"Onako server already running (pid {PID_FILE.read_text().strip()})")
|
|
152
|
+
return True
|
|
153
|
+
|
|
154
|
+
LOG_DIR.mkdir(parents=True, exist_ok=True)
|
|
155
|
+
onako_bin = shutil.which("onako")
|
|
156
|
+
if not onako_bin:
|
|
157
|
+
click.echo("Error: 'onako' command not found on PATH.", err=True)
|
|
158
|
+
sys.exit(1)
|
|
159
|
+
|
|
160
|
+
log_out = LOG_DIR / "onako.log"
|
|
161
|
+
|
|
162
|
+
cmd = [onako_bin, "serve", "--host", host, "--port", str(port), "--session", session, "--dir", working_dir]
|
|
163
|
+
if skip_permissions:
|
|
164
|
+
cmd.append("--dangerously-skip-permissions")
|
|
165
|
+
|
|
166
|
+
with open(log_out, "a") as log_fh:
|
|
167
|
+
proc = subprocess.Popen(
|
|
168
|
+
cmd,
|
|
169
|
+
stdout=log_fh,
|
|
170
|
+
stderr=subprocess.STDOUT,
|
|
171
|
+
start_new_session=True,
|
|
172
|
+
)
|
|
173
|
+
PID_FILE.parent.mkdir(parents=True, exist_ok=True)
|
|
174
|
+
PID_FILE.write_text(str(proc.pid))
|
|
175
|
+
|
|
176
|
+
local_ip = _get_local_ip()
|
|
177
|
+
banner = [
|
|
178
|
+
f"Onako server started (pid {proc.pid})",
|
|
179
|
+
f" Dashboard: http://{host}:{port}",
|
|
180
|
+
]
|
|
181
|
+
if local_ip:
|
|
182
|
+
banner.append(f" http://{local_ip}:{port}")
|
|
183
|
+
banner.append(f" Session: {session}")
|
|
184
|
+
banner.append(f" Logs: {log_out}")
|
|
185
|
+
for line in banner:
|
|
186
|
+
click.echo(line)
|
|
187
|
+
|
|
188
|
+
# Wait for server to be ready
|
|
189
|
+
import urllib.request
|
|
190
|
+
for _ in range(20):
|
|
191
|
+
try:
|
|
192
|
+
urllib.request.urlopen(f"http://127.0.0.1:{port}/health", timeout=1)
|
|
193
|
+
break
|
|
194
|
+
except Exception:
|
|
195
|
+
import time
|
|
196
|
+
time.sleep(0.25)
|
|
197
|
+
|
|
198
|
+
return True
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def _get_local_ip():
|
|
203
|
+
"""Get the machine's local network IP address."""
|
|
204
|
+
try:
|
|
205
|
+
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
206
|
+
s.connect(("8.8.8.8", 80))
|
|
207
|
+
ip = s.getsockname()[0]
|
|
208
|
+
s.close()
|
|
209
|
+
return ip
|
|
210
|
+
except Exception:
|
|
211
|
+
return None
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def _check_prerequisites():
|
|
215
|
+
"""Check that tmux and claude are installed."""
|
|
216
|
+
if not shutil.which("tmux"):
|
|
217
|
+
click.echo("Error: tmux is not installed.", err=True)
|
|
218
|
+
click.echo("Install it with: brew install tmux (macOS) or apt install tmux (Linux)", err=True)
|
|
219
|
+
sys.exit(1)
|
|
220
|
+
|
|
221
|
+
if not shutil.which("claude"):
|
|
222
|
+
click.echo("Warning: claude CLI not found on PATH.", err=True)
|
|
223
|
+
click.echo("Install Claude Code from: https://docs.anthropic.com/en/docs/claude-code", err=True)
|
|
@@ -8,13 +8,16 @@ from pydantic import BaseModel
|
|
|
8
8
|
from onako.tmux_orchestrator import TmuxOrchestrator
|
|
9
9
|
|
|
10
10
|
app = FastAPI()
|
|
11
|
-
|
|
11
|
+
session_name = os.environ.get("ONAKO_SESSION", "onako")
|
|
12
|
+
skip_permissions_default = os.environ.get("ONAKO_SKIP_PERMISSIONS") == "1"
|
|
13
|
+
orch = TmuxOrchestrator(session_name=session_name)
|
|
12
14
|
static_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "static")
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
class CreateTaskRequest(BaseModel):
|
|
16
18
|
prompt: str
|
|
17
19
|
working_dir: str | None = None
|
|
20
|
+
skip_permissions: bool | None = None
|
|
18
21
|
|
|
19
22
|
|
|
20
23
|
class SendMessageRequest(BaseModel):
|
|
@@ -28,12 +31,16 @@ def dashboard():
|
|
|
28
31
|
|
|
29
32
|
@app.get("/health")
|
|
30
33
|
def health():
|
|
31
|
-
return {"status": "ok"}
|
|
34
|
+
return {"status": "ok", "skip_permissions": skip_permissions_default}
|
|
32
35
|
|
|
33
36
|
|
|
34
37
|
@app.post("/tasks")
|
|
35
38
|
def create_task(req: CreateTaskRequest):
|
|
36
|
-
|
|
39
|
+
skip = req.skip_permissions if req.skip_permissions is not None else skip_permissions_default
|
|
40
|
+
if skip:
|
|
41
|
+
command = f"claude --dangerously-skip-permissions {shlex.quote(req.prompt)}"
|
|
42
|
+
else:
|
|
43
|
+
command = f"claude {shlex.quote(req.prompt)}"
|
|
37
44
|
task = orch.create_task(command, working_dir=req.working_dir, prompt=req.prompt)
|
|
38
45
|
return task
|
|
39
46
|
|
|
@@ -69,10 +76,20 @@ def send_message(task_id: str, req: SendMessageRequest):
|
|
|
69
76
|
return {"status": "sent"}
|
|
70
77
|
|
|
71
78
|
|
|
79
|
+
@app.post("/tasks/{task_id}/interrupt")
|
|
80
|
+
def interrupt_task(task_id: str):
|
|
81
|
+
if task_id not in orch.tasks:
|
|
82
|
+
raise HTTPException(status_code=404, detail="Task not found")
|
|
83
|
+
orch.send_interrupt(task_id)
|
|
84
|
+
return {"status": "interrupted"}
|
|
85
|
+
|
|
86
|
+
|
|
72
87
|
@app.delete("/tasks/{task_id}")
|
|
73
88
|
def delete_task(task_id: str):
|
|
74
89
|
if task_id not in orch.tasks:
|
|
75
90
|
raise HTTPException(status_code=404, detail="Task not found")
|
|
91
|
+
if task_id == "onako-main":
|
|
92
|
+
raise HTTPException(status_code=400, detail="Cannot kill the main window")
|
|
76
93
|
orch.kill_task(task_id)
|
|
77
94
|
return {"status": "deleted"}
|
|
78
95
|
|
|
@@ -55,6 +55,16 @@
|
|
|
55
55
|
}
|
|
56
56
|
.status-running { color: #22c55e; }
|
|
57
57
|
.status-done { color: #888; }
|
|
58
|
+
.origin-badge {
|
|
59
|
+
display: inline-block;
|
|
60
|
+
background: #444;
|
|
61
|
+
color: #aaa;
|
|
62
|
+
font-size: 10px;
|
|
63
|
+
padding: 1px 6px;
|
|
64
|
+
border-radius: 8px;
|
|
65
|
+
margin-left: 6px;
|
|
66
|
+
vertical-align: middle;
|
|
67
|
+
}
|
|
58
68
|
.empty-state {
|
|
59
69
|
text-align: center;
|
|
60
70
|
color: #666;
|
|
@@ -88,6 +98,16 @@
|
|
|
88
98
|
cursor: pointer;
|
|
89
99
|
font-size: 14px;
|
|
90
100
|
}
|
|
101
|
+
#interrupt-btn {
|
|
102
|
+
background: #f59e0b;
|
|
103
|
+
color: white;
|
|
104
|
+
border: none;
|
|
105
|
+
padding: 6px 12px;
|
|
106
|
+
border-radius: 6px;
|
|
107
|
+
cursor: pointer;
|
|
108
|
+
font-size: 12px;
|
|
109
|
+
}
|
|
110
|
+
#interrupt-btn.hidden { display: none; }
|
|
91
111
|
#kill-btn {
|
|
92
112
|
background: #ef4444;
|
|
93
113
|
color: white;
|
|
@@ -211,6 +231,7 @@
|
|
|
211
231
|
<div id="detail-header">
|
|
212
232
|
<button id="back-btn">← Back</button>
|
|
213
233
|
<span id="detail-task-id"></span>
|
|
234
|
+
<button id="interrupt-btn">Interrupt</button>
|
|
214
235
|
<button id="kill-btn">Kill</button>
|
|
215
236
|
</div>
|
|
216
237
|
<div id="output"></div>
|
|
@@ -225,6 +246,10 @@
|
|
|
225
246
|
<div id="modal">
|
|
226
247
|
<textarea id="prompt-input" placeholder="What do you want done?"></textarea>
|
|
227
248
|
<input id="workdir-input" type="text" placeholder="Working directory (optional)">
|
|
249
|
+
<label id="skip-perms-label" style="display:flex;align-items:center;gap:8px;margin-top:8px;font-size:13px;color:#aaa;cursor:pointer;">
|
|
250
|
+
<input type="checkbox" id="skip-perms-input" style="width:auto;margin:0;">
|
|
251
|
+
Skip permissions
|
|
252
|
+
</label>
|
|
228
253
|
<button id="submit-task-btn">Start Task</button>
|
|
229
254
|
</div>
|
|
230
255
|
|
|
@@ -233,6 +258,7 @@
|
|
|
233
258
|
let currentTaskId = null;
|
|
234
259
|
let currentTaskStatus = null;
|
|
235
260
|
let pollInterval = null;
|
|
261
|
+
let skipPermissionsDefault = false;
|
|
236
262
|
|
|
237
263
|
function timeAgo(dateStr) {
|
|
238
264
|
if (!dateStr) return '';
|
|
@@ -250,6 +276,15 @@
|
|
|
250
276
|
document.getElementById('connection-banner').style.display = show ? 'block' : 'none';
|
|
251
277
|
}
|
|
252
278
|
|
|
279
|
+
async function loadConfig() {
|
|
280
|
+
try {
|
|
281
|
+
const res = await fetch(`${API}/health`);
|
|
282
|
+
const data = await res.json();
|
|
283
|
+
skipPermissionsDefault = data.skip_permissions || false;
|
|
284
|
+
document.getElementById('skip-perms-input').checked = skipPermissionsDefault;
|
|
285
|
+
} catch (e) {}
|
|
286
|
+
}
|
|
287
|
+
|
|
253
288
|
async function loadTasks() {
|
|
254
289
|
try {
|
|
255
290
|
const res = await fetch(`${API}/tasks`);
|
|
@@ -260,7 +295,7 @@
|
|
|
260
295
|
} else {
|
|
261
296
|
list.innerHTML = tasks.map(t => `
|
|
262
297
|
<div class="task-item" onclick="showTask('${t.id}')">
|
|
263
|
-
<div class="task-id">${t.id}</div>
|
|
298
|
+
<div class="task-id">${t.id}${t.origin === 'external' ? '<span class="origin-badge">external</span>' : ''}</div>
|
|
264
299
|
<div class="task-prompt">${escapeHtml(t.prompt)}</div>
|
|
265
300
|
<div class="task-meta">
|
|
266
301
|
<span class="status-${t.status}">${t.status}</span>
|
|
@@ -281,7 +316,13 @@
|
|
|
281
316
|
document.getElementById('list-view').classList.add('hidden');
|
|
282
317
|
document.getElementById('detail-view').classList.add('active');
|
|
283
318
|
document.getElementById('detail-task-id').textContent = id;
|
|
284
|
-
|
|
319
|
+
if (id === 'onako-main') {
|
|
320
|
+
document.getElementById('interrupt-btn').classList.add('hidden');
|
|
321
|
+
document.getElementById('kill-btn').classList.add('hidden');
|
|
322
|
+
} else {
|
|
323
|
+
document.getElementById('interrupt-btn').classList.remove('hidden');
|
|
324
|
+
document.getElementById('kill-btn').classList.remove('hidden');
|
|
325
|
+
}
|
|
285
326
|
await refreshOutput();
|
|
286
327
|
pollInterval = setInterval(refreshOutput, 3000);
|
|
287
328
|
}
|
|
@@ -301,6 +342,7 @@
|
|
|
301
342
|
// Stop polling and hide kill button when task is done
|
|
302
343
|
if (data.status === 'done' && currentTaskStatus !== 'done') {
|
|
303
344
|
currentTaskStatus = 'done';
|
|
345
|
+
document.getElementById('interrupt-btn').classList.add('hidden');
|
|
304
346
|
document.getElementById('kill-btn').classList.add('hidden');
|
|
305
347
|
if (pollInterval) {
|
|
306
348
|
clearInterval(pollInterval);
|
|
@@ -338,6 +380,15 @@
|
|
|
338
380
|
}
|
|
339
381
|
}
|
|
340
382
|
|
|
383
|
+
async function interruptTask() {
|
|
384
|
+
if (!currentTaskId) return;
|
|
385
|
+
try {
|
|
386
|
+
await fetch(`${API}/tasks/${currentTaskId}/interrupt`, {method: 'POST'});
|
|
387
|
+
} catch (e) {
|
|
388
|
+
showConnectionError(true);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
341
392
|
async function killTask() {
|
|
342
393
|
if (!currentTaskId) return;
|
|
343
394
|
if (!confirm('Kill this task?')) return;
|
|
@@ -352,6 +403,7 @@
|
|
|
352
403
|
function showModal() {
|
|
353
404
|
document.getElementById('modal').style.display = 'block';
|
|
354
405
|
document.getElementById('modal-overlay').style.display = 'block';
|
|
406
|
+
document.getElementById('skip-perms-input').checked = skipPermissionsDefault;
|
|
355
407
|
document.getElementById('prompt-input').focus();
|
|
356
408
|
}
|
|
357
409
|
|
|
@@ -364,7 +416,8 @@
|
|
|
364
416
|
const prompt = document.getElementById('prompt-input').value.trim();
|
|
365
417
|
if (!prompt) return;
|
|
366
418
|
const workdir = document.getElementById('workdir-input').value.trim() || null;
|
|
367
|
-
const
|
|
419
|
+
const skipPerms = document.getElementById('skip-perms-input').checked;
|
|
420
|
+
const body = {prompt, skip_permissions: skipPerms};
|
|
368
421
|
if (workdir) body.working_dir = workdir;
|
|
369
422
|
try {
|
|
370
423
|
const res = await fetch(`${API}/tasks`, {
|
|
@@ -393,6 +446,7 @@
|
|
|
393
446
|
document.getElementById('modal-overlay').addEventListener('click', hideModal);
|
|
394
447
|
document.getElementById('submit-task-btn').addEventListener('click', submitTask);
|
|
395
448
|
document.getElementById('back-btn').addEventListener('click', showList);
|
|
449
|
+
document.getElementById('interrupt-btn').addEventListener('click', interruptTask);
|
|
396
450
|
document.getElementById('kill-btn').addEventListener('click', killTask);
|
|
397
451
|
document.getElementById('send-btn').addEventListener('click', sendMessage);
|
|
398
452
|
document.getElementById('message-input').addEventListener('keydown', e => {
|
|
@@ -403,6 +457,7 @@
|
|
|
403
457
|
});
|
|
404
458
|
|
|
405
459
|
// Init
|
|
460
|
+
loadConfig();
|
|
406
461
|
loadTasks();
|
|
407
462
|
setInterval(() => { if (!currentTaskId) loadTasks(); }, 10000);
|
|
408
463
|
</script>
|