agentengine-sdk-python 0.6.4__py3-none-any.whl → 0.7.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/METADATA +181 -0
- agentengine_sdk_python-0.7.0.dist-info/RECORD +482 -0
- {agentengine_sdk_python-0.6.4.dist-info → agentengine_sdk_python-0.7.0.dist-info}/WHEEL +1 -1
- agentengine_sdk_python-0.7.0.dist-info/entry_points.txt +3 -0
- agentengine_sdk_python-0.7.0.dist-info/licenses/LICENSE +175 -0
- agentengine_sdk_python-0.7.0.dist-info/top_level.txt +2 -0
- ksadk/__init__.py +13 -0
- ksadk/__main__.py +4 -0
- ksadk/a2a/__init__.py +15 -0
- ksadk/a2a/card_builder.py +64 -0
- ksadk/a2a/client.py +309 -0
- ksadk/a2a/executor.py +201 -0
- ksadk/a2a/server.py +79 -0
- ksadk/agents/__init__.py +20 -0
- ksadk/agents/base.py +370 -0
- ksadk/agents/context.py +38 -0
- ksadk/agents/event.py +35 -0
- ksadk/agents/loop_agent.py +71 -0
- ksadk/agents/parallel_agent.py +109 -0
- ksadk/agents/runner_adapter.py +24 -0
- ksadk/agents/sequential_agent.py +34 -0
- ksadk/api/__init__.py +3 -0
- ksadk/api/client.py +2246 -0
- ksadk/builders/__init__.py +20 -0
- ksadk/builders/base.py +66 -0
- ksadk/builders/code_builder.py +1990 -0
- ksadk/builders/container_builder.py +786 -0
- ksadk/builders/framework_requirements.py +59 -0
- ksadk/builders/ks3_uploader.py +389 -0
- ksadk/builders/mcp_builder.py +476 -0
- ksadk/builders/requirements_utils.py +75 -0
- ksadk/cli/__init__.py +531 -0
- ksadk/cli/__main__.py +4 -0
- ksadk/cli/agent_ref.py +204 -0
- ksadk/cli/cmd_a2a.py +167 -0
- ksadk/cli/cmd_agent.py +201 -0
- ksadk/cli/cmd_build.py +270 -0
- ksadk/cli/cmd_completion.py +304 -0
- ksadk/cli/cmd_config.py +758 -0
- ksadk/cli/cmd_create.py +2304 -0
- ksadk/cli/cmd_dashboard.py +900 -0
- ksadk/cli/cmd_deploy.py +704 -0
- ksadk/cli/cmd_destroy.py +345 -0
- ksadk/cli/cmd_files.py +1227 -0
- ksadk/cli/cmd_hermes.py +1263 -0
- ksadk/cli/cmd_invoke.py +1503 -0
- ksadk/cli/cmd_launch.py +564 -0
- ksadk/cli/cmd_mcp.py +1179 -0
- ksadk/cli/cmd_model.py +302 -0
- ksadk/cli/cmd_openclaw.py +3922 -0
- ksadk/cli/cmd_run.py +239 -0
- ksadk/cli/cmd_status.py +588 -0
- ksadk/cli/cmd_version.py +522 -0
- ksadk/cli/cmd_web.py +288 -0
- ksadk/cli/deploy_utils.py +87 -0
- ksadk/cli/dry_run.py +214 -0
- ksadk/cli/env_options.py +82 -0
- ksadk/cli/error_utils.py +525 -0
- ksadk/cli/global_options.py +31 -0
- ksadk/cli/local_runtime.py +97 -0
- ksadk/cli/model_catalog.py +136 -0
- ksadk/cli/network_options.py +412 -0
- ksadk/cli/resource_common.py +621 -0
- ksadk/cli/storage.py +84 -0
- ksadk/cli/ui.py +431 -0
- ksadk/cli/workflow_common.py +552 -0
- ksadk/common/__init__.py +14 -0
- ksadk/common/aicp_env.py +128 -0
- ksadk/common/auth.py +190 -0
- ksadk/common/constants.py +84 -0
- ksadk/common/llm_utils.py +61 -0
- ksadk/configs/__init__.py +61 -0
- ksadk/configs/env_registry.py +343 -0
- ksadk/configs/global_config.py +200 -0
- ksadk/configs/settings.py +706 -0
- ksadk/conversations/__init__.py +95 -0
- ksadk/conversations/attachment_storage.py +379 -0
- ksadk/conversations/attachments.py +774 -0
- ksadk/conversations/compaction_pipeline.py +387 -0
- ksadk/conversations/compaction_prompt.py +128 -0
- ksadk/conversations/context.py +303 -0
- ksadk/conversations/message_projection.py +269 -0
- ksadk/conversations/model_context.py +370 -0
- ksadk/conversations/model_options.py +136 -0
- ksadk/conversations/normalize.py +446 -0
- ksadk/conversations/reasoning_markup.py +91 -0
- ksadk/conversations/run_kinds.py +61 -0
- ksadk/conversations/run_status.py +53 -0
- ksadk/conversations/runtime.py +5276 -0
- ksadk/conversations/semantic_summary.py +359 -0
- ksadk/conversations/session_title.py +254 -0
- ksadk/deployment/__init__.py +83 -0
- ksadk/deployment/agent_access.py +226 -0
- ksadk/deployment/base.py +229 -0
- ksadk/deployment/manager.py +332 -0
- ksadk/deployment/providers/__init__.py +10 -0
- ksadk/deployment/providers/serverless.py +1115 -0
- ksadk/deployment/registry.py +120 -0
- ksadk/deployment/state.py +78 -0
- ksadk/deployment/ui_config.py +21 -0
- ksadk/detection/__init__.py +7 -0
- ksadk/detection/detector.py +431 -0
- ksadk/detection/mcp_detector.py +250 -0
- ksadk/hermes_terminal.py +467 -0
- ksadk/identity/__init__.py +17 -0
- ksadk/identity/resolver.py +385 -0
- ksadk/knowledge_base/__init__.py +62 -0
- ksadk/knowledge_base/adk_tool.py +47 -0
- ksadk/knowledge_base/client.py +297 -0
- ksadk/knowledge_base/langchain_tool.py +55 -0
- ksadk/knowledge_base/service.py +66 -0
- ksadk/knowledge_base/tool.py +50 -0
- ksadk/markdown.py +169 -0
- ksadk/mcp_runtime/__init__.py +231 -0
- ksadk/memory/__init__.py +57 -0
- ksadk/memory/adk/__init__.py +51 -0
- ksadk/memory/adk/backends/__init__.py +5 -0
- ksadk/memory/adk/backends/base_ltm_backend.py +52 -0
- ksadk/memory/adk/backends/http_ltm_backend.py +183 -0
- ksadk/memory/adk/backends/inmemory_ltm_backend.py +96 -0
- ksadk/memory/adk/backends/sdk_ltm_backend.py +456 -0
- ksadk/memory/adk/long_term_memory.py +273 -0
- ksadk/memory/adk/resilient_session_service.py +268 -0
- ksadk/memory/adk/short_term_memory.py +304 -0
- ksadk/memory/adk_tool.py +31 -0
- ksadk/memory/backends/__init__.py +6 -0
- ksadk/memory/backends/base.py +103 -0
- ksadk/memory/backends/memory.py +112 -0
- ksadk/memory/backends/redis.py +146 -0
- ksadk/memory/langchain_tool.py +39 -0
- ksadk/memory/ltm_backend_factory.py +24 -0
- ksadk/memory/manager.py +215 -0
- ksadk/memory/service.py +172 -0
- ksadk/memory/tool.py +96 -0
- ksadk/model_policy.py +223 -0
- ksadk/openclaw_gateway.py +378 -0
- ksadk/runners/__init__.py +8 -0
- ksadk/runners/adk_runner.py +1994 -0
- ksadk/runners/base_runner.py +305 -0
- ksadk/runners/deepagents_runner.py +13 -0
- ksadk/runners/factory.py +73 -0
- ksadk/runners/langchain_runner.py +751 -0
- ksadk/runners/langgraph_runner.py +985 -0
- ksadk/runners/patch_langchain.py +187 -0
- ksadk/runners/remote_runner.py +792 -0
- ksadk/runners/usage_accumulator.py +38 -0
- ksadk/runners/utils/__init__.py +19 -0
- ksadk/runners/utils/langfuse.py +230 -0
- ksadk/runners/utils/loader.py +62 -0
- ksadk/runtime_context.py +166 -0
- ksadk/runtime_state.py +25 -0
- ksadk/sandbox/__init__.py +28 -0
- ksadk/sandbox/backends/__init__.py +9 -0
- ksadk/sandbox/backends/e2b.py +154 -0
- ksadk/sandbox/backends/local_process.py +131 -0
- ksadk/sandbox/base.py +101 -0
- ksadk/sandbox/factory.py +53 -0
- ksadk/sandbox/registry.py +187 -0
- ksadk/server/__init__.py +7 -0
- ksadk/server/api_models.py +73 -0
- ksadk/server/app.py +3931 -0
- ksadk/server/static/assets/ArtifactsPanel-D-SSn2ee.js +1 -0
- ksadk/server/static/assets/CodeBlock-P16VOLYi.js +9 -0
- ksadk/server/static/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- ksadk/server/static/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- ksadk/server/static/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- ksadk/server/static/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- ksadk/server/static/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- ksadk/server/static/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- ksadk/server/static/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- ksadk/server/static/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- ksadk/server/static/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- ksadk/server/static/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- ksadk/server/static/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- ksadk/server/static/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- ksadk/server/static/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- ksadk/server/static/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- ksadk/server/static/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- ksadk/server/static/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- ksadk/server/static/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- ksadk/server/static/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- ksadk/server/static/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- ksadk/server/static/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- ksadk/server/static/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- ksadk/server/static/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- ksadk/server/static/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- ksadk/server/static/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- ksadk/server/static/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- ksadk/server/static/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- ksadk/server/static/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- ksadk/server/static/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- ksadk/server/static/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- ksadk/server/static/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- ksadk/server/static/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- ksadk/server/static/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- ksadk/server/static/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- ksadk/server/static/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- ksadk/server/static/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- ksadk/server/static/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- ksadk/server/static/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- ksadk/server/static/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- ksadk/server/static/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- ksadk/server/static/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- ksadk/server/static/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- ksadk/server/static/assets/MathMessageMarkdown-CdGiQWHR.js +8 -0
- ksadk/server/static/assets/MathMessageMarkdown-DeYh8QPr.css +1 -0
- ksadk/server/static/assets/MermaidBlock-IOcal8cm.js +303 -0
- ksadk/server/static/assets/NativeTerminalPanel-CHOd7Rch.css +1 -0
- ksadk/server/static/assets/NativeTerminalPanel-DGSDWsei.js +1 -0
- ksadk/server/static/assets/addon-fit-DthTIhi3.js +1 -0
- ksadk/server/static/assets/apl-CnwPGSsG.js +1 -0
- ksadk/server/static/assets/arc-BA13sHc9.js +1 -0
- ksadk/server/static/assets/architecture-7EHR7CIX-BvUlsA6l.js +1 -0
- ksadk/server/static/assets/architectureDiagram-3BPJPVTR-DzJzgVoL.js +36 -0
- ksadk/server/static/assets/asciiarmor-qTkVPQu6.js +1 -0
- ksadk/server/static/assets/asn1-Dr8qZg38.js +1 -0
- ksadk/server/static/assets/asterisk-Bja0s6e1.js +1 -0
- ksadk/server/static/assets/blockDiagram-GPEHLZMM-UTdVcZhn.js +132 -0
- ksadk/server/static/assets/brainfuck-D5EjA2JK.js +1 -0
- ksadk/server/static/assets/c4Diagram-AAUBKEIU-Dix0GD4m.js +10 -0
- ksadk/server/static/assets/channel-CTuydARX.js +1 -0
- ksadk/server/static/assets/chunk-2J33WTMH-C2JxuZ42.js +1 -0
- ksadk/server/static/assets/chunk-4BX2VUAB-Be57QPgD.js +1 -0
- ksadk/server/static/assets/chunk-55IACEB6-WjSuy4nv.js +1 -0
- ksadk/server/static/assets/chunk-727SXJPM-BOovP-b5.js +206 -0
- ksadk/server/static/assets/chunk-AQP2D5EJ-DOmZNmWj.js +231 -0
- ksadk/server/static/assets/chunk-FMBD7UC4-DzwlodkU.js +15 -0
- ksadk/server/static/assets/chunk-ND2GUHAM-DMqAikEU.js +1 -0
- ksadk/server/static/assets/chunk-QZHKN3VN-BnCydivS.js +1 -0
- ksadk/server/static/assets/classDiagram-4FO5ZUOK-BNHg45Be.js +1 -0
- ksadk/server/static/assets/classDiagram-v2-Q7XG4LA2-BNHg45Be.js +1 -0
- ksadk/server/static/assets/clike-DHH8Ad3s.js +1 -0
- ksadk/server/static/assets/clojure-BflJGmDX.js +1 -0
- ksadk/server/static/assets/cmake-CyVbuzPu.js +1 -0
- ksadk/server/static/assets/cobol-B_OZ4V-R.js +1 -0
- ksadk/server/static/assets/coffeescript-B2pKbFk8.js +1 -0
- ksadk/server/static/assets/commonlisp-CcllspGY.js +1 -0
- ksadk/server/static/assets/cose-bilkent-S5V4N54A-Zhy2GBnP.js +1 -0
- ksadk/server/static/assets/crystal-M5-qzICs.js +1 -0
- ksadk/server/static/assets/css-CYpP4FRV.js +1 -0
- ksadk/server/static/assets/cypher-p9eYesGn.js +1 -0
- ksadk/server/static/assets/cytoscape.esm-DelgaX4f.js +321 -0
- ksadk/server/static/assets/d-BhMjBjQP.js +1 -0
- ksadk/server/static/assets/dagre-BM42HDAG-CbKrtIUz.js +4 -0
- ksadk/server/static/assets/dagre-Bx709z4p.js +1 -0
- ksadk/server/static/assets/defaultLocale-C8Fc0cco.js +1 -0
- ksadk/server/static/assets/diagram-2AECGRRQ-BRApgQRK.js +43 -0
- ksadk/server/static/assets/diagram-5GNKFQAL-D0xbnDiK.js +10 -0
- ksadk/server/static/assets/diagram-KO2AKTUF-CVugVI9L.js +3 -0
- ksadk/server/static/assets/diagram-LMA3HP47-DozUGgee.js +24 -0
- ksadk/server/static/assets/diagram-OG6HWLK6-ZOYsKlru.js +24 -0
- ksadk/server/static/assets/diff-ChtP43wD.js +1 -0
- ksadk/server/static/assets/dist-2hInLS_J.js +9 -0
- ksadk/server/static/assets/dist-8EEyGgDx.js +1 -0
- ksadk/server/static/assets/dist-8_SfK1IP.js +1 -0
- ksadk/server/static/assets/dist-B0NP_Z0z.js +23 -0
- ksadk/server/static/assets/dist-BIJVDMuB.js +1 -0
- ksadk/server/static/assets/dist-BmlMPsCc.js +2 -0
- ksadk/server/static/assets/dist-BrCcQ47T.js +1 -0
- ksadk/server/static/assets/dist-BssVmjIo.js +6 -0
- ksadk/server/static/assets/dist-C3HIIaN5.js +1 -0
- ksadk/server/static/assets/dist-CPBtqRTW.js +1 -0
- ksadk/server/static/assets/dist-CkEKJFtk.js +1 -0
- ksadk/server/static/assets/dist-D-JMdWPQ.js +1 -0
- ksadk/server/static/assets/dist-D-xOD048.js +1 -0
- ksadk/server/static/assets/dist-D57wnGWd.js +1 -0
- ksadk/server/static/assets/dist-DL_NKc_z.js +1 -0
- ksadk/server/static/assets/dist-DMezvBGJ.js +1 -0
- ksadk/server/static/assets/dist-DmFaq_Iy.js +1 -0
- ksadk/server/static/assets/dist-Dp0k7bWI.js +1 -0
- ksadk/server/static/assets/dist-DpKtt4Bo.js +1 -0
- ksadk/server/static/assets/dist-DyOkZmze.js +11 -0
- ksadk/server/static/assets/dist-DyWsb78Q.js +1 -0
- ksadk/server/static/assets/dist-gX6GOLKq.js +1 -0
- ksadk/server/static/assets/dockerfile-BLkNEvjs.js +1 -0
- ksadk/server/static/assets/dtd-DTF72YNO.js +1 -0
- ksadk/server/static/assets/dylan-C6jEEEk-.js +1 -0
- ksadk/server/static/assets/ebnf-D4c0_ac3.js +1 -0
- ksadk/server/static/assets/ecl-BSZaIHnp.js +1 -0
- ksadk/server/static/assets/eiffel-BEjRio4Q.js +1 -0
- ksadk/server/static/assets/elm-Cshzl8qu.js +1 -0
- ksadk/server/static/assets/erDiagram-TEJ5UH35-Bk-9bgE5.js +85 -0
- ksadk/server/static/assets/erlang-DaB2Rkuy.js +1 -0
- ksadk/server/static/assets/eventmodeling-FCH6USID-DsAgWnlf.js +1 -0
- ksadk/server/static/assets/factor-D7LVTn2l.js +1 -0
- ksadk/server/static/assets/fcl-ClOhbFR7.js +1 -0
- ksadk/server/static/assets/flowDiagram-I6XJVG4X-Dn9kZVuZ.js +162 -0
- ksadk/server/static/assets/forth-Cezjo90N.js +1 -0
- ksadk/server/static/assets/fortran-Bt6PBEDR.js +1 -0
- ksadk/server/static/assets/ganttDiagram-6RSMTGT7-BGxXlJqm.js +292 -0
- ksadk/server/static/assets/gas-BHEdbvp9.js +1 -0
- ksadk/server/static/assets/gherkin-oBAE_ms0.js +1 -0
- ksadk/server/static/assets/gitGraph-WXDBUCRP-BIao9Yjg.js +1 -0
- ksadk/server/static/assets/gitGraphDiagram-PVQCEYII-C7Q0X-wi.js +106 -0
- ksadk/server/static/assets/graphlib-B8gBHxth.js +1 -0
- ksadk/server/static/assets/groovy-BC3IOsC8.js +1 -0
- ksadk/server/static/assets/haskell-BRsoo5mP.js +1 -0
- ksadk/server/static/assets/haxe-DIz0ZZqd.js +1 -0
- ksadk/server/static/assets/http-CLVgA2GD.js +1 -0
- ksadk/server/static/assets/idl-BUZw3wgd.js +1 -0
- ksadk/server/static/assets/index-C00Lwg3L.js +165 -0
- ksadk/server/static/assets/index-DAURbCsP.css +1 -0
- ksadk/server/static/assets/info-J43DQDTF-CyipqGxU.js +1 -0
- ksadk/server/static/assets/infoDiagram-5YYISTIA-BO_CSqq5.js +2 -0
- ksadk/server/static/assets/init-D6jRqBbL.js +1 -0
- ksadk/server/static/assets/ishikawaDiagram-YF4QCWOH-eYLPLd46.js +70 -0
- ksadk/server/static/assets/javascript-9Tg8ixDm.js +1 -0
- ksadk/server/static/assets/journeyDiagram-JHISSGLW-De9geSb0.js +139 -0
- ksadk/server/static/assets/julia-CQfgDRfP.js +1 -0
- ksadk/server/static/assets/kanban-definition-UN3LZRKU-Cs80kQto.js +89 -0
- ksadk/server/static/assets/katex-DSrCFD8n.js +265 -0
- ksadk/server/static/assets/linear-CN9sbKTF.js +1 -0
- ksadk/server/static/assets/livescript-BXxG0Yva.js +1 -0
- ksadk/server/static/assets/lua-CiA1ziua.js +1 -0
- ksadk/server/static/assets/mathematica-u8YMmbU0.js +1 -0
- ksadk/server/static/assets/mbox-BEMVcqjs.js +1 -0
- ksadk/server/static/assets/mermaid-parser.core-DlgSBU8l.js +161 -0
- ksadk/server/static/assets/mindmap-definition-RKZ34NQL-9afz7Oug.js +96 -0
- ksadk/server/static/assets/mirc-C9zpzAZU.js +1 -0
- ksadk/server/static/assets/mllike-B45xgp2S.js +1 -0
- ksadk/server/static/assets/modelica-CqHI_q-D.js +1 -0
- ksadk/server/static/assets/mscgen-qgSLujhx.js +1 -0
- ksadk/server/static/assets/mumps-CW_TBmxz.js +1 -0
- ksadk/server/static/assets/nginx-BMaDbqW3.js +1 -0
- ksadk/server/static/assets/nsis-AQ_alPln.js +1 -0
- ksadk/server/static/assets/ntriples-d28e9m0E.js +1 -0
- ksadk/server/static/assets/octave-D2Q8cUp1.js +1 -0
- ksadk/server/static/assets/ordinal-hYBb2elL.js +1 -0
- ksadk/server/static/assets/oz-BwTct_5T.js +1 -0
- ksadk/server/static/assets/packet-YPE3B663-CGkyRxlg.js +1 -0
- ksadk/server/static/assets/pascal-Dp_KdFgX.js +1 -0
- ksadk/server/static/assets/perl-CdEHsPfU.js +1 -0
- ksadk/server/static/assets/pie-LRSECV5Y-M0uWAf4n.js +1 -0
- ksadk/server/static/assets/pieDiagram-4H26LBE5-DPv_VstN.js +30 -0
- ksadk/server/static/assets/pig-AF4Hwhju.js +1 -0
- ksadk/server/static/assets/powershell-CzG71I4L.js +1 -0
- ksadk/server/static/assets/properties-C357ku5U.js +1 -0
- ksadk/server/static/assets/protobuf-D1ij_kNL.js +1 -0
- ksadk/server/static/assets/pug-Bugr-47h.js +1 -0
- ksadk/server/static/assets/puppet-B4hC2X4m.js +1 -0
- ksadk/server/static/assets/python-BqYw9LYJ.js +1 -0
- ksadk/server/static/assets/q-B9NhS7L_.js +1 -0
- ksadk/server/static/assets/quadrantDiagram-W4KKPZXB-o77wZ1XK.js +7 -0
- ksadk/server/static/assets/r-DADKenSm.js +1 -0
- ksadk/server/static/assets/radar-GUYGQ44K-Bdbm24-x.js +1 -0
- ksadk/server/static/assets/requirementDiagram-4Y6WPE33-BYVw81VC.js +84 -0
- ksadk/server/static/assets/rpm-gpDK5sbt.js +1 -0
- ksadk/server/static/assets/ruby-DsYpTuWg.js +1 -0
- ksadk/server/static/assets/sankeyDiagram-5OEKKPKP-B7nZFMKT.js +40 -0
- ksadk/server/static/assets/sas-C2OyD2Y6.js +1 -0
- ksadk/server/static/assets/scheme-CyDdOh7e.js +1 -0
- ksadk/server/static/assets/sequenceDiagram-3UESZ5HK-BGRRrFw5.js +162 -0
- ksadk/server/static/assets/shell-Du5Qg9im.js +1 -0
- ksadk/server/static/assets/sieve-BAxa3IjF.js +1 -0
- ksadk/server/static/assets/simple-mode-DRpGK0lJ.js +1 -0
- ksadk/server/static/assets/smalltalk-BLp5-jwC.js +1 -0
- ksadk/server/static/assets/solr-BBopId9w.js +1 -0
- ksadk/server/static/assets/sparql-Dz-mlCAC.js +1 -0
- ksadk/server/static/assets/spreadsheet-CTIncYxj.js +1 -0
- ksadk/server/static/assets/sql-DcCJ9jop.js +1 -0
- ksadk/server/static/assets/stateDiagram-AJRCARHV-BUfHCoPs.js +1 -0
- ksadk/server/static/assets/stateDiagram-v2-BHNVJYJU-8xBN_gLM.js +1 -0
- ksadk/server/static/assets/stex-sDrdk2BW.js +1 -0
- ksadk/server/static/assets/stylus-DLLZ8dgm.js +1 -0
- ksadk/server/static/assets/swift-DKB6_1j6.js +1 -0
- ksadk/server/static/assets/tcl-BGfruO1u.js +1 -0
- ksadk/server/static/assets/textile-DWBqthVk.js +1 -0
- ksadk/server/static/assets/tiddlywiki-VlUiK86J.js +1 -0
- ksadk/server/static/assets/tiki-CxVlf5KZ.js +1 -0
- ksadk/server/static/assets/timeline-definition-PNZ67QCA-FbCTGrf9.js +120 -0
- ksadk/server/static/assets/toml-LvoKBwCs.js +1 -0
- ksadk/server/static/assets/treeView-BLDUP644-npMo0ak1.js +1 -0
- ksadk/server/static/assets/treemap-LRROVOQU-CHdzrrdo.js +1 -0
- ksadk/server/static/assets/troff-C2dAgh7P.js +1 -0
- ksadk/server/static/assets/ttcn-BePYh-hG.js +1 -0
- ksadk/server/static/assets/ttcn-cfg-CY0aot7Q.js +1 -0
- ksadk/server/static/assets/turtle-BDLWE2cD.js +1 -0
- ksadk/server/static/assets/vb-BthdM_4N.js +1 -0
- ksadk/server/static/assets/vbscript-D9f6rSsU.js +1 -0
- ksadk/server/static/assets/velocity-CqftRsjg.js +1 -0
- ksadk/server/static/assets/vennDiagram-CIIHVFJN-DWgwtPsJ.js +34 -0
- ksadk/server/static/assets/verilog-D-x6ne0Z.js +1 -0
- ksadk/server/static/assets/vhdl-CMrOq2q1.js +1 -0
- ksadk/server/static/assets/wardley-L42UT6IY-BEQz7wyy.js +1 -0
- ksadk/server/static/assets/wardleyDiagram-YWT4CUSO-2x8G-tTM.js +78 -0
- ksadk/server/static/assets/webidl-D5jiJvOU.js +1 -0
- ksadk/server/static/assets/xquery-fj_R-kMw.js +1 -0
- ksadk/server/static/assets/xterm-DooSxjI5.js +36 -0
- ksadk/server/static/assets/xychartDiagram-2RQKCTM6-Drma3AYl.js +7 -0
- ksadk/server/static/assets/yacas-CXXgtw0p.js +1 -0
- ksadk/server/static/assets/z80-CL1naaMV.js +1 -0
- ksadk/server/static/favicon.svg +1 -0
- ksadk/server/static/icons.svg +24 -0
- ksadk/server/static/index.html +14 -0
- ksadk/server/terminal_sessions.py +551 -0
- ksadk/sessions/__init__.py +279 -0
- ksadk/sessions/base.py +354 -0
- ksadk/sessions/continuity.py +337 -0
- ksadk/sessions/errors.py +7 -0
- ksadk/sessions/in_memory.py +273 -0
- ksadk/sessions/local_service.py +949 -0
- ksadk/sessions/postgres_service.py +901 -0
- ksadk/sessions/resilience.py +52 -0
- ksadk/sessions/resilient.py +360 -0
- ksadk/sessions/sqlite_service.py +13 -0
- ksadk/skills/__init__.py +9 -0
- ksadk/skills/loader.py +46 -0
- ksadk/skills/models.py +120 -0
- ksadk/skills/package_store.py +104 -0
- ksadk/skills/runtime/__init__.py +17 -0
- ksadk/skills/runtime/agent.py +183 -0
- ksadk/skills/runtime/artifacts.py +39 -0
- ksadk/skills/runtime/backends/__init__.py +1 -0
- ksadk/skills/runtime/backends/disabled.py +8 -0
- ksadk/skills/runtime/backends/e2b.py +168 -0
- ksadk/skills/runtime/backends/local.py +95 -0
- ksadk/skills/runtime/base.py +103 -0
- ksadk/skills/runtime/executor.py +219 -0
- ksadk/skills/runtime/factory.py +37 -0
- ksadk/skills/runtime/loader.py +131 -0
- ksadk/skills/runtime/registry.py +150 -0
- ksadk/skills/runtime/request.py +67 -0
- ksadk/skills/service_client.py +239 -0
- ksadk/skills/service_env.py +58 -0
- ksadk/skills/tool_defs.py +221 -0
- ksadk/terminal_client.py +69 -0
- ksadk/terminal_exec_policy.py +229 -0
- ksadk/tools/__init__.py +17 -0
- ksadk/tools/gateway.py +230 -0
- ksadk/tools/result_budget.py +154 -0
- ksadk/toolsets/__init__.py +854 -0
- ksadk/toolsets/_langchain.py +11 -0
- ksadk/toolsets/platform.py +93 -0
- ksadk/toolsets/sandbox.py +310 -0
- ksadk/toolsets/skills.py +217 -0
- ksadk/toolsets/web.py +266 -0
- ksadk/toolsets/workspace.py +917 -0
- ksadk/toolsets/workspace_state.py +44 -0
- ksadk/tracing/__init__.py +37 -0
- ksadk/tracing/exporters/__init__.py +1 -0
- ksadk/tracing/exporters/inmemory_exporter.py +116 -0
- ksadk/tracing/exporters/langfuse_exporter.py +445 -0
- ksadk/tracing/setup.py +892 -0
- ksadk/tracing/span_utils.py +114 -0
- ksadk/tui/__init__.py +27 -0
- ksadk/tui/loop.py +1877 -0
- ksadk/tui/stream_render.py +68 -0
- ksadk/ui_config.py +168 -0
- ksadk/version.py +4 -0
- ksadk_runtime_common/__init__.py +20 -0
- ksadk_runtime_common/memory_backend/__init__.py +29 -0
- ksadk_runtime_common/memory_backend/manifest.py +79 -0
- ksadk_runtime_common/memory_backend/providers/__init__.py +6 -0
- ksadk_runtime_common/memory_backend/providers/lancedb.py +151 -0
- ksadk_runtime_common/memory_backend/providers/mem0.py +74 -0
- ksadk_runtime_common/memory_backend/registry.py +56 -0
- ksadk_runtime_common/memory_backend/render.py +71 -0
- ksadk_runtime_common/schemas/memory_backend_manifest.schema.json +148 -0
- ksadk_runtime_common/workspace_files/__init__.py +29 -0
- ksadk_runtime_common/workspace_files/bootstrap.py +56 -0
- ksadk_runtime_common/workspace_files/constants.py +9 -0
- ksadk_runtime_common/workspace_files/path_utils.py +71 -0
- ksadk_runtime_common/workspace_files/preview.py +96 -0
- ksadk_runtime_common/workspace_files/router.py +254 -0
- agentengine_sdk_python/__init__.py +0 -3
- agentengine_sdk_python-0.6.4.dist-info/METADATA +0 -48
- agentengine_sdk_python-0.6.4.dist-info/RECORD +0 -5
- agentengine_sdk_python-0.6.4.dist-info/top_level.txt +0 -1
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
"""Shared helpers for build/deploy/launch workflows."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass, replace
|
|
6
|
+
import json
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any, Sequence
|
|
9
|
+
|
|
10
|
+
import click
|
|
11
|
+
|
|
12
|
+
from ksadk.cli.dry_run import sanitize_dry_run_request
|
|
13
|
+
from ksadk.cli.ui import (
|
|
14
|
+
emit_json,
|
|
15
|
+
is_json_output,
|
|
16
|
+
print_info,
|
|
17
|
+
print_kv,
|
|
18
|
+
print_next_steps,
|
|
19
|
+
print_title,
|
|
20
|
+
print_warn,
|
|
21
|
+
print_rule,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass(frozen=True)
|
|
26
|
+
class ArtifactBuildPlan:
|
|
27
|
+
"""Workflow-level artifact build decision."""
|
|
28
|
+
|
|
29
|
+
should_build: bool
|
|
30
|
+
should_clear_metadata: bool
|
|
31
|
+
explicit_ref_option: str | None = None
|
|
32
|
+
will_build: bool | None = None
|
|
33
|
+
should_publish: bool | None = None
|
|
34
|
+
will_publish: bool | None = None
|
|
35
|
+
source: str | None = None
|
|
36
|
+
reference: str | None = None
|
|
37
|
+
reference_is_predicted: bool = False
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def build_workflow_local_plan(
|
|
41
|
+
*,
|
|
42
|
+
project_dir: Path,
|
|
43
|
+
framework: str,
|
|
44
|
+
target: str,
|
|
45
|
+
region: str | None,
|
|
46
|
+
deploy_name: str | None,
|
|
47
|
+
artifact_type: str | None,
|
|
48
|
+
artifact_plan: ArtifactBuildPlan,
|
|
49
|
+
build_dir: str | None,
|
|
50
|
+
artifact_reference: str | None,
|
|
51
|
+
no_cache: bool,
|
|
52
|
+
repackage: bool = False,
|
|
53
|
+
) -> dict[str, Any]:
|
|
54
|
+
"""Build a stable local execution plan for workflow dry-run output."""
|
|
55
|
+
normalized_artifact_type = (artifact_type or "").strip().lower()
|
|
56
|
+
normalized_reference = str(artifact_reference or artifact_plan.reference or "")
|
|
57
|
+
source = artifact_plan.source or ("built" if artifact_plan.should_build else "external")
|
|
58
|
+
will_build = artifact_plan.will_build if artifact_plan.will_build is not None else artifact_plan.should_build
|
|
59
|
+
should_publish = artifact_plan.should_publish if artifact_plan.should_publish is not None else artifact_plan.should_build
|
|
60
|
+
will_publish = artifact_plan.will_publish if artifact_plan.will_publish is not None else will_build
|
|
61
|
+
build_reason = _plan_step_reason(
|
|
62
|
+
source=source,
|
|
63
|
+
explicit_ref_option=artifact_plan.explicit_ref_option,
|
|
64
|
+
is_predicted=bool(artifact_plan.should_build and not will_build),
|
|
65
|
+
)
|
|
66
|
+
publish_reason = _plan_step_reason(
|
|
67
|
+
source=source,
|
|
68
|
+
explicit_ref_option=artifact_plan.explicit_ref_option,
|
|
69
|
+
is_predicted=bool(should_publish and not will_publish),
|
|
70
|
+
)
|
|
71
|
+
steps = [
|
|
72
|
+
{"name": "validate_config", "kind": "local", "will_run": True},
|
|
73
|
+
{"name": "package", "kind": "local", "will_run": True},
|
|
74
|
+
{
|
|
75
|
+
"name": "local_build",
|
|
76
|
+
"kind": "local",
|
|
77
|
+
"will_run": bool(will_build),
|
|
78
|
+
"planned": bool(artifact_plan.should_build and not will_build),
|
|
79
|
+
"reason": build_reason,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"name": "artifact_publish",
|
|
83
|
+
"kind": "remote",
|
|
84
|
+
"will_run": bool(will_publish),
|
|
85
|
+
"planned": bool(should_publish and not will_publish),
|
|
86
|
+
"reason": publish_reason,
|
|
87
|
+
},
|
|
88
|
+
{"name": "deploy_request", "kind": "remote", "will_run": True},
|
|
89
|
+
]
|
|
90
|
+
return {
|
|
91
|
+
"project_dir": str(project_dir),
|
|
92
|
+
"framework": str(framework or ""),
|
|
93
|
+
"target": str(target or ""),
|
|
94
|
+
"region": str(region or ""),
|
|
95
|
+
"deploy_name": str(deploy_name or ""),
|
|
96
|
+
"artifact_type": normalized_artifact_type,
|
|
97
|
+
"no_cache": bool(no_cache),
|
|
98
|
+
"repackage": bool(repackage),
|
|
99
|
+
"artifact": {
|
|
100
|
+
"should_build": bool(artifact_plan.should_build),
|
|
101
|
+
"will_build": bool(will_build),
|
|
102
|
+
"should_local_build": bool(artifact_plan.should_build),
|
|
103
|
+
"will_local_build": bool(will_build),
|
|
104
|
+
"should_publish": bool(should_publish),
|
|
105
|
+
"will_publish": bool(will_publish),
|
|
106
|
+
"should_clear_metadata": bool(artifact_plan.should_clear_metadata),
|
|
107
|
+
"explicit_ref_option": artifact_plan.explicit_ref_option,
|
|
108
|
+
"source": source,
|
|
109
|
+
"build_dir": str(build_dir or ""),
|
|
110
|
+
"reference": normalized_reference,
|
|
111
|
+
"reference_is_predicted": bool(artifact_plan.reference_is_predicted),
|
|
112
|
+
},
|
|
113
|
+
"steps": steps,
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def should_build_artifact(*, target: str, artifact_type: str | None, ks3_path: str | None, image: str | None) -> bool:
|
|
118
|
+
"""Whether deploy/launch should build artifacts locally."""
|
|
119
|
+
if target != "serverless":
|
|
120
|
+
return False
|
|
121
|
+
mode = (artifact_type or "Code").strip().lower()
|
|
122
|
+
if mode == "code":
|
|
123
|
+
return not bool(ks3_path)
|
|
124
|
+
if mode == "container":
|
|
125
|
+
return not bool(image)
|
|
126
|
+
return False
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def plan_artifact_build(
|
|
130
|
+
*,
|
|
131
|
+
target: str,
|
|
132
|
+
artifact_type: str | None,
|
|
133
|
+
ks3_path: str | None,
|
|
134
|
+
image: str | None,
|
|
135
|
+
no_cache: bool,
|
|
136
|
+
repackage: bool = False,
|
|
137
|
+
) -> ArtifactBuildPlan:
|
|
138
|
+
"""Plan artifact build behavior and metadata cleanup under cache options."""
|
|
139
|
+
should_build = should_build_artifact(
|
|
140
|
+
target=target,
|
|
141
|
+
artifact_type=artifact_type,
|
|
142
|
+
ks3_path=ks3_path,
|
|
143
|
+
image=image,
|
|
144
|
+
)
|
|
145
|
+
explicit_ref_option = None
|
|
146
|
+
if target == "serverless" and not should_build:
|
|
147
|
+
mode = (artifact_type or "Code").strip().lower()
|
|
148
|
+
if mode == "code" and ks3_path:
|
|
149
|
+
explicit_ref_option = "--ks3-path"
|
|
150
|
+
elif mode == "container" and image:
|
|
151
|
+
explicit_ref_option = "--image"
|
|
152
|
+
return ArtifactBuildPlan(
|
|
153
|
+
should_build=should_build,
|
|
154
|
+
should_clear_metadata=bool((no_cache or repackage) and should_build),
|
|
155
|
+
explicit_ref_option=explicit_ref_option,
|
|
156
|
+
will_build=should_build,
|
|
157
|
+
should_publish=bool(target == "serverless" and should_build),
|
|
158
|
+
will_publish=bool(target == "serverless" and should_build),
|
|
159
|
+
source="external" if explicit_ref_option else ("built" if should_build else None),
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def _predict_artifact_reference(
|
|
164
|
+
*,
|
|
165
|
+
target: str,
|
|
166
|
+
artifact_type: str | None,
|
|
167
|
+
deploy_name: str | None,
|
|
168
|
+
region: str | None,
|
|
169
|
+
account_id: str | None,
|
|
170
|
+
ks3_bucket: str | None,
|
|
171
|
+
registry: str | None,
|
|
172
|
+
) -> str:
|
|
173
|
+
"""Predict the artifact reference that a real build would produce."""
|
|
174
|
+
if target != "serverless":
|
|
175
|
+
return ""
|
|
176
|
+
|
|
177
|
+
normalized_artifact_type = (artifact_type or "Code").strip().lower()
|
|
178
|
+
normalized_deploy_name = (deploy_name or "agent").strip() or "agent"
|
|
179
|
+
normalized_region = "cn-beijing-6" if str(region or "").strip() == "pre-online" else str(region or "").strip()
|
|
180
|
+
|
|
181
|
+
if normalized_artifact_type == "code":
|
|
182
|
+
bucket = (ks3_bucket or "").strip()
|
|
183
|
+
if not bucket and account_id and normalized_region:
|
|
184
|
+
bucket = f"agentengine-{account_id}-{normalized_region}"
|
|
185
|
+
if not bucket:
|
|
186
|
+
bucket = "<ks3-bucket>"
|
|
187
|
+
return f"ks3://{bucket}/agents/{normalized_deploy_name}/code_<dry-run>.zip"
|
|
188
|
+
|
|
189
|
+
if normalized_artifact_type == "container":
|
|
190
|
+
normalized_registry = (registry or "").strip().rstrip("/")
|
|
191
|
+
if not normalized_registry:
|
|
192
|
+
normalized_registry = "<registry>"
|
|
193
|
+
return f"{normalized_registry}/{normalized_deploy_name}:dry-run"
|
|
194
|
+
|
|
195
|
+
return ""
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def resolve_artifact_build_plan(
|
|
199
|
+
*,
|
|
200
|
+
plan: ArtifactBuildPlan,
|
|
201
|
+
target: str,
|
|
202
|
+
artifact_type: str | None,
|
|
203
|
+
dry_run: bool,
|
|
204
|
+
deploy_name: str | None,
|
|
205
|
+
region: str | None,
|
|
206
|
+
account_id: str | None,
|
|
207
|
+
ks3_bucket: str | None,
|
|
208
|
+
registry: str | None,
|
|
209
|
+
explicit_reference: str | None,
|
|
210
|
+
cached_reference: str | None,
|
|
211
|
+
) -> ArtifactBuildPlan:
|
|
212
|
+
"""Resolve workflow artifact behavior after package metadata is available."""
|
|
213
|
+
normalized_explicit = str(explicit_reference or "").strip()
|
|
214
|
+
normalized_cached = str(cached_reference or "").strip()
|
|
215
|
+
|
|
216
|
+
if normalized_explicit:
|
|
217
|
+
return replace(
|
|
218
|
+
plan,
|
|
219
|
+
should_build=False,
|
|
220
|
+
will_build=False,
|
|
221
|
+
should_publish=False,
|
|
222
|
+
will_publish=False,
|
|
223
|
+
source="external",
|
|
224
|
+
reference=normalized_explicit,
|
|
225
|
+
reference_is_predicted=False,
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
if normalized_cached:
|
|
229
|
+
return replace(
|
|
230
|
+
plan,
|
|
231
|
+
should_build=False,
|
|
232
|
+
will_build=False,
|
|
233
|
+
should_publish=False,
|
|
234
|
+
will_publish=False,
|
|
235
|
+
source="cached",
|
|
236
|
+
reference=normalized_cached,
|
|
237
|
+
reference_is_predicted=False,
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
if plan.should_build and dry_run:
|
|
241
|
+
return replace(
|
|
242
|
+
plan,
|
|
243
|
+
will_build=False,
|
|
244
|
+
should_publish=bool(target == "serverless"),
|
|
245
|
+
will_publish=False,
|
|
246
|
+
source="planned_build",
|
|
247
|
+
reference=_predict_artifact_reference(
|
|
248
|
+
target=target,
|
|
249
|
+
artifact_type=artifact_type,
|
|
250
|
+
deploy_name=deploy_name,
|
|
251
|
+
region=region,
|
|
252
|
+
account_id=account_id,
|
|
253
|
+
ks3_bucket=ks3_bucket,
|
|
254
|
+
registry=registry,
|
|
255
|
+
),
|
|
256
|
+
reference_is_predicted=True,
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
if plan.should_build:
|
|
260
|
+
return replace(
|
|
261
|
+
plan,
|
|
262
|
+
will_build=True,
|
|
263
|
+
should_publish=bool(target == "serverless"),
|
|
264
|
+
will_publish=bool(target == "serverless"),
|
|
265
|
+
source="built",
|
|
266
|
+
reference=plan.reference,
|
|
267
|
+
reference_is_predicted=False,
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
return replace(
|
|
271
|
+
plan,
|
|
272
|
+
should_build=False,
|
|
273
|
+
will_build=False,
|
|
274
|
+
should_publish=False,
|
|
275
|
+
will_publish=False,
|
|
276
|
+
source=plan.source or "external",
|
|
277
|
+
reference=plan.reference or "",
|
|
278
|
+
reference_is_predicted=False,
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def _plan_step_reason(*, source: str, explicit_ref_option: str | None, is_predicted: bool) -> str:
|
|
283
|
+
"""Explain why a workflow plan step will run, be skipped, or be predicted."""
|
|
284
|
+
if is_predicted:
|
|
285
|
+
return "dry_run_prediction"
|
|
286
|
+
if source == "cached":
|
|
287
|
+
return "cache_hit"
|
|
288
|
+
if source == "external":
|
|
289
|
+
return "explicit_reference" if explicit_ref_option else "external_artifact"
|
|
290
|
+
return ""
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def _artifact_source_label(source: str | None) -> str:
|
|
294
|
+
return {
|
|
295
|
+
"planned_build": "预测构建产物",
|
|
296
|
+
"built": "本地构建产物",
|
|
297
|
+
"cached": "缓存制品",
|
|
298
|
+
"external": "外部制品",
|
|
299
|
+
}.get(str(source or "").strip(), str(source or "-"))
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
def _step_status(step: dict[str, Any]) -> str:
|
|
303
|
+
if step.get("will_run"):
|
|
304
|
+
return "执行"
|
|
305
|
+
if step.get("planned"):
|
|
306
|
+
return "仅计划"
|
|
307
|
+
return "跳过"
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def _step_reason_label(reason: str | None) -> str:
|
|
311
|
+
return {
|
|
312
|
+
"dry_run_prediction": "Dry Run 仅展示预期动作",
|
|
313
|
+
"cache_hit": "命中缓存",
|
|
314
|
+
"explicit_reference": "已显式指定外部制品",
|
|
315
|
+
"external_artifact": "使用外部制品",
|
|
316
|
+
}.get(str(reason or "").strip(), "")
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
def _request_body_summary(body: Any) -> str:
|
|
320
|
+
if body is None:
|
|
321
|
+
return "-"
|
|
322
|
+
if isinstance(body, dict):
|
|
323
|
+
keys = [str(key) for key in body.keys()]
|
|
324
|
+
if not keys:
|
|
325
|
+
return "{}"
|
|
326
|
+
return ", ".join(keys[:8]) + (" ..." if len(keys) > 8 else "")
|
|
327
|
+
if isinstance(body, list):
|
|
328
|
+
return f"list[{len(body)}]"
|
|
329
|
+
return type(body).__name__
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
def _request_header_summary(headers: Any) -> str:
|
|
333
|
+
if not isinstance(headers, dict):
|
|
334
|
+
return "-"
|
|
335
|
+
keys = [str(key) for key in headers.keys()]
|
|
336
|
+
return ", ".join(keys[:6]) + (" ..." if len(keys) > 6 else "") if keys else "-"
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
def _summarize_plan_steps(steps: Sequence[dict[str, Any]]) -> tuple[str, str, str]:
|
|
340
|
+
executed = [str(step.get("name") or "-") for step in steps if step.get("will_run")]
|
|
341
|
+
planned = [str(step.get("name") or "-") for step in steps if step.get("planned")]
|
|
342
|
+
skipped = [str(step.get("name") or "-") for step in steps if not step.get("will_run") and not step.get("planned")]
|
|
343
|
+
return (
|
|
344
|
+
", ".join(executed) or "-",
|
|
345
|
+
", ".join(planned) or "-",
|
|
346
|
+
", ".join(skipped) or "-",
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
def clear_build_metadata(project_dir: Path) -> bool:
|
|
351
|
+
"""Clear persisted build metadata, returning whether removal happened."""
|
|
352
|
+
metadata_file = project_dir / ".agentengine" / "build-metadata.json"
|
|
353
|
+
if not metadata_file.exists():
|
|
354
|
+
return False
|
|
355
|
+
metadata_file.unlink()
|
|
356
|
+
return True
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
def load_cached_artifact_reference(project_dir: Path, artifact_type: str | None) -> str | None:
|
|
360
|
+
"""Load a cached artifact reference from build metadata when available."""
|
|
361
|
+
metadata_file = project_dir / ".agentengine" / "build-metadata.json"
|
|
362
|
+
if not metadata_file.exists():
|
|
363
|
+
return None
|
|
364
|
+
|
|
365
|
+
try:
|
|
366
|
+
payload = json.loads(metadata_file.read_text(encoding="utf-8"))
|
|
367
|
+
except Exception:
|
|
368
|
+
return None
|
|
369
|
+
|
|
370
|
+
metadata = payload.get("metadata") or {}
|
|
371
|
+
normalized_artifact_type = (artifact_type or "Code").strip().lower()
|
|
372
|
+
if normalized_artifact_type == "container":
|
|
373
|
+
value = payload.get("image") or metadata.get("image")
|
|
374
|
+
else:
|
|
375
|
+
value = metadata.get("ks3_path")
|
|
376
|
+
normalized = str(value or "").strip()
|
|
377
|
+
return normalized or None
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
def print_workflow_header(
|
|
381
|
+
*,
|
|
382
|
+
title: str,
|
|
383
|
+
subtitle: str,
|
|
384
|
+
project_dir: Path,
|
|
385
|
+
target: str | None = None,
|
|
386
|
+
region: str | None = None,
|
|
387
|
+
mode_label: str | None = None,
|
|
388
|
+
mode_value: str | None = None,
|
|
389
|
+
account_id: str | None = None,
|
|
390
|
+
observability: bool | None = None,
|
|
391
|
+
) -> None:
|
|
392
|
+
"""Print a unified workflow header block."""
|
|
393
|
+
print_title(title, subtitle)
|
|
394
|
+
print_kv("项目目录", str(project_dir))
|
|
395
|
+
if target:
|
|
396
|
+
print_kv("目标", target)
|
|
397
|
+
if region:
|
|
398
|
+
print_kv("区域", region, value_style="#58a6ff")
|
|
399
|
+
if mode_label and mode_value:
|
|
400
|
+
print_kv(mode_label, mode_value)
|
|
401
|
+
if observability is not None:
|
|
402
|
+
print_kv("可观测性", "开启" if observability else "关闭")
|
|
403
|
+
if account_id:
|
|
404
|
+
print_kv("账号 ID", account_id)
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
def emit_no_cache_hint(*, plan: ArtifactBuildPlan, no_cache: bool) -> None:
|
|
408
|
+
"""Emit standardized no-cache behavior hints."""
|
|
409
|
+
if not no_cache:
|
|
410
|
+
return
|
|
411
|
+
if plan.explicit_ref_option:
|
|
412
|
+
print_warn(f"已显式指定 {plan.explicit_ref_option},--no-cache 不会重建外部制品")
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
def print_agent_next_steps(agent_ref: str, *, title: str | None = None) -> None:
|
|
416
|
+
"""Print canonical next-step hints for deployed agents."""
|
|
417
|
+
steps = [
|
|
418
|
+
f"agentengine agent status --agent {agent_ref}",
|
|
419
|
+
f"agentengine agent invoke --agent {agent_ref}",
|
|
420
|
+
]
|
|
421
|
+
if title:
|
|
422
|
+
print_next_steps(steps, title=title)
|
|
423
|
+
else:
|
|
424
|
+
print_next_steps(steps)
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
def build_workflow_result_envelope(
|
|
428
|
+
*,
|
|
429
|
+
action: str,
|
|
430
|
+
result: dict[str, Any],
|
|
431
|
+
hints: Sequence[str] | None = None,
|
|
432
|
+
) -> dict[str, Any]:
|
|
433
|
+
return {
|
|
434
|
+
"ok": True,
|
|
435
|
+
"kind": "result",
|
|
436
|
+
"resource": "workflow",
|
|
437
|
+
"action": action,
|
|
438
|
+
"result": dict(result),
|
|
439
|
+
"hints": list(hints or []),
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
def build_workflow_dry_run_envelope(
|
|
444
|
+
*,
|
|
445
|
+
action: str,
|
|
446
|
+
request: dict[str, Any],
|
|
447
|
+
plan: dict[str, Any] | None = None,
|
|
448
|
+
hints: Sequence[str] | None = None,
|
|
449
|
+
) -> dict[str, Any]:
|
|
450
|
+
envelope = {
|
|
451
|
+
"ok": True,
|
|
452
|
+
"kind": "dry_run",
|
|
453
|
+
"resource": "workflow",
|
|
454
|
+
"action": action,
|
|
455
|
+
"request": sanitize_dry_run_request(request),
|
|
456
|
+
"hints": list(hints or []),
|
|
457
|
+
}
|
|
458
|
+
if plan is not None:
|
|
459
|
+
envelope["plan"] = dict(plan)
|
|
460
|
+
return envelope
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
def render_workflow_result(
|
|
464
|
+
*,
|
|
465
|
+
action: str,
|
|
466
|
+
result: dict[str, Any],
|
|
467
|
+
hints: Sequence[str] | None = None,
|
|
468
|
+
) -> None:
|
|
469
|
+
if is_json_output():
|
|
470
|
+
emit_json(
|
|
471
|
+
build_workflow_result_envelope(
|
|
472
|
+
action=action,
|
|
473
|
+
result=result,
|
|
474
|
+
hints=hints,
|
|
475
|
+
)
|
|
476
|
+
)
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
def render_workflow_dry_run(
|
|
480
|
+
*,
|
|
481
|
+
action: str,
|
|
482
|
+
request: dict[str, Any],
|
|
483
|
+
plan: dict[str, Any] | None = None,
|
|
484
|
+
hints: Sequence[str] | None = None,
|
|
485
|
+
) -> None:
|
|
486
|
+
safe_request = sanitize_dry_run_request(request)
|
|
487
|
+
if is_json_output():
|
|
488
|
+
emit_json(
|
|
489
|
+
build_workflow_dry_run_envelope(
|
|
490
|
+
action=action,
|
|
491
|
+
request=safe_request,
|
|
492
|
+
plan=plan,
|
|
493
|
+
hints=hints,
|
|
494
|
+
)
|
|
495
|
+
)
|
|
496
|
+
return
|
|
497
|
+
|
|
498
|
+
print_title("Dry Run 计划", action)
|
|
499
|
+
if plan:
|
|
500
|
+
print_kv("项目目录", str(plan.get("project_dir") or "-"))
|
|
501
|
+
print_kv("框架", str(plan.get("framework") or "-"))
|
|
502
|
+
print_kv("目标", str(plan.get("target") or "-"))
|
|
503
|
+
if plan.get("region"):
|
|
504
|
+
print_kv("区域", str(plan.get("region")))
|
|
505
|
+
if plan.get("deploy_name"):
|
|
506
|
+
print_kv("部署名称", str(plan.get("deploy_name")))
|
|
507
|
+
artifact = dict(plan.get("artifact") or {})
|
|
508
|
+
steps = list(plan.get("steps") or [])
|
|
509
|
+
executed, planned, skipped = _summarize_plan_steps(steps)
|
|
510
|
+
print_rule("执行摘要")
|
|
511
|
+
print_info("Dry Run 仅展示执行计划,不会执行真实构建、上传或远端写操作。")
|
|
512
|
+
print_kv("本次执行", executed)
|
|
513
|
+
print_kv("仅计划", planned)
|
|
514
|
+
if skipped != "-":
|
|
515
|
+
print_kv("已跳过", skipped)
|
|
516
|
+
|
|
517
|
+
print_rule("本地计划")
|
|
518
|
+
print_kv("制品类型", str(plan.get("artifact_type") or "-"))
|
|
519
|
+
print_kv("需要本地构建", "是" if artifact.get("should_local_build", artifact.get("should_build")) else "否")
|
|
520
|
+
print_kv("会执行本地构建", "是" if artifact.get("will_local_build", artifact.get("will_build")) else "否")
|
|
521
|
+
print_kv("需要发布制品", "是" if artifact.get("should_publish") else "否")
|
|
522
|
+
print_kv("会执行制品发布", "是" if artifact.get("will_publish") else "否")
|
|
523
|
+
if artifact.get("source"):
|
|
524
|
+
print_kv("制品来源", _artifact_source_label(str(artifact.get("source"))))
|
|
525
|
+
if artifact.get("explicit_ref_option"):
|
|
526
|
+
print_kv("外部制品参数", str(artifact.get("explicit_ref_option")))
|
|
527
|
+
if artifact.get("build_dir"):
|
|
528
|
+
print_kv("构建目录", str(artifact.get("build_dir")))
|
|
529
|
+
if artifact.get("reference"):
|
|
530
|
+
print_kv("制品引用", str(artifact.get("reference")))
|
|
531
|
+
if artifact.get("reference_is_predicted"):
|
|
532
|
+
print_kv("引用类型", "预测值")
|
|
533
|
+
print_kv("no-cache", "开启" if plan.get("no_cache") else "关闭")
|
|
534
|
+
if steps:
|
|
535
|
+
print_info("步骤:")
|
|
536
|
+
for step in steps:
|
|
537
|
+
label = str(step.get("name") or "-")
|
|
538
|
+
kind = str(step.get("kind") or "local")
|
|
539
|
+
status = _step_status(step)
|
|
540
|
+
reason = _step_reason_label(str(step.get("reason") or "").strip())
|
|
541
|
+
click.echo(f" - [{kind}] {label}: {status}")
|
|
542
|
+
if reason:
|
|
543
|
+
click.echo(f" 原因: {reason}")
|
|
544
|
+
|
|
545
|
+
print_rule("远端请求")
|
|
546
|
+
print_kv("请求方法", str(safe_request.get("method", "REQUEST")))
|
|
547
|
+
print_kv("请求地址", str(safe_request.get("url", "")))
|
|
548
|
+
print_kv("请求头", _request_header_summary(safe_request.get("headers")))
|
|
549
|
+
print_kv("请求字段", _request_body_summary(safe_request.get("body")))
|
|
550
|
+
if safe_request.get("curl"):
|
|
551
|
+
print_info("Curl:")
|
|
552
|
+
click.echo(str(safe_request["curl"]))
|
ksadk/common/__init__.py
ADDED
ksadk/common/aicp_env.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"""Shared AICP env parsing helpers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import socket
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
DEFAULT_AICP_REGION = "cn-beijing-6"
|
|
10
|
+
DEFAULT_AICP_ENDPOINT = "aicp.api.ksyun.com"
|
|
11
|
+
INTERNAL_AICP_ENDPOINT = "aicp.internal.api.ksyun.com"
|
|
12
|
+
INNER_AICP_ENDPOINT = "aicp.inner.api.ksyun.com"
|
|
13
|
+
PUBLIC_AICP_ENDPOINT = DEFAULT_AICP_ENDPOINT
|
|
14
|
+
|
|
15
|
+
_AICP_ENDPOINTS_BY_MODE = {
|
|
16
|
+
"internal": INTERNAL_AICP_ENDPOINT,
|
|
17
|
+
"inner": INNER_AICP_ENDPOINT,
|
|
18
|
+
"public": PUBLIC_AICP_ENDPOINT,
|
|
19
|
+
}
|
|
20
|
+
_AUTO_AICP_ENDPOINTS = (
|
|
21
|
+
INTERNAL_AICP_ENDPOINT,
|
|
22
|
+
INNER_AICP_ENDPOINT,
|
|
23
|
+
PUBLIC_AICP_ENDPOINT,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _get_nonempty_env(name: str) -> str | None:
|
|
28
|
+
value = os.environ.get(name)
|
|
29
|
+
if value is None:
|
|
30
|
+
return None
|
|
31
|
+
|
|
32
|
+
value = value.strip()
|
|
33
|
+
return value or None
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _endpoint_host(endpoint: str | None) -> str:
|
|
37
|
+
if not endpoint:
|
|
38
|
+
return ""
|
|
39
|
+
|
|
40
|
+
normalized = endpoint.strip().lower()
|
|
41
|
+
if "://" in normalized:
|
|
42
|
+
normalized = normalized.split("://", 1)[1]
|
|
43
|
+
return normalized.split("/", 1)[0]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def is_inner_aicp_endpoint(endpoint: str | None) -> bool:
|
|
47
|
+
return _endpoint_host(endpoint).endswith(".inner.api.ksyun.com")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def is_internal_aicp_endpoint(endpoint: str | None) -> bool:
|
|
51
|
+
return _endpoint_host(endpoint).endswith(".internal.api.ksyun.com")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def is_aicp_kop_endpoint(endpoint: str | None) -> bool:
|
|
55
|
+
host = _endpoint_host(endpoint)
|
|
56
|
+
return (
|
|
57
|
+
host.endswith(".internal.api.ksyun.com")
|
|
58
|
+
or host.endswith(".inner.api.ksyun.com")
|
|
59
|
+
or host.endswith(".api.ksyun.com")
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _is_connectable(endpoint: str, *, timeout: float = 1.0) -> bool:
|
|
64
|
+
normalized = endpoint.strip()
|
|
65
|
+
if "://" in normalized:
|
|
66
|
+
scheme, normalized = normalized.split("://", 1)
|
|
67
|
+
else:
|
|
68
|
+
scheme = "http"
|
|
69
|
+
host = normalized.split("/", 1)[0]
|
|
70
|
+
port = 443 if scheme == "https" else 80
|
|
71
|
+
if ":" in host:
|
|
72
|
+
host, raw_port = host.rsplit(":", 1)
|
|
73
|
+
try:
|
|
74
|
+
port = int(raw_port)
|
|
75
|
+
except ValueError:
|
|
76
|
+
return False
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
with socket.create_connection((host, port), timeout=timeout):
|
|
80
|
+
return True
|
|
81
|
+
except OSError:
|
|
82
|
+
return False
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def resolve_aicp_connection(
|
|
86
|
+
env_prefix: str,
|
|
87
|
+
*,
|
|
88
|
+
default_region: str = DEFAULT_AICP_REGION,
|
|
89
|
+
default_endpoint: str = DEFAULT_AICP_ENDPOINT,
|
|
90
|
+
default_scheme: str = "https",
|
|
91
|
+
) -> dict[str, str]:
|
|
92
|
+
endpoint = _get_nonempty_env(f"{env_prefix}_ENDPOINT")
|
|
93
|
+
if endpoint is None:
|
|
94
|
+
endpoint = _resolve_auto_endpoint(default_endpoint=default_endpoint)
|
|
95
|
+
scheme = _get_nonempty_env(f"{env_prefix}_SCHEME")
|
|
96
|
+
if scheme is None:
|
|
97
|
+
scheme = _default_scheme_for_endpoint(endpoint, default_scheme=default_scheme)
|
|
98
|
+
|
|
99
|
+
region = (
|
|
100
|
+
_get_nonempty_env(f"{env_prefix}_REGION")
|
|
101
|
+
or _get_nonempty_env("KSYUN_REGION")
|
|
102
|
+
or default_region
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
"endpoint": endpoint,
|
|
107
|
+
"scheme": scheme,
|
|
108
|
+
"region": region,
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _resolve_auto_endpoint(*, default_endpoint: str = DEFAULT_AICP_ENDPOINT) -> str:
|
|
113
|
+
mode = (_get_nonempty_env("KSADK_AICP_ENDPOINT_MODE") or "auto").lower()
|
|
114
|
+
if mode in _AICP_ENDPOINTS_BY_MODE:
|
|
115
|
+
return _AICP_ENDPOINTS_BY_MODE[mode]
|
|
116
|
+
if mode not in {"auto", "detect"}:
|
|
117
|
+
return default_endpoint
|
|
118
|
+
|
|
119
|
+
for endpoint in _AUTO_AICP_ENDPOINTS:
|
|
120
|
+
if _is_connectable(endpoint):
|
|
121
|
+
return endpoint
|
|
122
|
+
return default_endpoint
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _default_scheme_for_endpoint(endpoint: str, *, default_scheme: str) -> str:
|
|
126
|
+
if is_internal_aicp_endpoint(endpoint) or is_inner_aicp_endpoint(endpoint):
|
|
127
|
+
return "http"
|
|
128
|
+
return default_scheme
|