agentengine-sdk-python 0.7.0__py3-none-any.whl → 0.8.0__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.
- {agentengine_sdk_python-0.7.0.dist-info → agentengine_sdk_python-0.8.0.dist-info}/METADATA +36 -20
- agentengine_sdk_python-0.8.0.dist-info/RECORD +578 -0
- ksadk/a2a/__init__.py +178 -11
- ksadk/a2a/bootstrap.py +334 -0
- ksadk/a2a/card.py +120 -0
- ksadk/a2a/context_store.py +203 -0
- ksadk/a2a/control_plane.py +818 -0
- ksadk/a2a/credential.py +99 -0
- ksadk/a2a/event_adapter.py +149 -0
- ksadk/a2a/executor.py +406 -89
- ksadk/a2a/external_transport.py +516 -0
- ksadk/a2a/identity.py +304 -0
- ksadk/a2a/ids.py +22 -0
- ksadk/a2a/langgraph.py +285 -0
- ksadk/a2a/resume_store.py +201 -0
- ksadk/a2a/routes.py +105 -0
- ksadk/a2a/server.py +107 -60
- ksadk/a2a/space_client.py +1101 -0
- ksadk/a2a/task_adapter.py +423 -0
- ksadk/a2a/task_event_dispatcher.py +167 -0
- ksadk/a2a/task_event_outbox.py +326 -0
- ksadk/a2a/task_store.py +206 -0
- ksadk/a2ui/__init__.py +27 -0
- ksadk/a2ui/core.py +186 -0
- ksadk/a2ui/models.py +166 -0
- ksadk/a2ui/renderer.py +198 -0
- ksadk/agui/__init__.py +9 -0
- ksadk/agui/a2ui_projection.py +92 -0
- ksadk/agui/agent.py +857 -0
- ksadk/agui/config.py +86 -0
- ksadk/agui/routes.py +55 -0
- ksadk/api/client.py +233 -191
- ksadk/builders/__init__.py +2 -0
- ksadk/builders/base.py +16 -14
- ksadk/builders/code_builder.py +318 -236
- ksadk/builders/container_builder.py +187 -167
- ksadk/builders/framework_requirements.py +29 -11
- ksadk/builders/ks3_uploader.py +58 -27
- ksadk/builders/managed_runtime_builder.py +145 -0
- ksadk/builders/mcp_builder.py +91 -92
- ksadk/builders/requirements_utils.py +1 -5
- ksadk/cli/__init__.py +89 -171
- ksadk/cli/cmd_a2a.py +254 -70
- ksadk/cli/cmd_agent.py +19 -5
- ksadk/cli/cmd_build.py +158 -29
- ksadk/cli/cmd_completion.py +47 -35
- ksadk/cli/cmd_config.py +267 -198
- ksadk/cli/cmd_create.py +500 -720
- ksadk/cli/cmd_dashboard.py +120 -45
- ksadk/cli/cmd_deploy.py +117 -58
- ksadk/cli/cmd_destroy.py +44 -14
- ksadk/cli/cmd_files.py +63 -24
- ksadk/cli/cmd_hermes.py +168 -89
- ksadk/cli/cmd_invoke.py +184 -122
- ksadk/cli/cmd_launch.py +64 -28
- ksadk/cli/cmd_mcp.py +98 -64
- ksadk/cli/cmd_model.py +14 -5
- ksadk/cli/cmd_openclaw.py +483 -227
- ksadk/cli/cmd_replay.py +71 -0
- ksadk/cli/cmd_run.py +33 -10
- ksadk/cli/cmd_status.py +80 -31
- ksadk/cli/cmd_version.py +20 -13
- ksadk/cli/cmd_web.py +89 -13
- ksadk/cli/deploy_utils.py +20 -20
- ksadk/cli/dry_run.py +5 -3
- ksadk/cli/error_utils.py +37 -12
- ksadk/cli/global_options.py +1 -2
- ksadk/cli/local_runtime.py +1 -2
- ksadk/cli/model_catalog.py +6 -2
- ksadk/cli/network_options.py +34 -14
- ksadk/cli/resource_common.py +6 -2
- ksadk/cli/storage.py +0 -1
- ksadk/cli/ui.py +5 -3
- ksadk/cli/workflow_common.py +51 -17
- ksadk/codex/__init__.py +12 -0
- ksadk/codex/client.py +408 -0
- ksadk/codex/phase.py +143 -0
- ksadk/codex/runtime.py +449 -0
- ksadk/common/aicp_env.py +0 -1
- ksadk/common/auth.py +2 -2
- ksadk/common/constants.py +1 -3
- ksadk/common/llm_utils.py +17 -13
- ksadk/compat/__init__.py +5 -0
- ksadk/compat/adk_compat.py +200 -0
- ksadk/compat/copilotkit_a2ui.py +330 -0
- ksadk/configs/__init__.py +12 -12
- ksadk/configs/env_registry.py +500 -100
- ksadk/configs/global_config.py +2 -1
- ksadk/configs/settings.py +151 -124
- ksadk/conversations/__init__.py +7 -5
- ksadk/conversations/attachment_storage.py +16 -11
- ksadk/conversations/attachments.py +44 -36
- ksadk/conversations/compaction_pipeline.py +12 -12
- ksadk/conversations/compaction_prompt.py +9 -5
- ksadk/conversations/context.py +221 -6
- ksadk/conversations/message_projection.py +438 -51
- ksadk/conversations/model_context.py +12 -6
- ksadk/conversations/model_options.py +0 -1
- ksadk/conversations/normalize.py +20 -16
- ksadk/conversations/reasoning_markup.py +1 -1
- ksadk/conversations/runtime.py +339 -5255
- ksadk/conversations/runtime_compaction.py +333 -0
- ksadk/conversations/runtime_constants.py +27 -0
- ksadk/conversations/runtime_governance.py +185 -0
- ksadk/conversations/runtime_input.py +652 -0
- ksadk/conversations/runtime_invocation.py +395 -0
- ksadk/conversations/runtime_metadata.py +475 -0
- ksadk/conversations/runtime_observability.py +355 -0
- ksadk/conversations/runtime_payloads.py +272 -0
- ksadk/conversations/runtime_persistence.py +440 -0
- ksadk/conversations/runtime_preparation.py +418 -0
- ksadk/conversations/runtime_resume.py +816 -0
- ksadk/conversations/runtime_stream_events.py +902 -0
- ksadk/conversations/runtime_streaming.py +547 -0
- ksadk/conversations/semantic_summary.py +17 -5
- ksadk/conversations/session_title.py +6 -3
- ksadk/deployment/__init__.py +15 -16
- ksadk/deployment/agent_access.py +12 -23
- ksadk/deployment/base.py +51 -38
- ksadk/deployment/manager.py +63 -65
- ksadk/deployment/providers/serverless.py +309 -202
- ksadk/deployment/registry.py +38 -32
- ksadk/deployment/state.py +11 -11
- ksadk/deployment/ui_config.py +1 -1
- ksadk/detection/__init__.py +1 -1
- ksadk/detection/detector.py +146 -83
- ksadk/detection/mcp_detector.py +9 -6
- ksadk/events/__init__.py +25 -0
- ksadk/events/parser.py +191 -0
- ksadk/events/replay.py +37 -0
- ksadk/events/runtime_event.py +264 -0
- ksadk/events/store.py +317 -0
- ksadk/harness/__init__.py +34 -0
- ksadk/harness/app.py +278 -0
- ksadk/harness/config.py +181 -0
- ksadk/harness/reasoner.py +105 -0
- ksadk/harness/runner.py +211 -0
- ksadk/harness/sandbox.py +141 -0
- ksadk/harness/tools.py +222 -0
- ksadk/hermes_terminal.py +23 -12
- ksadk/identity/resolver.py +15 -9
- ksadk/ids.py +32 -0
- ksadk/knowledge_base/adk_tool.py +1 -1
- ksadk/knowledge_base/client.py +23 -29
- ksadk/managed_runtime.py +188 -0
- ksadk/markdown.py +5 -2
- ksadk/mcp_runtime/__init__.py +9 -6
- ksadk/memory/__init__.py +1 -1
- ksadk/memory/adk/__init__.py +2 -0
- ksadk/memory/adk/backends/base_ltm_backend.py +2 -6
- ksadk/memory/adk/backends/http_ltm_backend.py +13 -21
- ksadk/memory/adk/backends/inmemory_ltm_backend.py +7 -13
- ksadk/memory/adk/backends/sdk_ltm_backend.py +26 -33
- ksadk/memory/adk/long_term_memory.py +31 -35
- ksadk/memory/adk/resilient_session_service.py +4 -5
- ksadk/memory/adk/short_term_memory.py +12 -21
- ksadk/memory/adk_tool.py +3 -2
- ksadk/memory/backends/base.py +19 -19
- ksadk/memory/backends/memory.py +24 -25
- ksadk/memory/backends/redis.py +31 -30
- ksadk/memory/langchain_tool.py +2 -1
- ksadk/memory/manager.py +52 -47
- ksadk/memory/service.py +10 -8
- ksadk/model_policy.py +15 -7
- ksadk/model_proxy/__init__.py +51 -0
- ksadk/model_proxy/bootstrap.py +80 -0
- ksadk/model_proxy/cache.py +165 -0
- ksadk/model_proxy/config.py +45 -0
- ksadk/model_proxy/demo_webui.py +115 -0
- ksadk/model_proxy/detect.py +145 -0
- ksadk/model_proxy/gate.py +68 -0
- ksadk/model_proxy/namespace.py +173 -0
- ksadk/model_proxy/protocol_proxy.py +22 -0
- ksadk/model_proxy/server.py +300 -0
- ksadk/model_proxy/transform.py +691 -0
- ksadk/openclaw_gateway.py +29 -14
- ksadk/runners/adk_runner.py +345 -120
- ksadk/runners/base_runner.py +46 -29
- ksadk/runners/codex_runner.py +132 -0
- ksadk/runners/deepagents_runner.py +0 -1
- ksadk/runners/factory.py +17 -5
- ksadk/runners/langchain_runner.py +29 -742
- ksadk/runners/langgraph_runner.py +352 -90
- ksadk/runners/patch_langchain.py +16 -16
- ksadk/runners/remote_runner.py +134 -33
- ksadk/runners/usage_accumulator.py +1 -0
- ksadk/runners/utils/langfuse.py +3 -3
- ksadk/runners/utils/loader.py +7 -7
- ksadk/runtime/__init__.py +41 -0
- ksadk/runtime/adapter.py +345 -0
- ksadk/runtime/framework_adapters.py +124 -0
- ksadk/runtime/preprocessing.py +118 -0
- ksadk/runtime/runner_adapter.py +873 -0
- ksadk/runtime_context.py +18 -3
- ksadk/runtime_state.py +0 -1
- ksadk/sandbox/__init__.py +4 -1
- ksadk/sandbox/backends/__init__.py +4 -1
- ksadk/sandbox/backends/e2b.py +13 -5
- ksadk/sandbox/backends/local_process.py +11 -3
- ksadk/sandbox/base.py +10 -15
- ksadk/sandbox/factory.py +14 -4
- ksadk/sandbox/registry.py +57 -6
- ksadk/server/api_models.py +15 -5
- ksadk/server/app.py +455 -3885
- ksadk/server/composition.py +21 -0
- ksadk/server/factory.py +624 -0
- ksadk/server/routes/__init__.py +1 -0
- ksadk/server/routes/checkpoint_resolution.py +116 -0
- ksadk/server/routes/common.py +713 -0
- ksadk/server/routes/control.py +327 -0
- ksadk/server/routes/dependencies.py +98 -0
- ksadk/server/routes/misc.py +448 -0
- ksadk/server/routes/models.py +443 -0
- ksadk/server/routes/openai_compat.py +207 -0
- ksadk/server/routes/projection.py +795 -0
- ksadk/server/routes/routers.py +52 -0
- ksadk/server/routes/run.py +726 -0
- ksadk/server/routes/sessions.py +649 -0
- ksadk/server/routes/streaming.py +223 -0
- ksadk/server/routes/workspace.py +381 -0
- ksadk/server/static/assets/{ArtifactsPanel-D-SSn2ee.js → ArtifactsPanel-Cjnqt-8W.js} +1 -1
- ksadk/server/static/assets/CodeBlock-BqyqZfuB.js +9 -0
- ksadk/server/static/assets/MathMessageMarkdown-BpH7jiFM.js +8 -0
- ksadk/server/static/assets/MermaidBlock-DWuxETaJ.js +303 -0
- ksadk/server/static/assets/NativeTerminalPanel-MDTopWMO.js +1 -0
- ksadk/server/static/assets/{arc-BA13sHc9.js → arc-CFKwSk_B.js} +1 -1
- ksadk/server/static/assets/architecture-7EHR7CIX-CynqOWjZ.js +1 -0
- ksadk/server/static/assets/{architectureDiagram-3BPJPVTR-DzJzgVoL.js → architectureDiagram-3BPJPVTR-Dej8jX8c.js} +1 -1
- ksadk/server/static/assets/{blockDiagram-GPEHLZMM-UTdVcZhn.js → blockDiagram-GPEHLZMM-1F64jqvy.js} +1 -1
- ksadk/server/static/assets/{c4Diagram-AAUBKEIU-Dix0GD4m.js → c4Diagram-AAUBKEIU-9q7AUAKb.js} +1 -1
- ksadk/server/static/assets/channel-iUGv2N24.js +1 -0
- ksadk/server/static/assets/{chunk-2J33WTMH-C2JxuZ42.js → chunk-2J33WTMH-6qgwJm7Q.js} +1 -1
- ksadk/server/static/assets/{chunk-4BX2VUAB-Be57QPgD.js → chunk-4BX2VUAB-CsWIQRhc.js} +1 -1
- ksadk/server/static/assets/{chunk-55IACEB6-WjSuy4nv.js → chunk-55IACEB6-BK8paA20.js} +1 -1
- ksadk/server/static/assets/{chunk-727SXJPM-BOovP-b5.js → chunk-727SXJPM-B-JEhy7h.js} +1 -1
- ksadk/server/static/assets/{chunk-AQP2D5EJ-DOmZNmWj.js → chunk-AQP2D5EJ-DYBvMHAa.js} +1 -1
- ksadk/server/static/assets/{chunk-FMBD7UC4-DzwlodkU.js → chunk-FMBD7UC4-BGhvzDYt.js} +1 -1
- ksadk/server/static/assets/{chunk-ND2GUHAM-DMqAikEU.js → chunk-ND2GUHAM-D98vPd-E.js} +1 -1
- ksadk/server/static/assets/chunk-QZHKN3VN-YQIEXeF6.js +1 -0
- ksadk/server/static/assets/classDiagram-4FO5ZUOK-CDAUuoXK.js +1 -0
- ksadk/server/static/assets/classDiagram-v2-Q7XG4LA2-CDAUuoXK.js +1 -0
- ksadk/server/static/assets/{cose-bilkent-S5V4N54A-Zhy2GBnP.js → cose-bilkent-S5V4N54A-CX3yotHq.js} +1 -1
- ksadk/server/static/assets/{dagre-BM42HDAG-CbKrtIUz.js → dagre-BM42HDAG-C7TguAWo.js} +1 -1
- ksadk/server/static/assets/{diagram-2AECGRRQ-BRApgQRK.js → diagram-2AECGRRQ-Dd17_kws.js} +1 -1
- ksadk/server/static/assets/{diagram-5GNKFQAL-D0xbnDiK.js → diagram-5GNKFQAL-DVIClIil.js} +1 -1
- ksadk/server/static/assets/{diagram-KO2AKTUF-CVugVI9L.js → diagram-KO2AKTUF-Df_3gYQa.js} +1 -1
- ksadk/server/static/assets/{diagram-LMA3HP47-DozUGgee.js → diagram-LMA3HP47-BhLk6ZtA.js} +1 -1
- ksadk/server/static/assets/{diagram-OG6HWLK6-ZOYsKlru.js → diagram-OG6HWLK6-D4GNGvuu.js} +1 -1
- ksadk/server/static/assets/{dist-DmFaq_Iy.js → dist-6CVKuTAe.js} +1 -1
- ksadk/server/static/assets/{dist-8EEyGgDx.js → dist-BUHRxvDG.js} +1 -1
- ksadk/server/static/assets/{dist-B0NP_Z0z.js → dist-BZ9n9AjO.js} +1 -1
- ksadk/server/static/assets/{dist-DMezvBGJ.js → dist-BibcG1V9.js} +1 -1
- ksadk/server/static/assets/{dist-C3HIIaN5.js → dist-Bs-jQcRX.js} +1 -1
- ksadk/server/static/assets/{dist-BrCcQ47T.js → dist-C2xjE7cO.js} +1 -1
- ksadk/server/static/assets/{dist-Dp0k7bWI.js → dist-C7-3jInC.js} +1 -1
- ksadk/server/static/assets/{dist-D-xOD048.js → dist-C99THtIA.js} +1 -1
- ksadk/server/static/assets/{dist-CkEKJFtk.js → dist-CGcp2ex8.js} +1 -1
- ksadk/server/static/assets/{dist-DyOkZmze.js → dist-CVQRZjPu.js} +1 -1
- ksadk/server/static/assets/{dist-BssVmjIo.js → dist-Cf23NY4L.js} +1 -1
- ksadk/server/static/assets/{dist-BIJVDMuB.js → dist-CgF3fj15.js} +1 -1
- ksadk/server/static/assets/{dist-2hInLS_J.js → dist-Cwt7koer.js} +1 -1
- ksadk/server/static/assets/{dist-DyWsb78Q.js → dist-D82mtD2s.js} +1 -1
- ksadk/server/static/assets/{dist-D-JMdWPQ.js → dist-DF06ORQo.js} +1 -1
- ksadk/server/static/assets/{dist-BmlMPsCc.js → dist-DHn6nBzr.js} +1 -1
- ksadk/server/static/assets/{dist-gX6GOLKq.js → dist-Djgl2wVZ.js} +1 -1
- ksadk/server/static/assets/{dist-DpKtt4Bo.js → dist-DlzCRy0S.js} +1 -1
- ksadk/server/static/assets/{dist-8_SfK1IP.js → dist-DqNnNFrw.js} +1 -1
- ksadk/server/static/assets/{dist-D57wnGWd.js → dist-DyvYLMW9.js} +1 -1
- ksadk/server/static/assets/{dist-CPBtqRTW.js → dist-eoW6tZXA.js} +1 -1
- ksadk/server/static/assets/{dist-DL_NKc_z.js → dist-ivOya1LD.js} +1 -1
- ksadk/server/static/assets/{erDiagram-TEJ5UH35-Bk-9bgE5.js → erDiagram-TEJ5UH35-CnfRcY2M.js} +1 -1
- ksadk/server/static/assets/eventmodeling-FCH6USID-ChYO-ijM.js +1 -0
- ksadk/server/static/assets/{flowDiagram-I6XJVG4X-Dn9kZVuZ.js → flowDiagram-I6XJVG4X-DGaJjGNJ.js} +1 -1
- ksadk/server/static/assets/{ganttDiagram-6RSMTGT7-BGxXlJqm.js → ganttDiagram-6RSMTGT7-DpCoB2g9.js} +1 -1
- ksadk/server/static/assets/gitGraph-WXDBUCRP-BN_0Fk-j.js +1 -0
- ksadk/server/static/assets/{gitGraphDiagram-PVQCEYII-C7Q0X-wi.js → gitGraphDiagram-PVQCEYII-9IKVFBVT.js} +1 -1
- ksadk/server/static/assets/index-QSwCHuB8.js +177 -0
- ksadk/server/static/assets/index-jOPmTOZH.css +2 -0
- ksadk/server/static/assets/info-J43DQDTF-Cp6o3vId.js +1 -0
- ksadk/server/static/assets/{infoDiagram-5YYISTIA-BO_CSqq5.js → infoDiagram-5YYISTIA-CYIIsb8y.js} +1 -1
- ksadk/server/static/assets/{ishikawaDiagram-YF4QCWOH-eYLPLd46.js → ishikawaDiagram-YF4QCWOH-DLOHGvWw.js} +1 -1
- ksadk/server/static/assets/{journeyDiagram-JHISSGLW-De9geSb0.js → journeyDiagram-JHISSGLW-BIzKeejT.js} +1 -1
- ksadk/server/static/assets/{kanban-definition-UN3LZRKU-Cs80kQto.js → kanban-definition-UN3LZRKU-BWHoFSw2.js} +1 -1
- ksadk/server/static/assets/{katex-DSrCFD8n.js → katex-DATssjp1.js} +1 -1
- ksadk/server/static/assets/{linear-CN9sbKTF.js → linear-CvMBw9cA.js} +1 -1
- ksadk/server/static/assets/{mermaid-parser.core-DlgSBU8l.js → mermaid-parser.core-mGAcEwcq.js} +2 -2
- ksadk/server/static/assets/{mindmap-definition-RKZ34NQL-9afz7Oug.js → mindmap-definition-RKZ34NQL-CSAQxEAe.js} +1 -1
- ksadk/server/static/assets/packet-YPE3B663-wQzct3cT.js +1 -0
- ksadk/server/static/assets/pie-LRSECV5Y-BgTQiv-9.js +1 -0
- ksadk/server/static/assets/{pieDiagram-4H26LBE5-DPv_VstN.js → pieDiagram-4H26LBE5-By-ra07M.js} +1 -1
- ksadk/server/static/assets/{quadrantDiagram-W4KKPZXB-o77wZ1XK.js → quadrantDiagram-W4KKPZXB-CxIR4JXI.js} +1 -1
- ksadk/server/static/assets/radar-GUYGQ44K-BIq5fXsn.js +1 -0
- ksadk/server/static/assets/{requirementDiagram-4Y6WPE33-BYVw81VC.js → requirementDiagram-4Y6WPE33-DpW90iu3.js} +1 -1
- ksadk/server/static/assets/{sankeyDiagram-5OEKKPKP-B7nZFMKT.js → sankeyDiagram-5OEKKPKP-DpGa6EAV.js} +1 -1
- ksadk/server/static/assets/{sequenceDiagram-3UESZ5HK-BGRRrFw5.js → sequenceDiagram-3UESZ5HK-NTKNGGe5.js} +1 -1
- ksadk/server/static/assets/{stateDiagram-AJRCARHV-BUfHCoPs.js → stateDiagram-AJRCARHV-DGpd9yFG.js} +1 -1
- ksadk/server/static/assets/stateDiagram-v2-BHNVJYJU-B3o579IQ.js +1 -0
- ksadk/server/static/assets/{timeline-definition-PNZ67QCA-FbCTGrf9.js → timeline-definition-PNZ67QCA-jqoYs3jQ.js} +1 -1
- ksadk/server/static/assets/treeView-BLDUP644-Dqi-E0EM.js +1 -0
- ksadk/server/static/assets/treemap-LRROVOQU-ClQP9CJ9.js +1 -0
- ksadk/server/static/assets/{vennDiagram-CIIHVFJN-DWgwtPsJ.js → vennDiagram-CIIHVFJN-l3Z7-wbP.js} +1 -1
- ksadk/server/static/assets/wardley-L42UT6IY-8XLvnNIs.js +1 -0
- ksadk/server/static/assets/{wardleyDiagram-YWT4CUSO-2x8G-tTM.js → wardleyDiagram-YWT4CUSO-BR54GPmr.js} +1 -1
- ksadk/server/static/assets/{xychartDiagram-2RQKCTM6-Drma3AYl.js → xychartDiagram-2RQKCTM6-SkiH8GsK.js} +1 -1
- ksadk/server/static/index.html +2 -2
- ksadk/server/terminal_sessions.py +111 -58
- ksadk/sessions/__init__.py +69 -19
- ksadk/sessions/base.py +31 -11
- ksadk/sessions/continuity.py +2 -3
- ksadk/sessions/in_memory.py +46 -2
- ksadk/sessions/local_service.py +148 -17
- ksadk/sessions/postgres_service.py +143 -25
- ksadk/sessions/resilient.py +36 -8
- ksadk/skills/models.py +17 -5
- ksadk/skills/package_store.py +5 -2
- ksadk/skills/runtime/agent.py +20 -5
- ksadk/skills/runtime/artifacts.py +1 -5
- ksadk/skills/runtime/backends/e2b.py +10 -4
- ksadk/skills/runtime/backends/local.py +15 -3
- ksadk/skills/runtime/base.py +1 -2
- ksadk/skills/runtime/executor.py +10 -3
- ksadk/skills/runtime/factory.py +4 -2
- ksadk/skills/runtime/loader.py +1 -2
- ksadk/skills/runtime/registry.py +15 -10
- ksadk/skills/runtime/request.py +3 -1
- ksadk/skills/service_client.py +38 -17
- ksadk/skills/tool_defs.py +15 -10
- ksadk/terminal_exec_policy.py +3 -4
- ksadk/tools/gateway.py +92 -15
- ksadk/tools/result_budget.py +12 -4
- ksadk/toolsets/__init__.py +134 -36
- ksadk/toolsets/platform.py +21 -5
- ksadk/toolsets/sandbox.py +82 -16
- ksadk/toolsets/skills.py +200 -39
- ksadk/toolsets/web.py +123 -26
- ksadk/toolsets/workspace.py +212 -101
- ksadk/tracing/exporters/inmemory_exporter.py +62 -51
- ksadk/tracing/exporters/langfuse_exporter.py +91 -76
- ksadk/tracing/setup.py +69 -53
- ksadk/tracing/span_utils.py +5 -2
- ksadk/tui/loop.py +78 -30
- ksadk/tui/stream_render.py +1 -0
- ksadk/ui_config.py +5 -3
- ksadk/version.py +1 -1
- ksadk_runtime_common/schemas/runtime_event_v1.json +95 -0
- agentengine_sdk_python-0.7.0.dist-info/RECORD +0 -482
- ksadk/server/static/assets/CodeBlock-P16VOLYi.js +0 -9
- ksadk/server/static/assets/MathMessageMarkdown-CdGiQWHR.js +0 -8
- ksadk/server/static/assets/MermaidBlock-IOcal8cm.js +0 -303
- ksadk/server/static/assets/NativeTerminalPanel-DGSDWsei.js +0 -1
- ksadk/server/static/assets/architecture-7EHR7CIX-BvUlsA6l.js +0 -1
- ksadk/server/static/assets/channel-CTuydARX.js +0 -1
- ksadk/server/static/assets/chunk-QZHKN3VN-BnCydivS.js +0 -1
- ksadk/server/static/assets/classDiagram-4FO5ZUOK-BNHg45Be.js +0 -1
- ksadk/server/static/assets/classDiagram-v2-Q7XG4LA2-BNHg45Be.js +0 -1
- ksadk/server/static/assets/eventmodeling-FCH6USID-DsAgWnlf.js +0 -1
- ksadk/server/static/assets/gitGraph-WXDBUCRP-BIao9Yjg.js +0 -1
- ksadk/server/static/assets/index-C00Lwg3L.js +0 -165
- ksadk/server/static/assets/index-DAURbCsP.css +0 -1
- ksadk/server/static/assets/info-J43DQDTF-CyipqGxU.js +0 -1
- ksadk/server/static/assets/packet-YPE3B663-CGkyRxlg.js +0 -1
- ksadk/server/static/assets/pie-LRSECV5Y-M0uWAf4n.js +0 -1
- ksadk/server/static/assets/radar-GUYGQ44K-Bdbm24-x.js +0 -1
- ksadk/server/static/assets/stateDiagram-v2-BHNVJYJU-8xBN_gLM.js +0 -1
- ksadk/server/static/assets/treeView-BLDUP644-npMo0ak1.js +0 -1
- ksadk/server/static/assets/treemap-LRROVOQU-CHdzrrdo.js +0 -1
- ksadk/server/static/assets/wardley-L42UT6IY-BEQz7wyy.js +0 -1
- {agentengine_sdk_python-0.7.0.dist-info → agentengine_sdk_python-0.8.0.dist-info}/WHEEL +0 -0
- {agentengine_sdk_python-0.7.0.dist-info → agentengine_sdk_python-0.8.0.dist-info}/entry_points.txt +0 -0
- {agentengine_sdk_python-0.7.0.dist-info → agentengine_sdk_python-0.8.0.dist-info}/licenses/LICENSE +0 -0
- {agentengine_sdk_python-0.7.0.dist-info → agentengine_sdk_python-0.8.0.dist-info}/top_level.txt +0 -0
ksadk/cli/cmd_config.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from pathlib import Path
|
|
3
1
|
import re
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
4
5
|
import click
|
|
5
|
-
from dotenv import dotenv_values
|
|
6
6
|
import questionary
|
|
7
|
-
from questionary import Style
|
|
8
7
|
import yaml
|
|
8
|
+
from dotenv import dotenv_values
|
|
9
|
+
from questionary import Style
|
|
9
10
|
|
|
10
11
|
from ksadk.cli.error_utils import (
|
|
11
12
|
abort_with_cli_error,
|
|
@@ -19,8 +20,6 @@ from ksadk.cli.ui import (
|
|
|
19
20
|
is_color_disabled,
|
|
20
21
|
is_json_output,
|
|
21
22
|
is_stdout_tty,
|
|
22
|
-
output_option as cli_output_option,
|
|
23
|
-
print_error,
|
|
24
23
|
print_info,
|
|
25
24
|
print_kv,
|
|
26
25
|
print_rule,
|
|
@@ -28,20 +27,25 @@ from ksadk.cli.ui import (
|
|
|
28
27
|
print_title,
|
|
29
28
|
print_warn,
|
|
30
29
|
)
|
|
30
|
+
from ksadk.cli.ui import (
|
|
31
|
+
output_option as cli_output_option,
|
|
32
|
+
)
|
|
31
33
|
|
|
32
34
|
# 自定义样式,确保选中项高亮可见
|
|
33
|
-
custom_style = Style(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
custom_style = Style(
|
|
36
|
+
[
|
|
37
|
+
("qmark", "fg:#5f819d bold"), # 略深一点的蓝青色
|
|
38
|
+
("question", "bold"),
|
|
39
|
+
("answer", "fg:#69f0ae bold"), # 浅绿色 (替代深红)
|
|
40
|
+
("pointer", "fg:#fbc02d bold"), # 略深的金色/暗黄色
|
|
41
|
+
("highlighted", "fg:#fbc02d bold"), # 同上
|
|
42
|
+
("selected", "fg:#69f0ae"), # 浅绿色
|
|
43
|
+
("separator", "fg:#69f0ae"), # 浅绿色
|
|
44
|
+
("instruction", ""),
|
|
45
|
+
("text", ""),
|
|
46
|
+
("disabled", "fg:#858585 italic"),
|
|
47
|
+
]
|
|
48
|
+
)
|
|
45
49
|
|
|
46
50
|
|
|
47
51
|
def _questionary_style():
|
|
@@ -83,13 +87,13 @@ def _update_env_file(path: Path, updates: dict):
|
|
|
83
87
|
for line in lines:
|
|
84
88
|
stripped = line.strip()
|
|
85
89
|
# Skip comments and empty lines
|
|
86
|
-
if not stripped or stripped.startswith(
|
|
90
|
+
if not stripped or stripped.startswith("#"):
|
|
87
91
|
new_lines.append(line)
|
|
88
92
|
continue
|
|
89
|
-
|
|
93
|
+
|
|
90
94
|
# Parse key=value
|
|
91
|
-
if
|
|
92
|
-
key = stripped.split(
|
|
95
|
+
if "=" in stripped:
|
|
96
|
+
key = stripped.split("=", 1)[0].strip()
|
|
93
97
|
if key in updates:
|
|
94
98
|
new_lines.append(f"{key}={updates[key]}")
|
|
95
99
|
updated_keys.add(key)
|
|
@@ -104,7 +108,7 @@ def _update_env_file(path: Path, updates: dict):
|
|
|
104
108
|
if key not in updated_keys and value:
|
|
105
109
|
# Add a newline before new keys if the file wasn't empty and didn't end with one
|
|
106
110
|
if not added_new and lines and lines[-1].strip():
|
|
107
|
-
new_lines.append("")
|
|
111
|
+
new_lines.append("")
|
|
108
112
|
new_lines.append(f"{key}={value}")
|
|
109
113
|
added_new = True
|
|
110
114
|
|
|
@@ -172,7 +176,9 @@ def _parse_set_items(set_items: tuple) -> tuple[dict, dict, list[str]]:
|
|
|
172
176
|
return updates_yaml, updates_env, invalid_items
|
|
173
177
|
|
|
174
178
|
|
|
175
|
-
def _apply_set_command(
|
|
179
|
+
def _apply_set_command(
|
|
180
|
+
set_items: tuple, output_path: Path, env_path: Path, is_global: bool
|
|
181
|
+
) -> dict:
|
|
176
182
|
"""Apply non-interactive config mutations and return a structured summary."""
|
|
177
183
|
updates_yaml, updates_env, invalid_items = _parse_set_items(set_items)
|
|
178
184
|
if not updates_yaml and not updates_env and invalid_items:
|
|
@@ -206,11 +212,11 @@ def _apply_set_command(set_items: tuple, output_path: Path, env_path: Path, is_g
|
|
|
206
212
|
if is_global:
|
|
207
213
|
from ksadk.configs.global_config import (
|
|
208
214
|
build_global_config_from_env,
|
|
209
|
-
|
|
215
|
+
get_env_from_global_config,
|
|
216
|
+
get_global_config_path,
|
|
217
|
+
save_global_config,
|
|
210
218
|
)
|
|
211
219
|
|
|
212
|
-
from ksadk.configs.global_config import get_env_from_global_config, save_global_config
|
|
213
|
-
|
|
214
220
|
current_global_env = get_env_from_global_config()
|
|
215
221
|
current_global_env.update(updates_env)
|
|
216
222
|
if "region" in updates_yaml and "KSYUN_REGION" not in current_global_env:
|
|
@@ -223,7 +229,11 @@ def _apply_set_command(set_items: tuple, output_path: Path, env_path: Path, is_g
|
|
|
223
229
|
|
|
224
230
|
|
|
225
231
|
def _collect_config_snapshot(output_path: Path, env_path: Path) -> dict:
|
|
226
|
-
from ksadk.configs.global_config import
|
|
232
|
+
from ksadk.configs.global_config import (
|
|
233
|
+
get_env_from_global_config,
|
|
234
|
+
get_global_config_path,
|
|
235
|
+
load_global_config,
|
|
236
|
+
)
|
|
227
237
|
|
|
228
238
|
project_config = _load_yaml_file(output_path)
|
|
229
239
|
project_env = {k: v for k, v in _load_env_file(env_path).items() if v not in (None, "")}
|
|
@@ -307,7 +317,9 @@ def _render_config_set_result_pretty(result: dict) -> None:
|
|
|
307
317
|
print_kv("全局配置", result["global_config_path"] or "~/.agentengine/settings.json")
|
|
308
318
|
|
|
309
319
|
|
|
310
|
-
def _run_config_set_command(
|
|
320
|
+
def _run_config_set_command(
|
|
321
|
+
*, set_items: tuple, output_path: Path, env_path: Path, is_global: bool
|
|
322
|
+
) -> dict:
|
|
311
323
|
if not set_items:
|
|
312
324
|
raise usage_error(
|
|
313
325
|
"请至少提供一个 KEY=VALUE 配置项。",
|
|
@@ -315,14 +327,15 @@ def _run_config_set_command(*, set_items: tuple, output_path: Path, env_path: Pa
|
|
|
315
327
|
)
|
|
316
328
|
return _apply_set_command(set_items, output_path, env_path, is_global)
|
|
317
329
|
|
|
330
|
+
|
|
318
331
|
def run_config_wizard(config_file: str | None, set_items: tuple, is_global: bool):
|
|
319
332
|
"""通过交互式向导配置 agentengine.yaml 和 .env 文件
|
|
320
|
-
|
|
333
|
+
|
|
321
334
|
支持:
|
|
322
335
|
1. 配置 Agent 基础信息 (名称、框架等)
|
|
323
336
|
2. 配置 模型服务 (API Key, Base URL)
|
|
324
337
|
3. 配置 云厂商凭证 (KSYUN AK/SK)
|
|
325
|
-
|
|
338
|
+
|
|
326
339
|
参数:
|
|
327
340
|
--set: 非交互式设置配置项 (如 --set name=MyAgent --set KSYUN_REGION=cn-beijing-6)
|
|
328
341
|
--global: 强制更新全局配置 (~/.agentengine/settings.json)
|
|
@@ -332,7 +345,10 @@ def run_config_wizard(config_file: str | None, set_items: tuple, is_global: bool
|
|
|
332
345
|
|
|
333
346
|
# === 0. 处理 --set 非交互模式 ===
|
|
334
347
|
if set_items:
|
|
335
|
-
print_warn(
|
|
348
|
+
print_warn(
|
|
349
|
+
"`agentengine config wizard --set ...` 是兼容入口,"
|
|
350
|
+
"推荐改用 `agentengine config set KEY=VALUE ...`。"
|
|
351
|
+
)
|
|
336
352
|
result = _run_config_set_command(
|
|
337
353
|
set_items=set_items,
|
|
338
354
|
output_path=output_path,
|
|
@@ -347,7 +363,10 @@ def run_config_wizard(config_file: str | None, set_items: tuple, is_global: bool
|
|
|
347
363
|
|
|
348
364
|
ensure_json_output_supported(
|
|
349
365
|
"agentengine config wizard",
|
|
350
|
-
suggestion=
|
|
366
|
+
suggestion=(
|
|
367
|
+
"请改用 `agentengine config show --output json` 或 "
|
|
368
|
+
"`agentengine config set KEY=VALUE`。"
|
|
369
|
+
),
|
|
351
370
|
)
|
|
352
371
|
_ensure_interactive_command(
|
|
353
372
|
"agentengine config wizard",
|
|
@@ -359,11 +378,11 @@ def run_config_wizard(config_file: str | None, set_items: tuple, is_global: bool
|
|
|
359
378
|
print_title("AgentEngine 配置向导")
|
|
360
379
|
|
|
361
380
|
# === 1. 加载现有配置 ===
|
|
362
|
-
existing_config = {}
|
|
381
|
+
existing_config: dict[str, Any] = {}
|
|
363
382
|
if output_path.exists():
|
|
364
383
|
try:
|
|
365
384
|
# 使用 utf-8-sig 自动处理 BOM,确保 Windows 兼容性
|
|
366
|
-
with open(output_path,
|
|
385
|
+
with open(output_path, "r", encoding="utf-8-sig") as f:
|
|
367
386
|
existing_config = yaml.safe_load(f) or {}
|
|
368
387
|
print_info(f"检测到现有配置文件: {output_path}")
|
|
369
388
|
except Exception:
|
|
@@ -374,7 +393,7 @@ def run_config_wizard(config_file: str | None, set_items: tuple, is_global: bool
|
|
|
374
393
|
print_info(f"检测到现有环境变量: {env_path}")
|
|
375
394
|
|
|
376
395
|
print_rule()
|
|
377
|
-
|
|
396
|
+
|
|
378
397
|
# Helper to clean code and handle Ctrl+C
|
|
379
398
|
def _ask_or_exit(question):
|
|
380
399
|
result = question.ask()
|
|
@@ -387,175 +406,199 @@ def run_config_wizard(config_file: str | None, set_items: tuple, is_global: bool
|
|
|
387
406
|
|
|
388
407
|
# === 2. 基础配置 (agentengine.yaml) ===
|
|
389
408
|
print_rule("基础配置")
|
|
390
|
-
|
|
409
|
+
|
|
391
410
|
# 智能默认值: 优先读文件 -> 其次用目录名 -> 最后 my-agent
|
|
392
|
-
default_name = existing_config.get(
|
|
411
|
+
default_name = existing_config.get("name")
|
|
393
412
|
if not default_name:
|
|
394
413
|
default_name = Path.cwd().name
|
|
395
|
-
|
|
396
|
-
new_config[
|
|
397
|
-
"Agent 名称:",
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
)
|
|
407
|
-
|
|
408
|
-
frameworks = [
|
|
409
|
-
default_framework = existing_config.get(
|
|
414
|
+
|
|
415
|
+
new_config["name"] = _ask_or_exit(
|
|
416
|
+
questionary.text("Agent 名称:", default=default_name, style=_questionary_style())
|
|
417
|
+
)
|
|
418
|
+
|
|
419
|
+
new_config["description"] = _ask_or_exit(
|
|
420
|
+
questionary.text(
|
|
421
|
+
"Agent 描述:",
|
|
422
|
+
default=existing_config.get("description", ""),
|
|
423
|
+
style=_questionary_style(),
|
|
424
|
+
)
|
|
425
|
+
)
|
|
426
|
+
|
|
427
|
+
frameworks = ["langgraph", "langchain", "deepagents", "adk", "openclaw"]
|
|
428
|
+
default_framework = existing_config.get("framework", "langgraph")
|
|
410
429
|
if default_framework and default_framework not in frameworks:
|
|
411
430
|
frameworks.append(default_framework)
|
|
412
|
-
new_config[
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
431
|
+
new_config["framework"] = _ask_or_exit(
|
|
432
|
+
questionary.select(
|
|
433
|
+
"选择开发框架:",
|
|
434
|
+
choices=frameworks,
|
|
435
|
+
default=default_framework,
|
|
436
|
+
style=_questionary_style(),
|
|
437
|
+
)
|
|
438
|
+
)
|
|
439
|
+
|
|
419
440
|
print_rule()
|
|
420
441
|
|
|
421
442
|
# === 3. 模型配置 (.env) ===
|
|
422
443
|
print_rule("模型配置")
|
|
423
444
|
print_info("配置用于推理的大模型服务 (OpenAI 兼容接口)")
|
|
424
|
-
|
|
445
|
+
|
|
425
446
|
# 向后兼容: 如果是从旧版模板生成的,可能包含 'your-api-key-here' 占位符,视为空
|
|
426
|
-
default_api_key = existing_env.get(
|
|
447
|
+
default_api_key = existing_env.get("OPENAI_API_KEY", "")
|
|
427
448
|
if default_api_key == "your-api-key-here":
|
|
428
449
|
default_api_key = ""
|
|
429
450
|
|
|
430
|
-
new_env[
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
)
|
|
435
|
-
|
|
436
|
-
new_env[
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
451
|
+
new_env["OPENAI_API_KEY"] = _ask_or_exit(
|
|
452
|
+
questionary.password(
|
|
453
|
+
"API Key (OPENAI_API_KEY):", default=default_api_key, style=_questionary_style()
|
|
454
|
+
)
|
|
455
|
+
)
|
|
456
|
+
|
|
457
|
+
new_env["OPENAI_BASE_URL"] = _ask_or_exit(
|
|
458
|
+
questionary.text(
|
|
459
|
+
"Base URL (OPENAI_BASE_URL) [选填,默认使用金山云星流平台URL]:",
|
|
460
|
+
default=existing_env.get("OPENAI_BASE_URL", ""),
|
|
461
|
+
style=_questionary_style(),
|
|
462
|
+
)
|
|
463
|
+
)
|
|
464
|
+
|
|
465
|
+
new_env["OPENAI_MODEL_NAME"] = _ask_or_exit(
|
|
466
|
+
questionary.text(
|
|
467
|
+
"模型名称 (OPENAI_MODEL_NAME) [选填,默认使用金山云星流平台glm-5.2]:",
|
|
468
|
+
default=existing_env.get("OPENAI_MODEL_NAME", ""),
|
|
469
|
+
style=_questionary_style(),
|
|
470
|
+
)
|
|
471
|
+
)
|
|
472
|
+
|
|
448
473
|
print_rule()
|
|
449
474
|
|
|
450
475
|
# === 4. 云厂商配置 (.env) ===
|
|
451
476
|
print_rule("金山云配置 (可选)")
|
|
452
477
|
print_info("用于 agentengine deploy 部署到云端环境")
|
|
453
|
-
|
|
454
|
-
should_config_ksyun = _ask_or_exit(
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
478
|
+
|
|
479
|
+
should_config_ksyun = _ask_or_exit(
|
|
480
|
+
questionary.confirm(
|
|
481
|
+
"是否配置金山云凭证?",
|
|
482
|
+
default=bool(existing_env.get("KSYUN_ACCESS_KEY")),
|
|
483
|
+
style=_questionary_style(),
|
|
484
|
+
)
|
|
485
|
+
)
|
|
459
486
|
|
|
460
487
|
if should_config_ksyun:
|
|
461
|
-
new_env[
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
488
|
+
new_env["KSYUN_ACCESS_KEY"] = _ask_or_exit(
|
|
489
|
+
questionary.password(
|
|
490
|
+
"Access Key (AK):",
|
|
491
|
+
default=existing_env.get("KSYUN_ACCESS_KEY", ""),
|
|
492
|
+
style=_questionary_style(),
|
|
493
|
+
)
|
|
494
|
+
)
|
|
495
|
+
|
|
496
|
+
new_env["KSYUN_SECRET_KEY"] = _ask_or_exit(
|
|
497
|
+
questionary.password(
|
|
498
|
+
"Secret Key (SK):",
|
|
499
|
+
default=existing_env.get("KSYUN_SECRET_KEY", ""),
|
|
500
|
+
style=_questionary_style(),
|
|
501
|
+
)
|
|
502
|
+
)
|
|
503
|
+
|
|
504
|
+
new_env["KSYUN_ACCOUNT_ID"] = _ask_or_exit(
|
|
505
|
+
questionary.text(
|
|
506
|
+
"Account ID (账户ID):",
|
|
507
|
+
default=existing_env.get("KSYUN_ACCOUNT_ID", ""),
|
|
508
|
+
style=_questionary_style(),
|
|
509
|
+
)
|
|
510
|
+
)
|
|
511
|
+
|
|
481
512
|
# 内部默认区域逻辑
|
|
482
|
-
default_region = existing_env.get(
|
|
513
|
+
default_region = existing_env.get("KSYUN_REGION")
|
|
483
514
|
if not default_region:
|
|
484
|
-
default_region = existing_config.get(
|
|
485
|
-
|
|
515
|
+
default_region = existing_config.get("region", "cn-beijing-6")
|
|
516
|
+
|
|
486
517
|
# 标准区域列表
|
|
487
|
-
standard_regions = [
|
|
518
|
+
standard_regions = ["cn-beijing-6", "cn-guangzhou-1"]
|
|
488
519
|
CUSTOM_OPTION = "⚙️ Custom (手动输入,金山云自定义区域请参考文档确认是否支持)"
|
|
489
|
-
|
|
520
|
+
|
|
490
521
|
choices = standard_regions.copy()
|
|
491
|
-
|
|
492
|
-
#
|
|
522
|
+
|
|
523
|
+
# 自定义现有值(如 pre-online)也加入选项,避免默认值校验失败。
|
|
493
524
|
if default_region and default_region not in standard_regions:
|
|
494
525
|
choices.append(default_region)
|
|
495
|
-
|
|
526
|
+
|
|
496
527
|
choices.append(CUSTOM_OPTION)
|
|
497
|
-
|
|
498
|
-
selected_region = _ask_or_exit(
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
528
|
+
|
|
529
|
+
selected_region = _ask_or_exit(
|
|
530
|
+
questionary.select(
|
|
531
|
+
"默认区域 (Region):",
|
|
532
|
+
choices=choices,
|
|
533
|
+
default=default_region if default_region in choices else standard_regions[0],
|
|
534
|
+
style=_questionary_style(),
|
|
535
|
+
)
|
|
536
|
+
)
|
|
537
|
+
|
|
505
538
|
# 如果选择了自定义,或者是点击了之前保留的自定义值,这里逻辑是这样的:
|
|
506
539
|
# 1. 如果选了标准值 -> 直接用
|
|
507
540
|
# 2. 如果选了 CUSTOM_OPTION -> 弹框让用户输
|
|
508
541
|
# 3. 如果选了列表里已有的自定义值 (如 pre-online) -> 直接用
|
|
509
|
-
|
|
542
|
+
|
|
510
543
|
if selected_region == CUSTOM_OPTION:
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
544
|
+
selected_region = _ask_or_exit(
|
|
545
|
+
questionary.text(
|
|
546
|
+
"请输入区域 Code (如 cn-shanghai-2):",
|
|
547
|
+
default=default_region if default_region not in standard_regions else "",
|
|
548
|
+
style=_questionary_style(),
|
|
549
|
+
)
|
|
550
|
+
)
|
|
551
|
+
|
|
552
|
+
new_env["KSYUN_REGION"] = selected_region
|
|
553
|
+
|
|
519
554
|
# 同步回 agentengine.yaml 的 region 字段,保持一致
|
|
520
|
-
new_config[
|
|
555
|
+
new_config["region"] = new_env["KSYUN_REGION"]
|
|
521
556
|
else:
|
|
522
557
|
# 如果不配置,保留原值或设为默认
|
|
523
|
-
new_config[
|
|
558
|
+
new_config["region"] = existing_config.get("region", "cn-beijing-6")
|
|
524
559
|
|
|
525
560
|
print_rule()
|
|
526
561
|
|
|
527
562
|
# === 4.5 容器镜像仓库认证 (仅 container 模式需要) ===
|
|
528
563
|
print_rule("容器镜像部署 (可选)")
|
|
529
564
|
print_info("如果计划使用 container 模式 (agentengine build -m container),需要配置镜像仓库认证")
|
|
530
|
-
|
|
531
|
-
should_config_registry = _ask_or_exit(
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
565
|
+
|
|
566
|
+
should_config_registry = _ask_or_exit(
|
|
567
|
+
questionary.confirm(
|
|
568
|
+
"是否使用 container 模式部署?",
|
|
569
|
+
default=bool(existing_env.get("KCR_USERNAME")),
|
|
570
|
+
style=_questionary_style(),
|
|
571
|
+
)
|
|
572
|
+
)
|
|
536
573
|
|
|
537
574
|
if should_config_registry:
|
|
538
|
-
new_env[
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
575
|
+
new_env["KCR_USERNAME"] = _ask_or_exit(
|
|
576
|
+
questionary.text(
|
|
577
|
+
"KCR 用户名 (企业版请填写访问凭证用户名):",
|
|
578
|
+
default=existing_env.get("KCR_USERNAME", ""),
|
|
579
|
+
style=_questionary_style(),
|
|
580
|
+
)
|
|
581
|
+
)
|
|
582
|
+
|
|
583
|
+
new_env["KCR_PASSWORD"] = _ask_or_exit(
|
|
584
|
+
questionary.password(
|
|
585
|
+
"KCR 密码或 Token:",
|
|
586
|
+
default=existing_env.get("KCR_PASSWORD", ""),
|
|
587
|
+
style=_questionary_style(),
|
|
588
|
+
)
|
|
589
|
+
)
|
|
590
|
+
|
|
591
|
+
default_registry = existing_env.get("KCR_REGISTRY", "")
|
|
592
|
+
custom_registry = _ask_or_exit(
|
|
593
|
+
questionary.text(
|
|
594
|
+
"镜像仓库地址 [选填,如: agenthzzqy-vpc.ksyunkcr.com/testagent-pub]:",
|
|
595
|
+
default=default_registry,
|
|
596
|
+
style=_questionary_style(),
|
|
597
|
+
)
|
|
598
|
+
)
|
|
599
|
+
|
|
557
600
|
if custom_registry:
|
|
558
|
-
new_env[
|
|
601
|
+
new_env["KCR_REGISTRY"] = custom_registry
|
|
559
602
|
|
|
560
603
|
print_info("提示:")
|
|
561
604
|
print_info("个人版 KCR 可留空 KCR_USERNAME,运行时使用 KSYUN_ACCOUNT_ID 作为用户名兜底")
|
|
@@ -563,77 +606,81 @@ def run_config_wizard(config_file: str | None, set_items: tuple, is_global: bool
|
|
|
563
606
|
print_info("KCR 访问凭证获取: https://kcr.console.ksyun.com/ → 访问凭证")
|
|
564
607
|
|
|
565
608
|
print_rule()
|
|
566
|
-
|
|
609
|
+
|
|
567
610
|
# === 5. 写入文件 ===
|
|
568
|
-
|
|
611
|
+
|
|
569
612
|
# 5.1 构造完整的 YAML (保留原有的其他配置)
|
|
570
613
|
final_config = existing_config.copy()
|
|
571
614
|
final_config.update(new_config)
|
|
572
|
-
|
|
615
|
+
|
|
573
616
|
# 确保结构完整 (补全 config 命令中未询问但必须的字段,如果不存在的话)
|
|
574
|
-
if
|
|
575
|
-
final_config[
|
|
576
|
-
if
|
|
577
|
-
final_config[
|
|
578
|
-
if
|
|
579
|
-
final_config[
|
|
617
|
+
if "entry_point" not in final_config:
|
|
618
|
+
final_config["entry_point"] = f"{new_config['name'].replace('-', '_')}/agent.py"
|
|
619
|
+
if "agent_variable" not in final_config:
|
|
620
|
+
final_config["agent_variable"] = "root_agent"
|
|
621
|
+
if "version" not in final_config:
|
|
622
|
+
final_config["version"] = "1.0.0"
|
|
580
623
|
|
|
581
624
|
# 5.2 写入 agentengine.yaml
|
|
582
625
|
# 使用 utf-8-sig 编码 (带 BOM),确保 Windows 程序正确识别为 UTF-8
|
|
583
|
-
with open(output_path,
|
|
626
|
+
with open(output_path, "w", encoding="utf-8-sig") as f:
|
|
584
627
|
# 简单的字典转 YAML 可能丢失注释,但这是预期行为
|
|
585
628
|
# 为了更好的体验,我们手动排版几个关键字段,其他用 dump
|
|
586
|
-
|
|
587
|
-
f.write(
|
|
629
|
+
|
|
630
|
+
f.write("# AgentEngine Project Config\n")
|
|
588
631
|
f.write(f"name: {final_config['name']}\n")
|
|
589
632
|
f.write(f"version: \"{final_config.get('version', '1.0.0')}\"\n\n")
|
|
590
|
-
|
|
591
|
-
f.write(
|
|
633
|
+
|
|
634
|
+
f.write("# Framework\n")
|
|
592
635
|
f.write(f"framework: {final_config['framework']}\n")
|
|
593
636
|
f.write(f"entry_point: {final_config['entry_point']}\n")
|
|
594
637
|
f.write(f"agent_variable: {final_config['agent_variable']}\n\n")
|
|
595
|
-
|
|
596
|
-
f.write(
|
|
638
|
+
|
|
639
|
+
f.write("# Deployment\n")
|
|
597
640
|
f.write(f"region: {final_config.get('region', 'cn-beijing-6')}\n")
|
|
598
|
-
|
|
641
|
+
|
|
599
642
|
# 处理其他复杂对象如 resources, scaling 等,如果存在
|
|
600
|
-
remaining = {
|
|
601
|
-
|
|
602
|
-
|
|
643
|
+
remaining = {
|
|
644
|
+
k: v
|
|
645
|
+
for k, v in final_config.items()
|
|
646
|
+
if k not in ["name", "version", "framework", "entry_point", "agent_variable", "region"]
|
|
647
|
+
}
|
|
603
648
|
if remaining:
|
|
604
649
|
f.write("\n# Advanced Settings\n")
|
|
605
650
|
yaml.dump(remaining, f, default_flow_style=False)
|
|
606
651
|
|
|
607
652
|
# 5.3 写入 .env
|
|
608
653
|
_update_env_file(env_path, new_env)
|
|
609
|
-
|
|
654
|
+
|
|
610
655
|
print_success("配置完成")
|
|
611
656
|
print_kv("配置文件", str(output_path))
|
|
612
657
|
print_kv("环境凭证", str(env_path))
|
|
613
|
-
|
|
658
|
+
|
|
614
659
|
# 5.4 处理全局配置保存逻辑
|
|
615
660
|
print_rule()
|
|
616
661
|
from ksadk.configs.global_config import (
|
|
617
|
-
save_global_config,
|
|
618
662
|
build_global_config_from_env,
|
|
619
663
|
get_global_config_path,
|
|
620
664
|
global_config_exists,
|
|
665
|
+
save_global_config,
|
|
621
666
|
)
|
|
622
667
|
|
|
623
668
|
should_save_global = False
|
|
624
|
-
|
|
669
|
+
|
|
625
670
|
# 情况1: 用户显式指定 --global -> 总是保存 (或确认后保存)
|
|
626
671
|
if is_global:
|
|
627
672
|
should_save_global = True
|
|
628
|
-
|
|
673
|
+
|
|
629
674
|
# 情况2: 全局配置不存在 -> 首次运行,提示保存
|
|
630
675
|
elif not global_config_exists():
|
|
631
|
-
should_save_global = _ask_or_exit(
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
676
|
+
should_save_global = _ask_or_exit(
|
|
677
|
+
questionary.confirm(
|
|
678
|
+
"是否保存到全局配置 (后续新项目可自动复用)?",
|
|
679
|
+
default=True,
|
|
680
|
+
style=_questionary_style(),
|
|
681
|
+
)
|
|
682
|
+
)
|
|
683
|
+
|
|
637
684
|
# 情况3: 全局配置已存在 且 未指定 --global -> 静默跳过,不打扰用户
|
|
638
685
|
else:
|
|
639
686
|
should_save_global = False
|
|
@@ -647,8 +694,17 @@ def run_config_wizard(config_file: str | None, set_items: tuple, is_global: bool
|
|
|
647
694
|
|
|
648
695
|
|
|
649
696
|
@click.group("config", context_settings=CONTEXT_SETTINGS, invoke_without_command=True)
|
|
650
|
-
@click.option(
|
|
651
|
-
|
|
697
|
+
@click.option(
|
|
698
|
+
"--set", "-s", "set_items", multiple=True, hidden=True, help="(兼容) 设置配置项 key=value"
|
|
699
|
+
)
|
|
700
|
+
@click.option(
|
|
701
|
+
"--global",
|
|
702
|
+
"is_global",
|
|
703
|
+
is_flag=True,
|
|
704
|
+
default=False,
|
|
705
|
+
hidden=True,
|
|
706
|
+
help="(兼容) 强制更新全局配置",
|
|
707
|
+
)
|
|
652
708
|
@cli_output_option(hidden=True)
|
|
653
709
|
@click.pass_context
|
|
654
710
|
def config(ctx: click.Context, set_items: tuple, is_global: bool, output_mode: str | None):
|
|
@@ -662,7 +718,10 @@ def config(ctx: click.Context, set_items: tuple, is_global: bool, output_mode: s
|
|
|
662
718
|
return
|
|
663
719
|
|
|
664
720
|
if set_items:
|
|
665
|
-
print_warn(
|
|
721
|
+
print_warn(
|
|
722
|
+
"`agentengine config --set ...` 是兼容入口,"
|
|
723
|
+
"推荐改用 `agentengine config set KEY=VALUE ...`。"
|
|
724
|
+
)
|
|
666
725
|
result = _run_config_set_command(
|
|
667
726
|
set_items=set_items,
|
|
668
727
|
output_path=_default_project_config_path(),
|
|
@@ -677,17 +736,27 @@ def config(ctx: click.Context, set_items: tuple, is_global: bool, output_mode: s
|
|
|
677
736
|
|
|
678
737
|
ensure_json_output_supported(
|
|
679
738
|
"agentengine config",
|
|
680
|
-
suggestion=
|
|
739
|
+
suggestion=(
|
|
740
|
+
"请改用 `agentengine config show --output json` 或 "
|
|
741
|
+
"`agentengine config set KEY=VALUE`。"
|
|
742
|
+
),
|
|
681
743
|
)
|
|
682
744
|
run_config_wizard(config_file=None, set_items=(), is_global=is_global)
|
|
683
745
|
|
|
684
746
|
|
|
685
747
|
@config.command("wizard", context_settings=CONTEXT_SETTINGS)
|
|
686
|
-
@click.option(
|
|
687
|
-
|
|
688
|
-
|
|
748
|
+
@click.option(
|
|
749
|
+
"--file",
|
|
750
|
+
"config_file",
|
|
751
|
+
default=None,
|
|
752
|
+
help="配置文件路径(默认自动复用 agentengine.yaml/ksadk.yaml)",
|
|
753
|
+
)
|
|
754
|
+
@click.option("--set", "-s", "set_items", multiple=True, help="设置配置项 key=value")
|
|
755
|
+
@click.option("--global", "is_global", is_flag=True, default=False, help="强制更新全局配置")
|
|
689
756
|
@cli_output_option(hidden=True)
|
|
690
|
-
def config_wizard(
|
|
757
|
+
def config_wizard(
|
|
758
|
+
config_file: str | None, set_items: tuple, is_global: bool, output_mode: str | None
|
|
759
|
+
):
|
|
691
760
|
"""通过交互式向导配置项目。"""
|
|
692
761
|
_ = output_mode
|
|
693
762
|
run_config_wizard(config_file=config_file, set_items=set_items, is_global=is_global)
|