clearideas-agent-runtime 1.0.0__tar.gz

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 (191) hide show
  1. clearideas_agent_runtime-1.0.0/.gitignore +49 -0
  2. clearideas_agent_runtime-1.0.0/LICENSE +201 -0
  3. clearideas_agent_runtime-1.0.0/NOTICE +8 -0
  4. clearideas_agent_runtime-1.0.0/PKG-INFO +227 -0
  5. clearideas_agent_runtime-1.0.0/PORTING_NOTES.md +116 -0
  6. clearideas_agent_runtime-1.0.0/README.md +190 -0
  7. clearideas_agent_runtime-1.0.0/pyproject.toml +118 -0
  8. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/__init__.py +114 -0
  9. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/_js/__init__.py +8 -0
  10. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/_js/abort.py +147 -0
  11. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/_js/base64.py +31 -0
  12. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/_js/collation.py +27 -0
  13. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/_js/errors.py +57 -0
  14. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/_js/fetch.py +130 -0
  15. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/_js/json.py +293 -0
  16. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/_js/json_syntax.py +313 -0
  17. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/_js/ops.py +240 -0
  18. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/_js/regex.py +18 -0
  19. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/_js/strings.py +129 -0
  20. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/_js/time.py +95 -0
  21. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/_js/url.py +48 -0
  22. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/_js/yaml.py +151 -0
  23. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/agent.py +104 -0
  24. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/artifacts.py +208 -0
  25. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/cli.py +641 -0
  26. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/conditions/__init__.py +5 -0
  27. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/conditions/jexl.py +202 -0
  28. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/conditions/jexl_parser.py +532 -0
  29. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/config/__init__.py +56 -0
  30. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/config/compose.py +163 -0
  31. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/config/composite_tools.py +70 -0
  32. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/config/mcp_integrity.py +92 -0
  33. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/config/mcp_tools.py +652 -0
  34. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/config/messages.py +37 -0
  35. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/config/providers.py +274 -0
  36. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/config/run_sandbox.py +49 -0
  37. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/config/schema.py +446 -0
  38. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/config/values.py +54 -0
  39. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/config/workspace_tools.py +213 -0
  40. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/config/workspaces.py +106 -0
  41. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/contracts/__init__.py +201 -0
  42. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/contracts/_zod.py +953 -0
  43. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/contracts/schemas.py +1429 -0
  44. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/contracts/types.py +54 -0
  45. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/core/__init__.py +28 -0
  46. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/core/errors.py +206 -0
  47. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/core/execution_plan.py +97 -0
  48. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/core/limits.py +302 -0
  49. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/core/messages.py +860 -0
  50. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/core/policies.py +64 -0
  51. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/core/ports.py +241 -0
  52. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/core/runtime.py +2562 -0
  53. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/core/state.py +78 -0
  54. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/core/templates.py +42 -0
  55. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/core/testing.py +112 -0
  56. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/core/version.py +3 -0
  57. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/execution/__init__.py +22 -0
  58. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/execution/_records.py +68 -0
  59. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/execution/child_process.py +157 -0
  60. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/execution/client.py +70 -0
  61. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/execution/contracts.py +57 -0
  62. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/execution/in_process.py +244 -0
  63. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/execution/remote.py +210 -0
  64. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/execution/secure_invocation.py +306 -0
  65. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/execution/worker_protocol.py +184 -0
  66. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/__init__.py +6 -0
  67. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/ai_sdk/__init__.py +7 -0
  68. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/ai_sdk/anthropic.py +562 -0
  69. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/ai_sdk/capture.py +351 -0
  70. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/ai_sdk/chat_completions.py +404 -0
  71. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/ai_sdk/cohere_chat.py +159 -0
  72. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/ai_sdk/core.py +721 -0
  73. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/ai_sdk/errors.py +268 -0
  74. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/ai_sdk/google.py +357 -0
  75. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/ai_sdk/openai_responses.py +424 -0
  76. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/ai_sdk/results.py +123 -0
  77. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/ai_sdk/shape.py +62 -0
  78. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/ai_sdk/tool_calls.py +262 -0
  79. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/ai_sdk/xai_responses.py +341 -0
  80. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/cohere.py +191 -0
  81. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/google.py +37 -0
  82. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/groq.py +45 -0
  83. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/openai.py +109 -0
  84. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/provider_options.py +350 -0
  85. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/providers.py +173 -0
  86. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/pydantic_ai.py +1116 -0
  87. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/models/responses_input.py +190 -0
  88. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/sandbox/__init__.py +9 -0
  89. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/sandbox/_process.py +169 -0
  90. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/sandbox/assets/agent-fs.py +555 -0
  91. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/sandbox/bubblewrap.py +344 -0
  92. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/sandbox/contracts.py +82 -0
  93. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/sandbox/docker.py +179 -0
  94. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/sandbox/modal.py +62 -0
  95. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/sandbox/policy.py +774 -0
  96. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/sandbox/provider_adapter.py +192 -0
  97. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/sandbox/run_sandbox.py +942 -0
  98. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/sandbox/testing.py +231 -0
  99. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/steps/__init__.py +1 -0
  100. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/steps/loop.py +401 -0
  101. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/steps/prompt/__init__.py +110 -0
  102. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/steps/prompt/context/__init__.py +1 -0
  103. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/steps/prompt/context/errors.py +194 -0
  104. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/steps/prompt/context/measure.py +122 -0
  105. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/steps/prompt/context/opening.py +165 -0
  106. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/steps/prompt/context/prune.py +188 -0
  107. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/steps/prompt/context/summarize.py +252 -0
  108. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/steps/prompt/context/template.py +88 -0
  109. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/steps/prompt/context/transcript.py +239 -0
  110. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/steps/prompt/execution.py +2132 -0
  111. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/steps/prompt/helpers.py +266 -0
  112. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/steps/prompt/history_compactor.py +359 -0
  113. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/steps/standard.py +844 -0
  114. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/stores/__init__.py +1 -0
  115. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/stores/local/__init__.py +40 -0
  116. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/stores/local/files.py +299 -0
  117. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/stores/local/run_stores.py +386 -0
  118. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/stores/local/workspaces.py +338 -0
  119. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/stores/sqlite.py +282 -0
  120. clearideas_agent_runtime-1.0.0/src/clearideas_agent_runtime/telemetry.py +280 -0
  121. clearideas_agent_runtime-1.0.0/tests/__init__.py +0 -0
  122. clearideas_agent_runtime-1.0.0/tests/agent/__init__.py +0 -0
  123. clearideas_agent_runtime-1.0.0/tests/agent/test_create_runtime.py +233 -0
  124. clearideas_agent_runtime-1.0.0/tests/artifacts/__init__.py +0 -0
  125. clearideas_agent_runtime-1.0.0/tests/artifacts/test_artifacts.py +72 -0
  126. clearideas_agent_runtime-1.0.0/tests/cli/__init__.py +0 -0
  127. clearideas_agent_runtime-1.0.0/tests/cli/test_cli.py +101 -0
  128. clearideas_agent_runtime-1.0.0/tests/conditions/__init__.py +0 -0
  129. clearideas_agent_runtime-1.0.0/tests/conditions/test_jexl.py +62 -0
  130. clearideas_agent_runtime-1.0.0/tests/config/__init__.py +0 -0
  131. clearideas_agent_runtime-1.0.0/tests/config/test_config.py +292 -0
  132. clearideas_agent_runtime-1.0.0/tests/config/test_mcp_tools.py +362 -0
  133. clearideas_agent_runtime-1.0.0/tests/config/test_workspace_tools.py +203 -0
  134. clearideas_agent_runtime-1.0.0/tests/conftest.py +30 -0
  135. clearideas_agent_runtime-1.0.0/tests/contracts/__init__.py +0 -0
  136. clearideas_agent_runtime-1.0.0/tests/contracts/test_manifest.py +687 -0
  137. clearideas_agent_runtime-1.0.0/tests/contracts/test_messages.py +410 -0
  138. clearideas_agent_runtime-1.0.0/tests/core/__init__.py +0 -0
  139. clearideas_agent_runtime-1.0.0/tests/core/helpers.py +30 -0
  140. clearideas_agent_runtime-1.0.0/tests/core/test_agent_runtime.py +685 -0
  141. clearideas_agent_runtime-1.0.0/tests/core/test_commit_points.py +111 -0
  142. clearideas_agent_runtime-1.0.0/tests/core/test_messages.py +567 -0
  143. clearideas_agent_runtime-1.0.0/tests/core/test_messages_runtime.py +494 -0
  144. clearideas_agent_runtime-1.0.0/tests/core/test_resilience.py +372 -0
  145. clearideas_agent_runtime-1.0.0/tests/core/test_seeded_runs.py +30 -0
  146. clearideas_agent_runtime-1.0.0/tests/core/test_state_plan_diagnostics.py +160 -0
  147. clearideas_agent_runtime-1.0.0/tests/core/test_workspaces.py +279 -0
  148. clearideas_agent_runtime-1.0.0/tests/interop/__init__.py +0 -0
  149. clearideas_agent_runtime-1.0.0/tests/interop/conftest.py +93 -0
  150. clearideas_agent_runtime-1.0.0/tests/interop/driver.py +330 -0
  151. clearideas_agent_runtime-1.0.0/tests/interop/generators.py +482 -0
  152. clearideas_agent_runtime-1.0.0/tests/interop/mock_provider.py +496 -0
  153. clearideas_agent_runtime-1.0.0/tests/interop/test_api_surface.py +55 -0
  154. clearideas_agent_runtime-1.0.0/tests/interop/test_cli.py +178 -0
  155. clearideas_agent_runtime-1.0.0/tests/interop/test_conditions.py +273 -0
  156. clearideas_agent_runtime-1.0.0/tests/interop/test_config.py +179 -0
  157. clearideas_agent_runtime-1.0.0/tests/interop/test_contracts.py +100 -0
  158. clearideas_agent_runtime-1.0.0/tests/interop/test_cross_resume.py +225 -0
  159. clearideas_agent_runtime-1.0.0/tests/interop/test_execution.py +206 -0
  160. clearideas_agent_runtime-1.0.0/tests/interop/test_mcp_tools.py +171 -0
  161. clearideas_agent_runtime-1.0.0/tests/interop/test_primitives.py +270 -0
  162. clearideas_agent_runtime-1.0.0/tests/interop/test_prompt_context.py +310 -0
  163. clearideas_agent_runtime-1.0.0/tests/interop/test_provider_wire.py +273 -0
  164. clearideas_agent_runtime-1.0.0/tests/interop/test_sandbox_policy.py +270 -0
  165. clearideas_agent_runtime-1.0.0/tests/interop/test_scenarios_core.py +232 -0
  166. clearideas_agent_runtime-1.0.0/tests/interop/test_scenarios_prompt.py +290 -0
  167. clearideas_agent_runtime-1.0.0/tests/interop/test_scenarios_providers.py +115 -0
  168. clearideas_agent_runtime-1.0.0/tests/interop/wire_cases.py +881 -0
  169. clearideas_agent_runtime-1.0.0/tests/interop/wire_diff.py +65 -0
  170. clearideas_agent_runtime-1.0.0/tests/models/__init__.py +0 -0
  171. clearideas_agent_runtime-1.0.0/tests/models/test_cohere.py +124 -0
  172. clearideas_agent_runtime-1.0.0/tests/models/test_pydantic_ai_adapter.py +508 -0
  173. clearideas_agent_runtime-1.0.0/tests/sandbox/__init__.py +0 -0
  174. clearideas_agent_runtime-1.0.0/tests/sandbox/support.py +79 -0
  175. clearideas_agent_runtime-1.0.0/tests/sandbox/test_providers.py +255 -0
  176. clearideas_agent_runtime-1.0.0/tests/sandbox/test_run_sandbox.py +312 -0
  177. clearideas_agent_runtime-1.0.0/tests/steps/__init__.py +0 -0
  178. clearideas_agent_runtime-1.0.0/tests/steps/prompt/__init__.py +0 -0
  179. clearideas_agent_runtime-1.0.0/tests/steps/prompt/support.py +122 -0
  180. clearideas_agent_runtime-1.0.0/tests/steps/prompt/test_context.py +318 -0
  181. clearideas_agent_runtime-1.0.0/tests/steps/prompt/test_index.py +775 -0
  182. clearideas_agent_runtime-1.0.0/tests/steps/prompt/test_messages.py +465 -0
  183. clearideas_agent_runtime-1.0.0/tests/steps/prompt/test_recovery.py +338 -0
  184. clearideas_agent_runtime-1.0.0/tests/steps/prompt/test_resilience.py +950 -0
  185. clearideas_agent_runtime-1.0.0/tests/steps/test_loop.py +372 -0
  186. clearideas_agent_runtime-1.0.0/tests/steps/test_standard.py +822 -0
  187. clearideas_agent_runtime-1.0.0/tests/stores/__init__.py +0 -0
  188. clearideas_agent_runtime-1.0.0/tests/stores/test_store_local.py +693 -0
  189. clearideas_agent_runtime-1.0.0/tests/stores/test_store_sqlite.py +167 -0
  190. clearideas_agent_runtime-1.0.0/tests/telemetry/__init__.py +0 -0
  191. clearideas_agent_runtime-1.0.0/tests/telemetry/test_otel.py +90 -0
@@ -0,0 +1,49 @@
1
+ # Dependencies
2
+ node_modules
3
+ .npm-cache/
4
+
5
+ # Compiled output and caches
6
+ dist/
7
+ coverage/
8
+ *.tsbuildinfo
9
+ .vitepress/cache/
10
+ **/.vitepress/cache/
11
+ .vitepress/dist/
12
+
13
+ # Local runtime state
14
+ .agent-runtime/
15
+ .agent-runtime-worker/
16
+ *.sqlite
17
+ *.sqlite-shm
18
+ *.sqlite-wal
19
+ *.db
20
+ *.jsonl
21
+
22
+ # Environment and credentials
23
+ .env
24
+ .env.*
25
+ !.env.example
26
+ *.pem
27
+ *.key
28
+
29
+ # Package-manager and test noise
30
+ npm-debug.log*
31
+ yarn-debug.log*
32
+ yarn-error.log*
33
+ .nyc_output/
34
+
35
+ # Editors and operating systems
36
+ .DS_Store
37
+ .idea/
38
+ .vscode/
39
+ *.swp
40
+
41
+ # Python
42
+ .venv
43
+ __pycache__/
44
+ *.py[cod]
45
+ .pytest_cache/
46
+ .ruff_cache/
47
+ .hypothesis/
48
+ *.egg-info/
49
+ python/.bootstrap/
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Clear Ideas Incorporated
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,8 @@
1
+ Clear Ideas Agent Runtime
2
+ Copyright 2026 Clear Ideas Incorporated
3
+
4
+ Clear Ideas is a trademark of Clear Ideas Incorporated.
5
+
6
+ The documentation site includes @clearideas/consent-analytics 0.1.0-rc.1, distributed
7
+ under the MIT License. Its license text is available at
8
+ docs/public/assets/analytics/LICENSE.clearideas-consent-analytics.txt.
@@ -0,0 +1,227 @@
1
+ Metadata-Version: 2.5
2
+ Name: clearideas-agent-runtime
3
+ Version: 1.0.0
4
+ Summary: Python implementation of Clear Ideas Agent Runtime, interoperable with the TypeScript runtime.
5
+ Project-URL: Homepage, https://github.com/clearideas/agent-runtime
6
+ Project-URL: Repository, https://github.com/clearideas/agent-runtime
7
+ Author: Clear Ideas Incorporated
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ License-File: NOTICE
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Typing :: Typed
17
+ Requires-Python: >=3.11
18
+ Requires-Dist: ada-url<5,>=4.0
19
+ Requires-Dist: cryptography>=44
20
+ Requires-Dist: httpx<1,>=0.28
21
+ Requires-Dist: pydantic<3,>=2.12
22
+ Requires-Dist: pyicu-wheels<2.16,>=2.15.2
23
+ Requires-Dist: pyjexl-extended==0.2.6
24
+ Requires-Dist: rfc8785<0.2,>=0.1.4
25
+ Requires-Dist: ruamel-yaml<0.20,>=0.19.1
26
+ Provides-Extra: all
27
+ Requires-Dist: mcp<3,>=2.3; extra == 'all'
28
+ Requires-Dist: opentelemetry-api<2,>=1.28; extra == 'all'
29
+ Requires-Dist: pydantic-ai-slim[anthropic,cohere,google,groq,openai,xai]<2.67,>=2.66; extra == 'all'
30
+ Provides-Extra: mcp
31
+ Requires-Dist: mcp<3,>=2.3; extra == 'mcp'
32
+ Provides-Extra: otel
33
+ Requires-Dist: opentelemetry-api<2,>=1.28; extra == 'otel'
34
+ Provides-Extra: providers
35
+ Requires-Dist: pydantic-ai-slim[anthropic,cohere,google,groq,openai,xai]<2.67,>=2.66; extra == 'providers'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # Clear Ideas Agent Runtime (Python)
39
+
40
+ `clearideas-agent-runtime` is the Python implementation of Agent Runtime 1.0.0.
41
+ It writes checkpoint contract 1.1 and supports durable run limits, blocked
42
+ runs, restart points, workspace commit points, and cross-language resume with
43
+ the TypeScript runtime.
44
+
45
+ ## Install
46
+
47
+ ```sh
48
+ pip install clearideas-agent-runtime
49
+ # Optional provider and MCP integrations:
50
+ pip install 'clearideas-agent-runtime[providers,mcp]'
51
+ ```
52
+
53
+ To work from the repository checkout instead, run `make install` at the root.
54
+
55
+ Requires Python 3.11+. Extras:
56
+
57
+ | Extra | Adds |
58
+ | ----------- | --------------------------------------------------------------------------------------------------------- |
59
+ | `providers` | `pydantic-ai-slim` provider clients (OpenAI, Anthropic, Google, Mistral, Groq, Cohere, OpenAI-compatible) |
60
+ | `mcp` | configured MCP tools (`mcp` SDK, streamable HTTP) |
61
+ | `otel` | `OpenTelemetryEventSink` |
62
+
63
+ ## Use
64
+
65
+ ```python
66
+ import asyncio
67
+ from clearideas_agent_runtime import FileRunStore, create_agent_runtime, define_agent
68
+
69
+ manifest = define_agent({
70
+ "schemaVersion": "1.0",
71
+ "model": {"provider": "openai", "model": "gpt-5-mini"},
72
+ "steps": [{"id": "answer", "type": "prompt", "prompt": "Say hello", "includeInFinalOutput": True}],
73
+ })
74
+
75
+ async def main() -> None:
76
+ runtime = create_agent_runtime(manifest=manifest, run_store=FileRunStore(".runs"))
77
+ result = await runtime.run({"runId": "hello"})
78
+ print(result["output"])
79
+
80
+ asyncio.run(main())
81
+ ```
82
+
83
+ Like `@clearideas/agent-runtime`, the top-level package re-exports the
84
+ public API of every subpackage (`AgentRuntime`, `compose_runtime`,
85
+ `FileRunStore`, `PromptStepExecutor`, `AbortController`, …). API parity is
86
+ tracked by `tests/interop/test_api_surface.py`. The pydantic-ai adapter
87
+ (`PydanticAIModelAdapter`, the counterpart of `AiSdkModelAdapter`) is loaded
88
+ on first use, since it needs the `providers` extra.
89
+
90
+ The [showcase](../examples/showcase/README.md#run-it-on-the-python-runtime)
91
+ runs every demo on this runtime too (`npm run start:python` in
92
+ `examples/showcase`): its `host.py` files are complete host integrations —
93
+ workspaces and sandboxes, approvals and resume, MCP tools, execution engines
94
+ and a remote worker, context management, and signed conversations.
95
+
96
+ The CLI is `agent-runtime-py` and accepts the same arguments as the TypeScript
97
+ `agent-runtime` for `validate`, `config validate`, `run`, `run-manifest`, `resume`,
98
+ `inspect`, `events`, and `worker`.
99
+
100
+ ## Package map
101
+
102
+ | TypeScript package | Python module |
103
+ | ------------------------------------------- | ------------------------------------------------------------------------- |
104
+ | `@clearideas/agent-runtime` | `clearideas_agent_runtime` (`create_agent_runtime`, `define_agent`) |
105
+ | `contracts` | `contracts` (pydantic models with Zod 4 semantics, identical issues) |
106
+ | `core` | `core` (`AgentRuntime`, hashing, signing, messages, tool policy) |
107
+ | `condition-jexl` | `conditions` (jexl's grammar, evaluated by pyjexl with JavaScript rules) |
108
+ | `step-prompt`, `step-loop`, `step-standard` | `steps.prompt`, `steps.loop`, `steps.standard` |
109
+ | `store-local`, `store-sqlite` | `stores.local`, `stores.sqlite` (same on-disk/SQLite layout) |
110
+ | `model-ai-sdk` | `models` (pydantic-ai adapter; AI SDK `providerOptions` translated) |
111
+ | `runtime` | `config` (host configuration, composition, MCP/composite/workspace tools) |
112
+ | `sandbox`, `sandbox-modal` | `sandbox` (Docker, bubblewrap, Modal gateway, host test provider) |
113
+ | `execution` | `execution` (in-process, child-process, remote engines; worker protocol) |
114
+ | `artifacts`, `telemetry-otel`, `cli` | `artifacts`, `telemetry`, `cli` |
115
+
116
+ Contract data stays JSON dictionaries with camelCase keys; Python APIs are
117
+ snake_case. See [PORTING_NOTES.md](PORTING_NOTES.md).
118
+
119
+ ## Model layer
120
+
121
+ The TypeScript runtime calls providers through the AI SDK; the Python runtime
122
+ uses pydantic-ai's model classes and the official provider SDKs for the HTTP
123
+ calls, with small translation layers so both runtimes send the same requests
124
+ and produce the same `ModelResult`s:
125
+
126
+ - **Requests.** `models/pydantic_ai.py` maps `ModelRequest`s to pydantic-ai
127
+ messages and settings; `models/provider_options.py` translates AI SDK
128
+ `providerOptions`. Where pydantic-ai builds a request differently from the
129
+ AI SDK provider, a thin subclass changes that mapping only:
130
+ `ResponsesChatModel` (OpenAI/xAI Responses reasoning, `include`, replayed
131
+ assistant items), `CohereChatModel`, `GroqChatModel`, `GoogleChatModel`.
132
+ - **Responses.** `models/ai_sdk/` reads the provider's raw response body or
133
+ event stream (recorded by a wrapped HTTP transport) and interprets it the way
134
+ the AI SDK provider does: content parts and their replay metadata, usage
135
+ (including the raw usage object), finish reason, and provider metadata. AI
136
+ SDK Core's tool-call parsing, response messages, and stream accumulation are
137
+ reproduced, so transcripts, usage, and streamed events are identical.
138
+ - **Errors and retries.** Failed calls become `AI_APICallError`s with the
139
+ provider's error message, and retryable ones are retried like the AI SDK
140
+ (two retries, exponential back-off honouring `retry-after`), ending in an
141
+ `AI_RetryError`. `JSON.parse` errors carry V8's messages.
142
+
143
+ Custom pydantic-ai models (without the wrapped transport) fall back to
144
+ pydantic-ai's own response mapping.
145
+
146
+ ## Tests
147
+
148
+ One command sets up dependencies and runs Python lint, type checks, and unit
149
+ tests:
150
+
151
+ ```sh
152
+ make test
153
+ ```
154
+
155
+ It installs uv if needed (a private copy in `python/.bootstrap`), runs
156
+ `npm ci` when `node_modules` is missing, rebuilds the TypeScript packages when
157
+ a source changed since the last build, syncs `python/.venv` (uv downloads a
158
+ suitable Python if necessary), then runs ruff, pyright, the Python runtime
159
+ unit tests, and the Python showcase library tests. Node.js 22+ and npm are
160
+ the only prerequisites.
161
+
162
+ The suite is strict: any warning is an error (apart from two deprecations
163
+ raised inside third-party packages, listed in `pyproject.toml`), and a test
164
+ that would be skipped fails instead, so a green run means every test ran.
165
+ `make test STRICT=0` allows skips on a platform without a prerequisite (for
166
+ example bubblewrap with unprivileged user namespaces on Linux).
167
+
168
+ ```sh
169
+ make check # full compatibility gate: make test, npm test, showcase parity
170
+ make test-showcase # showcase HTTP and parity tests against server.py
171
+ make interop # cross-language compatibility gate
172
+ make typecheck # only pyright
173
+ make clean # remove python/.venv, python/.bootstrap, and the build stamp
174
+ ```
175
+
176
+ Cross-language tests (`tests/interop/`) run the built TypeScript packages
177
+ through `interop/oracle.mjs` (function-level), `interop/driver.mjs` (whole
178
+ scenarios) and `interop/wire.mjs` (the AI SDK adapter against a mock
179
+ provider), and require identical output. They cover contract parsing and
180
+ issues, manifest hashes and canonical JSON, JEXL conditions, YAML, scenario
181
+ runs (events, records, checkpoints, signatures), cross-language resume,
182
+ prompt-context budgeting, host configuration and MCP digests, sandbox policy,
183
+ sealed execution envelopes, and the CLI. For the model layer they compare, for
184
+ all seven drivers: provider HTTP requests (about 300 cases, including every
185
+ supported provider option and replayed history), the complete `ModelResult`
186
+ or streamed event sequence, failed calls (error, message, attempts), and
187
+ whole manifest runs through the production adapters
188
+ (`test_scenarios_providers.py`). `make test` runs them as part of the Python
189
+ gate; `python -m
190
+ tests.interop.wire_diff [driver] [case]` prints a provider difference.
191
+
192
+ `make test-showcase` runs the showcase's HTTP test suite against the Python
193
+ showcase server and the showcase parity tests: every demo, in scripted mode,
194
+ on both runtimes, with the browser streams, host state, and model requests
195
+ compared, and paused runs and chats continued across the two runtimes (see
196
+ the showcase's [Test](../examples/showcase/README.md#test) section).
197
+
198
+ ## Known differences
199
+
200
+ - Steps of a parallel wave run concurrently, and JavaScript's microtask
201
+ scheduling interleaves their clock reads and id draws differently from
202
+ asyncio. With an injected deterministic clock, timestamps and ids inside a
203
+ wave can differ; state, outputs, and step results are identical.
204
+ - Provider HTTP requests are equivalent but not byte-identical: the Python
205
+ SDKs send some defaults explicitly (`stream: false`, `n: 1`, ...), a few
206
+ fields in another accepted form, and JSON members in another order (the
207
+ order of a tool schema's `properties`, which the model sees, is kept). The list is `KNOWN_DIFFERENCES` in
208
+ `tests/interop/test_provider_wire.py`; model results are identical.
209
+ - Response interpretation covers what a runtime request can produce
210
+ (function tools only): text, reasoning, tool calls, refusals, generated
211
+ files, usage, and provider metadata. Results of provider-executed tools
212
+ (web search, code execution, MCP servers) and Gemini's continuation and
213
+ streamed-argument modes are not ported.
214
+ - Connection failures report Node's messages for refused connections, failed
215
+ DNS lookups, and resets; other transport errors keep Python's message.
216
+ - Host-supplied regular expressions (tool/command patterns) are compiled with
217
+ Python `re`; JavaScript-only syntax is rejected.
218
+ - Configured workspace tools call the workspace session directly instead of
219
+ relaying through an in-process MCP server; results are identical.
220
+ - MCP tool results are the server's reply as sent, as in TypeScript, but the
221
+ Python MCP SDK validates it first: a reply without `content` (which the
222
+ TypeScript SDK defaults to `[]`) fails the call.
223
+ - Not ported yet: `execution-modal` (Modal compute launcher, worker, egress
224
+ policy) and the CLI commands `serve`, `examples`, and `connections`
225
+ (plus the `--stream`/`--show-reasoning` display flags), and the HTTP server
226
+ package. The showcase runs on both runtimes; its launcher and hosted
227
+ deployment remain TypeScript-only.
@@ -0,0 +1,116 @@
1
+ # Porting notes
2
+
3
+ Conventions used when porting a TypeScript package to this Python package.
4
+
5
+ ## Data and APIs
6
+
7
+ - Contract data (manifests, events, checkpoints, records, model requests and
8
+ results, tool calls, step results) stays **JSON dictionaries with camelCase
9
+ keys**, built in the same key order as the TypeScript object literal.
10
+ - Python APIs are snake_case: classes, functions, methods, keyword arguments.
11
+ Ports are `Protocol`s with snake_case methods (`load_run`, `execute_tool`).
12
+ - Objects that carry functions (step execution context, history context, tool
13
+ execution context) are dataclasses with snake_case attributes.
14
+ - JavaScript `undefined` as a _value_ (a missing output, a missing property in a
15
+ condition) is `clearideas_agent_runtime._js.ops.UNDEFINED`; a missing key is
16
+ an absent key, never `None`.
17
+ - JavaScript truthiness differs for `{}` and `[]` (truthy in JavaScript). Port
18
+ `x ? {...} : {}` on objects/arrays as `is not None`.
19
+
20
+ ## Host code
21
+
22
+ The showcase's `host.py` files (`examples/showcase/demos/*/host.py`) are
23
+ complete host integrations next to their TypeScript originals. Conventions
24
+ they follow:
25
+
26
+ - Import from the top-level package, as TypeScript hosts import from
27
+ `@clearideas/agent-runtime`; for example `AgentRuntime`, `compose_runtime`,
28
+ `FileRunStore`, and `AbortController` all come from
29
+ `clearideas_agent_runtime`.
30
+ - Options objects become dataclasses or keyword arguments:
31
+ `ValueResolutionContext`, `ComposeRuntimeOptions`, and
32
+ `WorkspaceCompositionOptions` for `compose_runtime`; keyword arguments for
33
+ `AgentRuntime(run_store=..., step_executors=[...])` and
34
+ `runtime.run(manifest=..., run_id=..., signal=...)`.
35
+ - Host hooks receive every argument the runtime passes (JavaScript callbacks
36
+ may ignore trailing ones): `authorize_command(request, context)`,
37
+ `authorize_tool(request, context)`, `authorize_sandbox(request)`,
38
+ `authorize_workspace(request)`.
39
+ - Adapters are objects with snake_case methods (`request_approval`,
40
+ `execute_tool`, `summarize(request, next)`, event sinks' `emit`); an
41
+ optional method is absent, or `None` (`stream = None` means non-streaming).
42
+
43
+ ## JavaScript semantics (`clearideas_agent_runtime._js`)
44
+
45
+ | Need | Module |
46
+ | ------------------------------------------------------ | ----------------- |
47
+ | `JSON.stringify`, `JSON.parse`, byte lengths, RFC 8785 | `_js.json` |
48
+ | UTF-16 `length`/`slice`, `trim`, `toLowerCase` | `_js.strings` |
49
+ | `Error`/`TypeError` with `name`, `error.message` | `_js.errors` |
50
+ | `AbortController`/`AbortSignal` | `_js.abort` |
51
+ | `toISOString`, `Date.parse`, `Date.now` | `_js.time` |
52
+ | `localeCompare` (ICU) | `_js.collation` |
53
+ | YAML 1.2 (`yaml` package) | `_js.yaml` |
54
+ | WHATWG `URL`, `net.isIP` | `_js.url` |
55
+ | `atob`/`btoa`/base64url | `_js.base64` |
56
+ | JS operators and coercion | `_js.ops` |
57
+ | JS `\s` in regular expressions | `_js.regex.WS` |
58
+ | V8 `JSON.parse` syntax-error messages | `_js.json_syntax` |
59
+
60
+ Use `[0-9]` instead of `\d` in ported regular expressions (JavaScript `\d` is ASCII).
61
+
62
+ ## Tests
63
+
64
+ - Each vitest file is ported to pytest with the same test names (snake_case)
65
+ under `tests/<package>/`.
66
+ - Cross-language tests live in `tests/interop/`. `interop/oracle.mjs` evaluates
67
+ inputs with the built TypeScript packages; `interop/driver.mjs` and
68
+ `tests/interop/driver.py` run whole scenarios and report every observable
69
+ output, which must be byte-identical.
70
+ - `make interop` runs `tests/interop` against the current TypeScript runtime.
71
+ `AGENT_RUNTIME_TEST_PYTHON_INTEROP=1 npm test` adds it to the npm test runner
72
+ when `python/.venv` exists. CI runs the Python unit suite with `make test`;
73
+ the interop gate remains separate until the 0.10 durability behavior is ported.
74
+ - Known, documented differences are listed in README.md ("Known differences").
75
+
76
+ ## Dependencies
77
+
78
+ | TypeScript | Python | Translation layer |
79
+ | --------------------------- | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
80
+ | `ai` (AI SDK) + `@ai-sdk/*` | `pydantic-ai-slim` (pinned minor) | `models/pydantic_ai.py`, `models/provider_options.py`, `models/ai_sdk/` |
81
+ | `zod` | `pydantic` | `contracts/_zod.py` (Zod 4 issue codes, messages, output key order) |
82
+ | `jexl` | `pyjexl-extended` | `conditions/jexl_parser.py` (jexl's lexer and parser, its error messages), `conditions/jexl.py` (JavaScript operators, truthiness, missing values) |
83
+ | `yaml` | `ruamel.yaml` | `_js/yaml.py` (YAML 1.2 core schema) |
84
+ | `localeCompare` (ICU) | `pyicu-wheels` | `_js/collation.py` |
85
+ | `@modelcontextprotocol/sdk` | `mcp` | `config/mcp_tools.py` |
86
+ | `better-sqlite3` | `sqlite3` (stdlib) | `stores/sqlite.py` |
87
+ | `node:crypto` | `cryptography` | `core/signing`, `execution/secure_invocation.py` |
88
+ | `@opentelemetry/api` | `opentelemetry-api` | `telemetry.py` |
89
+
90
+ ## Model layer
91
+
92
+ When porting or updating provider behaviour, keep the three layers apart:
93
+
94
+ - Request shape: `models/pydantic_ai.py` (messages, settings, output modes),
95
+ `models/provider_options.py` (one handler per supported AI SDK option), and
96
+ the per-provider model subclasses (`openai.py`, `cohere.py`, `groq.py`,
97
+ `google.py`, `responses_input.py`).
98
+ - Response interpretation: `models/ai_sdk/<provider>.py` ports the AI SDK
99
+ provider's `doGenerate`/`doStream` for the parts a runtime request can
100
+ produce; `models/ai_sdk/core.py` ports AI SDK Core and the adapter's result
101
+ assembly; `models/ai_sdk/shape.py` reproduces the key order and stripping of
102
+ the Zod schemas whose parsed values reach results (`raw` usage, logprobs).
103
+ - Errors and retries: `models/ai_sdk/errors.py`.
104
+
105
+ After upgrading `ai`/`@ai-sdk/*` or `pydantic-ai-slim`, run
106
+ `uv run python -m tests.interop.wire_diff` (from `python/`) and follow any
107
+ difference back to the provider code.
108
+
109
+ ## Type checking
110
+
111
+ `make typecheck` (pyright, standard mode) is clean. Two exceptions are
112
+ deliberate: the schema modules (`contracts/schemas.py`, `config/schema.py`)
113
+ use Zod-style call annotations that pyright cannot read, and the Optional
114
+ narrowing rules are off because contract-validated values are used the way
115
+ TypeScript uses non-null assertions. Remaining single-line suppressions are
116
+ `# pyright: ignore[rule]` comments on the line.