agentengine-sdk-python 0.8.3__py3-none-any.whl → 0.8.5__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.
Files changed (819) hide show
  1. {agentengine_sdk_python-0.8.3.dist-info → agentengine_sdk_python-0.8.5.dist-info}/METADATA +13 -9
  2. agentengine_sdk_python-0.8.5.dist-info/RECORD +1296 -0
  3. ksadk/_build_provenance.json +1 -1
  4. ksadk/_process.py +83 -0
  5. ksadk/_str_enum.py +17 -0
  6. ksadk/a2ui/core.py +3 -3
  7. ksadk/api/client.py +111 -91
  8. ksadk/builders/code_builder.py +74 -21
  9. ksadk/builders/framework_requirements.py +22 -3
  10. ksadk/builders/ks3_uploader.py +36 -7
  11. ksadk/builders/managed_runtime_builder.py +1 -0
  12. ksadk/cli/__init__.py +68 -3
  13. ksadk/cli/cmd_config.py +4 -4
  14. ksadk/cli/cmd_create.py +12 -12
  15. ksadk/cli/cmd_hermes.py +24 -2
  16. ksadk/cli/cmd_invoke.py +28 -5
  17. ksadk/cli/cmd_managed_runtime.py +13 -1
  18. ksadk/cli/cmd_openclaw.py +26 -1
  19. ksadk/cli/cmd_plugin.py +76 -13
  20. ksadk/cli/cmd_studio.py +64 -16
  21. ksadk/cli/cmd_web.py +2 -5
  22. ksadk/cli/openclaw_env.py +1 -1
  23. ksadk/cli/resource_common.py +26 -0
  24. ksadk/cli/runtime_bootstrap.py +23 -1
  25. ksadk/codex/client.py +425 -96
  26. ksadk/codex/projection.py +24 -0
  27. ksadk/codex/runtime.py +56 -298
  28. ksadk/common/auth.py +16 -10
  29. ksadk/configs/__init__.py +1 -1
  30. ksadk/configs/env_registry.py +153 -31
  31. ksadk/configs/env_registry_studio.py +86 -0
  32. ksadk/configs/global_config.py +1 -1
  33. ksadk/configs/settings.py +3 -3
  34. ksadk/connector/__init__.py +17 -0
  35. ksadk/connector/channel.py +477 -0
  36. ksadk/context_engine/capabilities.py +52 -4
  37. ksadk/conversations/attachment_storage.py +10 -3
  38. ksadk/conversations/attachments.py +16 -5
  39. ksadk/conversations/message_projection.py +133 -21
  40. ksadk/conversations/normalize.py +28 -10
  41. ksadk/conversations/projector.py +4 -6
  42. ksadk/conversations/runtime_baseline.py +37 -0
  43. ksadk/conversations/runtime_invocation.py +22 -4
  44. ksadk/conversations/runtime_observability.py +39 -10
  45. ksadk/conversations/runtime_payloads.py +9 -0
  46. ksadk/conversations/runtime_persistence.py +105 -9
  47. ksadk/conversations/runtime_preparation.py +42 -33
  48. ksadk/conversations/runtime_resume.py +50 -2
  49. ksadk/conversations/runtime_stream_events.py +34 -35
  50. ksadk/conversations/runtime_streaming.py +33 -7
  51. ksadk/deployment/env_forward.py +2 -2
  52. ksadk/deployment/providers/serverless.py +1 -1
  53. ksadk/events/adapters/_codex_items.py +16 -8
  54. ksadk/events/adapters/_codex_validators.py +18 -7
  55. ksadk/events/adapters/_langgraph_support.py +34 -0
  56. ksadk/events/adapters/langgraph.py +15 -1
  57. ksadk/events/canonical_store.py +3 -1
  58. ksadk/events/projections.py +1 -1
  59. ksadk/events/session_event.py +2 -2
  60. ksadk/harness/__init__.py +14 -0
  61. ksadk/harness/app.py +11 -0
  62. ksadk/harness/artifact_store.py +213 -0
  63. ksadk/harness/capabilities.py +115 -0
  64. ksadk/harness/capability_runtime.py +237 -0
  65. ksadk/harness/closure_contract.py +92 -0
  66. ksadk/harness/compaction_record.py +122 -0
  67. ksadk/harness/compiler.py +284 -0
  68. ksadk/harness/config.py +2 -2
  69. ksadk/harness/conformance/__init__.py +33 -0
  70. ksadk/harness/conformance/contract.py +506 -0
  71. ksadk/harness/conformance/fixtures.py +102 -0
  72. ksadk/harness/context_engine.py +403 -0
  73. ksadk/harness/context_maintenance.py +259 -0
  74. ksadk/harness/context_manifest.py +188 -0
  75. ksadk/harness/context_tuning.py +168 -0
  76. ksadk/harness/draft_runtime.py +322 -0
  77. ksadk/harness/engine/__init__.py +40 -0
  78. ksadk/harness/engine/base.py +122 -0
  79. ksadk/harness/engine/budgets.py +108 -0
  80. ksadk/harness/engine/capability_declarations.py +59 -0
  81. ksadk/harness/engine/completion_guard.py +42 -0
  82. ksadk/harness/engine/context_pipeline.py +579 -0
  83. ksadk/harness/engine/graph_builder.py +859 -0
  84. ksadk/harness/engine/langgraph.py +931 -0
  85. ksadk/harness/engine/mcp_disclosure.py +750 -0
  86. ksadk/harness/engine/policy_runtime.py +70 -0
  87. ksadk/harness/engine/postgres_checkpointer.py +63 -0
  88. ksadk/harness/engine/run_control_bridge.py +80 -0
  89. ksadk/harness/engine/run_types.py +88 -0
  90. ksadk/harness/engine/skill_disclosure.py +189 -0
  91. ksadk/harness/engine/spans.py +41 -0
  92. ksadk/harness/engine/subagents.py +343 -0
  93. ksadk/harness/engine/thread_ids.py +112 -0
  94. ksadk/harness/engine/tool_dispatch.py +144 -0
  95. ksadk/harness/event_tree.py +212 -0
  96. ksadk/harness/events.py +461 -0
  97. ksadk/harness/execution_policy.py +94 -0
  98. ksadk/harness/insights.py +210 -0
  99. ksadk/harness/lifecycle.py +578 -0
  100. ksadk/harness/lifecycle_conformance.py +233 -0
  101. ksadk/harness/lifecycle_local_plane.py +104 -0
  102. ksadk/harness/loop/__init__.py +44 -0
  103. ksadk/harness/loop/reason.py +454 -0
  104. ksadk/harness/loop/tools.py +762 -0
  105. ksadk/harness/managed_runtime.py +884 -0
  106. ksadk/harness/mcp_matrix.py +474 -0
  107. ksadk/harness/mcp_runtime.py +471 -0
  108. ksadk/harness/memory_consolidation.py +157 -0
  109. ksadk/harness/memory_loop.py +156 -0
  110. ksadk/harness/memory_runtime.py +541 -0
  111. ksadk/harness/metrics.py +90 -0
  112. ksadk/harness/model_capability.py +253 -0
  113. ksadk/harness/model_provider.py +220 -0
  114. ksadk/harness/observability/__init__.py +29 -0
  115. ksadk/harness/observability/inspection.py +528 -0
  116. ksadk/harness/observability/metrics.py +167 -0
  117. ksadk/harness/observability/otel_exporter.py +218 -0
  118. ksadk/harness/prompt_cache.py +70 -0
  119. ksadk/harness/public_activity.py +154 -0
  120. ksadk/harness/readiness.py +249 -0
  121. ksadk/harness/reasoner.py +466 -13
  122. ksadk/harness/release_readiness.py +140 -0
  123. ksadk/harness/resource_ref.py +69 -0
  124. ksadk/harness/run_control.py +668 -0
  125. ksadk/harness/runtime.py +171 -136
  126. ksadk/harness/runtime_capabilities.py +158 -0
  127. ksadk/harness/runtime_server.py +514 -0
  128. ksadk/harness/sandbox_adapters.py +739 -0
  129. ksadk/harness/sandbox_backend.py +530 -0
  130. ksadk/harness/sandbox_conformance.py +288 -0
  131. ksadk/harness/sandbox_lease.py +77 -0
  132. ksadk/harness/sandbox_lease_conformance.py +259 -0
  133. ksadk/harness/sandbox_matrix.py +170 -0
  134. ksadk/harness/sandbox_reconciliation.py +140 -0
  135. ksadk/harness/sandbox_recovery.py +586 -0
  136. ksadk/harness/sandbox_recovery_conformance.py +246 -0
  137. ksadk/harness/session_store.py +243 -0
  138. ksadk/harness/skill_composition.py +212 -0
  139. ksadk/harness/skill_feedback.py +123 -0
  140. ksadk/harness/skill_matrix.py +233 -0
  141. ksadk/harness/skill_runtime.py +259 -0
  142. ksadk/harness/spec.py +332 -0
  143. ksadk/harness/state.py +153 -0
  144. ksadk/harness/strategies.py +149 -0
  145. ksadk/harness/subagent.py +253 -0
  146. ksadk/harness/tool_policy.py +131 -0
  147. ksadk/harness/tool_receipts.py +96 -0
  148. ksadk/harness/tool_reliability.py +81 -0
  149. ksadk/harness/tools.py +38 -13
  150. ksadk/harness/user_errors.py +69 -0
  151. ksadk/harness/working_context.py +81 -0
  152. ksadk/harness/working_context_patch.py +99 -0
  153. ksadk/identity/resolver.py +18 -0
  154. ksadk/interaction/__init__.py +1 -1
  155. ksadk/interaction/ledger.py +1 -1
  156. ksadk/interaction/provider.py +2 -1
  157. ksadk/interaction/providers/__init__.py +3 -1
  158. ksadk/interaction/providers/adk.py +1 -1
  159. ksadk/interaction/providers/codex.py +1 -1
  160. ksadk/interaction/providers/harness.py +50 -0
  161. ksadk/interaction/providers/langgraph.py +2 -1
  162. ksadk/kernel/__init__.py +10 -0
  163. ksadk/kernel/approval_presentation.py +91 -0
  164. ksadk/kernel/authorization.py +1 -1
  165. ksadk/kernel/bootstrap.py +114 -106
  166. ksadk/kernel/contract_fingerprints.py +1 -1
  167. ksadk/kernel/contracts.py +5 -0
  168. ksadk/kernel/control.py +32 -1
  169. ksadk/kernel/execution_grants.py +221 -0
  170. ksadk/kernel/execution_grants_memory.py +133 -0
  171. ksadk/kernel/execution_grants_postgres.py +217 -0
  172. ksadk/kernel/execution_grants_sqlite.py +209 -0
  173. ksadk/kernel/ingress.py +42 -29
  174. ksadk/kernel/mapping.py +1 -1
  175. ksadk/kernel/memory_store.py +24 -11
  176. ksadk/kernel/postgres_store.py +63 -33
  177. ksadk/kernel/recovery.py +78 -14
  178. ksadk/kernel/sql/001_agent_kernel.sql +23 -0
  179. ksadk/kernel/sqlite_store.py +331 -25
  180. ksadk/kernel/state.py +2 -3
  181. ksadk/kernel/store.py +72 -2
  182. ksadk/kernel/worker.py +144 -51
  183. ksadk/kernel/worker_history.py +72 -0
  184. ksadk/kernel/worker_identity.py +47 -0
  185. ksadk/knowledge_base/client.py +57 -27
  186. ksadk/mcp_runtime/__init__.py +12 -4
  187. ksadk/memory/adk/backends/sdk_ltm_backend.py +161 -41
  188. ksadk/memory/adk/resilient_session_service.py +25 -17
  189. ksadk/memory/adk/short_term_memory.py +26 -9
  190. ksadk/memory/coordinator.py +22 -6
  191. ksadk/memory/extraction.py +40 -1
  192. ksadk/memory/models.py +84 -5
  193. ksadk/memory/provider_resolver.py +8 -0
  194. ksadk/memory/providers/local_postgres.py +200 -0
  195. ksadk/memory/providers/local_sqlite.py +42 -3
  196. ksadk/memory/retrieval.py +189 -0
  197. ksadk/memory/store_adapter.py +150 -0
  198. ksadk/model_policy.py +2 -2
  199. ksadk/model_proxy/detect.py +254 -0
  200. ksadk/model_proxy/server.py +14 -7
  201. ksadk/model_proxy/transform.py +40 -2
  202. ksadk/plugins/__init__.py +5 -1
  203. ksadk/plugins/artifacts.py +275 -0
  204. ksadk/plugins/bridges/__init__.py +4 -2
  205. ksadk/plugins/bridges/codex.py +120 -13
  206. ksadk/plugins/bridges/dsh.py +351 -156
  207. ksadk/plugins/builtins.py +72 -35
  208. ksadk/plugins/bundle_security.py +28 -4
  209. ksadk/plugins/codex_manifest.py +983 -0
  210. ksadk/plugins/companion_artifacts.py +83 -0
  211. ksadk/plugins/companions.py +368 -0
  212. ksadk/plugins/composition.py +8 -0
  213. ksadk/plugins/contracts.py +119 -1
  214. ksadk/plugins/delivery.py +153 -0
  215. ksadk/plugins/dsh_channels.py +156 -0
  216. ksadk/plugins/dsh_home.py +140 -0
  217. ksadk/plugins/dsh_installation_digest.py +71 -0
  218. ksadk/plugins/dsh_teams.py +105 -0
  219. ksadk/plugins/dsh_toolchain.py +203 -32
  220. ksadk/plugins/ecosystem_probe.py +6 -6
  221. ksadk/plugins/execution_host.py +99 -0
  222. ksadk/plugins/host.py +102 -39
  223. ksadk/plugins/kernel_adapter.py +205 -0
  224. ksadk/plugins/providers/__init__.py +23 -0
  225. ksadk/plugins/providers/bundles/dsh-channels-client/client.js +19 -0
  226. ksadk/plugins/providers/bundles/dsh-channels-client/cordis.patch.yml +3 -0
  227. ksadk/plugins/providers/bundles/dsh-channels-client/index.mjs +7 -0
  228. ksadk/plugins/providers/bundles/dsh-channels-client/package.json +12 -0
  229. ksadk/plugins/providers/bundles/dsh-knowledge/cordis.patch.yml +3 -0
  230. ksadk/plugins/providers/bundles/dsh-knowledge/index.mjs +53 -0
  231. ksadk/plugins/providers/bundles/dsh-knowledge/package.json +16 -0
  232. ksadk/plugins/providers/bundles/dsh-memory/cordis.patch.yml +3 -0
  233. ksadk/plugins/providers/bundles/dsh-memory/index.mjs +175 -0
  234. ksadk/plugins/providers/bundles/dsh-memory/package.json +16 -0
  235. ksadk/plugins/providers/bundles/dsh-platform-resources/client.mjs +166 -0
  236. ksadk/plugins/providers/bundles/dsh-platform-resources/cordis.patch.yml +3 -0
  237. ksadk/plugins/providers/bundles/dsh-platform-resources/index.mjs +9 -0
  238. ksadk/plugins/providers/bundles/dsh-platform-resources/package.json +12 -0
  239. ksadk/plugins/providers/bundles/dsh-skill-center/cordis.patch.yml +3 -0
  240. ksadk/plugins/providers/bundles/dsh-skill-center/index.mjs +125 -0
  241. ksadk/plugins/providers/bundles/dsh-skill-center/package.json +16 -0
  242. ksadk/plugins/providers/bundles/dsh-teams-client/client.js +29 -0
  243. ksadk/plugins/providers/bundles/dsh-teams-client/cordis.patch.yml +3 -0
  244. ksadk/plugins/providers/bundles/dsh-teams-client/index.mjs +11 -0
  245. ksadk/plugins/providers/bundles/dsh-teams-client/package.json +35 -0
  246. ksadk/plugins/providers/bundles/dsh-teams-leader-policy/cordis.patch.yml +3 -0
  247. ksadk/plugins/providers/bundles/dsh-teams-leader-policy/index.mjs +13 -0
  248. ksadk/plugins/providers/bundles/dsh-teams-leader-policy/package.json +27 -0
  249. ksadk/plugins/providers/bundles/dsh-teams-profile/cordis.patch.yml +3 -0
  250. ksadk/plugins/providers/bundles/dsh-teams-profile/index.mjs +12 -0
  251. ksadk/plugins/providers/bundles/dsh-teams-profile/package.json +26 -0
  252. ksadk/plugins/providers/bundles/dsh-teams-router/cordis.patch.yml +3 -0
  253. ksadk/plugins/providers/bundles/dsh-teams-router/index.mjs +16 -0
  254. ksadk/plugins/providers/bundles/dsh-teams-router/package.json +27 -0
  255. ksadk/plugins/providers/bundles/dsh-teams-tasks/cordis.patch.yml +3 -0
  256. ksadk/plugins/providers/bundles/dsh-teams-tasks/index.mjs +16 -0
  257. ksadk/plugins/providers/bundles/dsh-teams-tasks/package.json +27 -0
  258. ksadk/plugins/providers/bundles/dsh-teams-tools/cordis.patch.yml +3 -0
  259. ksadk/plugins/providers/bundles/dsh-teams-tools/index.mjs +25 -0
  260. ksadk/plugins/providers/bundles/dsh-teams-tools/package.json +29 -0
  261. ksadk/plugins/providers/bundles/dsh-teams-tools/tools.json +235 -0
  262. ksadk/plugins/providers/bundles/ksadk-codex/index.mjs +1 -1
  263. ksadk/plugins/providers/bundles/ksadk-dsh-capability-host/cordis.patch.yml +3 -0
  264. ksadk/plugins/providers/bundles/ksadk-dsh-capability-host/index.mjs +920 -0
  265. ksadk/plugins/providers/bundles/ksadk-dsh-capability-host/package.json +27 -0
  266. ksadk/plugins/providers/bundles/ksadk-dsh-companion-host/client.mjs +133 -0
  267. ksadk/plugins/providers/bundles/ksadk-dsh-companion-host/index.mjs +14 -0
  268. ksadk/plugins/providers/bundles/ksadk-dsh-studio/client.js +115 -0
  269. ksadk/plugins/providers/bundles/ksadk-dsh-studio/index.mjs +19 -0
  270. ksadk/plugins/providers/bundles/ksadk-dsh-studio/package.json +7 -0
  271. ksadk/plugins/providers/bundles/ksadk-harness/index.mjs +1 -1
  272. ksadk/plugins/providers/codex.py +344 -70
  273. ksadk/plugins/providers/codex_native.py +368 -0
  274. ksadk/plugins/providers/codex_turn.py +301 -0
  275. ksadk/plugins/providers/dsh_capabilities.py +1450 -0
  276. ksadk/plugins/providers/dsh_mcp.py +467 -0
  277. ksadk/plugins/providers/harness.py +294 -141
  278. ksadk/plugins/providers/harness_delegation.py +593 -0
  279. ksadk/plugins/providers/harness_managed.py +456 -0
  280. ksadk/plugins/providers/harness_tools.py +326 -0
  281. ksadk/plugins/providers/mcp_projection.py +150 -0
  282. ksadk/plugins/providers/platform_resources.py +657 -0
  283. ksadk/plugins/providers/shipped_dsh.py +4 -1
  284. ksadk/plugins/resolver.py +8 -1
  285. ksadk/plugins/subagent_providers/codex.py +28 -6
  286. ksadk/plugins/teams/__init__.py +5 -0
  287. ksadk/plugins/teams/api.py +405 -0
  288. ksadk/plugins/teams/application.py +680 -0
  289. ksadk/plugins/teams/artifacts.py +60 -0
  290. ksadk/plugins/teams/context.py +96 -0
  291. ksadk/plugins/teams/contracts.py +136 -0
  292. ksadk/plugins/teams/domain.py +1427 -0
  293. ksadk/plugins/teams/domain_values.py +24 -0
  294. ksadk/plugins/teams/errors.py +13 -0
  295. ksadk/plugins/teams/migration.py +311 -0
  296. ksadk/plugins/teams/migration_cli.py +322 -0
  297. ksadk/plugins/teams/postgres_store.py +138 -0
  298. ksadk/plugins/teams/runtime.py +777 -0
  299. ksadk/plugins/teams/source_projection.py +84 -0
  300. ksadk/plugins/teams/store.py +311 -0
  301. ksadk/plugins/teams/task_decisions.py +423 -0
  302. ksadk/plugins/teams/transport.py +91 -0
  303. ksadk/plugins/teams/workspaces.py +255 -0
  304. ksadk/resource_runtime/__init__.py +4 -0
  305. ksadk/resource_runtime/broker.py +616 -0
  306. ksadk/resource_runtime/build_artifacts.py +165 -0
  307. ksadk/resource_runtime/contracts.py +138 -0
  308. ksadk/resource_runtime/discovery_receipts.py +100 -0
  309. ksadk/resource_runtime/discovery_skills.py +172 -0
  310. ksadk/resource_runtime/errors.py +6 -0
  311. ksadk/resource_runtime/ipc.py +142 -0
  312. ksadk/resource_runtime/kernel_approval.py +165 -0
  313. ksadk/resource_runtime/knowledge.py +114 -0
  314. ksadk/resource_runtime/langgraph.py +94 -0
  315. ksadk/resource_runtime/leases.py +191 -0
  316. ksadk/resource_runtime/managed_projection.py +186 -0
  317. ksadk/resource_runtime/mcp_server.py +138 -0
  318. ksadk/resource_runtime/memory_provider.py +318 -0
  319. ksadk/resource_runtime/memory_receipts.py +34 -0
  320. ksadk/resource_runtime/operation_ledger.py +211 -0
  321. ksadk/resource_runtime/plugin_config.py +48 -0
  322. ksadk/resource_runtime/policy_authorization.py +54 -0
  323. ksadk/resource_runtime/process.py +110 -0
  324. ksadk/resource_runtime/skill_artifacts.py +153 -0
  325. ksadk/resource_runtime/skill_runtime.py +42 -0
  326. ksadk/resource_runtime/skill_workspace.py +118 -0
  327. ksadk/resource_runtime/skills.py +215 -0
  328. ksadk/resource_runtime/snapshots.py +180 -0
  329. ksadk/resource_runtime/socket_server.py +103 -0
  330. ksadk/resource_runtime/supervisor.py +380 -0
  331. ksadk/resource_runtime/worker.py +504 -0
  332. ksadk/runners/_langgraph_runner_streams.py +182 -38
  333. ksadk/runners/_langgraph_state_reader.py +106 -0
  334. ksadk/runners/_session_identity.py +285 -0
  335. ksadk/runners/adk_runner.py +166 -63
  336. ksadk/runners/base_runner.py +29 -1
  337. ksadk/runners/langgraph_runner.py +542 -195
  338. ksadk/runners/patch_langchain.py +47 -0
  339. ksadk/runners/usage_accumulator.py +11 -3
  340. ksadk/runtime/_runner_adapter/stream_mapping.py +194 -20
  341. ksadk/runtime/adapter.py +2 -0
  342. ksadk/runtime/conversation_execution.py +117 -17
  343. ksadk/runtime/executor.py +87 -3
  344. ksadk/runtime/factory.py +65 -274
  345. ksadk/runtime/framework_adapters.py +23 -0
  346. ksadk/runtime/preprocessing.py +21 -5
  347. ksadk/runtime/runner_adapter.py +106 -18
  348. ksadk/runtime/skill_eval_result.py +36 -0
  349. ksadk/runtime/timing.py +46 -0
  350. ksadk/runtime/usage.py +49 -18
  351. ksadk/runtime_context.py +142 -2
  352. ksadk/sandbox/backends/e2b.py +288 -25
  353. ksadk/sandbox/backends/local_process.py +72 -39
  354. ksadk/sandbox/base.py +64 -1
  355. ksadk/sandbox/diagnostics.py +82 -0
  356. ksadk/sandbox/e2b_connection.py +66 -0
  357. ksadk/sandbox/local_controls.py +746 -0
  358. ksadk/sandbox/local_launcher.py +90 -0
  359. ksadk/scheduler/dispatcher.py +1 -1
  360. ksadk/scheduler/sqlite_store.py +18 -0
  361. ksadk/server/composition.py +2 -0
  362. ksadk/server/factory.py +5 -0
  363. ksadk/server/invocation_identity.py +118 -0
  364. ksadk/server/persistence_capability.py +516 -0
  365. ksadk/server/routes/common.py +32 -3
  366. ksadk/server/routes/control.py +271 -52
  367. ksadk/server/routes/dependencies.py +16 -0
  368. ksadk/server/routes/kernel_ingress.py +9 -1
  369. ksadk/server/routes/misc.py +233 -25
  370. ksadk/server/routes/models.py +47 -4
  371. ksadk/server/routes/openai_compat.py +76 -13
  372. ksadk/server/routes/projection.py +252 -12
  373. ksadk/server/routes/run.py +106 -35
  374. ksadk/server/routes/sessions.py +491 -138
  375. ksadk/server/routes/streaming.py +43 -9
  376. ksadk/server/routes/workspace.py +130 -21
  377. ksadk/server/static/assets/{ArtifactsPanel-10GPXIJ6.js → ArtifactsPanel-C1YoaKhx.js} +1 -1
  378. ksadk/server/static/assets/{CodeBlock-BXk1l-G1.js → CodeBlock-DHuAWfr5.js} +10 -7
  379. ksadk/server/static/assets/MathMessageMarkdown-cvdrBwYr.js +8 -0
  380. ksadk/server/static/assets/{MermaidBlock--OEYoXIJ.js → MermaidBlock-DeBkbJvI.js} +9 -9
  381. ksadk/server/static/assets/{NativeTerminalPanel-DrEe1syq.js → NativeTerminalPanel-oJj44_sV.js} +1 -1
  382. ksadk/server/static/assets/{abnfDiagram-VCTEODGH-eeTFJLvo.js → abnfDiagram-VCTEODGH-Dhfv25o2.js} +1 -1
  383. ksadk/server/static/assets/{arc-S3ZNbIAd.js → arc-C35w-pn1.js} +1 -1
  384. ksadk/server/static/assets/architecture-7GRP2DOG-BCsa26zi.js +1 -0
  385. ksadk/server/static/assets/{architectureDiagram-5GKGNRK7-CRjgEJDX.js → architectureDiagram-5GKGNRK7-FoMY_u6D.js} +1 -1
  386. ksadk/server/static/assets/{blockDiagram-NRAW4CY4-C7bsBoNH.js → blockDiagram-NRAW4CY4-zD4Rt7oE.js} +1 -1
  387. ksadk/server/static/assets/{c4Diagram-UCG6FXSJ-BX3c33Ob.js → c4Diagram-UCG6FXSJ-BCtGGkhN.js} +1 -1
  388. ksadk/server/static/assets/channel-_KDifNys.js +1 -0
  389. ksadk/server/static/assets/chunk-2Q5K7J3B-HdVkJ9F0.js +1 -0
  390. ksadk/server/static/assets/{chunk-5VM5RSS4-bZ7ws-8m.js → chunk-5VM5RSS4-C2Ms13_k.js} +1 -1
  391. ksadk/server/static/assets/{chunk-F27PBJKO-D2r0pvhY.js → chunk-F27PBJKO-BoTj-qgx.js} +1 -1
  392. ksadk/server/static/assets/{chunk-G27WJ6UU-CZwF3oUP.js → chunk-G27WJ6UU-DOMyyjHH.js} +1 -1
  393. ksadk/server/static/assets/{chunk-JWPE2WC7-DigFYCML.js → chunk-JWPE2WC7-DbJJqDli.js} +1 -1
  394. ksadk/server/static/assets/{chunk-LCL6LL3I-CnorGV5q.js → chunk-LCL6LL3I-CLuRCt_W.js} +1 -1
  395. ksadk/server/static/assets/{chunk-POPQ4Y6H-CexntQA-.js → chunk-POPQ4Y6H-D0Dz847e.js} +1 -1
  396. ksadk/server/static/assets/{chunk-RHFEMEQ7-CHTC7UxA.js → chunk-RHFEMEQ7-BWSRzEcd.js} +1 -1
  397. ksadk/server/static/assets/{chunk-SVP7TREG-BC1EWt_-.js → chunk-SVP7TREG-CPoHqkCY.js} +1 -1
  398. ksadk/server/static/assets/{chunk-XXDRQBXY-BTG24xN0.js → chunk-XXDRQBXY-Bx1jS-X-.js} +1 -1
  399. ksadk/server/static/assets/classDiagram-DTDB5LWJ-BVCW3ZqZ.js +1 -0
  400. ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-BVCW3ZqZ.js +1 -0
  401. ksadk/server/static/assets/{cose-bilkent-JH36ORCC-CkonRdAS.js → cose-bilkent-JH36ORCC-LzyWm4m0.js} +1 -1
  402. ksadk/server/static/assets/cynefin-OW5HDTMX-CNXjFctL.js +1 -0
  403. ksadk/server/static/assets/{cynefinDiagram-5FMLGOSQ-DEOCBe15.js → cynefinDiagram-5FMLGOSQ-BlW_bHED.js} +1 -1
  404. ksadk/server/static/assets/{dagre-3AP2YEHR-DBThPuLa.js → dagre-3AP2YEHR-Bu_S86_i.js} +1 -1
  405. ksadk/server/static/assets/{dagre-ClTPrTht.js → dagre-B7nCawed.js} +1 -1
  406. ksadk/server/static/assets/{diagram-S7CK7UJ4-DsZHrnpJ.js → diagram-S7CK7UJ4-W_Zow2Km.js} +1 -1
  407. ksadk/server/static/assets/{diagram-UQ7AKVKN-BJR4nhVr.js → diagram-UQ7AKVKN-CLIKAHON.js} +1 -1
  408. ksadk/server/static/assets/{diagram-VSXAHHWV-xzcERX0a.js → diagram-VSXAHHWV-Dv6_QAlN.js} +1 -1
  409. ksadk/server/static/assets/{diagram-VX7I27RA-tn2xM1xu.js → diagram-VX7I27RA-BWAWRDtZ.js} +1 -1
  410. ksadk/server/static/assets/{diagram-Z3DM3KII-BZPGBkw5.js → diagram-Z3DM3KII-XA_rWMss.js} +1 -1
  411. ksadk/server/static/assets/dist-0X_j2Rcc.js +1 -0
  412. ksadk/server/static/assets/{dist-4zN1_tq5.js → dist-1nXCdsej.js} +1 -1
  413. ksadk/server/static/assets/{dist-M67Hwu0n.js → dist-2vL2sAdF.js} +1 -1
  414. ksadk/server/static/assets/{dist-BJLUwH6W.js → dist-B3bA05-e.js} +1 -1
  415. ksadk/server/static/assets/{dist-8VWI-2bZ.js → dist-BLpRy_Yx.js} +1 -1
  416. ksadk/server/static/assets/{dist-D1V3f1B4.js → dist-BO_UwatH.js} +1 -1
  417. ksadk/server/static/assets/{dist-Cq4OL6nO.js → dist-BdNFAney.js} +1 -1
  418. ksadk/server/static/assets/{dist-DfGFrb0v.js → dist-C0J5_3qM.js} +1 -1
  419. ksadk/server/static/assets/{dist-DyqV4fL4.js → dist-CGt_UGeO.js} +1 -1
  420. ksadk/server/static/assets/{dist-DjhwGUgZ.js → dist-CIRMvUM4.js} +1 -1
  421. ksadk/server/static/assets/{dist-B1oWRmrH.js → dist-CIpWk_5f.js} +1 -1
  422. ksadk/server/static/assets/{dist-CXpH_Rdd.js → dist-CPyieXEf.js} +1 -1
  423. ksadk/server/static/assets/{dist-Btyo4vX4.js → dist-D-92S-Fd.js} +1 -1
  424. ksadk/server/static/assets/{dist-u8tVH5Ak.js → dist-DNKuMzWc.js} +1 -1
  425. ksadk/server/static/assets/{dist-DQAB0qn_.js → dist-DWfdmz9s.js} +2 -2
  426. ksadk/server/static/assets/{dist-B-46q3Hk.js → dist-DppE_r-D.js} +1 -1
  427. ksadk/server/static/assets/{dist-C71CsujO.js → dist-DyG6Ya-z.js} +1 -1
  428. ksadk/server/static/assets/{dist-DJmCPRVB.js → dist-M-SrdhhZ.js} +1 -1
  429. ksadk/server/static/assets/{dist-Bbwqa8TG.js → dist-mqD5TZup.js} +1 -1
  430. ksadk/server/static/assets/{dist-BI1qQH4n.js → dist-n3n6t_FO.js} +1 -1
  431. ksadk/server/static/assets/{dist-DUwKa_l6.js → dist-qe8xjesy.js} +1 -1
  432. ksadk/server/static/assets/{dist-B0gdk4rl.js → dist-t6MzE0jU.js} +1 -1
  433. ksadk/server/static/assets/{ebnfDiagram-PWID7BFC-DVfMsLge.js → ebnfDiagram-PWID7BFC-BfCzF1Xi.js} +1 -1
  434. ksadk/server/static/assets/{erDiagram-SSCWMZ5O-CWEZSYaw.js → erDiagram-SSCWMZ5O-Dpz9_0zn.js} +1 -1
  435. ksadk/server/static/assets/eventmodeling-NTZA5JFV-B5-8RH9c.js +1 -0
  436. ksadk/server/static/assets/flowDiagram-A5DVABFB-BppFxEKw.js +1 -0
  437. ksadk/server/static/assets/{ganttDiagram-EL5Y4UJY-TWIxoyYL.js → ganttDiagram-EL5Y4UJY-DDaG1f4_.js} +1 -1
  438. ksadk/server/static/assets/gitGraph-4MIJSDKK-B-AhYj4C.js +1 -0
  439. ksadk/server/static/assets/{gitGraphDiagram-WWUBYQGX-DDh2hd2S.js → gitGraphDiagram-WWUBYQGX-DcxzRwYC.js} +1 -1
  440. ksadk/server/static/assets/index-BMd2mucF.css +2 -0
  441. ksadk/server/static/assets/index-D5qyyhTH.js +244 -0
  442. ksadk/server/static/assets/info-A6RAGUB7-0uiKrC35.js +1 -0
  443. ksadk/server/static/assets/{infoDiagram-RXCK75RN-CgoyWiDR.js → infoDiagram-RXCK75RN-CYMdn6lQ.js} +1 -1
  444. ksadk/server/static/assets/{ishikawaDiagram-5VMMS53U-CyRIu_om.js → ishikawaDiagram-5VMMS53U-CLHFAD6c.js} +1 -1
  445. ksadk/server/static/assets/{journeyDiagram-EYS64GPL-DN5JXHzN.js → journeyDiagram-EYS64GPL-BHSKQGAl.js} +1 -1
  446. ksadk/server/static/assets/{kanban-definition-3QL26DDD-CNP3ui66.js → kanban-definition-3QL26DDD-D5W3tjTT.js} +1 -1
  447. ksadk/server/static/assets/{katex-DWEzQy1d.js → katex-mtjOi4KM.js} +1 -1
  448. ksadk/server/static/assets/{linear-C-qHp7d2.js → linear-BETqsxE_.js} +1 -1
  449. ksadk/server/static/assets/{mermaid-parser.core-Cl-K943T.js → mermaid-parser.core-DPWrvs90.js} +2 -2
  450. ksadk/server/static/assets/{mindmap-definition-FBJOCRG2-D5DB5mYm.js → mindmap-definition-FBJOCRG2-CJG2mfBP.js} +1 -1
  451. ksadk/server/static/assets/packet-AYTQ26CC-BVTmZ_cw.js +1 -0
  452. ksadk/server/static/assets/{pegDiagram-XKGWAZYB-BQVc9ia_.js → pegDiagram-XKGWAZYB-GjAPNaqn.js} +1 -1
  453. ksadk/server/static/assets/pie-WAS4IAKB-DyfxBU7V.js +1 -0
  454. ksadk/server/static/assets/{pieDiagram-E7YTZNPT-B6UCAvtY.js → pieDiagram-E7YTZNPT-ToIewrqr.js} +1 -1
  455. ksadk/server/static/assets/{quadrantDiagram-AXDQQJYC-mIr2d3eb.js → quadrantDiagram-AXDQQJYC-4d78KiEY.js} +1 -1
  456. ksadk/server/static/assets/radar-RG4KPBEZ-FFontjL2.js +1 -0
  457. ksadk/server/static/assets/railroad-74A4TZTK-D0Uidzen.js +1 -0
  458. ksadk/server/static/assets/railroad-abnf-HS5TGJTU-BOo_9T2h.js +1 -0
  459. ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-D6-BjW7Z.js +1 -0
  460. ksadk/server/static/assets/railroad-peg-WCYAUIDC-CXx__yMm.js +1 -0
  461. ksadk/server/static/assets/{railroadDiagram-O6MQD6OU-Dt3FFDmK.js → railroadDiagram-O6MQD6OU-DKzx4xfv.js} +1 -1
  462. ksadk/server/static/assets/{requirementDiagram-EFPCY7ZU-Cz_vQtgF.js → requirementDiagram-EFPCY7ZU-CJYljxQS.js} +1 -1
  463. ksadk/server/static/assets/{sankeyDiagram-P5KCCOFB-wlO1TsH5.js → sankeyDiagram-P5KCCOFB-DLU2fV1w.js} +1 -1
  464. ksadk/server/static/assets/{sequenceDiagram-WJ2MYXX4-CHRbElYq.js → sequenceDiagram-WJ2MYXX4-CVqysrA9.js} +1 -1
  465. ksadk/server/static/assets/{sizeCapture-X5ZJPWSS-DXX54iyO.js → sizeCapture-X5ZJPWSS-BUxfmTHc.js} +1 -1
  466. ksadk/server/static/assets/{stateDiagram-HBIQ2CUA-Dp_lw9II.js → stateDiagram-HBIQ2CUA-CNFgYI9E.js} +1 -1
  467. ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-BXAFScz8.js +1 -0
  468. ksadk/server/static/assets/{swimlanes-XN3QIQJK-D8O5UlLG.js → swimlanes-XN3QIQJK-B6qCMe8N.js} +1 -1
  469. ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-uIQ2lJKH.js +8 -0
  470. ksadk/server/static/assets/{timeline-definition-24CTP7MA-8mfKcxvG.js → timeline-definition-24CTP7MA-CMD3x_U_.js} +1 -1
  471. ksadk/server/static/assets/treeView-Q6P3EWNA-CK5GgucZ.js +1 -0
  472. ksadk/server/static/assets/treemap-WGGIJYW6-Bq1u1SpG.js +1 -0
  473. ksadk/server/static/assets/{vennDiagram-4TSXK5OY-EnNl0DE7.js → vennDiagram-4TSXK5OY-BqtUqvXM.js} +1 -1
  474. ksadk/server/static/assets/wardley-WFR3VGLG-QAt06uEz.js +1 -0
  475. ksadk/server/static/assets/{wardleyDiagram-VM6X3IG4-DBu5fbYr.js → wardleyDiagram-VM6X3IG4-B5KfDjI-.js} +1 -1
  476. ksadk/server/static/assets/{xychartDiagram-S5SC5T6Z-BSVXs4IY.js → xychartDiagram-S5SC5T6Z-BaUlSZrn.js} +1 -1
  477. ksadk/server/static/index.html +2 -2
  478. ksadk/server/terminal_sessions.py +34 -2
  479. ksadk/session_context.py +66 -0
  480. ksadk/sessions/__init__.py +11 -21
  481. ksadk/sessions/_local_service_sync.py +263 -1
  482. ksadk/sessions/base.py +176 -0
  483. ksadk/sessions/errors.py +4 -0
  484. ksadk/sessions/in_memory.py +309 -19
  485. ksadk/sessions/invocation_identity.py +235 -0
  486. ksadk/sessions/local_service.py +83 -1
  487. ksadk/sessions/persistence.py +275 -0
  488. ksadk/sessions/postgres_service.py +358 -0
  489. ksadk/sessions/resilience.py +8 -0
  490. ksadk/sessions/resilient.py +362 -4
  491. ksadk/sessions/topology.py +135 -0
  492. ksadk/skills/__init__.py +26 -0
  493. ksadk/skills/events.py +464 -0
  494. ksadk/skills/manifest_cache.py +263 -0
  495. ksadk/skills/mcp_server/__init__.py +0 -0
  496. ksadk/skills/mcp_server/_registry.py +33 -0
  497. ksadk/skills/mcp_server/_routing.py +26 -0
  498. ksadk/skills/mcp_server/_workspace_files.py +160 -0
  499. ksadk/skills/mcp_server/register.py +415 -0
  500. ksadk/skills/mcp_server/server.py +218 -0
  501. ksadk/skills/models.py +37 -4
  502. ksadk/skills/observability.py +132 -0
  503. ksadk/skills/package_store.py +261 -40
  504. ksadk/skills/runtime/agent.py +67 -9
  505. ksadk/skills/runtime/artifact_delivery.py +139 -0
  506. ksadk/skills/runtime/artifacts.py +87 -0
  507. ksadk/skills/runtime/backends/e2b.py +460 -27
  508. ksadk/skills/runtime/backends/local.py +629 -62
  509. ksadk/skills/runtime/base.py +81 -7
  510. ksadk/skills/runtime/executor.py +268 -1
  511. ksadk/skills/runtime/loader.py +118 -5
  512. ksadk/skills/runtime/pinned.py +114 -0
  513. ksadk/skills/runtime/request.py +49 -0
  514. ksadk/skills/service_client.py +167 -28
  515. ksadk/skills/tool_defs.py +108 -3
  516. ksadk/studio/api.py +810 -93
  517. ksadk/studio/api_catalog_routes.py +18 -0
  518. ksadk/studio/api_contracts.py +8 -2
  519. ksadk/studio/api_plugin_routes.py +562 -104
  520. ksadk/studio/api_resource_connections.py +221 -0
  521. ksadk/studio/authoring.py +12 -6
  522. ksadk/studio/authoring_coordinator.py +23 -16
  523. ksadk/studio/builder.py +88 -0
  524. ksadk/studio/capabilities.py +23 -6
  525. ksadk/studio/channel_connections.py +333 -0
  526. ksadk/studio/cloud.py +370 -112
  527. ksadk/studio/cloud_shared_web.py +638 -0
  528. ksadk/studio/codex_agent_service.py +130 -28
  529. ksadk/studio/codex_builder.py +242 -3
  530. ksadk/studio/codex_credentials.py +90 -0
  531. ksadk/studio/codex_manifest.py +31 -4
  532. ksadk/studio/codex_plugin_store.py +746 -0
  533. ksadk/studio/codex_provider_build.py +231 -0
  534. ksadk/studio/codex_run.py +190 -26
  535. ksadk/studio/compatibility_report.py +12 -1
  536. ksadk/studio/compiler.py +88 -14
  537. ksadk/studio/configuration.py +182 -0
  538. ksadk/studio/contracts.py +165 -11
  539. ksadk/studio/dsh_application.py +247 -0
  540. ksadk/studio/dsh_capability_service.py +1374 -0
  541. ksadk/studio/dsh_lifecycle.py +58 -0
  542. ksadk/studio/dsh_models.py +59 -0
  543. ksadk/studio/dsh_provider_registration.py +367 -21
  544. ksadk/studio/entry.py +53 -0
  545. ksadk/studio/event_store.py +36 -5
  546. ksadk/studio/execution_host.py +525 -0
  547. ksadk/studio/framework_run.py +32 -10
  548. ksadk/studio/hosted_kernel.py +89 -14
  549. ksadk/studio/kernel_registry.py +418 -0
  550. ksadk/studio/kernel_sqlite_migration.py +181 -0
  551. ksadk/studio/mcp_runtime.py +11 -3
  552. ksadk/studio/model_client.py +1180 -66
  553. ksadk/studio/model_profile_service.py +26 -11
  554. ksadk/studio/native_documents.py +172 -0
  555. ksadk/studio/plugin_composition.py +202 -24
  556. ksadk/studio/plugin_kernel_adapter.py +21 -106
  557. ksadk/studio/plugin_lifecycle.py +80 -0
  558. ksadk/studio/plugin_runtime.py +448 -56
  559. ksadk/studio/provider_recovery.py +59 -0
  560. ksadk/studio/recovery_page.py +70 -0
  561. ksadk/studio/resource_authority.py +664 -0
  562. ksadk/studio/resource_binding_validation.py +77 -0
  563. ksadk/studio/resource_build_admission.py +196 -0
  564. ksadk/studio/resource_build_materializer.py +149 -0
  565. ksadk/studio/resource_catalog.py +149 -2
  566. ksadk/studio/resource_connections.py +220 -0
  567. ksadk/studio/run_activity.py +895 -0
  568. ksadk/studio/run_documents.py +127 -0
  569. ksadk/studio/run_service.py +789 -83
  570. ksadk/studio/runtime_catalog.py +53 -10
  571. ksadk/studio/runtime_source.py +16 -8
  572. ksadk/studio/scheduler_assistant.py +317 -0
  573. ksadk/studio/scheduler_runtime.py +32 -280
  574. ksadk/studio/scheduler_service.py +3 -0
  575. ksadk/studio/service.py +861 -120
  576. ksadk/studio/shared_web.py +579 -82
  577. ksadk/studio/static/assets/ChannelsPage-D_PGmKVq.js +8 -0
  578. ksadk/studio/static/assets/CodeBlock-DMIf4h33-UIqo-BPW.js +44 -0
  579. ksadk/studio/static/assets/ExecutionTree-v3HexvPo-Bk8wzGSy.js +1 -0
  580. ksadk/studio/static/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  581. ksadk/studio/static/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  582. ksadk/studio/static/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  583. ksadk/studio/static/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  584. ksadk/studio/static/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  585. ksadk/studio/static/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  586. ksadk/studio/static/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  587. ksadk/studio/static/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  588. ksadk/studio/static/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  589. ksadk/studio/static/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  590. ksadk/studio/static/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  591. ksadk/studio/static/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  592. ksadk/studio/static/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  593. ksadk/studio/static/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  594. ksadk/studio/static/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  595. ksadk/studio/static/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  596. ksadk/studio/static/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  597. ksadk/studio/static/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  598. ksadk/studio/static/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  599. ksadk/studio/static/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  600. ksadk/studio/static/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  601. ksadk/studio/static/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  602. ksadk/studio/static/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  603. ksadk/studio/static/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  604. ksadk/studio/static/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  605. ksadk/studio/static/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  606. ksadk/studio/static/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  607. ksadk/studio/static/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  608. ksadk/studio/static/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  609. ksadk/studio/static/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  610. ksadk/studio/static/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  611. ksadk/studio/static/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  612. ksadk/studio/static/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  613. ksadk/studio/static/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  614. ksadk/studio/static/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  615. ksadk/studio/static/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  616. ksadk/studio/static/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  617. ksadk/studio/static/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  618. ksadk/studio/static/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  619. ksadk/studio/static/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  620. ksadk/studio/static/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  621. ksadk/studio/static/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  622. ksadk/studio/static/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  623. ksadk/studio/static/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  624. ksadk/studio/static/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  625. ksadk/studio/static/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  626. ksadk/studio/static/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  627. ksadk/studio/static/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  628. ksadk/studio/static/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  629. ksadk/studio/static/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  630. ksadk/studio/static/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  631. ksadk/studio/static/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  632. ksadk/studio/static/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  633. ksadk/studio/static/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  634. ksadk/studio/static/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  635. ksadk/studio/static/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  636. ksadk/studio/static/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  637. ksadk/studio/static/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  638. ksadk/studio/static/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  639. ksadk/studio/static/assets/MathMessageMarkdown-BesSeCYl-BEOyPC3w.css +1 -0
  640. ksadk/studio/static/assets/MathMessageMarkdown-BesSeCYl-OhNwH4K9.js +8 -0
  641. ksadk/studio/static/assets/MermaidBlock-H_0qzQDf-BdXtxug_.js +11 -0
  642. ksadk/studio/static/assets/MessageMarkdown-CwMTvgFj-g0I-I4dD.js +59 -0
  643. ksadk/studio/static/assets/PrismRenderer-5pK6tUdb.js +3 -0
  644. ksadk/studio/static/assets/TeamsPage-DqX4HWKQ.js +3 -0
  645. ksadk/studio/static/assets/abnfDiagram-VCTEODGH-Bnb1O3tA.js +1 -0
  646. ksadk/studio/static/assets/arc-Pry-7G1_.js +1 -0
  647. ksadk/studio/static/assets/architecture-7GRP2DOG-BMOPAkUC.js +1 -0
  648. ksadk/studio/static/assets/architectureDiagram-5GKGNRK7-5Zn1gqJv.js +36 -0
  649. ksadk/studio/static/assets/array-BifhSqXX.js +1 -0
  650. ksadk/studio/static/assets/blockDiagram-I7D4REHJ-CLB4L11u.js +129 -0
  651. ksadk/studio/static/assets/c4Diagram-7LVT6UL2-BOma_Z_F.js +38 -0
  652. ksadk/studio/static/assets/channel-r8itPEik.js +1 -0
  653. ksadk/studio/static/assets/chunk-2E4U76K2-BFf_huql.js +2 -0
  654. ksadk/studio/static/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
  655. ksadk/studio/static/assets/chunk-2ZTRR5NV-C2qZJila.js +2 -0
  656. ksadk/studio/static/assets/chunk-3Z5EZCMW-DMniOlPd.js +1 -0
  657. ksadk/studio/static/assets/chunk-4HAMMTFA-DVtDP4rm.js +62 -0
  658. ksadk/studio/static/assets/chunk-5V3GS4D5-i-ZDOEnP.js +1 -0
  659. ksadk/studio/static/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
  660. ksadk/studio/static/assets/chunk-6AZGARVD-BB6FqMl-.js +1 -0
  661. ksadk/studio/static/assets/chunk-6EIED4P4-DdUJkP0f.js +1 -0
  662. ksadk/studio/static/assets/chunk-6K3QC6MW-CqVsVn-y.js +1 -0
  663. ksadk/studio/static/assets/chunk-6TQVIW2G-DKlLbNIP.js +1 -0
  664. ksadk/studio/static/assets/chunk-747NJXEK-BFkZPlab.js +2 -0
  665. ksadk/studio/static/assets/chunk-75Z2AOVW-BZNhM4vB.js +2 -0
  666. ksadk/studio/static/assets/chunk-CLGD4ZFX-D-GTtyKs.js +1 -0
  667. ksadk/studio/static/assets/chunk-DU6HZSFF-CpEZCUgg.js +128 -0
  668. ksadk/studio/static/assets/chunk-F27PBJKO-D7pvKf0C.js +1 -0
  669. ksadk/studio/static/assets/chunk-FOHPRMQF-DHwB1DNv.js +161 -0
  670. ksadk/studio/static/assets/chunk-GMAD6QVW-DE_8H717.js +72 -0
  671. ksadk/studio/static/assets/chunk-GVQU2GXP-BfEB0lNv.js +1 -0
  672. ksadk/studio/static/assets/chunk-I5DQTOEV-Hm2LfiYI.js +1 -0
  673. ksadk/studio/static/assets/chunk-ICYGCRZG-749o-pGJ.js +1 -0
  674. ksadk/studio/static/assets/chunk-IH6LHLGP-CC6I9F3i.js +1 -0
  675. ksadk/studio/static/assets/chunk-IMKFNOWR-D38axYOR.js +231 -0
  676. ksadk/studio/static/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
  677. ksadk/studio/static/assets/chunk-KI3K4JFJ-Rma-0k_M.js +1 -0
  678. ksadk/studio/static/assets/chunk-L3NEJ4N5-Dq5xn7aL.js +1 -0
  679. ksadk/studio/static/assets/chunk-LNGE3PJU-DWpGwHrW.js +34 -0
  680. ksadk/studio/static/assets/chunk-OSK3NFVY-DiCQjx9b.js +10 -0
  681. ksadk/studio/static/assets/chunk-OUJLGHUK-D0j2JRSg.js +2 -0
  682. ksadk/studio/static/assets/chunk-P2QGCYS3-VdhKmfYq.js +1 -0
  683. ksadk/studio/static/assets/chunk-POPQ4Y6H-C1_rzO5M.js +1 -0
  684. ksadk/studio/static/assets/chunk-PWAF6VOD-B45HvflI.js +1 -0
  685. ksadk/studio/static/assets/chunk-SHT3W25Y-DsCFnRVE.js +168 -0
  686. ksadk/studio/static/assets/chunk-SVP7TREG-DljApgRX.js +88 -0
  687. ksadk/studio/static/assets/chunk-TICWLB2K-DWqRtyqa.js +206 -0
  688. ksadk/studio/static/assets/chunk-TLUHSLCS-DUeGgnD5.js +2 -0
  689. ksadk/studio/static/assets/chunk-UY3FDG6J-CnmaAkG5.js +1 -0
  690. ksadk/studio/static/assets/chunk-XHIXRSVI-BFQ6B8BE.js +1 -0
  691. ksadk/studio/static/assets/chunk-XXDRQBXY-DqAYeljN.js +1 -0
  692. ksadk/studio/static/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
  693. ksadk/studio/static/assets/classDiagram-ZZMXUADV-DjeMNJmu.js +1 -0
  694. ksadk/studio/static/assets/classDiagram-v2-VYDZK3BY-DjeMNJmu.js +1 -0
  695. ksadk/studio/static/assets/clsx-DB0hHKMi.js +1 -0
  696. ksadk/studio/static/assets/cose-bilkent-JH36ORCC-om8AY0Mc.js +1 -0
  697. ksadk/studio/static/assets/createLucideIcon-DR0LGTP5.js +1 -0
  698. ksadk/studio/static/assets/cynefin-OW5HDTMX-7tP7QfM3.js +1 -0
  699. ksadk/studio/static/assets/cynefinDiagram-5FMLGOSQ-6BrmK52S.js +62 -0
  700. ksadk/studio/static/assets/cytoscape.esm-CGd-uY3x.js +321 -0
  701. ksadk/studio/static/assets/dagre-GXQ25YYZ-buZBRlwz.js +4 -0
  702. ksadk/studio/static/assets/dagre-PrKaheQc.js +1 -0
  703. ksadk/studio/static/assets/defaultLocale-BFoDCU3G.js +1 -0
  704. ksadk/studio/static/assets/diagram-S7CK7UJ4-C6aH78c4.js +30 -0
  705. ksadk/studio/static/assets/diagram-UQ7AKVKN-DY_tQ6C_.js +41 -0
  706. ksadk/studio/static/assets/diagram-VSXAHHWV-DX9p5cQT.js +3 -0
  707. ksadk/studio/static/assets/diagram-VX7I27RA-DB2WSH8X.js +24 -0
  708. ksadk/studio/static/assets/diagram-Z3DM3KII-Ce1BJwHE.js +24 -0
  709. ksadk/studio/static/assets/dist-v5Q1xZ2K.js +1 -0
  710. ksadk/studio/static/assets/ebnfDiagram-PWID7BFC-Daukxwqf.js +1 -0
  711. ksadk/studio/static/assets/erDiagram-RLTQ6QDP-CGthTMmJ.js +99 -0
  712. ksadk/studio/static/assets/eventmodeling-NTZA5JFV-BR2FzK4R.js +1 -0
  713. ksadk/studio/static/assets/flowDiagram-HODETNUW-CZ1tEenp.js +1 -0
  714. ksadk/studio/static/assets/ganttDiagram-EL5Y4UJY-BfoAZW9X.js +292 -0
  715. ksadk/studio/static/assets/gitGraph-4MIJSDKK-DYlXv_yJ.js +1 -0
  716. ksadk/studio/static/assets/gitGraphDiagram-WWUBYQGX-S985OIJF.js +106 -0
  717. ksadk/studio/static/assets/graphlib-DS17s2tU.js +1 -0
  718. ksadk/studio/static/assets/iconfont-4HN3C9Pg.woff2 +0 -0
  719. ksadk/studio/static/assets/index-CfEnms6Y.css +2 -0
  720. ksadk/studio/static/assets/index-Dp61rOWZ.js +0 -0
  721. ksadk/studio/static/assets/index.dom-BQenBtFm.js +1 -0
  722. ksadk/studio/static/assets/info-A6RAGUB7-BlU-8_xu.js +1 -0
  723. ksadk/studio/static/assets/infoDiagram-27XIBGKW-CO3W8tFn.js +2 -0
  724. ksadk/studio/static/assets/init-C-OQMol4.js +1 -0
  725. ksadk/studio/static/assets/ishikawaDiagram-5VMMS53U-BUGEl8cO.js +70 -0
  726. ksadk/studio/static/assets/journeyDiagram-3NMN7TZE-Ch2ZYxvr.js +139 -0
  727. ksadk/studio/static/assets/kanban-definition-UXKFOSKX-Da-Fp4vC.js +89 -0
  728. ksadk/studio/static/assets/katex-DhON-x74.js +257 -0
  729. ksadk/studio/static/assets/kingsoft-cloud-BOcLiQ3e.ico +0 -0
  730. ksadk/studio/static/assets/line-BDaeq300.js +1 -0
  731. ksadk/studio/static/assets/linear-DmucvK78.js +1 -0
  732. ksadk/studio/static/assets/mermaid-parser.core-Cj5mYdBi.js +4 -0
  733. ksadk/studio/static/assets/mindmap-definition-YA3MSWOX-CvlsVQ38.js +96 -0
  734. ksadk/studio/static/assets/ordinal-BDEzSJ7C.js +1 -0
  735. ksadk/studio/static/assets/packet-AYTQ26CC-BSJEH9Lb.js +1 -0
  736. ksadk/studio/static/assets/path-fybaL0A-.js +1 -0
  737. ksadk/studio/static/assets/pegDiagram-XKGWAZYB-BuHuNgT5.js +1 -0
  738. ksadk/studio/static/assets/pie-WAS4IAKB-qxv01Y8W.js +1 -0
  739. ksadk/studio/static/assets/pieDiagram-E7YTZNPT-DlrWiSOv.js +39 -0
  740. ksadk/studio/static/assets/preload-helper-CO68xz6u.js +1 -0
  741. ksadk/studio/static/assets/presentation-yYw7xK60-BmcZriri.js +1 -0
  742. ksadk/studio/static/assets/quadrantDiagram-AXDQQJYC-BA3hpUZM.js +7 -0
  743. ksadk/studio/static/assets/radar-RG4KPBEZ-B6h6pWOs.js +1 -0
  744. ksadk/studio/static/assets/railroad-74A4TZTK-CGtTWdGc.js +1 -0
  745. ksadk/studio/static/assets/railroad-abnf-HS5TGJTU-Cq7y22IA.js +1 -0
  746. ksadk/studio/static/assets/railroad-ebnf-LZEXJU2U-V0aQVv9m.js +1 -0
  747. ksadk/studio/static/assets/railroad-peg-WCYAUIDC-BQiIsX_p.js +1 -0
  748. ksadk/studio/static/assets/railroadDiagram-O6MQD6OU-BxpAazym.js +1 -0
  749. ksadk/studio/static/assets/requirementDiagram-BXWQKSXE-E-Ge0FcV.js +84 -0
  750. ksadk/studio/static/assets/rolldown-runtime-Dy4uBu1J-DK3Fl9T5.js +1 -0
  751. ksadk/studio/static/assets/rough.esm-Dy-Kn_BL.js +1 -0
  752. ksadk/studio/static/assets/sankeyDiagram-P5KCCOFB-CA6YKhQ3.js +40 -0
  753. ksadk/studio/static/assets/sequenceDiagram-WJ2MYXX4-CcElXGg4.js +162 -0
  754. ksadk/studio/static/assets/sizeCapture-INFHLROL-B0uUizjq.js +1 -0
  755. ksadk/studio/static/assets/src-B6xuSHsQ.js +1 -0
  756. ksadk/studio/static/assets/stateDiagram-D77RDMKH-DdXZOFqY.js +1 -0
  757. ksadk/studio/static/assets/stateDiagram-v2-MP3YSRHH-CJbOM-QK.js +1 -0
  758. ksadk/studio/static/assets/swimlanes-42K2YHIH-NtgEEHLY.js +1 -0
  759. ksadk/studio/static/assets/swimlanesDiagram-VR7AAH4N-D-AVlW8B.js +8 -0
  760. ksadk/studio/static/assets/timeline-definition-24CTP7MA-CIuYhNy3.js +120 -0
  761. ksadk/studio/static/assets/treeView-Q6P3EWNA-BTTYcvrF.js +1 -0
  762. ksadk/studio/static/assets/treemap-WGGIJYW6-Cg7tyfH8.js +1 -0
  763. ksadk/studio/static/assets/vennDiagram-4TSXK5OY-7HbApbrv.js +34 -0
  764. ksadk/studio/static/assets/wardley-WFR3VGLG-C6N1rULY.js +1 -0
  765. ksadk/studio/static/assets/wardleyDiagram-VM6X3IG4-CMJiaedy.js +78 -0
  766. ksadk/studio/static/assets/xychartDiagram-S5SC5T6Z-BdgtMvW2.js +7 -0
  767. ksadk/studio/static/index.html +8 -2
  768. ksadk/studio/teams_catalog.py +133 -0
  769. ksadk/studio/teams_installation.py +214 -0
  770. ksadk/studio/teams_node.py +545 -0
  771. ksadk/studio/teams_node_runner.py +69 -0
  772. ksadk/studio/teams_remote.py +274 -0
  773. ksadk/studio/templates.py +40 -19
  774. ksadk/studio/validator.py +13 -0
  775. ksadk/studio/workspace.py +19 -4
  776. ksadk/studio/workspace_plugins.py +136 -0
  777. ksadk/studio/workspace_registry.py +286 -0
  778. ksadk/toolsets/__init__.py +11 -0
  779. ksadk/toolsets/skills.py +446 -378
  780. ksadk/toolsets/workspace.py +3 -3
  781. ksadk/toolsets/workspace_identity.py +15 -0
  782. ksadk/version.py +1 -1
  783. ksadk_runtime_common/memory_backend/providers/lancedb.py +56 -2
  784. ksadk_runtime_common/schemas/memory_backend_manifest.schema.json +148 -148
  785. ksadk_runtime_common/workspace_files/router.py +26 -13
  786. agentengine_sdk_python-0.8.3.dist-info/RECORD +0 -833
  787. ksadk/server/static/assets/MathMessageMarkdown-D9uB55Oh.js +0 -8
  788. ksadk/server/static/assets/architecture-7GRP2DOG-Dk9nRQ6-.js +0 -1
  789. ksadk/server/static/assets/channel-s354Yo6o.js +0 -1
  790. ksadk/server/static/assets/chunk-2Q5K7J3B-CDpPpKR5.js +0 -1
  791. ksadk/server/static/assets/classDiagram-DTDB5LWJ-Dd0nucl9.js +0 -1
  792. ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-Dd0nucl9.js +0 -1
  793. ksadk/server/static/assets/cynefin-OW5HDTMX-BBlT4uMf.js +0 -1
  794. ksadk/server/static/assets/dist-DdRBIceA.js +0 -1
  795. ksadk/server/static/assets/eventmodeling-NTZA5JFV-Dr5okd8V.js +0 -1
  796. ksadk/server/static/assets/flowDiagram-A5DVABFB-VEO-cVcO.js +0 -1
  797. ksadk/server/static/assets/gitGraph-4MIJSDKK-CKiKY9Cf.js +0 -1
  798. ksadk/server/static/assets/index-B2k_urY8.js +0 -241
  799. ksadk/server/static/assets/index-ILPt6IWF.css +0 -2
  800. ksadk/server/static/assets/info-A6RAGUB7-ubA4Nm_p.js +0 -1
  801. ksadk/server/static/assets/packet-AYTQ26CC-C7R3NUlK.js +0 -1
  802. ksadk/server/static/assets/pie-WAS4IAKB-BIT6qjr3.js +0 -1
  803. ksadk/server/static/assets/radar-RG4KPBEZ-l5noef9X.js +0 -1
  804. ksadk/server/static/assets/railroad-74A4TZTK-Baea6ZvM.js +0 -1
  805. ksadk/server/static/assets/railroad-abnf-HS5TGJTU-OKn8zZnU.js +0 -1
  806. ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-DdKAKC4l.js +0 -1
  807. ksadk/server/static/assets/railroad-peg-WCYAUIDC-Bds8udlG.js +0 -1
  808. ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-5b-8o2iS.js +0 -1
  809. ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-uf6WPRA4.js +0 -8
  810. ksadk/server/static/assets/treeView-Q6P3EWNA-CK5CSrSO.js +0 -1
  811. ksadk/server/static/assets/treemap-WGGIJYW6-Ch2BKgAM.js +0 -1
  812. ksadk/server/static/assets/wardley-WFR3VGLG-YW3Q0ml_.js +0 -1
  813. ksadk/studio/static/assets/PrismRenderer-IYN-ffww.js +0 -3
  814. ksadk/studio/static/assets/index-DXs1Eq4M.css +0 -1
  815. ksadk/studio/static/assets/index-DeDqwTsD.js +0 -283
  816. {agentengine_sdk_python-0.8.3.dist-info → agentengine_sdk_python-0.8.5.dist-info}/WHEEL +0 -0
  817. {agentengine_sdk_python-0.8.3.dist-info → agentengine_sdk_python-0.8.5.dist-info}/entry_points.txt +0 -0
  818. {agentengine_sdk_python-0.8.3.dist-info → agentengine_sdk_python-0.8.5.dist-info}/licenses/LICENSE +0 -0
  819. {agentengine_sdk_python-0.8.3.dist-info → agentengine_sdk_python-0.8.5.dist-info}/top_level.txt +0 -0
ksadk/studio/service.py CHANGED
@@ -7,11 +7,13 @@ import hashlib
7
7
  import json
8
8
  import logging
9
9
  import os
10
+ import time
10
11
  import zipfile
11
- from collections.abc import Mapping, Sequence
12
+ from collections.abc import AsyncIterator, Awaitable, Mapping, Sequence
13
+ from contextlib import asynccontextmanager
12
14
  from dataclasses import dataclass
13
15
  from pathlib import Path
14
- from typing import Any, Callable, Literal, cast
16
+ from typing import Any, Callable, Literal, TypeVar, cast
15
17
  from urllib.parse import urlparse
16
18
  from uuid import uuid4
17
19
 
@@ -43,6 +45,7 @@ from ksadk.evaluation.studio_build_adapter import (
43
45
  from ksadk.events.store import RuntimeEventStore
44
46
  from ksadk.observability.session_log import SessionLogError, export_session_log
45
47
  from ksadk.observability.trajectory import encode_sse, project_trajectory_event
48
+ from ksadk.plugins.bundle_security import BundleSecurityError
46
49
  from ksadk.plugins.contracts import PluginManifest
47
50
  from ksadk.plugins.providers.legacy import LegacyHarnessSource
48
51
  from ksadk.plugins.providers.legacy_catalog import (
@@ -82,8 +85,11 @@ from ksadk.studio.codex_manifest import (
82
85
  CodexAgentManifest,
83
86
  CodexManifestRepository,
84
87
  )
88
+ from ksadk.studio.codex_plugin_store import CodexPluginSnapshotStore
89
+ from ksadk.studio.codex_provider_build import CodexProviderBuildManager
85
90
  from ksadk.studio.codex_run import CodexRunSpecResolver
86
91
  from ksadk.studio.compiler import AgentCompiler
92
+ from ksadk.studio.configuration import SETTINGS_ENV, WorkspaceConfiguration
87
93
  from ksadk.studio.contracts import (
88
94
  AgentAppearance,
89
95
  AgentBindings,
@@ -92,14 +98,21 @@ from ksadk.studio.contracts import (
92
98
  AgentTemplateComposeRequest,
93
99
  AgentTemplateComposition,
94
100
  BuildStatus,
101
+ BundleManifest,
95
102
  DeploymentRequest,
103
+ Diagnostic,
104
+ DiagnosticSeverity,
96
105
  Operation,
97
106
  OperationKind,
107
+ OperationStatus,
98
108
  RunEvent,
99
109
  RunStatus,
100
110
  RuntimeRef,
101
111
  ToolContract,
102
112
  )
113
+ from ksadk.studio.dsh_capability_service import (
114
+ StudioDshCapabilityService,
115
+ )
103
116
  from ksadk.studio.dsh_provider_registration import (
104
117
  StudioDshProviderRegistrationError,
105
118
  StudioDshProviderRegistrationManager,
@@ -113,8 +126,18 @@ from ksadk.studio.model_profile_service import test_model_profile_connection
113
126
  from ksadk.studio.operations import OperationManager
114
127
  from ksadk.studio.plugin_composition import StudioPluginCompositionCompiler
115
128
  from ksadk.studio.plugin_runtime import StudioPluginRuntime
116
- from ksadk.studio.repository import AgentDraftRepository, BuildRepository, load_yaml_file
129
+ from ksadk.studio.repository import AgentDraftRepository, BuildRepository
130
+ from ksadk.studio.resource_authority import (
131
+ ResourceAuthorityPolicy,
132
+ SignedKnowledgeResourceAuthority,
133
+ resource_authority_policy_from_environment,
134
+ )
135
+ from ksadk.studio.resource_build_admission import (
136
+ admit_resource_build,
137
+ resource_build_required,
138
+ )
117
139
  from ksadk.studio.resource_catalog import LocalResourceCatalog
140
+ from ksadk.studio.resource_connections import ResourceConnectionRepository
118
141
  from ksadk.studio.run_service import StudioRunService, StudioRunSpec
119
142
  from ksadk.studio.runtime_catalog import inspect_runtime_catalog
120
143
  from ksadk.studio.runtime_source import materialize_generated_runtime_source
@@ -129,9 +152,13 @@ from ksadk.studio.templates import (
129
152
  compose_research_agent,
130
153
  default_agent_spec,
131
154
  list_agent_templates,
155
+ with_harness_provider_permissions,
132
156
  )
133
157
  from ksadk.studio.validator import AgentValidator
134
158
  from ksadk.studio.workspace import Workspace
159
+ from ksadk.studio.workspace_registry import WorkspaceRegistry
160
+
161
+ _T = TypeVar("_T")
135
162
 
136
163
  _TRAJECTORY_KEEPALIVE_SECONDS = 15.0
137
164
  _EVALUATION_TARGET_LABELS = {
@@ -162,6 +189,9 @@ class StudioService:
162
189
  plugin_provider_factories: Mapping[str, Any] | None = None,
163
190
  legacy_harness_sources: Sequence[LegacyHarnessSource] = (),
164
191
  dsh_provider_registration_manager: StudioDshProviderRegistrationManager | None = None,
192
+ dsh_capability_service: StudioDshCapabilityService | None = None,
193
+ resource_authority_policy: ResourceAuthorityPolicy | None = None,
194
+ configuration_overrides: dict[str, str] | None = None,
165
195
  ) -> None:
166
196
  provider_manifests = dict(plugin_provider_manifests or {})
167
197
  provider_factories = dict(plugin_provider_factories or {})
@@ -171,6 +201,8 @@ class StudioService:
171
201
  )
172
202
  self.workspace = Workspace(root)
173
203
  self.workspace.initialize()
204
+ self.workspace_registry = WorkspaceRegistry()
205
+ self.workspace_record = self.workspace_registry.open(self.workspace.root)
174
206
  self._startup_provider_manifests = provider_manifests
175
207
  self._startup_provider_factories = provider_factories
176
208
  self._active_provider_manifests = dict(provider_manifests)
@@ -180,14 +212,58 @@ class StudioService:
180
212
  self.workspace.root
181
213
  )
182
214
  )
215
+ self.dsh_capabilities = (
216
+ dsh_capability_service
217
+ or StudioDshCapabilityService.discover_or_create_workspace_default(self.workspace.root)
218
+ )
219
+ if (
220
+ dsh_capability_service is not None
221
+ or os.environ.get("KSADK_DSH_HOME", "").strip()
222
+ or os.environ.get("KSADK_DSH_PROFILE", "").strip()
223
+ ):
224
+ self._resource_dsh_provider_registration_manager = None
225
+ self.resource_dsh_capabilities = self.dsh_capabilities
226
+ else:
227
+ self._resource_dsh_provider_registration_manager = (
228
+ StudioDshProviderRegistrationManager.create_workspace_resource_default(
229
+ self.workspace.root
230
+ )
231
+ )
232
+ self.resource_dsh_capabilities = (
233
+ StudioDshCapabilityService.create_workspace_resource_default(self.workspace.root)
234
+ )
183
235
  self._start_lock = asyncio.Lock()
236
+ self._profile_maintenance = False
184
237
  self._started = False
238
+ self._dsh_startup_task: asyncio.Task[None] | None = None
239
+ self._dsh_ready = False
240
+ self._closed = False
241
+ self.configuration = WorkspaceConfiguration(
242
+ self.workspace, overrides=configuration_overrides
243
+ )
244
+ self._resource_authority_policy_override = resource_authority_policy
185
245
  self._apply_persisted_settings()
186
246
  self.avatar_assets = AgentAvatarAssetStore(self.workspace)
187
247
  self.conversation_attachments = ConversationAttachmentStore(self.workspace)
188
248
  self.drafts = AgentDraftRepository(self.workspace)
189
249
  self.catalog = LocalResourceCatalog(self.workspace)
190
250
  self.builds = BuildRepository(self.workspace)
251
+ self.credentials = (
252
+ credential_resolver
253
+ or getattr(model_client, "credential_resolver", None)
254
+ or CredentialResolver(self.workspace, configuration=self.configuration)
255
+ )
256
+ self.resource_connections = ResourceConnectionRepository(self.workspace, self.credentials)
257
+ effective_resource_policy = (
258
+ resource_authority_policy
259
+ if resource_authority_policy is not None
260
+ else resource_authority_policy_from_environment(self.configuration.environment())
261
+ )
262
+ self.resource_authority = (
263
+ SignedKnowledgeResourceAuthority(self.resource_connections, effective_resource_policy)
264
+ if effective_resource_policy is not None
265
+ else None
266
+ )
191
267
  self.validator = AgentValidator()
192
268
  self.builder = AgentBundleBuilder(
193
269
  self.workspace,
@@ -209,6 +285,8 @@ class StudioService:
209
285
  self.codex_manifests = CodexManifestRepository(self.workspace)
210
286
  self.codex_builds = CodexBuildRepository(self.workspace)
211
287
  self.codex_drafts = CodexDraftRepository(self.workspace)
288
+ self.codex_plugin_snapshots = CodexPluginSnapshotStore(self.workspace)
289
+ self.codex_provider_builds = CodexProviderBuildManager(self)
212
290
  codex_builder_kwargs = {}
213
291
  if codex_runtime_inspector is not None:
214
292
  codex_builder_kwargs["runtime_inspector"] = codex_runtime_inspector
@@ -218,6 +296,10 @@ class StudioService:
218
296
  build_repository=self.codex_builds,
219
297
  resource_catalog=self.catalog,
220
298
  draft_repository=self.codex_drafts,
299
+ plugin_snapshot_store=self.codex_plugin_snapshots,
300
+ resource_connections=self.resource_connections,
301
+ provider_build=self.codex_provider_builds.prepare,
302
+ provider_validate=self.codex_provider_builds.bundle_root,
221
303
  **codex_builder_kwargs,
222
304
  )
223
305
  self.runtime_executor = runtime_executor or RuntimeExecutor(
@@ -230,17 +312,15 @@ class StudioService:
230
312
  session_service=self.session_service,
231
313
  runtime_events=self.runtime_events,
232
314
  )
233
- self.credentials = (
234
- credential_resolver
235
- or getattr(model_client, "credential_resolver", None)
236
- or CredentialResolver(self.workspace)
237
- )
238
315
  self.codex_runs = CodexRunSpecResolver(
239
316
  self.workspace,
240
317
  build_repository=self.codex_builds,
241
318
  manifest_repository=self.codex_manifests,
242
319
  credential_resolver=self.credentials,
243
320
  resource_catalog=self.catalog,
321
+ draft_repository=self.codex_drafts,
322
+ plugin_snapshot_store=self.codex_plugin_snapshots,
323
+ provider_bundle_resolver=self.codex_provider_builds.bundle_root,
244
324
  )
245
325
  self.framework_runs = FrameworkRunSpecResolver(
246
326
  self.workspace,
@@ -256,10 +336,17 @@ class StudioService:
256
336
  session_service=self.session_service,
257
337
  model_client=self.model_client,
258
338
  secret_resolver=self.credentials,
339
+ codex_local_launch_resolver=self.codex_provider_builds.native_launch,
340
+ runtime_executor=self.runtime_executor,
259
341
  harness_reasoner=harness_reasoner,
260
342
  provider_manifests=provider_manifests,
261
343
  provider_factories=provider_factories,
262
344
  legacy_harness_sources=legacy_harness_sources,
345
+ dsh_capability_service=self.dsh_capabilities,
346
+ resource_dsh_capability_service=self.resource_dsh_capabilities,
347
+ resource_authority=self.resource_authority,
348
+ resource_connections=self.resource_connections,
349
+ resource_actor_ref="local-user",
263
350
  )
264
351
  self.run_service.plugin_runtime = self.plugin_runs
265
352
  self.scheduler_runtimes = StudioScheduledKernelRegistry(
@@ -267,13 +354,32 @@ class StudioService:
267
354
  resolve_adapter_provider=self._scheduler_adapter_provider,
268
355
  session_service=self.session_service,
269
356
  runtime_executor=self.runtime_executor,
357
+ state_dir=self.workspace.resolve(".agentkit/plugin-runtime/state"),
270
358
  )
271
359
  self.scheduler = StudioSchedulerService(
272
360
  self.workspace,
273
361
  runtime_registry=self.scheduler_runtimes,
274
362
  )
363
+ from ksadk.studio.execution_host import StudioExecutionHost
364
+ from ksadk.studio.teams_installation import create_teams_installation
365
+ from ksadk.studio.workspace_plugins import WorkspacePluginRegistry
366
+
367
+ self.workspace_plugins = WorkspacePluginRegistry()
368
+ self.execution_host = StudioExecutionHost(
369
+ self.scheduler_runtimes,
370
+ state_path=self.workspace.resolve(".agentkit/plugin-runtime/execution-host.sqlite"),
371
+ )
372
+ self.plugin_runs.execution_policy_resolver = self.execution_host
373
+ self.teams_installation = create_teams_installation(self)
374
+ from ksadk.studio.channel_connections import StudioChannelConnections
375
+
376
+ self.channel_connections = StudioChannelConnections(self)
377
+ from ksadk.studio.scheduler_assistant import StudioScheduleAssistant
378
+
379
+ self.run_service.schedule_assistant = StudioScheduleAssistant(self)
275
380
  self.mcp_runtime = MCPRuntimeAdapter(self.workspace, credentials=self.credentials)
276
381
  self._cloud_gateway_override = cloud_gateway
382
+ self._profile_maintenance = False
277
383
  self.cloud = CloudDeploymentService(
278
384
  self.workspace,
279
385
  gateway=cloud_gateway or self._configured_cloud_gateway(),
@@ -283,12 +389,37 @@ class StudioService:
283
389
  self.evaluation_storage = EvaluationStorage(self.workspace.resolve(".agentkit/evaluations"))
284
390
  self.authoring = StudioAuthoringCoordinator(self)
285
391
  self.codex_agents = CodexAgentService(self)
286
-
287
- async def start(self) -> None:
288
- """Bind ready managed DSH registrations before build or execution."""
289
-
392
+ self._current_codex_builds: dict[str, CodexBuildRecord] = {}
393
+ # agent_detail 进程内 TTL 缓存:bootstrap/list_models/list_sessions 等
394
+ # 转发接口在会话切换时反复调用 agent_detail,每次都重做 builds 全扫 +
395
+ # validator.validate(100-300ms)。5s TTL 把切换/刷新的重复读折叠掉;
396
+ # create/update/delete agent 时主动失效。
397
+ self._agent_detail_cache: dict[str, tuple[float, dict[str, Any]]] = {}
398
+ self._agent_detail_ttl = 5.0
399
+
400
+ async def start(self, *, wait_for_dsh: bool = True) -> None:
401
+ """Start local state and optionally wait for the managed DSH profile."""
402
+ # Desktop workspace switching must not queue behind an in-flight DSH
403
+ # discovery task. The service is already usable while that optional
404
+ # task finishes in the background; callers that explicitly request
405
+ # readiness still await the task below.
406
+ if self._started and not wait_for_dsh:
407
+ return
290
408
  async with self._start_lock:
291
- if self._started:
409
+ self._ensure_open()
410
+ if not self._started:
411
+ await self.scheduler_runtimes.start()
412
+ self._started = True
413
+ self._dsh_startup_task = asyncio.create_task(self._initialize_dsh())
414
+ self.channel_connections.start_background()
415
+ task = self._dsh_startup_task
416
+ if wait_for_dsh and task is not None:
417
+ await asyncio.shield(task)
418
+
419
+ async def _initialize_dsh(self) -> None:
420
+ async with self._start_lock:
421
+ self._ensure_open()
422
+ if self._dsh_ready:
292
423
  return
293
424
  await self._bootstrap_official_dsh_defaults()
294
425
  manifests, factories, manager_refs = await self._provider_snapshot(refresh=False)
@@ -298,29 +429,202 @@ class StudioService:
298
429
  manager = self._dsh_provider_registration_manager
299
430
  if manager is not None and manager_refs is not None:
300
431
  manager.mark_bound(manager_refs)
301
- self._started = True
432
+ self._dsh_ready = True
302
433
 
303
434
  async def refresh_dsh_provider_registrations(self) -> None:
304
435
  """Rebind the exact current DSH Profile and release stale activations."""
305
436
 
306
437
  async with self._start_lock:
307
- if self._dsh_provider_registration_manager is None:
308
- self._dsh_provider_registration_manager = (
309
- StudioDshProviderRegistrationManager.discover_or_create_workspace_default(
310
- self.workspace.root
311
- )
438
+ self._ensure_open()
439
+ await self.execution_host.set_admission_open(False)
440
+ await self.scheduler_runtimes.set_admission_open(False)
441
+ self._profile_maintenance = True
442
+ safe_to_resume = True
443
+ try:
444
+ await self._require_profile_idle()
445
+ safe_to_resume = False
446
+ await self.plugin_runs.suspend_admission()
447
+ await self.reset_dsh_capability_state()
448
+ await self._bind_dsh_provider_registrations_locked(refresh=True)
449
+ await self._refresh_dsh_catalog_resource(required=False)
450
+ safe_to_resume = True
451
+ finally:
452
+ # 维护窗标志是纯同步状态,无条件复位:任何异常/取消路径都不得
453
+ # 把整个会话面永久留在 503。admission 的恢复语义不变(恢复失败
454
+ # 仍按契约保持关闭,由测试 test_failed_profile_rebind_* 保障)。
455
+ self._profile_maintenance = False
456
+ await self.execution_host.set_admission_open(safe_to_resume)
457
+ await self.scheduler_runtimes.set_admission_open(safe_to_resume)
458
+ if safe_to_resume:
459
+ await self.plugin_runs.resume_admission()
460
+
461
+ async def reconfigure_dsh_profile(
462
+ self,
463
+ operation: Callable[[], Awaitable[_T]],
464
+ ) -> _T:
465
+ """Run one Profile mutation while all Agent admission is suspended."""
466
+
467
+ async with self._start_lock:
468
+ self._ensure_open()
469
+ await self.execution_host.set_admission_open(False)
470
+ await self.scheduler_runtimes.set_admission_open(False)
471
+ self._profile_maintenance = True
472
+ safe_to_resume = True
473
+ try:
474
+ await self._require_profile_idle()
475
+ safe_to_resume = False
476
+ await self.plugin_runs.suspend_admission()
477
+ await self.reset_dsh_capability_state()
478
+ try:
479
+ result = await operation()
480
+ except asyncio.CancelledError:
481
+ # 取消中的任务做不了 recovery;维护窗标志在 finally 无条件
482
+ # 复位,避免一次取消把会话面永久 503。
483
+ raise
484
+ except BaseException as mutation_error:
485
+ if (
486
+ isinstance(mutation_error, StudioError)
487
+ and mutation_error.code == "DSH_PROFILE_RECOVERY_REQUIRED"
488
+ ):
489
+ raise
490
+ try:
491
+ await self._bind_dsh_provider_registrations_locked(refresh=True)
492
+ await self._refresh_dsh_catalog_resource(required=False)
493
+ safe_to_resume = True
494
+ except Exception as recovery_error: # noqa: BLE001
495
+ logging.getLogger(__name__).warning(
496
+ "DSH provider recovery after mutation failure skipped: %s",
497
+ recovery_error,
498
+ )
499
+ raise
500
+ await self._bind_dsh_provider_registrations_locked(refresh=True)
501
+ await self._refresh_dsh_catalog_resource(required=False)
502
+ safe_to_resume = True
503
+ return result
504
+ finally:
505
+ # 维护窗标志是纯同步状态,无条件复位:任何异常/取消路径都不得
506
+ # 把整个会话面永久留在 503。admission 的恢复语义不变(恢复失败
507
+ # 仍按契约保持关闭,由测试 test_failed_profile_rebind_* 保障)。
508
+ self._profile_maintenance = False
509
+ await self.execution_host.set_admission_open(safe_to_resume)
510
+ await self.scheduler_runtimes.set_admission_open(safe_to_resume)
511
+ if safe_to_resume:
512
+ await self.plugin_runs.resume_admission()
513
+
514
+ async def _require_profile_idle(self) -> None:
515
+ pending = await self.scheduler_runtimes.unsettled_sessions()
516
+ active_operations = [
517
+ operation for operation in self.operations.list()
518
+ if operation.status in {OperationStatus.QUEUED, OperationStatus.RUNNING}
519
+ ]
520
+ if pending or active_operations:
521
+ raise StudioError("DSH_PROFILE_IN_USE",
522
+ "仍有执行或审批正在进行,请结束执行后再变更插件 Profile", status_code=409)
523
+
524
+ def _require_direct_session(self, session_id: str | None) -> None:
525
+ if self._profile_maintenance:
526
+ raise StudioError("DSH_PROFILE_MAINTENANCE", "插件宿主正在维护", status_code=503)
527
+ if session_id:
528
+ from ksadk.studio.execution_host import ExecutionHostError
529
+
530
+ try:
531
+ self.execution_host.require_unreserved_session(session_id)
532
+ except ExecutionHostError as error:
533
+ raise StudioError(error.code, str(error), status_code=error.status) from error
534
+
535
+ def _require_direct_run(self, run_id: str) -> None:
536
+ from ksadk.studio.execution_host import ExecutionHostError
537
+
538
+ self._require_direct_session(None)
539
+ try:
540
+ self.execution_host.require_unreserved_run(run_id)
541
+ except ExecutionHostError as error:
542
+ raise StudioError(error.code, str(error), status_code=error.status) from error
543
+
544
+ async def _bind_dsh_provider_registrations_locked(self, *, refresh: bool) -> None:
545
+ if self._dsh_provider_registration_manager is None:
546
+ self._dsh_provider_registration_manager = (
547
+ StudioDshProviderRegistrationManager.discover_or_create_workspace_default(
548
+ self.workspace.root
312
549
  )
313
- await self._bootstrap_official_dsh_defaults()
314
- if self._started:
315
- await self.plugin_runs.aclose()
316
- manifests, factories, manager_refs = await self._provider_snapshot(refresh=True)
317
- self.plugin_compositions.replace_provider_registrations(manifests)
318
- self.plugin_runs.replace_provider_registrations(manifests, factories)
319
- self._active_provider_manifests = manifests
320
- manager = self._dsh_provider_registration_manager
321
- if manager is not None and manager_refs is not None:
322
- manager.mark_bound(manager_refs)
323
- self._started = True
550
+ )
551
+ await self._bootstrap_official_dsh_defaults()
552
+ manifests, factories, manager_refs = await self._provider_snapshot(refresh=refresh)
553
+ self.plugin_compositions.replace_provider_registrations(manifests)
554
+ self.plugin_runs.replace_provider_registrations(manifests, factories)
555
+ self._active_provider_manifests = manifests
556
+ manager = self._dsh_provider_registration_manager
557
+ if manager is not None and manager_refs is not None:
558
+ manager.mark_bound(manager_refs)
559
+ self._started = True
560
+ self._dsh_ready = True
561
+
562
+ async def reset_dsh_capability_state(self) -> None:
563
+ """Drop the current DSH capability/Core generation."""
564
+
565
+ self.catalog.clear_dsh_profile_mcp()
566
+ await self.dsh_capabilities.refresh()
567
+
568
+ async def refresh_dsh_catalog_resource(self): # type: ignore[no-untyped-def]
569
+ """Validate and publish the current DSH Profile as a bindable MCP."""
570
+
571
+ _snapshot, resource = await self.dsh_capability_catalog_snapshot()
572
+ return resource
573
+
574
+ async def dsh_capability_catalog_snapshot(self): # type: ignore[no-untyped-def]
575
+ """Atomically snapshot and publish one current DSH generation."""
576
+
577
+ async with self._start_lock:
578
+ self._ensure_open()
579
+ snapshot = await self.dsh_capabilities.capability_snapshot()
580
+ resource = self.catalog.replace_dsh_profile_mcp(snapshot.descriptor)
581
+ return snapshot, resource
582
+
583
+ async def ensure_dsh_catalog_available(self) -> None:
584
+ """Publish an explicitly enabled DSH Profile for the generic selector.
585
+
586
+ The normal Studio startup remains side-effect free for legacy users.
587
+ The generic MCP catalog request performs only a profile metadata check;
588
+ it starts the managed capability host when the user has already enabled
589
+ at least one DSH plugin.
590
+ """
591
+
592
+ async with self._start_lock:
593
+ self._ensure_open()
594
+ existing = self.catalog.list(kind="mcp", source="provider", limit=200)
595
+ if any(item.contract.get("materialization") == "dsh-profile" for item in existing):
596
+ return
597
+ checker = getattr(self.dsh_capabilities, "has_enabled_profile_plugins", None)
598
+ if checker is None:
599
+ return
600
+ try:
601
+ enabled = await checker()
602
+ except Exception as error: # noqa: BLE001 - optional ecosystem boundary
603
+ logging.getLogger(__name__).warning("DSH catalog discovery skipped: %s", error)
604
+ return
605
+ if enabled:
606
+ await self._refresh_dsh_catalog_resource(required=False)
607
+
608
+ @asynccontextmanager
609
+ async def dsh_profile_read_transaction(self) -> AsyncIterator[None]:
610
+ """Fence a UI grant read against Profile mutation and shutdown."""
611
+
612
+ async with self._start_lock:
613
+ self._ensure_open()
614
+ yield
615
+
616
+ async def _refresh_dsh_catalog_resource(self, *, required: bool): # type: ignore[no-untyped-def]
617
+ try:
618
+ snapshot = await self.dsh_capabilities.capability_snapshot()
619
+ return self.catalog.replace_dsh_profile_mcp(snapshot.descriptor)
620
+ except Exception as error: # noqa: BLE001 - optional ecosystem boundary
621
+ self.catalog.clear_dsh_profile_mcp()
622
+ if required:
623
+ raise
624
+ logging.getLogger(__name__).warning(
625
+ "DSH capability catalog publication skipped: %s", error
626
+ )
627
+ return None
324
628
 
325
629
  async def _bootstrap_official_dsh_defaults(self) -> None:
326
630
  manager = self._dsh_provider_registration_manager
@@ -332,9 +636,47 @@ class StudioService:
332
636
  logging.getLogger(__name__).warning(
333
637
  "official DSH provider bootstrap skipped: %s", error
334
638
  )
639
+ else:
640
+ if result in {"installed", "already_enabled"}:
641
+ logging.getLogger(__name__).info(
642
+ "official Codex DSH provider bootstrap: %s", result
643
+ )
644
+ try:
645
+ harness_result = await manager.bootstrap_official_harness_provider()
646
+ except Exception as error:
647
+ logging.getLogger(__name__).warning(
648
+ "official Harness DSH provider bootstrap skipped: %s", error
649
+ )
650
+ else:
651
+ if harness_result in {"installed", "already_enabled"}:
652
+ logging.getLogger(__name__).info(
653
+ "official Harness DSH provider bootstrap: %s", harness_result
654
+ )
655
+ try:
656
+ resource_result = await manager.bootstrap_official_resource_plugins()
657
+ except Exception as error: # optional DSH must fail closed to legacy paths
658
+ logging.getLogger(__name__).warning(
659
+ "official DSH resource bootstrap skipped: %s", error
660
+ )
661
+ else:
662
+ if resource_result in {"installed", "already_enabled"}:
663
+ logging.getLogger(__name__).info(
664
+ "official platform resource DSH bootstrap: %s", resource_result
665
+ )
666
+ resource_manager = self._resource_dsh_provider_registration_manager
667
+ if resource_manager is None:
335
668
  return
336
- if result in {"installed", "already_enabled"}:
337
- logging.getLogger(__name__).info("official Codex DSH provider bootstrap: %s", result)
669
+ try:
670
+ resource_result = await resource_manager.bootstrap_official_resource_plugins()
671
+ except Exception as error:
672
+ logging.getLogger(__name__).warning(
673
+ "official resource execution Profile bootstrap skipped: %s", error
674
+ )
675
+ else:
676
+ if resource_result in {"installed", "already_enabled"}:
677
+ logging.getLogger(__name__).info(
678
+ "official resource execution Profile bootstrap: %s", resource_result
679
+ )
338
680
 
339
681
  async def _provider_snapshot(
340
682
  self, *, refresh: bool
@@ -453,19 +795,29 @@ class StudioService:
453
795
  """Resolve one immutable Build through its only compatible resolver."""
454
796
 
455
797
  try:
798
+ self.codex_builds.get(build_id)
799
+ except Exception as exc:
800
+ if getattr(exc, "status_code", None) != 404:
801
+ raise
802
+ else:
803
+ # The record exists in the Codex repository. Any later resolution
804
+ # error belongs to that Build and must remain actionable; a nested
805
+ # 404 (for example a missing plugin snapshot) is not evidence that
806
+ # this is a framework Build.
456
807
  return self.codex_runs.resolve(
457
808
  build_id,
458
809
  model=model,
459
810
  sandbox=sandbox,
460
811
  approval_mode=approval_mode,
461
812
  )
462
- except Exception as exc:
463
- if getattr(exc, "status_code", None) != 404:
464
- raise
465
813
  framework_build = self.builds.get(build_id)
466
814
  runtime_type = framework_build.runtime_type.strip().lower()
467
815
  if runtime_type in {"harness", "plugin"}:
468
- return self.plugin_runs.resolve(build_id, model=model)
816
+ return self.plugin_runs.resolve(
817
+ build_id,
818
+ model=model,
819
+ approval_mode=approval_mode,
820
+ )
469
821
  return self.framework_runs.resolve(
470
822
  build_id,
471
823
  model=model,
@@ -537,6 +889,7 @@ class StudioService:
537
889
  sending provider-specific fields to every Runtime.
538
890
  """
539
891
 
892
+ self._require_direct_session(session_id)
540
893
  spec = self.resolve_run_spec(build_id)
541
894
  runtime_type = spec.launch_context.runtime_type.strip().lower()
542
895
  runtime_mode: Literal["native", "translated"] = (
@@ -553,7 +906,7 @@ class StudioService:
553
906
  ConversationCapability(name="attachment.image", mode="native"),
554
907
  # Bounded UTF-8/code attachments are made model-visible as
555
908
  # deterministic text parts by the Responses compatibility
556
- # adapter. Binary files remain unavailable in Phase 2.
909
+ # adapter. Binary files remain unavailable in Release.
557
910
  ConversationCapability(name="attachment.file", mode="translated"),
558
911
  ConversationCapability(name="reasoning.effort", mode="native"),
559
912
  ConversationCapability(name="goal", mode="native"),
@@ -595,21 +948,33 @@ class StudioService:
595
948
  await self.start()
596
949
  if self.is_codex_agent(agent_id):
597
950
  self.codex_agent_detail(agent_id)
951
+ manifest_snapshot = self.codex_manifests.load(agent_id)
952
+ cached = self._current_codex_builds.get(agent_id)
953
+ if cached is not None and cached.manifest_sha256 == manifest_snapshot.manifest_sha256:
954
+ try:
955
+ return self.codex_builds.get(cached.id)
956
+ except StudioError:
957
+ self._current_codex_builds.pop(agent_id, None)
598
958
  builds = [
599
959
  record
600
960
  for record in self.codex_builds.list()
601
961
  if record.agent_name == agent_id and self.codex_builder.is_current(record)
602
962
  ]
603
963
  if builds:
964
+ self._current_codex_builds[agent_id] = builds[0]
604
965
  return builds[0]
605
- return await asyncio.to_thread(self.codex_builder.build, agent_id)
966
+ built = await asyncio.to_thread(self.codex_builder.build, agent_id)
967
+ self._current_codex_builds[agent_id] = built
968
+ return built
606
969
  draft = self.drafts.get(agent_id)
607
970
  composition_required = self.plugin_compositions.required_for(draft)
971
+ resources_required = resource_build_required(draft)
608
972
  for record in self.builds.list_for_agent(agent_id):
609
973
  if record.status == BuildStatus.SUCCEEDED:
610
- if composition_required and (
974
+ if (composition_required or resources_required) and (
611
975
  record.source_revision != draft.metadata.revision
612
- or not self._build_has_composition(record)
976
+ or (composition_required and not self._build_has_composition(record))
977
+ or (resources_required and not self._build_has_resources(record))
613
978
  ):
614
979
  continue
615
980
  if composition_required:
@@ -620,6 +985,8 @@ class StudioService:
620
985
  "当前 Agent 需要插件组合,但无法生成 Composition",
621
986
  status_code=409,
622
987
  )
988
+ if not self._build_has_composition(record, composition=composition):
989
+ continue
623
990
  self.plugin_compositions.bind_build(
624
991
  composition,
625
992
  agent_id=draft.metadata.id,
@@ -638,7 +1005,44 @@ class StudioService:
638
1005
 
639
1006
  def _build_agent_bundle(self, draft: AgentDraft):
640
1007
  composition = self.plugin_compositions.compile_if_required(draft)
641
- record = self.builder.build(draft, composition=composition)
1008
+ resource_build = None
1009
+ if resource_build_required(draft):
1010
+ dsh_profile = self.resource_dsh_capabilities.capture_resource_build_snapshot()
1011
+ resource_build = admit_resource_build(
1012
+ draft,
1013
+ authority=self.resource_authority,
1014
+ connections=self.resource_connections,
1015
+ dsh_profile=dsh_profile,
1016
+ )
1017
+ try:
1018
+ record = self.builder.build(
1019
+ draft,
1020
+ composition=composition,
1021
+ resource_build=resource_build,
1022
+ )
1023
+ except BundleSecurityError as error:
1024
+ first = error.findings[0]
1025
+ reason = {
1026
+ "literal-secret-field": "明文凭证",
1027
+ "url-credentials": "含账号信息的 URL",
1028
+ "local-home-path": "本机用户目录路径",
1029
+ "invalid-structured-input": "无法解析的结构化数据",
1030
+ }.get(first.kind, "敏感内容")
1031
+ raise StudioError(
1032
+ "BUNDLE_SECURITY_REJECTED",
1033
+ f"AgentBundle 安全检查未通过:{first.path} 检测到{reason}",
1034
+ status_code=422,
1035
+ details={
1036
+ "securityFindings": [
1037
+ {
1038
+ "path": finding.path,
1039
+ "kind": finding.kind,
1040
+ "field": finding.field,
1041
+ }
1042
+ for finding in error.findings
1043
+ ]
1044
+ },
1045
+ ) from error
642
1046
  if composition is not None:
643
1047
  self.plugin_compositions.bind_build(
644
1048
  composition,
@@ -647,7 +1051,7 @@ class StudioService:
647
1051
  )
648
1052
  return record
649
1053
 
650
- def _build_has_composition(self, record: Any) -> bool:
1054
+ def _build_has_composition(self, record: Any, *, composition: Any = None) -> bool:
651
1055
  """Reject stale pre-Phase-2 builds for a composed runtime.
652
1056
 
653
1057
  This check is intentionally scoped to Harness/plugin runtimes. Legacy
@@ -666,6 +1070,33 @@ class StudioService:
666
1070
  and manifest.get("compositionProfileDigest")
667
1071
  and "composition-profile.json" in names
668
1072
  and "plugin-lock.json" in names
1073
+ and (
1074
+ composition is None
1075
+ or (
1076
+ manifest.get("compositionProfileDigest") == composition.profile_digest
1077
+ and manifest.get("pluginLockDigest") == composition.plugin_lock_digest
1078
+ )
1079
+ )
1080
+ )
1081
+ except (KeyError, OSError, UnicodeError, ValueError, zipfile.BadZipFile):
1082
+ return False
1083
+
1084
+ def _build_has_resources(self, record: Any) -> bool:
1085
+ if (
1086
+ not record.artifact_path
1087
+ or not record.resource_build_digest
1088
+ or not record.resource_snapshot_digest
1089
+ ):
1090
+ return False
1091
+ try:
1092
+ archive = self.workspace.resolve(record.artifact_path, must_exist=True)
1093
+ with zipfile.ZipFile(archive) as bundle:
1094
+ manifest = BundleManifest.model_validate_json(bundle.read("manifest.json"))
1095
+ names = frozenset(bundle.namelist())
1096
+ return bool(
1097
+ manifest.resource_build_digest == record.resource_build_digest
1098
+ and manifest.resource_snapshot_digest == record.resource_snapshot_digest
1099
+ and "platform-resources/resource-build.json" in names
669
1100
  )
670
1101
  except (KeyError, OSError, UnicodeError, ValueError, zipfile.BadZipFile):
671
1102
  return False
@@ -714,6 +1145,7 @@ class StudioService:
714
1145
  field="sessionId",
715
1146
  )
716
1147
  if continuity == "continue_session":
1148
+ await self._require_schedule_session_owner(agent_id, session_id)
717
1149
  self._require_schedule_continuation(runtime, spec.launch_context.runtime_type)
718
1150
  task = ScheduledTask(
719
1151
  task_id=f"sched-{uuid4().hex[:20]}",
@@ -736,6 +1168,29 @@ class StudioService:
736
1168
  )
737
1169
  return self.scheduler.create_task(task)
738
1170
 
1171
+ async def _require_schedule_session_owner(self, agent_id: str, session_id: str | None) -> None:
1172
+ session = (
1173
+ await self.session_service.get_session_metadata(session_id) if session_id else None
1174
+ )
1175
+ if session is None or session.agent_id != agent_id:
1176
+ raise StudioError(
1177
+ "SCHEDULE_SESSION_INVALID",
1178
+ "请选择该智能体已有的会话。",
1179
+ status_code=422,
1180
+ field="sessionId",
1181
+ )
1182
+
1183
+ async def validate_schedule_session(
1184
+ self, agent_id: str, continuity: str, session_id: str | None, build_id: str | None
1185
+ ) -> None:
1186
+ if continuity != "continue_session":
1187
+ return
1188
+ await self._require_schedule_session_owner(agent_id, session_id)
1189
+ await self.scheduler_runtimes.ensure_build(build_id, expected_agent_id=agent_id)
1190
+ runtime = self.scheduler_runtimes.runtime_for_build(build_id)
1191
+ spec = self.resolve_run_spec(build_id)
1192
+ self._require_schedule_continuation(runtime, spec.launch_context.runtime_type)
1193
+
739
1194
  @staticmethod
740
1195
  def _require_schedule_continuation(runtime: Any, runtime_type: str) -> None:
741
1196
  """Fail closed unless the bound Provider can preserve one conversation.
@@ -826,12 +1281,15 @@ class StudioService:
826
1281
  name: str | None = None,
827
1282
  labels: dict[str, str] | None = None,
828
1283
  ) -> AgentDraft:
829
- return self.codex_agents.create(
1284
+ created = self.codex_agents.create(
830
1285
  agent_id=agent_id,
831
1286
  spec=spec,
832
1287
  name=name,
833
1288
  labels=labels,
834
1289
  )
1290
+ self._current_codex_builds.pop(agent_id, None)
1291
+ self.invalidate_agent_detail(agent_id)
1292
+ return created
835
1293
 
836
1294
  def update_codex_agent(
837
1295
  self,
@@ -841,15 +1299,20 @@ class StudioService:
841
1299
  expected_revision: int,
842
1300
  name: str | None = None,
843
1301
  ) -> AgentDraft:
844
- return self.codex_agents.update(
1302
+ updated = self.codex_agents.update(
845
1303
  agent_id,
846
1304
  spec,
847
1305
  expected_revision=expected_revision,
848
1306
  name=name,
849
1307
  )
1308
+ self._current_codex_builds.pop(agent_id, None)
1309
+ self.invalidate_agent_detail(agent_id)
1310
+ return updated
850
1311
 
851
1312
  def delete_codex_agent(self, agent_id: str, *, purge: bool = False) -> None:
852
1313
  self.codex_agents.delete(agent_id, purge=purge)
1314
+ self._current_codex_builds.pop(agent_id, None)
1315
+ self.invalidate_agent_detail(agent_id)
853
1316
 
854
1317
  def codex_agent_detail(self, agent_id: str | None = None) -> dict:
855
1318
  return self.codex_agents.detail(agent_id)
@@ -885,6 +1348,7 @@ class StudioService:
885
1348
  idempotency_key: str,
886
1349
  on_event: Callable[[RunEvent], None] | None = None,
887
1350
  ) -> Operation:
1351
+ self._require_direct_session(session_id)
888
1352
  return self.codex_agents.submit_run(
889
1353
  build_id,
890
1354
  user_input,
@@ -903,16 +1367,23 @@ class StudioService:
903
1367
  async def delete_session(self, session_id: str) -> None:
904
1368
  from ksadk.studio.errors import not_found
905
1369
 
1370
+ self._require_direct_session(session_id)
906
1371
  runs = self.event_store.list_runs(session_id=session_id)
907
- if not runs:
1372
+ session = await self.session_service.get_session_metadata(session_id)
1373
+ if not runs and session is None:
908
1374
  raise not_found("session", session_id)
909
- if any(run.status == RunStatus.RUNNING for run in runs):
910
- raise StudioError(
911
- "SESSION_RUN_ACTIVE",
912
- "会话仍在运行,请先停止运行后再删除",
913
- status_code=409,
914
- details={"sessionId": session_id},
915
- )
1375
+ # 磁盘停在 RUNNING 的 run 只有仍在本进程内执行时才阻止删除;
1376
+ # 崩溃/重启遗留的僵尸 RUNNING 一律回收为 canceled 后放行删除。
1377
+ for run in runs:
1378
+ if run.status == RunStatus.RUNNING:
1379
+ if self.run_service.is_run_executing(run.id):
1380
+ raise StudioError(
1381
+ "SESSION_RUN_ACTIVE",
1382
+ "会话仍在运行,请先停止运行后再删除",
1383
+ status_code=409,
1384
+ details={"sessionId": session_id},
1385
+ )
1386
+ await self.run_service.reap_stale_running_run(run.id)
916
1387
  await self.plugin_runs.close_session(session_id)
917
1388
  await self.session_service.delete_session(session_id)
918
1389
  self.event_store.delete_session(session_id)
@@ -920,11 +1391,63 @@ class StudioService:
920
1391
  async def aclose(self) -> None:
921
1392
  """Release local provider activations and supervised plugin processes."""
922
1393
 
923
- await self.plugin_runs.aclose()
1394
+ async with self._start_lock:
1395
+ if self._closed:
1396
+ return
1397
+ if self._dsh_startup_task is not None and not self._dsh_startup_task.done():
1398
+ self._dsh_startup_task.cancel()
1399
+ self._closed = True
1400
+ cleanup = asyncio.create_task(self._close_owned_plugin_services())
1401
+ interrupted = False
1402
+ while not cleanup.done():
1403
+ try:
1404
+ await asyncio.shield(cleanup)
1405
+ except asyncio.CancelledError:
1406
+ interrupted = True
1407
+ cleanup.result()
1408
+ if interrupted:
1409
+ raise asyncio.CancelledError
1410
+
1411
+ async def _close_owned_plugin_services(self) -> None:
1412
+ from ksadk.studio.provider_recovery import detach_recovered_runs
1413
+
1414
+ await detach_recovered_runs(self.run_service)
1415
+ first_error: BaseException | None = None
1416
+ owned = [
1417
+ self.channel_connections.close,
1418
+ self.workspace_plugins.close, self.plugin_runs.aclose, self.dsh_capabilities.aclose,
1419
+ self.scheduler_runtimes.close, self.execution_host.close,
1420
+ ]
1421
+ # The model client owns a keep-alive connection pool shared by all
1422
+ # turns. Close it with the Studio service so shutdown remains clean.
1423
+ close_model_client = getattr(self.model_client, "aclose", None)
1424
+ if close_model_client is not None:
1425
+ owned.append(close_model_client)
1426
+ if self.resource_dsh_capabilities is not self.dsh_capabilities:
1427
+ owned.append(self.resource_dsh_capabilities.aclose)
924
1428
  if self._dsh_provider_registration_manager is not None:
925
- await self._dsh_provider_registration_manager.aclose()
1429
+ owned.append(self._dsh_provider_registration_manager.aclose)
1430
+ if self._resource_dsh_provider_registration_manager is not None:
1431
+ owned.append(self._resource_dsh_provider_registration_manager.aclose)
1432
+ for close in owned:
1433
+ try:
1434
+ await close()
1435
+ except BaseException as error: # cleanup must continue
1436
+ if first_error is None:
1437
+ first_error = error
1438
+ if first_error is not None:
1439
+ raise first_error
1440
+
1441
+ def _ensure_open(self) -> None:
1442
+ if self._closed:
1443
+ raise StudioError(
1444
+ "STUDIO_SERVICE_CLOSED",
1445
+ "Studio service 已关闭",
1446
+ status_code=503,
1447
+ )
926
1448
 
927
1449
  async def _require_runtime_session(self, session_id: str) -> None:
1450
+ self._require_direct_session(session_id)
928
1451
  if await self.session_service.get_session_metadata(session_id) is None:
929
1452
  raise StudioError(
930
1453
  "SESSION_NOT_FOUND",
@@ -1447,17 +1970,29 @@ class StudioService:
1447
1970
  return values[:limit]
1448
1971
 
1449
1972
  def agent_detail(self, agent_id: str) -> dict:
1973
+ cached = self._agent_detail_cache.get(agent_id)
1974
+ if cached and cached[0] > time.monotonic():
1975
+ return cached[1]
1450
1976
  if self.is_codex_agent(agent_id):
1451
1977
  detail = self.codex_agent_detail(agent_id)
1452
1978
  detail["soulProjection"] = self._soul_projection(detail["draft"])
1453
- return detail
1454
- draft = self.drafts.get(agent_id)
1455
- return {
1456
- "draft": draft,
1457
- "builds": self.builds.list_for_agent(agent_id)[:10],
1458
- "validation": self.validator.validate(draft),
1459
- "soulProjection": self._soul_projection(draft),
1460
- }
1979
+ else:
1980
+ draft = self.drafts.get(agent_id)
1981
+ detail = {
1982
+ "draft": draft,
1983
+ "builds": self.builds.list_for_agent(agent_id)[:10],
1984
+ "validation": self.validator.validate(draft),
1985
+ "soulProjection": self._soul_projection(draft),
1986
+ }
1987
+ self._agent_detail_cache[agent_id] = (time.monotonic() + self._agent_detail_ttl, detail)
1988
+ return detail
1989
+
1990
+ def invalidate_agent_detail(self, agent_id: str | None = None) -> None:
1991
+ """Invalidate cached agent_detail after create/update/delete/build."""
1992
+ if agent_id is None:
1993
+ self._agent_detail_cache.clear()
1994
+ else:
1995
+ self._agent_detail_cache.pop(agent_id, None)
1461
1996
 
1462
1997
  @staticmethod
1463
1998
  def _soul_projection(draft: AgentDraft) -> dict[str, object]:
@@ -1498,6 +2033,8 @@ class StudioService:
1498
2033
  )
1499
2034
  selected = runtime or resolved_spec.runtime
1500
2035
  resolved_spec.runtime = selected
2036
+ if selected is not None and selected.type == "harness" and spec is None:
2037
+ resolved_spec = with_harness_provider_permissions(resolved_spec)
1501
2038
  if selected is not None and selected.type == "codex":
1502
2039
  return cast(
1503
2040
  AgentDraft,
@@ -1508,7 +2045,7 @@ class StudioService:
1508
2045
  labels=labels,
1509
2046
  ),
1510
2047
  )
1511
- return cast(
2048
+ created = cast(
1512
2049
  AgentDraft,
1513
2050
  self.create_agent(
1514
2051
  agent_id=agent_id,
@@ -1519,6 +2056,8 @@ class StudioService:
1519
2056
  labels=labels,
1520
2057
  ),
1521
2058
  )
2059
+ self.invalidate_agent_detail(agent_id)
2060
+ return created
1522
2061
 
1523
2062
  def update_studio_agent(
1524
2063
  self,
@@ -1590,17 +2129,21 @@ class StudioService:
1590
2129
  appearance,
1591
2130
  expected_revision=expected_revision,
1592
2131
  )
1593
- return self.drafts.update_appearance(
2132
+ updated = self.drafts.update_appearance(
1594
2133
  agent_id,
1595
2134
  appearance,
1596
2135
  expected_revision=expected_revision,
1597
2136
  )
2137
+ self.invalidate_agent_detail(agent_id)
2138
+ return updated
1598
2139
 
1599
2140
  def delete_studio_agent(self, agent_id: str, *, purge: bool = False) -> None:
1600
2141
  if self.is_codex_agent(agent_id):
1601
2142
  self.delete_codex_agent(agent_id, purge=purge)
2143
+ self.invalidate_agent_detail(agent_id)
1602
2144
  return
1603
2145
  delete_framework_agent(self, agent_id, purge=purge)
2146
+ self.invalidate_agent_detail(agent_id)
1604
2147
 
1605
2148
  def validate_studio_agent(
1606
2149
  self,
@@ -1623,6 +2166,88 @@ class StudioService:
1623
2166
  return detail["validation"]
1624
2167
  return self.validator.validate(draft, level=level)
1625
2168
 
2169
+ async def resource_binding_status(self, agent_id: str, *, activation_id: str) -> dict:
2170
+ # Check workspace ownership, but never project the mutable draft as runtime state.
2171
+ await asyncio.to_thread(self.agent_detail, agent_id)
2172
+ status = await self.dsh_capabilities.resource_runtime_status(
2173
+ agent_id=agent_id,
2174
+ activation_id=activation_id,
2175
+ )
2176
+ if status is None:
2177
+ raise StudioError(
2178
+ "RESOURCE_ACTIVATION_NOT_FOUND",
2179
+ "未找到此 Agent 的资源运行实例",
2180
+ status_code=404,
2181
+ )
2182
+ return status
2183
+
2184
+ def validate_resource_bindings(self, agent_id: str, *, expected_revision: int) -> dict:
2185
+ from ksadk.resource_runtime.plugin_config import resource_plugin_config
2186
+ from ksadk.studio.resource_binding_validation import resource_binding_diagnostics
2187
+
2188
+ draft = self.agent_detail(agent_id)["draft"]
2189
+ if draft.metadata.revision != expected_revision:
2190
+ raise StudioError(
2191
+ "AGENT_REVISION_CONFLICT",
2192
+ "资源校验版本与当前 Agent 不一致",
2193
+ status_code=409,
2194
+ )
2195
+ diagnostics = resource_binding_diagnostics(
2196
+ draft.spec.bindings.plugins,
2197
+ draft.spec.memory,
2198
+ self.resource_connections,
2199
+ )
2200
+ configs = [
2201
+ (index, config)
2202
+ for index, binding in enumerate(draft.spec.bindings.plugins)
2203
+ if binding.enabled
2204
+ for config in [
2205
+ resource_plugin_config(
2206
+ binding.plugin_ref,
2207
+ binding.ecosystem,
2208
+ binding.config,
2209
+ enabled=True,
2210
+ )
2211
+ ]
2212
+ if config is not None
2213
+ ]
2214
+ verified = []
2215
+ if (
2216
+ self.resource_authority is not None
2217
+ and configs
2218
+ and not any(item.severity == DiagnosticSeverity.ERROR for item in diagnostics)
2219
+ ):
2220
+ for index, config in configs:
2221
+ try:
2222
+ verified.append(self.resource_authority.admit(config))
2223
+ except StudioError as error:
2224
+ diagnostics.append(
2225
+ Diagnostic(
2226
+ severity=DiagnosticSeverity.ERROR,
2227
+ code=error.code,
2228
+ message=error.message,
2229
+ field=error.field or f"spec.bindings.plugins[{index}].config.binding",
2230
+ )
2231
+ )
2232
+ current = self.agent_detail(agent_id)["draft"]
2233
+ if current.metadata.revision != draft.metadata.revision:
2234
+ raise StudioError(
2235
+ "AGENT_REVISION_CONFLICT",
2236
+ "资源校验期间 Agent 已变更,请刷新后重试",
2237
+ status_code=409,
2238
+ )
2239
+ authorization_verified = bool(configs) and len(verified) == len(configs)
2240
+ if authorization_verified:
2241
+ diagnostics = [
2242
+ item for item in diagnostics if item.code != "RESOURCE_AUTHORITY_UNVERIFIED"
2243
+ ]
2244
+ return {
2245
+ "revision": draft.metadata.revision,
2246
+ "valid": not any(item.severity == "error" for item in diagnostics),
2247
+ "authorizationVerified": authorization_verified,
2248
+ "diagnostics": [item.model_dump(by_alias=True, mode="json") for item in diagnostics],
2249
+ }
2250
+
1626
2251
  def submit_studio_build(
1627
2252
  self,
1628
2253
  agent_id: str,
@@ -1685,6 +2310,7 @@ class StudioService:
1685
2310
  runtime_input: Any = None,
1686
2311
  on_event: Callable[[RunEvent], None] | None = None,
1687
2312
  ) -> Operation:
2313
+ self._require_direct_session(session_id)
1688
2314
  try:
1689
2315
  self.codex_builds.get(build_id)
1690
2316
  except Exception as exc:
@@ -1801,12 +2427,14 @@ class StudioService:
1801
2427
  preview,
1802
2428
  catalog=self.catalog,
1803
2429
  )
1804
- return self.drafts.update(
2430
+ updated = self.drafts.update(
1805
2431
  agent_id,
1806
2432
  spec,
1807
2433
  expected_revision=expected_revision,
1808
2434
  name=name,
1809
2435
  )
2436
+ self.invalidate_agent_detail(agent_id)
2437
+ return updated
1810
2438
 
1811
2439
  def update_agent_bindings(
1812
2440
  self,
@@ -1995,6 +2623,7 @@ class StudioService:
1995
2623
  idempotency_key: str,
1996
2624
  on_event: Callable[[RunEvent], None] | None = None,
1997
2625
  ) -> Operation:
2626
+ self._require_direct_session(session_id)
1998
2627
  async def runner(_operation_id: str):
1999
2628
  return await self.run_build(
2000
2629
  build_id,
@@ -2035,6 +2664,7 @@ class StudioService:
2035
2664
  """Execute any immutable Studio Build through the canonical executor."""
2036
2665
 
2037
2666
  await self.start()
2667
+ self._require_direct_session(session_id)
2038
2668
  spec = self.resolve_run_spec(
2039
2669
  build_id,
2040
2670
  model=model,
@@ -2500,6 +3130,12 @@ class StudioService:
2500
3130
  runner=managed_runtime_runner,
2501
3131
  )
2502
3132
 
3133
+ # Do not turn a stale URL or a deleted Agent's Build into an accepted
3134
+ # operation that can only fail later in the worker. The Codex lookup
3135
+ # above intentionally falls back to framework builds, so establish
3136
+ # that the fallback record exists before returning HTTP 202.
3137
+ self.builds.get(build_id)
3138
+
2503
3139
  async def runner(_operation_id: str):
2504
3140
  return await self.cloud.deploy(build_id, request)
2505
3141
 
@@ -2646,41 +3282,68 @@ class StudioService:
2646
3282
  "cloudCredential": opaque(f"{region}\0{access_key}"),
2647
3283
  }
2648
3284
 
3285
+ @staticmethod
3286
+ def frontend_assets() -> dict[str, Any]:
3287
+ import re
3288
+
3289
+ entry = Path(__file__).with_name("static") / "index.html"
3290
+ if not entry.is_file():
3291
+ return {"entryAssets": []}
3292
+ assets = re.findall(
3293
+ r'(?:src|href)="(/static/assets/[^"<>]+\.(?:js|css))"',
3294
+ entry.read_text(encoding="utf-8"),
3295
+ )
3296
+ return {"entryAssets": [Path(asset).name for asset in assets]}
3297
+
2649
3298
  def get_settings(self) -> dict[str, Any]:
2650
- path = self.workspace.resolve(".agentkit/settings.yaml")
2651
- data: dict[str, Any] = {}
2652
- if path.is_file():
2653
- try:
2654
- data = load_yaml_file(path) or {}
2655
- except Exception:
2656
- data = {}
3299
+ data = self.configuration.settings()
3300
+ environment = self.configuration.environment()
2657
3301
  defaults = {
2658
- "sandbox": os.environ.get("KSADK_CODEX_SANDBOX", "read_only"),
3302
+ "sandbox": environment.get("KSADK_CODEX_SANDBOX", "workspace-write-auto"),
2659
3303
  "buildAfterCreate": True,
2660
3304
  "codexProxy": current_proxy_mode(),
2661
- "cloudRegion": os.environ.get(
2662
- "AGENTENGINE_REGION", os.environ.get("KSYUN_REGION", "cn-beijing-6")
3305
+ "cloudRegion": environment.get(
3306
+ "AGENTENGINE_REGION", environment.get("KSYUN_REGION", "cn-beijing-6")
2663
3307
  ),
2664
- "cloudBucket": os.environ.get("KS3_BUCKET", ""),
2665
- "cloudAccountId": (os.environ.get("KSYUN_ACCOUNT_ID", "").strip()),
3308
+ "cloudServerUrl": environment.get("AGENTENGINE_SERVER_URL", ""),
3309
+ "cloudBucket": environment.get("KS3_BUCKET", ""),
3310
+ "cloudAccountId": (environment.get("KSYUN_ACCOUNT_ID", "").strip()),
2666
3311
  # AK/SK 不回显(避免本地 UI 回传 secret);只暴露配置状态。
2667
3312
  # 已配置 = 启动环境或已持久化 settings 里 AK+SK 齐全。
2668
3313
  "cloudAccountConfigured": bool(
2669
- (os.environ.get("KSYUN_ACCESS_KEY") or os.environ.get("KS3_ACCESS_KEY", "")).strip()
3314
+ (
3315
+ environment.get("KSYUN_ACCESS_KEY") or environment.get("KS3_ACCESS_KEY", "")
3316
+ ).strip()
2670
3317
  and (
2671
- os.environ.get("KSYUN_SECRET_KEY") or os.environ.get("KS3_SECRET_KEY", "")
3318
+ environment.get("KSYUN_SECRET_KEY") or environment.get("KS3_SECRET_KEY", "")
2672
3319
  ).strip()
2673
3320
  ),
2674
3321
  "cloudSignedAccountConfigured": bool(
2675
- (os.environ.get("KSYUN_ACCESS_KEY") or os.environ.get("KS3_ACCESS_KEY", "")).strip()
3322
+ (
3323
+ environment.get("KSYUN_ACCESS_KEY") or environment.get("KS3_ACCESS_KEY", "")
3324
+ ).strip()
2676
3325
  and (
2677
- os.environ.get("KSYUN_SECRET_KEY") or os.environ.get("KS3_SECRET_KEY", "")
3326
+ environment.get("KSYUN_SECRET_KEY") or environment.get("KS3_SECRET_KEY", "")
2678
3327
  ).strip()
2679
3328
  ),
2680
- "traceContent": os.environ.get("KSADK_STUDIO_TRACE_CONTENT", "1") != "0",
3329
+ "traceContent": environment.get("KSADK_STUDIO_TRACE_CONTENT", "1") != "0",
2681
3330
  }
2682
3331
  defaults.update({k: v for k, v in data.items() if k in defaults and v is not None})
2683
- defaults["codexProxy"] = normalize_proxy_mode(defaults.get("codexProxy"))
3332
+ for key, name in SETTINGS_ENV.items():
3333
+ if key in defaults:
3334
+ value, _source = self.configuration.resolve(name)
3335
+ if value is not None:
3336
+ defaults[key] = value
3337
+ defaults["configurationSources"] = {
3338
+ key: self.configuration.resolve(name)[1] for key, name in SETTINGS_ENV.items()
3339
+ }
3340
+ defaults["platformResourceMissingFields"] = [
3341
+ key
3342
+ for key in ("cloudAccessKey", "cloudSecretKey", "cloudServerUrl")
3343
+ if not self.configuration.resolve(SETTINGS_ENV[key])[0]
3344
+ ]
3345
+ defaults["platformResourcesConfigured"] = self.resource_authority is not None
3346
+ defaults["codexProxy"] = normalize_proxy_mode(environment.get("KSADK_CODEX_USE_PROXY"))
2684
3347
  return defaults
2685
3348
 
2686
3349
  def update_settings(self, payload: dict[str, Any]) -> dict[str, Any]:
@@ -2690,6 +3353,7 @@ class StudioService:
2690
3353
  "codexProxy",
2691
3354
  "cloudRegion",
2692
3355
  "cloudBucket",
3356
+ "cloudServerUrl",
2693
3357
  "traceContent",
2694
3358
  # 云账号:AK/SK 留空 = 不修改(保留已存值);AccountID 可单独更新。
2695
3359
  "cloudAccessKey",
@@ -2718,35 +3382,102 @@ class StudioService:
2718
3382
  raise StudioError("SETTINGS_INVALID", "sandbox 取值非法", status_code=422)
2719
3383
  if "codexProxy" in data and data["codexProxy"] not in {"auto", "forced", "direct"}:
2720
3384
  raise StudioError("SETTINGS_INVALID", "codexProxy 取值非法", status_code=422)
2721
- path = self.workspace.resolve(".agentkit/settings.yaml")
2722
- self.workspace.atomic_write_yaml(path, data)
2723
- # env 桥接用落盘后的全量数据:局部更新(只改 AccountID)时,
2724
- # 已持久化的 AK/SK 也要继续桥接,否则签名凭证丢失。
3385
+ for key in (
3386
+ "cloudAccessKey",
3387
+ "cloudSecretKey",
3388
+ "cloudAccountId",
3389
+ "cloudRegion",
3390
+ "cloudBucket",
3391
+ "cloudServerUrl",
3392
+ ):
3393
+ if key in data:
3394
+ if (
3395
+ not isinstance(data[key], str)
3396
+ or len(data[key]) > 2048
3397
+ or any(ord(c) < 32 for c in data[key])
3398
+ ):
3399
+ raise StudioError(
3400
+ "SETTINGS_INVALID", "配置值格式无效", status_code=422, field=key
3401
+ )
3402
+ data[key] = data[key].strip()
3403
+ if data.get("cloudServerUrl"):
3404
+ from ksadk.studio.resource_authority import _canonical_endpoint
3405
+
3406
+ try:
3407
+ data["cloudServerUrl"] = _canonical_endpoint(
3408
+ data["cloudServerUrl"],
3409
+ allow_loopback_http=False,
3410
+ allow_ksyun_internal_http=True,
3411
+ )
3412
+ except ValueError as error:
3413
+ raise StudioError(
3414
+ "SETTINGS_INVALID",
3415
+ "控制面地址必须是有效的 HTTPS 服务地址",
3416
+ status_code=422,
3417
+ field="cloudServerUrl",
3418
+ ) from error
3419
+ if (
3420
+ "cloudAccessKey" in data
3421
+ and data["cloudAccessKey"] != self.configuration.resolve("KSYUN_ACCESS_KEY")[0]
3422
+ ):
3423
+ if not data.get("cloudSecretKey"):
3424
+ raise StudioError(
3425
+ "SETTINGS_INVALID",
3426
+ "切换 Access Key 时请同时填写对应的 Secret Key",
3427
+ status_code=422,
3428
+ field="cloudSecretKey",
3429
+ )
3430
+ data.setdefault("cloudAccountId", "")
3431
+ candidate_environment = self.configuration.environment()
3432
+ for key, name in SETTINGS_ENV.items():
3433
+ if key in data and name not in self.configuration.overrides:
3434
+ candidate_environment[name] = str(data[key])
2725
3435
  try:
2726
- persisted = load_yaml_file(path) or {}
2727
- except Exception:
2728
- persisted = data
2729
- self._apply_settings_to_env(persisted if isinstance(persisted, dict) else data)
3436
+ candidate_policy = (
3437
+ self._resource_authority_policy_override
3438
+ or resource_authority_policy_from_environment(candidate_environment)
3439
+ )
3440
+ except ValueError as error:
3441
+ raise StudioError(
3442
+ "SETTINGS_INVALID", "云端连接配置无效,请检查控制面地址和区域", status_code=422
3443
+ ) from error
3444
+ self.plugin_runs.check_configuration_mutable()
3445
+ self.configuration.update_settings(data)
3446
+ self._apply_persisted_settings()
3447
+ self.resource_authority = (
3448
+ SignedKnowledgeResourceAuthority(self.resource_connections, candidate_policy)
3449
+ if candidate_policy is not None
3450
+ else None
3451
+ )
3452
+ self.plugin_runs.replace_resource_authority(self.resource_authority)
2730
3453
  if self._cloud_gateway_override is None:
2731
3454
  self.cloud.gateway = self._configured_cloud_gateway()
2732
3455
  return self.get_settings()
2733
3456
 
2734
- def _apply_persisted_settings(self) -> None:
2735
- """启动时把 settings.yaml 回填到进程环境。
3457
+ async def apply_settings(self, payload: dict[str, Any]) -> dict[str, Any]:
3458
+ """Drain old credentials/leases before making a new account visible."""
3459
+ async with self._start_lock:
3460
+ if self.run_service.has_active_runs():
3461
+ raise StudioError(
3462
+ "SETTINGS_RUNTIME_BUSY", "请等待当前运行结束后再保存设置", status_code=409
3463
+ )
3464
+ try:
3465
+ await self.plugin_runs.suspend_admission()
3466
+ return self.update_settings(payload)
3467
+ finally:
3468
+ await self.plugin_runs.resume_admission()
2736
3469
 
2737
- update_settings 只在 PUT 时桥接 env;重启后 env 丢失,运行解析
2738
- (如 _resolve_sandbox 读 KSADK_CODEX_SANDBOX)会回落默认,表现为
2739
- 「设置页显示 workspace-write-auto,实际运行 read-only」。
2740
- """
2741
- path = self.workspace.resolve(".agentkit/settings.yaml")
2742
- if not path.is_file():
2743
- return
2744
- try:
2745
- data = load_yaml_file(path) or {}
2746
- except Exception:
2747
- return
2748
- if isinstance(data, dict):
2749
- self._apply_settings_to_env(data)
3470
+ def _apply_persisted_settings(self) -> None:
3471
+ data = self.configuration.settings()
3472
+ environment = self.configuration.environment()
3473
+ self._apply_settings_to_env(data)
3474
+ for name in (
3475
+ *SETTINGS_ENV.values(),
3476
+ *self.configuration.dotenv,
3477
+ *self.configuration.overrides,
3478
+ ):
3479
+ if name in environment:
3480
+ os.environ[name] = environment[name]
2750
3481
 
2751
3482
  @staticmethod
2752
3483
  def _apply_settings_to_env(data: dict[str, Any]) -> None:
@@ -2773,34 +3504,43 @@ class StudioService:
2773
3504
  if data.get("cloudAccountId"):
2774
3505
  os.environ["KSYUN_ACCOUNT_ID"] = str(data["cloudAccountId"])
2775
3506
 
2776
- @staticmethod
2777
- def _configured_cloud_gateway() -> CloudDeploymentGateway:
3507
+ def _configured_cloud_gateway(self) -> CloudDeploymentGateway:
2778
3508
  """Compose the existing signed Code deployment path from process-only credentials."""
2779
3509
 
3510
+ environment = self.configuration.environment()
2780
3511
  access_key = (
2781
- os.environ.get("KSYUN_ACCESS_KEY") or os.environ.get("KS3_ACCESS_KEY", "")
3512
+ environment.get("KSYUN_ACCESS_KEY") or environment.get("KS3_ACCESS_KEY", "")
2782
3513
  ).strip()
2783
3514
  secret_key = (
2784
- os.environ.get("KSYUN_SECRET_KEY") or os.environ.get("KS3_SECRET_KEY", "")
3515
+ environment.get("KSYUN_SECRET_KEY") or environment.get("KS3_SECRET_KEY", "")
3516
+ ).strip()
3517
+ configured_region = environment.get(
3518
+ "AGENTENGINE_REGION", environment.get("KSYUN_REGION", "")
2785
3519
  ).strip()
2786
- region = os.environ.get("AGENTENGINE_REGION", os.environ.get("KSYUN_REGION", "")).strip()
2787
- if not all((access_key, secret_key, region)):
3520
+ environment_region = environment.get("KSYUN_REGION", "").strip()
3521
+ logical_region = (
3522
+ "pre-online" if environment_region.lower() == "pre-online" else configured_region
3523
+ )
3524
+ if not all((access_key, secret_key, logical_region)):
2788
3525
  return UnavailableCloudGateway()
2789
3526
  control_client = AgentEngineClient(
2790
- region=region,
3527
+ base_url=environment.get("AGENTENGINE_SERVER_URL") or None,
3528
+ region=logical_region,
2791
3529
  access_key=access_key,
2792
3530
  secret_key=secret_key,
2793
3531
  )
2794
- stream_base_url = os.environ.get("AGENTENGINE_STREAM_SERVER_URL", "").strip()
2795
- if not stream_base_url and region.lower() == "pre-online":
3532
+ is_preonline = logical_region.lower() == "pre-online"
3533
+ stream_base_url = environment.get("AGENTENGINE_STREAM_SERVER_URL", "").strip()
3534
+ if not stream_base_url and is_preonline:
2796
3535
  # The pre-online KOP response path currently buffers SSE until
2797
- # EOF. Its internal Server ingress validates the same V4
2798
- # signature and preserves the RunAgent streaming response.
3536
+ # EOF, and KOP may not yet publish newly deployed native Action
3537
+ # names. Its internal Server ingress validates the same V4
3538
+ # signature for RunAgent, ManagedRuntime, and plugin delivery.
2799
3539
  stream_base_url = "http://agent-api-pre.kspmas-internal.ksyun.com"
2800
3540
  stream_client = (
2801
3541
  AgentEngineClient(
2802
3542
  base_url=stream_base_url,
2803
- region=region,
3543
+ region=logical_region,
2804
3544
  access_key=access_key,
2805
3545
  secret_key=secret_key,
2806
3546
  )
@@ -2808,10 +3548,11 @@ class StudioService:
2808
3548
  else control_client
2809
3549
  )
2810
3550
  return DirectAgentEngineCloudDeploymentGateway(
2811
- region=region,
3551
+ region=logical_region,
2812
3552
  client=control_client,
2813
3553
  stream_client=stream_client,
2814
- bucket=os.environ.get("KS3_BUCKET", "").strip() or None,
3554
+ managed_runtime_client=stream_client if is_preonline else None,
3555
+ bucket=environment.get("KS3_BUCKET", "").strip() or None,
2815
3556
  ks3_credentials={
2816
3557
  "access_key": access_key,
2817
3558
  "secret_key": secret_key,