goondan 0.1.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 (67) hide show
  1. goondan-0.1.0/.gitignore +39 -0
  2. goondan-0.1.0/AGENTS.md +62 -0
  3. goondan-0.1.0/LICENSE +202 -0
  4. goondan-0.1.0/PKG-INFO +97 -0
  5. goondan-0.1.0/README.md +69 -0
  6. goondan-0.1.0/goondan/__init__.py +36 -0
  7. goondan-0.1.0/goondan/_json.py +88 -0
  8. goondan-0.1.0/goondan/_schema.py +331 -0
  9. goondan-0.1.0/goondan/_values.py +309 -0
  10. goondan-0.1.0/goondan/_yaml.py +265 -0
  11. goondan-0.1.0/goondan/config.py +620 -0
  12. goondan-0.1.0/goondan/fold.py +344 -0
  13. goondan-0.1.0/goondan/goondan.schema.json +2484 -0
  14. goondan-0.1.0/goondan/models/AGENTS.md +21 -0
  15. goondan-0.1.0/goondan/models/__init__.py +26 -0
  16. goondan-0.1.0/goondan/models/_anthropic.py +638 -0
  17. goondan-0.1.0/goondan/models/_errors.py +208 -0
  18. goondan-0.1.0/goondan/models/_ids.py +16 -0
  19. goondan-0.1.0/goondan/models/_normalize.py +128 -0
  20. goondan-0.1.0/goondan/models/_openai.py +517 -0
  21. goondan-0.1.0/goondan/models/_options.py +229 -0
  22. goondan-0.1.0/goondan/models/_sse.py +74 -0
  23. goondan-0.1.0/goondan/models/_transport.py +185 -0
  24. goondan-0.1.0/goondan/models/_values.py +92 -0
  25. goondan-0.1.0/goondan/runtime.py +2899 -0
  26. goondan-0.1.0/goondan/store.py +349 -0
  27. goondan-0.1.0/goondan/template.py +672 -0
  28. goondan-0.1.0/goondan/types.py +342 -0
  29. goondan-0.1.0/pyproject.toml +44 -0
  30. goondan-0.1.0/tests/conformance/__init__.py +7 -0
  31. goondan-0.1.0/tests/conformance/bindings.py +448 -0
  32. goondan-0.1.0/tests/conformance/casefile.py +560 -0
  33. goondan-0.1.0/tests/conformance/compare.py +81 -0
  34. goondan-0.1.0/tests/conformance/coverage.py +61 -0
  35. goondan-0.1.0/tests/conformance/errors.py +42 -0
  36. goondan-0.1.0/tests/conformance/gates.py +69 -0
  37. goondan-0.1.0/tests/conformance/jsonptr.py +83 -0
  38. goondan-0.1.0/tests/conformance/normalize.py +190 -0
  39. goondan-0.1.0/tests/conformance/ops.py +200 -0
  40. goondan-0.1.0/tests/conformance/runner.py +794 -0
  41. goondan-0.1.0/tests/conformance/test_units.py +739 -0
  42. goondan-0.1.0/tests/conformance/values.py +67 -0
  43. goondan-0.1.0/tests/test_config_execution.py +90 -0
  44. goondan-0.1.0/tests/test_config_loading.py +245 -0
  45. goondan-0.1.0/tests/test_config_validation.py +293 -0
  46. goondan-0.1.0/tests/test_conformance.py +59 -0
  47. goondan-0.1.0/tests/test_errors_retry.py +442 -0
  48. goondan-0.1.0/tests/test_event_order.py +91 -0
  49. goondan-0.1.0/tests/test_hooks.py +1597 -0
  50. goondan-0.1.0/tests/test_input_v2.py +169 -0
  51. goondan-0.1.0/tests/test_journal_v3.py +228 -0
  52. goondan-0.1.0/tests/test_model_calls.py +532 -0
  53. goondan-0.1.0/tests/test_models_anthropic.py +417 -0
  54. goondan-0.1.0/tests/test_models_errors.py +98 -0
  55. goondan-0.1.0/tests/test_models_fixtures.py +189 -0
  56. goondan-0.1.0/tests/test_models_openai.py +266 -0
  57. goondan-0.1.0/tests/test_models_sse.py +75 -0
  58. goondan-0.1.0/tests/test_models_support.py +169 -0
  59. goondan-0.1.0/tests/test_models_transport.py +257 -0
  60. goondan-0.1.0/tests/test_operations.py +171 -0
  61. goondan-0.1.0/tests/test_review_regressions.py +241 -0
  62. goondan-0.1.0/tests/test_routes.py +370 -0
  63. goondan-0.1.0/tests/test_runtime.py +515 -0
  64. goondan-0.1.0/tests/test_schema_sync.py +38 -0
  65. goondan-0.1.0/tests/test_scope.py +632 -0
  66. goondan-0.1.0/tests/test_templates.py +650 -0
  67. goondan-0.1.0/uv.lock +324 -0
@@ -0,0 +1,39 @@
1
+ .DS_Store
2
+ **/.DS_Store
3
+ node_modules/
4
+ **/node_modules/
5
+ dist/
6
+ **/dist/
7
+ /test/
8
+ *.log
9
+ .tmp/
10
+ .vite/
11
+ **/.vite/
12
+ **/tmp-live-config-*/
13
+ mise.local.toml
14
+ **/state/
15
+ .goondan/
16
+
17
+ # Security - sensitive files
18
+ .env
19
+ .env.*
20
+ !.env.example
21
+ *.pem
22
+ *.key
23
+ *.p12
24
+ *.pfx
25
+ credentials.json
26
+ **/secrets/
27
+ **/.secrets/
28
+ **/oauth/grants/
29
+ **/oauth/sessions/
30
+
31
+ # Python build and test state
32
+ .venv/
33
+ __pycache__/
34
+ .pytest_cache/
35
+ *.pyc
36
+ *.egg-info/
37
+
38
+ # pnpm 오프라인 저장소
39
+ .pnpm-store/
@@ -0,0 +1,62 @@
1
+ # goondan Python 패키지
2
+
3
+ 이 패키지는 Goondan 구성 파일을 Python 프로세스에서 직접 실행합니다. 공개 인터페이스와 실행 동작은 TypeScript의 `@goondan/core`, `spec/goondan.schema.json`, `fixtures/conformance/`와 같은 의미를 유지합니다.
4
+
5
+ ## 모듈
6
+
7
+ `goondan/` 패키지는 TypeScript `packages/core/src`와 대응하는 책임으로 모듈을 나눕니다. 이름이 밑줄로 시작하는 모듈은 패키지 내부용이며, 호스트가 쓰는 이름은 `__init__.py`가 다시 내보냅니다.
8
+
9
+ | 모듈 | 소유 범위 |
10
+ |---|---|
11
+ | `types.py` | 공개 데이터클래스, 프로토콜, 컨텍스트, 정의 도우미와 오류 클래스 |
12
+ | `_json.py` | 두 호스트가 같은 결과를 만드는 JSON 직렬화와 값 처리 |
13
+ | `_yaml.py` | YAML 해석 규칙, 중복 키·앵커·별칭 판정 |
14
+ | `_schema.py` | `goondan.schema.json` 해석기, 스키마 검사와 오류 정렬 |
15
+ | `_values.py` | 단계 값 형식, 메시지 보강, 제어 결과와 도구 반환값 정규화 |
16
+ | `config.py` | YAML 로딩, `resources` 합성, 상속과 제거, 참조·바인딩 검사 |
17
+ | `template.py` | 구성 로딩 시 읽은 맵만 쓰는 렌더러와 정적 include 해석 |
18
+ | `store.py` | `Store` 프로토콜의 오류와 `InMemoryStore` |
19
+ | `fold.py` | 버전이 붙은 저널 이벤트를 상태 뷰로 재생하는 순수 `fold` |
20
+ | `runtime.py` | `Goondan`과 `create_goondan`, 입력 대기열, 훅, 모델·도구 반복, route, 승인 작업, 임대와 이벤트 |
21
+ | `goondan.schema.json` | `spec/goondan.schema.json`의 패키지 사본 |
22
+ | `models/` | Anthropic과 OpenAI 공식 모델 어댑터 |
23
+
24
+ 모듈은 순환 없이 한 방향으로 가져옵니다. `models/`는 코어 모듈 가운데 `types.py`와 `_json.py`만 가져오므로 어댑터를 설치하지 않아도 런타임은 동작합니다.
25
+
26
+ ## 실행 범위와 호스트 API
27
+
28
+ 군단 객체는 에이전트를 선언 이름으로 식별합니다. `stateful: true`인 에이전트는 세션과 에이전트 이름의 조합마다 대화와 확장 인스턴스를 유지합니다. `stateful: false`인 에이전트는 실행마다 빈 대화와 새 확장 인스턴스를 사용하며 실행 기록은 같은 세션 저널에 남깁니다.
29
+
30
+ 호스트 API는 `run(value, session_id=None, meta=None, agent=..., start_agent=...)`, `abort`, `idle`, `close`, `sessions.delete`, `operations.list`, `operations.decide`입니다. `run`은 수락된 입력의 `session_id`, `turn_id`, `input_id`와 턴 결과 awaitable인 `result`를 가진 핸들을 반환합니다. 진행 중인 세션에 추가로 호출한 `run`은 대상 stateful 인스턴스의 입력 대기열에 합류합니다. `agent`와 `start_agent`는 함께 지정할 수 없습니다.
31
+
32
+ `session_id`, `turn_id`, `instance`, `execution_id`, `input_id`는 각각 다른 범위를 나타냅니다. 하위 실행의 직접 원인은 `parent_execution_id`, 승인 작업에서 시작한 실행의 원인은 `operation_id`입니다. 직렬화되는 필드는 camelCase를 유지합니다.
33
+
34
+ `runtime.py`는 일치한 route 분기를 동시에 실행합니다. stateful fan-in은 출발 집합의 실행과 대기 입력이 끝난 뒤 route 선언 순서로 메시지를 합쳐 한 번 실행하고, stateless 에이전트는 도달한 입력마다 독립 실행합니다. 함수 노드는 인스턴스와 대기열 없이 메시지 배열을 변환하고 `route.function` 저널 이벤트를 기록합니다. `$output` route가 없거나 일치하지 않아도 턴은 빈 `outputs`로 성공할 수 있습니다.
35
+
36
+ ## 저널과 승인 작업
37
+
38
+ 세션마다 append 전용 저널 스트림 하나를 둡니다. `Store`는 `append`, `scan`, `head`, `watch`, `acquire_lease`, `delete_session`을 제공하고, 런타임은 `expected`, `write_id`, 임대와 펜싱 토큰으로 상태 변경을 보호합니다. 대화, 승인 작업, 턴과 에이전트 실행 상태는 `fold`의 결과입니다.
39
+
40
+ 현재 지원 범위는 세션당 활성 작성자 하나입니다. 만료되는 임대는 모델 호출, 도구 호출과 승인 대기를 포함한 턴 전체에서 갱신하고, 갱신을 잃으면 실행을 끝낸 뒤 늦은 쓰기를 펜싱으로 거부합니다.
41
+
42
+ 승인 작업의 공개 요청은 `operations.list`와 `operations.decide`입니다. 작업 알림은 `operation.*` 저널·실행 이벤트로 전달하고, 완료 입력은 대상 인스턴스의 입력 대기열에 넣습니다. 세션을 처음 열 때 저널을 재생하여 열린 실행과 턴을 정리하고 승인된 작업과 완료 전달을 자동으로 복구합니다. `inputPatch`는 결정할 때와 실행 직전에 현재 도구 입력 스키마로 검사합니다.
43
+
44
+ ## 훅과 구현 규약
45
+
46
+ 훅 시점은 `onInput`, `onPrompt`, `onStep`, `onModelInput`, `onModelResult`, `onToolCall`, `onToolResult`, `onOutput`, `onError`입니다. `onPrompt` 결과와 `onStep`의 대화 변경은 저널에 기록하고, `onModelInput` 변경은 해당 모델 호출에만 적용합니다.
47
+
48
+ 도구 구현은 내용 부분 배열, `content`를 가진 결과 매핑, 그 밖의 JSON 값 가운데 하나를 반환합니다. 런타임은 `callId`, `name`, `args`를 실행한 호출의 값으로 채우고 정규화한 결과를 `onToolResult`에 전달합니다.
49
+
50
+ 저널 이벤트는 append 직후 같은 봉투로 실행 이벤트 수신자에게 전달합니다. 저장하지 않는 진행 이벤트는 `observational: true`를 가집니다. 에이전트 실행은 `agent.*`, 군단 턴은 `turn.*` 이벤트를 사용합니다.
51
+
52
+ Python 공개 이름에는 snake_case를 사용합니다. 직렬화되는 메시지, 모델 입력, 도구 호출, 결과, 저널 이벤트와 오류 필드에는 camelCase를 사용합니다.
53
+
54
+ ## 의존성과 패키징
55
+
56
+ 런타임 자체는 Jinja2와 PyYAML만 요구합니다. `goondan.models`는 요청을 httpx로 보내므로 `goondan[models]` 선택 의존성으로 설치합니다.
57
+
58
+ 휠은 `[tool.hatch.build.targets.wheel]`이 결정합니다. 패키징을 바꿨으면 `uv build --wheel`로 만든 휠의 파일 목록에 `goondan/goondan.schema.json`이 있는지 확인합니다.
59
+
60
+ ## 검사
61
+
62
+ 저장소 루트의 `pnpm test:python`은 `python/goondan`에서 `uv run --extra test --extra models python -m pytest`를 실행합니다. `tests/test_conformance.py`는 루트의 공통 사례를 실행하고, `tests/test_schema_sync.py`는 패키지 스키마 사본이 규격과 같은지 확인합니다. 모델 어댑터 검사는 실제 제공자를 호출하지 않습니다.
goondan-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
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 Goondan contributors
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.
202
+
goondan-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,97 @@
1
+ Metadata-Version: 2.5
2
+ Name: goondan
3
+ Version: 0.1.0
4
+ Summary: Goondan runtime for Python: runs YAML-declared agents, routes and hooks over a per-session journal
5
+ Project-URL: Homepage, https://github.com/goondan/goondan#readme
6
+ Project-URL: Repository, https://github.com/goondan/goondan
7
+ Project-URL: Issues, https://github.com/goondan/goondan/issues
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: agent,goondan,llm,runtime,yaml
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: >=3.11
19
+ Requires-Dist: jinja2<4,>=3.1
20
+ Requires-Dist: pyyaml<7,>=6
21
+ Provides-Extra: models
22
+ Requires-Dist: httpx<1,>=0.27; extra == 'models'
23
+ Provides-Extra: test
24
+ Requires-Dist: httpx<1,>=0.27; extra == 'test'
25
+ Requires-Dist: pytest-asyncio<1,>=0.24; extra == 'test'
26
+ Requires-Dist: pytest<9,>=8; extra == 'test'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # goondan
30
+
31
+ Goondan은 에이전트 구성과 연결을 YAML로 선언하고, TypeScript와 Python 호스트가 같은 구성을 같은 의미로 실행하는 런타임입니다. 이 패키지는 그 Python 호스트입니다.
32
+
33
+ 실행 의미는 [`spec/goondan.md`](https://github.com/goondan/goondan/blob/main/spec/goondan.md)가 규범으로 정하고, 두 호스트가 같은 기대 결과로 통과해야 하는 공통 실행 사례로 검증합니다.
34
+
35
+ ## 설치
36
+
37
+ ```bash
38
+ pip install goondan
39
+ ```
40
+
41
+ 공식 Anthropic·OpenAI 어댑터를 함께 쓰려면 `models` 추가 의존을 설치합니다.
42
+
43
+ ```bash
44
+ pip install "goondan[models]"
45
+ ```
46
+
47
+ ## 사용
48
+
49
+ YAML에는 에이전트와 연결, 그리고 모델·도구·함수·확장의 **이름**만 선언합니다. 이름에 해당하는 구현은 호스트가 주입합니다.
50
+
51
+ ```yaml
52
+ # goondan.yaml
53
+ name: hello
54
+ agents:
55
+ assistant:
56
+ model: main
57
+ systemMessage: 질문에 짧게 답합니다.
58
+ routes: [assistant]
59
+ ```
60
+
61
+ ```python
62
+ import asyncio
63
+ from goondan import create_goondan, load_config
64
+ from goondan.models import anthropic_model
65
+
66
+
67
+ async def main():
68
+ goondan = create_goondan(
69
+ config=load_config("."),
70
+ models={"main": anthropic_model(model="claude-sonnet-5")},
71
+ )
72
+ try:
73
+ run = await goondan.run("Goondan을 설명해 주세요.", session_id="example")
74
+ result = await run.result
75
+ print(result["output"])
76
+ finally:
77
+ await goondan.close()
78
+
79
+
80
+ asyncio.run(main())
81
+ ```
82
+
83
+ `run`은 입력이 세션 저널에 기록되면 실행 핸들을 돌려줍니다. 핸들의 `session_id`, `turn_id`, `input_id`로 진행을 추적하고, 결과가 필요할 때 `result`를 기다립니다.
84
+
85
+ ## 범위
86
+
87
+ 런타임의 책임은 모델 루프, route 실행, 입력 대기열, 저널, 승인 작업과 취소입니다. 도구는 호스트 프로세스 안에서 실행되는 함수이며, 런타임은 샌드박스, 자격 증명 관리, 비용 통제와 관측 백엔드를 제공하지 않습니다. 격리가 필요하면 호스트가 도구 구현 바깥에 연결합니다.
88
+
89
+ ## 문서
90
+
91
+ - [저장소와 README](https://github.com/goondan/goondan#readme)
92
+ - [실행 규격](https://github.com/goondan/goondan/blob/main/spec/goondan.md)
93
+ - [모델 어댑터 규격](https://github.com/goondan/goondan/blob/main/spec/model-adapters.md)
94
+
95
+ ## 라이선스
96
+
97
+ Apache-2.0
@@ -0,0 +1,69 @@
1
+ # goondan
2
+
3
+ Goondan은 에이전트 구성과 연결을 YAML로 선언하고, TypeScript와 Python 호스트가 같은 구성을 같은 의미로 실행하는 런타임입니다. 이 패키지는 그 Python 호스트입니다.
4
+
5
+ 실행 의미는 [`spec/goondan.md`](https://github.com/goondan/goondan/blob/main/spec/goondan.md)가 규범으로 정하고, 두 호스트가 같은 기대 결과로 통과해야 하는 공통 실행 사례로 검증합니다.
6
+
7
+ ## 설치
8
+
9
+ ```bash
10
+ pip install goondan
11
+ ```
12
+
13
+ 공식 Anthropic·OpenAI 어댑터를 함께 쓰려면 `models` 추가 의존을 설치합니다.
14
+
15
+ ```bash
16
+ pip install "goondan[models]"
17
+ ```
18
+
19
+ ## 사용
20
+
21
+ YAML에는 에이전트와 연결, 그리고 모델·도구·함수·확장의 **이름**만 선언합니다. 이름에 해당하는 구현은 호스트가 주입합니다.
22
+
23
+ ```yaml
24
+ # goondan.yaml
25
+ name: hello
26
+ agents:
27
+ assistant:
28
+ model: main
29
+ systemMessage: 질문에 짧게 답합니다.
30
+ routes: [assistant]
31
+ ```
32
+
33
+ ```python
34
+ import asyncio
35
+ from goondan import create_goondan, load_config
36
+ from goondan.models import anthropic_model
37
+
38
+
39
+ async def main():
40
+ goondan = create_goondan(
41
+ config=load_config("."),
42
+ models={"main": anthropic_model(model="claude-sonnet-5")},
43
+ )
44
+ try:
45
+ run = await goondan.run("Goondan을 설명해 주세요.", session_id="example")
46
+ result = await run.result
47
+ print(result["output"])
48
+ finally:
49
+ await goondan.close()
50
+
51
+
52
+ asyncio.run(main())
53
+ ```
54
+
55
+ `run`은 입력이 세션 저널에 기록되면 실행 핸들을 돌려줍니다. 핸들의 `session_id`, `turn_id`, `input_id`로 진행을 추적하고, 결과가 필요할 때 `result`를 기다립니다.
56
+
57
+ ## 범위
58
+
59
+ 런타임의 책임은 모델 루프, route 실행, 입력 대기열, 저널, 승인 작업과 취소입니다. 도구는 호스트 프로세스 안에서 실행되는 함수이며, 런타임은 샌드박스, 자격 증명 관리, 비용 통제와 관측 백엔드를 제공하지 않습니다. 격리가 필요하면 호스트가 도구 구현 바깥에 연결합니다.
60
+
61
+ ## 문서
62
+
63
+ - [저장소와 README](https://github.com/goondan/goondan#readme)
64
+ - [실행 규격](https://github.com/goondan/goondan/blob/main/spec/goondan.md)
65
+ - [모델 어댑터 규격](https://github.com/goondan/goondan/blob/main/spec/model-adapters.md)
66
+
67
+ ## 라이선스
68
+
69
+ Apache-2.0
@@ -0,0 +1,36 @@
1
+ from .config import load_config, validate_config
2
+ from .runtime import Goondan, create_goondan
3
+ from .fold import FOLD_VERSION, FoldError, UnsupportedJournalVersionError, fold
4
+ from .store import (
5
+ InMemoryStore,
6
+ Store,
7
+ StoreConflictError,
8
+ StoreError,
9
+ StoreInputError,
10
+ )
11
+ from .types import (
12
+ Extension,
13
+ ExtensionDefinition,
14
+ GoondanAbortError,
15
+ GoondanConfig,
16
+ GoondanConfigError,
17
+ GoondanError,
18
+ GoondanExecutionError,
19
+ HookContext,
20
+ ModelContext,
21
+ NoLog,
22
+ RunHandle,
23
+ RunResult,
24
+ Tool,
25
+ define_extension,
26
+ define_tool,
27
+ )
28
+
29
+ __all__ = [
30
+ "Extension", "ExtensionDefinition", "HookContext", "ModelContext", "NoLog", "RunHandle", "RunResult",
31
+ "InMemoryStore", "Store", "StoreConflictError", "StoreError", "StoreInputError",
32
+ "FOLD_VERSION", "FoldError", "UnsupportedJournalVersionError", "fold",
33
+ "GoondanAbortError", "GoondanConfig", "GoondanConfigError", "GoondanError",
34
+ "GoondanExecutionError", "Goondan", "Tool",
35
+ "create_goondan", "define_extension", "define_tool", "load_config", "validate_config",
36
+ ]
@@ -0,0 +1,88 @@
1
+ """§JSON 텍스트: the one JSON text serializer the whole package uses.
2
+
3
+ `JSON 텍스트` is what `JSON.stringify` writes in the TypeScript host, so the number
4
+ spelling follows the ECMAScript `Number::toString` algorithm rather than Python's `repr`,
5
+ and strings are written without ASCII escaping. The runtime, the template `json` filter
6
+ and the model adapters all serialize through this module, so the package cannot
7
+ contradict itself about the text a model receives.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import json
13
+ import math
14
+ from decimal import Decimal
15
+ from typing import Any, Mapping
16
+
17
+ from .types import GoondanError
18
+
19
+
20
+ def _positional(raw: str) -> str:
21
+ """The exponent spelling `repr` produced, written out in positional notation.
22
+
23
+ Only a fractional tail loses its trailing zeros: the zeros of an integer part carry
24
+ the magnitude, so `1e16` is `10000000000000000` and never `1`.
25
+ """
26
+ text = format(Decimal(raw), "f")
27
+ return text.rstrip("0").rstrip(".") if "." in text else text
28
+
29
+
30
+ def number_text(value: int | float) -> str:
31
+ """§JSON 텍스트: the `Number::toString` spelling of one finite JSON number."""
32
+ if isinstance(value, bool):
33
+ raise GoondanError("a boolean is not a JSON number")
34
+ if isinstance(value, int):
35
+ return str(value)
36
+ if not math.isfinite(value):
37
+ raise GoondanError("JSON numbers must be finite")
38
+ # `JSON.stringify(-0)` is `0`, so the sign of a zero is never written.
39
+ if value == 0:
40
+ return "0"
41
+ absolute = abs(value)
42
+ raw = repr(value).lower()
43
+ if 1e-6 <= absolute < 1e21:
44
+ # ECMAScript writes this range without an exponent; Python's `repr` may not.
45
+ if "e" in raw:
46
+ return _positional(raw)
47
+ return raw[:-2] if raw.endswith(".0") else raw
48
+ if "e" not in raw:
49
+ return raw
50
+ mantissa, exponent = raw.split("e")
51
+ if "." in mantissa:
52
+ mantissa = mantissa.rstrip("0").rstrip(".")
53
+ power = int(exponent)
54
+ return f"{mantissa}e{'+' if power >= 0 else '-'}{abs(power)}"
55
+
56
+
57
+ def _text(value: str) -> str:
58
+ return json.dumps(value, ensure_ascii=False)
59
+
60
+
61
+ def _write(value: Any, indent: int, level: int) -> str:
62
+ if value is None: return "null"
63
+ if value is True: return "true"
64
+ if value is False: return "false"
65
+ if isinstance(value, (int, float)): return number_text(value)
66
+ if isinstance(value, str): return _text(value)
67
+ compact = indent == 0
68
+ if isinstance(value, list):
69
+ if not value: return "[]"
70
+ if compact: return "[" + ",".join(_write(item, 0, 0) for item in value) + "]"
71
+ inner = ",\n".join(" " * (level + 1) + _write(item, indent, level + 1) for item in value)
72
+ return "[\n" + inner + "\n" + " " * level + "]"
73
+ if isinstance(value, Mapping):
74
+ if not value: return "{}"
75
+ if compact: return "{" + ",".join(f"{_text(str(key))}:{_write(item, 0, 0)}" for key, item in value.items()) + "}"
76
+ inner = ",\n".join(" " * (level + 1) + f"{_text(str(key))}: {_write(item, indent, level + 1)}" for key, item in value.items())
77
+ return "{\n" + inner + "\n" + " " * level + "}"
78
+ raise GoondanError(f"value is not JSON: {type(value).__name__}")
79
+
80
+
81
+ def json_text(value: Any) -> str:
82
+ """§JSON 텍스트: the compact text, with no spaces between members and no ASCII escaping."""
83
+ return _write(value, 0, 0)
84
+
85
+
86
+ def json_pretty_text(value: Any) -> str:
87
+ """The indented form the `json` filter without an argument produces: two spaces per level."""
88
+ return _write(value, 2, 0)