agentengine-sdk-python 0.8.6__py3-none-any.whl → 0.8.7__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.6.dist-info → agentengine_sdk_python-0.8.7.dist-info}/METADATA +31 -13
- {agentengine_sdk_python-0.8.6.dist-info → agentengine_sdk_python-0.8.7.dist-info}/RECORD +655 -501
- {agentengine_sdk_python-0.8.6.dist-info → agentengine_sdk_python-0.8.7.dist-info}/WHEEL +1 -1
- ksadk/_build_provenance.json +1 -1
- ksadk/a2a/_invocation_state.py +1 -1
- ksadk/a2a/adk_invocation_context.py +2 -1
- ksadk/a2a/adk_tools.py +19 -9
- ksadk/a2a/bootstrap.py +7 -6
- ksadk/a2a/codex.py +2 -1
- ksadk/a2a/control_plane.py +119 -2
- ksadk/a2a/executor.py +24 -7
- ksadk/a2a/invocation_service.py +198 -7
- ksadk/a2a/kernel_task_adapter.py +60 -9
- ksadk/a2a/langgraph_invocation_context.py +3 -2
- ksadk/a2a/langgraph_managed.py +17 -1
- ksadk/a2a/langgraph_recovery.py +43 -5
- ksadk/a2a/langgraph_tool_runtime.py +8 -6
- ksadk/a2a/langgraph_tools.py +13 -1
- ksadk/a2a/platform.py +8 -2
- ksadk/a2a/runtime_approval.py +6 -21
- ksadk/a2a/runtime_input.py +3 -2
- ksadk/a2a/timeouts.py +37 -0
- ksadk/a2a/tool_outcomes.py +73 -0
- ksadk/a2a/workload_tokens.py +21 -134
- ksadk/a2ui/__init__.py +4 -0
- ksadk/a2ui/assets/basic-v0_9_1.json +1383 -0
- ksadk/a2ui/assets/common-types-v0_9.json +305 -0
- ksadk/a2ui/assets/legacy-seven-components.json +230 -0
- ksadk/a2ui/assets/manifest.json +86 -0
- ksadk/a2ui/budget.py +54 -0
- ksadk/a2ui/catalog.py +64 -0
- ksadk/a2ui/generation.py +71 -0
- ksadk/a2ui/legacy.py +88 -0
- ksadk/a2ui/linking.py +115 -0
- ksadk/a2ui/payload.py +46 -0
- ksadk/a2ui/presentation.py +79 -0
- ksadk/a2ui/registry.py +166 -0
- ksadk/a2ui/wire.py +110 -0
- ksadk/agui/_agent_helpers.py +16 -1
- ksadk/agui/_agent_kernel.py +481 -0
- ksadk/agui/_agent_projection.py +379 -0
- ksadk/agui/_agent_resume.py +279 -0
- ksadk/agui/_agent_types.py +67 -0
- ksadk/agui/a2ui_projection.py +3 -1
- ksadk/agui/agent.py +110 -566
- ksadk/agui/config.py +19 -5
- ksadk/agui/routes.py +2 -0
- ksadk/api/client.py +158 -7
- ksadk/builders/code_builder.py +144 -29
- ksadk/builders/container_builder.py +27 -6
- ksadk/builders/framework_requirements.py +5 -4
- ksadk/builders/mcp_builder.py +3 -1
- ksadk/cli/cmd_deploy.py +5 -0
- ksadk/cli/cmd_invoke.py +57 -2
- ksadk/cli/cmd_studio.py +19 -3
- ksadk/cli/cmd_web.py +20 -56
- ksadk/cli/hosted_command_events.py +148 -0
- ksadk/cli/hosted_invoke.py +66 -14
- ksadk/cli/runtime_bootstrap.py +1 -0
- ksadk/codex/async_client.py +354 -12
- ksadk/codex/runtime.py +17 -2
- ksadk/common/diagnostics.py +15 -0
- ksadk/compat/copilotkit_a2ui.py +85 -21
- ksadk/configs/env_registry.py +71 -19
- ksadk/configs/env_registry_a2a.py +42 -0
- ksadk/conversations/a2ui_projection.py +50 -0
- ksadk/conversations/context.py +12 -0
- ksadk/conversations/message_projection.py +106 -60
- ksadk/conversations/message_projection_blocks.py +75 -3
- ksadk/conversations/message_projection_outcomes.py +81 -0
- ksadk/conversations/projector.py +29 -0
- ksadk/conversations/runtime_invocation.py +3 -0
- ksadk/conversations/runtime_projection.py +23 -1
- ksadk/conversations/runtime_stream_events.py +11 -7
- ksadk/conversations/runtime_streaming.py +21 -17
- ksadk/deployment/mcp.py +93 -0
- ksadk/deployment/providers/serverless.py +130 -4
- ksadk/events/_v1_compat/projection.py +2 -0
- ksadk/events/adapters/_langgraph_custom.py +195 -0
- ksadk/events/adapters/_langgraph_model_tasks.py +59 -0
- ksadk/events/adapters/_langgraph_support.py +80 -29
- ksadk/events/adapters/_langgraph_tool_outcomes.py +71 -0
- ksadk/events/adapters/_langgraph_usage_origin.py +86 -0
- ksadk/events/adapters/adk.py +11 -0
- ksadk/events/adapters/langgraph.py +188 -20
- ksadk/events/canonical.py +23 -1
- ksadk/events/canonical_store.py +133 -4
- ksadk/events/cold_recovery.py +2 -1
- ksadk/events/native_checkpoint.py +10 -0
- ksadk/events/reducer.py +9 -9
- ksadk/events/run_authority.py +15 -0
- ksadk/events/session_event.py +61 -0
- ksadk/events/sse_heartbeat.py +50 -0
- ksadk/events/usage.py +50 -0
- ksadk/harness/app.py +1 -1
- ksadk/harness/artifact_adapters/native_catalog.py +92 -0
- ksadk/harness/artifact_adapters/native_tool.py +16 -0
- ksadk/harness/browser_adapters/native_playwright.py +3 -1
- ksadk/harness/browser_adapters/native_vision.py +2 -1
- ksadk/harness/engine/postgres_checkpointer.py +170 -29
- ksadk/harness/model_adapters/native_openai.py +3 -1
- ksadk/harness/native/artifact_catalog_contract.py +26 -0
- ksadk/harness/native/artifact_partial_read_capacity.py +6 -3
- ksadk/harness/native/artifact_read_capacity.py +15 -87
- ksadk/harness/native/artifact_runtime.py +44 -1
- ksadk/harness/native/artifact_search_capacity.py +20 -119
- ksadk/harness/native/artifact_single_read_capacity.py +7 -6
- ksadk/harness/native/background_command_contract.py +40 -0
- ksadk/harness/native/background_commands.py +101 -0
- ksadk/harness/native/call_budget.py +24 -0
- ksadk/harness/native/child_budget.py +6 -6
- ksadk/harness/native/child_interruption.py +3 -2
- ksadk/harness/native/child_media.py +105 -0
- ksadk/harness/native/context.py +44 -0
- ksadk/harness/native/context_compaction_projection.py +38 -2
- ksadk/harness/native/context_continuation.py +54 -0
- ksadk/harness/native/context_contributions.py +2 -1
- ksadk/harness/native/context_directory_progress.py +117 -0
- ksadk/harness/native/context_driver.py +136 -11
- ksadk/harness/native/context_partial_summary.py +2 -0
- ksadk/harness/native/context_partition.py +37 -1
- ksadk/harness/native/context_replay.py +2 -1
- ksadk/harness/native/context_request_projection.py +59 -6
- ksadk/harness/native/context_runtime.py +211 -16
- ksadk/harness/native/context_runtime_contracts.py +123 -1
- ksadk/harness/native/context_session_history.py +96 -0
- ksadk/harness/native/context_source_progress.py +164 -5
- ksadk/harness/native/context_summary_planning.py +63 -15
- ksadk/harness/native/context_summary_prompt.py +72 -0
- ksadk/harness/native/context_summary_recovery.py +3 -1
- ksadk/harness/native/delivery_artifacts.py +58 -0
- ksadk/harness/native/delivery_context.py +64 -0
- ksadk/harness/native/delivery_feedback.py +95 -0
- ksadk/harness/native/delivery_review.py +10 -10
- ksadk/harness/native/effect_control.py +45 -1
- ksadk/harness/native/effect_receipts.py +50 -3
- ksadk/harness/native/effect_runtime.py +10 -1
- ksadk/harness/native/engine.py +601 -16
- ksadk/harness/native/execution_budget.py +88 -0
- ksadk/harness/native/history.py +1 -0
- ksadk/harness/native/machine.py +44 -7
- ksadk/harness/native/model.py +17 -3
- ksadk/harness/native/model_runtime.py +192 -12
- ksadk/harness/native/model_takeover.py +4 -2
- ksadk/harness/native/notification_admission.py +183 -0
- ksadk/harness/native/ports.py +54 -6
- ksadk/harness/native/run_clock.py +13 -6
- ksadk/harness/native/state.py +100 -1
- ksadk/harness/native/stream_display_buffer.py +198 -0
- ksadk/harness/native/subagents.py +21 -0
- ksadk/harness/native/task_policy.py +8 -3
- ksadk/harness/native/tool_batch_capacity.py +152 -0
- ksadk/harness/native/tool_budget.py +38 -9
- ksadk/harness/native/tool_error_recovery.py +241 -0
- ksadk/harness/native/tool_error_streak.py +10 -1
- ksadk/harness/native/tool_progress.py +1 -0
- ksadk/harness/native/tool_scheduling.py +9 -10
- ksadk/harness/native/turn_control.py +21 -2
- ksadk/harness/native/verification_runtime.py +2 -1
- ksadk/harness/native_facade.py +180 -9
- ksadk/harness/native_projection.py +18 -8
- ksadk/harness/native_runtime.py +208 -3
- ksadk/harness/provider_thinking.py +63 -0
- ksadk/harness/public_activity.py +3 -0
- ksadk/harness/skill_adapters/native_disclosure.py +13 -1
- ksadk/harness/skill_adapters/native_metadata.py +40 -0
- ksadk/harness/spec.py +6 -0
- ksadk/harness/stores/native_commit_history.py +373 -0
- ksadk/harness/stores/native_contract.py +205 -1
- ksadk/harness/stores/native_memory.py +363 -1
- ksadk/harness/stores/native_sqlite.py +572 -14
- ksadk/harness/stores/native_sqlite_migration.py +34 -7
- ksadk/harness/subagent.py +6 -1
- ksadk/harness/subagent_adapters/native_background_child.py +8 -7
- ksadk/harness/subagent_adapters/native_child.py +87 -8
- ksadk/harness/tool_display.py +113 -2
- ksadk/harness/tool_display_contract.py +34 -1
- ksadk/interaction/contracts.py +19 -4
- ksadk/interaction/display_values.py +140 -0
- ksadk/interaction/form_values.py +130 -0
- ksadk/interaction/langgraph.py +53 -0
- ksadk/interaction/langgraph_approval.py +59 -0
- ksadk/interaction/langgraph_interrupt.py +129 -0
- ksadk/interaction/langgraph_observer.py +125 -0
- ksadk/interaction/ledger.py +32 -5
- ksadk/interaction/native_events.py +29 -0
- ksadk/interaction/providers/langgraph.py +19 -8
- ksadk/interaction/resolution.py +43 -0
- ksadk/interaction/schema.py +168 -0
- ksadk/interaction/submission.py +184 -0
- ksadk/kernel/admission_cursor.py +19 -0
- ksadk/kernel/bootstrap.py +344 -228
- ksadk/kernel/contract_fingerprints.py +5 -0
- ksadk/kernel/contracts.py +1 -0
- ksadk/kernel/control.py +67 -0
- ksadk/kernel/conversation_input.py +39 -0
- ksadk/kernel/execution_host_ingress.py +6 -3
- ksadk/kernel/history_projection.py +85 -4
- ksadk/kernel/ingress.py +63 -11
- ksadk/kernel/interactions_memory.py +447 -0
- ksadk/kernel/interactions_postgres.py +500 -0
- ksadk/kernel/interactions_sqlite.py +684 -0
- ksadk/kernel/legacy_postgres_repair.py +113 -0
- ksadk/kernel/local_interactions.py +172 -0
- ksadk/kernel/memory_store.py +137 -366
- ksadk/kernel/native_confirmation.py +109 -0
- ksadk/kernel/postgres_locks.py +23 -0
- ksadk/kernel/postgres_store.py +573 -511
- ksadk/kernel/postgres_time.py +12 -0
- ksadk/kernel/recovery.py +26 -1
- ksadk/kernel/runtime_config.py +72 -0
- ksadk/kernel/runtime_environment.py +301 -0
- ksadk/kernel/session_storage.py +144 -0
- ksadk/kernel/sql/002_session_retirement.sql +86 -0
- ksadk/kernel/sql/003_legacy_repair_queue.sql +49 -0
- ksadk/kernel/sql/backfill_session_namespaces.sql +59 -0
- ksadk/kernel/sqlite_session_cleanup.py +84 -0
- ksadk/kernel/sqlite_store.py +232 -622
- ksadk/kernel/store.py +6 -0
- ksadk/kernel/submission_postgres.py +99 -0
- ksadk/kernel/submission_sqlite.py +107 -0
- ksadk/kernel/teams_effects.py +3 -4
- ksadk/kernel/teams_execution_context.py +3 -4
- ksadk/kernel/worker.py +89 -200
- ksadk/kernel/worker_controls.py +112 -27
- ksadk/kernel/worker_interactions.py +343 -47
- ksadk/knowledge_base/__init__.py +1 -1
- ksadk/knowledge_base/client.py +128 -14
- ksadk/knowledge_base/openclaw_bridge.py +58 -0
- ksadk/knowledge_base/service.py +2 -0
- ksadk/mcp_runtime/__init__.py +34 -15
- ksadk/mcp_runtime/_adk.py +14 -0
- ksadk/mcp_runtime/oauth/__init__.py +6 -0
- ksadk/mcp_runtime/oauth/_agent.py +147 -0
- ksadk/mcp_runtime/oauth/_durable_tools.py +208 -0
- ksadk/mcp_runtime/oauth/bootstrap.py +69 -0
- ksadk/mcp_runtime/oauth/client.py +200 -0
- ksadk/mcp_runtime/oauth/code_config.py +90 -0
- ksadk/mcp_runtime/oauth/contract.json +32 -0
- ksadk/mcp_runtime/oauth/contract.py +6 -0
- ksadk/mcp_runtime/oauth/declarations.py +106 -0
- ksadk/mcp_runtime/oauth/http.py +63 -0
- ksadk/mcp_runtime/oauth/kernel.py +717 -0
- ksadk/mcp_runtime/oauth/langgraph.py +402 -0
- ksadk/mcp_runtime/oauth/local/__init__.py +1 -0
- ksadk/mcp_runtime/oauth/local/broker.py +469 -0
- ksadk/mcp_runtime/oauth/local/checkpoint.py +17 -0
- ksadk/mcp_runtime/oauth/local/persistence.py +227 -0
- ksadk/mcp_runtime/oauth/local/protocol.py +390 -0
- ksadk/mcp_runtime/oauth/local/runtime.py +413 -0
- ksadk/mcp_runtime/oauth/local/transport.py +79 -0
- ksadk/mcp_runtime/oauth/runtime_io.py +43 -0
- ksadk/mcp_runtime/oauth/security.py +73 -0
- ksadk/mcp_runtime/oauth/tools.py +396 -0
- ksadk/mcp_runtime/oauth/transport.py +92 -0
- ksadk/memory/adk/long_term_memory.py +1 -2
- ksadk/memory/openclaw_bridge.py +115 -0
- ksadk/memory/providers/local_postgres.py +247 -55
- ksadk/memory/service.py +29 -3
- ksadk/model_gateway/client.py +1 -1
- ksadk/model_proxy/compat.py +22 -0
- ksadk/model_proxy/transform.py +3 -4
- ksadk/plugins/providers/codex.py +37 -2
- ksadk/plugins/providers/harness_tools.py +39 -2
- ksadk/resource_runtime/contracts.py +8 -3
- ksadk/resource_runtime/knowledge.py +1 -1
- ksadk/resource_runtime/managed_projection.py +24 -9
- ksadk/resource_runtime/worker.py +5 -1
- ksadk/runners/_adk_a2a_stream.py +10 -0
- ksadk/runners/_langgraph_answer_contract.py +47 -0
- ksadk/runners/_langgraph_canonical_stream.py +641 -0
- ksadk/runners/_langgraph_checkpoint_binding.py +89 -0
- ksadk/runners/_langgraph_final_answer.py +91 -0
- ksadk/runners/_langgraph_fresh_turn.py +67 -0
- ksadk/runners/_langgraph_interactions.py +199 -0
- ksadk/runners/_langgraph_output.py +69 -0
- ksadk/runners/_langgraph_runner_streams.py +32 -75
- ksadk/runners/_langgraph_state_reader.py +5 -0
- ksadk/runners/_langgraph_wait_cancellation.py +49 -0
- ksadk/runners/_session_identity.py +22 -1
- ksadk/runners/adk_runner.py +13 -3
- ksadk/runners/base_runner.py +21 -0
- ksadk/runners/langgraph_runner.py +128 -108
- ksadk/runners/patch_langchain.py +4 -2
- ksadk/runtime/_langgraph_interaction_adapter.py +333 -0
- ksadk/runtime/_runner_adapter/a2ui_surface.py +194 -22
- ksadk/runtime/_runner_adapter/chunk_mapping.py +688 -0
- ksadk/runtime/_runner_adapter/resume_context.py +64 -0
- ksadk/runtime/_runner_adapter/stream_mapping.py +29 -597
- ksadk/runtime/conversation_execution.py +61 -32
- ksadk/runtime/executor.py +34 -1
- ksadk/runtime/framework_adapters.py +27 -2
- ksadk/runtime/langgraph_checkpoint_view.py +147 -0
- ksadk/runtime/preprocessing.py +9 -1
- ksadk/runtime/runner_adapter.py +77 -37
- ksadk/runtime/session_storage.py +71 -0
- ksadk/sandbox/backends/e2b.py +95 -13
- ksadk/sandbox/backends/local_process.py +68 -4
- ksadk/sandbox/base.py +1 -1
- ksadk/sandbox/diagnostics.py +31 -0
- ksadk/sandbox/e2b_background.py +1768 -0
- ksadk/sandbox/e2b_errors.py +26 -0
- ksadk/sandbox/local_background.py +406 -0
- ksadk/sandbox/local_controls.py +8 -1
- ksadk/server/database_access.py +369 -0
- ksadk/server/database_access_contract.py +222 -0
- ksadk/server/factory.py +125 -3
- ksadk/server/history_deadline.py +20 -4
- ksadk/server/history_page_cache.py +8 -2
- ksadk/server/routes/common.py +11 -1
- ksadk/server/routes/control.py +2 -1
- ksadk/server/routes/database_access.py +17 -0
- ksadk/server/routes/dependencies.py +28 -0
- ksadk/server/routes/interactions.py +106 -0
- ksadk/server/routes/kernel_ingress.py +19 -1
- ksadk/server/routes/local_kernel_control.py +80 -0
- ksadk/server/routes/openai_compat.py +6 -0
- ksadk/server/routes/projection.py +159 -2
- ksadk/server/routes/routers.py +6 -0
- ksadk/server/routes/run.py +30 -1
- ksadk/server/routes/session_identity.py +130 -0
- ksadk/server/routes/sessions.py +326 -312
- ksadk/server/routes/streaming.py +3 -2
- ksadk/server/routes/ui_bootstrap.py +251 -0
- ksadk/server/routes/workspace.py +7 -0
- ksadk/server/static/a2ui/basic-v0_9_1.json +1383 -0
- ksadk/server/static/a2ui/common-types-v0_9.json +305 -0
- ksadk/server/static/a2ui/legacy-seven-components.json +230 -0
- ksadk/server/static/a2ui/manifest.json +86 -0
- ksadk/server/static/a2ui/material-icons-OFL-1.1.txt +93 -0
- ksadk/server/static/assets/{ArtifactsPanel-CILaW-fC.js → ArtifactsPanel-Cdr5C_vM.js} +1 -1
- ksadk/server/static/assets/{CodeBlock-BVrNVtJC.js → CodeBlock-BWRafud9.js} +6 -6
- ksadk/server/static/assets/{MathMessageMarkdown-Dp7c4wWD.js → MathMessageMarkdown-CFKeJIvy.js} +7 -7
- ksadk/server/static/assets/{MermaidBlock-Dxop8Rd7.js → MermaidBlock-BneAGUOd.js} +9 -9
- ksadk/server/static/assets/NativeTerminalPanel-BHI85zDO.js +1 -0
- ksadk/server/static/assets/OfficialA2uiRenderer-BOmT36lJ.js +16 -0
- ksadk/server/static/assets/{abnfDiagram-VCTEODGH-ckWDmOzw.js → abnfDiagram-VCTEODGH-DQvlOsBI.js} +1 -1
- ksadk/server/static/assets/{arc-DqxJede-.js → arc-CGx0e4pN.js} +1 -1
- ksadk/server/static/assets/architecture-7GRP2DOG-CFWjFkDL.js +1 -0
- ksadk/server/static/assets/{architectureDiagram-5GKGNRK7-SEQA4bVi.js → architectureDiagram-5GKGNRK7-WyybcNKX.js} +1 -1
- ksadk/server/static/assets/{blockDiagram-NRAW4CY4-pM0B-6NJ.js → blockDiagram-NRAW4CY4-C9Cx_GVs.js} +1 -1
- ksadk/server/static/assets/{c4Diagram-UCG6FXSJ-m2tuCNVq.js → c4Diagram-UCG6FXSJ-Bh7X3bGr.js} +1 -1
- ksadk/server/static/assets/channel-D6Dp_l74.js +1 -0
- ksadk/server/static/assets/chunk-2Q5K7J3B-CwmjhFYK.js +1 -0
- ksadk/server/static/assets/{chunk-5VM5RSS4-GJHDr9Ww.js → chunk-5VM5RSS4-cP9XupZj.js} +1 -1
- ksadk/server/static/assets/{chunk-F27PBJKO-CbAN45AV.js → chunk-F27PBJKO-Bm77fvR9.js} +1 -1
- ksadk/server/static/assets/{chunk-G27WJ6UU-D5ngbbzF.js → chunk-G27WJ6UU-DDKNPesQ.js} +1 -1
- ksadk/server/static/assets/{chunk-JWPE2WC7-Cc5IwuYC.js → chunk-JWPE2WC7-BqiUDB7s.js} +1 -1
- ksadk/server/static/assets/{chunk-LCL6LL3I-CprgDDdJ.js → chunk-LCL6LL3I-C528mMZy.js} +1 -1
- ksadk/server/static/assets/{chunk-POPQ4Y6H-CDZhSy82.js → chunk-POPQ4Y6H-CzZ9g_Uf.js} +1 -1
- ksadk/server/static/assets/{chunk-RHFEMEQ7-CZchUNro.js → chunk-RHFEMEQ7-CXj4tUZ-.js} +1 -1
- ksadk/server/static/assets/{chunk-SVP7TREG-BVruqk6T.js → chunk-SVP7TREG-BHyd85pS.js} +1 -1
- ksadk/server/static/assets/{chunk-XXDRQBXY-4ld9SxPN.js → chunk-XXDRQBXY-Qe29PHGe.js} +1 -1
- ksadk/server/static/assets/classDiagram-DTDB5LWJ-DsbvkCAV.js +1 -0
- ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-DsbvkCAV.js +1 -0
- ksadk/server/static/assets/{cose-bilkent-JH36ORCC-Dmyyk_Vp.js → cose-bilkent-JH36ORCC-maRKgeec.js} +1 -1
- ksadk/server/static/assets/cynefin-OW5HDTMX-CBZRVuc4.js +1 -0
- ksadk/server/static/assets/{cynefinDiagram-5FMLGOSQ-BIyq3EJb.js → cynefinDiagram-5FMLGOSQ-CoD0bEvn.js} +1 -1
- ksadk/server/static/assets/{dagre-3AP2YEHR-eBw08Qdk.js → dagre-3AP2YEHR-BkpgQqyW.js} +1 -1
- ksadk/server/static/assets/{dagre-DfvnEf45.js → dagre-BUaTFrYa.js} +1 -1
- ksadk/server/static/assets/{diagram-S7CK7UJ4-CUSrE3Mg.js → diagram-S7CK7UJ4-25HdTbjE.js} +1 -1
- ksadk/server/static/assets/{diagram-UQ7AKVKN-Dq5Zw2gy.js → diagram-UQ7AKVKN-KO-WqOIg.js} +1 -1
- ksadk/server/static/assets/{diagram-VSXAHHWV-DyUHfNwT.js → diagram-VSXAHHWV-B360BkDQ.js} +1 -1
- ksadk/server/static/assets/{diagram-VX7I27RA-CREmM89O.js → diagram-VX7I27RA-COr1Oqsg.js} +1 -1
- ksadk/server/static/assets/{diagram-Z3DM3KII-Dw9zhHUK.js → diagram-Z3DM3KII-CgaKrIwB.js} +1 -1
- ksadk/server/static/assets/{dist-AEv-vXf-.js → dist--HftQyp9.js} +1 -1
- ksadk/server/static/assets/{dist-pq-nD33R.js → dist-B3Jp5r1e.js} +1 -1
- ksadk/server/static/assets/{dist-cxTGfdqx.js → dist-BEbS8Bag.js} +1 -1
- ksadk/server/static/assets/{dist-BX_-FENW.js → dist-BQ116UdZ.js} +1 -1
- ksadk/server/static/assets/{dist-DDSyLEOX.js → dist-BoRn8a_t.js} +1 -1
- ksadk/server/static/assets/{dist-BBsYarrI.js → dist-Brbrdmff.js} +1 -1
- ksadk/server/static/assets/{dist-B8Myiet9.js → dist-Bsuusoi0.js} +1 -1
- ksadk/server/static/assets/{dist-DUxO0R99.js → dist-Bxcu8Ca0.js} +1 -1
- ksadk/server/static/assets/{dist-CVPau3tn.js → dist-By-MVndb.js} +1 -1
- ksadk/server/static/assets/{dist-lOy23y43.js → dist-C9BTMVwS.js} +1 -1
- ksadk/server/static/assets/{dist-C_qdxcSH.js → dist-CBo9AHUv.js} +1 -1
- ksadk/server/static/assets/{dist-bupkyEBZ.js → dist-CR61WJFC.js} +1 -1
- ksadk/server/static/assets/{dist-CHpW1BHj.js → dist-CwnkOyDn.js} +1 -1
- ksadk/server/static/assets/{dist-0uJ4tdx6.js → dist-CxIl4t92.js} +1 -1
- ksadk/server/static/assets/{dist-Cp2PaOMY.js → dist-DKG0OYnk.js} +1 -1
- ksadk/server/static/assets/{dist-BQMrUwdI.js → dist-DSw5Ju6-.js} +1 -1
- ksadk/server/static/assets/{dist-hL5p1til.js → dist-DXOlCAay.js} +1 -1
- ksadk/server/static/assets/{dist-CD4L6ymH.js → dist-DgJ57sRe.js} +1 -1
- ksadk/server/static/assets/{dist-CuR5Bgme.js → dist-DmWw0IXB.js} +1 -1
- ksadk/server/static/assets/{dist-Co68Apq4.js → dist-DzdXSBJb.js} +1 -1
- ksadk/server/static/assets/{dist-B49GzZDb.js → dist-HHvdjADB.js} +1 -1
- ksadk/server/static/assets/{dist-QzbGrED_.js → dist-_0Xgu_07.js} +1 -1
- ksadk/server/static/assets/{ebnfDiagram-PWID7BFC-BS5LdNoR.js → ebnfDiagram-PWID7BFC-DogDP2db.js} +1 -1
- ksadk/server/static/assets/{erDiagram-SSCWMZ5O-Bv1QtiY-.js → erDiagram-SSCWMZ5O-CeBDnUjR.js} +1 -1
- ksadk/server/static/assets/eventmodeling-NTZA5JFV-vXZWMkpn.js +1 -0
- ksadk/server/static/assets/flowDiagram-A5DVABFB-5LRgzKLv.js +1 -0
- ksadk/server/static/assets/{ganttDiagram-EL5Y4UJY-musi-e0G.js → ganttDiagram-EL5Y4UJY-oIQL3MCp.js} +1 -1
- ksadk/server/static/assets/gitGraph-4MIJSDKK-BUWSkncI.js +1 -0
- ksadk/server/static/assets/{gitGraphDiagram-WWUBYQGX-DH37EGkG.js → gitGraphDiagram-WWUBYQGX-B7qz0cmZ.js} +1 -1
- ksadk/server/static/assets/index-4g1ndaxW.js +1132 -0
- ksadk/server/static/assets/index-DEVfafsU.css +2 -0
- ksadk/server/static/assets/info-A6RAGUB7-CzJ_YrOs.js +1 -0
- ksadk/server/static/assets/{infoDiagram-RXCK75RN-C1kEtv2y.js → infoDiagram-RXCK75RN-yQRC41Ya.js} +1 -1
- ksadk/server/static/assets/{ishikawaDiagram-5VMMS53U-BCNPyMka.js → ishikawaDiagram-5VMMS53U-BCu4HiwL.js} +1 -1
- ksadk/server/static/assets/{journeyDiagram-EYS64GPL--cDbKnjP.js → journeyDiagram-EYS64GPL-JaqmO73K.js} +1 -1
- ksadk/server/static/assets/{kanban-definition-3QL26DDD-R1rAVw2f.js → kanban-definition-3QL26DDD-DQo4X8NO.js} +1 -1
- ksadk/server/static/assets/{katex-BT-X-V7U.js → katex-t_DWylQw.js} +1 -1
- ksadk/server/static/assets/{linear-DTR631iG.js → linear-DWdnI35B.js} +1 -1
- ksadk/server/static/assets/material-icons-latin-400-normal-kAwBdRge.woff2 +0 -0
- ksadk/server/static/assets/{mermaid-parser.core-DfFzJhX8.js → mermaid-parser.core-BHrT2Pfe.js} +2 -2
- ksadk/server/static/assets/{mindmap-definition-FBJOCRG2-D4by_rmk.js → mindmap-definition-FBJOCRG2-PBVAhZYV.js} +1 -1
- ksadk/server/static/assets/packet-AYTQ26CC-CXoos6fx.js +1 -0
- ksadk/server/static/assets/{pegDiagram-XKGWAZYB-xWXPEh0c.js → pegDiagram-XKGWAZYB-CU_cLfow.js} +1 -1
- ksadk/server/static/assets/pie-WAS4IAKB-CjF9NoIt.js +1 -0
- ksadk/server/static/assets/{pieDiagram-E7YTZNPT-BudBDlCI.js → pieDiagram-E7YTZNPT-B1h0-_pW.js} +1 -1
- ksadk/server/static/assets/{quadrantDiagram-AXDQQJYC-DXZ0PCJF.js → quadrantDiagram-AXDQQJYC-DEMoGo5a.js} +1 -1
- ksadk/server/static/assets/radar-RG4KPBEZ-BQGWs9nw.js +1 -0
- ksadk/server/static/assets/railroad-74A4TZTK-B6znvLUK.js +1 -0
- ksadk/server/static/assets/railroad-abnf-HS5TGJTU-Bzquz0As.js +1 -0
- ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-1IikGkb5.js +1 -0
- ksadk/server/static/assets/railroad-peg-WCYAUIDC-BKKgHzdc.js +1 -0
- ksadk/server/static/assets/{railroadDiagram-O6MQD6OU-BdAYRYB8.js → railroadDiagram-O6MQD6OU-BTAob2wg.js} +1 -1
- ksadk/server/static/assets/{requirementDiagram-EFPCY7ZU-CBBmaL70.js → requirementDiagram-EFPCY7ZU-Dl0Q2SuO.js} +1 -1
- ksadk/server/static/assets/{sankeyDiagram-P5KCCOFB-Doc3rdwp.js → sankeyDiagram-P5KCCOFB-DeaTWkur.js} +1 -1
- ksadk/server/static/assets/{sequenceDiagram-WJ2MYXX4-0J8R8hWW.js → sequenceDiagram-WJ2MYXX4-gFQYrsOd.js} +1 -1
- ksadk/server/static/assets/{sizeCapture-X5ZJPWSS-CfFLlWsK.js → sizeCapture-X5ZJPWSS-pGQzddMB.js} +1 -1
- ksadk/server/static/assets/{stateDiagram-HBIQ2CUA-jBwkjtTy.js → stateDiagram-HBIQ2CUA-DmpYOZt1.js} +1 -1
- ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-Dolxgkw3.js +1 -0
- ksadk/server/static/assets/{swimlanes-XN3QIQJK-B0WxTQf8.js → swimlanes-XN3QIQJK-BfuSAsrr.js} +1 -1
- ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-BuI1erYj.js +8 -0
- ksadk/server/static/assets/{timeline-definition-24CTP7MA-BfCT_75A.js → timeline-definition-24CTP7MA-CgJwrrxf.js} +1 -1
- ksadk/server/static/assets/treeView-Q6P3EWNA-DtMdDH8N.js +1 -0
- ksadk/server/static/assets/treemap-WGGIJYW6-VoU8QtLZ.js +1 -0
- ksadk/server/static/assets/{vennDiagram-4TSXK5OY-9gX1VMDC.js → vennDiagram-4TSXK5OY-CBSAgXDd.js} +1 -1
- ksadk/server/static/assets/wardley-WFR3VGLG-YWSRB0Zm.js +1 -0
- ksadk/server/static/assets/{wardleyDiagram-VM6X3IG4-sEs_BP6O.js → wardleyDiagram-VM6X3IG4-013TZ2JZ.js} +1 -1
- ksadk/server/static/assets/{xychartDiagram-S5SC5T6Z-Ll4jvUN9.js → xychartDiagram-S5SC5T6Z-u6Frp8xp.js} +1 -1
- ksadk/server/static/index.html +2 -2
- ksadk/server/static/ui-source.json +11 -0
- ksadk/sessions/_local_service_sync.py +146 -5
- ksadk/sessions/_postgres_schema.py +17 -0
- ksadk/sessions/base.py +3 -0
- ksadk/sessions/continuity.py +7 -1
- ksadk/sessions/db_budget.py +14 -12
- ksadk/sessions/history_budget.py +7 -0
- ksadk/sessions/in_memory.py +113 -4
- ksadk/sessions/persistence.py +73 -7
- ksadk/sessions/postgres_service.py +948 -8
- ksadk/sessions/resilience.py +16 -0
- ksadk/sessions/resilient.py +601 -5
- ksadk/sessions/topology.py +9 -2
- ksadk/skills/mcp_server/register.py +471 -415
- ksadk/skills/request_connection.py +188 -0
- ksadk/skills/runtime/backends/e2b.py +52 -12
- ksadk/skills/service_client.py +104 -45
- ksadk/studio/api.py +413 -11
- ksadk/studio/api_contracts.py +7 -3
- ksadk/studio/api_plugin_routes.py +13 -6
- ksadk/studio/authoring_coordinator.py +6 -1
- ksadk/studio/background_output.py +72 -0
- ksadk/studio/build_resolution.py +28 -4
- ksadk/studio/cloud.py +516 -7
- ksadk/studio/cloud_history.py +149 -0
- ksadk/studio/cloud_shared_web.py +32 -3
- ksadk/studio/compiler.py +93 -4
- ksadk/studio/contracts.py +368 -9
- ksadk/studio/dsh_application.py +17 -4
- ksadk/studio/execution_host.py +10 -5
- ksadk/studio/interaction_submission.py +7 -2
- ksadk/studio/model_chat_tools.py +22 -10
- ksadk/studio/model_client.py +41 -11
- ksadk/studio/model_wire_identity.py +24 -0
- ksadk/studio/native_background_command_port.py +97 -0
- ksadk/studio/native_background_connection.py +230 -0
- ksadk/studio/native_background_locator.py +272 -0
- ksadk/studio/native_background_ownership.py +255 -0
- ksadk/studio/native_background_wakeup.py +686 -0
- ksadk/studio/native_browser_port.py +9 -3
- ksadk/studio/native_child_skills.py +4 -0
- ksadk/studio/native_coding_template.py +287 -0
- ksadk/studio/native_command_policy.py +23 -0
- ksadk/studio/native_context_evidence.py +81 -0
- ksadk/studio/native_context_port.py +13 -2
- ksadk/studio/native_directory_observation.py +177 -0
- ksadk/studio/native_final_shape.py +148 -19
- ksadk/studio/native_model_port.py +201 -43
- ksadk/studio/native_planning.py +43 -2
- ksadk/studio/native_product.py +238 -12
- ksadk/studio/native_project_instructions.py +267 -0
- ksadk/studio/native_read_budget.py +21 -3
- ksadk/studio/native_subagent_port.py +125 -2
- ksadk/studio/native_tool_port.py +255 -14
- ksadk/studio/native_verification_presentation.py +13 -3
- ksadk/studio/plugin_kernel_adapter.py +13 -0
- ksadk/studio/plugin_native_activation.py +2 -2
- ksadk/studio/presentation.py +12 -0
- ksadk/studio/project_instruction_trust.py +54 -0
- ksadk/studio/repository.py +1 -1
- ksadk/studio/resource_catalog.py +4 -1
- ksadk/studio/run_activity.py +8 -0
- ksadk/studio/run_service.py +496 -40
- ksadk/studio/scheduler_assistant.py +3 -1
- ksadk/studio/service.py +99 -2
- ksadk/studio/shared_web.py +38 -12
- ksadk/studio/shared_web_response_events.py +32 -5
- ksadk/studio/static/assets/ChannelsPage-Do_mRmVu.js +8 -0
- ksadk/studio/static/assets/{CodeBlock-DMIf4h33-CkufcPYo.js → CodeBlock-DMIf4h33-CsO7rJKv.js} +3 -3
- ksadk/studio/static/assets/{ExecutionTree-v3HexvPo-Bk8wzGSy.js → ExecutionTree-v3HexvPo-BeWoMqA-.js} +1 -1
- ksadk/studio/static/assets/{MathMessageMarkdown-BesSeCYl-DYG1Wzbx.js → MathMessageMarkdown-BesSeCYl-CiB60plG.js} +1 -1
- ksadk/studio/static/assets/{MermaidBlock-H_0qzQDf-BdXtxug_.js → MermaidBlock-H_0qzQDf-oRTZUNRr.js} +3 -3
- ksadk/studio/static/assets/{MessageMarkdown-CwMTvgFj-BeyLyQHu.js → MessageMarkdown-CwMTvgFj-BzEmQkHH.js} +5 -5
- ksadk/studio/static/assets/OfficialA2uiRenderer-DI49Kpxu-BBxfdj3P.js +16 -0
- ksadk/studio/static/assets/{PrismRenderer-5pK6tUdb.js → PrismRenderer-CcrOV6Lf.js} +1 -1
- ksadk/studio/static/assets/TeamsPage-qNVYpcox.js +4 -0
- ksadk/studio/static/assets/{abnfDiagram-VCTEODGH-Bnb1O3tA.js → abnfDiagram-VCTEODGH-BdEjkX5G.js} +1 -1
- ksadk/studio/static/assets/{arc-Pry-7G1_.js → arc-4LNeT6Qr.js} +1 -1
- ksadk/studio/static/assets/architecture-7GRP2DOG-C6BmiLXs.js +1 -0
- ksadk/studio/static/assets/{architectureDiagram-5GKGNRK7-5Zn1gqJv.js → architectureDiagram-5GKGNRK7-nKXkceF2.js} +3 -3
- ksadk/studio/static/assets/{blockDiagram-I7D4REHJ-CLB4L11u.js → blockDiagram-I7D4REHJ-pSawBX0F.js} +1 -1
- ksadk/studio/static/assets/{c4Diagram-7LVT6UL2-BOma_Z_F.js → c4Diagram-7LVT6UL2-D3DGtCIa.js} +1 -1
- ksadk/studio/static/assets/channel-CwBcaXYb.js +1 -0
- ksadk/studio/static/assets/{chunk-2E4U76K2-BFf_huql.js → chunk-2E4U76K2-CfUBZPB8.js} +2 -2
- ksadk/studio/static/assets/chunk-2Q5K7J3B-B9fZb2AW.js +1 -0
- ksadk/studio/static/assets/{chunk-2ZTRR5NV-C2qZJila.js → chunk-2ZTRR5NV-63jTqPgP.js} +1 -1
- ksadk/studio/static/assets/{chunk-3Z5EZCMW-DMniOlPd.js → chunk-3Z5EZCMW-CLzTC-ds.js} +1 -1
- ksadk/studio/static/assets/{chunk-4HAMMTFA-DVtDP4rm.js → chunk-4HAMMTFA--k1euiK8.js} +3 -3
- ksadk/studio/static/assets/{chunk-5V3GS4D5-i-ZDOEnP.js → chunk-5V3GS4D5--NT8dMSC.js} +1 -1
- ksadk/studio/static/assets/{chunk-5VM5RSS4-ZNzvKenW.js → chunk-5VM5RSS4-B4EX-xPG.js} +2 -2
- ksadk/studio/static/assets/{chunk-6AZGARVD-BB6FqMl-.js → chunk-6AZGARVD-BxyCuIKr.js} +1 -1
- ksadk/studio/static/assets/{chunk-6EIED4P4-DdUJkP0f.js → chunk-6EIED4P4-BqAnqs6L.js} +1 -1
- ksadk/studio/static/assets/{chunk-6K3QC6MW-CqVsVn-y.js → chunk-6K3QC6MW-DqKCc1_c.js} +1 -1
- ksadk/studio/static/assets/{chunk-6TQVIW2G-DKlLbNIP.js → chunk-6TQVIW2G-NQp6TssR.js} +1 -1
- ksadk/studio/static/assets/{chunk-747NJXEK-BFkZPlab.js → chunk-747NJXEK-CFf3ol0D.js} +1 -1
- ksadk/studio/static/assets/{chunk-75Z2AOVW-BZNhM4vB.js → chunk-75Z2AOVW-DpzsVI3p.js} +1 -1
- ksadk/studio/static/assets/chunk-CLGD4ZFX-BiEFihjn.js +1 -0
- ksadk/studio/static/assets/{chunk-DU6HZSFF-CpEZCUgg.js → chunk-DU6HZSFF-HbWKkMwX.js} +3 -3
- ksadk/studio/static/assets/{chunk-F27PBJKO-D7pvKf0C.js → chunk-F27PBJKO-BY9pwz0W.js} +1 -1
- ksadk/studio/static/assets/{chunk-FOHPRMQF-DHwB1DNv.js → chunk-FOHPRMQF-BAABtQ6R.js} +5 -5
- ksadk/studio/static/assets/{chunk-GMAD6QVW-DE_8H717.js → chunk-GMAD6QVW-C-Lw1ag9.js} +1 -1
- ksadk/studio/static/assets/{chunk-GVQU2GXP-BfEB0lNv.js → chunk-GVQU2GXP-CCUMaVF8.js} +1 -1
- ksadk/studio/static/assets/{chunk-I5DQTOEV-Hm2LfiYI.js → chunk-I5DQTOEV-DpUJ7zEH.js} +1 -1
- ksadk/studio/static/assets/{chunk-ICYGCRZG-749o-pGJ.js → chunk-ICYGCRZG-CknVx2uG.js} +1 -1
- ksadk/studio/static/assets/{chunk-IH6LHLGP-CC6I9F3i.js → chunk-IH6LHLGP-BJ6nT6RF.js} +1 -1
- ksadk/studio/static/assets/{chunk-IMKFNOWR-D38axYOR.js → chunk-IMKFNOWR-CTelL5KO.js} +1 -1
- ksadk/studio/static/assets/{chunk-JWPE2WC7-DVXcaiue.js → chunk-JWPE2WC7-CMg2kMrr.js} +1 -1
- ksadk/studio/static/assets/{chunk-KI3K4JFJ-Rma-0k_M.js → chunk-KI3K4JFJ-B1SKa0PC.js} +1 -1
- ksadk/studio/static/assets/{chunk-L3NEJ4N5-Dq5xn7aL.js → chunk-L3NEJ4N5-C8A22muD.js} +1 -1
- ksadk/studio/static/assets/{chunk-LNGE3PJU-DWpGwHrW.js → chunk-LNGE3PJU-D_NJe87O.js} +1 -1
- ksadk/studio/static/assets/{chunk-OSK3NFVY-DiCQjx9b.js → chunk-OSK3NFVY-DFHvKoNt.js} +1 -1
- ksadk/studio/static/assets/{chunk-OUJLGHUK-D0j2JRSg.js → chunk-OUJLGHUK-DkHSrVKj.js} +1 -1
- ksadk/studio/static/assets/{chunk-P2QGCYS3-VdhKmfYq.js → chunk-P2QGCYS3-C3nH7MEr.js} +1 -1
- ksadk/studio/static/assets/{chunk-POPQ4Y6H-C1_rzO5M.js → chunk-POPQ4Y6H-CLm6A2JW.js} +1 -1
- ksadk/studio/static/assets/{chunk-PWAF6VOD-B45HvflI.js → chunk-PWAF6VOD-BmVQq92D.js} +1 -1
- ksadk/studio/static/assets/{chunk-SHT3W25Y-DsCFnRVE.js → chunk-SHT3W25Y-cETj_Yg7.js} +1 -1
- ksadk/studio/static/assets/{chunk-SVP7TREG-DljApgRX.js → chunk-SVP7TREG-hm4Ur8KN.js} +1 -1
- ksadk/studio/static/assets/{chunk-TICWLB2K-DWqRtyqa.js → chunk-TICWLB2K-BuVjFGjc.js} +1 -1
- ksadk/studio/static/assets/{chunk-TLUHSLCS-DUeGgnD5.js → chunk-TLUHSLCS-7mZ4xr0q.js} +2 -2
- ksadk/studio/static/assets/{chunk-UY3FDG6J-CnmaAkG5.js → chunk-UY3FDG6J-2nV2i5mW.js} +1 -1
- ksadk/studio/static/assets/{chunk-XHIXRSVI-BFQ6B8BE.js → chunk-XHIXRSVI-BIR36bKX.js} +1 -1
- ksadk/studio/static/assets/chunk-XXDRQBXY-rafYnJzG.js +1 -0
- ksadk/studio/static/assets/classDiagram-ZZMXUADV-DdyoXyMk.js +1 -0
- ksadk/studio/static/assets/classDiagram-v2-VYDZK3BY-DdyoXyMk.js +1 -0
- ksadk/studio/static/assets/{cose-bilkent-JH36ORCC-om8AY0Mc.js → cose-bilkent-JH36ORCC-B9Ubz7rk.js} +1 -1
- ksadk/studio/static/assets/{createLucideIcon-DR0LGTP5.js → createLucideIcon-CTD6_IjT.js} +1 -1
- ksadk/studio/static/assets/cynefin-OW5HDTMX-BVS4hy6V.js +1 -0
- ksadk/studio/static/assets/{cynefinDiagram-5FMLGOSQ-6BrmK52S.js → cynefinDiagram-5FMLGOSQ-CKrgw1wI.js} +1 -1
- ksadk/studio/static/assets/{cytoscape.esm-CGd-uY3x.js → cytoscape.esm-Jip0ihto.js} +16 -16
- ksadk/studio/static/assets/{dagre-GXQ25YYZ-buZBRlwz.js → dagre-GXQ25YYZ-NjDjs3Kl.js} +1 -1
- ksadk/studio/static/assets/{dagre-PrKaheQc.js → dagre-YnTFOVV4.js} +1 -1
- ksadk/studio/static/assets/{diagram-S7CK7UJ4-C6aH78c4.js → diagram-S7CK7UJ4-C6X87QRZ.js} +1 -1
- ksadk/studio/static/assets/{diagram-UQ7AKVKN-DY_tQ6C_.js → diagram-UQ7AKVKN-Xf2JVuyK.js} +1 -1
- ksadk/studio/static/assets/{diagram-VSXAHHWV-DX9p5cQT.js → diagram-VSXAHHWV-CUZlU7Dr.js} +1 -1
- ksadk/studio/static/assets/{diagram-VX7I27RA-DB2WSH8X.js → diagram-VX7I27RA-BOcfFxfe.js} +1 -1
- ksadk/studio/static/assets/{diagram-Z3DM3KII-Ce1BJwHE.js → diagram-Z3DM3KII-1zrr7ezR.js} +1 -1
- ksadk/studio/static/assets/{dist-v5Q1xZ2K.js → dist-Brlz61T5.js} +1 -1
- ksadk/studio/static/assets/{ebnfDiagram-PWID7BFC-Daukxwqf.js → ebnfDiagram-PWID7BFC-C1LymnKg.js} +1 -1
- ksadk/studio/static/assets/{erDiagram-RLTQ6QDP-CGthTMmJ.js → erDiagram-RLTQ6QDP-Dm0YWPea.js} +1 -1
- ksadk/studio/static/assets/eventmodeling-NTZA5JFV-D9gMNzTL.js +1 -0
- ksadk/studio/static/assets/flowDiagram-HODETNUW-NYJgBJQu.js +1 -0
- ksadk/studio/static/assets/{ganttDiagram-EL5Y4UJY-BfoAZW9X.js → ganttDiagram-EL5Y4UJY-uJ27IKEw.js} +1 -1
- ksadk/studio/static/assets/gitGraph-4MIJSDKK-DQVCMicu.js +1 -0
- ksadk/studio/static/assets/{gitGraphDiagram-WWUBYQGX-S985OIJF.js → gitGraphDiagram-WWUBYQGX-mtpvi7ne.js} +3 -3
- ksadk/studio/static/assets/index-Cp9Unfkn.css +2 -0
- ksadk/studio/static/assets/index-HepnaEeR.js +1152 -0
- ksadk/studio/static/assets/{index.dom-BQenBtFm.js → index.dom-DSf_jcX2.js} +1 -1
- ksadk/studio/static/assets/info-A6RAGUB7-CMrsF9SP.js +1 -0
- ksadk/studio/static/assets/{infoDiagram-27XIBGKW-CO3W8tFn.js → infoDiagram-27XIBGKW-Hqrd2vbU.js} +1 -1
- ksadk/studio/static/assets/{ishikawaDiagram-5VMMS53U-BUGEl8cO.js → ishikawaDiagram-5VMMS53U-BB7nm3Dk.js} +1 -1
- ksadk/studio/static/assets/{journeyDiagram-3NMN7TZE-Ch2ZYxvr.js → journeyDiagram-3NMN7TZE-BXbRt7Ps.js} +1 -1
- ksadk/studio/static/assets/{kanban-definition-UXKFOSKX-Da-Fp4vC.js → kanban-definition-UXKFOSKX-2EtAxRbw.js} +1 -1
- ksadk/studio/static/assets/{katex-DhON-x74.js → katex-K_8DQ5UN.js} +1 -1
- ksadk/studio/static/assets/{line-BDaeq300.js → line-C4h80pWP.js} +1 -1
- ksadk/studio/static/assets/{linear-DmucvK78.js → linear-DCteYK3U.js} +1 -1
- ksadk/studio/static/assets/{mermaid-parser.core-Cj5mYdBi.js → mermaid-parser.core-TWhr-wg2.js} +2 -2
- ksadk/studio/static/assets/{mindmap-definition-YA3MSWOX-CvlsVQ38.js → mindmap-definition-YA3MSWOX-BC7jpEOt.js} +1 -1
- ksadk/studio/static/assets/{ordinal-BDEzSJ7C.js → ordinal-BXUrfsNY.js} +1 -1
- ksadk/studio/static/assets/packet-AYTQ26CC-BdMfjW7Z.js +1 -0
- ksadk/studio/static/assets/{pegDiagram-XKGWAZYB-BuHuNgT5.js → pegDiagram-XKGWAZYB-C-ZzWopk.js} +1 -1
- ksadk/studio/static/assets/pie-WAS4IAKB-B06bKgAM.js +1 -0
- ksadk/studio/static/assets/{pieDiagram-E7YTZNPT-DlrWiSOv.js → pieDiagram-E7YTZNPT-DGDL1XJp.js} +1 -1
- ksadk/studio/static/assets/{quadrantDiagram-AXDQQJYC-BA3hpUZM.js → quadrantDiagram-AXDQQJYC-DAPa64vy.js} +1 -1
- ksadk/studio/static/assets/radar-RG4KPBEZ-4lhecdYg.js +1 -0
- ksadk/studio/static/assets/railroad-74A4TZTK-CBTdV2Xq.js +1 -0
- ksadk/studio/static/assets/railroad-abnf-HS5TGJTU-D4HzgxJY.js +1 -0
- ksadk/studio/static/assets/railroad-ebnf-LZEXJU2U-D-qRzoh8.js +1 -0
- ksadk/studio/static/assets/railroad-peg-WCYAUIDC-DYA99dLv.js +1 -0
- ksadk/studio/static/assets/{railroadDiagram-O6MQD6OU-BxpAazym.js → railroadDiagram-O6MQD6OU-CkH0b7UT.js} +1 -1
- ksadk/studio/static/assets/{react-vendor-BNmTiJ-I.js → react-vendor-CTyAWUMQ.js} +1 -1
- ksadk/studio/static/assets/{requirementDiagram-BXWQKSXE-E-Ge0FcV.js → requirementDiagram-BXWQKSXE-BgZ0H8ni.js} +2 -2
- ksadk/studio/static/assets/rolldown-runtime-cO0ylGnt.js +1 -0
- ksadk/studio/static/assets/{sankeyDiagram-P5KCCOFB-CA6YKhQ3.js → sankeyDiagram-P5KCCOFB-BgqqGK6v.js} +1 -1
- ksadk/studio/static/assets/{sequenceDiagram-WJ2MYXX4-CcElXGg4.js → sequenceDiagram-WJ2MYXX4-CbQE1ava.js} +1 -1
- ksadk/studio/static/assets/{sizeCapture-INFHLROL-B0uUizjq.js → sizeCapture-INFHLROL-BtEJ4_JN.js} +1 -1
- ksadk/studio/static/assets/{src-B6xuSHsQ.js → src-DSHesKRm.js} +1 -1
- ksadk/studio/static/assets/{stateDiagram-D77RDMKH-DdXZOFqY.js → stateDiagram-D77RDMKH-D9uG2y8U.js} +1 -1
- ksadk/studio/static/assets/stateDiagram-v2-MP3YSRHH-2pITMnQn.js +1 -0
- ksadk/studio/static/assets/{swimlanes-42K2YHIH-NtgEEHLY.js → swimlanes-42K2YHIH-B0QgwqLd.js} +1 -1
- ksadk/studio/static/assets/swimlanesDiagram-VR7AAH4N-TXD08-JZ.js +8 -0
- ksadk/studio/static/assets/{timeline-definition-24CTP7MA-CIuYhNy3.js → timeline-definition-24CTP7MA-tbRyDWb4.js} +1 -1
- ksadk/studio/static/assets/treeView-Q6P3EWNA-NawrivXx.js +1 -0
- ksadk/studio/static/assets/treemap-WGGIJYW6-DabVcIU4.js +1 -0
- ksadk/studio/static/assets/{vennDiagram-4TSXK5OY-7HbApbrv.js → vennDiagram-4TSXK5OY-Xjhys4e4.js} +1 -1
- ksadk/studio/static/assets/wardley-WFR3VGLG-BrU5uhdd.js +1 -0
- ksadk/studio/static/assets/{wardleyDiagram-VM6X3IG4-CMJiaedy.js → wardleyDiagram-VM6X3IG4--sd605zd.js} +1 -1
- ksadk/studio/static/assets/{xychartDiagram-S5SC5T6Z-BdgtMvW2.js → xychartDiagram-S5SC5T6Z-B3XzcsnZ.js} +1 -1
- ksadk/studio/static/index.html +9 -9
- ksadk/studio/static/ui-source.json +11 -0
- ksadk/studio/teams_installation.py +1 -1
- ksadk/studio/templates.py +33 -3
- ksadk/toolsets/__init__.py +14 -1
- ksadk/toolsets/sandbox.py +303 -7
- ksadk/toolsets/workspace.py +17 -10
- ksadk/toolsets/workspace_editing.py +40 -0
- ksadk/toolsets/workspace_model_observation.py +6 -1
- ksadk/tracing/__init__.py +10 -1
- ksadk/tracing/routed.py +416 -0
- ksadk/tracing/setup.py +58 -3
- ksadk/version.py +1 -1
- ksadk_runtime_common/memory_backend/manifest.py +1 -1
- ksadk_runtime_common/memory_backend/providers/ksmem.py +60 -0
- ksadk_runtime_common/memory_backend/providers/lancedb.py +1 -2
- ksadk_runtime_common/memory_backend/providers/mem0.py +1 -0
- ksadk_runtime_common/memory_backend/registry.py +2 -0
- ksadk_runtime_common/memory_backend/render.py +1 -1
- ksadk_runtime_common/schemas/memory_backend_manifest.schema.json +37 -12
- ksadk_runtime_common/schemas/runtime_event_v2.json +2 -1
- ksadk/server/static/assets/NativeTerminalPanel-Cjjz8B30.js +0 -1
- ksadk/server/static/assets/architecture-7GRP2DOG-pn_DuLy6.js +0 -1
- ksadk/server/static/assets/channel-fySsnkft.js +0 -1
- ksadk/server/static/assets/chunk-2Q5K7J3B-BheGxKRQ.js +0 -1
- ksadk/server/static/assets/classDiagram-DTDB5LWJ-DSfLtNYm.js +0 -1
- ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-DSfLtNYm.js +0 -1
- ksadk/server/static/assets/cynefin-OW5HDTMX-PFWIGtvA.js +0 -1
- ksadk/server/static/assets/eventmodeling-NTZA5JFV-DsM4upQX.js +0 -1
- ksadk/server/static/assets/flowDiagram-A5DVABFB-D5NA16k9.js +0 -1
- ksadk/server/static/assets/gitGraph-4MIJSDKK-DUCVz-ih.js +0 -1
- ksadk/server/static/assets/index-CZdkAvsv.js +0 -244
- ksadk/server/static/assets/index-CvXdHgF3.css +0 -2
- ksadk/server/static/assets/info-A6RAGUB7-rw0ZNHZp.js +0 -1
- ksadk/server/static/assets/packet-AYTQ26CC-Ca4Hvki9.js +0 -1
- ksadk/server/static/assets/pie-WAS4IAKB-hwiz6fbw.js +0 -1
- ksadk/server/static/assets/radar-RG4KPBEZ-BR1oZXLM.js +0 -1
- ksadk/server/static/assets/railroad-74A4TZTK-DfgEISfX.js +0 -1
- ksadk/server/static/assets/railroad-abnf-HS5TGJTU-CWOC3rdk.js +0 -1
- ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-CiRvHCLY.js +0 -1
- ksadk/server/static/assets/railroad-peg-WCYAUIDC-DSDDyJ2f.js +0 -1
- ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-Cw1fPb5w.js +0 -1
- ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-Cc3JMBAF.js +0 -8
- ksadk/server/static/assets/treeView-Q6P3EWNA-C05SJHxo.js +0 -1
- ksadk/server/static/assets/treemap-WGGIJYW6-BqNLAhc3.js +0 -1
- ksadk/server/static/assets/wardley-WFR3VGLG-DokNktqB.js +0 -1
- ksadk/studio/static/assets/ChannelsPage-xX5HlMId.js +0 -8
- ksadk/studio/static/assets/TeamsPage-CCaaGaVp.js +0 -3
- ksadk/studio/static/assets/architecture-7GRP2DOG-BMOPAkUC.js +0 -1
- ksadk/studio/static/assets/channel-r8itPEik.js +0 -1
- ksadk/studio/static/assets/chunk-2Q5K7J3B-C1jixKkw.js +0 -1
- ksadk/studio/static/assets/chunk-CLGD4ZFX-D-GTtyKs.js +0 -1
- ksadk/studio/static/assets/chunk-XXDRQBXY-DqAYeljN.js +0 -1
- ksadk/studio/static/assets/classDiagram-ZZMXUADV-DjeMNJmu.js +0 -1
- ksadk/studio/static/assets/classDiagram-v2-VYDZK3BY-DjeMNJmu.js +0 -1
- ksadk/studio/static/assets/cynefin-OW5HDTMX-7tP7QfM3.js +0 -1
- ksadk/studio/static/assets/eventmodeling-NTZA5JFV-BR2FzK4R.js +0 -1
- ksadk/studio/static/assets/flowDiagram-HODETNUW-CZ1tEenp.js +0 -1
- ksadk/studio/static/assets/gitGraph-4MIJSDKK-DYlXv_yJ.js +0 -1
- ksadk/studio/static/assets/index-C7DNDik2.css +0 -2
- ksadk/studio/static/assets/index-Cy68gTlH.js +0 -265
- ksadk/studio/static/assets/info-A6RAGUB7-BlU-8_xu.js +0 -1
- ksadk/studio/static/assets/packet-AYTQ26CC-BSJEH9Lb.js +0 -1
- ksadk/studio/static/assets/pie-WAS4IAKB-qxv01Y8W.js +0 -1
- ksadk/studio/static/assets/radar-RG4KPBEZ-B6h6pWOs.js +0 -1
- ksadk/studio/static/assets/railroad-74A4TZTK-CGtTWdGc.js +0 -1
- ksadk/studio/static/assets/railroad-abnf-HS5TGJTU-Cq7y22IA.js +0 -1
- ksadk/studio/static/assets/railroad-ebnf-LZEXJU2U-V0aQVv9m.js +0 -1
- ksadk/studio/static/assets/railroad-peg-WCYAUIDC-BQiIsX_p.js +0 -1
- ksadk/studio/static/assets/rolldown-runtime-hePW80VL.js +0 -1
- ksadk/studio/static/assets/stateDiagram-v2-MP3YSRHH-CJbOM-QK.js +0 -1
- ksadk/studio/static/assets/swimlanesDiagram-VR7AAH4N-D-AVlW8B.js +0 -8
- ksadk/studio/static/assets/treeView-Q6P3EWNA-BTTYcvrF.js +0 -1
- ksadk/studio/static/assets/treemap-WGGIJYW6-Cg7tyfH8.js +0 -1
- ksadk/studio/static/assets/wardley-WFR3VGLG-C6N1rULY.js +0 -1
- {agentengine_sdk_python-0.8.6.dist-info → agentengine_sdk_python-0.8.7.dist-info}/entry_points.txt +0 -0
- {agentengine_sdk_python-0.8.6.dist-info → agentengine_sdk_python-0.8.7.dist-info}/licenses/LICENSE +0 -0
- {agentengine_sdk_python-0.8.6.dist-info → agentengine_sdk_python-0.8.7.dist-info}/top_level.txt +0 -0
- /ksadk/studio/static/assets/{array-BifhSqXX.js → array-mTkv7xdZ.js} +0 -0
- /ksadk/studio/static/assets/{chunk-Y2CYZVJY-DsF7k-Jl.js → chunk-Y2CYZVJY-C72YQVBQ.js} +0 -0
- /ksadk/studio/static/assets/{clsx-DB0hHKMi.js → clsx-BE-4uLAX.js} +0 -0
- /ksadk/studio/static/assets/{defaultLocale-BFoDCU3G.js → defaultLocale-YBltSZ3l.js} +0 -0
- /ksadk/studio/static/assets/{graphlib-DS17s2tU.js → graphlib-CYZB3_li.js} +0 -0
- /ksadk/studio/static/assets/{init-C-OQMol4.js → init-Ccnd9r3c.js} +0 -0
- /ksadk/studio/static/assets/{path-fybaL0A-.js → path-BfzAkHoX.js} +0 -0
- /ksadk/studio/static/assets/{preload-helper-CO68xz6u.js → preload-helper-2TpOpXko.js} +0 -0
- /ksadk/studio/static/assets/{presentation-yYw7xK60-BmcZriri.js → presentation-yYw7xK60-B7PYgYAE.js} +0 -0
- /ksadk/studio/static/assets/{rolldown-runtime-Dy4uBu1J-DK3Fl9T5.js → rolldown-runtime-Dy4uBu1J-CmRlGT1x.js} +0 -0
- /ksadk/studio/static/assets/{rough.esm-Dy-Kn_BL.js → rough.esm-BF6Sy8cM.js} +0 -0
ksadk/kernel/sqlite_store.py
CHANGED
|
@@ -26,27 +26,6 @@ import aiosqlite
|
|
|
26
26
|
|
|
27
27
|
from ksadk.events.session_event import (
|
|
28
28
|
SessionEventStore,
|
|
29
|
-
SessionServiceEventStore,
|
|
30
|
-
envelope_to_session_event,
|
|
31
|
-
session_event_storage_id,
|
|
32
|
-
session_event_to_envelope,
|
|
33
|
-
validate_write_guard,
|
|
34
|
-
)
|
|
35
|
-
from ksadk.interaction.contracts import (
|
|
36
|
-
InteractionReceipt,
|
|
37
|
-
InteractionRecord,
|
|
38
|
-
InteractionSubmission,
|
|
39
|
-
is_terminal,
|
|
40
|
-
)
|
|
41
|
-
from ksadk.interaction.ledger import (
|
|
42
|
-
ALREADY_RESOLVED,
|
|
43
|
-
REQUEST_CONFLICT,
|
|
44
|
-
REVISION_MISMATCH,
|
|
45
|
-
interaction_event,
|
|
46
|
-
request_digest,
|
|
47
|
-
requested_event_payload,
|
|
48
|
-
resolve_outcome,
|
|
49
|
-
submission_digest,
|
|
50
29
|
)
|
|
51
30
|
from ksadk.kernel.contracts import (
|
|
52
31
|
ActivationLease,
|
|
@@ -65,6 +44,7 @@ from ksadk.kernel.state import (
|
|
|
65
44
|
assert_run_transition,
|
|
66
45
|
is_active_run,
|
|
67
46
|
)
|
|
47
|
+
from ksadk.kernel.sqlite_session_cleanup import install_session_delete_trigger, retire_missing_session
|
|
68
48
|
from ksadk.kernel.store import (
|
|
69
49
|
ActivationLeaseRequest,
|
|
70
50
|
InboxMessage,
|
|
@@ -74,13 +54,112 @@ from ksadk.kernel.store import (
|
|
|
74
54
|
new_message_id,
|
|
75
55
|
now_iso,
|
|
76
56
|
)
|
|
77
|
-
from ksadk.sessions._local_tables import
|
|
78
|
-
from ksadk.sessions.base import SessionEvent
|
|
57
|
+
from ksadk.sessions._local_tables import KSADK_SESSIONS_TABLE
|
|
79
58
|
from ksadk.sessions.local_service import LocalSessionService
|
|
59
|
+
from ksadk.sessions.postgres_service import PostgresSessionService
|
|
60
|
+
|
|
61
|
+
SCHEMA_VERSION = 4
|
|
62
|
+
|
|
63
|
+
_SCHEMA = """
|
|
64
|
+
CREATE TABLE IF NOT EXISTS kernel_inbox (
|
|
65
|
+
message_id TEXT PRIMARY KEY,
|
|
66
|
+
agent_instance_id TEXT NOT NULL,
|
|
67
|
+
session_id TEXT NOT NULL,
|
|
68
|
+
idempotency_key TEXT NOT NULL,
|
|
69
|
+
request_digest TEXT NOT NULL,
|
|
70
|
+
accepted_seq INTEGER NOT NULL,
|
|
71
|
+
status TEXT NOT NULL CHECK (status IN ('accepted','claimed','completed','discarded')),
|
|
72
|
+
claimed_fence INTEGER,
|
|
73
|
+
payload_json TEXT NOT NULL,
|
|
74
|
+
UNIQUE(session_id, idempotency_key)
|
|
75
|
+
);
|
|
76
|
+
CREATE INDEX IF NOT EXISTS idx_kernel_inbox_claim
|
|
77
|
+
ON kernel_inbox (agent_instance_id, session_id, status, accepted_seq);
|
|
78
|
+
CREATE INDEX IF NOT EXISTS idx_kernel_inbox_idempotency
|
|
79
|
+
ON kernel_inbox (session_id, idempotency_key);
|
|
80
|
+
|
|
81
|
+
CREATE TABLE IF NOT EXISTS kernel_runs (
|
|
82
|
+
run_id TEXT PRIMARY KEY,
|
|
83
|
+
agent_instance_id TEXT NOT NULL,
|
|
84
|
+
session_id TEXT NOT NULL,
|
|
85
|
+
state TEXT NOT NULL CHECK (state IN (
|
|
86
|
+
'pending','running','paused','waiting','completed','failed','cancelled','interrupted'
|
|
87
|
+
)),
|
|
88
|
+
activation_fence INTEGER NOT NULL DEFAULT 0,
|
|
89
|
+
created_at TEXT NOT NULL,
|
|
90
|
+
updated_at TEXT NOT NULL,
|
|
91
|
+
metadata_json TEXT NOT NULL DEFAULT '{}'
|
|
92
|
+
);
|
|
93
|
+
CREATE INDEX IF NOT EXISTS idx_kernel_runs_session_state
|
|
94
|
+
ON kernel_runs (session_id, state);
|
|
95
|
+
|
|
96
|
+
CREATE TABLE IF NOT EXISTS kernel_activations (
|
|
97
|
+
agent_instance_id TEXT NOT NULL,
|
|
98
|
+
session_id TEXT NOT NULL,
|
|
99
|
+
activation_id TEXT NOT NULL,
|
|
100
|
+
fencing_token INTEGER NOT NULL,
|
|
101
|
+
lease_expires_at REAL NOT NULL,
|
|
102
|
+
lease_expires_at_iso TEXT NOT NULL,
|
|
103
|
+
released INTEGER NOT NULL DEFAULT 0,
|
|
104
|
+
runtime_type TEXT NOT NULL DEFAULT 'ksadk',
|
|
105
|
+
bundle_digest TEXT NOT NULL DEFAULT '',
|
|
106
|
+
capability_digest TEXT NOT NULL DEFAULT '',
|
|
107
|
+
PRIMARY KEY (agent_instance_id, session_id)
|
|
108
|
+
);
|
|
109
|
+
CREATE INDEX IF NOT EXISTS idx_kernel_activations_expiry
|
|
110
|
+
ON kernel_activations (lease_expires_at);
|
|
111
|
+
|
|
112
|
+
CREATE TABLE IF NOT EXISTS kernel_accepted_seq (
|
|
113
|
+
session_id TEXT PRIMARY KEY,
|
|
114
|
+
last_seq INTEGER NOT NULL DEFAULT 0
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
CREATE TABLE IF NOT EXISTS kernel_interactions (
|
|
118
|
+
interaction_id TEXT NOT NULL,
|
|
119
|
+
tenant_id TEXT NOT NULL,
|
|
120
|
+
agent_instance_id TEXT NOT NULL,
|
|
121
|
+
session_id TEXT NOT NULL,
|
|
122
|
+
run_id TEXT NOT NULL,
|
|
123
|
+
kind TEXT NOT NULL CHECK (kind IN ('approval','structured_input','plan_review','custom')),
|
|
124
|
+
request_schema_json TEXT NOT NULL,
|
|
125
|
+
presentation_json TEXT,
|
|
126
|
+
revision INTEGER NOT NULL,
|
|
127
|
+
status TEXT NOT NULL CHECK (status IN (
|
|
128
|
+
'pending','resolving','resolved','cancelled','expired'
|
|
129
|
+
)),
|
|
130
|
+
created_at TEXT NOT NULL,
|
|
131
|
+
expires_at TEXT,
|
|
132
|
+
provider_id TEXT NOT NULL DEFAULT '',
|
|
133
|
+
native_target_json TEXT,
|
|
134
|
+
continuation_json TEXT,
|
|
135
|
+
request_digest TEXT NOT NULL,
|
|
136
|
+
response_json TEXT,
|
|
137
|
+
outcome TEXT,
|
|
138
|
+
actor TEXT,
|
|
139
|
+
event_id TEXT,
|
|
140
|
+
accepted_seq INTEGER,
|
|
141
|
+
fencing_token INTEGER,
|
|
142
|
+
updated_at TEXT,
|
|
143
|
+
PRIMARY KEY (tenant_id, interaction_id)
|
|
144
|
+
);
|
|
145
|
+
CREATE INDEX IF NOT EXISTS idx_kernel_interactions_pending
|
|
146
|
+
ON kernel_interactions (tenant_id, session_id, status);
|
|
147
|
+
|
|
148
|
+
CREATE TABLE IF NOT EXISTS kernel_interaction_submissions (
|
|
149
|
+
tenant_id TEXT NOT NULL,
|
|
150
|
+
interaction_id TEXT NOT NULL,
|
|
151
|
+
idempotency_key TEXT NOT NULL,
|
|
152
|
+
submission_digest TEXT NOT NULL,
|
|
153
|
+
receipt_json TEXT NOT NULL,
|
|
154
|
+
PRIMARY KEY (tenant_id, interaction_id, idempotency_key)
|
|
155
|
+
);
|
|
156
|
+
"""
|
|
157
|
+
|
|
80
158
|
|
|
81
|
-
from ksadk.kernel.
|
|
159
|
+
from ksadk.kernel.interactions_sqlite import SQLiteInteractionStoreMixin
|
|
82
160
|
|
|
83
|
-
|
|
161
|
+
|
|
162
|
+
class SQLiteAgentKernelStore(SQLiteInteractionStoreMixin, SQLiteExecutionGrantMixin):
|
|
84
163
|
def __init__(
|
|
85
164
|
self,
|
|
86
165
|
db_path: str | Path,
|
|
@@ -89,6 +168,15 @@ class SQLiteAgentKernelStore(SQLiteExecutionGrantMixin):
|
|
|
89
168
|
self.db_path = Path(db_path).expanduser().resolve()
|
|
90
169
|
self.db_path.parent.mkdir(parents=True, exist_ok=True)
|
|
91
170
|
self._events = session_event_store
|
|
171
|
+
service = getattr(session_event_store, "session_service", None)
|
|
172
|
+
# A standalone Studio can pair a local kernel with a durable remote
|
|
173
|
+
# Session authority. An empty process-local mirror is not such proof.
|
|
174
|
+
self._remote_sessions = service if isinstance(service, PostgresSessionService) else None
|
|
175
|
+
self._session_path = service.db_path if isinstance(service, LocalSessionService) else None
|
|
176
|
+
self._session_schema = None
|
|
177
|
+
if self._session_path is not None:
|
|
178
|
+
self._session_schema = "main" if self._session_path == self.db_path else "session_authority"
|
|
179
|
+
self._split_connection: aiosqlite.Connection | None = None
|
|
92
180
|
self._write_lock = asyncio.Lock()
|
|
93
181
|
self._connection: aiosqlite.Connection | None = None
|
|
94
182
|
self._ready: asyncio.Future[None] | None = None
|
|
@@ -110,23 +198,60 @@ class SQLiteAgentKernelStore(SQLiteExecutionGrantMixin):
|
|
|
110
198
|
await connection.executescript(_SCHEMA + EXECUTION_GRANT_SCHEMA)
|
|
111
199
|
await connection.execute("BEGIN IMMEDIATE")
|
|
112
200
|
try:
|
|
201
|
+
from ksadk.kernel.admission_cursor import migrate_sqlite_admission_cursors
|
|
202
|
+
|
|
203
|
+
await migrate_sqlite_admission_cursors(connection, self.db_path, self._events)
|
|
113
204
|
await self._migrate_execution_grants(connection)
|
|
205
|
+
if self._session_schema == "main":
|
|
206
|
+
await install_session_delete_trigger(connection)
|
|
114
207
|
await connection.execute(f"PRAGMA user_version={SCHEMA_VERSION}")
|
|
115
208
|
await connection.commit()
|
|
116
209
|
except BaseException:
|
|
117
210
|
await connection.rollback()
|
|
118
211
|
raise
|
|
119
212
|
|
|
213
|
+
async def _session_lookup_connection(self) -> aiosqlite.Connection:
|
|
214
|
+
# Caller holds _write_lock. A separate connection for legacy split
|
|
215
|
+
# SQLite files keeps ordinary kernel transactions from locking the
|
|
216
|
+
# SessionService DB (their event appends use another writer).
|
|
217
|
+
if self._session_schema != "session_authority":
|
|
218
|
+
return await self._connect()
|
|
219
|
+
if self._split_connection is None:
|
|
220
|
+
connection = await aiosqlite.connect(self.db_path.as_uri() + "?mode=rw", uri=True)
|
|
221
|
+
try:
|
|
222
|
+
connection.row_factory = aiosqlite.Row
|
|
223
|
+
await connection.execute(
|
|
224
|
+
"ATTACH DATABASE ? AS session_authority",
|
|
225
|
+
(self._session_path.as_uri() + "?mode=rw",),
|
|
226
|
+
)
|
|
227
|
+
except BaseException:
|
|
228
|
+
await connection.close()
|
|
229
|
+
raise
|
|
230
|
+
self._split_connection = connection
|
|
231
|
+
return self._split_connection
|
|
232
|
+
|
|
120
233
|
async def close(self) -> None:
|
|
234
|
+
if self._split_connection is not None:
|
|
235
|
+
await self._split_connection.close()
|
|
236
|
+
self._split_connection = None
|
|
121
237
|
if self._connection is not None:
|
|
122
238
|
await self._connection.close()
|
|
123
239
|
self._connection = None
|
|
124
240
|
|
|
125
241
|
# ---------------------------------------------------------------- helpers
|
|
126
242
|
|
|
127
|
-
async def _begin(self) -> aiosqlite.Connection:
|
|
128
|
-
connection
|
|
129
|
-
|
|
243
|
+
async def _begin(self, connection: aiosqlite.Connection | None = None) -> aiosqlite.Connection:
|
|
244
|
+
if connection is None:
|
|
245
|
+
connection = await self._connect()
|
|
246
|
+
try:
|
|
247
|
+
await connection.execute("BEGIN IMMEDIATE")
|
|
248
|
+
except BaseException:
|
|
249
|
+
# aiosqlite queues work in a thread: cancellation can arrive after
|
|
250
|
+
# SQLite began the transaction but before execute returns. The
|
|
251
|
+
# caller's transaction guard has not started yet. Roll back on
|
|
252
|
+
# this same connection before its write lock can be released.
|
|
253
|
+
await connection.rollback()
|
|
254
|
+
raise
|
|
130
255
|
return connection
|
|
131
256
|
|
|
132
257
|
@staticmethod
|
|
@@ -178,7 +303,7 @@ class SQLiteAgentKernelStore(SQLiteExecutionGrantMixin):
|
|
|
178
303
|
command: AgentControlCommand,
|
|
179
304
|
*,
|
|
180
305
|
connection: aiosqlite.Connection | None = None,
|
|
181
|
-
) ->
|
|
306
|
+
) -> SessionEventEnvelope:
|
|
182
307
|
# admission 事实的 guard 绑定提交方 permit 引用与 command_id。
|
|
183
308
|
guard = AdmissionWriteGuard(
|
|
184
309
|
authorization_ref=command.authorization_ref,
|
|
@@ -190,9 +315,9 @@ class SQLiteAgentKernelStore(SQLiteExecutionGrantMixin):
|
|
|
190
315
|
and isinstance(service, LocalSessionService)
|
|
191
316
|
and service.db_path == self.db_path
|
|
192
317
|
):
|
|
193
|
-
await self._append_interaction_event_on(connection, envelope, guard)
|
|
318
|
+
return await self._append_interaction_event_on(connection, envelope, guard)
|
|
194
319
|
else:
|
|
195
|
-
await self._events.append(envelope, guard=guard)
|
|
320
|
+
return await self._events.append(envelope, guard=guard)
|
|
196
321
|
|
|
197
322
|
async def _emit_activation(
|
|
198
323
|
self, envelope: SessionEventEnvelope, activation: dict[str, Any], fence: int
|
|
@@ -263,7 +388,7 @@ class SQLiteAgentKernelStore(SQLiteExecutionGrantMixin):
|
|
|
263
388
|
)
|
|
264
389
|
await connection.commit()
|
|
265
390
|
return self._receipt(
|
|
266
|
-
|
|
391
|
+
AgentControlCommand.model_validate_json(existing["payload_json"]),
|
|
267
392
|
"duplicate",
|
|
268
393
|
message_id=existing["message_id"],
|
|
269
394
|
accepted_seq=existing["accepted_seq"],
|
|
@@ -341,7 +466,7 @@ class SQLiteAgentKernelStore(SQLiteExecutionGrantMixin):
|
|
|
341
466
|
# Shared local storage appends the event through this same
|
|
342
467
|
# connection, atomically with Inbox admission. Legacy external
|
|
343
468
|
# event stores retain the pre-existing persist-before-ack path.
|
|
344
|
-
await self._emit_admission(
|
|
469
|
+
admitted = await self._emit_admission(
|
|
345
470
|
control_event(
|
|
346
471
|
session_id=command.session_id,
|
|
347
472
|
event_type="control.command_accepted",
|
|
@@ -357,6 +482,11 @@ class SQLiteAgentKernelStore(SQLiteExecutionGrantMixin):
|
|
|
357
482
|
command,
|
|
358
483
|
connection=connection,
|
|
359
484
|
)
|
|
485
|
+
accepted_seq = admitted.seq
|
|
486
|
+
await connection.execute(
|
|
487
|
+
"UPDATE kernel_inbox SET accepted_seq=? WHERE message_id=?",
|
|
488
|
+
(accepted_seq, message_id),
|
|
489
|
+
)
|
|
360
490
|
await connection.commit()
|
|
361
491
|
except BaseException:
|
|
362
492
|
await connection.rollback()
|
|
@@ -687,599 +817,20 @@ class SQLiteAgentKernelStore(SQLiteExecutionGrantMixin):
|
|
|
687
817
|
expected_fence,
|
|
688
818
|
)
|
|
689
819
|
|
|
690
|
-
# -------------------------------------------------------------- interactions
|
|
691
|
-
|
|
692
|
-
async def _check_interaction_guard(
|
|
693
|
-
self,
|
|
694
|
-
connection: aiosqlite.Connection,
|
|
695
|
-
agent_instance_id: str,
|
|
696
|
-
session_id: str,
|
|
697
|
-
guard: ActivationWriteGuard | AdmissionWriteGuard,
|
|
698
|
-
) -> dict[str, Any]:
|
|
699
|
-
row = await self._fetchone(
|
|
700
|
-
connection,
|
|
701
|
-
"SELECT * FROM kernel_activations WHERE activation_id=?",
|
|
702
|
-
(guard.activation_id,),
|
|
703
|
-
)
|
|
704
|
-
activation = self._activation_row(row)
|
|
705
|
-
if (
|
|
706
|
-
activation is None
|
|
707
|
-
or activation["lease_expires_at"] <= time.time()
|
|
708
|
-
or activation["fencing_token"] != int(guard.fencing_token)
|
|
709
|
-
or activation["agent_instance_id"] != agent_instance_id
|
|
710
|
-
or activation["session_id"] != session_id
|
|
711
|
-
):
|
|
712
|
-
raise StaleFenceError(
|
|
713
|
-
"interaction write guard does not match the current lease",
|
|
714
|
-
details={
|
|
715
|
-
"activation_id": guard.activation_id,
|
|
716
|
-
"fencing_token": int(guard.fencing_token),
|
|
717
|
-
"session_id": session_id,
|
|
718
|
-
},
|
|
719
|
-
)
|
|
720
|
-
return activation
|
|
721
|
-
|
|
722
|
-
def _require_local_transactional_event_store(self) -> None:
|
|
723
|
-
"""Ensure an Interaction fact shares this store's SQLite transaction.
|
|
724
|
-
|
|
725
|
-
``SessionServiceEventStore(LocalSessionService)`` normally owns the
|
|
726
|
-
canonical local SessionEvent log. Giving the kernel a different file
|
|
727
|
-
would make a ledger row and its event independently committable, so it
|
|
728
|
-
is an invalid Interaction/v1 configuration rather than a best-effort
|
|
729
|
-
fallback. Other session backends remain usable for the pre-existing
|
|
730
|
-
non-transactional local control path, but not for durable interactions.
|
|
731
|
-
"""
|
|
732
|
-
|
|
733
|
-
service = (
|
|
734
|
-
self._events.session_service
|
|
735
|
-
if isinstance(self._events, SessionServiceEventStore)
|
|
736
|
-
else None
|
|
737
|
-
)
|
|
738
|
-
if (
|
|
739
|
-
not isinstance(service, LocalSessionService)
|
|
740
|
-
or service.db_path != self.db_path.resolve()
|
|
741
|
-
):
|
|
742
|
-
raise RuntimeError(
|
|
743
|
-
"SQLite InteractionLedger requires SessionEventStore backed by the "
|
|
744
|
-
"same SQLite database"
|
|
745
|
-
)
|
|
746
|
-
|
|
747
|
-
async def _append_interaction_event_on(
|
|
748
|
-
self,
|
|
749
|
-
connection: aiosqlite.Connection,
|
|
750
|
-
envelope: SessionEventEnvelope,
|
|
751
|
-
guard: ActivationWriteGuard,
|
|
752
|
-
) -> SessionEventEnvelope:
|
|
753
|
-
"""Append the canonical SessionEvent in the ledger writer transaction."""
|
|
754
|
-
|
|
755
|
-
self._require_local_transactional_event_store()
|
|
756
|
-
validate_write_guard(envelope, guard)
|
|
757
|
-
packed = envelope_to_session_event(envelope)
|
|
758
|
-
storage_id = session_event_storage_id(envelope.session_id, str(envelope.event_id))
|
|
759
|
-
session_row = await self._fetchone(
|
|
760
|
-
connection,
|
|
761
|
-
f"SELECT id FROM {KSADK_SESSIONS_TABLE} WHERE id=?",
|
|
762
|
-
(envelope.session_id,),
|
|
763
|
-
)
|
|
764
|
-
if session_row is None:
|
|
765
|
-
raise InvalidCommandError(
|
|
766
|
-
f"session {envelope.session_id!r} does not exist in the shared event log"
|
|
767
|
-
)
|
|
768
|
-
existing = await self._fetchone(
|
|
769
|
-
connection,
|
|
770
|
-
f"SELECT id, author, event_type, content_json, timestamp, seq_id,"
|
|
771
|
-
f" invocation_id, metadata_json FROM {KSADK_EVENTS_TABLE}"
|
|
772
|
-
" WHERE session_id=? AND id=?",
|
|
773
|
-
(envelope.session_id, storage_id),
|
|
774
|
-
)
|
|
775
|
-
if existing is not None:
|
|
776
|
-
stored = SessionEvent(
|
|
777
|
-
id=existing["id"],
|
|
778
|
-
session_id=envelope.session_id,
|
|
779
|
-
author=existing["author"],
|
|
780
|
-
event_type=existing["event_type"],
|
|
781
|
-
content=json.loads(existing["content_json"]),
|
|
782
|
-
timestamp=float(existing["timestamp"]),
|
|
783
|
-
seq_id=int(existing["seq_id"]),
|
|
784
|
-
invocation_id=existing["invocation_id"],
|
|
785
|
-
metadata=json.loads(existing["metadata_json"]),
|
|
786
|
-
)
|
|
787
|
-
persisted = session_event_to_envelope(stored)
|
|
788
|
-
if persisted is None: # pragma: no cover - only our packed rows use this id
|
|
789
|
-
raise RuntimeError("kernel interaction event lost its envelope marker")
|
|
790
|
-
SessionServiceEventStore._assert_same_fact(persisted, envelope)
|
|
791
|
-
return persisted
|
|
792
|
-
|
|
793
|
-
next_seq_row = await self._fetchone(
|
|
794
|
-
connection,
|
|
795
|
-
f"SELECT COALESCE(MAX(seq_id), 0) + 1 AS next_seq FROM {KSADK_EVENTS_TABLE}"
|
|
796
|
-
" WHERE session_id=?",
|
|
797
|
-
(envelope.session_id,),
|
|
798
|
-
)
|
|
799
|
-
next_seq = int(next_seq_row["next_seq"])
|
|
800
|
-
packed.bind_seq_id(next_seq)
|
|
801
|
-
await connection.execute(
|
|
802
|
-
f"INSERT INTO {KSADK_EVENTS_TABLE} ("
|
|
803
|
-
"id, session_id, author, event_type, content_json, timestamp, "
|
|
804
|
-
"state_delta_json, seq_id, invocation_id, metadata_json"
|
|
805
|
-
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
806
|
-
(
|
|
807
|
-
storage_id,
|
|
808
|
-
envelope.session_id,
|
|
809
|
-
packed.author,
|
|
810
|
-
packed.event_type,
|
|
811
|
-
json.dumps(packed.content, ensure_ascii=False),
|
|
812
|
-
packed.timestamp,
|
|
813
|
-
json.dumps(packed.state_delta, ensure_ascii=False),
|
|
814
|
-
next_seq,
|
|
815
|
-
packed.invocation_id,
|
|
816
|
-
json.dumps(packed.metadata, ensure_ascii=False),
|
|
817
|
-
),
|
|
818
|
-
)
|
|
819
|
-
await connection.execute(
|
|
820
|
-
f"UPDATE {KSADK_SESSIONS_TABLE} SET updated_at=? WHERE id=?",
|
|
821
|
-
(time.time(), envelope.session_id),
|
|
822
|
-
)
|
|
823
|
-
persisted = session_event_to_envelope(packed)
|
|
824
|
-
if persisted is None: # pragma: no cover - packed by this method
|
|
825
|
-
raise RuntimeError("kernel interaction event lost its envelope marker")
|
|
826
|
-
return persisted
|
|
827
|
-
|
|
828
|
-
async def _interaction_row_for_guard(
|
|
829
|
-
self,
|
|
830
|
-
connection: aiosqlite.Connection,
|
|
831
|
-
interaction_id: str,
|
|
832
|
-
guard: ActivationWriteGuard,
|
|
833
|
-
) -> aiosqlite.Row | None:
|
|
834
|
-
"""Find a public id through the trusted activation scope, not by id alone."""
|
|
835
|
-
|
|
836
|
-
activation_row = await self._fetchone(
|
|
837
|
-
connection,
|
|
838
|
-
"SELECT * FROM kernel_activations WHERE activation_id=?",
|
|
839
|
-
(guard.activation_id,),
|
|
840
|
-
)
|
|
841
|
-
activation = self._activation_row(activation_row)
|
|
842
|
-
if (
|
|
843
|
-
activation is None
|
|
844
|
-
or activation["released"]
|
|
845
|
-
or activation["lease_expires_at"] <= time.time()
|
|
846
|
-
or activation["fencing_token"] != int(guard.fencing_token)
|
|
847
|
-
):
|
|
848
|
-
raise StaleFenceError(
|
|
849
|
-
"interaction write guard does not match the current lease",
|
|
850
|
-
details={
|
|
851
|
-
"activation_id": guard.activation_id,
|
|
852
|
-
"fencing_token": int(guard.fencing_token),
|
|
853
|
-
},
|
|
854
|
-
)
|
|
855
|
-
return await self._fetchone(
|
|
856
|
-
connection,
|
|
857
|
-
"SELECT * FROM kernel_interactions WHERE interaction_id=?"
|
|
858
|
-
" AND agent_instance_id=? AND session_id=?",
|
|
859
|
-
(
|
|
860
|
-
interaction_id,
|
|
861
|
-
activation["agent_instance_id"],
|
|
862
|
-
activation["session_id"],
|
|
863
|
-
),
|
|
864
|
-
)
|
|
865
|
-
|
|
866
|
-
@staticmethod
|
|
867
|
-
def _row_to_record(row: aiosqlite.Row | None) -> InteractionRecord | None:
|
|
868
|
-
if row is None:
|
|
869
|
-
return None
|
|
870
|
-
from ksadk.interaction.contracts import InteractionPresentation
|
|
871
|
-
|
|
872
|
-
presentation = None
|
|
873
|
-
if row["presentation_json"]:
|
|
874
|
-
presentation = InteractionPresentation.model_validate_json(row["presentation_json"])
|
|
875
|
-
return InteractionRecord(
|
|
876
|
-
interaction_id=row["interaction_id"],
|
|
877
|
-
tenant_id=row["tenant_id"],
|
|
878
|
-
agent_instance_id=row["agent_instance_id"],
|
|
879
|
-
session_id=row["session_id"],
|
|
880
|
-
run_id=row["run_id"],
|
|
881
|
-
kind=row["kind"],
|
|
882
|
-
request_schema=json.loads(row["request_schema_json"]),
|
|
883
|
-
revision=int(row["revision"]),
|
|
884
|
-
status=row["status"],
|
|
885
|
-
created_at=row["created_at"],
|
|
886
|
-
expires_at=row["expires_at"],
|
|
887
|
-
presentation=presentation,
|
|
888
|
-
provider_id=row["provider_id"] or "",
|
|
889
|
-
native_target=(
|
|
890
|
-
json.loads(row["native_target_json"]) if row["native_target_json"] else None
|
|
891
|
-
),
|
|
892
|
-
continuation_metadata=(
|
|
893
|
-
json.loads(row["continuation_json"]) if row["continuation_json"] else None
|
|
894
|
-
),
|
|
895
|
-
)
|
|
896
|
-
|
|
897
|
-
def _record_values(self, record: InteractionRecord, *, request_digest_: str) -> tuple:
|
|
898
|
-
return (
|
|
899
|
-
record.interaction_id,
|
|
900
|
-
record.tenant_id,
|
|
901
|
-
record.agent_instance_id,
|
|
902
|
-
record.session_id,
|
|
903
|
-
record.run_id,
|
|
904
|
-
record.kind,
|
|
905
|
-
json.dumps(record.request_schema, ensure_ascii=False),
|
|
906
|
-
(record.presentation.model_dump_json() if record.presentation is not None else None),
|
|
907
|
-
record.revision,
|
|
908
|
-
record.status,
|
|
909
|
-
record.created_at,
|
|
910
|
-
record.expires_at,
|
|
911
|
-
record.provider_id,
|
|
912
|
-
(
|
|
913
|
-
json.dumps(record.native_target, ensure_ascii=False)
|
|
914
|
-
if record.native_target is not None
|
|
915
|
-
else None
|
|
916
|
-
),
|
|
917
|
-
(
|
|
918
|
-
json.dumps(record.continuation_metadata, ensure_ascii=False)
|
|
919
|
-
if record.continuation_metadata is not None
|
|
920
|
-
else None
|
|
921
|
-
),
|
|
922
|
-
request_digest_,
|
|
923
|
-
now_iso(),
|
|
924
|
-
)
|
|
925
|
-
|
|
926
|
-
async def request(
|
|
927
|
-
self, record: InteractionRecord, *, guard: ActivationWriteGuard
|
|
928
|
-
) -> InteractionRecord:
|
|
929
|
-
digest = request_digest(record)
|
|
930
|
-
async with self._write_lock:
|
|
931
|
-
connection = await self._begin()
|
|
932
|
-
try:
|
|
933
|
-
await self._check_interaction_guard(
|
|
934
|
-
connection, record.agent_instance_id, record.session_id, guard
|
|
935
|
-
)
|
|
936
|
-
existing = await self._fetchone(
|
|
937
|
-
connection,
|
|
938
|
-
"SELECT * FROM kernel_interactions WHERE tenant_id=? AND interaction_id=?",
|
|
939
|
-
(record.tenant_id, record.interaction_id),
|
|
940
|
-
)
|
|
941
|
-
if existing is not None:
|
|
942
|
-
if existing["request_digest"] != digest:
|
|
943
|
-
raise InvalidCommandError(
|
|
944
|
-
"interaction_id reused with a different request digest",
|
|
945
|
-
details={
|
|
946
|
-
"reason": REQUEST_CONFLICT,
|
|
947
|
-
"interaction_id": record.interaction_id,
|
|
948
|
-
},
|
|
949
|
-
)
|
|
950
|
-
await connection.commit()
|
|
951
|
-
stored = self._row_to_record(existing)
|
|
952
|
-
assert stored is not None
|
|
953
|
-
return stored
|
|
954
|
-
await connection.execute(
|
|
955
|
-
"INSERT INTO kernel_interactions (interaction_id, tenant_id,"
|
|
956
|
-
" agent_instance_id, session_id, run_id, kind, request_schema_json,"
|
|
957
|
-
" presentation_json, revision, status, created_at, expires_at,"
|
|
958
|
-
" provider_id, native_target_json, continuation_json,"
|
|
959
|
-
" request_digest, updated_at) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
|
960
|
-
self._record_values(record, request_digest_=digest),
|
|
961
|
-
)
|
|
962
|
-
# pending 行与 canonical requested 事实共用同一 SQLite commit。
|
|
963
|
-
await self._append_interaction_event_on(
|
|
964
|
-
connection, requested_event_payload(record, now_iso()), guard
|
|
965
|
-
)
|
|
966
|
-
await connection.commit()
|
|
967
|
-
except BaseException:
|
|
968
|
-
await connection.rollback()
|
|
969
|
-
raise
|
|
970
|
-
return record
|
|
971
|
-
|
|
972
|
-
async def resolve(
|
|
973
|
-
self, submission: InteractionSubmission, *, guard: ActivationWriteGuard
|
|
974
|
-
) -> InteractionReceipt:
|
|
975
|
-
sub_digest = submission_digest(submission)
|
|
976
|
-
async with self._write_lock:
|
|
977
|
-
connection = await self._begin()
|
|
978
|
-
try:
|
|
979
|
-
row = await self._interaction_row_for_guard(
|
|
980
|
-
connection, submission.interaction_id, guard
|
|
981
|
-
)
|
|
982
|
-
if row is None:
|
|
983
|
-
raise InvalidCommandError(
|
|
984
|
-
f"unknown interaction_id {submission.interaction_id!r}"
|
|
985
|
-
)
|
|
986
|
-
await self._check_interaction_guard(
|
|
987
|
-
connection, row["agent_instance_id"], row["session_id"], guard
|
|
988
|
-
)
|
|
989
|
-
current = self._row_to_record(row)
|
|
990
|
-
assert current is not None
|
|
991
|
-
if is_terminal(current.status):
|
|
992
|
-
existing_sub = await self._fetchone(
|
|
993
|
-
connection,
|
|
994
|
-
"SELECT * FROM kernel_interaction_submissions WHERE tenant_id=?"
|
|
995
|
-
" AND interaction_id=? AND idempotency_key=?",
|
|
996
|
-
(
|
|
997
|
-
current.tenant_id,
|
|
998
|
-
current.interaction_id,
|
|
999
|
-
submission.idempotency_key,
|
|
1000
|
-
),
|
|
1001
|
-
)
|
|
1002
|
-
if existing_sub is not None and existing_sub["submission_digest"] == sub_digest:
|
|
1003
|
-
await connection.commit()
|
|
1004
|
-
return InteractionReceipt.model_validate_json(existing_sub["receipt_json"])
|
|
1005
|
-
raise InvalidCommandError(
|
|
1006
|
-
f"interaction already reached terminal status {current.status!r}",
|
|
1007
|
-
details={
|
|
1008
|
-
"reason": ALREADY_RESOLVED,
|
|
1009
|
-
"interaction_id": current.interaction_id,
|
|
1010
|
-
},
|
|
1011
|
-
)
|
|
1012
|
-
if current.revision != submission.expected_revision:
|
|
1013
|
-
raise InvalidCommandError(
|
|
1014
|
-
"interaction revision does not match expected_revision",
|
|
1015
|
-
details={
|
|
1016
|
-
"reason": REVISION_MISMATCH,
|
|
1017
|
-
"interaction_id": current.interaction_id,
|
|
1018
|
-
"expected_revision": submission.expected_revision,
|
|
1019
|
-
"current_revision": current.revision,
|
|
1020
|
-
},
|
|
1021
|
-
)
|
|
1022
|
-
outcome = resolve_outcome(submission.action)
|
|
1023
|
-
updated = current.model_copy(
|
|
1024
|
-
update={"status": "resolved", "revision": current.revision + 1}
|
|
1025
|
-
)
|
|
1026
|
-
stored = await self._append_interaction_event_on(
|
|
1027
|
-
connection,
|
|
1028
|
-
interaction_event(
|
|
1029
|
-
updated,
|
|
1030
|
-
event_type="interaction.resolved",
|
|
1031
|
-
timestamp=now_iso(),
|
|
1032
|
-
outcome=outcome,
|
|
1033
|
-
response=submission.response,
|
|
1034
|
-
actor_ref="user",
|
|
1035
|
-
),
|
|
1036
|
-
guard,
|
|
1037
|
-
)
|
|
1038
|
-
receipt = InteractionReceipt(
|
|
1039
|
-
interaction_id=updated.interaction_id,
|
|
1040
|
-
revision=updated.revision,
|
|
1041
|
-
status="resolved",
|
|
1042
|
-
outcome=outcome, # type: ignore[arg-type]
|
|
1043
|
-
event_id=str(stored.event_id),
|
|
1044
|
-
accepted_seq=stored.seq,
|
|
1045
|
-
)
|
|
1046
|
-
await connection.execute(
|
|
1047
|
-
"UPDATE kernel_interactions SET revision=?, status=?,"
|
|
1048
|
-
" response_json=?, outcome=?, actor=?, event_id=?, accepted_seq=?,"
|
|
1049
|
-
" fencing_token=?, updated_at=? WHERE tenant_id=? AND interaction_id=?",
|
|
1050
|
-
(
|
|
1051
|
-
updated.revision,
|
|
1052
|
-
"resolved",
|
|
1053
|
-
json.dumps(submission.response, ensure_ascii=False),
|
|
1054
|
-
outcome,
|
|
1055
|
-
"user",
|
|
1056
|
-
str(stored.event_id),
|
|
1057
|
-
stored.seq,
|
|
1058
|
-
int(guard.fencing_token),
|
|
1059
|
-
now_iso(),
|
|
1060
|
-
updated.tenant_id,
|
|
1061
|
-
updated.interaction_id,
|
|
1062
|
-
),
|
|
1063
|
-
)
|
|
1064
|
-
await connection.execute(
|
|
1065
|
-
"INSERT INTO kernel_interaction_submissions (tenant_id,"
|
|
1066
|
-
" interaction_id, idempotency_key, submission_digest, receipt_json)"
|
|
1067
|
-
" VALUES (?,?,?,?,?) ON CONFLICT DO NOTHING",
|
|
1068
|
-
(
|
|
1069
|
-
updated.tenant_id,
|
|
1070
|
-
updated.interaction_id,
|
|
1071
|
-
submission.idempotency_key,
|
|
1072
|
-
sub_digest,
|
|
1073
|
-
receipt.model_dump_json(),
|
|
1074
|
-
),
|
|
1075
|
-
)
|
|
1076
|
-
await connection.commit()
|
|
1077
|
-
except BaseException:
|
|
1078
|
-
await connection.rollback()
|
|
1079
|
-
raise
|
|
1080
|
-
return receipt
|
|
1081
|
-
|
|
1082
|
-
async def _terminal_command(
|
|
1083
|
-
self,
|
|
1084
|
-
interaction_id: str,
|
|
1085
|
-
expected_revision: int,
|
|
1086
|
-
*,
|
|
1087
|
-
guard: ActivationWriteGuard,
|
|
1088
|
-
status: str,
|
|
1089
|
-
reason: str,
|
|
1090
|
-
) -> InteractionReceipt:
|
|
1091
|
-
async with self._write_lock:
|
|
1092
|
-
connection = await self._begin()
|
|
1093
|
-
try:
|
|
1094
|
-
row = await self._interaction_row_for_guard(connection, interaction_id, guard)
|
|
1095
|
-
if row is None:
|
|
1096
|
-
raise InvalidCommandError(f"unknown interaction_id {interaction_id!r}")
|
|
1097
|
-
await self._check_interaction_guard(
|
|
1098
|
-
connection, row["agent_instance_id"], row["session_id"], guard
|
|
1099
|
-
)
|
|
1100
|
-
current = self._row_to_record(row)
|
|
1101
|
-
assert current is not None
|
|
1102
|
-
if is_terminal(current.status):
|
|
1103
|
-
raise InvalidCommandError(
|
|
1104
|
-
f"interaction already reached terminal status {current.status!r}",
|
|
1105
|
-
details={
|
|
1106
|
-
"reason": ALREADY_RESOLVED,
|
|
1107
|
-
"interaction_id": current.interaction_id,
|
|
1108
|
-
},
|
|
1109
|
-
)
|
|
1110
|
-
if current.revision != expected_revision:
|
|
1111
|
-
raise InvalidCommandError(
|
|
1112
|
-
"interaction revision does not match expected_revision",
|
|
1113
|
-
details={
|
|
1114
|
-
"reason": REVISION_MISMATCH,
|
|
1115
|
-
"interaction_id": current.interaction_id,
|
|
1116
|
-
"expected_revision": expected_revision,
|
|
1117
|
-
"current_revision": current.revision,
|
|
1118
|
-
},
|
|
1119
|
-
)
|
|
1120
|
-
updated = current.model_copy(
|
|
1121
|
-
update={"status": status, "revision": current.revision + 1}
|
|
1122
|
-
)
|
|
1123
|
-
event_type = (
|
|
1124
|
-
"interaction.cancelled" if status == "cancelled" else "interaction.expired"
|
|
1125
|
-
)
|
|
1126
|
-
stored = await self._append_interaction_event_on(
|
|
1127
|
-
connection,
|
|
1128
|
-
interaction_event(
|
|
1129
|
-
updated,
|
|
1130
|
-
event_type=event_type,
|
|
1131
|
-
timestamp=now_iso(),
|
|
1132
|
-
reason=reason,
|
|
1133
|
-
),
|
|
1134
|
-
guard,
|
|
1135
|
-
)
|
|
1136
|
-
receipt = InteractionReceipt(
|
|
1137
|
-
interaction_id=updated.interaction_id,
|
|
1138
|
-
revision=updated.revision,
|
|
1139
|
-
status=updated.status, # type: ignore[arg-type]
|
|
1140
|
-
outcome=updated.status, # type: ignore[arg-type]
|
|
1141
|
-
event_id=str(stored.event_id),
|
|
1142
|
-
accepted_seq=stored.seq,
|
|
1143
|
-
)
|
|
1144
|
-
await connection.execute(
|
|
1145
|
-
"UPDATE kernel_interactions SET revision=?, status=?, outcome=?,"
|
|
1146
|
-
" event_id=?, accepted_seq=?, fencing_token=?, updated_at=?"
|
|
1147
|
-
" WHERE tenant_id=? AND interaction_id=?",
|
|
1148
|
-
(
|
|
1149
|
-
updated.revision,
|
|
1150
|
-
status,
|
|
1151
|
-
status,
|
|
1152
|
-
str(stored.event_id),
|
|
1153
|
-
stored.seq,
|
|
1154
|
-
int(guard.fencing_token),
|
|
1155
|
-
now_iso(),
|
|
1156
|
-
updated.tenant_id,
|
|
1157
|
-
updated.interaction_id,
|
|
1158
|
-
),
|
|
1159
|
-
)
|
|
1160
|
-
await connection.commit()
|
|
1161
|
-
except BaseException:
|
|
1162
|
-
await connection.rollback()
|
|
1163
|
-
raise
|
|
1164
|
-
return receipt
|
|
1165
|
-
|
|
1166
|
-
async def cancel(
|
|
1167
|
-
self, interaction_id: str, expected_revision: int, *, guard: ActivationWriteGuard
|
|
1168
|
-
) -> InteractionReceipt:
|
|
1169
|
-
return await self._terminal_command(
|
|
1170
|
-
interaction_id,
|
|
1171
|
-
expected_revision,
|
|
1172
|
-
guard=guard,
|
|
1173
|
-
status="cancelled",
|
|
1174
|
-
reason="cancelled by owner",
|
|
1175
|
-
)
|
|
1176
|
-
|
|
1177
|
-
async def expire(
|
|
1178
|
-
self, interaction_id: str, expected_revision: int, *, guard: ActivationWriteGuard
|
|
1179
|
-
) -> InteractionReceipt:
|
|
1180
|
-
return await self._terminal_command(
|
|
1181
|
-
interaction_id,
|
|
1182
|
-
expected_revision,
|
|
1183
|
-
guard=guard,
|
|
1184
|
-
status="expired",
|
|
1185
|
-
reason="interaction expired",
|
|
1186
|
-
)
|
|
1187
|
-
|
|
1188
|
-
async def get(
|
|
1189
|
-
self,
|
|
1190
|
-
interaction_id: str,
|
|
1191
|
-
*,
|
|
1192
|
-
tenant_id: str | None = None,
|
|
1193
|
-
agent_instance_id: str | None = None,
|
|
1194
|
-
session_id: str | None = None,
|
|
1195
|
-
run_id: str | None = None,
|
|
1196
|
-
) -> InteractionRecord | None:
|
|
1197
|
-
"""Return an interaction only inside a complete trusted scope.
|
|
1198
|
-
|
|
1199
|
-
An omitted scope is retained for local compatibility but is fail-closed
|
|
1200
|
-
when the opaque id exists in more than one tenant. Partial scope is
|
|
1201
|
-
never sufficient for a security-sensitive worker lookup.
|
|
1202
|
-
"""
|
|
1203
|
-
|
|
1204
|
-
scope = (tenant_id, agent_instance_id, session_id, run_id)
|
|
1205
|
-
connection = await self._connect()
|
|
1206
|
-
if any(value is not None for value in scope):
|
|
1207
|
-
if not all(value is not None for value in scope):
|
|
1208
|
-
raise InvalidCommandError(
|
|
1209
|
-
"interaction lookup requires a complete trusted scope",
|
|
1210
|
-
details={"interaction_id": interaction_id},
|
|
1211
|
-
)
|
|
1212
|
-
row = await self._fetchone(
|
|
1213
|
-
connection,
|
|
1214
|
-
"SELECT * FROM kernel_interactions WHERE interaction_id=?"
|
|
1215
|
-
" AND tenant_id=? AND agent_instance_id=? AND session_id=? AND run_id=?",
|
|
1216
|
-
(interaction_id, tenant_id, agent_instance_id, session_id, run_id),
|
|
1217
|
-
)
|
|
1218
|
-
return self._row_to_record(row)
|
|
1219
|
-
rows = await connection.execute_fetchall(
|
|
1220
|
-
"SELECT * FROM kernel_interactions WHERE interaction_id=? LIMIT 2",
|
|
1221
|
-
(interaction_id,),
|
|
1222
|
-
)
|
|
1223
|
-
if len(rows) > 1:
|
|
1224
|
-
raise InvalidCommandError(
|
|
1225
|
-
f"interaction_id {interaction_id!r} is ambiguous without trusted scope",
|
|
1226
|
-
details={"reason": REQUEST_CONFLICT, "interaction_id": interaction_id},
|
|
1227
|
-
)
|
|
1228
|
-
return self._row_to_record(rows[0]) if rows else None
|
|
1229
|
-
|
|
1230
|
-
async def get_terminal_receipt(
|
|
1231
|
-
self,
|
|
1232
|
-
interaction_id: str,
|
|
1233
|
-
*,
|
|
1234
|
-
tenant_id: str,
|
|
1235
|
-
agent_instance_id: str,
|
|
1236
|
-
session_id: str,
|
|
1237
|
-
run_id: str,
|
|
1238
|
-
) -> InteractionReceipt | None:
|
|
1239
|
-
"""Read the committed outcome inside a complete trusted scope.
|
|
1240
|
-
|
|
1241
|
-
Resolved alone does not mean approved. Pending/resolving records never
|
|
1242
|
-
yield an authorization receipt; callers must still match the request.
|
|
1243
|
-
"""
|
|
1244
|
-
if not all(
|
|
1245
|
-
isinstance(value, str) and value
|
|
1246
|
-
for value in (interaction_id, tenant_id, agent_instance_id, session_id, run_id)
|
|
1247
|
-
):
|
|
1248
|
-
raise InvalidCommandError("interaction receipt requires a complete trusted scope")
|
|
1249
|
-
row = await self._fetchone(
|
|
1250
|
-
await self._connect(),
|
|
1251
|
-
"SELECT * FROM kernel_interactions WHERE interaction_id=? AND tenant_id=?"
|
|
1252
|
-
" AND agent_instance_id=? AND session_id=? AND run_id=?",
|
|
1253
|
-
(interaction_id, tenant_id, agent_instance_id, session_id, run_id),
|
|
1254
|
-
)
|
|
1255
|
-
if row is None or not is_terminal(row["status"]):
|
|
1256
|
-
return None
|
|
1257
|
-
return InteractionReceipt(
|
|
1258
|
-
interaction_id=row["interaction_id"],
|
|
1259
|
-
revision=int(row["revision"]),
|
|
1260
|
-
status=row["status"],
|
|
1261
|
-
outcome=row["outcome"],
|
|
1262
|
-
event_id=row["event_id"],
|
|
1263
|
-
accepted_seq=row["accepted_seq"],
|
|
1264
|
-
)
|
|
1265
|
-
|
|
1266
|
-
async def list_pending_interactions(
|
|
1267
|
-
self, tenant_id: str, session_id: str
|
|
1268
|
-
) -> list[InteractionRecord]:
|
|
1269
|
-
connection = await self._connect()
|
|
1270
|
-
rows = await connection.execute_fetchall(
|
|
1271
|
-
"SELECT * FROM kernel_interactions WHERE tenant_id=? AND session_id=?"
|
|
1272
|
-
" AND status='pending' ORDER BY created_at",
|
|
1273
|
-
(tenant_id, session_id),
|
|
1274
|
-
)
|
|
1275
|
-
records = [self._row_to_record(row) for row in rows]
|
|
1276
|
-
return [r for r in records if r is not None]
|
|
1277
|
-
|
|
1278
820
|
# ------------------------------------------------------------- activations
|
|
1279
821
|
|
|
1280
822
|
async def acquire_activation(self, request: ActivationLeaseRequest) -> ActivationLease:
|
|
823
|
+
remote_missing = self._remote_sessions is not None and await self.is_session_missing(request.session_id)
|
|
1281
824
|
async with self._write_lock:
|
|
1282
|
-
|
|
825
|
+
lookup = await self._session_lookup_connection()
|
|
826
|
+
schema = self._session_schema
|
|
827
|
+
if schema == "session_authority" and await self._fetchone(
|
|
828
|
+
lookup, f"SELECT 1 FROM session_authority.{KSADK_SESSIONS_TABLE} WHERE id=?",
|
|
829
|
+
(request.session_id,),
|
|
830
|
+
):
|
|
831
|
+
# Healthy split-store sessions use the original lease path.
|
|
832
|
+
lookup, schema = await self._connect(), None
|
|
833
|
+
connection = await self._begin(lookup)
|
|
1283
834
|
try:
|
|
1284
835
|
row = await self._fetchone(
|
|
1285
836
|
connection,
|
|
@@ -1301,6 +852,14 @@ class SQLiteAgentKernelStore(SQLiteExecutionGrantMixin):
|
|
|
1301
852
|
"lease_expires_at": row["lease_expires_at_iso"],
|
|
1302
853
|
},
|
|
1303
854
|
)
|
|
855
|
+
if schema is not None or (remote_missing and await self.is_session_missing(request.session_id)):
|
|
856
|
+
# If the same owner still has a live stream, revoke its old
|
|
857
|
+
# fence in the same transaction that retires the orphan.
|
|
858
|
+
retirement_fence = int(row["fencing_token"]) + 1 if row else 1
|
|
859
|
+
if await retire_missing_session(
|
|
860
|
+
connection, schema, request.agent_instance_id, request.session_id, retirement_fence,
|
|
861
|
+
):
|
|
862
|
+
token = retirement_fence
|
|
1304
863
|
expires_iso = datetime.fromtimestamp(expires_at, tz=timezone.utc).isoformat()
|
|
1305
864
|
await connection.execute(
|
|
1306
865
|
"INSERT INTO kernel_activations (agent_instance_id, session_id,"
|
|
@@ -1521,6 +1080,57 @@ class SQLiteAgentKernelStore(SQLiteExecutionGrantMixin):
|
|
|
1521
1080
|
metadata=json.loads(row["metadata_json"]),
|
|
1522
1081
|
)
|
|
1523
1082
|
|
|
1083
|
+
async def is_session_missing(self, session_id: str) -> bool:
|
|
1084
|
+
if self._remote_sessions is not None:
|
|
1085
|
+
return await self._remote_sessions.get_session_header(session_id) is None
|
|
1086
|
+
if self._session_schema is None:
|
|
1087
|
+
return False
|
|
1088
|
+
async with self._write_lock:
|
|
1089
|
+
connection = await self._session_lookup_connection()
|
|
1090
|
+
row = await self._fetchone(
|
|
1091
|
+
connection, f"SELECT 1 FROM {self._session_schema}.{KSADK_SESSIONS_TABLE} WHERE id=?",
|
|
1092
|
+
(session_id,),
|
|
1093
|
+
)
|
|
1094
|
+
return row is None
|
|
1095
|
+
|
|
1096
|
+
async def pending_session_ids(self, agent_instance_id: str) -> set[str]:
|
|
1097
|
+
# Include old runs whose Inbox history has already been removed. Only
|
|
1098
|
+
# the authoritative local DB can distinguish those from foreign runs.
|
|
1099
|
+
open_run = """r.state IN ('running','paused','waiting') AND EXISTS (
|
|
1100
|
+
SELECT 1 FROM kernel_inbox i WHERE i.agent_instance_id=r.agent_instance_id
|
|
1101
|
+
AND i.session_id=r.session_id)"""
|
|
1102
|
+
if self._session_schema is not None:
|
|
1103
|
+
open_run += f""" OR (r.state IN ('pending','running','paused','waiting')
|
|
1104
|
+
AND NOT EXISTS (SELECT 1 FROM {self._session_schema}.{KSADK_SESSIONS_TABLE} s WHERE s.id=r.session_id))"""
|
|
1105
|
+
orphan_interactions = ""
|
|
1106
|
+
if self._session_schema is not None:
|
|
1107
|
+
orphan_interactions = f""" UNION SELECT p.session_id FROM kernel_interactions p
|
|
1108
|
+
WHERE p.agent_instance_id=:agent AND p.status IN ('pending','resolving')
|
|
1109
|
+
AND NOT EXISTS (SELECT 1 FROM {self._session_schema}.{KSADK_SESSIONS_TABLE} s WHERE s.id=p.session_id)"""
|
|
1110
|
+
async with self._write_lock:
|
|
1111
|
+
connection = await self._session_lookup_connection()
|
|
1112
|
+
rows = await connection.execute_fetchall(
|
|
1113
|
+
f"""SELECT session_id FROM kernel_inbox WHERE agent_instance_id=:agent
|
|
1114
|
+
AND status IN ('accepted','claimed') UNION
|
|
1115
|
+
SELECT r.session_id FROM kernel_runs r WHERE r.agent_instance_id=:agent AND ({open_run})
|
|
1116
|
+
{orphan_interactions}""",
|
|
1117
|
+
{"agent": agent_instance_id},
|
|
1118
|
+
)
|
|
1119
|
+
candidates = []
|
|
1120
|
+
if self._remote_sessions is not None:
|
|
1121
|
+
candidates = await connection.execute_fetchall(
|
|
1122
|
+
"""SELECT session_id FROM kernel_runs WHERE agent_instance_id=? AND
|
|
1123
|
+
state IN ('pending','running','paused','waiting') UNION
|
|
1124
|
+
SELECT session_id FROM kernel_interactions WHERE agent_instance_id=?
|
|
1125
|
+
AND status IN ('pending','resolving')""", (agent_instance_id, agent_instance_id),
|
|
1126
|
+
)
|
|
1127
|
+
pending = {row["session_id"] for row in rows}
|
|
1128
|
+
if candidates:
|
|
1129
|
+
pending.update(await self._remote_sessions.missing_session_ids(
|
|
1130
|
+
{row["session_id"] for row in candidates} - pending
|
|
1131
|
+
))
|
|
1132
|
+
return pending
|
|
1133
|
+
|
|
1524
1134
|
async def find_active_run(
|
|
1525
1135
|
self, agent_instance_id: str, session_id: str | None = None
|
|
1526
1136
|
) -> RunRecord | None:
|