cmdbox 0.6.3.2__py3-none-any.whl → 0.6.4.1__py3-none-any.whl

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.

Potentially problematic release.


This version of cmdbox might be problematic. Click here for more details.

Files changed (168) hide show
  1. cmdbox/app/app.py +22 -7
  2. cmdbox/app/common.py +9 -6
  3. cmdbox/app/commons/loghandler.py +101 -20
  4. cmdbox/app/commons/redis_client.py +1 -1
  5. cmdbox/app/edge.py +2 -4
  6. cmdbox/app/feature.py +1 -1
  7. cmdbox/app/features/cli/cmdbox_agent_mcp_client.py +175 -0
  8. cmdbox/app/features/cli/cmdbox_agent_mcp_proxy.py +96 -0
  9. cmdbox/app/features/cli/cmdbox_audit_createdb.py +224 -224
  10. cmdbox/app/features/cli/cmdbox_audit_delete.py +4 -4
  11. cmdbox/app/features/cli/cmdbox_audit_search.py +4 -4
  12. cmdbox/app/features/cli/cmdbox_audit_write.py +6 -8
  13. cmdbox/app/features/cli/cmdbox_client_file_copy.py +3 -3
  14. cmdbox/app/features/cli/cmdbox_client_file_download.py +3 -3
  15. cmdbox/app/features/cli/cmdbox_client_file_list.py +3 -3
  16. cmdbox/app/features/cli/cmdbox_client_file_mkdir.py +3 -3
  17. cmdbox/app/features/cli/cmdbox_client_file_move.py +3 -3
  18. cmdbox/app/features/cli/cmdbox_client_file_remove.py +3 -3
  19. cmdbox/app/features/cli/cmdbox_client_file_rmdir.py +3 -3
  20. cmdbox/app/features/cli/cmdbox_client_file_upload.py +3 -3
  21. cmdbox/app/features/cli/cmdbox_client_http.py +7 -6
  22. cmdbox/app/features/cli/cmdbox_client_server_info.py +4 -4
  23. cmdbox/app/features/cli/cmdbox_cmd_list.py +4 -4
  24. cmdbox/app/features/cli/cmdbox_cmd_load.py +5 -5
  25. cmdbox/app/features/cli/cmdbox_edge_config.py +1 -1
  26. cmdbox/app/features/cli/cmdbox_edge_start.py +3 -3
  27. cmdbox/app/features/cli/cmdbox_mcp_client.py +174 -174
  28. cmdbox/app/features/cli/cmdbox_mcp_proxy.py +96 -96
  29. cmdbox/app/features/cli/cmdbox_server_list.py +3 -3
  30. cmdbox/app/features/cli/cmdbox_server_start.py +103 -103
  31. cmdbox/app/features/cli/cmdbox_server_stop.py +6 -6
  32. cmdbox/app/features/cli/cmdbox_tts_install.py +317 -0
  33. cmdbox/app/features/cli/cmdbox_tts_say.py +179 -0
  34. cmdbox/app/features/cli/cmdbox_tts_start.py +329 -0
  35. cmdbox/app/features/cli/cmdbox_tts_stop.py +108 -0
  36. cmdbox/app/features/cli/cmdbox_web_apikey_add.py +91 -91
  37. cmdbox/app/features/cli/cmdbox_web_apikey_del.py +91 -91
  38. cmdbox/app/features/cli/cmdbox_web_gencert.py +7 -7
  39. cmdbox/app/features/cli/cmdbox_web_genpass.py +168 -168
  40. cmdbox/app/features/cli/cmdbox_web_group_add.py +94 -94
  41. cmdbox/app/features/cli/cmdbox_web_group_del.py +87 -87
  42. cmdbox/app/features/cli/cmdbox_web_group_edit.py +94 -94
  43. cmdbox/app/features/cli/cmdbox_web_group_list.py +87 -87
  44. cmdbox/app/features/cli/cmdbox_web_start.py +236 -235
  45. cmdbox/app/features/cli/cmdbox_web_stop.py +72 -72
  46. cmdbox/app/features/cli/cmdbox_web_user_add.py +104 -104
  47. cmdbox/app/features/cli/cmdbox_web_user_del.py +87 -87
  48. cmdbox/app/features/cli/cmdbox_web_user_edit.py +104 -104
  49. cmdbox/app/features/cli/cmdbox_web_user_list.py +87 -87
  50. cmdbox/app/features/web/cmdbox_web_agent.py +16 -4
  51. cmdbox/app/features/web/cmdbox_web_get_cmd_choices.py +10 -2
  52. cmdbox/app/features/web/cmdbox_web_save_cmd.py +1 -0
  53. cmdbox/app/features/web/cmdbox_web_versions_used.py +4 -0
  54. cmdbox/app/filer.py +9 -9
  55. cmdbox/app/mcp.py +19 -8
  56. cmdbox/app/options.py +52 -47
  57. cmdbox/app/server.py +224 -224
  58. cmdbox/app/web.py +39 -17
  59. cmdbox/extensions/features.yml +7 -1
  60. cmdbox/extensions/sample_project/sample/app/features/cli/sample_client_time.py +2 -2
  61. cmdbox/extensions/sample_project/sample/app/features/cli/sample_server_time.py +3 -3
  62. cmdbox/licenses/LICENSE_APScheduler_3_11_0_MIT_License.txt +19 -0
  63. cmdbox/licenses/LICENSE_SQLAlchemy_2_0_43_MIT.txt +19 -0
  64. cmdbox/licenses/LICENSE_Werkzeug_3_1_1_BSD_License.txt +28 -0
  65. cmdbox/licenses/LICENSE_absolufy-imports_0_3_1_MIT_License.txt +21 -0
  66. cmdbox/licenses/LICENSE_anyio_4_10_0_UNKNOWN.txt +20 -0
  67. cmdbox/licenses/{LICENSE_typer_0_16_0_MIT_License.txt → LICENSE_backoff_2_2_1_MIT_License.txt} +1 -1
  68. cmdbox/licenses/LICENSE_certifi_2025_8_3_Mozilla_Public_License_2_0-MPL_2_0.txt +20 -0
  69. cmdbox/licenses/LICENSE_charset-normalizer_3_4_3_MIT.txt +21 -0
  70. cmdbox/licenses/LICENSE_cryptography_45_0_6_Apache-2_0_OR_BSD-3-Clause.txt +3 -0
  71. cmdbox/licenses/LICENSE_cyclopts_3_22_5_Apache_Software_License.txt +201 -0
  72. cmdbox/licenses/LICENSE_fastapi-sso_0_18_0_MIT_License.txt +21 -0
  73. cmdbox/licenses/LICENSE_fastmcp_2_11_3_Apache_Software_License.txt +201 -0
  74. cmdbox/licenses/LICENSE_google-adk_1_9_0_Apache_Software_License.txt +202 -0
  75. cmdbox/licenses/LICENSE_google-genai_1_28_0_Apache_Software_License.txt +202 -0
  76. cmdbox/licenses/LICENSE_google-genai_1_29_0_Apache_Software_License.txt +202 -0
  77. cmdbox/licenses/LICENSE_greenlet_3_2_4_MIT_AND_Python-2_0.txt +30 -0
  78. cmdbox/licenses/LICENSE_isodate_0_7_2_BSD_License.txt +26 -0
  79. cmdbox/licenses/LICENSE_lazy-object-proxy_1_11_0_BSD_License.txt +20 -0
  80. cmdbox/licenses/LICENSE_litellm-enterprise_0_1_19_UNKNOWN.txt +37 -0
  81. cmdbox/licenses/LICENSE_litellm_1_75_5_post1_MIT_License.txt +26 -0
  82. cmdbox/licenses/LICENSE_markdown-it-py_4_0_0_MIT_License.txt +21 -0
  83. cmdbox/licenses/LICENSE_mcp_1_12_4_MIT_License.txt +21 -0
  84. cmdbox/licenses/LICENSE_multidict_6_6_4_Apache_License_2_0.txt +13 -0
  85. cmdbox/licenses/LICENSE_oauthlib_3_3_1_BSD-3-Clause.txt +27 -0
  86. cmdbox/licenses/LICENSE_openai_1_99_9_Apache_Software_License.txt +201 -0
  87. cmdbox/licenses/LICENSE_openapi-core_0_19_5_BSD_License.txt +29 -0
  88. cmdbox/licenses/LICENSE_openapi-schema-validator_0_6_3_BSD_License.txt +29 -0
  89. cmdbox/licenses/LICENSE_openapi-spec-validator_0_7_2_Apache_Software_License.txt +201 -0
  90. cmdbox/licenses/LICENSE_opentelemetry-api_1_36_0_UNKNOWN.txt +201 -0
  91. cmdbox/licenses/LICENSE_opentelemetry-sdk_1_36_0_UNKNOWN.txt +201 -0
  92. cmdbox/licenses/LICENSE_opentelemetry-semantic-conventions_0_57b0_UNKNOWN.txt +201 -0
  93. cmdbox/licenses/LICENSE_orjson_3_11_1_Apache_Software_License-MIT_License.txt +201 -0
  94. cmdbox/licenses/LICENSE_parse_1_20_2_MIT_License.txt +19 -0
  95. cmdbox/licenses/LICENSE_pathable_0_4_4_Apache_Software_License.txt +201 -0
  96. cmdbox/licenses/{LICENSE_pillow_11_2_1_UNKNOWN.txt → LICENSE_pillow_11_3_0_UNKNOWN.txt} +393 -3
  97. cmdbox/licenses/LICENSE_pyperclip_1_9_0_BSD_License.txt +27 -0
  98. cmdbox/licenses/LICENSE_redis_6_4_0_MIT_License.txt +21 -0
  99. cmdbox/licenses/LICENSE_rfc3339-validator_0_1_4_MIT_License.txt +22 -0
  100. cmdbox/licenses/LICENSE_rich-rst_1_3_1_MIT_License.txt +7 -0
  101. cmdbox/licenses/LICENSE_rpds-py_0_27_0_UNKNOWN.txt +19 -0
  102. cmdbox/licenses/{LICENSE_setuptools_65_5_0_MIT_License.txt → LICENSE_setuptools_80_9_0_UNKNOWN.txt} +0 -2
  103. cmdbox/licenses/LICENSE_sphinx-intl_2_3_2_UNKNOWN.txt +25 -0
  104. cmdbox/licenses/LICENSE_tenacity_9_1_2_Apache_Software_License.txt +202 -0
  105. cmdbox/licenses/LICENSE_tiktoken_0_11_0_MIT_License-Copyright-c-2022_OpenAI-Shantanu_Jain-Permission_is_hereby_granted-free_of_charge-to_any_per.txt +21 -0
  106. cmdbox/licenses/LICENSE_tokenizers_0_21_4_Apache_Software_License.txt +1 -0
  107. cmdbox/licenses/LICENSE_voicevox_core_0_16_0_MIT.txt +20 -0
  108. cmdbox/licenses/LICENSE_watchdog_6_0_0_Apache_Software_License.txt +16 -0
  109. cmdbox/licenses/{LICENSE_httptools_0_6_4_MIT_License.txt → LICENSE_wsproto_1_2_0_MIT_License.txt} +3 -3
  110. cmdbox/licenses/files.txt +69 -50
  111. cmdbox/logconf_cmdbox.yml +136 -0
  112. cmdbox/version.py +2 -2
  113. cmdbox/web/agent.html +16 -2
  114. cmdbox/web/assets/cmdbox/agent.js +226 -1
  115. cmdbox/web/assets/cmdbox/common.js +20 -25
  116. cmdbox/web/assets/cmdbox/svgicon.js +18 -0
  117. {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info}/METADATA +29 -20
  118. {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info}/RECORD +158 -118
  119. {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info}/WHEEL +1 -1
  120. cmdbox/config.yml +0 -3
  121. cmdbox/licenses/LICENSE_shellingham_1_5_4_ISC_License-ISCL.txt +0 -13
  122. cmdbox/licenses/LICENSE_watchfiles_1_1_0_MIT_License.txt +0 -21
  123. cmdbox/logconf_audit.yml +0 -43
  124. cmdbox/logconf_client.yml +0 -43
  125. cmdbox/logconf_edge.yml +0 -43
  126. cmdbox/logconf_gui.yml +0 -43
  127. cmdbox/logconf_mcp.yml +0 -43
  128. cmdbox/logconf_server.yml +0 -43
  129. cmdbox/logconf_web.yml +0 -43
  130. /cmdbox/licenses/{LICENSE_Authlib_1_6_0_BSD_License.txt → LICENSE_Authlib_1_6_1_BSD_License.txt} +0 -0
  131. /cmdbox/licenses/{LICENSE_SQLAlchemy_2_0_41_MIT.txt → LICENSE_SQLAlchemy_2_0_42_MIT.txt} +0 -0
  132. /cmdbox/licenses/{LICENSE_aiohttp_3_12_13_Apache-2_0.txt → LICENSE_aiohttp_3_12_15_Apache-2_0_AND_MIT.txt} +0 -0
  133. /cmdbox/licenses/{LICENSE_aiosignal_1_3_2_Apache_Software_License.txt → LICENSE_aiosignal_1_4_0_Apache_Software_License.txt} +0 -0
  134. /cmdbox/licenses/{LICENSE_certifi_2025_6_15_Mozilla_Public_License_2_0-MPL_2_0.txt → LICENSE_certifi_2025_7_14_Mozilla_Public_License_2_0-MPL_2_0.txt} +0 -0
  135. /cmdbox/licenses/{LICENSE_cryptography_45_0_4_Apache-2_0_OR_BSD-3-Clause.txt → LICENSE_cryptography_45_0_5_Apache-2_0_OR_BSD-3-Clause.txt} +0 -0
  136. /cmdbox/licenses/{LICENSE_docstring_parser_0_16_MIT_License.txt → LICENSE_docstring_parser_0_17_0_MIT_License.txt} +0 -0
  137. /cmdbox/licenses/{LICENSE_fastapi_0_115_14_MIT_License.txt → LICENSE_fastapi_0_116_1_MIT_License.txt} +0 -0
  138. /cmdbox/licenses/{LICENSE_fastmcp_2_10_1_Apache_Software_License.txt → LICENSE_fastmcp_2_11_0_Apache_Software_License.txt} +0 -0
  139. /cmdbox/licenses/{LICENSE_fsspec_2025_5_1_BSD_License.txt → LICENSE_fsspec_2025_7_0_BSD_License.txt} +0 -0
  140. /cmdbox/licenses/{LICENSE_google-adk_1_5_0_Apache_Software_License.txt → LICENSE_google-adk_1_10_0_Apache_Software_License.txt} +0 -0
  141. /cmdbox/licenses/{LICENSE_google-api-python-client_2_174_0_Apache_Software_License.txt → LICENSE_google-api-python-client_2_177_0_Apache_Software_License.txt} +0 -0
  142. /cmdbox/licenses/{LICENSE_huggingface-hub_0_33_1_Apache_Software_License.txt → LICENSE_google-api-python-client_2_178_0_Apache_Software_License.txt} +0 -0
  143. /cmdbox/licenses/{LICENSE_google-cloud-aiplatform_1_100_0_Apache_2_0.txt → LICENSE_google-cloud-aiplatform_1_106_0_Apache_2_0.txt} +0 -0
  144. /cmdbox/licenses/{LICENSE_google-cloud-bigquery_3_34_0_Apache_Software_License.txt → LICENSE_google-cloud-aiplatform_1_108_0_Apache_2_0.txt} +0 -0
  145. /cmdbox/licenses/{LICENSE_google-genai_1_23_0_Apache_Software_License.txt → LICENSE_google-cloud-bigquery_3_35_1_Apache_Software_License.txt} +0 -0
  146. /cmdbox/licenses/{LICENSE_grpcio-status_1_73_1_Apache_Software_License.txt → LICENSE_grpcio-status_1_74_0_Apache_Software_License.txt} +0 -0
  147. /cmdbox/licenses/{LICENSE_grpcio_1_73_1_Apache_Software_License.txt → LICENSE_grpcio_1_74_0_Apache_Software_License.txt} +0 -0
  148. /cmdbox/licenses/{LICENSE_opentelemetry-api_1_34_1_Apache_Software_License.txt → LICENSE_huggingface-hub_0_34_3_Apache_Software_License.txt} +0 -0
  149. /cmdbox/licenses/{LICENSE_opentelemetry-sdk_1_34_1_Apache_Software_License.txt → LICENSE_huggingface-hub_0_34_4_Apache_Software_License.txt} +0 -0
  150. /cmdbox/licenses/{LICENSE_opentelemetry-semantic-conventions_0_55b1_Apache_Software_License.txt → LICENSE_jsonschema-path_0_3_4_Apache_Software_License.txt} +0 -0
  151. /cmdbox/licenses/{LICENSE_jsonschema_4_24_0_UNKNOWN.txt → LICENSE_jsonschema_4_25_0_UNKNOWN.txt} +0 -0
  152. /cmdbox/licenses/{LICENSE_litellm_1_73_6_MIT_License.txt → LICENSE_litellm_1_74_12_MIT_License.txt} +0 -0
  153. /cmdbox/licenses/{LICENSE_mcp_1_10_1_MIT_License.txt → LICENSE_mcp_1_12_3_MIT_License.txt} +0 -0
  154. /cmdbox/licenses/{LICENSE_multidict_6_6_2_Apache_License_2_0.txt → LICENSE_multidict_6_6_3_Apache_License_2_0.txt} +0 -0
  155. /cmdbox/licenses/{LICENSE_nh3_0_2_21_MIT.txt → LICENSE_nh3_0_3_0_MIT.txt} +0 -0
  156. /cmdbox/licenses/{LICENSE_numpy_2_3_1_BSD_License.txt → LICENSE_numpy_2_3_2_BSD_License.txt} +0 -0
  157. /cmdbox/licenses/{LICENSE_openai_1_93_0_Apache_Software_License.txt → LICENSE_openai_1_98_0_Apache_Software_License.txt} +0 -0
  158. /cmdbox/licenses/{LICENSE_tokenizers_0_21_2_Apache_Software_License.txt → LICENSE_pywin32_311_Python_Software_Foundation_License.txt} +0 -0
  159. /cmdbox/licenses/{LICENSE_regex_2024_11_6_Apache_Software_License.txt → LICENSE_regex_2025_7_34_UNKNOWN.txt} +0 -0
  160. /cmdbox/licenses/{LICENSE_rich_14_0_0_MIT_License.txt → LICENSE_rich_14_1_0_MIT_License.txt} +0 -0
  161. /cmdbox/licenses/{LICENSE_rpds-py_0_25_1_MIT.txt → LICENSE_rpds-py_0_26_0_MIT.txt} +0 -0
  162. /cmdbox/licenses/{LICENSE_sse-starlette_2_3_6_BSD_License.txt → LICENSE_sse-starlette_3_0_2_UNKNOWN.txt} +0 -0
  163. /cmdbox/licenses/{LICENSE_starlette_0_46_2_BSD_License.txt → LICENSE_starlette_0_47_2_BSD_License.txt} +0 -0
  164. /cmdbox/licenses/{LICENSE_typing_extensions_4_14_0_UNKNOWN.txt → LICENSE_typing_extensions_4_14_1_UNKNOWN.txt} +0 -0
  165. /cmdbox/licenses/{LICENSE_zope_event_5_1_Zope_Public_License.txt → LICENSE_zope_event_5_1_1_Zope_Public_License.txt} +0 -0
  166. {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info}/entry_points.txt +0 -0
  167. {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info/licenses}/LICENSE +0 -0
  168. {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info}/top_level.txt +0 -0
cmdbox/app/mcp.py CHANGED
@@ -49,21 +49,21 @@ class Mcp:
49
49
  Any: FastMCP
50
50
  """
51
51
  from fastmcp import FastMCP
52
- from fastmcp.server.auth import BearerAuthProvider
52
+ from fastmcp.server.auth.providers.jwt import JWTVerifier
53
53
  cls = self.signin.__class__
54
54
  publickey_str = cls.verify_jwt_publickey_str if hasattr(cls, 'verify_jwt_publickey_str') else None
55
55
  issuer = cls.verify_jwt_issuer if hasattr(cls, 'verify_jwt_issuer') else None
56
56
  audience = cls.verify_jwt_audience if hasattr(cls, 'verify_jwt_audience') else None
57
57
  if publickey_str is not None and issuer is not None and audience is not None:
58
- self.logger.info(f"Using BearerAuthProvider with public key, issuer: {issuer}, audience: {audience}")
59
- auth = BearerAuthProvider(
58
+ self.logger.info(f"Using JWTVerifier with public key, issuer: {issuer}, audience: {audience}")
59
+ auth = JWTVerifier(
60
60
  public_key=publickey_str,
61
61
  issuer=issuer,
62
62
  audience=audience
63
63
  )
64
64
  mcp = FastMCP(name=self.ver.__appid__, auth=auth, tools=tools)
65
65
  else:
66
- self.logger.info(f"Using BearerAuthProvider without public key, issuer, or audience.")
66
+ self.logger.info(f"Using JWTVerifier without public key, issuer, or audience.")
67
67
  mcp = FastMCP(name=self.ver.__appid__)
68
68
  mcp.add_middleware(self.create_mw_logging(self.logger, args))
69
69
  mcp.add_middleware(self.create_mw_reqscope(self.logger, args))
@@ -81,8 +81,9 @@ class Mcp:
81
81
  """
82
82
  from google.adk.events import Event
83
83
  from google.adk.sessions import DatabaseSessionService, InMemorySessionService, session
84
- from typing_extensions import override
84
+ #from typing_extensions import override
85
85
  if hasattr(args, 'agent_session_dburl') and args.agent_session_dburl is not None:
86
+ """
86
87
  class _DatabaseSessionService(DatabaseSessionService):
87
88
  @override
88
89
  async def append_event(self, session: session.Session, event: Event) -> Event:
@@ -98,6 +99,8 @@ class Mcp:
98
99
  ret.content.parts = bk_parts
99
100
  return ret
100
101
  dss = _DatabaseSessionService(db_url=args.agent_session_dburl)
102
+ """
103
+ dss = DatabaseSessionService(db_url=args.agent_session_dburl)
101
104
  #dss.db_engine.echo = True
102
105
  return dss
103
106
  else:
@@ -328,6 +331,9 @@ class Mcp:
328
331
  func_txt += f' Dict[str, Any]: 実行結果\n'
329
332
  func_txt += f' """\n'
330
333
  func_txt += f' logger = logging.getLogger("web")\n'
334
+ func_txt += f' if not options.get_cmd_attr("'+mode+'", "'+cmd+'", "use_agent"):\n'
335
+ func_txt += f' logger.warning("{func_name} is not allowed to be executed by the system.")\n'
336
+ func_txt += f' return dict(warn="{func_name} is not allowed to be executed by the system.")\n'
331
337
  func_txt += ' opt = {o["opt"]: kwargs.get(o["opt"], o["default"]) for o in options.get_cmd_choices("'+mode+'", "'+cmd+'", False)}\n'
332
338
  func_txt += f' opt["data"] = Path(opt["data"]) if hasattr(opt, "data") else common.HOME_DIR / f".{self.ver.__appid__}"\n'
333
339
  func_txt += f' if "{title}":\n'
@@ -379,7 +385,7 @@ class Mcp:
379
385
  Returns:
380
386
  ToolList: ToolListのリスト
381
387
  """
382
- tool_list = ToolList(self, logger)
388
+ tool_list = ToolList(self, logger, self.data)
383
389
  tool_list.extract_callable = extract_callable
384
390
  return tool_list
385
391
 
@@ -461,13 +467,14 @@ class Mcp:
461
467
  return runner, mcp
462
468
 
463
469
  class ToolList(object):
464
- def __init__(self, mcp:Mcp, logger:logging.Logger, *args:List):
470
+ def __init__(self, mcp:Mcp, logger:logging.Logger, data:Path, *args:List):
465
471
  """
466
472
  ツールリストを初期化します
467
473
 
468
474
  Args:
469
475
  mcp (Mcp): MCPインスタンス
470
476
  logger (logging.Logger): ロガー
477
+ data (Path): データパス
471
478
  *args (List): 追加するツールのリスト
472
479
  """
473
480
  from fastmcp.tools import FunctionTool
@@ -477,6 +484,7 @@ class ToolList(object):
477
484
  self.tools = []
478
485
  self.mcp = mcp
479
486
  self.logger = logger
487
+ self.data = data
480
488
  self.extract_callable = False
481
489
  for mode in options.get_mode_keys():
482
490
  for cmd in options.get_cmd_keys(mode):
@@ -602,7 +610,7 @@ class ToolList(object):
602
610
  options = Options.getInstance()
603
611
  is_japan = common.is_japan()
604
612
  ret_tools = self.tools.copy()
605
- web = Web.getInstance()
613
+ web = Web.getInstance(self.logger, self.data)
606
614
  if web.signin.signin_file_data is None:
607
615
  # サインインファイルが読み込まれていない場合は登録済みのリストを返す
608
616
  if self.extract_callable:
@@ -633,6 +641,9 @@ class ToolList(object):
633
641
  for opt in cmd_list:
634
642
  func_name = opt['title']
635
643
  mode, cmd, description = opt['mode'], opt['cmd'], opt['description'] if 'description' in opt and opt['description'] else ''
644
+ # ユーザーコマンドもfeatures.ymlの定義に従って実行許可するかどうか。
645
+ #if not options.get_cmd_attr(mode, cmd, 'use_agent'):
646
+ # continue
636
647
  choices = options.get_cmd_choices(mode, cmd, False)
637
648
  description += '\n' + options.get_cmd_attr(mode, cmd, 'description_ja' if is_japan else 'description_en')
638
649
  # 関数の定義を生成
cmdbox/app/options.py CHANGED
@@ -8,10 +8,8 @@ from starlette.routing import Route
8
8
  from typing import List, Dict, Any
9
9
  import argparse
10
10
  import functools
11
- import locale
12
11
  import logging
13
12
  import re
14
- import time
15
13
  import uuid
16
14
 
17
15
 
@@ -179,8 +177,7 @@ class Options:
179
177
  opt['action'] = 'append' if val['multi'] else None
180
178
  o = [f'-{val["short"]}'] if "short" in val else []
181
179
  o += [f'--{key}']
182
- language, _ = locale.getlocale()
183
- opt['help'] = val['description_en'] if language.find('Japan') < 0 and language.find('ja_JP') < 0 else val['description_ja']
180
+ opt['help'] = val['description_en'] if not common.is_japan() else val['description_ja']
184
181
  opt['default'] = val['default']
185
182
  if val['multi'] and val['default'] is not None:
186
183
  raise ValueError(f'list_options: The default value must be None if multi is True. key={key}, val={val}')
@@ -300,6 +297,11 @@ class Options:
300
297
  description_ja="このコマンド登録の説明文を指定します。Agentがこのコマンドの用途を理解するのに使用します。",
301
298
  description_en="Specifies a description of this command registration, used to help the Agent understand the use of this command.",
302
299
  choice=None)
300
+ self._options["logsv"] = dict(
301
+ type=Options.T_BOOL, default=False, required=False, multi=False, hide=True,
302
+ description_ja="logsvを有効にします。logsvは複数のプロセスがログファイルへの書き込みを同期するための機能です。すでにlogsvが有効なプロセスがある場合は無視されます。",
303
+ description_en="Enables logsv. Logsv is a feature that synchronizes log file writing among multiple processes. If there is already an active process with logsv enabled, it will be ignored.",
304
+ choice=[False, True])
303
305
 
304
306
  def init_debugoption(self):
305
307
  # デバックオプションを追加
@@ -368,20 +370,7 @@ class Options:
368
370
  """
369
371
  return ftype in self.features_loaded and self.features_loaded[ftype]
370
372
 
371
- def load_features_file(self, ftype:str, func, appcls, ver, logger:logging.Logger=None):
372
- """
373
- フィーチャーファイル(features.yml)を読み込みます。
374
-
375
- Args:
376
- ftype (str): フィーチャータイプ。cli又はweb
377
- func (Any): フィーチャーの処理関数
378
- appcls (Any): アプリケーションクラス
379
- ver (Any): バージョンモジュール
380
- logger (logging.Logger): ロガー
381
- """
382
- # 読込み済みかどうかの判定
383
- if self.is_features_loaded(ftype):
384
- return
373
+ def _load_features_yml(self, ver, logger:logging.Logger=None):
385
374
  # cmdboxを拡張したアプリをカスタマイズするときのfeatures.ymlを読み込む
386
375
  features_yml = Path(f'.{ver.__appid__}/features.yml')
387
376
  if not features_yml.exists() or not features_yml.is_file():
@@ -398,35 +387,51 @@ class Options:
398
387
  logger.debug(f"features.yml data: {yml}")
399
388
  else:
400
389
  yml = self.features_yml_data
401
- if yml is None: return
402
- if 'features' not in yml:
403
- raise Exception('features.yml is invalid. (The root element must be "features".)')
404
- if ftype not in yml['features']:
405
- raise Exception(f'features.yml is invalid. (There is no “{ftype}” in the “features” element.)')
406
- if yml['features'][ftype] is None:
407
- return
408
- if type(yml['features'][ftype]) is not list:
409
- raise Exception(f'features.yml is invalid. (The “features.{ftype} element must be a list. {ftype}={yml["features"][ftype]})')
410
- # featureモジュール読込みの前にagentruleの読み込み
411
- self.load_features_agentrule(logger)
412
- for data in yml['features'][ftype]:
413
- if type(data) is not dict:
414
- raise Exception(f'features.yml is invalid. (The “features.{ftype}” element must be a list element must be a dictionary. data={data})')
415
- if 'package' not in data:
416
- raise Exception(f'features.yml is invalid. (The “package” element must be in the dictionary of the list element of the “features.{ftype}” element. data={data})')
417
- if 'prefix' not in data:
418
- raise Exception(f'features.yml is invalid. (The prefix element must be in the dictionary of the list element of the “features.{ftype}” element. data={data})')
419
- if data['package'] is None or data['package'] == "":
420
- continue
421
- if data['prefix'] is None or data['prefix'] == "":
422
- continue
423
- exclude_modules = []
424
- if 'exclude_modules' in data:
425
- if type(data['exclude_modules']) is not list:
426
- raise Exception(f'features.yml is invalid. (The “exclude_modules” element must be a list element. data={data})')
427
- exclude_modules = data['exclude_modules']
428
- func(data['package'], data['prefix'], exclude_modules, appcls, ver, logger, self.is_features_loaded(ftype))
429
- self.features_loaded[ftype] = True
390
+ return yml
391
+ return None
392
+
393
+ def load_features_file(self, ftype:str, func, appcls, ver, logger:logging.Logger=None):
394
+ """
395
+ フィーチャーファイル(features.yml)を読み込みます。
396
+
397
+ Args:
398
+ ftype (str): フィーチャータイプ。cli又はweb
399
+ func (Any): フィーチャーの処理関数
400
+ appcls (Any): アプリケーションクラス
401
+ ver (Any): バージョンモジュール
402
+ logger (logging.Logger): ロガー
403
+ """
404
+ # 読込み済みかどうかの判定
405
+ if self.is_features_loaded(ftype):
406
+ return
407
+ yml = self._load_features_yml(ver, logger)
408
+ if yml is None: return
409
+ if 'features' not in yml:
410
+ raise Exception('features.yml is invalid. (The root element must be "features".)')
411
+ if ftype not in yml['features']:
412
+ raise Exception(f'features.yml is invalid. (There is no “{ftype}” in the “features” element.)')
413
+ if yml['features'][ftype] is None:
414
+ return
415
+ if type(yml['features'][ftype]) is not list:
416
+ raise Exception(f'features.yml is invalid. (The “features.{ftype} element must be a list. {ftype}={yml["features"][ftype]})')
417
+ for data in yml['features'][ftype]:
418
+ if type(data) is not dict:
419
+ raise Exception(f'features.yml is invalid. (The “features.{ftype}” element must be a list element must be a dictionary. data={data})')
420
+ if 'package' not in data:
421
+ raise Exception(f'features.yml is invalid. (The “package” element must be in the dictionary of the list element of the “features.{ftype}” element. data={data})')
422
+ if 'prefix' not in data:
423
+ raise Exception(f'features.yml is invalid. (The prefix element must be in the dictionary of the list element of the “features.{ftype}” element. data={data})')
424
+ if data['package'] is None or data['package'] == "":
425
+ continue
426
+ if data['prefix'] is None or data['prefix'] == "":
427
+ continue
428
+ exclude_modules = []
429
+ if 'exclude_modules' in data:
430
+ if type(data['exclude_modules']) is not list:
431
+ raise Exception(f'features.yml is invalid. (The “exclude_modules” element must be a list element. data={data})')
432
+ exclude_modules = data['exclude_modules']
433
+ func(data['package'], data['prefix'], exclude_modules, appcls, ver, logger, self.is_features_loaded(ftype))
434
+ self.features_loaded[ftype] = True
430
435
 
431
436
 
432
437
  def load_features_args(self, args_dict:Dict[str, Any]):