agentengine-sdk-python 0.8.0__py3-none-any.whl → 0.8.2__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.8.0.dist-info → agentengine_sdk_python-0.8.2.dist-info}/METADATA +43 -7
- agentengine_sdk_python-0.8.2.dist-info/RECORD +778 -0
- {agentengine_sdk_python-0.8.0.dist-info → agentengine_sdk_python-0.8.2.dist-info}/WHEEL +1 -1
- ksadk/a2a/__init__.py +2 -0
- ksadk/a2a/_space_client_events.py +381 -0
- ksadk/a2a/bootstrap.py +0 -2
- ksadk/a2a/card.py +6 -111
- ksadk/a2a/control_plane.py +239 -1
- ksadk/a2a/event_adapter.py +156 -64
- ksadk/a2a/executor.py +195 -172
- ksadk/a2a/routes.py +12 -5
- ksadk/a2a/server.py +1 -8
- ksadk/a2a/service_env.py +33 -0
- ksadk/a2a/space_client.py +43 -349
- ksadk/a2a_card.py +101 -0
- ksadk/a2ui/core.py +222 -53
- ksadk/agui/_agent_helpers.py +243 -0
- ksadk/agui/a2ui_projection.py +12 -5
- ksadk/agui/agent.py +474 -275
- ksadk/agui/config.py +11 -5
- ksadk/agui/routes.py +7 -15
- ksadk/api/client.py +530 -40
- ksadk/api/environment.py +27 -0
- ksadk/builders/code_builder.py +352 -53
- ksadk/builders/container_builder.py +71 -44
- ksadk/builders/framework_requirements.py +2 -1
- ksadk/builders/ks3_uploader.py +2 -2
- ksadk/builders/managed_runtime_builder.py +60 -28
- ksadk/cli/__init__.py +25 -0
- ksadk/cli/cmd_a2a.py +18 -31
- ksadk/cli/cmd_create.py +13 -26
- ksadk/cli/cmd_dashboard.py +15 -1
- ksadk/cli/cmd_deploy.py +28 -3
- ksadk/cli/cmd_eval.py +443 -0
- ksadk/cli/cmd_evalset.py +284 -0
- ksadk/cli/cmd_files.py +5 -1
- ksadk/cli/cmd_hermes.py +137 -163
- ksadk/cli/cmd_invoke.py +28 -38
- ksadk/cli/cmd_launch.py +12 -0
- ksadk/cli/cmd_managed_runtime.py +95 -0
- ksadk/cli/cmd_observe.py +85 -0
- ksadk/cli/cmd_openclaw.py +85 -479
- ksadk/cli/cmd_replay.py +28 -4
- ksadk/cli/cmd_run.py +29 -67
- ksadk/cli/cmd_studio.py +201 -0
- ksadk/cli/cmd_web.py +15 -6
- ksadk/cli/dry_run.py +2 -1
- ksadk/cli/env_options.py +83 -0
- ksadk/cli/global_options.py +3 -1
- ksadk/cli/hermes_env.py +151 -0
- ksadk/cli/invoke_payload.py +49 -0
- ksadk/cli/network_options.py +7 -5
- ksadk/cli/openclaw_env.py +458 -0
- ksadk/cli/runtime_bootstrap.py +51 -0
- ksadk/cli/ui.py +6 -0
- ksadk/cli/workflow_common.py +5 -5
- ksadk/codex/__init__.py +3 -3
- ksadk/codex/client.py +833 -49
- ksadk/codex/phase.py +1 -1
- ksadk/codex/runtime.py +720 -127
- ksadk/common/kop_client.py +232 -0
- ksadk/configs/__init__.py +1 -3
- ksadk/configs/env_registry.py +244 -45
- ksadk/configs/env_registry_pcm.py +181 -0
- ksadk/configs/env_var_spec.py +18 -0
- ksadk/configs/global_config.py +6 -1
- ksadk/configs/settings.py +5 -108
- ksadk/context_engine/__init__.py +98 -0
- ksadk/context_engine/assembler.py +176 -0
- ksadk/context_engine/baseline.py +419 -0
- ksadk/context_engine/cache_observability.py +228 -0
- ksadk/context_engine/capabilities.py +443 -0
- ksadk/context_engine/contributors.py +344 -0
- ksadk/context_engine/hosted_pipeline.py +417 -0
- ksadk/context_engine/models.py +117 -0
- ksadk/context_engine/planner.py +698 -0
- ksadk/context_engine/policies.py +319 -0
- ksadk/context_engine/projection.py +31 -0
- ksadk/context_engine/shadow_plan.py +266 -0
- ksadk/context_engine/tokenizer.py +164 -0
- ksadk/conversations/__init__.py +85 -94
- ksadk/conversations/context.py +126 -6
- ksadk/conversations/message_projection.py +292 -28
- ksadk/conversations/model_context.py +49 -3
- ksadk/conversations/runtime_compaction.py +207 -5
- ksadk/conversations/runtime_input.py +193 -3
- ksadk/conversations/runtime_invocation.py +81 -3
- ksadk/conversations/runtime_observability.py +157 -4
- ksadk/conversations/runtime_payloads.py +42 -0
- ksadk/conversations/runtime_preparation.py +280 -2
- ksadk/conversations/runtime_resume.py +71 -32
- ksadk/conversations/runtime_stream_events.py +94 -9
- ksadk/conversations/runtime_streaming.py +175 -22
- ksadk/conversations/semantic_summary.py +311 -1
- ksadk/conversations/session_lock.py +51 -0
- ksadk/deployment/env_forward.py +72 -0
- ksadk/deployment/managed_runtime.py +38 -0
- ksadk/deployment/manager.py +24 -8
- ksadk/deployment/providers/serverless.py +228 -92
- ksadk/evaluation/__init__.py +116 -0
- ksadk/evaluation/a2a_adapter.py +452 -0
- ksadk/evaluation/adapters.py +67 -0
- ksadk/evaluation/agent_eval_client.py +395 -0
- ksadk/evaluation/cloud_binding.py +80 -0
- ksadk/evaluation/cloud_converter.py +194 -0
- ksadk/evaluation/cloud_service.py +199 -0
- ksadk/evaluation/contracts.py +478 -0
- ksadk/evaluation/evalset.py +351 -0
- ksadk/evaluation/evaluators.py +627 -0
- ksadk/evaluation/evidence.py +258 -0
- ksadk/evaluation/executor.py +143 -0
- ksadk/evaluation/local_adapter.py +550 -0
- ksadk/evaluation/service_env.py +27 -0
- ksadk/evaluation/storage.py +68 -0
- ksadk/evaluation/studio_build_adapter.py +253 -0
- ksadk/evaluation/target.py +82 -0
- ksadk/events/__init__.py +13 -13
- ksadk/events/_v1_compat/__init__.py +1 -0
- ksadk/events/_v1_compat/models.py +299 -0
- ksadk/events/_v1_compat/parser.py +247 -0
- ksadk/events/_v1_compat/projection.py +753 -0
- ksadk/events/adapters/__init__.py +34 -0
- ksadk/events/adapters/_a2a_snapshot.py +622 -0
- ksadk/events/adapters/_a2a_support.py +275 -0
- ksadk/events/adapters/_codex_interactions.py +375 -0
- ksadk/events/adapters/_codex_items.py +801 -0
- ksadk/events/adapters/_codex_validators.py +311 -0
- ksadk/events/adapters/_langgraph_support.py +785 -0
- ksadk/events/adapters/a2a.py +841 -0
- ksadk/events/adapters/adk.py +503 -0
- ksadk/events/adapters/codex.py +717 -0
- ksadk/events/adapters/langgraph.py +745 -0
- ksadk/events/canonical.py +440 -0
- ksadk/events/canonical_replay.py +497 -0
- ksadk/events/canonical_store.py +468 -0
- ksadk/events/cold_recovery.py +257 -0
- ksadk/events/content.py +89 -0
- ksadk/events/identity.py +86 -0
- ksadk/events/pipeline.py +455 -0
- ksadk/events/projections.py +66 -0
- ksadk/events/reducer.py +661 -0
- ksadk/events/replay.py +3 -36
- ksadk/events/runtime_event.py +20 -256
- ksadk/events/session_event.py +324 -0
- ksadk/events/store.py +3 -316
- ksadk/events/v1_compat.py +41 -0
- ksadk/harness/__init__.py +3 -2
- ksadk/harness/app.py +114 -123
- ksadk/harness/config.py +1 -1
- ksadk/harness/runtime.py +467 -0
- ksadk/hermes_terminal.py +5 -0
- ksadk/identity/resolver.py +4 -3
- ksadk/interaction/__init__.py +28 -0
- ksadk/interaction/contracts.py +136 -0
- ksadk/interaction/ledger.py +189 -0
- ksadk/interaction/provider.py +122 -0
- ksadk/interaction/providers/__init__.py +52 -0
- ksadk/interaction/providers/adk.py +40 -0
- ksadk/interaction/providers/codex.py +94 -0
- ksadk/interaction/providers/langgraph.py +58 -0
- ksadk/kernel/__init__.py +117 -0
- ksadk/kernel/authorization.py +258 -0
- ksadk/kernel/bootstrap.py +1074 -0
- ksadk/kernel/contract_fingerprints.py +61 -0
- ksadk/kernel/contracts.py +362 -0
- ksadk/kernel/control.py +219 -0
- ksadk/kernel/errors.py +79 -0
- ksadk/kernel/ingress.py +1102 -0
- ksadk/kernel/mapping.py +111 -0
- ksadk/kernel/memory_store.py +1133 -0
- ksadk/kernel/postgres_store.py +1756 -0
- ksadk/kernel/recovery.py +452 -0
- ksadk/kernel/runtime_identity.py +103 -0
- ksadk/kernel/sql/001_agent_kernel.sql +120 -0
- ksadk/kernel/sqlite_store.py +1410 -0
- ksadk/kernel/state.py +145 -0
- ksadk/kernel/store.py +232 -0
- ksadk/kernel/worker.py +953 -0
- ksadk/knowledge_base/client.py +22 -4
- ksadk/knowledge_base/service.py +32 -5
- ksadk/managed_a2a_card.py +160 -0
- ksadk/managed_runtime.py +16 -9
- ksadk/memory/__init__.py +61 -0
- ksadk/memory/adk/backends/base_ltm_backend.py +96 -1
- ksadk/memory/adk/backends/http_ltm_backend.py +14 -5
- ksadk/memory/adk/backends/inmemory_ltm_backend.py +136 -3
- ksadk/memory/adk/backends/sdk_ltm_backend.py +394 -5
- ksadk/memory/adk/backends/sqlite_ltm_backend.py +95 -0
- ksadk/memory/adk/long_term_memory.py +3 -2
- ksadk/memory/coordinator.py +461 -0
- ksadk/memory/events.py +202 -0
- ksadk/memory/extraction.py +228 -0
- ksadk/memory/ltm_backend_factory.py +16 -3
- ksadk/memory/models.py +316 -0
- ksadk/memory/policy.py +215 -0
- ksadk/memory/provider.py +47 -0
- ksadk/memory/provider_adapter.py +159 -0
- ksadk/memory/provider_resolver.py +71 -0
- ksadk/memory/providers/__init__.py +5 -0
- ksadk/memory/providers/local_sqlite.py +490 -0
- ksadk/memory/resolved_policy.py +145 -0
- ksadk/memory/service.py +198 -8
- ksadk/memory/tool.py +4 -0
- ksadk/model_proxy/bootstrap.py +16 -9
- ksadk/model_proxy/config.py +22 -1
- ksadk/model_proxy/detect.py +202 -9
- ksadk/model_proxy/namespace.py +67 -15
- ksadk/model_proxy/server.py +168 -6
- ksadk/model_proxy/transform.py +105 -3
- ksadk/observability/__init__.py +25 -0
- ksadk/observability/session_log.py +420 -0
- ksadk/observability/trajectory.py +105 -0
- ksadk/prompts/__init__.py +71 -0
- ksadk/prompts/compiler.py +215 -0
- ksadk/prompts/models.py +82 -0
- ksadk/prompts/projection.py +89 -0
- ksadk/prompts/resolved.py +137 -0
- ksadk/prompts/sources.py +233 -0
- ksadk/runners/_langgraph_runner_streams.py +822 -0
- ksadk/runners/adk_runner.py +14 -31
- ksadk/runners/base_runner.py +44 -3
- ksadk/runners/factory.py +3 -3
- ksadk/runners/langgraph_runner.py +252 -433
- ksadk/runners/utils/__init__.py +0 -10
- ksadk/runners/utils/loader.py +16 -0
- ksadk/runtime/__init__.py +67 -41
- ksadk/runtime/_runner_adapter/__init__.py +1 -0
- ksadk/runtime/_runner_adapter/stream_mapping.py +788 -0
- ksadk/runtime/adapter.py +199 -16
- ksadk/runtime/conversation_execution.py +687 -0
- ksadk/runtime/executor.py +392 -0
- ksadk/runtime/factory.py +342 -0
- ksadk/runtime/framework_adapters.py +6 -12
- ksadk/runtime/hosted_finalizer.py +268 -0
- ksadk/runtime/launch.py +61 -0
- ksadk/runtime/preprocessing.py +49 -14
- ksadk/runtime/runner_adapter.py +330 -391
- ksadk/runtime/runner_loading.py +36 -0
- ksadk/runtime/usage.py +33 -0
- ksadk/sandbox/backends/e2b.py +36 -3
- ksadk/server/__init__.py +39 -4
- ksadk/server/app.py +18 -492
- ksadk/server/composition.py +36 -2
- ksadk/server/factory.py +210 -149
- ksadk/server/routes/common.py +15 -46
- ksadk/server/routes/control.py +13 -9
- ksadk/server/routes/kernel_ingress.py +258 -0
- ksadk/server/routes/misc.py +10 -33
- ksadk/server/routes/models.py +14 -6
- ksadk/server/routes/openai_compat.py +129 -27
- ksadk/server/routes/projection.py +84 -16
- ksadk/server/routes/run.py +347 -460
- ksadk/server/routes/sessions.py +37 -40
- ksadk/server/routes/streaming.py +52 -7
- ksadk/server/routes/workspace.py +54 -21
- ksadk/server/static/assets/{ArtifactsPanel-Cjnqt-8W.js → ArtifactsPanel-DSU1sWD_.js} +1 -1
- ksadk/server/static/assets/{CodeBlock-BqyqZfuB.js → CodeBlock-DOH6MVcn.js} +4 -4
- ksadk/server/static/assets/{MathMessageMarkdown-BpH7jiFM.js → MathMessageMarkdown-BL8my1R2.js} +4 -4
- ksadk/server/static/assets/MathMessageMarkdown-BorAY7qD.css +1 -0
- ksadk/server/static/assets/MermaidBlock-Dz4IP-Tx.js +312 -0
- ksadk/server/static/assets/NativeTerminalPanel-DUrK0JpZ.js +1 -0
- ksadk/server/static/assets/abnfDiagram-VCTEODGH-g20pFzNV.js +1 -0
- ksadk/server/static/assets/arc-C4FzinUA.js +1 -0
- ksadk/server/static/assets/architecture-7GRP2DOG-DjKratdf.js +1 -0
- ksadk/server/static/assets/architectureDiagram-5GKGNRK7-DpIqL5h4.js +36 -0
- ksadk/server/static/assets/blockDiagram-NRAW4CY4-BjkljTNz.js +129 -0
- ksadk/server/static/assets/c4Diagram-UCG6FXSJ-Dk_ieq2X.js +38 -0
- ksadk/server/static/assets/channel-4cQHKtx1.js +1 -0
- ksadk/server/static/assets/chunk-2Q5K7J3B-DmgWkESh.js +1 -0
- ksadk/server/static/assets/{chunk-FMBD7UC4-BGhvzDYt.js → chunk-5VM5RSS4-BVHAchFb.js} +1 -1
- ksadk/server/static/assets/{chunk-ND2GUHAM-D98vPd-E.js → chunk-F27PBJKO-C-ipQzuS.js} +1 -1
- ksadk/server/static/assets/chunk-G27WJ6UU-C2EyJbIK.js +231 -0
- ksadk/server/static/assets/{chunk-4BX2VUAB-CsWIQRhc.js → chunk-JWPE2WC7-vYvVJb_M.js} +1 -1
- ksadk/server/static/assets/chunk-LCL6LL3I-BcI6ysPT.js +206 -0
- ksadk/server/static/assets/chunk-POPQ4Y6H-C030x_Z1.js +1 -0
- ksadk/server/static/assets/chunk-RHFEMEQ7-yyGpsz4n.js +168 -0
- ksadk/server/static/assets/chunk-SVP7TREG-BLTlmMU7.js +88 -0
- ksadk/server/static/assets/chunk-XXDRQBXY-C_32ArgP.js +1 -0
- ksadk/server/static/assets/classDiagram-DTDB5LWJ-DLFd9Xi0.js +1 -0
- ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-DLFd9Xi0.js +1 -0
- ksadk/server/static/assets/{cose-bilkent-S5V4N54A-CX3yotHq.js → cose-bilkent-JH36ORCC-9YQYwdl0.js} +1 -1
- ksadk/server/static/assets/cynefin-OW5HDTMX-DjEM48Qp.js +1 -0
- ksadk/server/static/assets/cynefinDiagram-5FMLGOSQ-ErLF5N13.js +62 -0
- ksadk/server/static/assets/cytoscape.esm-CyCl8rPi.js +321 -0
- ksadk/server/static/assets/dagre-3AP2YEHR-DFiQF-6f.js +4 -0
- ksadk/server/static/assets/dagre-BuhGnRI1.js +1 -0
- ksadk/server/static/assets/diagram-S7CK7UJ4-Bt1v8-GC.js +30 -0
- ksadk/server/static/assets/diagram-UQ7AKVKN-DSCxJdBK.js +41 -0
- ksadk/server/static/assets/diagram-VSXAHHWV-DHfYwp_9.js +3 -0
- ksadk/server/static/assets/diagram-VX7I27RA-DdzD-4Le.js +24 -0
- ksadk/server/static/assets/diagram-Z3DM3KII-Du-nAJ9F.js +24 -0
- ksadk/server/static/assets/{dist-D82mtD2s.js → dist-8hqcx0sU.js} +1 -1
- ksadk/server/static/assets/dist-B7seoj3d.js +1 -0
- ksadk/server/static/assets/{dist-DHn6nBzr.js → dist-BE7bu-DL.js} +1 -1
- ksadk/server/static/assets/{dist-eoW6tZXA.js → dist-BVDffZ0U.js} +1 -1
- ksadk/server/static/assets/{dist-C2xjE7cO.js → dist-BX8z72IC.js} +1 -1
- ksadk/server/static/assets/{dist-CgF3fj15.js → dist-Bf2M8m3N.js} +1 -1
- ksadk/server/static/assets/{dist-Bs-jQcRX.js → dist-BjU6y-A2.js} +1 -1
- ksadk/server/static/assets/{dist-Djgl2wVZ.js → dist-BytlxIDT.js} +1 -1
- ksadk/server/static/assets/{dist-CVQRZjPu.js → dist-CSh_DE14.js} +1 -1
- ksadk/server/static/assets/{dist-6CVKuTAe.js → dist-CXYYBw3_.js} +1 -1
- ksadk/server/static/assets/{dist-DlzCRy0S.js → dist-C_wsv-Qd.js} +1 -1
- ksadk/server/static/assets/{dist-DF06ORQo.js → dist-ClxGviKw.js} +1 -1
- ksadk/server/static/assets/{dist-Cf23NY4L.js → dist-CttYUqzS.js} +1 -1
- ksadk/server/static/assets/{dist-ivOya1LD.js → dist-DNp6rLRA.js} +1 -1
- ksadk/server/static/assets/{dist-BibcG1V9.js → dist-DUX-id_F.js} +1 -1
- ksadk/server/static/assets/{dist-BUHRxvDG.js → dist-DmldrHd_.js} +1 -1
- ksadk/server/static/assets/{dist-BZ9n9AjO.js → dist-DnfXs8Vn.js} +2 -2
- ksadk/server/static/assets/{dist-DqNnNFrw.js → dist-Dq9gLD7L.js} +1 -1
- ksadk/server/static/assets/{dist-CGcp2ex8.js → dist-W-TIVntx.js} +1 -1
- ksadk/server/static/assets/{dist-Cwt7koer.js → dist-dDdADKFA.js} +1 -1
- ksadk/server/static/assets/{dist-C7-3jInC.js → dist-dydu68Fl.js} +1 -1
- ksadk/server/static/assets/{dist-C99THtIA.js → dist-ngtN0DJB.js} +1 -1
- ksadk/server/static/assets/ebnfDiagram-PWID7BFC-Da9C9NO1.js +1 -0
- ksadk/server/static/assets/erDiagram-SSCWMZ5O-EAGqqR79.js +99 -0
- ksadk/server/static/assets/eventmodeling-NTZA5JFV-CMgMaJrC.js +1 -0
- ksadk/server/static/assets/flowDiagram-A5DVABFB-BBKL0x3P.js +1 -0
- ksadk/server/static/assets/ganttDiagram-EL5Y4UJY-DqJsKb59.js +292 -0
- ksadk/server/static/assets/gitGraph-4MIJSDKK-Dw63mrhw.js +1 -0
- ksadk/server/static/assets/gitGraphDiagram-WWUBYQGX-B6g4dtDi.js +106 -0
- ksadk/server/static/assets/index-8ipRcQ-M.js +240 -0
- ksadk/server/static/assets/index-ByFCqjlh.css +2 -0
- ksadk/server/static/assets/info-A6RAGUB7-B6iAblII.js +1 -0
- ksadk/server/static/assets/infoDiagram-RXCK75RN-Djm_nbd5.js +2 -0
- ksadk/server/static/assets/{ishikawaDiagram-YF4QCWOH-DLOHGvWw.js → ishikawaDiagram-5VMMS53U-DWya9SG2.js} +6 -6
- ksadk/server/static/assets/{journeyDiagram-JHISSGLW-BIzKeejT.js → journeyDiagram-EYS64GPL-DutxhSNI.js} +6 -6
- ksadk/server/static/assets/{kanban-definition-UN3LZRKU-BWHoFSw2.js → kanban-definition-3QL26DDD-DJdOF8Fm.js} +10 -10
- ksadk/server/static/assets/katex-vFWytM5c.js +257 -0
- ksadk/server/static/assets/{linear-CvMBw9cA.js → linear-BHjG8b-J.js} +1 -1
- ksadk/server/static/assets/mermaid-parser.core-KGSy4jWT.js +166 -0
- ksadk/server/static/assets/{mindmap-definition-RKZ34NQL-CSAQxEAe.js → mindmap-definition-FBJOCRG2-9-HC88D4.js} +29 -29
- ksadk/server/static/assets/packet-AYTQ26CC-BOYAipuq.js +1 -0
- ksadk/server/static/assets/pegDiagram-XKGWAZYB-DrEZd4fD.js +1 -0
- ksadk/server/static/assets/pie-WAS4IAKB-Ctq0Kbku.js +1 -0
- ksadk/server/static/assets/pieDiagram-E7YTZNPT-DpjqOFFp.js +39 -0
- ksadk/server/static/assets/{quadrantDiagram-W4KKPZXB-CxIR4JXI.js → quadrantDiagram-AXDQQJYC-BiNhgOXX.js} +6 -6
- ksadk/server/static/assets/radar-RG4KPBEZ-DN0-ul_0.js +1 -0
- ksadk/server/static/assets/railroad-74A4TZTK-C6cC_to0.js +1 -0
- ksadk/server/static/assets/railroad-abnf-HS5TGJTU-BimjIuRc.js +1 -0
- ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-CvY65ABq.js +1 -0
- ksadk/server/static/assets/railroad-peg-WCYAUIDC-D72Iq_Tv.js +1 -0
- ksadk/server/static/assets/railroadDiagram-O6MQD6OU-_Y3Ojg6G.js +1 -0
- ksadk/server/static/assets/requirementDiagram-EFPCY7ZU-DeCFdg9K.js +84 -0
- ksadk/server/static/assets/{sankeyDiagram-5OEKKPKP-DpGa6EAV.js → sankeyDiagram-P5KCCOFB-CPH75rhw.js} +7 -7
- ksadk/server/static/assets/{sequenceDiagram-3UESZ5HK-NTKNGGe5.js → sequenceDiagram-WJ2MYXX4-OEpQQdr4.js} +10 -10
- ksadk/server/static/assets/sizeCapture-X5ZJPWSS-heUErzhI.js +1 -0
- ksadk/server/static/assets/stateDiagram-HBIQ2CUA-DvA3jSMB.js +1 -0
- ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-BgQY03nz.js +1 -0
- ksadk/server/static/assets/swimlanes-XN3QIQJK-CR-dfN_t.js +1 -0
- ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-DLVw3q5Q.js +8 -0
- ksadk/server/static/assets/{timeline-definition-PNZ67QCA-jqoYs3jQ.js → timeline-definition-24CTP7MA-DAVJf1TX.js} +7 -7
- ksadk/server/static/assets/treeView-Q6P3EWNA-BMpO0wsB.js +1 -0
- ksadk/server/static/assets/treemap-WGGIJYW6-Et0aqzU3.js +1 -0
- ksadk/server/static/assets/vennDiagram-4TSXK5OY-DwM8eDkh.js +34 -0
- ksadk/server/static/assets/wardley-WFR3VGLG-CbY0mhpl.js +1 -0
- ksadk/server/static/assets/wardleyDiagram-VM6X3IG4-DZL-Zz2t.js +78 -0
- ksadk/server/static/assets/xychartDiagram-S5SC5T6Z-Dy6Yh_hu.js +7 -0
- ksadk/server/static/index.html +2 -2
- ksadk/sessions/__init__.py +26 -9
- ksadk/sessions/_local_service_sync.py +688 -0
- ksadk/sessions/_local_tables.py +21 -0
- ksadk/sessions/_postgres_schema.py +305 -0
- ksadk/sessions/_postgres_tables.py +15 -0
- ksadk/sessions/base.py +80 -1
- ksadk/sessions/in_memory.py +53 -2
- ksadk/sessions/local_service.py +63 -604
- ksadk/sessions/postgres_service.py +58 -148
- ksadk/sessions/resilient.py +35 -1
- ksadk/skills/runtime/backends/e2b.py +1 -1
- ksadk/skills/service_client.py +13 -3
- ksadk/studio/__init__.py +5 -0
- ksadk/studio/agent_avatar_assets.py +120 -0
- ksadk/studio/agent_lifecycle.py +51 -0
- ksadk/studio/api.py +1598 -0
- ksadk/studio/api_catalog_routes.py +324 -0
- ksadk/studio/api_contracts.py +286 -0
- ksadk/studio/api_helpers.py +132 -0
- ksadk/studio/api_memory_routes.py +82 -0
- ksadk/studio/authoring.py +749 -0
- ksadk/studio/authoring_coordinator.py +1017 -0
- ksadk/studio/builder.py +397 -0
- ksadk/studio/capabilities.py +368 -0
- ksadk/studio/cloud.py +2099 -0
- ksadk/studio/codex_agent_service.py +694 -0
- ksadk/studio/codex_authoring.py +469 -0
- ksadk/studio/codex_builder.py +437 -0
- ksadk/studio/codex_manifest.py +307 -0
- ksadk/studio/codex_run.py +395 -0
- ksadk/studio/compiler.py +190 -0
- ksadk/studio/contracts.py +755 -0
- ksadk/studio/errors.py +47 -0
- ksadk/studio/event_store.py +214 -0
- ksadk/studio/framework_run.py +342 -0
- ksadk/studio/hosted_kernel.py +317 -0
- ksadk/studio/identifiers.py +33 -0
- ksadk/studio/manifest_resolver.py +131 -0
- ksadk/studio/mcp_runtime.py +229 -0
- ksadk/studio/model_client.py +629 -0
- ksadk/studio/model_profile_service.py +214 -0
- ksadk/studio/operations.py +275 -0
- ksadk/studio/otel_trace.py +1060 -0
- ksadk/studio/pagination.py +182 -0
- ksadk/studio/pcm_memory.py +85 -0
- ksadk/studio/python_tool_inspection.py +183 -0
- ksadk/studio/repository.py +327 -0
- ksadk/studio/resource_catalog.py +1260 -0
- ksadk/studio/run_service.py +1133 -0
- ksadk/studio/runtime_catalog.py +74 -0
- ksadk/studio/runtime_source.py +365 -0
- ksadk/studio/service.py +2249 -0
- ksadk/studio/shared_web.py +1004 -0
- ksadk/studio/skill_discovery.py +628 -0
- ksadk/studio/static/assets/PrismRenderer-IYN-ffww.js +3 -0
- ksadk/studio/static/assets/index-BLpcdrgW.css +1 -0
- ksadk/studio/static/assets/index-CYekR2Xv.js +260 -0
- ksadk/studio/static/assets/react-vendor-BNmTiJ-I.js +9 -0
- ksadk/studio/static/assets/rolldown-runtime-hePW80VL.js +1 -0
- ksadk/studio/static/index.html +15 -0
- ksadk/studio/templates.py +722 -0
- ksadk/studio/validator.py +265 -0
- ksadk/studio/workspace.py +135 -0
- ksadk/tools/gateway.py +9 -0
- ksadk/toolsets/__init__.py +27 -1
- ksadk/toolsets/a2a.py +426 -0
- ksadk/tracing/__init__.py +19 -21
- ksadk/tracing/setup.py +317 -403
- ksadk/tracing/span_utils.py +0 -44
- ksadk/version.py +1 -1
- ksadk_runtime_common/memory_backend/registry.py +56 -56
- ksadk_runtime_common/schemas/runtime_event_v1.json +37 -0
- ksadk_runtime_common/schemas/runtime_event_v2.json +271 -0
- ksadk_runtime_common/workspace_files/router.py +8 -2
- agentengine_sdk_python-0.8.0.dist-info/RECORD +0 -578
- ksadk/a2a/card_builder.py +0 -64
- ksadk/a2a/client.py +0 -309
- ksadk/events/parser.py +0 -191
- ksadk/harness/runner.py +0 -211
- ksadk/runners/codex_runner.py +0 -132
- ksadk/runners/utils/langfuse.py +0 -230
- ksadk/server/static/assets/MathMessageMarkdown-DeYh8QPr.css +0 -1
- ksadk/server/static/assets/MermaidBlock-DWuxETaJ.js +0 -303
- ksadk/server/static/assets/NativeTerminalPanel-MDTopWMO.js +0 -1
- ksadk/server/static/assets/arc-CFKwSk_B.js +0 -1
- ksadk/server/static/assets/architecture-7EHR7CIX-CynqOWjZ.js +0 -1
- ksadk/server/static/assets/architectureDiagram-3BPJPVTR-Dej8jX8c.js +0 -36
- ksadk/server/static/assets/blockDiagram-GPEHLZMM-1F64jqvy.js +0 -132
- ksadk/server/static/assets/c4Diagram-AAUBKEIU-9q7AUAKb.js +0 -10
- ksadk/server/static/assets/channel-iUGv2N24.js +0 -1
- ksadk/server/static/assets/chunk-2J33WTMH-6qgwJm7Q.js +0 -1
- ksadk/server/static/assets/chunk-55IACEB6-BK8paA20.js +0 -1
- ksadk/server/static/assets/chunk-727SXJPM-B-JEhy7h.js +0 -206
- ksadk/server/static/assets/chunk-AQP2D5EJ-DYBvMHAa.js +0 -231
- ksadk/server/static/assets/chunk-QZHKN3VN-YQIEXeF6.js +0 -1
- ksadk/server/static/assets/classDiagram-4FO5ZUOK-CDAUuoXK.js +0 -1
- ksadk/server/static/assets/classDiagram-v2-Q7XG4LA2-CDAUuoXK.js +0 -1
- ksadk/server/static/assets/cytoscape.esm-DelgaX4f.js +0 -321
- ksadk/server/static/assets/dagre-BM42HDAG-C7TguAWo.js +0 -4
- ksadk/server/static/assets/dagre-Bx709z4p.js +0 -1
- ksadk/server/static/assets/diagram-2AECGRRQ-Dd17_kws.js +0 -43
- ksadk/server/static/assets/diagram-5GNKFQAL-DVIClIil.js +0 -10
- ksadk/server/static/assets/diagram-KO2AKTUF-Df_3gYQa.js +0 -3
- ksadk/server/static/assets/diagram-LMA3HP47-BhLk6ZtA.js +0 -24
- ksadk/server/static/assets/diagram-OG6HWLK6-D4GNGvuu.js +0 -24
- ksadk/server/static/assets/dist-DyvYLMW9.js +0 -1
- ksadk/server/static/assets/erDiagram-TEJ5UH35-CnfRcY2M.js +0 -85
- ksadk/server/static/assets/eventmodeling-FCH6USID-ChYO-ijM.js +0 -1
- ksadk/server/static/assets/flowDiagram-I6XJVG4X-DGaJjGNJ.js +0 -162
- ksadk/server/static/assets/ganttDiagram-6RSMTGT7-DpCoB2g9.js +0 -292
- ksadk/server/static/assets/gitGraph-WXDBUCRP-BN_0Fk-j.js +0 -1
- ksadk/server/static/assets/gitGraphDiagram-PVQCEYII-9IKVFBVT.js +0 -106
- ksadk/server/static/assets/graphlib-B8gBHxth.js +0 -1
- ksadk/server/static/assets/index-QSwCHuB8.js +0 -177
- ksadk/server/static/assets/index-jOPmTOZH.css +0 -2
- ksadk/server/static/assets/info-J43DQDTF-Cp6o3vId.js +0 -1
- ksadk/server/static/assets/infoDiagram-5YYISTIA-CYIIsb8y.js +0 -2
- ksadk/server/static/assets/katex-DATssjp1.js +0 -265
- ksadk/server/static/assets/mermaid-parser.core-mGAcEwcq.js +0 -161
- ksadk/server/static/assets/packet-YPE3B663-wQzct3cT.js +0 -1
- ksadk/server/static/assets/pie-LRSECV5Y-BgTQiv-9.js +0 -1
- ksadk/server/static/assets/pieDiagram-4H26LBE5-By-ra07M.js +0 -30
- ksadk/server/static/assets/radar-GUYGQ44K-BIq5fXsn.js +0 -1
- ksadk/server/static/assets/requirementDiagram-4Y6WPE33-DpW90iu3.js +0 -84
- ksadk/server/static/assets/stateDiagram-AJRCARHV-DGpd9yFG.js +0 -1
- ksadk/server/static/assets/stateDiagram-v2-BHNVJYJU-B3o579IQ.js +0 -1
- ksadk/server/static/assets/treeView-BLDUP644-Dqi-E0EM.js +0 -1
- ksadk/server/static/assets/treemap-LRROVOQU-ClQP9CJ9.js +0 -1
- ksadk/server/static/assets/vennDiagram-CIIHVFJN-l3Z7-wbP.js +0 -34
- ksadk/server/static/assets/wardley-L42UT6IY-8XLvnNIs.js +0 -1
- ksadk/server/static/assets/wardleyDiagram-YWT4CUSO-BR54GPmr.js +0 -78
- ksadk/server/static/assets/xychartDiagram-2RQKCTM6-SkiH8GsK.js +0 -7
- ksadk/tracing/exporters/langfuse_exporter.py +0 -460
- {agentengine_sdk_python-0.8.0.dist-info → agentengine_sdk_python-0.8.2.dist-info}/entry_points.txt +0 -0
- {agentengine_sdk_python-0.8.0.dist-info → agentengine_sdk_python-0.8.2.dist-info}/licenses/LICENSE +0 -0
- {agentengine_sdk_python-0.8.0.dist-info → agentengine_sdk_python-0.8.2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""RuntimeAdapter installation facts exposed to Studio authoring."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from importlib.metadata import PackageNotFoundError
|
|
6
|
+
from importlib.metadata import version as package_version
|
|
7
|
+
|
|
8
|
+
from ksadk.managed_runtime import installed_runtime_version
|
|
9
|
+
from ksadk.runtime import RuntimeExecutor
|
|
10
|
+
|
|
11
|
+
_RUNTIMES = {
|
|
12
|
+
"codex": {
|
|
13
|
+
"package": "openai-codex",
|
|
14
|
+
"displayName": "Codex",
|
|
15
|
+
"adapter": "CodexRuntimeAdapter",
|
|
16
|
+
"capabilities": {
|
|
17
|
+
"session": True,
|
|
18
|
+
"cancel": True,
|
|
19
|
+
"resume": "thread_id",
|
|
20
|
+
"checkpoint": "thread",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
"adk": {
|
|
24
|
+
"package": "google-adk",
|
|
25
|
+
"displayName": "Google ADK",
|
|
26
|
+
"adapter": "ADKRuntimeAdapter",
|
|
27
|
+
"capabilities": {
|
|
28
|
+
"session": True,
|
|
29
|
+
"cancel": True,
|
|
30
|
+
"resume": "forward_only",
|
|
31
|
+
"checkpoint": "runtime_dependent",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
"langgraph": {
|
|
35
|
+
"package": "langgraph",
|
|
36
|
+
"displayName": "LangGraph",
|
|
37
|
+
"adapter": "LangGraphRuntimeAdapter",
|
|
38
|
+
"capabilities": {
|
|
39
|
+
"session": True,
|
|
40
|
+
"cancel": True,
|
|
41
|
+
"resume": "checkpoint_id",
|
|
42
|
+
"checkpoint": "runtime_dependent",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def inspect_runtime_catalog(executor: RuntimeExecutor) -> list[dict]:
|
|
49
|
+
items: list[dict] = []
|
|
50
|
+
for runtime_type in executor.registered_runtime_types():
|
|
51
|
+
metadata = _RUNTIMES[runtime_type]
|
|
52
|
+
package = str(metadata["package"])
|
|
53
|
+
try:
|
|
54
|
+
installed = (
|
|
55
|
+
installed_runtime_version("codex")
|
|
56
|
+
if runtime_type == "codex"
|
|
57
|
+
else package_version(package)
|
|
58
|
+
)
|
|
59
|
+
except PackageNotFoundError:
|
|
60
|
+
installed = ""
|
|
61
|
+
items.append(
|
|
62
|
+
{
|
|
63
|
+
"runtimeType": runtime_type,
|
|
64
|
+
**metadata,
|
|
65
|
+
"installed": bool(installed),
|
|
66
|
+
"version": installed or None,
|
|
67
|
+
"status": "ready" if installed else "missing-dependency",
|
|
68
|
+
"installCommand": f"pip install 'ksadk[{runtime_type}]'",
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
return items
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
__all__ = ["inspect_runtime_catalog"]
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
"""Generated framework source for Studio quick/conversation authoring flows."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import hashlib
|
|
6
|
+
import json
|
|
7
|
+
import re
|
|
8
|
+
import shutil
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from ksadk.studio.contracts import AgentDraft
|
|
12
|
+
from ksadk.studio.errors import StudioError
|
|
13
|
+
from ksadk.studio.resource_catalog import LocalResourceCatalog
|
|
14
|
+
from ksadk.studio.workspace import Workspace
|
|
15
|
+
from ksadk.toolsets import describe_agentengine_tools
|
|
16
|
+
|
|
17
|
+
_GENERATED_MARKER = ".agentkit-generated"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def materialize_generated_runtime_source(
|
|
21
|
+
workspace: Workspace,
|
|
22
|
+
draft: AgentDraft,
|
|
23
|
+
*,
|
|
24
|
+
catalog: LocalResourceCatalog | None = None,
|
|
25
|
+
) -> None:
|
|
26
|
+
"""Create or refresh the source owned by a generated ADK/LangGraph draft.
|
|
27
|
+
|
|
28
|
+
Imported and detected projects are never overwritten: the marker is created
|
|
29
|
+
only when Studio owns a previously empty source directory.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
runtime = draft.spec.runtime
|
|
33
|
+
if runtime is None or runtime.type == "codex" or not runtime.project_path:
|
|
34
|
+
return
|
|
35
|
+
root = workspace.resolve(runtime.project_path)
|
|
36
|
+
marker = root / _GENERATED_MARKER
|
|
37
|
+
if root.exists() and any(root.iterdir()) and not marker.is_file():
|
|
38
|
+
return
|
|
39
|
+
root.mkdir(parents=True, exist_ok=True)
|
|
40
|
+
entry = workspace.resolve(Path(runtime.project_path) / (runtime.entry_point or "agent.py"))
|
|
41
|
+
entry.parent.mkdir(parents=True, exist_ok=True)
|
|
42
|
+
resolved_catalog = catalog or LocalResourceCatalog(workspace)
|
|
43
|
+
prompt, tool_names, python_tools = _runtime_inputs(
|
|
44
|
+
workspace,
|
|
45
|
+
draft,
|
|
46
|
+
catalog=resolved_catalog,
|
|
47
|
+
)
|
|
48
|
+
_snapshot_python_tools(workspace, root, python_tools)
|
|
49
|
+
model = _configured_model(resolved_catalog, draft)
|
|
50
|
+
if runtime.type == "adk":
|
|
51
|
+
source = _adk_source(
|
|
52
|
+
draft.metadata.id,
|
|
53
|
+
prompt,
|
|
54
|
+
model,
|
|
55
|
+
runtime.agent_variable,
|
|
56
|
+
tool_names,
|
|
57
|
+
python_tools,
|
|
58
|
+
)
|
|
59
|
+
else:
|
|
60
|
+
source = _langgraph_source(
|
|
61
|
+
prompt,
|
|
62
|
+
model,
|
|
63
|
+
runtime.agent_variable,
|
|
64
|
+
tool_names,
|
|
65
|
+
python_tools,
|
|
66
|
+
)
|
|
67
|
+
workspace.atomic_write_text(entry, source)
|
|
68
|
+
workspace.atomic_write_yaml(
|
|
69
|
+
root / "ksadk.yaml",
|
|
70
|
+
{
|
|
71
|
+
"name": draft.metadata.id,
|
|
72
|
+
"framework": runtime.type,
|
|
73
|
+
"entry_point": runtime.entry_point or "agent.py",
|
|
74
|
+
"agent_variable": runtime.agent_variable,
|
|
75
|
+
},
|
|
76
|
+
)
|
|
77
|
+
workspace.atomic_write_text(
|
|
78
|
+
marker,
|
|
79
|
+
"AgentKit Studio generated source. Safe to refresh from its YAML Revision.\n",
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _configured_model(catalog: LocalResourceCatalog, draft: AgentDraft) -> str:
|
|
84
|
+
resolved = catalog.resolve_model(draft.spec.bindings)
|
|
85
|
+
if resolved is not None:
|
|
86
|
+
return resolved.model
|
|
87
|
+
if draft.spec.model is not None:
|
|
88
|
+
return draft.spec.model.model
|
|
89
|
+
return str(draft.metadata.labels.get("agentkit.ksyun.com/model") or "glm-5.1")
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _runtime_inputs(
|
|
93
|
+
workspace: Workspace,
|
|
94
|
+
draft: AgentDraft,
|
|
95
|
+
*,
|
|
96
|
+
catalog: LocalResourceCatalog,
|
|
97
|
+
) -> tuple[str, list[str], list[dict[str, str]]]:
|
|
98
|
+
tools, _permissions = catalog.policy_preview(draft.spec.bindings)
|
|
99
|
+
builtin_names = [tool.name for tool in tools if tool.enabled and tool.executor == "builtin"]
|
|
100
|
+
python_tools = [
|
|
101
|
+
{
|
|
102
|
+
"name": tool.name,
|
|
103
|
+
"description": tool.description,
|
|
104
|
+
"sourcePath": str(tool.source_path),
|
|
105
|
+
"callableName": str(tool.callable_name),
|
|
106
|
+
"sourceSha256": str(tool.source_sha256),
|
|
107
|
+
"bundlePath": f".agentkit_tools/{_python_name(tool.name)}.py",
|
|
108
|
+
}
|
|
109
|
+
for tool in tools
|
|
110
|
+
if tool.enabled and tool.executor == "python"
|
|
111
|
+
]
|
|
112
|
+
unsupported_executors = sorted(
|
|
113
|
+
{tool.executor for tool in tools if tool.enabled} - {"builtin", "python"}
|
|
114
|
+
)
|
|
115
|
+
if unsupported_executors:
|
|
116
|
+
raise StudioError(
|
|
117
|
+
"TOOL_RUNTIME_INCOMPATIBLE",
|
|
118
|
+
"所选 Tool 类型不能直接注入当前 Python Runtime",
|
|
119
|
+
status_code=422,
|
|
120
|
+
details={"executors": unsupported_executors},
|
|
121
|
+
)
|
|
122
|
+
available = {
|
|
123
|
+
str(item["name"])
|
|
124
|
+
for item in describe_agentengine_tools(profile="coding", mode="direct")
|
|
125
|
+
if item.get("enabled", True)
|
|
126
|
+
}
|
|
127
|
+
unsupported = sorted(set(builtin_names) - available)
|
|
128
|
+
if unsupported:
|
|
129
|
+
raise StudioError(
|
|
130
|
+
"TOOL_RUNTIME_INCOMPATIBLE",
|
|
131
|
+
"所选 Tool 没有可供 Python Runtime 执行的实现",
|
|
132
|
+
status_code=422,
|
|
133
|
+
details={"tools": unsupported},
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
prompt = draft.spec.instructions.system.strip() or "You are a reliable assistant."
|
|
137
|
+
skill_sections: list[str] = []
|
|
138
|
+
for ref in catalog.resolve_skills(draft.spec.bindings):
|
|
139
|
+
path = workspace.resolve(
|
|
140
|
+
Path("capabilities/skills") / ref.name / "SKILL.md",
|
|
141
|
+
must_exist=True,
|
|
142
|
+
)
|
|
143
|
+
content = _skill_body(path.read_text(encoding="utf-8-sig"))
|
|
144
|
+
if content:
|
|
145
|
+
skill_sections.append(f"## Skill: {ref.name}\n\n{content}")
|
|
146
|
+
if skill_sections:
|
|
147
|
+
prompt = f"{prompt}\n\n# Bound skills\n\n" + "\n\n".join(skill_sections)
|
|
148
|
+
return prompt, builtin_names, python_tools
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def _snapshot_python_tools(
|
|
152
|
+
workspace: Workspace,
|
|
153
|
+
runtime_root: Path,
|
|
154
|
+
tools: list[dict[str, str]],
|
|
155
|
+
) -> None:
|
|
156
|
+
target_root = runtime_root / ".agentkit_tools"
|
|
157
|
+
if target_root.exists():
|
|
158
|
+
shutil.rmtree(target_root)
|
|
159
|
+
for tool in tools:
|
|
160
|
+
source = workspace.resolve(tool["sourcePath"], must_exist=True)
|
|
161
|
+
content = source.read_bytes()
|
|
162
|
+
digest = f"sha256:{hashlib.sha256(content).hexdigest()}"
|
|
163
|
+
if digest != tool["sourceSha256"]:
|
|
164
|
+
raise StudioError(
|
|
165
|
+
"TOOL_SOURCE_DIGEST_MISMATCH",
|
|
166
|
+
"Python Tool 源码与 Catalog 锁定摘要不一致",
|
|
167
|
+
status_code=409,
|
|
168
|
+
details={"tool": tool["name"]},
|
|
169
|
+
)
|
|
170
|
+
target = runtime_root / tool["bundlePath"]
|
|
171
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
172
|
+
target.write_bytes(content)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def _skill_body(content: str) -> str:
|
|
176
|
+
normalized = content.strip()
|
|
177
|
+
if normalized.startswith("---\n"):
|
|
178
|
+
parts = normalized.split("\n---\n", 1)
|
|
179
|
+
if len(parts) == 2:
|
|
180
|
+
normalized = parts[1].strip()
|
|
181
|
+
return normalized
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def _python_name(value: str) -> str:
|
|
185
|
+
normalized = re.sub(r"[^A-Za-z0-9_]", "_", value)
|
|
186
|
+
if not normalized or normalized[0].isdigit():
|
|
187
|
+
normalized = f"agent_{normalized}"
|
|
188
|
+
return normalized
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def _adk_source(
|
|
192
|
+
agent_id: str,
|
|
193
|
+
prompt: str,
|
|
194
|
+
model: str,
|
|
195
|
+
variable: str,
|
|
196
|
+
tool_names: list[str],
|
|
197
|
+
python_tools: list[dict[str, str]],
|
|
198
|
+
) -> str:
|
|
199
|
+
return f'''"""Generated by AgentKit Studio. Agent behavior remains YAML-owned."""
|
|
200
|
+
|
|
201
|
+
import os
|
|
202
|
+
import importlib.util
|
|
203
|
+
from pathlib import Path
|
|
204
|
+
|
|
205
|
+
from google.adk.agents import Agent
|
|
206
|
+
from google.adk.integrations.langchain import LangchainTool
|
|
207
|
+
from google.adk.models.lite_llm import LiteLlm
|
|
208
|
+
from ksadk.toolsets import get_agentengine_tools
|
|
209
|
+
from langchain_core.tools import StructuredTool
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def _model_reference() -> str:
|
|
213
|
+
selected = os.getenv("OPENAI_MODEL_NAME") or os.getenv("MODEL_NAME") or {json.dumps(model)}
|
|
214
|
+
return selected if "/" in selected else f"openai/{{selected}}"
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def _load_python_tools():
|
|
218
|
+
loaded = []
|
|
219
|
+
for index, descriptor in enumerate({json.dumps(python_tools)}):
|
|
220
|
+
path = Path(__file__).parent / descriptor["bundlePath"]
|
|
221
|
+
module_spec = importlib.util.spec_from_file_location(
|
|
222
|
+
f"agentkit_custom_tool_{{index}}",
|
|
223
|
+
path,
|
|
224
|
+
)
|
|
225
|
+
if module_spec is None or module_spec.loader is None:
|
|
226
|
+
raise RuntimeError(f"Cannot load custom tool: {{descriptor['name']}}")
|
|
227
|
+
module = importlib.util.module_from_spec(module_spec)
|
|
228
|
+
module_spec.loader.exec_module(module)
|
|
229
|
+
function = getattr(module, descriptor["callableName"])
|
|
230
|
+
loaded.append(
|
|
231
|
+
StructuredTool.from_function(
|
|
232
|
+
function,
|
|
233
|
+
name=descriptor["name"],
|
|
234
|
+
description=descriptor["description"],
|
|
235
|
+
)
|
|
236
|
+
)
|
|
237
|
+
return loaded
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
_builtin_tool_names = {json.dumps(tool_names)}
|
|
241
|
+
_langchain_tools = (
|
|
242
|
+
get_agentengine_tools(
|
|
243
|
+
include=_builtin_tool_names,
|
|
244
|
+
profile="coding",
|
|
245
|
+
mode="direct",
|
|
246
|
+
)
|
|
247
|
+
if _builtin_tool_names
|
|
248
|
+
else []
|
|
249
|
+
) + _load_python_tools()
|
|
250
|
+
_tools = [LangchainTool(tool) for tool in _langchain_tools]
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
{variable} = Agent(
|
|
254
|
+
name={json.dumps(_python_name(agent_id))},
|
|
255
|
+
model=LiteLlm(model=_model_reference()),
|
|
256
|
+
instruction={json.dumps(prompt)},
|
|
257
|
+
tools=_tools,
|
|
258
|
+
)
|
|
259
|
+
'''
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
def _langgraph_source(
|
|
263
|
+
prompt: str,
|
|
264
|
+
model: str,
|
|
265
|
+
variable: str,
|
|
266
|
+
tool_names: list[str],
|
|
267
|
+
python_tools: list[dict[str, str]],
|
|
268
|
+
) -> str:
|
|
269
|
+
return f'''"""Generated by AgentKit Studio. Agent behavior remains YAML-owned."""
|
|
270
|
+
|
|
271
|
+
import os
|
|
272
|
+
import importlib.util
|
|
273
|
+
from pathlib import Path
|
|
274
|
+
from typing import Annotated, TypedDict
|
|
275
|
+
|
|
276
|
+
from langchain_core.messages import AnyMessage, SystemMessage
|
|
277
|
+
from langchain_openai import ChatOpenAI
|
|
278
|
+
from langgraph.checkpoint.memory import MemorySaver
|
|
279
|
+
from langgraph.graph import END, START, StateGraph
|
|
280
|
+
from langgraph.graph.message import add_messages
|
|
281
|
+
from langgraph.prebuilt import ToolNode, tools_condition
|
|
282
|
+
from ksadk.toolsets import get_agentengine_tools
|
|
283
|
+
from langchain_core.tools import StructuredTool
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
class AgentState(TypedDict):
|
|
287
|
+
messages: Annotated[list[AnyMessage], add_messages]
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
def _load_python_tools():
|
|
291
|
+
loaded = []
|
|
292
|
+
for index, descriptor in enumerate({json.dumps(python_tools)}):
|
|
293
|
+
path = Path(__file__).parent / descriptor["bundlePath"]
|
|
294
|
+
module_spec = importlib.util.spec_from_file_location(
|
|
295
|
+
f"agentkit_custom_tool_{{index}}",
|
|
296
|
+
path,
|
|
297
|
+
)
|
|
298
|
+
if module_spec is None or module_spec.loader is None:
|
|
299
|
+
raise RuntimeError(f"Cannot load custom tool: {{descriptor['name']}}")
|
|
300
|
+
module = importlib.util.module_from_spec(module_spec)
|
|
301
|
+
module_spec.loader.exec_module(module)
|
|
302
|
+
function = getattr(module, descriptor["callableName"])
|
|
303
|
+
loaded.append(
|
|
304
|
+
StructuredTool.from_function(
|
|
305
|
+
function,
|
|
306
|
+
name=descriptor["name"],
|
|
307
|
+
description=descriptor["description"],
|
|
308
|
+
)
|
|
309
|
+
)
|
|
310
|
+
return loaded
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
_builtin_tool_names = {json.dumps(tool_names)}
|
|
314
|
+
_tools = (
|
|
315
|
+
get_agentengine_tools(
|
|
316
|
+
include=_builtin_tool_names,
|
|
317
|
+
profile="coding",
|
|
318
|
+
mode="direct",
|
|
319
|
+
)
|
|
320
|
+
if _builtin_tool_names
|
|
321
|
+
else []
|
|
322
|
+
) + _load_python_tools()
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
def _call_model(state: AgentState):
|
|
326
|
+
selected = os.getenv("OPENAI_MODEL_NAME") or os.getenv("MODEL_NAME") or {json.dumps(model)}
|
|
327
|
+
client = ChatOpenAI(
|
|
328
|
+
model=selected,
|
|
329
|
+
api_key=os.environ["OPENAI_API_KEY"],
|
|
330
|
+
base_url=os.getenv("OPENAI_BASE_URL") or os.getenv("OPENAI_API_BASE"),
|
|
331
|
+
stream_usage=True,
|
|
332
|
+
)
|
|
333
|
+
runnable = client.bind_tools(_tools) if _tools else client
|
|
334
|
+
messages = list(state["messages"])
|
|
335
|
+
# KsADK Runtime 已投影 CompiledPrompt/ContextPlan 时,state 中存在 SystemMessage,
|
|
336
|
+
# 不再重复注入模板 Prompt;直接调用 graph 时仍保留独立运行能力。
|
|
337
|
+
if not any(isinstance(message, SystemMessage) for message in messages):
|
|
338
|
+
messages.insert(0, SystemMessage(content={json.dumps(prompt)}))
|
|
339
|
+
return {{"messages": [runnable.invoke(messages)]}}
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def ksadk_graph_factory(*, checkpointer):
|
|
343
|
+
"""Compile the graph with a caller-owned checkpoint backend.
|
|
344
|
+
|
|
345
|
+
Studio uses ``MemorySaver`` for local authoring. The hosted KsADK runner
|
|
346
|
+
rebuilds this graph through the same factory with its admitted PostgreSQL
|
|
347
|
+
saver before the first turn, so an interrupt can resume after a Pod move.
|
|
348
|
+
"""
|
|
349
|
+
builder = StateGraph(AgentState)
|
|
350
|
+
builder.add_node("model", _call_model)
|
|
351
|
+
builder.add_edge(START, "model")
|
|
352
|
+
if _tools:
|
|
353
|
+
builder.add_node("tools", ToolNode(_tools))
|
|
354
|
+
builder.add_conditional_edges("model", tools_condition)
|
|
355
|
+
builder.add_edge("tools", "model")
|
|
356
|
+
else:
|
|
357
|
+
builder.add_edge("model", END)
|
|
358
|
+
return builder.compile(checkpointer=checkpointer)
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
{variable} = ksadk_graph_factory(checkpointer=MemorySaver())
|
|
362
|
+
'''
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
__all__ = ["materialize_generated_runtime_source"]
|