scoutagent 2.0.0__tar.gz → 2.0.2__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.
- scoutagent-2.0.2/PKG-INFO +13 -0
- scoutagent-2.0.2/README.md +5 -0
- scoutagent-2.0.2/pyproject.toml +16 -0
- scoutagent-2.0.2/setup.cfg +4 -0
- scoutagent-2.0.2/src/scoutagent/__init__.py +0 -0
- scoutagent-2.0.2/src/scoutagent/catalog/launcher.json +81 -0
- scoutagent-2.0.2/src/scoutagent/runtime/__init__.py +0 -0
- scoutagent-2.0.2/src/scoutagent/runtime/python/__init__.py +0 -0
- scoutagent-2.0.2/src/scoutagent/runtime/python/launcher.py +499 -0
- scoutagent-2.0.2/src/scoutagent.egg-info/PKG-INFO +13 -0
- scoutagent-2.0.2/src/scoutagent.egg-info/SOURCES.txt +12 -0
- scoutagent-2.0.2/src/scoutagent.egg-info/dependency_links.txt +1 -0
- scoutagent-2.0.2/src/scoutagent.egg-info/entry_points.txt +2 -0
- scoutagent-2.0.2/src/scoutagent.egg-info/top_level.txt +1 -0
- scoutagent-2.0.0/.gitignore +0 -32
- scoutagent-2.0.0/PKG-INFO +0 -123
- scoutagent-2.0.0/README.md +0 -93
- scoutagent-2.0.0/pyproject.toml +0 -83
- scoutagent-2.0.0/src/scoutagent/__init__.py +0 -60
- scoutagent-2.0.0/src/scoutagent/cli.py +0 -179
- scoutagent-2.0.0/src/scoutagent/installer.py +0 -190
- scoutagent-2.0.0/src/scoutagent/platform.py +0 -87
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scoutagent
|
|
3
|
+
Version: 2.0.2
|
|
4
|
+
Summary: CMDOP universal CLI launcher
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
# scoutagent
|
|
10
|
+
|
|
11
|
+
CMDOP universal CLI launcher. Connect applications and AI agents to computers through CMDOP.
|
|
12
|
+
|
|
13
|
+
Run `scoutagent --help` or `scoutagent`. Official product: https://cmdop.ai
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires=["setuptools>=80"]
|
|
3
|
+
build-backend="setuptools.build_meta"
|
|
4
|
+
[project]
|
|
5
|
+
name="scoutagent"
|
|
6
|
+
version="2.0.2"
|
|
7
|
+
description="CMDOP universal CLI launcher"
|
|
8
|
+
readme="README.md"
|
|
9
|
+
requires-python=">=3.10"
|
|
10
|
+
license="MIT"
|
|
11
|
+
[project.scripts]
|
|
12
|
+
scoutagent="scoutagent.runtime.python.launcher:main"
|
|
13
|
+
[tool.setuptools.packages.find]
|
|
14
|
+
where=["src"]
|
|
15
|
+
[tool.setuptools.package-data]
|
|
16
|
+
"scoutagent"=["catalog/*.json"]
|
|
File without changes
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema_version": 1,
|
|
3
|
+
"contract_version": "0.1.0",
|
|
4
|
+
"package_version": "2.0.2",
|
|
5
|
+
"brand": {
|
|
6
|
+
"name": "CMDOP",
|
|
7
|
+
"site": "https://cmdop.ai",
|
|
8
|
+
"tagline": "Connect your AI and applications to computers you control."
|
|
9
|
+
},
|
|
10
|
+
"identity": {
|
|
11
|
+
"family_id": "scoutagent",
|
|
12
|
+
"entry_name": "scoutagent",
|
|
13
|
+
"publisher": "CMDOP",
|
|
14
|
+
"notice": "CMDOP universal CLI launcher."
|
|
15
|
+
},
|
|
16
|
+
"links": {
|
|
17
|
+
"product": "https://cmdop.ai",
|
|
18
|
+
"sdk": "https://docs.cmdop.ai/reference/sdk",
|
|
19
|
+
"mcp": "https://docs.cmdop.ai/start/quickstart-agent",
|
|
20
|
+
"machine": "https://docs.cmdop.ai/start/quickstart-owner",
|
|
21
|
+
"reforms": "https://reforms.ai"
|
|
22
|
+
},
|
|
23
|
+
"compatibility": {
|
|
24
|
+
"python": {
|
|
25
|
+
"package_name": "cmdop",
|
|
26
|
+
"minimum_major": 3,
|
|
27
|
+
"minimum_minor": 10,
|
|
28
|
+
"status": "published",
|
|
29
|
+
"approved_version": "3.6.1"
|
|
30
|
+
},
|
|
31
|
+
"typescript": {
|
|
32
|
+
"package_name": "@cmdop/sdk",
|
|
33
|
+
"minimum_major": 20,
|
|
34
|
+
"minimum_minor": 0,
|
|
35
|
+
"status": "published",
|
|
36
|
+
"approved_version": "3.6.1"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"menu": [
|
|
40
|
+
{
|
|
41
|
+
"id": "sdk",
|
|
42
|
+
"label": "Preview SDK setup for my project"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": "doctor",
|
|
46
|
+
"label": "Check my development environment"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"id": "product",
|
|
50
|
+
"label": "What can I build with CMDOP?"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"id": "mcp",
|
|
54
|
+
"label": "Connect an AI client with MCP \u2014 guide"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"id": "machine",
|
|
58
|
+
"label": "Connect my computer \u2014 guide"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"id": "website",
|
|
62
|
+
"label": "Show the CMDOP website"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"id": "reforms",
|
|
66
|
+
"label": "Explore Reforms \u2014 a separate Notion product"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": "exit",
|
|
70
|
+
"label": "Exit"
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"help_text": "CMDOP universal CLI. Commands: doctor, sdk plan, sdk setup, explain, links, --help, --version.",
|
|
74
|
+
"explanations": {
|
|
75
|
+
"sdk": "The SDK is a Python or JavaScript library for your application. Installing it does not connect a computer. Set up CMDOP separately and use an explicitly authorized read when ready.",
|
|
76
|
+
"mcp": "Connect an AI client to the remote CMDOP MCP endpoint using the official guide. Installing the SDK is not required. This launcher does not edit client configuration or connect it.",
|
|
77
|
+
"machine": "Connect a computer using the official CMDOP machine setup guide. This launcher does not download the machine binary, install a service or sign you in.",
|
|
78
|
+
"product": "Connect your AI and applications to computers you control. Choose an SDK for an application, MCP for an AI client, or the machine setup guide to bring a computer online.",
|
|
79
|
+
"reforms": "Reforms is a separate product for client workflows in Notion. It is optional and is not CMDOP setup documentation."
|
|
80
|
+
}
|
|
81
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
"""Native, read-only offline launcher. Python 3.10+, standard library only.
|
|
2
|
+
|
|
3
|
+
``evaluate`` accepts injected runtime facts; it never executes discovered tools.
|
|
4
|
+
Commands in a plan are data, and no SDK or credential files are imported/read.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
import hashlib
|
|
9
|
+
import os
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
import shutil
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
ROOT = Path(__file__).resolve().parents[2]
|
|
16
|
+
STAGES = (
|
|
17
|
+
"runtime", "installed", "imported", "configured", "authenticated",
|
|
18
|
+
"machine_ready", "machine_read", "starter", "guide",
|
|
19
|
+
)
|
|
20
|
+
LEGACY_FLAGS = {"--force", "--install-only", "--prefix", "--quiet", "--"}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def read_catalog():
|
|
24
|
+
"""Load the shared catalog relative to this module, independent of cwd."""
|
|
25
|
+
return json.loads((ROOT / "catalog" / "launcher.json").read_text(encoding="utf-8"))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def runtime_facts():
|
|
29
|
+
"""Inspect PATH without executing programs; only our own version is known."""
|
|
30
|
+
return {
|
|
31
|
+
"native_language": "python",
|
|
32
|
+
"platform": sys.platform,
|
|
33
|
+
"versions": {"python": list(sys.version_info[:3]), "typescript": None},
|
|
34
|
+
"executables": {
|
|
35
|
+
"python": sys.executable,
|
|
36
|
+
"node": shutil.which("node"),
|
|
37
|
+
"npm": shutil.which("npm"),
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _is_directory(path):
|
|
43
|
+
try:
|
|
44
|
+
return path.is_dir()
|
|
45
|
+
except OSError:
|
|
46
|
+
return False
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _is_file(path):
|
|
50
|
+
try:
|
|
51
|
+
return path.is_file()
|
|
52
|
+
except OSError:
|
|
53
|
+
return False
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def evaluate(action, options=None, catalog=None, runtime_context=None):
|
|
57
|
+
"""Return (result dictionary, exit code), with no mutation or subprocesses.
|
|
58
|
+
|
|
59
|
+
Options use ``target``, ``language`` and ``new`` (and ``topic`` for guides).
|
|
60
|
+
Runtime context has platform, versions and executables per the contract.
|
|
61
|
+
Filesystem inspection is limited to the target and ancestor writability.
|
|
62
|
+
"""
|
|
63
|
+
options = {} if options is None else options
|
|
64
|
+
catalog = read_catalog() if catalog is None else catalog
|
|
65
|
+
context = runtime_facts() if runtime_context is None else runtime_context
|
|
66
|
+
result = {
|
|
67
|
+
"schema_version": 1, "contract_version": catalog["contract_version"],
|
|
68
|
+
"requested_action": action, "result": "success", "error_category": None,
|
|
69
|
+
"message": "", "stages": dict.fromkeys(STAGES, "not_attempted"),
|
|
70
|
+
"changes": [], "plan": None, "diagnostics": {"revisions": json.loads(json.dumps(catalog["revisions"]))} if "revisions" in catalog else {}, "links": dict(catalog["links"]),
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
def fail(reason, message=None, code=3):
|
|
74
|
+
result.update(result="failed" if code in (2, 4) else "blocked",
|
|
75
|
+
error_category=reason, message=message or reason)
|
|
76
|
+
return result, code
|
|
77
|
+
|
|
78
|
+
if action == "help":
|
|
79
|
+
result["message"] = catalog["help_text"]
|
|
80
|
+
return result, 0
|
|
81
|
+
if action == "version":
|
|
82
|
+
result["message"] = catalog["package_version"]
|
|
83
|
+
return result, 0
|
|
84
|
+
if action == "links":
|
|
85
|
+
result["stages"]["guide"] = "passed"
|
|
86
|
+
result["message"] = "Links are shown only; no browser was opened."
|
|
87
|
+
return result, 0
|
|
88
|
+
if action == "explain":
|
|
89
|
+
topic = options.get("topic", "product")
|
|
90
|
+
if topic not in catalog["explanations"]:
|
|
91
|
+
return fail("usage", "Unknown explanation topic.", 2)
|
|
92
|
+
result["message"] = catalog["explanations"][topic]
|
|
93
|
+
result["stages"]["guide"] = "passed"
|
|
94
|
+
return result, 0
|
|
95
|
+
if action not in ("doctor", "sdk_plan", "sdk_setup"):
|
|
96
|
+
return fail("usage", "Unknown action.", 2)
|
|
97
|
+
language = options.get("language", context.get("native_language", "typescript"))
|
|
98
|
+
if language not in catalog["compatibility"]:
|
|
99
|
+
return fail("usage", "Choose python or typescript.", 2)
|
|
100
|
+
planning = action != "doctor"
|
|
101
|
+
if planning and (not options.get("target") or not options.get("language")):
|
|
102
|
+
return fail("usage", "SDK preview requires --target and --language.", 2)
|
|
103
|
+
|
|
104
|
+
# abspath matches Node's path.resolve without resolving project symlinks.
|
|
105
|
+
target = Path(os.path.abspath(options.get("target", os.getcwd())))
|
|
106
|
+
is_new = bool(options.get("new"))
|
|
107
|
+
blockers = []
|
|
108
|
+
names = []
|
|
109
|
+
package_json = None
|
|
110
|
+
if _is_directory(target):
|
|
111
|
+
try:
|
|
112
|
+
names = os.listdir(target)
|
|
113
|
+
except OSError:
|
|
114
|
+
blockers.append("target_unreadable")
|
|
115
|
+
if is_new and names:
|
|
116
|
+
blockers.append("new_target_not_empty")
|
|
117
|
+
elif not is_new or _is_file(target):
|
|
118
|
+
blockers.append("target_not_directory")
|
|
119
|
+
parent = target
|
|
120
|
+
while not _is_directory(parent) and parent.parent != parent:
|
|
121
|
+
parent = parent.parent
|
|
122
|
+
if not os.access(parent, os.W_OK):
|
|
123
|
+
blockers.append("target_unwritable")
|
|
124
|
+
|
|
125
|
+
if not blockers and "package.json" in names:
|
|
126
|
+
try:
|
|
127
|
+
package_json = json.loads((target / "package.json").read_text(encoding="utf-8"))
|
|
128
|
+
if not isinstance(package_json, dict) or (
|
|
129
|
+
"packageManager" in package_json
|
|
130
|
+
and not isinstance(package_json["packageManager"], str)
|
|
131
|
+
):
|
|
132
|
+
raise ValueError("Invalid manifest")
|
|
133
|
+
except (OSError, ValueError):
|
|
134
|
+
package_json = None
|
|
135
|
+
blockers.append("invalid_manifest")
|
|
136
|
+
|
|
137
|
+
manager = "npm" if language == "typescript" else "pip"
|
|
138
|
+
lock_names = ("package-lock.json", "pnpm-lock.yaml", "yarn.lock") if language == "typescript" else ("uv.lock", "poetry.lock")
|
|
139
|
+
locks = [name for name in lock_names if name in names]
|
|
140
|
+
if len(locks) > 1:
|
|
141
|
+
blockers.append("project_conflict")
|
|
142
|
+
if language == "typescript":
|
|
143
|
+
declared_manager = (package_json or {}).get("packageManager", "")
|
|
144
|
+
if "pnpm-lock.yaml" in locks or declared_manager.startswith("pnpm@"):
|
|
145
|
+
manager = "pnpm"
|
|
146
|
+
elif "yarn.lock" in locks or declared_manager.startswith("yarn@"):
|
|
147
|
+
manager = "yarn"
|
|
148
|
+
elif package_json is not None and "packageManager" in package_json:
|
|
149
|
+
manager = declared_manager.split("@")[0]
|
|
150
|
+
if "pnpm-workspace.yaml" in names:
|
|
151
|
+
manager = "pnpm"
|
|
152
|
+
if package_json is not None and "workspaces" in package_json:
|
|
153
|
+
blockers.append("project_conflict")
|
|
154
|
+
elif "uv.lock" in locks:
|
|
155
|
+
manager = "uv"
|
|
156
|
+
elif "poetry.lock" in locks:
|
|
157
|
+
manager = "poetry"
|
|
158
|
+
if manager not in ("npm", "pip"):
|
|
159
|
+
blockers.append("unsupported_project_manager")
|
|
160
|
+
|
|
161
|
+
version = context.get("versions", {}).get(language)
|
|
162
|
+
present = context.get("executables", {}).get("python" if language == "python" else "node")
|
|
163
|
+
spec = catalog["compatibility"][language]
|
|
164
|
+
if not present and not version:
|
|
165
|
+
blockers.append("runtime_missing")
|
|
166
|
+
elif not version:
|
|
167
|
+
blockers.append("runtime_unverified")
|
|
168
|
+
elif tuple(version[:2]) < (spec["minimum_major"], spec["minimum_minor"]):
|
|
169
|
+
blockers.append("runtime_unsupported")
|
|
170
|
+
if language == "typescript" and manager == "npm" and not context.get("executables", {}).get("npm"):
|
|
171
|
+
blockers.append("manager_missing")
|
|
172
|
+
python_in_venv = ".venv/Scripts/python.exe" if context.get("platform") == "win32" else ".venv/bin/python"
|
|
173
|
+
if planning and language == "python" and not is_new and not _is_file(target / python_in_venv):
|
|
174
|
+
blockers.append("missing_project_venv")
|
|
175
|
+
|
|
176
|
+
result["diagnostics"] = {
|
|
177
|
+
**result["diagnostics"],
|
|
178
|
+
"target": str(target), "language": language,
|
|
179
|
+
"mode": "new" if is_new else "existing", "manager": manager,
|
|
180
|
+
"lockfiles": locks, "runtime_version": version,
|
|
181
|
+
"runtime_presence": bool(present or version), "offline": True, "install_enabled": False,
|
|
182
|
+
}
|
|
183
|
+
result["stages"]["runtime"] = "blocked" if any(
|
|
184
|
+
reason in blockers for reason in ("runtime_missing", "runtime_unverified", "runtime_unsupported")
|
|
185
|
+
) else "passed"
|
|
186
|
+
if not planning:
|
|
187
|
+
if blockers:
|
|
188
|
+
return fail(blockers[0], "Environment diagnostics found prerequisites: " + ", ".join(dict.fromkeys(blockers)))
|
|
189
|
+
result["message"] = "Local environment inspected. SDK import, authorization and machine access were not checked."
|
|
190
|
+
return result, 0
|
|
191
|
+
|
|
192
|
+
blockers.append("sdk_baseline_pending")
|
|
193
|
+
commands = [["npm", "install", "--save-exact", "@cmdop/sdk@<approved-version>"]] if language == "typescript" else (
|
|
194
|
+
([["python3", "-m", "venv", ".venv"]] if is_new else [])
|
|
195
|
+
+ [[python_in_venv, "-m", "pip", "install", "cmdop==<approved-version>"]]
|
|
196
|
+
)
|
|
197
|
+
result["plan"] = {
|
|
198
|
+
"language": language, "target": str(target), "mode": "new" if is_new else "existing",
|
|
199
|
+
"manager": manager, "package_name": spec["package_name"], "approved_version": None,
|
|
200
|
+
"commands": commands,
|
|
201
|
+
"files_may_change": ["package.json", "package-lock.json", "node_modules"] if language == "typescript" else (["pyproject.toml"] if is_new else []) + [".venv"],
|
|
202
|
+
"install_enabled": False, "blockers": list(dict.fromkeys(blockers)),
|
|
203
|
+
}
|
|
204
|
+
return fail(blockers[0], "Preview only. Nothing was installed or written. A verified SDK baseline and the install executor are not available yet.")
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def parse(args):
|
|
208
|
+
"""Parse the bounded CLI without abbreviation or a legacy end-of-options flag."""
|
|
209
|
+
if any(arg in LEGACY_FLAGS or arg.startswith("--prefix=") for arg in args):
|
|
210
|
+
raise ValueError("Legacy installer options are not supported; use an explicit SDK preview or machine guide.")
|
|
211
|
+
options, positional = {}, []
|
|
212
|
+
as_json = help_requested = version_requested = False
|
|
213
|
+
index = 0
|
|
214
|
+
while index < len(args):
|
|
215
|
+
arg = args[index]
|
|
216
|
+
if arg == "--json":
|
|
217
|
+
as_json = True
|
|
218
|
+
elif arg in ("--plain", "--no-color"):
|
|
219
|
+
pass
|
|
220
|
+
elif arg in ("--help", "-h"):
|
|
221
|
+
help_requested = True
|
|
222
|
+
elif arg == "--version":
|
|
223
|
+
version_requested = True
|
|
224
|
+
elif arg == "--new":
|
|
225
|
+
options["new"] = True
|
|
226
|
+
elif arg in ("--target", "--language"):
|
|
227
|
+
if index + 1 == len(args) or not args[index + 1] or args[index + 1].startswith("--"):
|
|
228
|
+
raise ValueError("Missing option value")
|
|
229
|
+
key = arg[2:]
|
|
230
|
+
if key in options:
|
|
231
|
+
raise ValueError("Duplicate option")
|
|
232
|
+
index += 1
|
|
233
|
+
options[key] = args[index]
|
|
234
|
+
elif arg.startswith("-"):
|
|
235
|
+
raise ValueError("Unknown option")
|
|
236
|
+
else:
|
|
237
|
+
positional.append(arg)
|
|
238
|
+
index += 1
|
|
239
|
+
if help_requested:
|
|
240
|
+
return "help", {}, as_json
|
|
241
|
+
if version_requested:
|
|
242
|
+
return "version", {}, as_json
|
|
243
|
+
if not positional:
|
|
244
|
+
return "bare", options, as_json
|
|
245
|
+
if len(positional) == 2 and positional[0] == "sdk" and positional[1] in ("plan", "setup"):
|
|
246
|
+
action = "sdk_" + positional[1]
|
|
247
|
+
elif positional == ["doctor"]:
|
|
248
|
+
action = "doctor"
|
|
249
|
+
elif positional[0] == "explain" and len(positional) <= 2:
|
|
250
|
+
action = "explain"
|
|
251
|
+
options["topic"] = positional[1] if len(positional) == 2 else "product"
|
|
252
|
+
elif len(positional) == 1 and positional[0] in ("links", "help", "version"):
|
|
253
|
+
action = positional[0]
|
|
254
|
+
else:
|
|
255
|
+
raise ValueError("Unknown command or extra arguments")
|
|
256
|
+
if options.get("new") and action not in ("sdk_plan", "sdk_setup"):
|
|
257
|
+
raise ValueError("--new is only valid for SDK preview")
|
|
258
|
+
if action in ("links", "explain", "help", "version") and (options.get("target") or options.get("language")):
|
|
259
|
+
raise ValueError("Unexpected project options")
|
|
260
|
+
return action, options, as_json
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def render(result, as_json=False):
|
|
264
|
+
if as_json:
|
|
265
|
+
print(json.dumps(result, ensure_ascii=False))
|
|
266
|
+
return
|
|
267
|
+
print(result["message"])
|
|
268
|
+
if result["plan"] is not None and not result["diagnostics"].get("plan_presented"):
|
|
269
|
+
print(json.dumps(result["plan"], indent=2))
|
|
270
|
+
elif result["requested_action"] == "doctor":
|
|
271
|
+
print(json.dumps(result["diagnostics"], indent=2))
|
|
272
|
+
elif result["requested_action"] == "links":
|
|
273
|
+
for name, href in result["links"].items():
|
|
274
|
+
print(name + ": " + href)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def _observe(session, method, *args):
|
|
278
|
+
"""Optional recording cannot alter the useful menu operation."""
|
|
279
|
+
if session is not None:
|
|
280
|
+
try:
|
|
281
|
+
getattr(session, method)(*args)
|
|
282
|
+
except Exception:
|
|
283
|
+
pass
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def write_sdk_starter(target, language):
|
|
287
|
+
"""Create the SDK-owned example only on explicit request; never run it."""
|
|
288
|
+
if language != "python":
|
|
289
|
+
raise ValueError("Native starter language required")
|
|
290
|
+
target = Path(target)
|
|
291
|
+
if target.resolve() != target.absolute() or not target.is_dir():
|
|
292
|
+
raise ValueError("Target changed")
|
|
293
|
+
source = json.loads((ROOT / "catalog/sdk-starters.json").read_text())
|
|
294
|
+
template = source["templates"]["python"]
|
|
295
|
+
content = template["content"].encode()
|
|
296
|
+
if (source["schema_version"] != 1 or template["filename"] != "cmdop_example.py"
|
|
297
|
+
or len(content) > 16384 or hashlib.sha256(content).hexdigest() != template["sha256"]):
|
|
298
|
+
raise ValueError("Invalid SDK starter")
|
|
299
|
+
with (target / template["filename"]).open("xb") as stream:
|
|
300
|
+
stream.write(content)
|
|
301
|
+
return template["filename"]
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
def _setup_module():
|
|
305
|
+
"""Lazy sibling import works in both a packed namespace and source harness."""
|
|
306
|
+
import importlib.util
|
|
307
|
+
|
|
308
|
+
name = __name__ + "__sdk_setup"
|
|
309
|
+
spec = importlib.util.spec_from_file_location(name, Path(__file__).with_name("sdk_setup.py"))
|
|
310
|
+
module = importlib.util.module_from_spec(spec)
|
|
311
|
+
sys.modules[name] = module
|
|
312
|
+
spec.loader.exec_module(module)
|
|
313
|
+
return module
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
def run_sdk_setup(action, options, catalog, baseline, *, ask=None, write=print):
|
|
317
|
+
"""Local-artifact acceptance only; default CLI remains baseline-blocked."""
|
|
318
|
+
if action not in ("sdk_plan", "sdk_setup") or not baseline or options.get("language") != "python":
|
|
319
|
+
return evaluate(action, options, catalog)
|
|
320
|
+
result, _ = evaluate("help", {}, catalog)
|
|
321
|
+
result["requested_action"] = action
|
|
322
|
+
if not options.get("target"):
|
|
323
|
+
result.update(result="failed", error_category="usage", message="SDK setup requires --target and --language.")
|
|
324
|
+
return result, 2
|
|
325
|
+
module = _setup_module()
|
|
326
|
+
plan = module.plan_setup(options["target"], new_project=bool(options.get("new")), baseline=baseline)
|
|
327
|
+
result["plan"] = plan
|
|
328
|
+
result["diagnostics"].update(local_setup_candidate=True, install_enabled=not plan["blockers"])
|
|
329
|
+
if plan["blockers"]:
|
|
330
|
+
result.update(result="blocked", error_category=plan["blockers"][0], message="SDK setup prerequisites are not satisfied. Nothing was changed.")
|
|
331
|
+
return result, 3
|
|
332
|
+
result["stages"]["runtime"] = "passed"
|
|
333
|
+
if action == "sdk_plan":
|
|
334
|
+
result["message"] = "Reviewed local SDK candidate plan. Nothing was installed or written."
|
|
335
|
+
return result, 0
|
|
336
|
+
if ask is None:
|
|
337
|
+
result.update(result="blocked", error_category="confirmation_required", message="Review this plan in a terminal and explicitly confirm installation.")
|
|
338
|
+
return result, 3
|
|
339
|
+
write("Local SDK candidate: the package manager may resolve dependencies. This does not connect a machine.")
|
|
340
|
+
write(json.dumps(plan, indent=2))
|
|
341
|
+
result["diagnostics"]["plan_presented"] = True
|
|
342
|
+
confirmed = False
|
|
343
|
+
try:
|
|
344
|
+
confirmed = ask("Install this SDK in the project? Type yes [Back]: ").strip().lower() == "yes"
|
|
345
|
+
except EOFError:
|
|
346
|
+
pass
|
|
347
|
+
execution = module.execute_setup(plan, confirmed=confirmed)
|
|
348
|
+
result.update(result=execution["status"], error_category=execution.get("error_category"),
|
|
349
|
+
message=execution.get("message") or execution.get("recovery") or "SDK setup completed. Follow the official connection guide when ready.",
|
|
350
|
+
changes=execution.get("changes", []))
|
|
351
|
+
result["stages"].update({name: "passed" if value == "succeeded" else value
|
|
352
|
+
for name, value in execution.get("stages", {}).items()})
|
|
353
|
+
result["diagnostics"]["installed_version"] = execution.get("installed_version")
|
|
354
|
+
if execution["exit_code"] == 0:
|
|
355
|
+
result["message"] = "SDK installed and imported. Next: " + catalog["links"]["sdk"]
|
|
356
|
+
write("SDK import checked. No authorization or machine access was performed.")
|
|
357
|
+
starter = False
|
|
358
|
+
try:
|
|
359
|
+
starter = ask("Create the SDK example file without running it? Type yes [Back]: ").strip().lower() == "yes"
|
|
360
|
+
except EOFError:
|
|
361
|
+
pass
|
|
362
|
+
except KeyboardInterrupt:
|
|
363
|
+
result.update(result="cancelled", error_category="cancelled",
|
|
364
|
+
message="Cancelled after SDK installation/import. Existing project changes are retained.")
|
|
365
|
+
return result, 130
|
|
366
|
+
if starter:
|
|
367
|
+
try:
|
|
368
|
+
filename = write_sdk_starter(plan["target"], "python")
|
|
369
|
+
result["changes"].append(filename)
|
|
370
|
+
result["stages"]["starter"] = "written"
|
|
371
|
+
write("Created " + filename + ". It connects only when you run it after configuring CMDOP. " + catalog["links"]["sdk"])
|
|
372
|
+
except (OSError, ValueError, KeyError, TypeError):
|
|
373
|
+
result.update(result="blocked", error_category="starter_not_written",
|
|
374
|
+
message="SDK installed and imported. The example was not written; existing files are preserved.")
|
|
375
|
+
result["stages"]["starter"] = "blocked"
|
|
376
|
+
return result, 3
|
|
377
|
+
return result, execution["exit_code"]
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
def menu(catalog, observation_session=None, *, setup_baseline=None):
|
|
381
|
+
"""Line-based menu; retain unresolved preview/doctor exit status on exit/EOF."""
|
|
382
|
+
last_code = 0
|
|
383
|
+
items = catalog["menu"]
|
|
384
|
+
exit_choice = next((i for i, item in enumerate(items, 1) if item["id"] == "exit"), len(items))
|
|
385
|
+
try:
|
|
386
|
+
while True:
|
|
387
|
+
print("\n" + catalog["brand"]["name"] + " · " + catalog["brand"]["site"])
|
|
388
|
+
print(catalog["brand"]["tagline"] + "\n" + catalog["identity"]["notice"])
|
|
389
|
+
print("Local SDK setup candidate. Project changes require confirmation." if setup_baseline else "Offline prototype: nothing has been installed or connected.")
|
|
390
|
+
for index, item in enumerate(items, 1):
|
|
391
|
+
print(str(index) + ". " + ("Set up SDK for my project" if setup_baseline and item["id"] == "sdk" else item["label"]))
|
|
392
|
+
choice = input("Choose an option [" + str(exit_choice) + "]: ").strip() or str(exit_choice)
|
|
393
|
+
if not choice.isdecimal() or not 1 <= int(choice) <= len(items):
|
|
394
|
+
print("Choose a number from 1 to " + str(len(items)) + ".")
|
|
395
|
+
continue
|
|
396
|
+
item = items[int(choice) - 1]
|
|
397
|
+
_observe(observation_session, "action", item["id"])
|
|
398
|
+
if item["id"] == "exit":
|
|
399
|
+
if observation_session is not None:
|
|
400
|
+
try:
|
|
401
|
+
import asyncio
|
|
402
|
+
|
|
403
|
+
asyncio.run(observation_session.finish(code=last_code, ask=input, write=print))
|
|
404
|
+
except Exception:
|
|
405
|
+
pass
|
|
406
|
+
return last_code
|
|
407
|
+
if item["id"] == "sdk":
|
|
408
|
+
language = input("Language [python/typescript]: ").strip() or "python"
|
|
409
|
+
target = input("Project directory: ").strip()
|
|
410
|
+
options = {"language": language, "target": target}
|
|
411
|
+
if setup_baseline and language == "python":
|
|
412
|
+
options["new"] = input("Create a new project? Type yes [existing]: ").strip().lower() == "yes"
|
|
413
|
+
if setup_baseline:
|
|
414
|
+
result, code = run_sdk_setup("sdk_setup", options, catalog, setup_baseline, ask=input)
|
|
415
|
+
else:
|
|
416
|
+
result, code = evaluate("sdk_plan", options, catalog)
|
|
417
|
+
_observe(observation_session, "outcome", "sdk", result)
|
|
418
|
+
render(result)
|
|
419
|
+
if code == 130:
|
|
420
|
+
if result.get("error_category") != "confirmation_required":
|
|
421
|
+
return 130
|
|
422
|
+
elif code:
|
|
423
|
+
last_code = code
|
|
424
|
+
elif item["id"] == "doctor":
|
|
425
|
+
result, code = evaluate("doctor", {}, catalog)
|
|
426
|
+
_observe(observation_session, "outcome", "doctor", result)
|
|
427
|
+
render(result)
|
|
428
|
+
if code:
|
|
429
|
+
last_code = code
|
|
430
|
+
elif item["id"] == "website":
|
|
431
|
+
print(catalog["links"]["product"])
|
|
432
|
+
else:
|
|
433
|
+
result, _ = evaluate("explain", {"topic": item["id"]}, catalog)
|
|
434
|
+
_observe(observation_session, "outcome", item["id"], result)
|
|
435
|
+
render(result)
|
|
436
|
+
print(catalog["links"][item["id"]])
|
|
437
|
+
except EOFError:
|
|
438
|
+
return last_code
|
|
439
|
+
except KeyboardInterrupt:
|
|
440
|
+
print("\nCancelled.")
|
|
441
|
+
return 130
|
|
442
|
+
finally:
|
|
443
|
+
_observe(observation_session, "discard")
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
def main(args=None, *, observation_session=None, observation_session_factory=None, setup_baseline=None):
|
|
447
|
+
"""Run the CLI, returning an exit code instead of exiting on import."""
|
|
448
|
+
args = list(sys.argv[1:] if args is None else args)
|
|
449
|
+
catalog = None
|
|
450
|
+
try:
|
|
451
|
+
catalog = read_catalog()
|
|
452
|
+
try:
|
|
453
|
+
action, options, as_json = parse(args)
|
|
454
|
+
except ValueError as error:
|
|
455
|
+
result, _ = evaluate("help", {}, catalog)
|
|
456
|
+
result.update(requested_action="usage", result="failed", error_category="usage", message=str(error))
|
|
457
|
+
render(result, "--json" in args)
|
|
458
|
+
return 2
|
|
459
|
+
if action == "bare":
|
|
460
|
+
if options:
|
|
461
|
+
result, _ = evaluate("unknown", {}, catalog)
|
|
462
|
+
render(result, as_json)
|
|
463
|
+
return 2
|
|
464
|
+
if not as_json and sys.stdin.isatty() and sys.stdout.isatty():
|
|
465
|
+
if (observation_session is None and observation_session_factory is not None
|
|
466
|
+
and os.environ.get("DO_NOT_TRACK") != "1"):
|
|
467
|
+
try:
|
|
468
|
+
observation_session = observation_session_factory()
|
|
469
|
+
except Exception:
|
|
470
|
+
observation_session = None
|
|
471
|
+
if setup_baseline:
|
|
472
|
+
return menu(catalog, observation_session=observation_session, setup_baseline=setup_baseline)
|
|
473
|
+
return menu(catalog, observation_session=observation_session)
|
|
474
|
+
action = "help"
|
|
475
|
+
if setup_baseline and action in ("sdk_plan", "sdk_setup"):
|
|
476
|
+
ask = input if action == "sdk_setup" and not as_json and sys.stdin.isatty() and sys.stdout.isatty() else None
|
|
477
|
+
result, code = run_sdk_setup(action, options, catalog, setup_baseline, ask=ask)
|
|
478
|
+
else:
|
|
479
|
+
result, code = evaluate(action, options, catalog)
|
|
480
|
+
render(result, as_json)
|
|
481
|
+
return code
|
|
482
|
+
except (OSError, ValueError, KeyError, TypeError):
|
|
483
|
+
if catalog is None:
|
|
484
|
+
print("Launcher inspection failed.", file=sys.stderr)
|
|
485
|
+
else:
|
|
486
|
+
result, _ = evaluate("help", {}, catalog)
|
|
487
|
+
result.update(result="failed", error_category="execution_failure", message="Launcher inspection failed.")
|
|
488
|
+
render(result, "--json" in args)
|
|
489
|
+
return 4
|
|
490
|
+
except KeyboardInterrupt:
|
|
491
|
+
if catalog is not None:
|
|
492
|
+
result, _ = evaluate("help", {}, catalog)
|
|
493
|
+
result.update(result="cancelled", error_category="cancelled", message="Cancelled.")
|
|
494
|
+
render(result, "--json" in args)
|
|
495
|
+
return 130
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
if __name__ == "__main__":
|
|
499
|
+
sys.exit(main())
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scoutagent
|
|
3
|
+
Version: 2.0.2
|
|
4
|
+
Summary: CMDOP universal CLI launcher
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
# scoutagent
|
|
10
|
+
|
|
11
|
+
CMDOP universal CLI launcher. Connect applications and AI agents to computers through CMDOP.
|
|
12
|
+
|
|
13
|
+
Run `scoutagent --help` or `scoutagent`. Official product: https://cmdop.ai
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/scoutagent/__init__.py
|
|
4
|
+
src/scoutagent.egg-info/PKG-INFO
|
|
5
|
+
src/scoutagent.egg-info/SOURCES.txt
|
|
6
|
+
src/scoutagent.egg-info/dependency_links.txt
|
|
7
|
+
src/scoutagent.egg-info/entry_points.txt
|
|
8
|
+
src/scoutagent.egg-info/top_level.txt
|
|
9
|
+
src/scoutagent/catalog/launcher.json
|
|
10
|
+
src/scoutagent/runtime/__init__.py
|
|
11
|
+
src/scoutagent/runtime/python/__init__.py
|
|
12
|
+
src/scoutagent/runtime/python/launcher.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
scoutagent
|