agentengine-sdk-python 0.8.5__py3-none-any.whl → 0.8.6__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.5.dist-info → agentengine_sdk_python-0.8.6.dist-info}/METADATA +12 -8
- {agentengine_sdk_python-0.8.5.dist-info → agentengine_sdk_python-0.8.6.dist-info}/RECORD +823 -388
- ksadk/_async_iterators.py +79 -0
- ksadk/_build_provenance.json +1 -1
- ksadk/_model_anthropic.py +49 -0
- ksadk/_model_input.py +86 -0
- ksadk/_model_json.py +40 -0
- ksadk/_model_reasoning.py +17 -0
- ksadk/_model_refusal.py +20 -0
- ksadk/_model_sse.py +163 -0
- ksadk/a2a/__init__.py +157 -167
- ksadk/a2a/_invocation_state.py +86 -0
- ksadk/a2a/_space_client_events.py +33 -22
- ksadk/a2a/adk.py +194 -0
- ksadk/a2a/adk_invocation_context.py +242 -0
- ksadk/a2a/adk_runtime.py +126 -0
- ksadk/a2a/adk_tools.py +319 -0
- ksadk/a2a/bootstrap.py +149 -23
- ksadk/a2a/build_validation.py +147 -0
- ksadk/a2a/card.py +23 -15
- ksadk/a2a/codex.py +160 -0
- ksadk/a2a/codex_checkpoint.py +111 -0
- ksadk/a2a/codex_recovery.py +96 -0
- ksadk/a2a/codex_recovery_events.py +123 -0
- ksadk/a2a/codex_runtime.py +198 -0
- ksadk/a2a/codex_session_checkpoint.py +162 -0
- ksadk/a2a/composition.py +88 -0
- ksadk/a2a/context_store.py +118 -19
- ksadk/a2a/control_plane.py +108 -106
- ksadk/a2a/event_adapter.py +92 -193
- ksadk/a2a/executor.py +257 -85
- ksadk/a2a/exposure.py +106 -0
- ksadk/a2a/external_transport.py +3 -4
- ksadk/a2a/identity.py +106 -12
- ksadk/a2a/ids.py +14 -3
- ksadk/a2a/inbound_kernel.py +133 -0
- ksadk/a2a/interaction_wire.py +76 -0
- ksadk/a2a/invocation_checkpoint.py +274 -0
- ksadk/a2a/invocation_policy.py +87 -0
- ksadk/a2a/invocation_publication.py +210 -0
- ksadk/a2a/invocation_service.py +972 -0
- ksadk/a2a/invocation_types.py +459 -0
- ksadk/a2a/kernel_task_adapter.py +259 -0
- ksadk/a2a/langgraph.py +20 -7
- ksadk/a2a/langgraph_invocation_context.py +136 -0
- ksadk/a2a/langgraph_managed.py +150 -0
- ksadk/a2a/langgraph_recovery.py +32 -0
- ksadk/a2a/langgraph_runtime.py +89 -0
- ksadk/a2a/langgraph_tool_runtime.py +132 -0
- ksadk/a2a/langgraph_tools.py +63 -0
- ksadk/a2a/message_digest.py +40 -0
- ksadk/a2a/platform.py +389 -0
- ksadk/a2a/policy_refs.py +13 -0
- ksadk/a2a/presentation.py +402 -0
- ksadk/a2a/product_kernel_facts.py +177 -0
- ksadk/a2a/product_key.py +99 -0
- ksadk/a2a/protocol_errors.py +116 -0
- ksadk/a2a/result_text.py +49 -0
- ksadk/a2a/resume_store.py +93 -3
- ksadk/a2a/routes.py +6 -1
- ksadk/a2a/runtime_approval.py +198 -0
- ksadk/a2a/runtime_input.py +151 -0
- ksadk/a2a/server.py +16 -7
- ksadk/a2a/space_client.py +101 -16
- ksadk/a2a/task_adapter.py +19 -5
- ksadk/a2a/task_event_dispatcher.py +39 -2
- ksadk/a2a/task_event_outbox.py +215 -0
- ksadk/a2a/task_event_outbox_owned.py +130 -0
- ksadk/a2a/task_store.py +37 -0
- ksadk/a2a/tool_activity.py +176 -0
- ksadk/a2a/workload_tokens.py +134 -0
- ksadk/api/client.py +32 -79
- ksadk/api/sse_stream.py +96 -0
- ksadk/builders/code_builder.py +83 -106
- ksadk/builders/container_builder.py +11 -29
- ksadk/builders/framework_requirements.py +2 -0
- ksadk/builders/managed_runtime_builder.py +12 -0
- ksadk/builders/source_provenance.py +87 -0
- ksadk/cli/cmd_a2a.py +43 -0
- ksadk/cli/cmd_build.py +9 -0
- ksadk/cli/cmd_deploy.py +27 -2
- ksadk/cli/cmd_invoke.py +45 -92
- ksadk/cli/cmd_studio.py +5 -1
- ksadk/cli/cmd_web.py +2 -0
- ksadk/cli/hosted_invoke.py +206 -0
- ksadk/cli/invoke_content.py +60 -0
- ksadk/cli/runtime_bootstrap.py +27 -5
- ksadk/codex/_expert_request_reader.py +48 -0
- ksadk/codex/a2a_tools.py +140 -0
- ksadk/codex/async_approval.py +169 -0
- ksadk/codex/async_client.py +938 -0
- ksadk/codex/async_proxy.py +216 -0
- ksadk/codex/base_runtime.py +25 -0
- ksadk/codex/client.py +3 -1048
- ksadk/codex/client_payloads.py +85 -0
- ksadk/codex/rollout_checkpoint.py +264 -0
- ksadk/codex/runtime.py +290 -54
- ksadk/common/auth.py +2 -2
- ksadk/common/cloud_headers.py +36 -0
- ksadk/common/diagnostics.py +34 -0
- ksadk/common/kop_client.py +2 -1
- ksadk/configs/env_registry.py +106 -127
- ksadk/configs/env_registry_a2a.py +173 -0
- ksadk/configs/env_registry_studio.py +53 -5
- ksadk/configs/global_config.py +1 -0
- ksadk/configs/settings.py +6 -0
- ksadk/context_engine/assembler.py +9 -0
- ksadk/context_engine/contributors.py +80 -17
- ksadk/context_engine/instruction_authority.py +18 -0
- ksadk/conversations/attachments.py +53 -15
- ksadk/conversations/contracts.py +28 -9
- ksadk/conversations/message_projection.py +30 -125
- ksadk/conversations/message_projection_blocks.py +137 -0
- ksadk/conversations/model_context.py +11 -3
- ksadk/conversations/projector.py +63 -0
- ksadk/conversations/runtime_compaction.py +7 -2
- ksadk/conversations/runtime_input.py +16 -4
- ksadk/conversations/runtime_payloads.py +4 -0
- ksadk/conversations/runtime_persistence.py +192 -24
- ksadk/conversations/runtime_preparation.py +85 -6
- ksadk/conversations/runtime_projection.py +217 -0
- ksadk/conversations/runtime_resume.py +141 -70
- ksadk/conversations/tool_receipt_resume.py +387 -0
- ksadk/conversations/tool_receipts.py +32 -0
- ksadk/deployment/env_forward.py +5 -0
- ksadk/deployment/manager.py +15 -6
- ksadk/deployment/providers/serverless.py +76 -136
- ksadk/deployment/providers/serverless_payloads.py +122 -0
- ksadk/evaluation/agent_eval_client.py +2 -1
- ksadk/evaluation/contracts.py +78 -3
- ksadk/evaluation/evaluators.py +166 -1
- ksadk/evaluation/evidence.py +271 -4
- ksadk/evaluation/local_adapter.py +76 -12
- ksadk/evaluation/studio_build_adapter.py +73 -9
- ksadk/events/adapters/_a2a_checkpoint.py +151 -0
- ksadk/events/adapters/_a2a_snapshot.py +18 -14
- ksadk/events/adapters/_a2a_support.py +15 -3
- ksadk/events/adapters/_a2a_tool_activity.py +123 -0
- ksadk/events/adapters/_codex_errors.py +49 -0
- ksadk/events/adapters/_langgraph_support.py +12 -1
- ksadk/events/adapters/a2a.py +54 -26
- ksadk/events/adapters/adk.py +188 -30
- ksadk/events/adapters/codex.py +33 -7
- ksadk/events/adapters/langgraph.py +16 -6
- ksadk/events/canonical.py +5 -0
- ksadk/events/canonical_store.py +200 -4
- ksadk/events/reducer.py +82 -0
- ksadk/events/run_authority.py +176 -0
- ksadk/harness/__init__.py +4 -0
- ksadk/harness/artifact_adapters/__init__.py +1 -0
- ksadk/harness/artifact_adapters/native_page_budget.py +172 -0
- ksadk/harness/artifact_adapters/native_search.py +249 -0
- ksadk/harness/artifact_adapters/native_search_budget.py +134 -0
- ksadk/harness/artifact_adapters/native_store.py +115 -0
- ksadk/harness/artifact_adapters/native_tool.py +222 -0
- ksadk/harness/artifact_store.py +26 -9
- ksadk/harness/browser_adapters/__init__.py +6 -0
- ksadk/harness/browser_adapters/native_browser_tool.py +92 -0
- ksadk/harness/browser_adapters/native_dom_snapshot.py +187 -0
- ksadk/harness/browser_adapters/native_playwright.py +953 -0
- ksadk/harness/browser_adapters/native_vision.py +295 -0
- ksadk/harness/capability_adapters/__init__.py +1 -0
- ksadk/harness/capability_adapters/native_dsh.py +289 -0
- ksadk/harness/capability_runtime.py +104 -9
- ksadk/harness/compaction_record.py +31 -0
- ksadk/harness/compiler.py +3 -3
- ksadk/harness/config.py +28 -5
- ksadk/harness/conformance/contract.py +9 -11
- ksadk/harness/context_engine.py +18 -33
- ksadk/harness/context_sections.py +397 -0
- ksadk/harness/diagnostic_adapters/__init__.py +1 -0
- ksadk/harness/diagnostic_adapters/contracts.py +70 -0
- ksadk/harness/diagnostic_adapters/lsp_rpc.py +210 -0
- ksadk/harness/diagnostic_adapters/native_lsp.py +286 -0
- ksadk/harness/engine/completion_guard.py +16 -1
- ksadk/harness/engine/context_pipeline.py +864 -92
- ksadk/harness/engine/graph_builder.py +123 -630
- ksadk/harness/engine/hooked_reasoner.py +380 -0
- ksadk/harness/engine/langgraph.py +126 -8
- ksadk/harness/engine/mcp_disclosure.py +65 -114
- ksadk/harness/engine/phases/__init__.py +6 -0
- ksadk/harness/engine/phases/context.py +48 -0
- ksadk/harness/engine/phases/interaction.py +31 -0
- ksadk/harness/engine/phases/reason.py +552 -0
- ksadk/harness/engine/phases/tools.py +638 -0
- ksadk/harness/engine/policy_runtime.py +21 -10
- ksadk/harness/engine/postgres_checkpointer.py +325 -2
- ksadk/harness/engine/run_control_bridge.py +21 -1
- ksadk/harness/engine/run_types.py +10 -0
- ksadk/harness/engine/skill_disclosure.py +98 -12
- ksadk/harness/engine/steering.py +177 -0
- ksadk/harness/engine/subagents.py +18 -1
- ksadk/harness/engine/tool_dispatch.py +112 -7
- ksadk/harness/events.py +39 -2
- ksadk/harness/execution_policy.py +10 -0
- ksadk/harness/hooks.py +259 -0
- ksadk/harness/loop/reason.py +281 -36
- ksadk/harness/loop/tools.py +157 -12
- ksadk/harness/managed_runtime.py +254 -94
- ksadk/harness/mcp_disclosure_contract.py +85 -0
- ksadk/harness/mcp_result_policy.py +44 -0
- ksadk/harness/mcp_runtime.py +33 -0
- ksadk/harness/micro_compact.py +69 -0
- ksadk/harness/model_adapters/__init__.py +1 -0
- ksadk/harness/model_adapters/native_mcp_media.py +100 -0
- ksadk/harness/model_adapters/native_mcp_result.py +36 -0
- ksadk/harness/model_adapters/native_openai.py +703 -0
- ksadk/harness/model_capability.py +223 -8
- ksadk/harness/model_provider.py +214 -4
- ksadk/harness/multimodal.py +57 -0
- ksadk/harness/native/__init__.py +1 -0
- ksadk/harness/native/activation_contract.py +25 -0
- ksadk/harness/native/activation_recovery.py +29 -0
- ksadk/harness/native/adapters.py +291 -0
- ksadk/harness/native/artifact_contract.py +14 -0
- ksadk/harness/native/artifact_partial_read_capacity.py +171 -0
- ksadk/harness/native/artifact_read_capacity.py +182 -0
- ksadk/harness/native/artifact_read_contract.py +27 -0
- ksadk/harness/native/artifact_runtime.py +408 -0
- ksadk/harness/native/artifact_search_capacity.py +206 -0
- ksadk/harness/native/artifact_search_contract.py +40 -0
- ksadk/harness/native/artifact_single_read_capacity.py +170 -0
- ksadk/harness/native/browser_contract.py +229 -0
- ksadk/harness/native/browser_recovery.py +183 -0
- ksadk/harness/native/capabilities.py +204 -0
- ksadk/harness/native/child_approval.py +60 -0
- ksadk/harness/native/child_budget.py +136 -0
- ksadk/harness/native/child_cancellation.py +80 -0
- ksadk/harness/native/child_input.py +98 -0
- ksadk/harness/native/child_input_runtime.py +59 -0
- ksadk/harness/native/child_interruption.py +81 -0
- ksadk/harness/native/child_lifecycle.py +246 -0
- ksadk/harness/native/child_lifecycle_contract.py +91 -0
- ksadk/harness/native/child_notifications.py +75 -0
- ksadk/harness/native/child_promotion.py +66 -0
- ksadk/harness/native/command_runtime.py +99 -0
- ksadk/harness/native/completion.py +302 -0
- ksadk/harness/native/completion_text.py +116 -0
- ksadk/harness/native/context.py +358 -0
- ksadk/harness/native/context_artifact_page.py +75 -0
- ksadk/harness/native/context_compaction_projection.py +131 -0
- ksadk/harness/native/context_contributions.py +320 -0
- ksadk/harness/native/context_contributor_contract.py +133 -0
- ksadk/harness/native/context_driver.py +820 -0
- ksadk/harness/native/context_fresh_tools.py +49 -0
- ksadk/harness/native/context_history.py +272 -0
- ksadk/harness/native/context_microcompact.py +61 -0
- ksadk/harness/native/context_partial_summary.py +58 -0
- ksadk/harness/native/context_partition.py +492 -0
- ksadk/harness/native/context_pruning.py +275 -0
- ksadk/harness/native/context_reduction.py +60 -0
- ksadk/harness/native/context_replay.py +148 -0
- ksadk/harness/native/context_request_projection.py +526 -0
- ksadk/harness/native/context_runtime.py +976 -0
- ksadk/harness/native/context_runtime_contracts.py +409 -0
- ksadk/harness/native/context_search.py +112 -0
- ksadk/harness/native/context_source_fragments.py +188 -0
- ksadk/harness/native/context_source_progress.py +119 -0
- ksadk/harness/native/context_summary_planning.py +788 -0
- ksadk/harness/native/context_summary_recovery.py +105 -0
- ksadk/harness/native/delivery_review.py +331 -0
- ksadk/harness/native/delivery_review_contract.py +54 -0
- ksadk/harness/native/effect_admission.py +82 -0
- ksadk/harness/native/effect_control.py +318 -0
- ksadk/harness/native/effect_receipts.py +729 -0
- ksadk/harness/native/effect_runtime.py +303 -0
- ksadk/harness/native/effective_configuration.py +28 -0
- ksadk/harness/native/engine.py +945 -0
- ksadk/harness/native/final_output.py +34 -0
- ksadk/harness/native/final_submission.py +58 -0
- ksadk/harness/native/finalization_workspace.py +96 -0
- ksadk/harness/native/fork.py +151 -0
- ksadk/harness/native/guidance.py +91 -0
- ksadk/harness/native/history.py +381 -0
- ksadk/harness/native/hook_executor.py +205 -0
- ksadk/harness/native/hook_runtime_contract.py +282 -0
- ksadk/harness/native/interaction_observation.py +117 -0
- ksadk/harness/native/lease.py +103 -0
- ksadk/harness/native/machine.py +974 -0
- ksadk/harness/native/mcp_result_governance.py +156 -0
- ksadk/harness/native/model.py +570 -0
- ksadk/harness/native/model_feedback.py +63 -0
- ksadk/harness/native/model_input.py +30 -0
- ksadk/harness/native/model_recovery_contract.py +35 -0
- ksadk/harness/native/model_replay.py +128 -0
- ksadk/harness/native/model_request.py +133 -0
- ksadk/harness/native/model_runtime.py +196 -0
- ksadk/harness/native/model_takeover.py +419 -0
- ksadk/harness/native/model_tool_batch.py +40 -0
- ksadk/harness/native/observed_progress.py +46 -0
- ksadk/harness/native/operator_guidance.py +201 -0
- ksadk/harness/native/output_contract.py +80 -0
- ksadk/harness/native/output_recovery.py +24 -0
- ksadk/harness/native/ports.py +749 -0
- ksadk/harness/native/precompact_hook_runtime.py +171 -0
- ksadk/harness/native/replay_context.py +149 -0
- ksadk/harness/native/request_media.py +112 -0
- ksadk/harness/native/restore_contract.py +16 -0
- ksadk/harness/native/run_clock.py +120 -0
- ksadk/harness/native/state.py +436 -0
- ksadk/harness/native/steering.py +170 -0
- ksadk/harness/native/stop_hook_runtime.py +151 -0
- ksadk/harness/native/studio_admission.py +29 -0
- ksadk/harness/native/subagents.py +86 -0
- ksadk/harness/native/task_policy.py +99 -0
- ksadk/harness/native/task_progress.py +86 -0
- ksadk/harness/native/terminal_verification.py +43 -0
- ksadk/harness/native/tool_argument_feedback.py +178 -0
- ksadk/harness/native/tool_budget.py +253 -0
- ksadk/harness/native/tool_error_streak.py +89 -0
- ksadk/harness/native/tool_hook_runtime.py +343 -0
- ksadk/harness/native/tool_input_validation.py +58 -0
- ksadk/harness/native/tool_interruption.py +96 -0
- ksadk/harness/native/tool_observation.py +259 -0
- ksadk/harness/native/tool_progress.py +223 -0
- ksadk/harness/native/tool_recovery.py +25 -0
- ksadk/harness/native/tool_scheduling.py +33 -0
- ksadk/harness/native/tool_schema.py +126 -0
- ksadk/harness/native/transitions.py +151 -0
- ksadk/harness/native/turn_control.py +98 -0
- ksadk/harness/native/user_document.py +98 -0
- ksadk/harness/native/user_document_capture.py +49 -0
- ksadk/harness/native/user_input.py +87 -0
- ksadk/harness/native/verification.py +432 -0
- ksadk/harness/native/verification_binding.py +40 -0
- ksadk/harness/native/verification_runtime.py +233 -0
- ksadk/harness/native/verification_workspace.py +67 -0
- ksadk/harness/native_driver_failure.py +123 -0
- ksadk/harness/native_facade.py +977 -0
- ksadk/harness/native_factory.py +244 -0
- ksadk/harness/native_projection.py +503 -0
- ksadk/harness/native_runtime.py +621 -0
- ksadk/harness/native_shadow.py +250 -0
- ksadk/harness/native_shadow_inputs.py +146 -0
- ksadk/harness/progress_adapters/__init__.py +5 -0
- ksadk/harness/progress_adapters/native_todo.py +75 -0
- ksadk/harness/prompt_cache.py +65 -3
- ksadk/harness/public_activity.py +59 -0
- ksadk/harness/public_output.py +30 -0
- ksadk/harness/public_summary.py +36 -0
- ksadk/harness/reasoner.py +331 -22
- ksadk/harness/rpc.py +200 -0
- ksadk/harness/run_control.py +107 -2
- ksadk/harness/runtime.py +11 -2
- ksadk/harness/runtime_capabilities.py +71 -1
- ksadk/harness/sandbox_backend.py +203 -0
- ksadk/harness/sdk.py +153 -0
- ksadk/harness/session_store.py +370 -24
- ksadk/harness/skill_adapters/__init__.py +1 -0
- ksadk/harness/skill_adapters/native_bundle.py +148 -0
- ksadk/harness/skill_adapters/native_disclosure.py +306 -0
- ksadk/harness/skill_intent.py +47 -0
- ksadk/harness/skill_runtime.py +74 -16
- ksadk/harness/spec.py +20 -10
- ksadk/harness/state.py +2 -0
- ksadk/harness/stores/__init__.py +14 -0
- ksadk/harness/stores/native_command_settlement.py +65 -0
- ksadk/harness/stores/native_contract.py +311 -0
- ksadk/harness/stores/native_memory.py +326 -0
- ksadk/harness/stores/native_memory_archive.py +70 -0
- ksadk/harness/stores/native_migration_cli.py +91 -0
- ksadk/harness/stores/native_outbox.py +56 -0
- ksadk/harness/stores/native_sqlite.py +782 -0
- ksadk/harness/stores/native_sqlite_audit.py +29 -0
- ksadk/harness/stores/native_sqlite_migration.py +252 -0
- ksadk/harness/subagent.py +12 -2
- ksadk/harness/subagent_adapters/checkpoint_recovery.py +120 -0
- ksadk/harness/subagent_adapters/native_background_child.py +803 -0
- ksadk/harness/subagent_adapters/native_child.py +819 -0
- ksadk/harness/subagent_adapters/native_child_approval.py +128 -0
- ksadk/harness/subagent_adapters/native_child_continuation.py +51 -0
- ksadk/harness/subagent_adapters/native_child_result.py +392 -0
- ksadk/harness/subagent_adapters/prepared_recovery.py +120 -0
- ksadk/harness/tool_display.py +75 -0
- ksadk/harness/tool_display_contract.py +134 -0
- ksadk/harness/tool_output.py +141 -0
- ksadk/harness/tool_policy.py +3 -0
- ksadk/harness/tool_result_policy.py +216 -0
- ksadk/harness/tools.py +52 -0
- ksadk/harness/workspace_adapters/__init__.py +6 -0
- ksadk/harness/workspace_adapters/native_directory.py +180 -0
- ksadk/harness/workspace_adapters/native_git.py +208 -0
- ksadk/harness/workspace_adapters/native_isolation.py +350 -0
- ksadk/interaction/providers/langgraph.py +8 -1
- ksadk/kernel/bootstrap.py +144 -160
- ksadk/kernel/contract_fingerprints.py +45 -1
- ksadk/kernel/contracts.py +25 -0
- ksadk/kernel/control.py +153 -33
- ksadk/kernel/execution_grants.py +209 -2
- ksadk/kernel/execution_grants_memory.py +127 -8
- ksadk/kernel/execution_grants_postgres.py +188 -10
- ksadk/kernel/execution_grants_sqlite.py +235 -9
- ksadk/kernel/execution_host_ingress.py +1071 -0
- ksadk/kernel/history_projection.py +120 -0
- ksadk/kernel/ingress.py +117 -204
- ksadk/kernel/ingress_bootstrap.py +268 -0
- ksadk/kernel/legacy_history.py +179 -0
- ksadk/kernel/memory_store.py +38 -48
- ksadk/kernel/memory_store_projection.py +63 -0
- ksadk/kernel/postgres_event_log.py +181 -0
- ksadk/kernel/postgres_store.py +167 -198
- ksadk/kernel/readiness.py +125 -0
- ksadk/kernel/recovery.py +89 -3
- ksadk/kernel/recovery_projection.py +124 -0
- ksadk/kernel/runtime_checkpoint.py +34 -0
- ksadk/kernel/sql/001_agent_kernel.sql +5 -0
- ksadk/kernel/sqlite_schema.py +100 -0
- ksadk/kernel/sqlite_store.py +147 -216
- ksadk/kernel/store.py +47 -15
- ksadk/kernel/teams_artifact_tools.py +392 -0
- ksadk/kernel/teams_effects.py +851 -0
- ksadk/kernel/teams_execution_context.py +408 -0
- ksadk/kernel/teams_host_http.py +237 -0
- ksadk/kernel/teams_material_transport.py +245 -0
- ksadk/kernel/teams_materials.py +318 -0
- ksadk/kernel/teams_runtime_bootstrap.py +604 -0
- ksadk/kernel/teams_tool_runtime.py +273 -0
- ksadk/kernel/teams_workspace.py +259 -0
- ksadk/kernel/worker.py +323 -332
- ksadk/kernel/worker_controls.py +454 -0
- ksadk/kernel/worker_identity.py +27 -0
- ksadk/kernel/worker_interactions.py +197 -0
- ksadk/knowledge_base/client.py +15 -1
- ksadk/managed_runtime.py +29 -2
- ksadk/memory/adk/backends/http_ltm_backend.py +2 -1
- ksadk/memory/adk/backends/sdk_ltm_backend.py +15 -1
- ksadk/memory/adk/bounded_database_session_service.py +232 -0
- ksadk/memory/adk/resilient_session_service.py +115 -15
- ksadk/memory/adk/short_term_memory.py +8 -9
- ksadk/memory/extraction.py +120 -7
- ksadk/memory/providers/local_candidates.py +183 -0
- ksadk/memory/providers/local_sqlite.py +252 -78
- ksadk/memory/resolved_policy.py +12 -7
- ksadk/model_gateway/__init__.py +29 -0
- ksadk/model_gateway/client.py +253 -0
- ksadk/model_gateway/events.py +113 -0
- ksadk/model_gateway/matrix.py +297 -0
- ksadk/model_proxy/compat.py +670 -0
- ksadk/model_proxy/server.py +10 -7
- ksadk/model_proxy/transform.py +37 -9
- ksadk/plugins/bridges/dsh.py +18 -20
- ksadk/plugins/bridges/dsh_profile_manifest.py +36 -0
- ksadk/plugins/builtin_resources.py +199 -0
- ksadk/plugins/builtins.py +380 -186
- ksadk/plugins/context_contributor.py +15 -4
- ksadk/plugins/dsh_dependency_policy.py +41 -0
- ksadk/plugins/dsh_toolchain.py +24 -35
- ksadk/plugins/execution_host.py +8 -0
- ksadk/plugins/host.py +73 -5
- ksadk/plugins/kernel_adapter.py +44 -1
- ksadk/plugins/memory_provider.py +180 -0
- ksadk/plugins/providers/_process_group.py +50 -0
- ksadk/plugins/providers/bundles/dsh-knowledge/index.mjs +24 -2
- ksadk/plugins/providers/bundles/dsh-knowledge/package.json +1 -1
- ksadk/plugins/providers/bundles/dsh-memory/package.json +1 -1
- ksadk/plugins/providers/bundles/dsh-skill-center/package.json +1 -1
- ksadk/plugins/providers/bundles/dsh-teams-tools/package.json +1 -1
- ksadk/plugins/providers/bundles/ksadk-dsh-capability-host/package.json +1 -1
- ksadk/plugins/providers/codex.py +42 -38
- ksadk/plugins/providers/codex_native.py +20 -0
- ksadk/plugins/providers/codex_skills.py +46 -0
- ksadk/plugins/providers/dsh_capabilities.py +16 -171
- ksadk/plugins/providers/dsh_connector_lease.py +225 -0
- ksadk/plugins/providers/dsh_mcp.py +163 -1
- ksadk/plugins/providers/harness.py +247 -34
- ksadk/plugins/providers/harness_context.py +61 -0
- ksadk/plugins/providers/harness_contributions.py +241 -0
- ksadk/plugins/providers/harness_delegation.py +91 -14
- ksadk/plugins/providers/harness_hooks.py +121 -0
- ksadk/plugins/providers/harness_managed.py +269 -175
- ksadk/plugins/providers/harness_tools.py +165 -36
- ksadk/plugins/providers/legacy_catalog.py +1 -1
- ksadk/plugins/providers/mcp_projection.py +100 -3
- ksadk/plugins/providers/platform_resources.py +16 -6
- ksadk/plugins/teams/application.py +3 -143
- ksadk/plugins/teams/build_artifacts.py +460 -0
- ksadk/plugins/teams/cloud_contract_fingerprints.py +22 -0
- ksadk/plugins/teams/cloud_contracts.py +928 -0
- ksadk/plugins/teams/cloud_permits.py +250 -0
- ksadk/plugins/teams/domain.py +201 -148
- ksadk/plugins/teams/effect_contracts.py +255 -0
- ksadk/plugins/teams/execution_projection.py +255 -0
- ksadk/plugins/teams/leader_decisions.py +106 -0
- ksadk/plugins/teams/postgres_store.py +299 -85
- ksadk/plugins/teams/release_contracts.py +60 -0
- ksadk/plugins/teams/runtime.py +116 -40
- ksadk/plugins/teams/store.py +214 -6
- ksadk/plugins/teams/task_decisions.py +21 -8
- ksadk/plugins/teams/tool_service.py +152 -0
- ksadk/plugins/teams/transport.py +8 -3
- ksadk/resource_runtime/skill_runtime.py +3 -0
- ksadk/resource_runtime/socket_server.py +11 -0
- ksadk/resource_runtime/worker.py +28 -4
- ksadk/runners/_adk_a2a_stream.py +122 -0
- ksadk/runners/_adk_canonical_stream.py +474 -0
- ksadk/runners/_langgraph_canonical_streams.py +527 -0
- ksadk/runners/_langgraph_runner_streams.py +6 -400
- ksadk/runners/_langgraph_tool_projection.py +86 -0
- ksadk/runners/_langgraph_tools_transformer.py +27 -0
- ksadk/runners/adk_runner.py +195 -290
- ksadk/runners/base_runner.py +6 -5
- ksadk/runners/langgraph_runner.py +82 -86
- ksadk/runners/utils/loader.py +28 -14
- ksadk/runtime/_runner_adapter/a2ui_surface.py +145 -0
- ksadk/runtime/_runner_adapter/gateway_approvals.py +93 -0
- ksadk/runtime/_runner_adapter/stream_mapping.py +83 -128
- ksadk/runtime/adapter.py +40 -3
- ksadk/runtime/conversation_execution.py +4 -2
- ksadk/runtime/executor.py +97 -7
- ksadk/runtime/factory.py +13 -6
- ksadk/runtime/framework_adapters.py +184 -10
- ksadk/runtime/hosted_finalizer.py +4 -6
- ksadk/runtime/launch.py +2 -0
- ksadk/runtime/runner_adapter.py +123 -13
- ksadk/runtime_context.py +2 -0
- ksadk/sandbox/backends/e2b.py +30 -4
- ksadk/sandbox/backends/local_process.py +10 -0
- ksadk/sandbox/e2b_connection.py +9 -1
- ksadk/sandbox/local_controls.py +32 -2
- ksadk/sandbox/local_launcher.py +34 -0
- ksadk/server/factory.py +178 -25
- ksadk/server/history_deadline.py +158 -0
- ksadk/server/history_page_cache.py +129 -0
- ksadk/server/routes/checkpoint_audit.py +88 -0
- ksadk/server/routes/checkpoint_listing.py +294 -0
- ksadk/server/routes/checkpoint_resolution.py +73 -20
- ksadk/server/routes/control.py +51 -3
- ksadk/server/routes/display_projection.py +154 -0
- ksadk/server/routes/kernel_ingress.py +17 -2
- ksadk/server/routes/misc.py +102 -12
- ksadk/server/routes/models.py +25 -1
- ksadk/server/routes/openai_compat.py +6 -0
- ksadk/server/routes/projection.py +159 -216
- ksadk/server/routes/run.py +6 -2
- ksadk/server/routes/sessions.py +301 -342
- ksadk/server/routes/streaming.py +68 -15
- ksadk/server/routes/tool_receipt_claim_routes.py +107 -0
- ksadk/server/routes/workspace.py +5 -2
- ksadk/server/static/assets/{ArtifactsPanel-C1YoaKhx.js → ArtifactsPanel-CILaW-fC.js} +1 -1
- ksadk/server/static/assets/{CodeBlock-DHuAWfr5.js → CodeBlock-BVrNVtJC.js} +1 -1
- ksadk/server/static/assets/{MathMessageMarkdown-cvdrBwYr.js → MathMessageMarkdown-Dp7c4wWD.js} +1 -1
- ksadk/server/static/assets/{MermaidBlock-DeBkbJvI.js → MermaidBlock-Dxop8Rd7.js} +6 -6
- ksadk/server/static/assets/{NativeTerminalPanel-oJj44_sV.js → NativeTerminalPanel-Cjjz8B30.js} +1 -1
- ksadk/server/static/assets/{abnfDiagram-VCTEODGH-Dhfv25o2.js → abnfDiagram-VCTEODGH-ckWDmOzw.js} +1 -1
- ksadk/server/static/assets/{arc-C35w-pn1.js → arc-DqxJede-.js} +1 -1
- ksadk/server/static/assets/architecture-7GRP2DOG-pn_DuLy6.js +1 -0
- ksadk/server/static/assets/{architectureDiagram-5GKGNRK7-FoMY_u6D.js → architectureDiagram-5GKGNRK7-SEQA4bVi.js} +1 -1
- ksadk/server/static/assets/{blockDiagram-NRAW4CY4-zD4Rt7oE.js → blockDiagram-NRAW4CY4-pM0B-6NJ.js} +1 -1
- ksadk/server/static/assets/{c4Diagram-UCG6FXSJ-BCtGGkhN.js → c4Diagram-UCG6FXSJ-m2tuCNVq.js} +1 -1
- ksadk/server/static/assets/channel-fySsnkft.js +1 -0
- ksadk/server/static/assets/chunk-2Q5K7J3B-BheGxKRQ.js +1 -0
- ksadk/server/static/assets/{chunk-5VM5RSS4-C2Ms13_k.js → chunk-5VM5RSS4-GJHDr9Ww.js} +1 -1
- ksadk/server/static/assets/{chunk-F27PBJKO-BoTj-qgx.js → chunk-F27PBJKO-CbAN45AV.js} +1 -1
- ksadk/server/static/assets/{chunk-G27WJ6UU-DOMyyjHH.js → chunk-G27WJ6UU-D5ngbbzF.js} +1 -1
- ksadk/server/static/assets/{chunk-JWPE2WC7-DbJJqDli.js → chunk-JWPE2WC7-Cc5IwuYC.js} +1 -1
- ksadk/server/static/assets/{chunk-LCL6LL3I-CLuRCt_W.js → chunk-LCL6LL3I-CprgDDdJ.js} +1 -1
- ksadk/server/static/assets/{chunk-POPQ4Y6H-D0Dz847e.js → chunk-POPQ4Y6H-CDZhSy82.js} +1 -1
- ksadk/server/static/assets/{chunk-RHFEMEQ7-BWSRzEcd.js → chunk-RHFEMEQ7-CZchUNro.js} +1 -1
- ksadk/server/static/assets/{chunk-SVP7TREG-CPoHqkCY.js → chunk-SVP7TREG-BVruqk6T.js} +1 -1
- ksadk/server/static/assets/{chunk-XXDRQBXY-Bx1jS-X-.js → chunk-XXDRQBXY-4ld9SxPN.js} +1 -1
- ksadk/server/static/assets/classDiagram-DTDB5LWJ-DSfLtNYm.js +1 -0
- ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-DSfLtNYm.js +1 -0
- ksadk/server/static/assets/{cose-bilkent-JH36ORCC-LzyWm4m0.js → cose-bilkent-JH36ORCC-Dmyyk_Vp.js} +1 -1
- ksadk/server/static/assets/cynefin-OW5HDTMX-PFWIGtvA.js +1 -0
- ksadk/server/static/assets/{cynefinDiagram-5FMLGOSQ-BlW_bHED.js → cynefinDiagram-5FMLGOSQ-BIyq3EJb.js} +1 -1
- ksadk/server/static/assets/{dagre-3AP2YEHR-Bu_S86_i.js → dagre-3AP2YEHR-eBw08Qdk.js} +1 -1
- ksadk/server/static/assets/{dagre-B7nCawed.js → dagre-DfvnEf45.js} +1 -1
- ksadk/server/static/assets/{diagram-S7CK7UJ4-W_Zow2Km.js → diagram-S7CK7UJ4-CUSrE3Mg.js} +1 -1
- ksadk/server/static/assets/{diagram-UQ7AKVKN-CLIKAHON.js → diagram-UQ7AKVKN-Dq5Zw2gy.js} +1 -1
- ksadk/server/static/assets/{diagram-VSXAHHWV-Dv6_QAlN.js → diagram-VSXAHHWV-DyUHfNwT.js} +1 -1
- ksadk/server/static/assets/{diagram-VX7I27RA-BWAWRDtZ.js → diagram-VX7I27RA-CREmM89O.js} +1 -1
- ksadk/server/static/assets/{diagram-Z3DM3KII-XA_rWMss.js → diagram-Z3DM3KII-Dw9zhHUK.js} +1 -1
- ksadk/server/static/assets/{dist-CGt_UGeO.js → dist-0uJ4tdx6.js} +1 -1
- ksadk/server/static/assets/{dist-C0J5_3qM.js → dist-AEv-vXf-.js} +1 -1
- ksadk/server/static/assets/{dist-CIpWk_5f.js → dist-B49GzZDb.js} +1 -1
- ksadk/server/static/assets/{dist-B3bA05-e.js → dist-B8Myiet9.js} +1 -1
- ksadk/server/static/assets/{dist-DWfdmz9s.js → dist-BBsYarrI.js} +1 -1
- ksadk/server/static/assets/{dist-BLpRy_Yx.js → dist-BQMrUwdI.js} +1 -1
- ksadk/server/static/assets/{dist-CIRMvUM4.js → dist-BX_-FENW.js} +1 -1
- ksadk/server/static/assets/{dist-BdNFAney.js → dist-CD4L6ymH.js} +1 -1
- ksadk/server/static/assets/{dist-n3n6t_FO.js → dist-CHpW1BHj.js} +1 -1
- ksadk/server/static/assets/{dist-DppE_r-D.js → dist-CVPau3tn.js} +1 -1
- ksadk/server/static/assets/{dist-qe8xjesy.js → dist-C_qdxcSH.js} +1 -1
- ksadk/server/static/assets/{dist-2vL2sAdF.js → dist-Co68Apq4.js} +1 -1
- ksadk/server/static/assets/{dist-1nXCdsej.js → dist-Cp2PaOMY.js} +1 -1
- ksadk/server/static/assets/{dist-DNKuMzWc.js → dist-CuR5Bgme.js} +1 -1
- ksadk/server/static/assets/{dist-t6MzE0jU.js → dist-DDSyLEOX.js} +1 -1
- ksadk/server/static/assets/{dist-CPyieXEf.js → dist-DUxO0R99.js} +1 -1
- ksadk/server/static/assets/{dist-DyG6Ya-z.js → dist-QzbGrED_.js} +1 -1
- ksadk/server/static/assets/{dist-0X_j2Rcc.js → dist-bupkyEBZ.js} +1 -1
- ksadk/server/static/assets/{dist-mqD5TZup.js → dist-cxTGfdqx.js} +1 -1
- ksadk/server/static/assets/{dist-M-SrdhhZ.js → dist-hL5p1til.js} +1 -1
- ksadk/server/static/assets/{dist-D-92S-Fd.js → dist-lOy23y43.js} +1 -1
- ksadk/server/static/assets/{dist-BO_UwatH.js → dist-pq-nD33R.js} +1 -1
- ksadk/server/static/assets/{ebnfDiagram-PWID7BFC-BfCzF1Xi.js → ebnfDiagram-PWID7BFC-BS5LdNoR.js} +1 -1
- ksadk/server/static/assets/{erDiagram-SSCWMZ5O-Dpz9_0zn.js → erDiagram-SSCWMZ5O-Bv1QtiY-.js} +1 -1
- ksadk/server/static/assets/eventmodeling-NTZA5JFV-DsM4upQX.js +1 -0
- ksadk/server/static/assets/flowDiagram-A5DVABFB-D5NA16k9.js +1 -0
- ksadk/server/static/assets/{ganttDiagram-EL5Y4UJY-DDaG1f4_.js → ganttDiagram-EL5Y4UJY-musi-e0G.js} +1 -1
- ksadk/server/static/assets/gitGraph-4MIJSDKK-DUCVz-ih.js +1 -0
- ksadk/server/static/assets/{gitGraphDiagram-WWUBYQGX-DcxzRwYC.js → gitGraphDiagram-WWUBYQGX-DH37EGkG.js} +1 -1
- ksadk/server/static/assets/index-CZdkAvsv.js +244 -0
- ksadk/server/static/assets/index-CvXdHgF3.css +2 -0
- ksadk/server/static/assets/info-A6RAGUB7-rw0ZNHZp.js +1 -0
- ksadk/server/static/assets/{infoDiagram-RXCK75RN-CYMdn6lQ.js → infoDiagram-RXCK75RN-C1kEtv2y.js} +1 -1
- ksadk/server/static/assets/{ishikawaDiagram-5VMMS53U-CLHFAD6c.js → ishikawaDiagram-5VMMS53U-BCNPyMka.js} +1 -1
- ksadk/server/static/assets/{journeyDiagram-EYS64GPL-BHSKQGAl.js → journeyDiagram-EYS64GPL--cDbKnjP.js} +1 -1
- ksadk/server/static/assets/{kanban-definition-3QL26DDD-D5W3tjTT.js → kanban-definition-3QL26DDD-R1rAVw2f.js} +1 -1
- ksadk/server/static/assets/{katex-mtjOi4KM.js → katex-BT-X-V7U.js} +1 -1
- ksadk/server/static/assets/{linear-BETqsxE_.js → linear-DTR631iG.js} +1 -1
- ksadk/server/static/assets/{mermaid-parser.core-DPWrvs90.js → mermaid-parser.core-DfFzJhX8.js} +2 -2
- ksadk/server/static/assets/{mindmap-definition-FBJOCRG2-CJG2mfBP.js → mindmap-definition-FBJOCRG2-D4by_rmk.js} +1 -1
- ksadk/server/static/assets/packet-AYTQ26CC-Ca4Hvki9.js +1 -0
- ksadk/server/static/assets/{pegDiagram-XKGWAZYB-GjAPNaqn.js → pegDiagram-XKGWAZYB-xWXPEh0c.js} +1 -1
- ksadk/server/static/assets/pie-WAS4IAKB-hwiz6fbw.js +1 -0
- ksadk/server/static/assets/{pieDiagram-E7YTZNPT-ToIewrqr.js → pieDiagram-E7YTZNPT-BudBDlCI.js} +1 -1
- ksadk/server/static/assets/{quadrantDiagram-AXDQQJYC-4d78KiEY.js → quadrantDiagram-AXDQQJYC-DXZ0PCJF.js} +1 -1
- ksadk/server/static/assets/radar-RG4KPBEZ-BR1oZXLM.js +1 -0
- ksadk/server/static/assets/railroad-74A4TZTK-DfgEISfX.js +1 -0
- ksadk/server/static/assets/railroad-abnf-HS5TGJTU-CWOC3rdk.js +1 -0
- ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-CiRvHCLY.js +1 -0
- ksadk/server/static/assets/railroad-peg-WCYAUIDC-DSDDyJ2f.js +1 -0
- ksadk/server/static/assets/{railroadDiagram-O6MQD6OU-DKzx4xfv.js → railroadDiagram-O6MQD6OU-BdAYRYB8.js} +1 -1
- ksadk/server/static/assets/{requirementDiagram-EFPCY7ZU-CJYljxQS.js → requirementDiagram-EFPCY7ZU-CBBmaL70.js} +1 -1
- ksadk/server/static/assets/{sankeyDiagram-P5KCCOFB-DLU2fV1w.js → sankeyDiagram-P5KCCOFB-Doc3rdwp.js} +1 -1
- ksadk/server/static/assets/{sequenceDiagram-WJ2MYXX4-CVqysrA9.js → sequenceDiagram-WJ2MYXX4-0J8R8hWW.js} +1 -1
- ksadk/server/static/assets/{sizeCapture-X5ZJPWSS-BUxfmTHc.js → sizeCapture-X5ZJPWSS-CfFLlWsK.js} +1 -1
- ksadk/server/static/assets/{stateDiagram-HBIQ2CUA-CNFgYI9E.js → stateDiagram-HBIQ2CUA-jBwkjtTy.js} +1 -1
- ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-Cw1fPb5w.js +1 -0
- ksadk/server/static/assets/{swimlanes-XN3QIQJK-B6qCMe8N.js → swimlanes-XN3QIQJK-B0WxTQf8.js} +1 -1
- ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-Cc3JMBAF.js +8 -0
- ksadk/server/static/assets/{timeline-definition-24CTP7MA-CMD3x_U_.js → timeline-definition-24CTP7MA-BfCT_75A.js} +1 -1
- ksadk/server/static/assets/treeView-Q6P3EWNA-C05SJHxo.js +1 -0
- ksadk/server/static/assets/treemap-WGGIJYW6-BqNLAhc3.js +1 -0
- ksadk/server/static/assets/{vennDiagram-4TSXK5OY-BqtUqvXM.js → vennDiagram-4TSXK5OY-9gX1VMDC.js} +1 -1
- ksadk/server/static/assets/wardley-WFR3VGLG-DokNktqB.js +1 -0
- ksadk/server/static/assets/{wardleyDiagram-VM6X3IG4-B5KfDjI-.js → wardleyDiagram-VM6X3IG4-sEs_BP6O.js} +1 -1
- ksadk/server/static/assets/{xychartDiagram-S5SC5T6Z-BaUlSZrn.js → xychartDiagram-S5SC5T6Z-Ll4jvUN9.js} +1 -1
- ksadk/server/static/index.html +2 -2
- ksadk/sessions/__init__.py +8 -1
- ksadk/sessions/_checkpoint_resume_audit.py +44 -0
- ksadk/sessions/_in_memory_query.py +112 -0
- ksadk/sessions/_local_service_sync.py +157 -156
- ksadk/sessions/_local_state_sync.py +152 -0
- ksadk/sessions/_local_tables.py +2 -0
- ksadk/sessions/_postgres_checkpoint_read.py +323 -0
- ksadk/sessions/_postgres_checkpoint_stats.py +330 -0
- ksadk/sessions/_postgres_history_read.py +678 -0
- ksadk/sessions/_postgres_schema.py +44 -2
- ksadk/sessions/_postgres_tables.py +2 -0
- ksadk/sessions/_postgres_tool_receipts.py +169 -0
- ksadk/sessions/_resilient_read.py +630 -0
- ksadk/sessions/_tool_receipt_sync.py +119 -0
- ksadk/sessions/agent_identity.py +16 -0
- ksadk/sessions/base.py +278 -0
- ksadk/sessions/db_budget.py +332 -0
- ksadk/sessions/errors.py +12 -0
- ksadk/sessions/history_budget.py +36 -0
- ksadk/sessions/history_identity.py +27 -0
- ksadk/sessions/in_memory.py +376 -113
- ksadk/sessions/local_service.py +345 -0
- ksadk/sessions/postgres_service.py +515 -549
- ksadk/sessions/resilience.py +21 -14
- ksadk/sessions/resilient.py +611 -504
- ksadk/skills/loader.py +44 -2
- ksadk/skills/runtime/backends/e2b.py +17 -14
- ksadk/skills/service_client.py +6 -1
- ksadk/studio/a2a_bindings.py +407 -0
- ksadk/studio/a2a_orchestration.py +178 -0
- ksadk/studio/active_run_output.py +92 -0
- ksadk/studio/activity_records.py +542 -0
- ksadk/studio/agent_configuration.py +173 -0
- ksadk/studio/api.py +219 -389
- ksadk/studio/api_a2a_routes.py +93 -0
- ksadk/studio/api_catalog_routes.py +13 -0
- ksadk/studio/api_cloud_chat_routes.py +382 -0
- ksadk/studio/api_contracts.py +23 -0
- ksadk/studio/attachment_store.py +14 -2
- ksadk/studio/build_resolution.py +117 -0
- ksadk/studio/build_singleflight.py +37 -0
- ksadk/studio/builder.py +20 -2
- ksadk/studio/capabilities.py +8 -3
- ksadk/studio/cloud.py +83 -377
- ksadk/studio/cloud_gateways.py +424 -0
- ksadk/studio/cloud_shared_web.py +7 -0
- ksadk/studio/codex_agent_service.py +17 -0
- ksadk/studio/codex_manifest.py +5 -1
- ksadk/studio/codex_provider_build.py +65 -0
- ksadk/studio/compiler.py +102 -6
- ksadk/studio/contract_base.py +19 -0
- ksadk/studio/contracts.py +231 -201
- ksadk/studio/dsh_application.py +58 -12
- ksadk/studio/dsh_capability_service.py +17 -171
- ksadk/studio/dsh_mcp_transport.py +191 -0
- ksadk/studio/event_store.py +17 -0
- ksadk/studio/execution_host.py +84 -11
- ksadk/studio/framework_run.py +18 -0
- ksadk/studio/interaction_submission.py +265 -0
- ksadk/studio/kernel_registry.py +12 -1
- ksadk/studio/lifecycle_status.py +43 -0
- ksadk/studio/model_buffered_wire.py +227 -0
- ksadk/studio/model_chat_tools.py +143 -0
- ksadk/studio/model_client.py +1241 -761
- ksadk/studio/model_content_stream.py +129 -0
- ksadk/studio/model_credentials.py +196 -0
- ksadk/studio/model_profile_service.py +65 -31
- ksadk/studio/model_request_projection.py +284 -0
- ksadk/studio/model_responses_content.py +296 -0
- ksadk/studio/model_usage.py +109 -0
- ksadk/studio/model_wire_failure.py +110 -0
- ksadk/studio/model_wire_identity.py +138 -0
- ksadk/studio/model_wire_snapshot.py +45 -0
- ksadk/studio/model_wire_tools.py +283 -0
- ksadk/studio/native_acceptance.py +68 -0
- ksadk/studio/native_approval.py +111 -0
- ksadk/studio/native_browser_port.py +861 -0
- ksadk/studio/native_child_mcp.py +87 -0
- ksadk/studio/native_child_publication.py +68 -0
- ksadk/studio/native_child_skills.py +72 -0
- ksadk/studio/native_child_workspace.py +176 -0
- ksadk/studio/native_command_policy.py +53 -0
- ksadk/studio/native_context_port.py +326 -0
- ksadk/studio/native_context_registration.py +54 -0
- ksadk/studio/native_document_input.py +88 -0
- ksadk/studio/native_final_shape.py +852 -0
- ksadk/studio/native_gateway_stream.py +69 -0
- ksadk/studio/native_hook_port.py +145 -0
- ksadk/studio/native_hook_registration.py +70 -0
- ksadk/studio/native_inventory_disclosure.py +223 -0
- ksadk/studio/native_kernel_admission.py +84 -0
- ksadk/studio/native_language_diagnostics.py +320 -0
- ksadk/studio/native_mcp_disclosure.py +198 -0
- ksadk/studio/native_mcp_tool_port.py +219 -0
- ksadk/studio/native_memory_acceptance.py +362 -0
- ksadk/studio/native_memory_context.py +266 -0
- ksadk/studio/native_memory_flush.py +174 -0
- ksadk/studio/native_memory_sources.py +80 -0
- ksadk/studio/native_memory_tool_port.py +360 -0
- ksadk/studio/native_memory_turn.py +183 -0
- ksadk/studio/native_model_port.py +765 -0
- ksadk/studio/native_model_recovery.py +126 -0
- ksadk/studio/native_options.py +75 -0
- ksadk/studio/native_output_fields.py +58 -0
- ksadk/studio/native_planning.py +156 -0
- ksadk/studio/native_product.py +988 -0
- ksadk/studio/native_read_budget.py +426 -0
- ksadk/studio/native_recovery.py +171 -0
- ksadk/studio/native_scope.py +35 -0
- ksadk/studio/native_session_context_port.py +141 -0
- ksadk/studio/native_session_engine.py +14 -0
- ksadk/studio/native_skill_source.py +74 -0
- ksadk/studio/native_subagent_port.py +700 -0
- ksadk/studio/native_terminal_recovery.py +95 -0
- ksadk/studio/native_test_action.py +610 -0
- ksadk/studio/native_tool_port.py +477 -0
- ksadk/studio/native_user_input.py +60 -0
- ksadk/studio/native_verification_presentation.py +65 -0
- ksadk/studio/native_workspace_diagnostics.py +183 -0
- ksadk/studio/native_workspace_port.py +43 -0
- ksadk/studio/operations.py +34 -9
- ksadk/studio/plugin_composition.py +26 -10
- ksadk/studio/plugin_kernel_adapter.py +75 -1
- ksadk/studio/plugin_native_activation.py +163 -0
- ksadk/studio/plugin_runtime.py +639 -119
- ksadk/studio/plugin_runtime_admission.py +57 -0
- ksadk/studio/presentation.py +92 -0
- ksadk/studio/public_output_store.py +69 -0
- ksadk/studio/resource_authority.py +11 -3
- ksadk/studio/resource_catalog.py +8 -12
- ksadk/studio/run_activity.py +338 -385
- ksadk/studio/run_controls.py +185 -0
- ksadk/studio/run_service.py +908 -319
- ksadk/studio/run_submission_receipts.py +68 -0
- ksadk/studio/runtime_catalog.py +23 -4
- ksadk/studio/runtime_prewarm.py +22 -0
- ksadk/studio/scheduler_assistant.py +4 -1
- ksadk/studio/service.py +356 -282
- ksadk/studio/service_settings.py +229 -0
- ksadk/studio/shared_web.py +393 -169
- ksadk/studio/shared_web_response_events.py +180 -0
- ksadk/studio/shared_web_run_state.py +133 -0
- ksadk/studio/skill_discovery.py +305 -3
- ksadk/studio/static/assets/ChannelsPage-xX5HlMId.js +8 -0
- ksadk/studio/static/assets/{CodeBlock-DMIf4h33-UIqo-BPW.js → CodeBlock-DMIf4h33-CkufcPYo.js} +3 -3
- ksadk/studio/static/assets/{MathMessageMarkdown-BesSeCYl-OhNwH4K9.js → MathMessageMarkdown-BesSeCYl-DYG1Wzbx.js} +1 -1
- ksadk/studio/static/assets/{MessageMarkdown-CwMTvgFj-g0I-I4dD.js → MessageMarkdown-CwMTvgFj-BeyLyQHu.js} +2 -2
- ksadk/studio/static/assets/TeamsPage-CCaaGaVp.js +3 -0
- ksadk/studio/static/assets/index-C7DNDik2.css +2 -0
- ksadk/studio/static/assets/index-Cy68gTlH.js +265 -0
- ksadk/studio/static/index.html +3 -3
- ksadk/studio/teams_catalog.py +33 -0
- ksadk/studio/teams_installation.py +4 -1
- ksadk/studio/teams_node.py +4 -0
- ksadk/studio/teams_node_factory.py +558 -0
- ksadk/studio/teams_node_runner.py +3 -0
- ksadk/studio/teams_node_v1.py +935 -0
- ksadk/studio/teams_remote.py +259 -37
- ksadk/studio/templates.py +1 -0
- ksadk/studio/workspace_plugins.py +3 -1
- ksadk/tools/a2a_policy.py +5 -0
- ksadk/tools/artifact_observation.py +53 -0
- ksadk/tools/captured_source_artifact.py +68 -0
- ksadk/tools/schema.py +34 -0
- ksadk/toolsets/__init__.py +82 -88
- ksadk/toolsets/a2a.py +89 -89
- ksadk/toolsets/sandbox.py +377 -6
- ksadk/toolsets/skill_management.py +315 -0
- ksadk/toolsets/tool_selection.py +94 -0
- ksadk/toolsets/workspace.py +342 -324
- ksadk/toolsets/workspace_editing.py +291 -0
- ksadk/toolsets/workspace_model_observation.py +104 -0
- ksadk/toolsets/workspace_mutation.py +75 -0
- ksadk/toolsets/workspace_read_budget.py +216 -0
- ksadk/toolsets/workspace_search.py +192 -0
- ksadk/toolsets/workspace_search_process.py +129 -0
- ksadk/toolsets/workspace_state.py +6 -0
- ksadk/version.py +1 -1
- ksadk_runtime_common/http_headers.py +18 -0
- ksadk_runtime_common/workspace_files/router.py +2 -1
- ksadk/server/static/assets/architecture-7GRP2DOG-BCsa26zi.js +0 -1
- ksadk/server/static/assets/channel-_KDifNys.js +0 -1
- ksadk/server/static/assets/chunk-2Q5K7J3B-HdVkJ9F0.js +0 -1
- ksadk/server/static/assets/classDiagram-DTDB5LWJ-BVCW3ZqZ.js +0 -1
- ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-BVCW3ZqZ.js +0 -1
- ksadk/server/static/assets/cynefin-OW5HDTMX-CNXjFctL.js +0 -1
- ksadk/server/static/assets/eventmodeling-NTZA5JFV-B5-8RH9c.js +0 -1
- ksadk/server/static/assets/flowDiagram-A5DVABFB-BppFxEKw.js +0 -1
- ksadk/server/static/assets/gitGraph-4MIJSDKK-B-AhYj4C.js +0 -1
- ksadk/server/static/assets/index-BMd2mucF.css +0 -2
- ksadk/server/static/assets/index-D5qyyhTH.js +0 -244
- ksadk/server/static/assets/info-A6RAGUB7-0uiKrC35.js +0 -1
- ksadk/server/static/assets/packet-AYTQ26CC-BVTmZ_cw.js +0 -1
- ksadk/server/static/assets/pie-WAS4IAKB-DyfxBU7V.js +0 -1
- ksadk/server/static/assets/radar-RG4KPBEZ-FFontjL2.js +0 -1
- ksadk/server/static/assets/railroad-74A4TZTK-D0Uidzen.js +0 -1
- ksadk/server/static/assets/railroad-abnf-HS5TGJTU-BOo_9T2h.js +0 -1
- ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-D6-BjW7Z.js +0 -1
- ksadk/server/static/assets/railroad-peg-WCYAUIDC-CXx__yMm.js +0 -1
- ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-BXAFScz8.js +0 -1
- ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-uIQ2lJKH.js +0 -8
- ksadk/server/static/assets/treeView-Q6P3EWNA-CK5GgucZ.js +0 -1
- ksadk/server/static/assets/treemap-WGGIJYW6-Bq1u1SpG.js +0 -1
- ksadk/server/static/assets/wardley-WFR3VGLG-QAt06uEz.js +0 -1
- ksadk/studio/static/assets/ChannelsPage-D_PGmKVq.js +0 -8
- ksadk/studio/static/assets/TeamsPage-DqX4HWKQ.js +0 -3
- ksadk/studio/static/assets/index-CfEnms6Y.css +0 -2
- ksadk/studio/static/assets/index-Dp61rOWZ.js +0 -0
- {agentengine_sdk_python-0.8.5.dist-info → agentengine_sdk_python-0.8.6.dist-info}/WHEEL +0 -0
- {agentengine_sdk_python-0.8.5.dist-info → agentengine_sdk_python-0.8.6.dist-info}/entry_points.txt +0 -0
- {agentengine_sdk_python-0.8.5.dist-info → agentengine_sdk_python-0.8.6.dist-info}/licenses/LICENSE +0 -0
- {agentengine_sdk_python-0.8.5.dist-info → agentengine_sdk_python-0.8.6.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
"""Snapshot-bound PostgreSQL checkpoint reads and resume audits."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
from collections.abc import AsyncIterator
|
|
7
|
+
from contextlib import aclosing, nullcontext
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from ksadk.sessions._checkpoint_resume_audit import CheckpointResumeAudit
|
|
11
|
+
from ksadk.sessions._postgres_tables import KSADK_PG_EVENTS_TABLE, KSADK_PG_SESSIONS_TABLE
|
|
12
|
+
from ksadk.sessions.base import (
|
|
13
|
+
CheckpointEventQuery,
|
|
14
|
+
Session,
|
|
15
|
+
SessionEvent,
|
|
16
|
+
SessionEventQuery,
|
|
17
|
+
checkpoint_creation_identity,
|
|
18
|
+
checkpoint_resume_identity,
|
|
19
|
+
)
|
|
20
|
+
from ksadk.sessions.errors import HistoryProjectionBudgetExceeded
|
|
21
|
+
from ksadk.sessions.history_budget import CURRENT_HISTORY_READ_BUDGET
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class _PostgresCheckpointReadMixin:
|
|
25
|
+
async def scan_checkpoint_events(self, query: CheckpointEventQuery) -> list[SessionEvent]:
|
|
26
|
+
if query.limit < 1 or query.limit > 50:
|
|
27
|
+
raise ValueError("checkpoint scan limit must be between 1 and 50")
|
|
28
|
+
return await self._scan_checkpoint_events_with_connection(None, query)
|
|
29
|
+
|
|
30
|
+
async def iter_resume_related_event_pages(
|
|
31
|
+
self,
|
|
32
|
+
session_id: str,
|
|
33
|
+
*,
|
|
34
|
+
page_size: int = 256,
|
|
35
|
+
expected_session: Session | None = None,
|
|
36
|
+
) -> AsyncIterator[list[SessionEvent]]:
|
|
37
|
+
"""Scan only resume facts by sequence in one read-only snapshot."""
|
|
38
|
+
await self._ensure_schema()
|
|
39
|
+
kinds = [
|
|
40
|
+
"run_checkpoint",
|
|
41
|
+
"run_resume",
|
|
42
|
+
"runtime_resume",
|
|
43
|
+
"continuation.created",
|
|
44
|
+
"continuation.resumed",
|
|
45
|
+
]
|
|
46
|
+
async with self._connection() as connection:
|
|
47
|
+
async with connection.transaction(isolation="repeatable_read", readonly=True):
|
|
48
|
+
if expected_session is not None:
|
|
49
|
+
from ksadk.sessions.errors import HistoryReloadRequired
|
|
50
|
+
|
|
51
|
+
owner = await connection.fetchrow(
|
|
52
|
+
f"SELECT agent_id,user_id,created_at FROM {KSADK_PG_SESSIONS_TABLE} "
|
|
53
|
+
"WHERE namespace=$1 AND id=$2",
|
|
54
|
+
self.namespace,
|
|
55
|
+
session_id,
|
|
56
|
+
)
|
|
57
|
+
if (
|
|
58
|
+
owner is None
|
|
59
|
+
or owner["agent_id"] != expected_session.agent_id
|
|
60
|
+
or owner["user_id"] != expected_session.user_id
|
|
61
|
+
or float(owner["created_at"]) != expected_session.created_at
|
|
62
|
+
):
|
|
63
|
+
raise HistoryReloadRequired("Checkpoint session changed during lookup")
|
|
64
|
+
upper = int(
|
|
65
|
+
await connection.fetchval(
|
|
66
|
+
f"SELECT COALESCE(MAX(seq_id),0) FROM {KSADK_PG_EVENTS_TABLE} "
|
|
67
|
+
"WHERE namespace=$1 AND session_id=$2",
|
|
68
|
+
self.namespace,
|
|
69
|
+
session_id,
|
|
70
|
+
)
|
|
71
|
+
or 0
|
|
72
|
+
)
|
|
73
|
+
count = int(
|
|
74
|
+
await connection.fetchval(
|
|
75
|
+
f"SELECT COUNT(*) FROM {KSADK_PG_EVENTS_TABLE} "
|
|
76
|
+
"WHERE namespace=$1 AND session_id=$2 AND event_type=ANY($3::text[]) "
|
|
77
|
+
"AND seq_id<=$4",
|
|
78
|
+
self.namespace,
|
|
79
|
+
session_id,
|
|
80
|
+
kinds,
|
|
81
|
+
upper,
|
|
82
|
+
)
|
|
83
|
+
or 0
|
|
84
|
+
)
|
|
85
|
+
if count > 8192:
|
|
86
|
+
raise HistoryProjectionBudgetExceeded(
|
|
87
|
+
"Checkpoint lookup exceeds 8192 related events"
|
|
88
|
+
)
|
|
89
|
+
cursor = 0
|
|
90
|
+
used = 0
|
|
91
|
+
while True:
|
|
92
|
+
candidates = (
|
|
93
|
+
f"FROM {KSADK_PG_EVENTS_TABLE} WHERE namespace=$1 AND session_id=$2 "
|
|
94
|
+
"AND event_type=ANY($3::text[]) AND seq_id>$4 AND seq_id<=$5 "
|
|
95
|
+
"ORDER BY seq_id,id LIMIT $6"
|
|
96
|
+
)
|
|
97
|
+
args = (self.namespace, session_id, kinds, cursor, upper, page_size)
|
|
98
|
+
size = int(
|
|
99
|
+
await connection.fetchval(
|
|
100
|
+
"SELECT COALESCE(SUM(octet_length(content_json::text)+"
|
|
101
|
+
"octet_length(state_delta_json::text)+"
|
|
102
|
+
"octet_length(metadata_json::text)+"
|
|
103
|
+
"octet_length(to_jsonb(id)::text)+"
|
|
104
|
+
"octet_length(to_jsonb(session_id)::text)+"
|
|
105
|
+
"octet_length(to_jsonb(author)::text)+"
|
|
106
|
+
"octet_length(to_jsonb(event_type)::text)+"
|
|
107
|
+
"COALESCE(octet_length(to_jsonb(invocation_id)::text),0)+256),0) "
|
|
108
|
+
"FROM (SELECT id,session_id,author,event_type,invocation_id,"
|
|
109
|
+
"content_json,state_delta_json,metadata_json "
|
|
110
|
+
+ candidates
|
|
111
|
+
+ ") AS resume_candidates",
|
|
112
|
+
*args,
|
|
113
|
+
)
|
|
114
|
+
or 0
|
|
115
|
+
)
|
|
116
|
+
if used + size > 16 * 1024 * 1024:
|
|
117
|
+
raise HistoryProjectionBudgetExceeded(
|
|
118
|
+
"Checkpoint lookup exceeds 16 MiB of related events"
|
|
119
|
+
)
|
|
120
|
+
rows = await connection.fetch(
|
|
121
|
+
"SELECT id,session_id,author,event_type,content_json,timestamp,"
|
|
122
|
+
"state_delta_json,seq_id,invocation_id,metadata_json " + candidates,
|
|
123
|
+
*args,
|
|
124
|
+
)
|
|
125
|
+
if not rows:
|
|
126
|
+
break
|
|
127
|
+
yield [self._event_from_row(row) for row in rows]
|
|
128
|
+
used += size
|
|
129
|
+
cursor = int(rows[-1]["seq_id"])
|
|
130
|
+
if len(rows) < page_size:
|
|
131
|
+
break
|
|
132
|
+
|
|
133
|
+
async def _scan_checkpoint_events_with_connection(
|
|
134
|
+
self,
|
|
135
|
+
connection: Any | None,
|
|
136
|
+
query: CheckpointEventQuery,
|
|
137
|
+
cursor: tuple[float, str, int, str] | None = None,
|
|
138
|
+
) -> list[SessionEvent]:
|
|
139
|
+
event_query = SessionEventQuery(
|
|
140
|
+
session_ids=query.session_ids,
|
|
141
|
+
agent_id=query.agent_id,
|
|
142
|
+
event_types=["run_checkpoint", "continuation.created"],
|
|
143
|
+
checkpoint_ids=query.checkpoint_ids,
|
|
144
|
+
run_id=query.run_id,
|
|
145
|
+
offset=query.offset,
|
|
146
|
+
limit=query.limit,
|
|
147
|
+
from_start=True,
|
|
148
|
+
)
|
|
149
|
+
if query.framework is None and connection is None:
|
|
150
|
+
return await self.query_events(event_query)
|
|
151
|
+
if connection is None:
|
|
152
|
+
async with self._connection() as owned:
|
|
153
|
+
bounded = CURRENT_HISTORY_READ_BUDGET.get() is not None
|
|
154
|
+
async with (
|
|
155
|
+
owned.transaction(isolation="repeatable_read", readonly=True)
|
|
156
|
+
if bounded
|
|
157
|
+
else nullcontext()
|
|
158
|
+
):
|
|
159
|
+
return await self._scan_checkpoint_events_with_connection(
|
|
160
|
+
owned,
|
|
161
|
+
query,
|
|
162
|
+
cursor,
|
|
163
|
+
)
|
|
164
|
+
await self._ensure_schema()
|
|
165
|
+
clauses, params = self._batch_event_where(event_query)
|
|
166
|
+
if query.framework is not None:
|
|
167
|
+
params.append(query.framework.lower())
|
|
168
|
+
clauses.append(
|
|
169
|
+
"(lower(event_row.metadata_json->>'framework')="
|
|
170
|
+
f"${len(params)}"
|
|
171
|
+
" OR (event_row.event_type='continuation.created'"
|
|
172
|
+
" AND lower(event_row.content_json->'runtime_event'->'source'->>'framework')="
|
|
173
|
+
f"${len(params)}))"
|
|
174
|
+
)
|
|
175
|
+
if cursor is not None:
|
|
176
|
+
placeholders = []
|
|
177
|
+
for value in cursor:
|
|
178
|
+
params.append(value)
|
|
179
|
+
placeholders.append(f"${len(params)}")
|
|
180
|
+
clauses.append(
|
|
181
|
+
"(event_row.timestamp,event_row.session_id,event_row.seq_id,event_row.id) > "
|
|
182
|
+
f"({','.join(placeholders)})"
|
|
183
|
+
)
|
|
184
|
+
params.extend([query.limit, query.offset])
|
|
185
|
+
candidates = (
|
|
186
|
+
f"FROM {KSADK_PG_EVENTS_TABLE} event_row "
|
|
187
|
+
f"JOIN {KSADK_PG_SESSIONS_TABLE} session_row "
|
|
188
|
+
"ON session_row.namespace=event_row.namespace "
|
|
189
|
+
"AND session_row.id=event_row.session_id "
|
|
190
|
+
f"WHERE {' AND '.join(clauses)} ORDER BY event_row.timestamp,event_row.session_id,"
|
|
191
|
+
f"event_row.seq_id,event_row.id LIMIT ${len(params) - 1} OFFSET ${len(params)}"
|
|
192
|
+
)
|
|
193
|
+
await self._precheck_history_body(
|
|
194
|
+
connection,
|
|
195
|
+
"SELECT event_row.content_json,event_row.state_delta_json,"
|
|
196
|
+
"event_row.metadata_json " + candidates,
|
|
197
|
+
params,
|
|
198
|
+
)
|
|
199
|
+
rows = await connection.fetch(
|
|
200
|
+
"SELECT event_row.id,event_row.session_id,event_row.author,event_row.event_type,"
|
|
201
|
+
"event_row.content_json,event_row.timestamp,event_row.state_delta_json,"
|
|
202
|
+
"event_row.seq_id,event_row.invocation_id,event_row.metadata_json " + candidates,
|
|
203
|
+
*params,
|
|
204
|
+
)
|
|
205
|
+
return [self._event_from_row(row) for row in rows]
|
|
206
|
+
|
|
207
|
+
async def iter_checkpoint_event_chunks(
|
|
208
|
+
self, query: CheckpointEventQuery
|
|
209
|
+
) -> AsyncIterator[list[SessionEvent]]:
|
|
210
|
+
if query.limit < 1 or query.limit > 50:
|
|
211
|
+
raise ValueError("checkpoint scan limit must be between 1 and 50")
|
|
212
|
+
await self._ensure_schema()
|
|
213
|
+
async with self._connection() as connection:
|
|
214
|
+
async with connection.transaction(isolation="repeatable_read", readonly=True):
|
|
215
|
+
token = self._checkpoint_snapshot_connection.set(connection)
|
|
216
|
+
try:
|
|
217
|
+
cursor: tuple[float, str, int, str] | None = None
|
|
218
|
+
first_page = True
|
|
219
|
+
while True:
|
|
220
|
+
batch = await self._scan_checkpoint_events_with_connection(
|
|
221
|
+
connection,
|
|
222
|
+
CheckpointEventQuery(
|
|
223
|
+
**{
|
|
224
|
+
**query.__dict__,
|
|
225
|
+
"offset": query.offset if first_page else 0,
|
|
226
|
+
}
|
|
227
|
+
),
|
|
228
|
+
cursor,
|
|
229
|
+
)
|
|
230
|
+
if not batch:
|
|
231
|
+
break
|
|
232
|
+
yield batch
|
|
233
|
+
if len(batch) < query.limit:
|
|
234
|
+
break
|
|
235
|
+
last = batch[-1]
|
|
236
|
+
cursor = (
|
|
237
|
+
last.timestamp,
|
|
238
|
+
last.session_id,
|
|
239
|
+
last.seq_id,
|
|
240
|
+
last.id,
|
|
241
|
+
)
|
|
242
|
+
first_page = False
|
|
243
|
+
finally:
|
|
244
|
+
self._checkpoint_snapshot_connection.reset(token)
|
|
245
|
+
|
|
246
|
+
async def get_checkpoint_lookup_stats(
|
|
247
|
+
self, session_id: str, run_id: str, checkpoint_id: str
|
|
248
|
+
) -> dict[str, object]:
|
|
249
|
+
candidate = None
|
|
250
|
+
max_seq_id = 0
|
|
251
|
+
audit = CheckpointResumeAudit()
|
|
252
|
+
async with asyncio.timeout(self.db_budget.write_operation_seconds):
|
|
253
|
+
async with aclosing(self.iter_resume_related_event_pages(session_id)) as pages:
|
|
254
|
+
async for page in pages:
|
|
255
|
+
for event in page:
|
|
256
|
+
creation = checkpoint_creation_identity(event)
|
|
257
|
+
if event.event_type == "run_checkpoint":
|
|
258
|
+
metadata = event.metadata or {}
|
|
259
|
+
if str(metadata.get("run_id") or "") != run_id:
|
|
260
|
+
continue
|
|
261
|
+
max_seq_id = max(max_seq_id, event.seq_id)
|
|
262
|
+
if str(metadata.get("checkpoint_id") or "") == checkpoint_id:
|
|
263
|
+
candidate = event
|
|
264
|
+
elif creation is not None:
|
|
265
|
+
if creation == (run_id, checkpoint_id):
|
|
266
|
+
max_seq_id = max(max_seq_id, event.seq_id)
|
|
267
|
+
candidate = event
|
|
268
|
+
else:
|
|
269
|
+
identity = checkpoint_resume_identity(event)
|
|
270
|
+
if identity is not None and identity[:2] == (run_id, checkpoint_id):
|
|
271
|
+
audit.record(event, identity)
|
|
272
|
+
return {
|
|
273
|
+
"candidate": candidate,
|
|
274
|
+
"max_seq_id": max_seq_id,
|
|
275
|
+
"resume_count": audit["resume_count"],
|
|
276
|
+
"last_resumed_at": audit["last_resumed_at"],
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
async def get_checkpoint_stats(self, keys: list[tuple[str, str, str]]) -> dict[str, object]:
|
|
280
|
+
from ksadk.sessions._postgres_checkpoint_stats import get_checkpoint_stats
|
|
281
|
+
|
|
282
|
+
if len(keys) > 50:
|
|
283
|
+
raise ValueError("checkpoint stats batch cannot exceed 50 keys")
|
|
284
|
+
if not keys:
|
|
285
|
+
return {"audits": {}, "latest_seq_ids": {}}
|
|
286
|
+
await self._ensure_schema()
|
|
287
|
+
active = self._checkpoint_snapshot_connection.get()
|
|
288
|
+
async with asyncio.timeout(self.db_budget.write_operation_seconds):
|
|
289
|
+
async with self._connection() if active is None else nullcontext(active) as connection:
|
|
290
|
+
async with (
|
|
291
|
+
connection.transaction(isolation="repeatable_read", readonly=True)
|
|
292
|
+
if active is None
|
|
293
|
+
else nullcontext()
|
|
294
|
+
):
|
|
295
|
+
# The master aggregation validates every known carrier before
|
|
296
|
+
# filtering identity. Bound its duplicated per-key JSON input
|
|
297
|
+
# in the same snapshot, preserving fail-loud audit semantics.
|
|
298
|
+
sessions = [key[0] for key in dict.fromkeys(keys)]
|
|
299
|
+
sizes = await connection.fetchrow(
|
|
300
|
+
f"SELECT COUNT(*) AS event_count, COALESCE(SUM("
|
|
301
|
+
"octet_length(event_row.content_json::text)+"
|
|
302
|
+
"octet_length(event_row.metadata_json::text)+1024),0) AS body_bytes "
|
|
303
|
+
f"FROM {KSADK_PG_EVENTS_TABLE} event_row "
|
|
304
|
+
"JOIN unnest($2::text[]) requested(session_id) "
|
|
305
|
+
"ON event_row.session_id=requested.session_id "
|
|
306
|
+
"WHERE event_row.namespace=$1 AND event_row.event_type IN "
|
|
307
|
+
"('run_resume','runtime_resume','continuation.resumed','continuation.created')",
|
|
308
|
+
self.namespace,
|
|
309
|
+
sessions,
|
|
310
|
+
)
|
|
311
|
+
size = int(sizes["body_bytes"])
|
|
312
|
+
if int(sizes["event_count"]) > 8192 or size > 16 * 1024 * 1024:
|
|
313
|
+
raise HistoryProjectionBudgetExceeded(
|
|
314
|
+
"Checkpoint audit exceeds related-event budget"
|
|
315
|
+
)
|
|
316
|
+
budget = CURRENT_HISTORY_READ_BUDGET.get()
|
|
317
|
+
if budget is not None:
|
|
318
|
+
budget.account(size)
|
|
319
|
+
token = self._checkpoint_snapshot_connection.set(connection)
|
|
320
|
+
try:
|
|
321
|
+
return await get_checkpoint_stats(self, keys)
|
|
322
|
+
finally:
|
|
323
|
+
self._checkpoint_snapshot_connection.reset(token)
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
"""PostgreSQL checkpoint audit aggregation helpers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import math
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from ksadk.sessions._checkpoint_resume_audit import CheckpointResumeAudit
|
|
10
|
+
from ksadk.sessions._postgres_tables import KSADK_PG_EVENTS_TABLE
|
|
11
|
+
from ksadk.sessions.base import (
|
|
12
|
+
SessionEvent,
|
|
13
|
+
checkpoint_creation_identity,
|
|
14
|
+
checkpoint_resume_identity,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _raw_session_event(session_id: str, raw_event: object) -> SessionEvent:
|
|
19
|
+
if isinstance(raw_event, str):
|
|
20
|
+
try:
|
|
21
|
+
raw_event = json.loads(raw_event)
|
|
22
|
+
except (TypeError, ValueError):
|
|
23
|
+
raw_event = None
|
|
24
|
+
if not isinstance(raw_event, dict):
|
|
25
|
+
raise ValueError("canonical checkpoint carrier row is not an object")
|
|
26
|
+
return SessionEvent(
|
|
27
|
+
id=str(raw_event.get("id") or ""),
|
|
28
|
+
session_id=session_id,
|
|
29
|
+
event_type=str(raw_event.get("event_type") or ""),
|
|
30
|
+
content=dict(raw_event.get("content") or {}),
|
|
31
|
+
timestamp=raw_event.get("timestamp", 0.0),
|
|
32
|
+
seq_id=int(raw_event.get("seq_id") or 0),
|
|
33
|
+
invocation_id=raw_event.get("invocation_id"),
|
|
34
|
+
metadata=dict(raw_event.get("metadata") or {}),
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _json_rows(value: object) -> tuple[object, ...]:
|
|
39
|
+
"""Decode asyncpg JSONB aggregates whether codecs return text or lists."""
|
|
40
|
+
|
|
41
|
+
if value is None:
|
|
42
|
+
return ()
|
|
43
|
+
if isinstance(value, str):
|
|
44
|
+
try:
|
|
45
|
+
value = json.loads(value)
|
|
46
|
+
except (TypeError, ValueError) as error:
|
|
47
|
+
raise ValueError("canonical checkpoint carrier aggregate is not valid JSON") from error
|
|
48
|
+
if not isinstance(value, (list, tuple)):
|
|
49
|
+
raise ValueError("canonical checkpoint carrier aggregate is not an array")
|
|
50
|
+
return tuple(value)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
async def get_checkpoint_stats(
|
|
54
|
+
service: Any, keys: list[tuple[str, str, str]]
|
|
55
|
+
) -> dict[str, object]:
|
|
56
|
+
if len(keys) > 50:
|
|
57
|
+
raise ValueError("checkpoint stats batch cannot exceed 50 keys")
|
|
58
|
+
unique_keys = list(dict.fromkeys(keys))
|
|
59
|
+
audits = {key: {"resume_count": 0, "last_resumed_at": None} for key in unique_keys}
|
|
60
|
+
run_keys = list(dict.fromkeys((session_id, run_id) for session_id, run_id, _ in unique_keys))
|
|
61
|
+
latest = {key: 0 for key in run_keys}
|
|
62
|
+
if not unique_keys:
|
|
63
|
+
return {"audits": audits, "latest_seq_ids": latest}
|
|
64
|
+
await service._ensure_schema()
|
|
65
|
+
connection = service._checkpoint_snapshot_connection.get()
|
|
66
|
+
owns_connection = connection is None
|
|
67
|
+
if owns_connection:
|
|
68
|
+
connection = await service._pool.acquire()
|
|
69
|
+
try:
|
|
70
|
+
audit_rows = await connection.fetch(
|
|
71
|
+
f"""WITH requested(session_id,run_id,checkpoint_id) AS (
|
|
72
|
+
SELECT * FROM unnest($2::text[],$3::text[],$4::text[])
|
|
73
|
+
)
|
|
74
|
+
SELECT requested.session_id,requested.run_id,requested.checkpoint_id,
|
|
75
|
+
MAX(event_row.timestamp) FILTER (
|
|
76
|
+
WHERE event_row.event_type IN ('run_resume','runtime_resume')
|
|
77
|
+
AND event_row.timestamp > '-Infinity'::double precision
|
|
78
|
+
AND event_row.timestamp < 'Infinity'::double precision
|
|
79
|
+
) AS legacy_last_resumed_at,
|
|
80
|
+
COUNT(event_row.id) FILTER (
|
|
81
|
+
WHERE event_row.event_type IN ('run_resume','runtime_resume')
|
|
82
|
+
) AS legacy_resume_count,
|
|
83
|
+
ARRAY_AGG(event_row.timestamp ORDER BY event_row.id) FILTER (
|
|
84
|
+
WHERE event_row.event_type='continuation.resumed'
|
|
85
|
+
) AS canonical_carrier_timestamps,
|
|
86
|
+
ARRAY_AGG(
|
|
87
|
+
COALESCE(
|
|
88
|
+
event_row.content_json->'runtime_event'->>'timestamp',
|
|
89
|
+
event_row.content_json->'session_event'->'payload'->>'timestamp'
|
|
90
|
+
)
|
|
91
|
+
ORDER BY event_row.id
|
|
92
|
+
) FILTER (WHERE event_row.event_type='continuation.resumed')
|
|
93
|
+
AS canonical_timestamps,
|
|
94
|
+
(
|
|
95
|
+
SELECT COALESCE(
|
|
96
|
+
jsonb_agg(
|
|
97
|
+
jsonb_build_object(
|
|
98
|
+
'id', resume_row.id,
|
|
99
|
+
'event_type', resume_row.event_type,
|
|
100
|
+
'content', resume_row.content_json,
|
|
101
|
+
'timestamp', resume_row.timestamp,
|
|
102
|
+
'seq_id', resume_row.seq_id,
|
|
103
|
+
'invocation_id', resume_row.invocation_id,
|
|
104
|
+
'metadata', resume_row.metadata_json
|
|
105
|
+
) ORDER BY resume_row.id
|
|
106
|
+
),
|
|
107
|
+
'[]'::jsonb
|
|
108
|
+
)
|
|
109
|
+
FROM {KSADK_PG_EVENTS_TABLE} resume_row
|
|
110
|
+
WHERE resume_row.namespace=$1
|
|
111
|
+
AND resume_row.session_id=requested.session_id
|
|
112
|
+
AND resume_row.event_type IN (
|
|
113
|
+
'run_resume','runtime_resume','continuation.resumed'
|
|
114
|
+
)
|
|
115
|
+
) AS resume_rows
|
|
116
|
+
FROM requested
|
|
117
|
+
LEFT JOIN {KSADK_PG_EVENTS_TABLE} event_row
|
|
118
|
+
ON event_row.namespace=$1
|
|
119
|
+
AND event_row.session_id=requested.session_id
|
|
120
|
+
AND (
|
|
121
|
+
(
|
|
122
|
+
event_row.event_type IN ('run_resume','runtime_resume')
|
|
123
|
+
AND event_row.metadata_json->>'run_id'=requested.run_id
|
|
124
|
+
AND event_row.metadata_json->>'checkpoint_id'=requested.checkpoint_id
|
|
125
|
+
)
|
|
126
|
+
OR (
|
|
127
|
+
event_row.event_type='continuation.resumed'
|
|
128
|
+
AND COALESCE(
|
|
129
|
+
event_row.metadata_json->>'run_id',
|
|
130
|
+
event_row.content_json->'runtime_event'->>'run_id',
|
|
131
|
+
event_row.content_json->'session_event'->'payload'->>'run_id'
|
|
132
|
+
)=requested.run_id
|
|
133
|
+
AND COALESCE(
|
|
134
|
+
event_row.content_json->'runtime_event'->>'continuation_id',
|
|
135
|
+
event_row.content_json->'session_event'->'payload'->>'continuation_id'
|
|
136
|
+
)=requested.checkpoint_id
|
|
137
|
+
AND COALESCE(
|
|
138
|
+
event_row.content_json->'runtime_event'->>'continuation_kind',
|
|
139
|
+
event_row.content_json->'session_event'->'payload'->>'continuation_kind'
|
|
140
|
+
)='graph_checkpoint'
|
|
141
|
+
)
|
|
142
|
+
)
|
|
143
|
+
GROUP BY requested.session_id,requested.run_id,requested.checkpoint_id""",
|
|
144
|
+
service.namespace,
|
|
145
|
+
[key[0] for key in unique_keys],
|
|
146
|
+
[key[1] for key in unique_keys],
|
|
147
|
+
[key[2] for key in unique_keys],
|
|
148
|
+
)
|
|
149
|
+
latest_rows = await connection.fetch(
|
|
150
|
+
f"""WITH requested(session_id,run_id) AS (
|
|
151
|
+
SELECT * FROM unnest($2::text[],$3::text[])
|
|
152
|
+
)
|
|
153
|
+
SELECT requested.session_id,requested.run_id,
|
|
154
|
+
COALESCE(MAX(event_row.seq_id),0) AS latest_seq_id,
|
|
155
|
+
(
|
|
156
|
+
SELECT COALESCE(
|
|
157
|
+
jsonb_agg(
|
|
158
|
+
jsonb_build_object(
|
|
159
|
+
'id', creation_row.id,
|
|
160
|
+
'event_type', creation_row.event_type,
|
|
161
|
+
'content', creation_row.content_json,
|
|
162
|
+
'timestamp', creation_row.timestamp,
|
|
163
|
+
'seq_id', creation_row.seq_id,
|
|
164
|
+
'invocation_id', creation_row.invocation_id,
|
|
165
|
+
'metadata', creation_row.metadata_json
|
|
166
|
+
) ORDER BY creation_row.id
|
|
167
|
+
),
|
|
168
|
+
'[]'::jsonb
|
|
169
|
+
)
|
|
170
|
+
FROM {KSADK_PG_EVENTS_TABLE} creation_row
|
|
171
|
+
WHERE creation_row.namespace=$1
|
|
172
|
+
AND creation_row.session_id=requested.session_id
|
|
173
|
+
AND creation_row.event_type='continuation.created'
|
|
174
|
+
) AS canonical_creation_rows
|
|
175
|
+
FROM requested
|
|
176
|
+
LEFT JOIN {KSADK_PG_EVENTS_TABLE} event_row
|
|
177
|
+
ON event_row.namespace=$1
|
|
178
|
+
AND event_row.session_id=requested.session_id
|
|
179
|
+
AND (
|
|
180
|
+
(
|
|
181
|
+
event_row.event_type='run_checkpoint'
|
|
182
|
+
AND event_row.metadata_json->>'run_id'=requested.run_id
|
|
183
|
+
)
|
|
184
|
+
OR (
|
|
185
|
+
event_row.event_type='continuation.created'
|
|
186
|
+
AND COALESCE(
|
|
187
|
+
event_row.metadata_json->>'run_id',
|
|
188
|
+
event_row.content_json->'runtime_event'->>'run_id',
|
|
189
|
+
event_row.content_json->'session_event'->'payload'->>'run_id'
|
|
190
|
+
)=requested.run_id
|
|
191
|
+
AND COALESCE(
|
|
192
|
+
event_row.content_json->'runtime_event'->>'continuation_kind',
|
|
193
|
+
event_row.content_json->'session_event'->'payload'->>'continuation_kind'
|
|
194
|
+
)='graph_checkpoint'
|
|
195
|
+
)
|
|
196
|
+
)
|
|
197
|
+
GROUP BY requested.session_id,requested.run_id""",
|
|
198
|
+
service.namespace,
|
|
199
|
+
[key[0] for key in run_keys],
|
|
200
|
+
[key[1] for key in run_keys],
|
|
201
|
+
)
|
|
202
|
+
finally:
|
|
203
|
+
if owns_connection:
|
|
204
|
+
await service._pool.release(connection)
|
|
205
|
+
for row in audit_rows:
|
|
206
|
+
# Live SQL returns complete identities for both carrier families.
|
|
207
|
+
# Validate known canonical rows even when they target another checkpoint.
|
|
208
|
+
if row.get("resume_rows") is not None:
|
|
209
|
+
audit = CheckpointResumeAudit()
|
|
210
|
+
for raw_event in _json_rows(row["resume_rows"]):
|
|
211
|
+
event = _raw_session_event(str(row["session_id"]), raw_event)
|
|
212
|
+
identity = checkpoint_resume_identity(event)
|
|
213
|
+
if identity is not None and identity[:2] == (row["run_id"], row["checkpoint_id"]):
|
|
214
|
+
audit.record(event, identity)
|
|
215
|
+
audits[(row["session_id"], row["run_id"], row["checkpoint_id"])] = audit
|
|
216
|
+
continue
|
|
217
|
+
# Validate every known canonical resume carrier in the session before
|
|
218
|
+
# applying the identity filter above. The SQL join intentionally
|
|
219
|
+
# narrows counts to the requested checkpoint, but that must not hide a
|
|
220
|
+
# corrupt known carrier from the same fail-loud policy used by REST,
|
|
221
|
+
# in-memory, and SQLite paths.
|
|
222
|
+
canonical_rows_value = row.get("canonical_resume_rows")
|
|
223
|
+
canonical_rows = (
|
|
224
|
+
_json_rows(canonical_rows_value) if canonical_rows_value is not None else None
|
|
225
|
+
)
|
|
226
|
+
resume_count = int(
|
|
227
|
+
row.get("legacy_resume_count", row.get("resume_count", 0)) or 0
|
|
228
|
+
)
|
|
229
|
+
canonical_timestamps: list[float] = []
|
|
230
|
+
for raw_event in canonical_rows or ():
|
|
231
|
+
event = _raw_session_event(str(row["session_id"]), raw_event)
|
|
232
|
+
identity = checkpoint_resume_identity(event)
|
|
233
|
+
if identity is None or identity[:2] != (
|
|
234
|
+
str(row["run_id"]),
|
|
235
|
+
str(row["checkpoint_id"]),
|
|
236
|
+
):
|
|
237
|
+
continue
|
|
238
|
+
resume_count += 1
|
|
239
|
+
canonical_timestamps.append(identity[2])
|
|
240
|
+
# Keep payload timestamp parsing outside SQL. Canonical rows are
|
|
241
|
+
# user-provided JSON and may carry malformed values (including
|
|
242
|
+
# overflowed exponents); attempting a direct PostgreSQL float cast
|
|
243
|
+
# would abort the whole stats query. Legacy carrier timestamps
|
|
244
|
+
# remain covered by the aggregate above.
|
|
245
|
+
last_resumed_at = row["legacy_last_resumed_at"]
|
|
246
|
+
try:
|
|
247
|
+
last_resumed_at = float(last_resumed_at)
|
|
248
|
+
except (TypeError, ValueError):
|
|
249
|
+
last_resumed_at = None
|
|
250
|
+
if last_resumed_at is not None and not math.isfinite(last_resumed_at):
|
|
251
|
+
last_resumed_at = None
|
|
252
|
+
for candidate in canonical_timestamps:
|
|
253
|
+
last_resumed_at = max(last_resumed_at or candidate, candidate)
|
|
254
|
+
# Older fake/compatibility rows may not expose canonical_resume_rows;
|
|
255
|
+
# retain their payload-timestamp precedence fallback. Live PostgreSQL
|
|
256
|
+
# always returns canonical_resume_rows from the correlated subquery.
|
|
257
|
+
fallback_pairs = (
|
|
258
|
+
zip(
|
|
259
|
+
row.get("canonical_carrier_timestamps") or (),
|
|
260
|
+
row.get("canonical_timestamps") or row.get("canonical_payloads") or (),
|
|
261
|
+
)
|
|
262
|
+
if canonical_rows is None
|
|
263
|
+
else ()
|
|
264
|
+
)
|
|
265
|
+
for carrier_timestamp, raw_value in fallback_pairs:
|
|
266
|
+
counted_identity = False
|
|
267
|
+
# Compatibility fakes from the pre-integrity SQL shape return
|
|
268
|
+
# canonical payload objects rather than extracted timestamps.
|
|
269
|
+
# Reconstruct a complete carrier identity before validating it.
|
|
270
|
+
if isinstance(raw_value, str):
|
|
271
|
+
import json
|
|
272
|
+
|
|
273
|
+
try:
|
|
274
|
+
raw_value = json.loads(raw_value)
|
|
275
|
+
except (TypeError, ValueError):
|
|
276
|
+
raw_value = None
|
|
277
|
+
if isinstance(raw_value, dict):
|
|
278
|
+
from ksadk.events.canonical_store import canonical_storage_id
|
|
279
|
+
|
|
280
|
+
payload = dict(raw_value)
|
|
281
|
+
raw_timestamp = payload.get("timestamp")
|
|
282
|
+
event = SessionEvent(
|
|
283
|
+
id=canonical_storage_id(
|
|
284
|
+
str(row["session_id"]), str(payload.get("event_id") or "")
|
|
285
|
+
),
|
|
286
|
+
session_id=str(row["session_id"]),
|
|
287
|
+
event_type=str(payload.get("event_type") or ""),
|
|
288
|
+
content={"runtime_event": payload},
|
|
289
|
+
timestamp=carrier_timestamp,
|
|
290
|
+
seq_id=int(payload.get("seq") or 0),
|
|
291
|
+
metadata={"canonical_event_id": str(payload.get("event_id") or "")},
|
|
292
|
+
)
|
|
293
|
+
identity = checkpoint_resume_identity(event)
|
|
294
|
+
if identity is None or identity[:2] != (
|
|
295
|
+
str(row["run_id"]),
|
|
296
|
+
str(row["checkpoint_id"]),
|
|
297
|
+
):
|
|
298
|
+
continue
|
|
299
|
+
resume_count += 1
|
|
300
|
+
counted_identity = True
|
|
301
|
+
raw_timestamp = identity[2]
|
|
302
|
+
else:
|
|
303
|
+
raw_timestamp = raw_value
|
|
304
|
+
try:
|
|
305
|
+
carrier = float(carrier_timestamp)
|
|
306
|
+
except (TypeError, ValueError):
|
|
307
|
+
carrier = None
|
|
308
|
+
if carrier is not None and not math.isfinite(carrier):
|
|
309
|
+
carrier = None
|
|
310
|
+
try:
|
|
311
|
+
candidate = float(raw_timestamp)
|
|
312
|
+
except (TypeError, ValueError):
|
|
313
|
+
candidate = carrier
|
|
314
|
+
if candidate is None or not math.isfinite(candidate):
|
|
315
|
+
candidate = carrier
|
|
316
|
+
if candidate is None:
|
|
317
|
+
continue
|
|
318
|
+
if not counted_identity:
|
|
319
|
+
resume_count += 1
|
|
320
|
+
last_resumed_at = max(last_resumed_at or candidate, candidate)
|
|
321
|
+
audits[(row["session_id"], row["run_id"], row["checkpoint_id"])] = {
|
|
322
|
+
"resume_count": resume_count,
|
|
323
|
+
"last_resumed_at": last_resumed_at,
|
|
324
|
+
}
|
|
325
|
+
for row in latest_rows:
|
|
326
|
+
for raw_event in _json_rows(row.get("canonical_creation_rows")):
|
|
327
|
+
event = _raw_session_event(str(row["session_id"]), raw_event)
|
|
328
|
+
checkpoint_creation_identity(event)
|
|
329
|
+
latest[(row["session_id"], row["run_id"])] = int(row["latest_seq_id"] or 0)
|
|
330
|
+
return {"audits": audits, "latest_seq_ids": latest}
|