agentengine-sdk-python 0.8.7__py3-none-any.whl → 0.8.9__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 (285) hide show
  1. {agentengine_sdk_python-0.8.7.dist-info → agentengine_sdk_python-0.8.9.dist-info}/METADATA +22 -20
  2. {agentengine_sdk_python-0.8.7.dist-info → agentengine_sdk_python-0.8.9.dist-info}/RECORD +259 -221
  3. ksadk/__init__.py +2 -1
  4. ksadk/_build_provenance.json +1 -1
  5. ksadk/_mcp_compat.py +305 -0
  6. ksadk/agent.py +29 -0
  7. ksadk/agui/_agent_kernel.py +176 -142
  8. ksadk/agui/agent.py +75 -6
  9. ksadk/agui/hosted.py +343 -0
  10. ksadk/agui/request_identity.py +11 -0
  11. ksadk/agui/routes.py +77 -2
  12. ksadk/builders/code_builder.py +30 -23
  13. ksadk/builders/container_builder.py +5 -5
  14. ksadk/builders/framework_requirements.py +1 -1
  15. ksadk/builders/mcp_builder.py +142 -0
  16. ksadk/builders/project_imports.py +66 -0
  17. ksadk/cli/cmd_mcp.py +1 -1
  18. ksadk/cli/cmd_run.py +6 -4
  19. ksadk/cli/cmd_web.py +12 -0
  20. ksadk/cli/runtime_bootstrap.py +4 -1
  21. ksadk/cli/runtime_logging.py +30 -0
  22. ksadk/common/cloud_headers.py +33 -6
  23. ksadk/compat/adk_compat.py +2 -0
  24. ksadk/compat/adk_stream.py +35 -0
  25. ksadk/configs/env_registry.py +31 -0
  26. ksadk/context_engine/capabilities.py +13 -9
  27. ksadk/conversations/context.py +5 -0
  28. ksadk/conversations/message_projection.py +28 -19
  29. ksadk/conversations/projector.py +6 -0
  30. ksadk/conversations/runtime_compaction.py +6 -2
  31. ksadk/conversations/runtime_input.py +4 -0
  32. ksadk/conversations/runtime_invocation.py +5 -1
  33. ksadk/conversations/runtime_metadata.py +6 -7
  34. ksadk/conversations/runtime_observability.py +1 -0
  35. ksadk/conversations/runtime_payloads.py +5 -1
  36. ksadk/conversations/runtime_persistence.py +23 -0
  37. ksadk/conversations/runtime_preparation.py +128 -5
  38. ksadk/detection/mcp_detector.py +80 -22
  39. ksadk/events/adapters/langgraph.py +53 -1
  40. ksadk/harness/__init__.py +3 -0
  41. ksadk/harness/service_presentation.py +44 -0
  42. ksadk/harness/service_runtime.py +1038 -0
  43. ksadk/interaction/providers/harness.py +9 -4
  44. ksadk/kernel/control.py +16 -22
  45. ksadk/kernel/history_projection.py +191 -58
  46. ksadk/kernel/ingress.py +50 -26
  47. ksadk/kernel/postgres_event_log.py +10 -2
  48. ksadk/kernel/postgres_store.py +81 -2
  49. ksadk/kernel/run_references.py +38 -0
  50. ksadk/kernel/worker.py +2 -2
  51. ksadk/kernel/worker_controls.py +11 -1
  52. ksadk/kernel/worker_identity.py +15 -8
  53. ksadk/knowledge_base/client.py +10 -3
  54. ksadk/mcp_runtime/oauth/_agent.py +77 -9
  55. ksadk/mcp_runtime/oauth/kernel.py +5 -0
  56. ksadk/mcp_runtime/oauth/langgraph.py +47 -15
  57. ksadk/mcp_runtime/oauth/local/broker.py +41 -9
  58. ksadk/mcp_runtime/oauth/local/protocol.py +3 -11
  59. ksadk/mcp_runtime/oauth/local/transport.py +9 -2
  60. ksadk/mcp_runtime/oauth/tools.py +46 -8
  61. ksadk/mcp_runtime/oauth/transport.py +19 -2
  62. ksadk/memory/adk/backends/sdk_ltm_backend.py +21 -12
  63. ksadk/memory/scope_ids.py +49 -0
  64. ksadk/plugins/providers/harness.py +65 -28
  65. ksadk/plugins/providers/harness_service.py +198 -0
  66. ksadk/plugins/providers/harness_service_context.py +175 -0
  67. ksadk/plugins/providers/harness_service_hooks.py +168 -0
  68. ksadk/plugins/providers/harness_service_memory.py +479 -0
  69. ksadk/plugins/providers/platform_resources.py +2 -2
  70. ksadk/resource_runtime/contracts.py +39 -1
  71. ksadk/resource_runtime/langgraph.py +7 -3
  72. ksadk/resource_runtime/managed_projection.py +8 -6
  73. ksadk/resource_runtime/mcp_server.py +3 -3
  74. ksadk/resource_runtime/worker.py +27 -5
  75. ksadk/runners/_adk_canonical_stream.py +53 -24
  76. ksadk/runners/_adk_tunnel_history.py +96 -0
  77. ksadk/runners/_langgraph_answer_contract.py +1 -7
  78. ksadk/runners/_langgraph_canonical_stream.py +29 -6
  79. ksadk/runners/_langgraph_context.py +265 -0
  80. ksadk/runners/_langgraph_factory.py +79 -0
  81. ksadk/runners/_langgraph_model_budget.py +397 -0
  82. ksadk/runners/_langgraph_runner_streams.py +13 -6
  83. ksadk/runners/_session_identity.py +8 -3
  84. ksadk/runners/adk_runner.py +104 -36
  85. ksadk/runners/langgraph_runner.py +145 -29
  86. ksadk/runners/usage_accumulator.py +40 -0
  87. ksadk/runtime/conversation_execution.py +26 -4
  88. ksadk/runtime/factory.py +17 -5
  89. ksadk/runtime/framework_adapters.py +10 -0
  90. ksadk/runtime/langgraph_checkpoint_view.py +28 -7
  91. ksadk/runtime/launch.py +2 -0
  92. ksadk/server/factory.py +58 -1
  93. ksadk/server/routes/common.py +2 -0
  94. ksadk/server/routes/control.py +24 -8
  95. ksadk/server/routes/harness_service_view.py +38 -0
  96. ksadk/server/routes/history_items.py +157 -0
  97. ksadk/server/routes/kernel_ingress.py +51 -12
  98. ksadk/server/routes/local_kernel_control.py +16 -0
  99. ksadk/server/routes/models.py +26 -0
  100. ksadk/server/routes/openai_compat.py +10 -3
  101. ksadk/server/routes/projection.py +4 -0
  102. ksadk/server/routes/run.py +4 -2
  103. ksadk/server/routes/sessions.py +20 -1
  104. ksadk/server/routes/ui_bootstrap.py +16 -2
  105. ksadk/server/static/assets/{ArtifactsPanel-Cdr5C_vM.js → ArtifactsPanel-iZ_6CAQ2.js} +1 -1
  106. ksadk/server/static/assets/{CodeBlock-BWRafud9.js → CodeBlock-D6uglm5n.js} +1 -1
  107. ksadk/server/static/assets/{MathMessageMarkdown-CFKeJIvy.js → MathMessageMarkdown-D6ojdxCG.js} +1 -1
  108. ksadk/server/static/assets/{MermaidBlock-BneAGUOd.js → MermaidBlock-Csk2ivT7.js} +6 -6
  109. ksadk/server/static/assets/{NativeTerminalPanel-BHI85zDO.js → NativeTerminalPanel-CCJA1XSH.js} +1 -1
  110. ksadk/server/static/assets/{OfficialA2uiRenderer-BOmT36lJ.js → OfficialA2uiRenderer-C06jus9N.js} +1 -1
  111. ksadk/server/static/assets/{abnfDiagram-VCTEODGH-DQvlOsBI.js → abnfDiagram-VCTEODGH-BhrF5tmL.js} +1 -1
  112. ksadk/server/static/assets/{arc-CGx0e4pN.js → arc-Btsh3kfy.js} +1 -1
  113. ksadk/server/static/assets/architecture-7GRP2DOG-BSXho3cq.js +1 -0
  114. ksadk/server/static/assets/{architectureDiagram-5GKGNRK7-WyybcNKX.js → architectureDiagram-5GKGNRK7-Cl8MfAmp.js} +1 -1
  115. ksadk/server/static/assets/{blockDiagram-NRAW4CY4-C9Cx_GVs.js → blockDiagram-NRAW4CY4-CeHSr8E_.js} +1 -1
  116. ksadk/server/static/assets/{c4Diagram-UCG6FXSJ-Bh7X3bGr.js → c4Diagram-UCG6FXSJ-BSD7RUKo.js} +1 -1
  117. ksadk/server/static/assets/channel-BpyDVKis.js +1 -0
  118. ksadk/server/static/assets/chunk-2Q5K7J3B-HLcpmPI2.js +1 -0
  119. ksadk/server/static/assets/{chunk-5VM5RSS4-cP9XupZj.js → chunk-5VM5RSS4-wz0pkBjp.js} +1 -1
  120. ksadk/server/static/assets/{chunk-F27PBJKO-Bm77fvR9.js → chunk-F27PBJKO-shjQ7cPM.js} +1 -1
  121. ksadk/server/static/assets/{chunk-G27WJ6UU-DDKNPesQ.js → chunk-G27WJ6UU-DL_MfUsu.js} +1 -1
  122. ksadk/server/static/assets/{chunk-JWPE2WC7-BqiUDB7s.js → chunk-JWPE2WC7-moUdwYpb.js} +1 -1
  123. ksadk/server/static/assets/{chunk-LCL6LL3I-C528mMZy.js → chunk-LCL6LL3I-B3QcDsZM.js} +1 -1
  124. ksadk/server/static/assets/{chunk-POPQ4Y6H-CzZ9g_Uf.js → chunk-POPQ4Y6H-BLBKb48A.js} +1 -1
  125. ksadk/server/static/assets/{chunk-RHFEMEQ7-CXj4tUZ-.js → chunk-RHFEMEQ7-CXR6ZzOx.js} +1 -1
  126. ksadk/server/static/assets/{chunk-SVP7TREG-BHyd85pS.js → chunk-SVP7TREG-DoR8BxkO.js} +1 -1
  127. ksadk/server/static/assets/{chunk-XXDRQBXY-Qe29PHGe.js → chunk-XXDRQBXY-8HJaIq0q.js} +1 -1
  128. ksadk/server/static/assets/classDiagram-DTDB5LWJ-DlNiRtSN.js +1 -0
  129. ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-DlNiRtSN.js +1 -0
  130. ksadk/server/static/assets/{cose-bilkent-JH36ORCC-maRKgeec.js → cose-bilkent-JH36ORCC-DnSSHHqS.js} +1 -1
  131. ksadk/server/static/assets/cynefin-OW5HDTMX-DxNym3qg.js +1 -0
  132. ksadk/server/static/assets/{cynefinDiagram-5FMLGOSQ-CoD0bEvn.js → cynefinDiagram-5FMLGOSQ-4eCi_Rw5.js} +1 -1
  133. ksadk/server/static/assets/{dagre-3AP2YEHR-BkpgQqyW.js → dagre-3AP2YEHR-DpPk9jsh.js} +1 -1
  134. ksadk/server/static/assets/{dagre-BUaTFrYa.js → dagre-G789Mawt.js} +1 -1
  135. ksadk/server/static/assets/{diagram-S7CK7UJ4-25HdTbjE.js → diagram-S7CK7UJ4-7x2FScRJ.js} +1 -1
  136. ksadk/server/static/assets/{diagram-UQ7AKVKN-KO-WqOIg.js → diagram-UQ7AKVKN-DGvliWDD.js} +1 -1
  137. ksadk/server/static/assets/{diagram-VSXAHHWV-B360BkDQ.js → diagram-VSXAHHWV-C0i4uEyS.js} +1 -1
  138. ksadk/server/static/assets/{diagram-VX7I27RA-COr1Oqsg.js → diagram-VX7I27RA-C7SmgIl5.js} +1 -1
  139. ksadk/server/static/assets/{diagram-Z3DM3KII-CgaKrIwB.js → diagram-Z3DM3KII-Xca7TB4U.js} +1 -1
  140. ksadk/server/static/assets/{dist-By-MVndb.js → dist-B3rsrE8r.js} +1 -1
  141. ksadk/server/static/assets/{dist-Bsuusoi0.js → dist-BM6KIyhr.js} +1 -1
  142. ksadk/server/static/assets/{dist-DzdXSBJb.js → dist-BMZKBrmN.js} +1 -1
  143. ksadk/server/static/assets/{dist-DmWw0IXB.js → dist-BUGNcOx8.js} +1 -1
  144. ksadk/server/static/assets/{dist-DXOlCAay.js → dist-BbIN_x76.js} +1 -1
  145. ksadk/server/static/assets/{dist--HftQyp9.js → dist-CGB89Aru.js} +1 -1
  146. ksadk/server/static/assets/{dist-DKG0OYnk.js → dist-CGIWL8mC.js} +1 -1
  147. ksadk/server/static/assets/{dist-DgJ57sRe.js → dist-CHeuPGXZ.js} +1 -1
  148. ksadk/server/static/assets/{dist-_0Xgu_07.js → dist-CMJq3QL-.js} +1 -1
  149. ksadk/server/static/assets/{dist-CwnkOyDn.js → dist-CiUeIDKz.js} +1 -1
  150. ksadk/server/static/assets/{dist-BoRn8a_t.js → dist-CmaZEf5M.js} +1 -1
  151. ksadk/server/static/assets/{dist-BQ116UdZ.js → dist-Cq4qlsg3.js} +1 -1
  152. ksadk/server/static/assets/{dist-CBo9AHUv.js → dist-DDVDyH7h.js} +1 -1
  153. ksadk/server/static/assets/{dist-DSw5Ju6-.js → dist-DDi9q5bO.js} +1 -1
  154. ksadk/server/static/assets/{dist-CxIl4t92.js → dist-DJ8mj6p4.js} +1 -1
  155. ksadk/server/static/assets/{dist-Brbrdmff.js → dist-DRGym1nc.js} +1 -1
  156. ksadk/server/static/assets/{dist-BEbS8Bag.js → dist-DcrTYAeW.js} +1 -1
  157. ksadk/server/static/assets/{dist-C9BTMVwS.js → dist-DpuxDDLa.js} +1 -1
  158. ksadk/server/static/assets/{dist-B3Jp5r1e.js → dist-EFGQ7G_k.js} +1 -1
  159. ksadk/server/static/assets/{dist-HHvdjADB.js → dist-IyCF0NNA.js} +1 -1
  160. ksadk/server/static/assets/{dist-Bxcu8Ca0.js → dist-Ny95vkRV.js} +1 -1
  161. ksadk/server/static/assets/{dist-CR61WJFC.js → dist-s5cohO5C.js} +1 -1
  162. ksadk/server/static/assets/{ebnfDiagram-PWID7BFC-DogDP2db.js → ebnfDiagram-PWID7BFC-DNwVczAJ.js} +1 -1
  163. ksadk/server/static/assets/{erDiagram-SSCWMZ5O-CeBDnUjR.js → erDiagram-SSCWMZ5O-OxFlhx6v.js} +1 -1
  164. ksadk/server/static/assets/eventmodeling-NTZA5JFV-C-gXDupK.js +1 -0
  165. ksadk/server/static/assets/flowDiagram-A5DVABFB-CkpCYD4e.js +1 -0
  166. ksadk/server/static/assets/{ganttDiagram-EL5Y4UJY-oIQL3MCp.js → ganttDiagram-EL5Y4UJY-D4krNgUz.js} +1 -1
  167. ksadk/server/static/assets/gitGraph-4MIJSDKK-0RSkEgC5.js +1 -0
  168. ksadk/server/static/assets/{gitGraphDiagram-WWUBYQGX-B7qz0cmZ.js → gitGraphDiagram-WWUBYQGX-BUSVPN1s.js} +1 -1
  169. ksadk/server/static/assets/index-B9UP7He9.css +2 -0
  170. ksadk/server/static/assets/index-COn4kn-G.js +1135 -0
  171. ksadk/server/static/assets/info-A6RAGUB7-C6KX7WO4.js +1 -0
  172. ksadk/server/static/assets/{infoDiagram-RXCK75RN-yQRC41Ya.js → infoDiagram-RXCK75RN-b6w3u3-O.js} +1 -1
  173. ksadk/server/static/assets/{ishikawaDiagram-5VMMS53U-BCu4HiwL.js → ishikawaDiagram-5VMMS53U-CsC7gzRt.js} +1 -1
  174. ksadk/server/static/assets/{journeyDiagram-EYS64GPL-JaqmO73K.js → journeyDiagram-EYS64GPL-BATLNoy1.js} +1 -1
  175. ksadk/server/static/assets/{kanban-definition-3QL26DDD-DQo4X8NO.js → kanban-definition-3QL26DDD-C49zL_s0.js} +1 -1
  176. ksadk/server/static/assets/{katex-t_DWylQw.js → katex-CDVgGGy2.js} +1 -1
  177. ksadk/server/static/assets/{linear-DWdnI35B.js → linear-DkyDumSy.js} +1 -1
  178. ksadk/server/static/assets/{mermaid-parser.core-BHrT2Pfe.js → mermaid-parser.core-BDX-LqSy.js} +2 -2
  179. ksadk/server/static/assets/{mindmap-definition-FBJOCRG2-PBVAhZYV.js → mindmap-definition-FBJOCRG2-DRPnzL2n.js} +1 -1
  180. ksadk/server/static/assets/packet-AYTQ26CC-CMMupxPW.js +1 -0
  181. ksadk/server/static/assets/{pegDiagram-XKGWAZYB-CU_cLfow.js → pegDiagram-XKGWAZYB-Zm-xrNrr.js} +1 -1
  182. ksadk/server/static/assets/pie-WAS4IAKB-Bfo0pa9v.js +1 -0
  183. ksadk/server/static/assets/{pieDiagram-E7YTZNPT-B1h0-_pW.js → pieDiagram-E7YTZNPT-a8C1Jxo4.js} +1 -1
  184. ksadk/server/static/assets/{quadrantDiagram-AXDQQJYC-DEMoGo5a.js → quadrantDiagram-AXDQQJYC-ihH8znBv.js} +1 -1
  185. ksadk/server/static/assets/radar-RG4KPBEZ-PRBiHoJx.js +1 -0
  186. ksadk/server/static/assets/railroad-74A4TZTK-BCJ-XMRJ.js +1 -0
  187. ksadk/server/static/assets/railroad-abnf-HS5TGJTU-Bbttj0Jz.js +1 -0
  188. ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-Bo18264J.js +1 -0
  189. ksadk/server/static/assets/railroad-peg-WCYAUIDC-xZDJTFLD.js +1 -0
  190. ksadk/server/static/assets/{railroadDiagram-O6MQD6OU-BTAob2wg.js → railroadDiagram-O6MQD6OU-DD9lFfXo.js} +1 -1
  191. ksadk/server/static/assets/{requirementDiagram-EFPCY7ZU-Dl0Q2SuO.js → requirementDiagram-EFPCY7ZU-CGn93Iyb.js} +1 -1
  192. ksadk/server/static/assets/{sankeyDiagram-P5KCCOFB-DeaTWkur.js → sankeyDiagram-P5KCCOFB-BuyjrHuW.js} +1 -1
  193. ksadk/server/static/assets/{sequenceDiagram-WJ2MYXX4-gFQYrsOd.js → sequenceDiagram-WJ2MYXX4-D-Iw-30A.js} +1 -1
  194. ksadk/server/static/assets/{sizeCapture-X5ZJPWSS-pGQzddMB.js → sizeCapture-X5ZJPWSS-B0EHLwrD.js} +1 -1
  195. ksadk/server/static/assets/{stateDiagram-HBIQ2CUA-DmpYOZt1.js → stateDiagram-HBIQ2CUA-k9Zyg69R.js} +1 -1
  196. ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-tUEVnq9-.js +1 -0
  197. ksadk/server/static/assets/{swimlanes-XN3QIQJK-BfuSAsrr.js → swimlanes-XN3QIQJK-D2BewKmp.js} +1 -1
  198. ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-CGBmsrCQ.js +8 -0
  199. ksadk/server/static/assets/{timeline-definition-24CTP7MA-CgJwrrxf.js → timeline-definition-24CTP7MA-czSzsYbz.js} +1 -1
  200. ksadk/server/static/assets/treeView-Q6P3EWNA-CrEvfC8M.js +1 -0
  201. ksadk/server/static/assets/treemap-WGGIJYW6-D1TmShtn.js +1 -0
  202. ksadk/server/static/assets/{vennDiagram-4TSXK5OY-CBSAgXDd.js → vennDiagram-4TSXK5OY-BJF_qZLF.js} +1 -1
  203. ksadk/server/static/assets/wardley-WFR3VGLG-0gZiSyL0.js +1 -0
  204. ksadk/server/static/assets/{wardleyDiagram-VM6X3IG4-013TZ2JZ.js → wardleyDiagram-VM6X3IG4-BfwUuJpr.js} +1 -1
  205. ksadk/server/static/assets/{xychartDiagram-S5SC5T6Z-u6Frp8xp.js → xychartDiagram-S5SC5T6Z-Ci6Nsp4p.js} +1 -1
  206. ksadk/server/static/index.html +2 -2
  207. ksadk/server/static/ui-source.json +6 -6
  208. ksadk/sessions/_postgres_history_backfill.py +80 -0
  209. ksadk/sessions/_postgres_schema.py +117 -0
  210. ksadk/sessions/_postgres_tables.py +6 -0
  211. ksadk/sessions/base.py +24 -0
  212. ksadk/sessions/history_tool_refs.py +244 -0
  213. ksadk/sessions/in_memory.py +42 -0
  214. ksadk/sessions/local_service.py +78 -0
  215. ksadk/sessions/model_history.py +20 -0
  216. ksadk/sessions/postgres_service.py +215 -19
  217. ksadk/sessions/resilient.py +24 -0
  218. ksadk/skills/mcp_server/server.py +239 -217
  219. ksadk/studio/contracts.py +8 -0
  220. ksadk/studio/mcp_runtime.py +23 -8
  221. ksadk/studio/native_mcp_disclosure.py +8 -6
  222. ksadk/studio/native_mcp_tool_port.py +3 -1
  223. ksadk/studio/native_memory_context.py +10 -8
  224. ksadk/studio/native_product.py +3 -4
  225. ksadk/studio/plugin_composition.py +8 -1
  226. ksadk/studio/plugin_native_activation.py +4 -2
  227. ksadk/studio/plugin_runtime.py +9 -0
  228. ksadk/studio/service.py +2 -0
  229. ksadk/studio/static/assets/{ChannelsPage-Do_mRmVu.js → ChannelsPage-Ot9iV_QP.js} +1 -1
  230. ksadk/studio/static/assets/{CodeBlock-DMIf4h33-CsO7rJKv.js → CodeBlock-DMIf4h33-Cfs6se0v.js} +1 -1
  231. ksadk/studio/static/assets/{MathMessageMarkdown-BesSeCYl-CiB60plG.js → MathMessageMarkdown-BesSeCYl-BIBDiQAl.js} +1 -1
  232. ksadk/studio/static/assets/{MessageMarkdown-CwMTvgFj-BzEmQkHH.js → MessageMarkdown-CwMTvgFj-CWM4n-9K.js} +2 -2
  233. ksadk/studio/static/assets/{OfficialA2uiRenderer-DI49Kpxu-BBxfdj3P.js → OfficialA2uiRenderer-DI49Kpxu-BZSumE9D.js} +1 -1
  234. ksadk/studio/static/assets/{TeamsPage-qNVYpcox.js → TeamsPage-CVOpMIMf.js} +2 -2
  235. ksadk/studio/static/assets/index-CW1D-Kqg.css +2 -0
  236. ksadk/studio/static/assets/index-DMexeQ1-.js +1155 -0
  237. ksadk/studio/static/index.html +3 -3
  238. ksadk/studio/static/ui-source.json +6 -6
  239. ksadk/tracing/setup.py +53 -3
  240. ksadk/tunnel/__init__.py +37 -0
  241. ksadk/tunnel/connector.py +384 -0
  242. ksadk/tunnel/discovery.py +107 -0
  243. ksadk/tunnel/failure.py +168 -0
  244. ksadk/tunnel/http_tools.py +100 -0
  245. ksadk/tunnel/langgraph.py +125 -0
  246. ksadk/tunnel/middleware.py +28 -0
  247. ksadk/tunnel/peers.py +872 -0
  248. ksadk/tunnel/protocol.py +97 -0
  249. ksadk/tunnel/registry.py +306 -0
  250. ksadk/tunnel/runtime.py +147 -0
  251. ksadk/tunnel/server.py +201 -0
  252. ksadk/tunnel/services.py +366 -0
  253. ksadk/tunnel/toolset.py +78 -0
  254. ksadk/version.py +1 -1
  255. ksadk_runtime_common/memory_backend/providers/mem0.py +20 -0
  256. ksadk/server/static/assets/architecture-7GRP2DOG-CFWjFkDL.js +0 -1
  257. ksadk/server/static/assets/channel-D6Dp_l74.js +0 -1
  258. ksadk/server/static/assets/chunk-2Q5K7J3B-CwmjhFYK.js +0 -1
  259. ksadk/server/static/assets/classDiagram-DTDB5LWJ-DsbvkCAV.js +0 -1
  260. ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-DsbvkCAV.js +0 -1
  261. ksadk/server/static/assets/cynefin-OW5HDTMX-CBZRVuc4.js +0 -1
  262. ksadk/server/static/assets/eventmodeling-NTZA5JFV-vXZWMkpn.js +0 -1
  263. ksadk/server/static/assets/flowDiagram-A5DVABFB-5LRgzKLv.js +0 -1
  264. ksadk/server/static/assets/gitGraph-4MIJSDKK-BUWSkncI.js +0 -1
  265. ksadk/server/static/assets/index-4g1ndaxW.js +0 -1132
  266. ksadk/server/static/assets/index-DEVfafsU.css +0 -2
  267. ksadk/server/static/assets/info-A6RAGUB7-CzJ_YrOs.js +0 -1
  268. ksadk/server/static/assets/packet-AYTQ26CC-CXoos6fx.js +0 -1
  269. ksadk/server/static/assets/pie-WAS4IAKB-CjF9NoIt.js +0 -1
  270. ksadk/server/static/assets/radar-RG4KPBEZ-BQGWs9nw.js +0 -1
  271. ksadk/server/static/assets/railroad-74A4TZTK-B6znvLUK.js +0 -1
  272. ksadk/server/static/assets/railroad-abnf-HS5TGJTU-Bzquz0As.js +0 -1
  273. ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-1IikGkb5.js +0 -1
  274. ksadk/server/static/assets/railroad-peg-WCYAUIDC-BKKgHzdc.js +0 -1
  275. ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-Dolxgkw3.js +0 -1
  276. ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-BuI1erYj.js +0 -8
  277. ksadk/server/static/assets/treeView-Q6P3EWNA-DtMdDH8N.js +0 -1
  278. ksadk/server/static/assets/treemap-WGGIJYW6-VoU8QtLZ.js +0 -1
  279. ksadk/server/static/assets/wardley-WFR3VGLG-YWSRB0Zm.js +0 -1
  280. ksadk/studio/static/assets/index-Cp9Unfkn.css +0 -2
  281. ksadk/studio/static/assets/index-HepnaEeR.js +0 -1152
  282. {agentengine_sdk_python-0.8.7.dist-info → agentengine_sdk_python-0.8.9.dist-info}/WHEEL +0 -0
  283. {agentengine_sdk_python-0.8.7.dist-info → agentengine_sdk_python-0.8.9.dist-info}/entry_points.txt +0 -0
  284. {agentengine_sdk_python-0.8.7.dist-info → agentengine_sdk_python-0.8.9.dist-info}/licenses/LICENSE +0 -0
  285. {agentengine_sdk_python-0.8.7.dist-info → agentengine_sdk_python-0.8.9.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,265 @@
1
+ """New-turn message assembly for native LangGraph message graphs.
2
+
3
+ The graph schema and model nodes remain unchanged. Only a new root input may
4
+ replace messages; Command/resume paths never call this module.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import operator
10
+ from typing import Any, get_origin
11
+
12
+ TURN_KEY = "ksadk_invocation_id"
13
+
14
+
15
+ def standard_messages(graph: Any) -> bool:
16
+ from langgraph.channels.last_value import LastValue
17
+ from langgraph.graph.message import add_messages
18
+
19
+ channel = getattr(graph, "channels", {}).get("messages")
20
+ return getattr(channel, "operator", None) in (add_messages, operator.add) or (
21
+ type(channel) is LastValue and (channel.typ is list or get_origin(channel.typ) is list)
22
+ )
23
+
24
+
25
+ def framework_summary(graph: Any) -> bool:
26
+ # DeepAgents keeps a cutoff into its raw messages. Replacing that list would
27
+ # invalidate the cutoff. LangChain's explicit middleware also owns its summary.
28
+ return "_summarization_event" in getattr(graph, "channels", {}) or any(
29
+ str(name).startswith("SummarizationMiddleware.") for name in getattr(graph, "nodes", {})
30
+ )
31
+
32
+
33
+ async def checkpoint_messages(graph: Any, config: dict) -> list:
34
+ from langchain_core.messages import convert_to_messages
35
+
36
+ from ksadk.runtime.langgraph_checkpoint_view import _FRESH_READ, fresh_checkpoint_view
37
+
38
+ saver = getattr(graph, "checkpointer", None)
39
+ if not saver or getattr(saver, "_ksadk_resume_only", False):
40
+ return []
41
+ # A preparatory read must not consume the graph execution's fresh-turn read.
42
+ # Use the existing orphan-tool repair on a copy, never update an old checkpoint.
43
+ token = _FRESH_READ.set({"used": False})
44
+ try:
45
+ if not standard_messages(graph):
46
+ # DeepAgents can use a DeltaChannel; its persisted value is a
47
+ # sentinel, so let LangGraph reconstruct it through the public API.
48
+ snapshot = await graph.aget_state(config)
49
+ return convert_to_messages(snapshot.values.get("messages", []))
50
+ saved = await saver.aget_tuple(config)
51
+ saved = fresh_checkpoint_view(config, saved)
52
+ return (
53
+ convert_to_messages(saved.checkpoint.get("channel_values", {}).get("messages", []))
54
+ if saved
55
+ else []
56
+ )
57
+ finally:
58
+ _FRESH_READ.reset(token)
59
+
60
+
61
+ def text_history(history: list) -> list:
62
+ from langchain_core.messages import AIMessage, HumanMessage
63
+
64
+ messages = []
65
+ for row in history:
66
+ content = row.get("content", "")
67
+ if isinstance(content, str) and content.startswith(
68
+ ("[tool_call]", "[tool_result]", "[approval_request]", "[approval_response]")
69
+ ):
70
+ continue
71
+ if row.get("role") == "user":
72
+ messages.append(HumanMessage(content=content))
73
+ elif row.get("role") in ("model", "assistant"):
74
+ messages.append(AIMessage(content=content))
75
+ return messages
76
+
77
+
78
+ def current_hook_messages(messages: list, histories: list[list], user_input: Any) -> list:
79
+ """Remove only a known history prefix from an existing prepare-state hook.
80
+
81
+ The hook still receives its original history for business field mapping.
82
+ Content equality is used for this prefix only, never to deduplicate real turns.
83
+ """
84
+ from langchain_core.messages import SystemMessage, convert_to_messages
85
+
86
+ messages = convert_to_messages(messages)
87
+ start = 0
88
+ while start < len(messages) and isinstance(messages[start], SystemMessage):
89
+ start += 1
90
+ for history in histories:
91
+ prefix = text_history(history)
92
+ if not prefix:
93
+ continue
94
+ signatures = [(m.type, m.content) for m in prefix]
95
+ candidate = messages[start : start + len(prefix)]
96
+ if [(m.type, m.content) for m in candidate] != signatures:
97
+ continue
98
+ end = start + len(prefix)
99
+ # Legacy SDK history includes the current user event. Some hooks use
100
+ # that list directly instead of appending the current input once more.
101
+ if (
102
+ end == len(messages)
103
+ and candidate[-1].type == "human"
104
+ and candidate[-1].content == user_input
105
+ ):
106
+ end -= 1
107
+ return [*messages[:start], *messages[end:]]
108
+ return messages
109
+
110
+
111
+ def effective_history(context: dict, saved: list) -> list:
112
+ """Keep native tool/content blocks for retained turns when a saver has them."""
113
+ from langchain_core.messages import SystemMessage
114
+
115
+ previous = []
116
+ groups: dict[str, list] = {}
117
+ turn = ""
118
+ for message in saved:
119
+ if isinstance(message, SystemMessage) and message.response_metadata.get(TURN_KEY):
120
+ continue # Request policy/ambient context is rebuilt for the new turn.
121
+ marker = message.response_metadata.get(TURN_KEY)
122
+ if marker:
123
+ turn = marker
124
+ if turn == context.get("invocation_id"):
125
+ break # A retry must not append its current input again.
126
+ previous.append(message)
127
+ if turn:
128
+ groups.setdefault(turn, []).append(message)
129
+ rows = context.get("history") or []
130
+ turns = context.get("turns") or []
131
+ last_native_turn = next(reversed(groups), None)
132
+ last_session_turn = turns[-1]["invocation_id"] if turns else None
133
+ native_text = [
134
+ (m.type, m.content)
135
+ for m in previous
136
+ if m.type in {"human", "ai"} and m.content and not getattr(m, "tool_calls", None)
137
+ ]
138
+ session_text = [(m.type, m.content) for m in text_history(rows)]
139
+ if (
140
+ context.get("uncompacted")
141
+ and previous
142
+ and (
143
+ not rows
144
+ or native_text == session_text
145
+ or (last_native_turn is not None and last_native_turn == last_session_turn)
146
+ )
147
+ ):
148
+ # Preserve checkpoint-only history as well, e.g. after a local session
149
+ # store restart. No raw prefix has been replaced by an SDK summary yet.
150
+ return previous
151
+
152
+ # Application-owned system messages may live in checkpoint state; they are
153
+ # not part of the SDK transcript summary and must remain available.
154
+ result = [m for m in previous if isinstance(m, SystemMessage)]
155
+ cursor = 0
156
+ for retained in turns:
157
+ expected = retained["history"]
158
+ native = groups.get(retained["invocation_id"])
159
+ if not native or not expected:
160
+ continue
161
+ for index in range(cursor, len(rows) - len(expected) + 1):
162
+ if rows[index : index + len(expected)] == expected:
163
+ result.extend(text_history(rows[cursor:index]))
164
+ result.extend(m for m in native if not isinstance(m, SystemMessage))
165
+ cursor = index + len(expected)
166
+ break
167
+ result.extend(text_history(rows[cursor:]))
168
+ return result
169
+
170
+
171
+ def merge_hook_current(
172
+ sdk_messages: list, hook_messages: Any, user_input: Any, histories: list[list]
173
+ ) -> list:
174
+ """Keep hook policy and its final user input; SDK supplies prior history."""
175
+ from copy import deepcopy
176
+
177
+ from langchain_core.messages import HumanMessage, SystemMessage, convert_to_messages
178
+ from langgraph.types import Overwrite
179
+
180
+ result = deepcopy(sdk_messages)
181
+ if isinstance(hook_messages, Overwrite):
182
+ hook_messages = hook_messages.value
183
+ if not isinstance(hook_messages, (list, tuple)):
184
+ return result
185
+ try:
186
+ supplied = convert_to_messages(hook_messages)
187
+ except (TypeError, ValueError, NotImplementedError):
188
+ return result
189
+
190
+ def text(content):
191
+ if isinstance(content, str):
192
+ return content
193
+ if isinstance(content, list):
194
+ return "\n".join(
195
+ part["text"]
196
+ for part in content
197
+ if isinstance(part, dict)
198
+ and part.get("type") in {"text", "input_text"}
199
+ and isinstance(part.get("text"), str)
200
+ )
201
+ return None
202
+
203
+ def has_input_block(content, expected):
204
+ return isinstance(content, list) and any(
205
+ isinstance(part, dict)
206
+ and part.get("type") in {"text", "input_text"}
207
+ and part.get("text") in expected
208
+ for part in content
209
+ )
210
+
211
+ policies = [m for m in result if isinstance(m, SystemMessage)]
212
+ for message in supplied:
213
+ if isinstance(message, SystemMessage) and not any(
214
+ m.content == message.content for m in policies
215
+ ):
216
+ policies.append(deepcopy(message))
217
+ current = [m for m in result if not isinstance(m, SystemMessage)]
218
+ # Legacy hooks may translate the current question or return image-only
219
+ # content. Their final user message is the current-input contract; requiring
220
+ # equality with the original request would silently discard that behavior.
221
+ # A completed historical turn (ending in AI/tool output) is never current.
222
+ if current and isinstance(current[-1], HumanMessage):
223
+ original = current[-1]
224
+ expected = {
225
+ value
226
+ for value in (text(original.content), user_input)
227
+ if isinstance(value, str) and value
228
+ }
229
+ tail = [m for m in supplied if not isinstance(m, SystemMessage)][-1:]
230
+ match = tail[0] if tail and isinstance(tail[0], HumanMessage) else None
231
+ if match is not None:
232
+ anchored = (
233
+ (original.id is not None and match.id == original.id)
234
+ or text(match.content) in expected
235
+ or has_input_block(match.content, expected)
236
+ )
237
+ # Only an exact known history-only replay can be discarded here.
238
+ # A transformed current input may legitimately equal an older turn.
239
+ body = [(m.type, m.content) for m in supplied if not isinstance(m, SystemMessage)]
240
+ if not anchored and any(
241
+ body == [(m.type, m.content) for m in text_history(history)]
242
+ for history in histories
243
+ if history
244
+ ):
245
+ match = None
246
+ if match is not None:
247
+ replacement = deepcopy(match)
248
+ # Retain SDK-provided attachments even when an old text-only hook
249
+ # knows nothing about the current multimodal request.
250
+ if isinstance(original.content, list):
251
+ blocks = (
252
+ replacement.content
253
+ if isinstance(replacement.content, list)
254
+ else [{"type": "text", "text": replacement.content}]
255
+ )
256
+ for block in original.content:
257
+ if (
258
+ isinstance(block, dict)
259
+ and block.get("type") not in {"text", "input_text"}
260
+ and block not in blocks
261
+ ):
262
+ blocks.append(deepcopy(block))
263
+ replacement = replacement.model_copy(update={"content": blocks})
264
+ current[-1] = replacement
265
+ return [*policies, *current]
@@ -0,0 +1,79 @@
1
+ """Select and bind graph factories for checkpoint and tunnel support."""
2
+
3
+ from ._langgraph_checkpoint_binding import bind_native_checkpointer
4
+
5
+
6
+ class LangGraphFactoryMixin:
7
+ def _sdk_mcp_agent(self, graph=None):
8
+ graph = self._agent if graph is None else graph
9
+ builder = getattr(graph, "builder", None)
10
+ return vars(builder).get("_ksadk_mcp_agent") if hasattr(builder, "__dict__") else None
11
+
12
+ def _graph_factory(self, *, module=None, agent=None):
13
+ module = self._module if module is None else module
14
+ agent = self._agent if agent is None else agent
15
+ factory = getattr(module, "ksadk_graph_factory", None)
16
+ tunnel_tools = self._configured_tunnel_tools()
17
+ if tunnel_tools is not None:
18
+ return self._tunnel_graph_factory(factory, agent, tunnel_tools)
19
+ if callable(factory):
20
+ return factory
21
+ if self._sdk_mcp_agent(agent) is not None:
22
+ return lambda *, checkpointer: bind_native_checkpointer(agent, checkpointer)
23
+ return None
24
+
25
+ def _configured_tunnel_tools(self):
26
+ binding = getattr(self, "_tunnel_binding", None)
27
+ if binding is None:
28
+ return None
29
+ from ksadk.tunnel.langgraph import TunnelTools
30
+
31
+ if self._tunnel_tools is None:
32
+ self._tunnel_tools = TunnelTools(binding.policy.agent_id, binding.registry)
33
+ return self._tunnel_tools
34
+
35
+ def _build_loaded_tunnel_graph(self, module, agent, managed_saver, local_saver):
36
+ saver = managed_saver
37
+ if saver is None:
38
+ saver = getattr(agent, "checkpointer", None)
39
+ if saver is None:
40
+ saver = local_saver
41
+ factory = self._graph_factory(module=module, agent=agent)
42
+ return factory(checkpointer=saver)
43
+
44
+ def _tunnel_graph_factory(self, factory, agent, tunnel_tools):
45
+ """Require explicit integration for arbitrary compiled application graphs."""
46
+ import inspect
47
+
48
+ accepts_tunnel = False
49
+ if callable(factory):
50
+ params = inspect.signature(factory).parameters
51
+ accepts_tunnel = (
52
+ "tunnel_tools" in params
53
+ and params["tunnel_tools"].kind != inspect.Parameter.POSITIONAL_ONLY
54
+ )
55
+
56
+ def build(*, checkpointer):
57
+ if accepts_tunnel:
58
+ graph = factory(checkpointer=checkpointer, tunnel_tools=tunnel_tools)
59
+ elif callable(factory):
60
+ graph = factory(checkpointer=checkpointer)
61
+ else:
62
+ graph = agent
63
+ from langgraph.graph.state import CompiledStateGraph
64
+
65
+ if not isinstance(graph, CompiledStateGraph):
66
+ raise TypeError("MCP tunnel graph factory must return CompiledStateGraph")
67
+ if self._sdk_mcp_agent(graph) is not None:
68
+ from ksadk.mcp_runtime.oauth._agent import bind_tunnel_graph
69
+
70
+ graph = bind_tunnel_graph(graph, tunnel_tools, checkpointer=checkpointer)
71
+ elif not accepts_tunnel:
72
+ raise TypeError(
73
+ "LangGraph MCP tunnel requires an SDK create_mcp_agent graph or "
74
+ "ksadk_graph_factory(*, checkpointer, tunnel_tools). Custom graphs "
75
+ "must explicitly bind tunnel_tools in their model and tool nodes."
76
+ )
77
+ return graph
78
+
79
+ return build