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,257 @@
|
|
|
1
|
+
"""Cold recovery: deterministic outcomes for runs and items left open by a process exit.
|
|
2
|
+
|
|
3
|
+
The in-process path is :mod:`ksadk.events.pipeline` conformance recovery; this
|
|
4
|
+
module is its cold counterpart. Both produce the same kind of fact — canonical
|
|
5
|
+
events that enter the store and participate in replay — so consumers never
|
|
6
|
+
special-case a repaired stream. See ``docs/runtime-event-v2-cold-recovery-design.md``
|
|
7
|
+
for the decision rules.
|
|
8
|
+
|
|
9
|
+
Ownership: the outcome events use deterministic event ids
|
|
10
|
+
(:func:`ksadk.events.identity.stable_event_id` with ``framework="ksadk"``), so
|
|
11
|
+
two racing recoverers compute the same ids and the second writer is rejected by
|
|
12
|
+
``RuntimeEventStore._assert_same_fact``. Execution-level liveness (pod leases)
|
|
13
|
+
is out of scope here; the caller passes the ownership verdict in.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from dataclasses import dataclass, field
|
|
19
|
+
|
|
20
|
+
from ksadk.events.canonical import (
|
|
21
|
+
ErrorInfo,
|
|
22
|
+
ItemFailed,
|
|
23
|
+
RunInterrupted,
|
|
24
|
+
RuntimeEvent,
|
|
25
|
+
SourceRef,
|
|
26
|
+
)
|
|
27
|
+
from ksadk.events.canonical_replay import replay_projection
|
|
28
|
+
from ksadk.events.canonical_store import RuntimeEventStore
|
|
29
|
+
from ksadk.events.identity import stable_event_id
|
|
30
|
+
from ksadk.events.reducer import RunProjection
|
|
31
|
+
|
|
32
|
+
_RECOVERY_SOURCE_METADATA = {"recovery": "cold"}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclass
|
|
36
|
+
class OpenItem:
|
|
37
|
+
scope_id: str
|
|
38
|
+
item_id: str
|
|
39
|
+
item_kind: str
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@dataclass
|
|
43
|
+
class RecoveryFinding:
|
|
44
|
+
"""One open run detected by the scan, with the facts needed to settle it."""
|
|
45
|
+
|
|
46
|
+
run_id: str
|
|
47
|
+
scope_id: str
|
|
48
|
+
resumable: bool
|
|
49
|
+
continuation_id: str | None
|
|
50
|
+
resume_attempt_ids: list[str] = field(default_factory=list)
|
|
51
|
+
open_items: list[OpenItem] = field(default_factory=list)
|
|
52
|
+
last_seq: int = 0
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@dataclass
|
|
56
|
+
class RecoveryReport:
|
|
57
|
+
"""Outcome of a cold-recovery pass over one session."""
|
|
58
|
+
|
|
59
|
+
resumed_run_ids: list[str] = field(default_factory=list)
|
|
60
|
+
interrupted_run_ids: list[str] = field(default_factory=list)
|
|
61
|
+
written_events: list[RuntimeEvent] = field(default_factory=list)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _recovery_source(scope_id: str) -> SourceRef:
|
|
65
|
+
return SourceRef(
|
|
66
|
+
framework="ksadk",
|
|
67
|
+
metadata={**_RECOVERY_SOURCE_METADATA, "scope_id": scope_id},
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
async def scan_open_runs(
|
|
72
|
+
store: RuntimeEventStore,
|
|
73
|
+
session_id: str,
|
|
74
|
+
) -> list[RecoveryFinding]:
|
|
75
|
+
"""Detect runs left open, with their resumability and open items."""
|
|
76
|
+
|
|
77
|
+
findings: list[RecoveryFinding] = []
|
|
78
|
+
run_ids = await store.list_run_ids(session_id)
|
|
79
|
+
for run_id in run_ids:
|
|
80
|
+
projection = await replay_projection(store, session_id, run_id=run_id)
|
|
81
|
+
if projection.status not in (None, "running"):
|
|
82
|
+
continue
|
|
83
|
+
resumable = False
|
|
84
|
+
continuation_id: str | None = None
|
|
85
|
+
resume_attempt_ids: list[str] = []
|
|
86
|
+
for continuation in projection.continuations:
|
|
87
|
+
continuation_id = continuation.continuation_id
|
|
88
|
+
resume_attempt_ids.extend(continuation.resume_attempt_ids)
|
|
89
|
+
if getattr(continuation, "resumable", False):
|
|
90
|
+
resumable = True
|
|
91
|
+
findings.append(
|
|
92
|
+
RecoveryFinding(
|
|
93
|
+
run_id=run_id,
|
|
94
|
+
scope_id=_root_scope(projection),
|
|
95
|
+
resumable=resumable,
|
|
96
|
+
continuation_id=continuation_id,
|
|
97
|
+
resume_attempt_ids=resume_attempt_ids,
|
|
98
|
+
open_items=[
|
|
99
|
+
OpenItem(
|
|
100
|
+
scope_id=item.scope_id,
|
|
101
|
+
item_id=item.item_id,
|
|
102
|
+
item_kind=item.item_kind,
|
|
103
|
+
)
|
|
104
|
+
for item in projection.items
|
|
105
|
+
if item.status == "open"
|
|
106
|
+
],
|
|
107
|
+
last_seq=projection.last_seq or 0,
|
|
108
|
+
)
|
|
109
|
+
)
|
|
110
|
+
return findings
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _root_scope(projection: RunProjection) -> str:
|
|
114
|
+
return f"run:{projection.run_id}" if projection.run_id else "session"
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _recovery_event_id(scope_id: str, item_id: str, kind: str, run_id: str) -> str:
|
|
118
|
+
return stable_event_id(
|
|
119
|
+
"ksadk",
|
|
120
|
+
scope_id,
|
|
121
|
+
item_id,
|
|
122
|
+
kind,
|
|
123
|
+
part_id="cold_recovery",
|
|
124
|
+
native_occurrence_id=run_id,
|
|
125
|
+
chunk_ordinal=0,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def settle_finding(
|
|
130
|
+
finding: RecoveryFinding,
|
|
131
|
+
session_id: str,
|
|
132
|
+
*,
|
|
133
|
+
allow_resume: bool,
|
|
134
|
+
timestamp: float,
|
|
135
|
+
run_seq: int | None = None,
|
|
136
|
+
reason: str = "process_exit",
|
|
137
|
+
) -> list[RuntimeEvent]:
|
|
138
|
+
"""Synthesize the deterministic outcome events for one open run.
|
|
139
|
+
|
|
140
|
+
``allow_resume`` is the execution-level ownership verdict. When both the
|
|
141
|
+
continuation facts say ``resumable`` and the caller allows takeover, no
|
|
142
|
+
events are produced — the run is handed to the normal resume path.
|
|
143
|
+
Otherwise every open item gets an outcome and the run is interrupted.
|
|
144
|
+
``reason`` becomes the ``run.interrupted`` reason; recovery coordination
|
|
145
|
+
passes its own stable code (e.g. ``runtime_not_durably_attachable``).
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
if finding.resumable and allow_resume:
|
|
149
|
+
return []
|
|
150
|
+
events: list[RuntimeEvent] = []
|
|
151
|
+
base = dict(
|
|
152
|
+
schema_version=2,
|
|
153
|
+
timestamp=timestamp,
|
|
154
|
+
run_id=finding.run_id,
|
|
155
|
+
run_seq=run_seq,
|
|
156
|
+
scope_id=finding.scope_id,
|
|
157
|
+
source=_recovery_source(finding.scope_id),
|
|
158
|
+
)
|
|
159
|
+
# 结局事件占据 last_seq 之后的新 seq,reducer 要求 seq 严格单调。
|
|
160
|
+
next_seq = finding.last_seq
|
|
161
|
+
for item in finding.open_items:
|
|
162
|
+
code = (
|
|
163
|
+
"tool_outcome_unknown"
|
|
164
|
+
if item.item_kind == "tool_call"
|
|
165
|
+
else f"{item.item_kind}_outcome_unknown"
|
|
166
|
+
)
|
|
167
|
+
next_seq += 1
|
|
168
|
+
events.append(
|
|
169
|
+
ItemFailed(
|
|
170
|
+
event_id=_recovery_event_id(
|
|
171
|
+
item.scope_id, item.item_id, "item.failed", finding.run_id
|
|
172
|
+
),
|
|
173
|
+
seq=next_seq,
|
|
174
|
+
item_id=item.item_id,
|
|
175
|
+
item_kind=item.item_kind,
|
|
176
|
+
error=ErrorInfo(
|
|
177
|
+
code=code,
|
|
178
|
+
message="process exited before the item settled",
|
|
179
|
+
source="cold_recovery",
|
|
180
|
+
scope_id=item.scope_id,
|
|
181
|
+
item_id=item.item_id,
|
|
182
|
+
),
|
|
183
|
+
**{**base, "scope_id": item.scope_id},
|
|
184
|
+
)
|
|
185
|
+
)
|
|
186
|
+
next_seq += 1
|
|
187
|
+
events.append(
|
|
188
|
+
RunInterrupted(
|
|
189
|
+
event_id=_recovery_event_id(finding.scope_id, "run", "run.interrupted", finding.run_id),
|
|
190
|
+
seq=next_seq,
|
|
191
|
+
status="interrupted",
|
|
192
|
+
reason=reason,
|
|
193
|
+
continuation_id=finding.continuation_id,
|
|
194
|
+
**base,
|
|
195
|
+
)
|
|
196
|
+
)
|
|
197
|
+
return events
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
async def recover_session(
|
|
201
|
+
store: RuntimeEventStore,
|
|
202
|
+
session_id: str,
|
|
203
|
+
*,
|
|
204
|
+
caller_attempt_id: str | None = None,
|
|
205
|
+
allow_resume_for: "callable[[str], bool] | None" = None,
|
|
206
|
+
timestamp: float = 0.0,
|
|
207
|
+
) -> RecoveryReport:
|
|
208
|
+
"""Scan a session and persist deterministic outcomes for orphaned runs.
|
|
209
|
+
|
|
210
|
+
``caller_attempt_id`` is the caller's own resume attempt (the id the
|
|
211
|
+
execution layer stamped on its ``continuation.resumed``). A run whose last
|
|
212
|
+
resume attempt is the caller's own is never settled by this call — the
|
|
213
|
+
caller is the owner and resumes through the normal path. Written events
|
|
214
|
+
reuse the pipeline's persistence idempotency: a second recoverer racing on
|
|
215
|
+
the same session writes the same deterministic ids and is rejected as a
|
|
216
|
+
duplicate fact, not as an error.
|
|
217
|
+
"""
|
|
218
|
+
|
|
219
|
+
report = RecoveryReport()
|
|
220
|
+
for finding in await scan_open_runs(store, session_id):
|
|
221
|
+
if (
|
|
222
|
+
caller_attempt_id is not None
|
|
223
|
+
and finding.resume_attempt_ids
|
|
224
|
+
and finding.resume_attempt_ids[-1] == caller_attempt_id
|
|
225
|
+
):
|
|
226
|
+
# 同 attempt 不自杀:自己就是当前属主,走正常 resume 路径。
|
|
227
|
+
report.resumed_run_ids.append(finding.run_id)
|
|
228
|
+
continue
|
|
229
|
+
allow = allow_resume_for(finding.run_id) if allow_resume_for else False
|
|
230
|
+
events = settle_finding(finding, session_id, allow_resume=allow, timestamp=timestamp)
|
|
231
|
+
if not events:
|
|
232
|
+
report.resumed_run_ids.append(finding.run_id)
|
|
233
|
+
continue
|
|
234
|
+
for event in events:
|
|
235
|
+
try:
|
|
236
|
+
persisted, _created = await store.persist_one(session_id, event)
|
|
237
|
+
except ValueError as error:
|
|
238
|
+
# 并发竞态:另一恢复者已写入同 event_id 的结局(携带不同的
|
|
239
|
+
# 恢复时刻 timestamp,故 _assert_same_fact 视为冲突)。同一
|
|
240
|
+
# 确定性 id 的结局被抢先写入即本次恢复的目标已达成,吸收
|
|
241
|
+
# 而非报错;其他 id 冲突不是本模块产物,原样抛出。
|
|
242
|
+
if f"{event.event_id!r}" not in str(error):
|
|
243
|
+
raise
|
|
244
|
+
continue
|
|
245
|
+
report.written_events.append(persisted)
|
|
246
|
+
report.interrupted_run_ids.append(finding.run_id)
|
|
247
|
+
return report
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
__all__ = [
|
|
251
|
+
"OpenItem",
|
|
252
|
+
"RecoveryFinding",
|
|
253
|
+
"RecoveryReport",
|
|
254
|
+
"recover_session",
|
|
255
|
+
"scan_open_runs",
|
|
256
|
+
"settle_finding",
|
|
257
|
+
]
|
ksadk/events/content.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""Typed, JSON-serializable content values for canonical runtime events."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Annotated, Literal, TypeAlias, Union
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel, ConfigDict, Field, JsonValue
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class _ContentModel(BaseModel):
|
|
11
|
+
model_config = ConfigDict(extra="forbid", strict=True)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TextContent(_ContentModel):
|
|
15
|
+
content_type: Literal["text"] = "text"
|
|
16
|
+
part_id: str = Field(min_length=1)
|
|
17
|
+
text: str
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class JsonContent(_ContentModel):
|
|
21
|
+
content_type: Literal["json"] = "json"
|
|
22
|
+
part_id: str = Field(min_length=1)
|
|
23
|
+
value: JsonValue
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ToolCallContent(_ContentModel):
|
|
27
|
+
content_type: Literal["tool_call"] = "tool_call"
|
|
28
|
+
part_id: str = Field(min_length=1)
|
|
29
|
+
call_id: str = Field(min_length=1)
|
|
30
|
+
name: str = Field(min_length=1)
|
|
31
|
+
arguments: JsonValue
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ToolResultContent(_ContentModel):
|
|
35
|
+
content_type: Literal["tool_result"] = "tool_result"
|
|
36
|
+
part_id: str = Field(min_length=1)
|
|
37
|
+
call_id: str = Field(min_length=1)
|
|
38
|
+
result: JsonValue
|
|
39
|
+
is_error: bool = False
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class ArtifactContent(_ContentModel):
|
|
43
|
+
content_type: Literal["artifact"] = "artifact"
|
|
44
|
+
part_id: str = Field(min_length=1)
|
|
45
|
+
artifact_id: str = Field(min_length=1)
|
|
46
|
+
name: str = Field(min_length=1)
|
|
47
|
+
mime_type: str | None = None
|
|
48
|
+
uri: str | None = None
|
|
49
|
+
data: JsonValue = None
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class DataContent(_ContentModel):
|
|
53
|
+
content_type: Literal["data"] = "data"
|
|
54
|
+
part_id: str = Field(min_length=1)
|
|
55
|
+
data: JsonValue
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
ContentValue: TypeAlias = Annotated[
|
|
59
|
+
Union[
|
|
60
|
+
TextContent,
|
|
61
|
+
JsonContent,
|
|
62
|
+
ToolCallContent,
|
|
63
|
+
ToolResultContent,
|
|
64
|
+
ArtifactContent,
|
|
65
|
+
DataContent,
|
|
66
|
+
],
|
|
67
|
+
Field(discriminator="content_type"),
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
# An update carries one named part. ``op`` on ItemUpdated defines whether that
|
|
71
|
+
# part is appended or replaced; snapshots carry the complete ordered part set.
|
|
72
|
+
ContentUpdate: TypeAlias = ContentValue
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class ContentSnapshot(_ContentModel):
|
|
76
|
+
parts: tuple[ContentValue, ...] = Field(strict=False)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
__all__ = [
|
|
80
|
+
"ArtifactContent",
|
|
81
|
+
"ContentSnapshot",
|
|
82
|
+
"ContentUpdate",
|
|
83
|
+
"ContentValue",
|
|
84
|
+
"DataContent",
|
|
85
|
+
"JsonContent",
|
|
86
|
+
"TextContent",
|
|
87
|
+
"ToolCallContent",
|
|
88
|
+
"ToolResultContent",
|
|
89
|
+
]
|
ksadk/events/identity.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"""Deterministic identities for canonical runtime scopes, items, and events."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import hashlib
|
|
6
|
+
import json
|
|
7
|
+
import unicodedata
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def stable_scope_id(framework: str, *native_components: Any) -> str:
|
|
12
|
+
"""Derive a stable execution-scope id from source-native components."""
|
|
13
|
+
|
|
14
|
+
return _stable_identity("scope", framework, native_components)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def stable_item_id(framework: str, *native_components: Any) -> str:
|
|
18
|
+
"""Derive a stable item id from source-native components."""
|
|
19
|
+
|
|
20
|
+
return _stable_identity("item", framework, native_components)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def stable_part_id(framework: str, *native_components: Any) -> str:
|
|
24
|
+
"""Derive a stable content-part id from source-native components."""
|
|
25
|
+
|
|
26
|
+
return _stable_identity("part", framework, native_components)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def stable_event_id(
|
|
30
|
+
framework: str,
|
|
31
|
+
scope_id: str,
|
|
32
|
+
item_id: str,
|
|
33
|
+
event_type: str,
|
|
34
|
+
part_id: str,
|
|
35
|
+
native_occurrence_id: str,
|
|
36
|
+
chunk_ordinal: int,
|
|
37
|
+
) -> str:
|
|
38
|
+
"""Derive a mutation-occurrence id, distinct from the source item id."""
|
|
39
|
+
|
|
40
|
+
return _stable_identity(
|
|
41
|
+
"event",
|
|
42
|
+
framework,
|
|
43
|
+
(
|
|
44
|
+
scope_id,
|
|
45
|
+
item_id,
|
|
46
|
+
event_type,
|
|
47
|
+
part_id,
|
|
48
|
+
native_occurrence_id,
|
|
49
|
+
chunk_ordinal,
|
|
50
|
+
),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _stable_identity(kind: str, framework: Any, components: tuple[Any, ...]) -> str:
|
|
55
|
+
if not components:
|
|
56
|
+
raise ValueError("identity component must not be empty")
|
|
57
|
+
normalized = [_normalize_component(framework)]
|
|
58
|
+
normalized.extend(_normalize_component(component) for component in components)
|
|
59
|
+
payload = json.dumps(
|
|
60
|
+
{"components": normalized, "kind": kind},
|
|
61
|
+
ensure_ascii=False,
|
|
62
|
+
separators=(",", ":"),
|
|
63
|
+
sort_keys=True,
|
|
64
|
+
).encode("utf-8")
|
|
65
|
+
digest = hashlib.sha256(payload).hexdigest()[:24]
|
|
66
|
+
return f"{kind}_{digest}"
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _normalize_component(component: Any) -> str:
|
|
70
|
+
if component is None:
|
|
71
|
+
raise ValueError("identity component must not be empty")
|
|
72
|
+
if isinstance(component, bool):
|
|
73
|
+
value = "true" if component else "false"
|
|
74
|
+
elif isinstance(component, (str, int)):
|
|
75
|
+
value = str(component)
|
|
76
|
+
else:
|
|
77
|
+
raise TypeError(
|
|
78
|
+
f"identity component must be a string or integer, got {type(component).__name__}"
|
|
79
|
+
)
|
|
80
|
+
value = unicodedata.normalize("NFC", value)
|
|
81
|
+
if not value.strip():
|
|
82
|
+
raise ValueError("identity component must not be empty")
|
|
83
|
+
return value
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
__all__ = ["stable_event_id", "stable_item_id", "stable_part_id", "stable_scope_id"]
|