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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import json
|
|
3
4
|
import os
|
|
4
5
|
from dataclasses import dataclass, field
|
|
5
6
|
from typing import Any, Mapping, Sequence
|
|
@@ -72,6 +73,277 @@ class CompactionSummaryResult:
|
|
|
72
73
|
fallback_reason: str | None = None
|
|
73
74
|
|
|
74
75
|
|
|
76
|
+
# --- PR D2:Session Working State(方案 §9.3) ---
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@dataclass
|
|
80
|
+
class WorkingState:
|
|
81
|
+
"""压缩前后保持任务连续性的结构化工作面,随 ContextCheckpoint 持久化。
|
|
82
|
+
|
|
83
|
+
生成原则(方案 §9.3):优先确定性提取——``pending_tools``/``pending_approvals``/receipt
|
|
84
|
+
从事实事件取;``current_goal`` 从最新 user_message/pinned_state 取;``active_files`` 从
|
|
85
|
+
workspace 工具调用参数取。仅 ``decisions``/``errors_and_corrections``/``next_action`` 等
|
|
86
|
+
难结构化项允许从摘要文本解析(带 fallback)。不跨 Session 召回,不写 MemoryProvider。
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
current_goal: str = ""
|
|
90
|
+
current_phase: str | None = None
|
|
91
|
+
completed_steps: list[str] = field(default_factory=list)
|
|
92
|
+
pending_steps: list[str] = field(default_factory=list)
|
|
93
|
+
next_action: str | None = None
|
|
94
|
+
active_files: list[dict[str, object]] = field(default_factory=list)
|
|
95
|
+
decisions: list[dict[str, object]] = field(default_factory=list)
|
|
96
|
+
errors_and_corrections: list[dict[str, object]] = field(default_factory=list)
|
|
97
|
+
pending_tools: list[dict[str, object]] = field(default_factory=list)
|
|
98
|
+
pending_approvals: list[dict[str, object]] = field(default_factory=list)
|
|
99
|
+
artifact_refs: list[dict[str, object]] = field(default_factory=list)
|
|
100
|
+
# §8.1:关键约束("不得操作生产环境" 等),从摘要/pinned_state 提取,缺失时合并旧值。
|
|
101
|
+
constraints: list[str] = field(default_factory=list)
|
|
102
|
+
source_seq_range: tuple[int, int] = (0, 0)
|
|
103
|
+
schema_version: str = "v1"
|
|
104
|
+
|
|
105
|
+
def critical_fields_present(self) -> bool:
|
|
106
|
+
"""§8.1:关键字段校验。四项必须全部非空(P0 严格验收,不可放宽)。
|
|
107
|
+
|
|
108
|
+
- current_goal 非空
|
|
109
|
+
- constraints 非空
|
|
110
|
+
- completed_steps 非空
|
|
111
|
+
- next_action 非空
|
|
112
|
+
"""
|
|
113
|
+
return (
|
|
114
|
+
bool(self.current_goal and self.current_goal.strip())
|
|
115
|
+
and len(self.constraints) > 0
|
|
116
|
+
and len(self.completed_steps) > 0
|
|
117
|
+
and bool(self.next_action and self.next_action.strip())
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
def merge_missing_from(self, previous: "WorkingState | None") -> "WorkingState":
|
|
121
|
+
"""§8.1:关键字段缺失时用压缩前 WorkingState 合并,不接受空值覆盖。
|
|
122
|
+
|
|
123
|
+
current_goal/constraints/completed_steps/next_action 空时回填 previous 的值
|
|
124
|
+
(避免压缩后丢失"不得操作生产环境"等关键约束和已完成进展)。pending_tools/approvals
|
|
125
|
+
始终以事实事件提取为准(不合并,防过期 pending)。
|
|
126
|
+
"""
|
|
127
|
+
if previous is None:
|
|
128
|
+
return self
|
|
129
|
+
if not self.current_goal.strip():
|
|
130
|
+
self.current_goal = previous.current_goal
|
|
131
|
+
if not self.constraints:
|
|
132
|
+
self.constraints = list(previous.constraints)
|
|
133
|
+
if not self.next_action and previous.next_action:
|
|
134
|
+
self.next_action = previous.next_action
|
|
135
|
+
if not self.completed_steps and previous.completed_steps:
|
|
136
|
+
self.completed_steps = list(previous.completed_steps)
|
|
137
|
+
return self
|
|
138
|
+
|
|
139
|
+
def to_audit_dict(self) -> dict[str, Any]:
|
|
140
|
+
"""审计用 plain dict(写 checkpoint metadata)。不含 prompt 明文,只含结构化字段。"""
|
|
141
|
+
return {
|
|
142
|
+
"current_goal": self.current_goal,
|
|
143
|
+
"next_action": self.next_action,
|
|
144
|
+
"completed_steps": list(self.completed_steps),
|
|
145
|
+
"completed_steps_count": len(self.completed_steps),
|
|
146
|
+
"pending_steps": list(self.pending_steps),
|
|
147
|
+
"pending_steps_count": len(self.pending_steps),
|
|
148
|
+
"active_files": list(self.active_files),
|
|
149
|
+
"decisions_count": len(self.decisions),
|
|
150
|
+
"errors_and_corrections_count": len(self.errors_and_corrections),
|
|
151
|
+
"pending_tools": list(self.pending_tools),
|
|
152
|
+
"pending_approvals": list(self.pending_approvals),
|
|
153
|
+
"artifact_refs": list(self.artifact_refs),
|
|
154
|
+
"constraints": list(self.constraints),
|
|
155
|
+
"source_seq_range": list(self.source_seq_range),
|
|
156
|
+
"schema_version": self.schema_version,
|
|
157
|
+
"content_hash": self.content_hash(),
|
|
158
|
+
"status": "succeeded",
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
def content_hash(self) -> str:
|
|
162
|
+
import hashlib
|
|
163
|
+
|
|
164
|
+
payload = json.dumps(
|
|
165
|
+
{
|
|
166
|
+
"current_goal": self.current_goal,
|
|
167
|
+
"next_action": self.next_action,
|
|
168
|
+
"completed_steps": self.completed_steps,
|
|
169
|
+
"pending_steps": self.pending_steps,
|
|
170
|
+
"active_files": self.active_files,
|
|
171
|
+
"decisions": self.decisions,
|
|
172
|
+
"errors_and_corrections": self.errors_and_corrections,
|
|
173
|
+
"pending_tools": self.pending_tools,
|
|
174
|
+
"pending_approvals": self.pending_approvals,
|
|
175
|
+
"artifact_refs": self.artifact_refs,
|
|
176
|
+
"constraints": self.constraints,
|
|
177
|
+
"source_seq_range": list(self.source_seq_range),
|
|
178
|
+
"schema_version": self.schema_version,
|
|
179
|
+
},
|
|
180
|
+
ensure_ascii=False,
|
|
181
|
+
sort_keys=True,
|
|
182
|
+
)
|
|
183
|
+
return f"sha256:{hashlib.sha256(payload.encode('utf-8')).hexdigest()}"
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def _parse_summary_v2_sections(
|
|
187
|
+
summary_text: str,
|
|
188
|
+
) -> tuple[
|
|
189
|
+
str | None,
|
|
190
|
+
list[dict[str, object]],
|
|
191
|
+
list[dict[str, object]],
|
|
192
|
+
str,
|
|
193
|
+
list[str],
|
|
194
|
+
list[str],
|
|
195
|
+
]:
|
|
196
|
+
"""从摘要 v2 结构化文本确定性解析 next_action / decisions / errors_and_corrections /
|
|
197
|
+
current_goal / constraints(方案 §9.4 / P0 Working State 验收)。
|
|
198
|
+
|
|
199
|
+
支持中文标记("当前用户目标"/"关键约束"/"下一步工作位置")与英文标记。纯文本解析,无 LLM。
|
|
200
|
+
容错:无标记时返回 ``(None, [], [], "", [])``。
|
|
201
|
+
"""
|
|
202
|
+
text = str(summary_text or "").strip()
|
|
203
|
+
if not text:
|
|
204
|
+
return None, [], [], "", [], []
|
|
205
|
+
|
|
206
|
+
def _find_section(*labels: str) -> str:
|
|
207
|
+
for label in labels:
|
|
208
|
+
# 形如 "下一步工作位置:<内容>",到下一个已知标记或末尾
|
|
209
|
+
for marker in (f"{label}:", f"{label}:", f"{label} "):
|
|
210
|
+
idx = text.find(marker)
|
|
211
|
+
if idx >= 0:
|
|
212
|
+
body = text[idx + len(marker) :].strip()
|
|
213
|
+
# 截到下一个已知 section 标记
|
|
214
|
+
stop = len(body)
|
|
215
|
+
for other in (
|
|
216
|
+
"下一步",
|
|
217
|
+
"下一步工作",
|
|
218
|
+
"未完成事项",
|
|
219
|
+
"重要决策",
|
|
220
|
+
"错误修正",
|
|
221
|
+
"当前用户目标",
|
|
222
|
+
"关键约束",
|
|
223
|
+
"已完成进展",
|
|
224
|
+
"重要引用",
|
|
225
|
+
"Next",
|
|
226
|
+
"Next Step",
|
|
227
|
+
"Decision",
|
|
228
|
+
"Error",
|
|
229
|
+
"Pending",
|
|
230
|
+
"最新用户指令",
|
|
231
|
+
):
|
|
232
|
+
if other.startswith(label):
|
|
233
|
+
continue
|
|
234
|
+
pos = body.find(other)
|
|
235
|
+
if pos >= 0 and pos < stop:
|
|
236
|
+
stop = pos
|
|
237
|
+
return body[:stop].strip().strip("。.;;")
|
|
238
|
+
return ""
|
|
239
|
+
|
|
240
|
+
next_action = _find_section("下一步工作位置", "下一步", "Next Step", "Next") or None
|
|
241
|
+
decisions_text = _find_section("重要决策", "关键决策", "Decision")
|
|
242
|
+
errors_text = _find_section("错误修正", "错误与纠正", "Error")
|
|
243
|
+
decisions = [{"text": decisions_text}] if decisions_text else []
|
|
244
|
+
errors_and_corrections = [{"text": errors_text}] if errors_text else []
|
|
245
|
+
# P0:current_goal / constraints / completed_steps 从摘要解析(方案 §9.3/§9.4)
|
|
246
|
+
current_goal = _find_section("当前用户目标", "当前目标", "Current Goal", "Goal") or ""
|
|
247
|
+
constraints_text = _find_section("关键约束", "重要约束", "Constraints", "Constraint")
|
|
248
|
+
constraints = (
|
|
249
|
+
[c.strip() for c in constraints_text.split(";;") if c.strip()] if constraints_text else []
|
|
250
|
+
)
|
|
251
|
+
completed_text = _find_section("已完成进展", "已完成", "Completed", "Progress")
|
|
252
|
+
completed_steps = (
|
|
253
|
+
[s.strip() for s in completed_text.split(";;") if s.strip()] if completed_text else []
|
|
254
|
+
)
|
|
255
|
+
return (
|
|
256
|
+
next_action,
|
|
257
|
+
decisions,
|
|
258
|
+
errors_and_corrections,
|
|
259
|
+
current_goal,
|
|
260
|
+
constraints,
|
|
261
|
+
completed_steps,
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def extract_working_state(
|
|
266
|
+
events: Sequence[SessionEvent],
|
|
267
|
+
*,
|
|
268
|
+
pinned_state: Mapping[str, Any] | None = None,
|
|
269
|
+
summary_text: str = "",
|
|
270
|
+
source_seq_range: tuple[int, int] = (0, 0),
|
|
271
|
+
) -> WorkingState:
|
|
272
|
+
"""从事实事件确定性提取 WorkingState(方案 §9.3)。
|
|
273
|
+
|
|
274
|
+
``pending_tools``/``pending_approvals``/``current_goal``/``active_files`` 来自事件,
|
|
275
|
+
不靠摘要模型猜测(与 ``extract_pinned_state`` 同源但结构化)。``decisions``/
|
|
276
|
+
``errors_and_corrections``/``next_action`` 暂留空(v2 摘要文本解析留 follow-up,
|
|
277
|
+
当前优先确定性事实)。容错:v1 旧摘要或缺失字段时返回部分填充。
|
|
278
|
+
"""
|
|
279
|
+
pinned = dict(pinned_state or {})
|
|
280
|
+
# pending_tools / pending_approvals:复用 pinned_state 的确定性提取结果(已去配对)。
|
|
281
|
+
pending_tools_raw = list(pinned.get("pending_tools") or [])
|
|
282
|
+
pending_approvals_raw = list(pinned.get("pending_approvals") or [])
|
|
283
|
+
artifact_refs_raw = list(pinned.get("attachment_refs") or [])
|
|
284
|
+
current_goal = str(pinned.get("current_user_goal") or "").strip()
|
|
285
|
+
# constraints 从 pinned_state 取(确定性),缺失时由摘要解析补充
|
|
286
|
+
constraints_raw = list(pinned.get("constraints") or [])
|
|
287
|
+
# completed_steps 从 pinned_state 取(确定性),缺失时由摘要解析补充
|
|
288
|
+
completed_steps_raw = list(pinned.get("completed_steps") or [])
|
|
289
|
+
|
|
290
|
+
# active_files:从 tool_call 事件的 tool_args.path 提取(workspace 类工具)。
|
|
291
|
+
active_files: list[dict[str, object]] = []
|
|
292
|
+
seen_paths: set[str] = set()
|
|
293
|
+
for event in events:
|
|
294
|
+
event_type = canonical_event_type(
|
|
295
|
+
event.event_type,
|
|
296
|
+
author=event.author,
|
|
297
|
+
role=str((event.content or {}).get("role") or ""),
|
|
298
|
+
)
|
|
299
|
+
if event_type != "tool_call":
|
|
300
|
+
continue
|
|
301
|
+
meta = event.metadata or {}
|
|
302
|
+
tool_args = meta.get("tool_args")
|
|
303
|
+
if isinstance(tool_args, Mapping):
|
|
304
|
+
path = str(tool_args.get("path") or tool_args.get("file") or "").strip()
|
|
305
|
+
if path and path not in seen_paths:
|
|
306
|
+
seen_paths.add(path)
|
|
307
|
+
active_files.append({"path": path, "tool_name": str(meta.get("tool_name") or "")})
|
|
308
|
+
|
|
309
|
+
# 摘要 v2 文本解析(方案 §9.3 / §9.4 / P0):从结构化摘要确定性解析 next_action / decisions /
|
|
310
|
+
# errors_and_corrections / current_goal / constraints / completed_steps。
|
|
311
|
+
(
|
|
312
|
+
next_action,
|
|
313
|
+
decisions,
|
|
314
|
+
errors_and_corrections,
|
|
315
|
+
summary_goal,
|
|
316
|
+
summary_constraints,
|
|
317
|
+
summary_completed,
|
|
318
|
+
) = _parse_summary_v2_sections(summary_text)
|
|
319
|
+
# current_goal 优先用 pinned_state,缺失时用摘要解析的 goal
|
|
320
|
+
if not current_goal.strip() and summary_goal:
|
|
321
|
+
current_goal = summary_goal
|
|
322
|
+
# constraints 优先用 pinned_state/事件,缺失时用摘要解析
|
|
323
|
+
if not constraints_raw and summary_constraints:
|
|
324
|
+
constraints_raw = list(summary_constraints)
|
|
325
|
+
# completed_steps 优先用 pinned_state,缺失时用摘要解析
|
|
326
|
+
completed_steps = (
|
|
327
|
+
list(completed_steps_raw)
|
|
328
|
+
if completed_steps_raw
|
|
329
|
+
else (list(summary_completed) if summary_completed else [])
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
return WorkingState(
|
|
333
|
+
current_goal=current_goal,
|
|
334
|
+
next_action=next_action,
|
|
335
|
+
decisions=decisions,
|
|
336
|
+
errors_and_corrections=errors_and_corrections,
|
|
337
|
+
completed_steps=completed_steps,
|
|
338
|
+
active_files=active_files[-10:],
|
|
339
|
+
pending_tools=[{"text": t} for t in pending_tools_raw],
|
|
340
|
+
pending_approvals=[{"text": t} for t in pending_approvals_raw],
|
|
341
|
+
artifact_refs=[{"ref": r} for r in artifact_refs_raw],
|
|
342
|
+
constraints=list(constraints_raw),
|
|
343
|
+
source_seq_range=source_seq_range,
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
|
|
75
347
|
class SummaryModelClient:
|
|
76
348
|
"""独立的摘要模型客户端。
|
|
77
349
|
|
|
@@ -221,12 +493,35 @@ def find_pinned_group_indexes(groups: Sequence[Sequence[SessionEvent]]) -> set[i
|
|
|
221
493
|
|
|
222
494
|
|
|
223
495
|
def extract_pinned_state(groups: Sequence[Sequence[SessionEvent]]) -> dict[str, Any]:
|
|
224
|
-
"""提取必须在 checkpoint 里显式保留的状态。
|
|
496
|
+
"""提取必须在 checkpoint 里显式保留的状态。
|
|
497
|
+
|
|
498
|
+
P0:除了 pending approvals/tools/attachment_refs/current_user_goal,还确定性提取
|
|
499
|
+
constraints("不得操作生产环境" 等)和 completed_steps("镜像已构建" 等),
|
|
500
|
+
从 user/assistant 消息文本中按标记提取,不依赖摘要模型。
|
|
501
|
+
"""
|
|
225
502
|
|
|
226
503
|
pending_approvals: list[str] = []
|
|
227
504
|
pending_tools: list[str] = []
|
|
228
505
|
attachment_refs: list[str] = []
|
|
229
506
|
current_user_goal = ""
|
|
507
|
+
constraints: list[str] = []
|
|
508
|
+
completed_steps: list[str] = []
|
|
509
|
+
|
|
510
|
+
# 约束标记:用户说"不得/不要/禁止X"或 assistant 说"约束:X"
|
|
511
|
+
import re
|
|
512
|
+
|
|
513
|
+
constraint_patterns = [
|
|
514
|
+
re.compile(r"(?:不得|不要|禁止|不能|严禁)[^。\n;;]{2,50}"),
|
|
515
|
+
]
|
|
516
|
+
# 完成标记:assistant 说"X已构建/X完成/X构建完成"
|
|
517
|
+
# 捕获完整短语(含"已构建"等),不拆开
|
|
518
|
+
completed_patterns = [
|
|
519
|
+
re.compile(
|
|
520
|
+
r"([\u4e00-\u9fa5A-Za-z0-9 ]{2,30}"
|
|
521
|
+
r"(?:已构建|已完成|已成功|构建完成|构建好了"
|
|
522
|
+
r"|做完了|搞定了|改完了|修好了|测完了|跑通了|部署完成|配置完成))"
|
|
523
|
+
),
|
|
524
|
+
]
|
|
230
525
|
|
|
231
526
|
for group in groups:
|
|
232
527
|
for event in group:
|
|
@@ -259,6 +554,19 @@ def extract_pinned_state(groups: Sequence[Sequence[SessionEvent]]) -> dict[str,
|
|
|
259
554
|
).strip()
|
|
260
555
|
if label:
|
|
261
556
|
attachment_refs.append(label)
|
|
557
|
+
# P0:从 user 消息提取约束
|
|
558
|
+
for pattern in constraint_patterns:
|
|
559
|
+
for m in pattern.findall(text):
|
|
560
|
+
c = m.strip().rstrip(",。;;")
|
|
561
|
+
if c and c not in constraints:
|
|
562
|
+
constraints.append(c)
|
|
563
|
+
elif event_type == "assistant_message" and text:
|
|
564
|
+
# P0:从 assistant 消息提取已完成步骤
|
|
565
|
+
for pattern in completed_patterns:
|
|
566
|
+
for m in pattern.findall(text):
|
|
567
|
+
s = m.strip().rstrip(",。;;")
|
|
568
|
+
if s and s not in completed_steps:
|
|
569
|
+
completed_steps.append(s)
|
|
262
570
|
|
|
263
571
|
unique_attachments: list[str] = []
|
|
264
572
|
for item in attachment_refs:
|
|
@@ -271,6 +579,8 @@ def extract_pinned_state(groups: Sequence[Sequence[SessionEvent]]) -> dict[str,
|
|
|
271
579
|
"pending_tools": pending_tools,
|
|
272
580
|
"attachment_refs": unique_attachments[-5:],
|
|
273
581
|
"current_user_goal": current_user_goal,
|
|
582
|
+
"constraints": constraints,
|
|
583
|
+
"completed_steps": completed_steps,
|
|
274
584
|
}
|
|
275
585
|
|
|
276
586
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Session 级并发锁与 stale guard(方案 §9.6)。
|
|
2
|
+
|
|
3
|
+
同一 Session 同时只允许一个 checkpoint/WorkingState 更新提交;并发 Turn 使用乐观版本或
|
|
4
|
+
session lock,失败方重新读取最新 checkpoint 后规划(方案 §9.6)。本模块提供进程内
|
|
5
|
+
per-session async lock(pod 重启清空,单进程内有效);跨进程/云端需由 Session Store 的乐观
|
|
6
|
+
锁或行锁兜底,本锁只做 best-effort 防同进程并发覆盖。
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import asyncio
|
|
12
|
+
from contextlib import asynccontextmanager
|
|
13
|
+
from typing import AsyncIterator
|
|
14
|
+
|
|
15
|
+
_SESSION_LOCKS: dict[str, asyncio.Lock] = {}
|
|
16
|
+
_REGISTRY_LOCK = asyncio.Lock()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
async def _get_or_create_lock(session_id: str) -> asyncio.Lock:
|
|
20
|
+
async with _REGISTRY_LOCK:
|
|
21
|
+
lock = _SESSION_LOCKS.get(session_id)
|
|
22
|
+
if lock is None:
|
|
23
|
+
lock = asyncio.Lock()
|
|
24
|
+
_SESSION_LOCKS[session_id] = lock
|
|
25
|
+
return lock
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@asynccontextmanager
|
|
29
|
+
async def session_compaction_lock(session_id: str, *, timeout: float = 30.0) -> AsyncIterator[None]:
|
|
30
|
+
"""获取 per-session compaction 锁(方案 §9.6)。
|
|
31
|
+
|
|
32
|
+
超时抛 ``asyncio.TimeoutError``,调用方按 stale guard 处理(重新读最新 checkpoint 再规划)。
|
|
33
|
+
"""
|
|
34
|
+
lock = await _get_or_create_lock(session_id)
|
|
35
|
+
try:
|
|
36
|
+
await asyncio.wait_for(lock.acquire(), timeout=timeout)
|
|
37
|
+
except asyncio.TimeoutError:
|
|
38
|
+
# stale guard:拿不到锁说明另一 turn 正在 compaction,本方放弃提交避免覆盖
|
|
39
|
+
raise
|
|
40
|
+
try:
|
|
41
|
+
yield
|
|
42
|
+
finally:
|
|
43
|
+
lock.release()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def clear_session_locks() -> None:
|
|
47
|
+
"""测试/运维用:清空所有 per-session 锁。"""
|
|
48
|
+
_SESSION_LOCKS.clear()
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
__all__ = ["clear_session_locks", "session_compaction_lock"]
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""部署时的 shell 进程环境变量转发规则。
|
|
2
|
+
|
|
3
|
+
通用 deploy (serverless/kcf/kce) 与 hermes/openclaw deploy 共用同一套规则:
|
|
4
|
+
按前缀 (KSADK_/OPENAI_/KSYUN_/E2B_) + 显式 allowlist 转发 shell 环境变量,
|
|
5
|
+
denylist 中的 CLI/builders/configs/web 模块本地键不转发。
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
from typing import Mapping, MutableMapping, Optional
|
|
10
|
+
|
|
11
|
+
from ksadk.configs.env_registry import ENV_VAR_REGISTRY
|
|
12
|
+
|
|
13
|
+
DEPLOY_PROCESS_ENV_ALLOWLIST = frozenset(
|
|
14
|
+
{
|
|
15
|
+
spec.name
|
|
16
|
+
for spec in ENV_VAR_REGISTRY
|
|
17
|
+
if spec.module
|
|
18
|
+
not in {
|
|
19
|
+
"builders",
|
|
20
|
+
"cli",
|
|
21
|
+
"configs",
|
|
22
|
+
"web",
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
) | frozenset(
|
|
26
|
+
{
|
|
27
|
+
"E2B_API_KEY",
|
|
28
|
+
"E2B_API_URL",
|
|
29
|
+
"OPENAI_API_BASE",
|
|
30
|
+
"OPENAI_API_KEY",
|
|
31
|
+
"OPENAI_BASE_URL",
|
|
32
|
+
"OPENAI_MODEL_NAME",
|
|
33
|
+
"SKILL_SPACE_ID",
|
|
34
|
+
"KSYUN_ACCESS_KEY",
|
|
35
|
+
"KSYUN_ACCOUNT_ID",
|
|
36
|
+
"KSYUN_REGION",
|
|
37
|
+
"KSYUN_SECRET_KEY",
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
DEPLOY_PROCESS_ENV_PREFIXES = ("KSADK_", "OPENAI_", "KSYUN_", "E2B_")
|
|
41
|
+
DEPLOY_PROCESS_ENV_DENYLIST = frozenset(
|
|
42
|
+
{spec.name for spec in ENV_VAR_REGISTRY if spec.module in {"builders", "cli", "configs", "web"}}
|
|
43
|
+
) | frozenset(
|
|
44
|
+
{
|
|
45
|
+
"KSADK_GLOBAL_CONFIG_ENV_KEYS",
|
|
46
|
+
"KSADK_UPDATED_AT",
|
|
47
|
+
"KSADK_VERSION",
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def should_forward_process_env(name: str) -> bool:
|
|
53
|
+
if name in DEPLOY_PROCESS_ENV_DENYLIST:
|
|
54
|
+
return False
|
|
55
|
+
return name in DEPLOY_PROCESS_ENV_ALLOWLIST or name.startswith(DEPLOY_PROCESS_ENV_PREFIXES)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def forward_shell_process_env(
|
|
59
|
+
base_env: MutableMapping[str, str],
|
|
60
|
+
environ: Optional[Mapping[str, str]] = None,
|
|
61
|
+
) -> MutableMapping[str, str]:
|
|
62
|
+
"""把 shell 进程环境中符合转发规则的键补进 ``base_env`` (setdefault 语义)。
|
|
63
|
+
|
|
64
|
+
不覆盖 ``base_env`` 已有的键 —— 调用方已 resolve 的值 (如 OPENAI_BASE_URL)
|
|
65
|
+
优先;本函数只负责把白名单/前缀内、但调用方未显式处理的键 (如 KSYUN_*)
|
|
66
|
+
带进 deploy payload。显式 --env/--env-file 由调用方在之后覆盖。
|
|
67
|
+
"""
|
|
68
|
+
source = os.environ if environ is None else environ
|
|
69
|
+
for key, value in sorted(source.items()):
|
|
70
|
+
if value and should_forward_process_env(key):
|
|
71
|
+
base_env.setdefault(key, value)
|
|
72
|
+
return base_env
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Local manifest assembly for server-managed runtime deployments."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from ksadk.builders.managed_runtime_builder import ManagedRuntimeBuilder
|
|
8
|
+
from ksadk.deployment.base import DeployTarget, PackageInfo
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def build_managed_runtime_package(
|
|
12
|
+
package_info: PackageInfo, target: DeployTarget
|
|
13
|
+
) -> PackageInfo:
|
|
14
|
+
"""Build the canonical manifest and retain its integrity digest for deploy."""
|
|
15
|
+
|
|
16
|
+
builder = ManagedRuntimeBuilder(
|
|
17
|
+
Path(package_info.project_dir),
|
|
18
|
+
runtime_version=str(target.extra.get("runtime_version") or ""),
|
|
19
|
+
)
|
|
20
|
+
result = builder.build()
|
|
21
|
+
if not result.success:
|
|
22
|
+
raise RuntimeError(f"构建失败: {result.error_message}")
|
|
23
|
+
|
|
24
|
+
package_info.metadata.update(result.metadata)
|
|
25
|
+
manifest_sha256 = str(result.metadata.get("manifest_sha256") or "").strip()
|
|
26
|
+
if manifest_sha256:
|
|
27
|
+
target.extra["manifest_sha256"] = manifest_sha256
|
|
28
|
+
if result.artifact_path is not None:
|
|
29
|
+
package_info.metadata["managed_manifest_path"] = str(result.artifact_path)
|
|
30
|
+
# ManagedRuntime deployment submits this exact YAML declaration to
|
|
31
|
+
# Server; it has no code ZIP, KS3 upload or CodeConfig.
|
|
32
|
+
package_info.metadata["managed_runtime_manifest"] = result.artifact_path.read_text(
|
|
33
|
+
encoding="utf-8"
|
|
34
|
+
)
|
|
35
|
+
return package_info
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
__all__ = ["build_managed_runtime_package"]
|
ksadk/deployment/manager.py
CHANGED
|
@@ -224,9 +224,9 @@ try:
|
|
|
224
224
|
except ImportError:
|
|
225
225
|
pass
|
|
226
226
|
|
|
227
|
-
from ksadk.runners import create_runner
|
|
228
227
|
from ksadk.detection import DetectionResult, FrameworkType
|
|
229
|
-
from ksadk.
|
|
228
|
+
from ksadk.runtime import RuntimeExecutor, RuntimeLaunchContext, build_default_runtime_registry
|
|
229
|
+
from ksadk.server import RuntimeAppConfig, configure_runtime_app, create_runtime_app
|
|
230
230
|
import uvicorn
|
|
231
231
|
|
|
232
232
|
# 检测结果 (部署时固化)
|
|
@@ -238,12 +238,28 @@ detection_result = DetectionResult(
|
|
|
238
238
|
agent_variable="{detection_result.agent_variable}"
|
|
239
239
|
)
|
|
240
240
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
241
|
+
runtime_context = RuntimeLaunchContext(
|
|
242
|
+
runtime_type=detection_result.type.value,
|
|
243
|
+
project_dir="/app",
|
|
244
|
+
detection=detection_result,
|
|
245
|
+
config=dict(getattr(detection_result, "raw_config", None) or {{}}),
|
|
246
|
+
)
|
|
247
|
+
# managed A2A discovery-only card:KSADK_A2A_RUNTIME_ID 非空时挂
|
|
248
|
+
# /.well-known/agent-card.json;注册前即可被 server 探测(a2a-runtime-inbound-wiring)。
|
|
249
|
+
_managed_a2a_card = None
|
|
250
|
+
if os.environ.get("KSADK_A2A_RUNTIME_ID", "").strip():
|
|
251
|
+
from ksadk.managed_a2a_card import build_managed_a2a_card_if_configured
|
|
252
|
+
|
|
253
|
+
_managed_a2a_card = build_managed_a2a_card_if_configured()
|
|
254
|
+
app = create_runtime_app(
|
|
255
|
+
RuntimeAppConfig(
|
|
256
|
+
runtime_type=detection_result.type.value,
|
|
257
|
+
runtime_executor=RuntimeExecutor(build_default_runtime_registry()),
|
|
258
|
+
launch_context=runtime_context,
|
|
259
|
+
a2a=_managed_a2a_card,
|
|
260
|
+
),
|
|
261
|
+
configure_runtime_app,
|
|
262
|
+
)
|
|
247
263
|
|
|
248
264
|
if __name__ == "__main__":
|
|
249
265
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|