dynos-client 0.2.2__tar.gz → 0.3.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 (31) hide show
  1. dynos_client-0.3.0/LICENSE +202 -0
  2. {dynos_client-0.2.2 → dynos_client-0.3.0}/PKG-INFO +17 -11
  3. {dynos_client-0.2.2 → dynos_client-0.3.0}/README.md +11 -9
  4. {dynos_client-0.2.2 → dynos_client-0.3.0}/pyproject.toml +8 -2
  5. dynos_client-0.3.0/src/dynos_client/_config.py +22 -0
  6. dynos_client-0.3.0/src/dynos_client/_credentials.py +38 -0
  7. dynos_client-0.3.0/src/dynos_client/_http_errors.py +31 -0
  8. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/action.py +16 -2
  9. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/action_context.py +36 -4
  10. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/auth_cli.py +30 -6
  11. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/belief.py +9 -70
  12. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/call.py +136 -11
  13. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/cli.py +2 -2
  14. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/mission.py +22 -8
  15. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/remote_orchestrator.py +182 -41
  16. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/servant.py +78 -13
  17. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/session_cli.py +43 -38
  18. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/session_manager.py +74 -7
  19. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client.egg-info/PKG-INFO +17 -11
  20. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client.egg-info/SOURCES.txt +4 -0
  21. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client.egg-info/requires.txt +1 -1
  22. {dynos_client-0.2.2 → dynos_client-0.3.0}/setup.cfg +0 -0
  23. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/__init__.py +0 -0
  24. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/__main__.py +0 -0
  25. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/domain.py +0 -0
  26. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/expr_parser.py +0 -0
  27. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/hash_cli.py +0 -0
  28. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client/resolve_runnable.py +0 -0
  29. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client.egg-info/dependency_links.txt +0 -0
  30. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client.egg-info/entry_points.txt +0 -0
  31. {dynos_client-0.2.2 → dynos_client-0.3.0}/src/dynos_client.egg-info/top_level.txt +0 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Christopher Thierauf
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -1,11 +1,15 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dynos-client
3
- Version: 0.2.2
3
+ Version: 0.3.0
4
4
  Summary: Client and CLI for orchestrating DYNOS backends remotely
5
+ Author: Chris Thierauf
5
6
  License: Apache-2.0
7
+ Project-URL: Homepage, https://dynosplan.com
8
+ Project-URL: Source, https://git.whoi.edu/cthierauf/dynos_public
6
9
  Requires-Python: >=3.8
7
10
  Description-Content-Type: text/markdown
8
- Requires-Dist: dynos-core>=0.2.2
11
+ License-File: LICENSE
12
+ Requires-Dist: dynos-core<0.4,>=0.3.0
9
13
  Requires-Dist: requests
10
14
  Requires-Dist: typer
11
15
  Requires-Dist: bcrypt>=4.0
@@ -33,11 +37,13 @@ backend itself.
33
37
 
34
38
  ## Install
35
39
 
40
+ From PyPI:
41
+
36
42
  ```bash
37
43
  pip install dynos-client
38
44
  ```
39
45
 
40
- Pulls in `dynos-core`, `requests`, `typer`, and `bcrypt`. Registers a `dynos` console script.
46
+ Pulls in `dynos-core`, `requests`, `typer`, `bcrypt`, and `rich`. Registers a `dynos` console script.
41
47
 
42
48
  ## Sessions and the backend
43
49
 
@@ -82,7 +88,7 @@ run `swap` or `create`.
82
88
  | `dynos call <subcmd>` | Talk to a running backend: `health`, `goal`, `plan`, `execute`, `state`, `objects`, `trigger`, `reset`, `geojson`, ... |
83
89
  | `dynos session <subcmd>` | Manage gateway sessions: `create`, `list`, `info`, `swap`, `extend`, `reset`, `stop`. |
84
90
  | `dynos connect <module>:<Class>` | Run as a *servant*; the backend dispatches actions over HTTP and your local code executes them. |
85
- | `dynos hash-password` | Produce a bcrypt hash for the gateway's admin user table. You can send this to the server admin (me) to change your pw |
91
+ | `dynos hash-password` | Produce a bcrypt hash for the gateway's user table; send the hash (not your password) to the operator to set or change your password. |
86
92
 
87
93
  Run any of them with `--help` for full options.
88
94
 
@@ -131,7 +137,7 @@ trust (e.g. recording `at(wp_end)` without descent ever happening).
131
137
  dynos call trigger "resample_zone(source_zone=site_alpha)" # OK for debug
132
138
  ```
133
139
 
134
- If you find yourself wanting to chain `trigger` calls, you actually want a
140
+ If you find yourself wanting to chain `trigger` calls, you want a
135
141
  goal. Let the planner sequence them.
136
142
 
137
143
  ## Missions
@@ -147,10 +153,10 @@ from dynos_sentry.sentry import Zone, full_coverage_of
147
153
  orch = RemoteOrchestrator.from_config(timeout_s=3600)
148
154
 
149
155
  area_north = Zone("area_north", coordinate_frame="geographic",
150
- vertices=[[-70.67, 41.525], [-70.66, 41.525], [-70.66, 41.53], [-70.67, 41.53]],
156
+ vertices=[[-129.99, 45.965], [-129.98, 45.965], [-129.98, 45.97], [-129.99, 45.97]],
151
157
  altitude=70.0, speed=0.8, coverage_width=170.0, robot_width=0.5)
152
158
  area_south = Zone("area_south", coordinate_frame="geographic",
153
- vertices=[[-70.67, 41.52], [-70.66, 41.52], [-70.66, 41.525], [-70.67, 41.525]],
159
+ vertices=[[-129.99, 45.96], [-129.98, 45.96], [-129.98, 45.965], [-129.99, 45.965]],
154
160
  altitude=70.0, speed=0.8, coverage_width=170.0, robot_width=0.5)
155
161
  orch.create_object(area_north)
156
162
  orch.create_object(area_south)
@@ -174,9 +180,9 @@ results = orch.execute_blocks(mission)
174
180
  ```
175
181
 
176
182
  A single plan block can carry multiple goals; the planner finds one plan that
177
- achieves all of them. Note what is *not* here: no takeover, descent, or abort
183
+ achieves all of them. What is *not* here: no takeover, descent, or abort
178
184
  steps. Those bookends (and the vehicle's abort/recovery) are added by the
179
- mission framework and the on-vehicle safety system, not by you -- a client
185
+ mission framework and the on-vehicle safety system, not by you. A client
180
186
  never assembles lifecycle or abort steps, and never puts a phase in a goal. A
181
187
  plan block is the normal building block; an action block (a single transition,
182
188
  no planning) strips out the replanning context and is reserved for genuine
@@ -186,13 +192,13 @@ imperative primitives.
186
192
 
187
193
  `create_object` returns the backend record by default. When you submit a point
188
194
  whose coordinates match an existing one, the backend collapses them onto a
189
- single object and reports the canonical name under `merged_into` -- so the name
195
+ single object and reports the canonical name under `merged_into`, so the name
190
196
  you get back may differ from the one you sent, and you may no longer be holding
191
197
  the object that another call created earlier.
192
198
 
193
199
  Pass `return_ref=True` to get a client-side handle bound to that canonical name,
194
200
  whether the object was freshly created or merged. Feed it straight into fluents
195
- and `set_goal` -- no need to read `merged_into`, and no string references:
201
+ and `set_goal`; no need to read `merged_into`, and no string references:
196
202
 
197
203
  ```python
198
204
  from dynos_sentry.sentry import Coordinate, at
@@ -20,11 +20,13 @@ backend itself.
20
20
 
21
21
  ## Install
22
22
 
23
+ From PyPI:
24
+
23
25
  ```bash
24
26
  pip install dynos-client
25
27
  ```
26
28
 
27
- Pulls in `dynos-core`, `requests`, `typer`, and `bcrypt`. Registers a `dynos` console script.
29
+ Pulls in `dynos-core`, `requests`, `typer`, `bcrypt`, and `rich`. Registers a `dynos` console script.
28
30
 
29
31
  ## Sessions and the backend
30
32
 
@@ -69,7 +71,7 @@ run `swap` or `create`.
69
71
  | `dynos call <subcmd>` | Talk to a running backend: `health`, `goal`, `plan`, `execute`, `state`, `objects`, `trigger`, `reset`, `geojson`, ... |
70
72
  | `dynos session <subcmd>` | Manage gateway sessions: `create`, `list`, `info`, `swap`, `extend`, `reset`, `stop`. |
71
73
  | `dynos connect <module>:<Class>` | Run as a *servant*; the backend dispatches actions over HTTP and your local code executes them. |
72
- | `dynos hash-password` | Produce a bcrypt hash for the gateway's admin user table. You can send this to the server admin (me) to change your pw |
74
+ | `dynos hash-password` | Produce a bcrypt hash for the gateway's user table; send the hash (not your password) to the operator to set or change your password. |
73
75
 
74
76
  Run any of them with `--help` for full options.
75
77
 
@@ -118,7 +120,7 @@ trust (e.g. recording `at(wp_end)` without descent ever happening).
118
120
  dynos call trigger "resample_zone(source_zone=site_alpha)" # OK for debug
119
121
  ```
120
122
 
121
- If you find yourself wanting to chain `trigger` calls, you actually want a
123
+ If you find yourself wanting to chain `trigger` calls, you want a
122
124
  goal. Let the planner sequence them.
123
125
 
124
126
  ## Missions
@@ -134,10 +136,10 @@ from dynos_sentry.sentry import Zone, full_coverage_of
134
136
  orch = RemoteOrchestrator.from_config(timeout_s=3600)
135
137
 
136
138
  area_north = Zone("area_north", coordinate_frame="geographic",
137
- vertices=[[-70.67, 41.525], [-70.66, 41.525], [-70.66, 41.53], [-70.67, 41.53]],
139
+ vertices=[[-129.99, 45.965], [-129.98, 45.965], [-129.98, 45.97], [-129.99, 45.97]],
138
140
  altitude=70.0, speed=0.8, coverage_width=170.0, robot_width=0.5)
139
141
  area_south = Zone("area_south", coordinate_frame="geographic",
140
- vertices=[[-70.67, 41.52], [-70.66, 41.52], [-70.66, 41.525], [-70.67, 41.525]],
142
+ vertices=[[-129.99, 45.96], [-129.98, 45.96], [-129.98, 45.965], [-129.99, 45.965]],
141
143
  altitude=70.0, speed=0.8, coverage_width=170.0, robot_width=0.5)
142
144
  orch.create_object(area_north)
143
145
  orch.create_object(area_south)
@@ -161,9 +163,9 @@ results = orch.execute_blocks(mission)
161
163
  ```
162
164
 
163
165
  A single plan block can carry multiple goals; the planner finds one plan that
164
- achieves all of them. Note what is *not* here: no takeover, descent, or abort
166
+ achieves all of them. What is *not* here: no takeover, descent, or abort
165
167
  steps. Those bookends (and the vehicle's abort/recovery) are added by the
166
- mission framework and the on-vehicle safety system, not by you -- a client
168
+ mission framework and the on-vehicle safety system, not by you. A client
167
169
  never assembles lifecycle or abort steps, and never puts a phase in a goal. A
168
170
  plan block is the normal building block; an action block (a single transition,
169
171
  no planning) strips out the replanning context and is reserved for genuine
@@ -173,13 +175,13 @@ imperative primitives.
173
175
 
174
176
  `create_object` returns the backend record by default. When you submit a point
175
177
  whose coordinates match an existing one, the backend collapses them onto a
176
- single object and reports the canonical name under `merged_into` -- so the name
178
+ single object and reports the canonical name under `merged_into`, so the name
177
179
  you get back may differ from the one you sent, and you may no longer be holding
178
180
  the object that another call created earlier.
179
181
 
180
182
  Pass `return_ref=True` to get a client-side handle bound to that canonical name,
181
183
  whether the object was freshly created or merged. Feed it straight into fluents
182
- and `set_goal` -- no need to read `merged_into`, and no string references:
184
+ and `set_goal`; no need to read `merged_into`, and no string references:
183
185
 
184
186
  ```python
185
187
  from dynos_sentry.sentry import Coordinate, at
@@ -4,15 +4,21 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dynos-client"
7
- version = "0.2.2"
7
+ version = "0.3.0"
8
8
  description = "Client and CLI for orchestrating DYNOS backends remotely"
9
9
  readme = "README.md"
10
10
  license = { text = "Apache-2.0" }
11
+ authors = [{ name = "Chris Thierauf" }]
11
12
  requires-python = ">=3.8"
12
- dependencies = ["dynos-core>=0.2.2", "requests", "typer", "bcrypt>=4.0", "rich"]
13
+ dependencies = ["dynos-core>=0.3.0,<0.4", "requests", "typer", "bcrypt>=4.0", "rich"]
13
14
 
14
15
  [project.scripts]
15
16
  dynos = "dynos_client.cli:main"
16
17
 
17
18
  [tool.setuptools.packages.find]
18
19
  where = ["src"]
20
+
21
+ # Documentation (https://dynosplan.com/docs) is added when the docs site is live.
22
+ [project.urls]
23
+ Homepage = "https://dynosplan.com"
24
+ Source = "https://git.whoi.edu/cthierauf/dynos_public"
@@ -0,0 +1,22 @@
1
+ """Single source for the on-disk DYNOS client config (token cache) location.
2
+
3
+ ``dynos login`` writes the bearer token + backend URL here; every reader (the
4
+ ``dynos session`` CLI, ``dynos call``, ``RemoteOrchestrator.from_config``) must
5
+ resolve the SAME path, or ``login`` writes a token a reader never finds and the
6
+ user silently appears logged out. One definition so the write path and every
7
+ read path cannot drift. Overridable via ``DYNOS_CONFIG_PATH`` (tests point it at
8
+ a temp file).
9
+ """
10
+
11
+ import os
12
+ from pathlib import Path
13
+
14
+ #: Env var that overrides the default config-file location.
15
+ CONFIG_PATH_ENV = "DYNOS_CONFIG_PATH"
16
+
17
+
18
+ def config_path() -> Path:
19
+ """Path to the client config file (``~/.dynos/config.json`` by default)."""
20
+ return Path(
21
+ os.environ.get(CONFIG_PATH_ENV, str(Path.home() / ".dynos" / "config.json"))
22
+ )
@@ -0,0 +1,38 @@
1
+ """Shared credential-file safety check.
2
+
3
+ One source of truth for the "refuse, don't chmod" invariant: a bearer token
4
+ stored in a world/group-readable file is a credential anyone with shell access
5
+ can read, so refuse to load it and point the operator at the fix rather than
6
+ silently changing their file permissions. Reused by every CLI that reads the
7
+ cached token so the security behavior cannot drift between copies.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import os
13
+ from pathlib import Path
14
+
15
+ import typer
16
+ from rich.console import Console
17
+
18
+ _console = Console()
19
+
20
+
21
+ def refuse_if_world_or_group_readable(path: Path) -> None:
22
+ """Refuse to load a token from a file readable by group or world.
23
+
24
+ The bearer token in the config file is a credential. We do not silently
25
+ ``chmod``; the operator decides whether to fix the permissions or rotate
26
+ the credential. Skipped on platforms without POSIX file modes (Windows).
27
+ """
28
+ try:
29
+ mode = os.stat(str(path)).st_mode & 0o777
30
+ except OSError:
31
+ return # file vanished between the caller's check and stat(); caller handles
32
+ if mode & 0o077:
33
+ _console.print(
34
+ f"[red]Refusing to read {path}: mode is {oct(mode)} (group/world "
35
+ f"accessible). The token is a credential. Run "
36
+ f"`chmod 600 {path}` or rotate the token via `dynos login`.[/red]"
37
+ )
38
+ raise typer.Exit(1)
@@ -0,0 +1,31 @@
1
+ """Shared best-effort extraction of a short error detail from an HTTP response.
2
+
3
+ One source of truth for turning a 4xx/5xx ``requests.Response`` into a concise
4
+ human-readable string, reused by the remote orchestrator and the CLI command
5
+ groups so the robust JSON-``detail``/body/status fallback does not drift into
6
+ thinner hand-rolled copies.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from typing import TYPE_CHECKING
12
+
13
+ if TYPE_CHECKING:
14
+ import requests
15
+
16
+
17
+ def resp_detail(resp: "requests.Response") -> str:
18
+ """Best-effort short detail string from an error response.
19
+
20
+ Tries the JSON ``detail`` field (FastAPI's convention), falls back to the
21
+ body text, then the status line. Truncated to keep error messages short.
22
+ """
23
+ try:
24
+ body = resp.json()
25
+ if isinstance(body, dict):
26
+ d = body.get("detail")
27
+ if isinstance(d, str):
28
+ return d
29
+ return str(body)[:200]
30
+ except (ValueError, TypeError):
31
+ return resp.text[:200] if resp.text else f"HTTP {resp.status_code}"
@@ -8,8 +8,22 @@ backend. When the backend IS installed, its @Action takes precedence.
8
8
  import inspect
9
9
 
10
10
 
11
- def Action(transition_or_func=None, *, transition=None, **_):
12
- """Decorate a method as an action bound to a transition."""
11
+ def Action(transition_or_func=None, *, transition=None, **unsupported):
12
+ """Decorate a method as an action bound to a transition.
13
+
14
+ Only ``transition`` is honoured for a servant action. The backend's
15
+ ``@Action`` options (``cost``, ``queue``, ``repeat_hz``, ...) configure how
16
+ the backend itself runs an action and have no effect on one that runs on a
17
+ servant, so passing them raises instead of being silently dropped.
18
+ """
19
+ if unsupported:
20
+ raise TypeError(
21
+ f"the client @Action does not support {sorted(unsupported)}: a "
22
+ "servant action only takes transition=. Cost, queue and timing "
23
+ "options apply to actions that run inside the backend, not to "
24
+ "actions run by `dynos connect`; remove them, or ask the backend "
25
+ "operator to host the action."
26
+ )
13
27
  if transition_or_func is None or not callable(transition_or_func):
14
28
  t = transition_or_func or transition
15
29
 
@@ -7,13 +7,16 @@ this module only implements the slice user ``@Action`` methods actually need
7
7
  when dispatched via ``dynos connect``: a structured logger, the audit ID, and
8
8
  the transition name.
9
9
 
10
- If a user's ``@Action`` reaches for ``ctx.report_progress`` /
11
- ``ctx.check_cancelled`` / ``ctx.read_sensor`` / ``ctx.call_hardware`` from
12
- the servant side, an ``AttributeError`` is the right outcome; the action
13
- is using backend-only machinery that isn't available remotely.
10
+ ``ctx.check_cancelled()`` reports whether the backend has asked this action to
11
+ stop (its step was preempted, e.g. by a goal change); a long-running action
12
+ should poll it and return early. ``ctx.report_progress`` / ``ctx.read_sensor``
13
+ / ``ctx.heartbeat`` are backend-only machinery: reaching for them from the
14
+ servant side raises ``AttributeError``. The servant heartbeats on the action's
15
+ behalf while it runs.
14
16
  """
15
17
 
16
18
  import logging
19
+ import threading
17
20
  from dataclasses import dataclass, field
18
21
  from typing import Any, Optional
19
22
 
@@ -65,3 +68,32 @@ class ClientActionContext:
65
68
  default_factory=lambda: _ClientActionLogger(logging.getLogger("dynos.servant"))
66
69
  )
67
70
  orchestrator: Optional[Any] = None
71
+ cancel_event: threading.Event = field(default_factory=threading.Event)
72
+
73
+ def check_cancelled(self) -> bool:
74
+ """True once the backend has asked this action to stop.
75
+
76
+ Poll it in long loops and return early (an ``ActionResult.failure``
77
+ explaining the stop is the usual answer); the backend has already
78
+ moved on to replanning.
79
+ """
80
+ return self.cancel_event.is_set()
81
+
82
+ def _require_orchestrator(self) -> Any:
83
+ if self.orchestrator is None:
84
+ raise RuntimeError(
85
+ f"ctx.create_object/list_objects for '{self.transition_name}' has no "
86
+ f"orchestrator: this servant context was built without one. Dispatch via "
87
+ f"RemoteOrchestrator.trigger_action (which wires it), do not reconstruct "
88
+ f"a client from ~/.dynos."
89
+ )
90
+ return self.orchestrator
91
+
92
+ def create_object(self, obj: Any) -> Any:
93
+ """Register a domain object on the backend this servant is connected to --
94
+ the audited object-management capability, portable with the in-process ctx."""
95
+ return self._require_orchestrator().create_object(obj)
96
+
97
+ def list_objects(self) -> Any:
98
+ """List the backend's domain objects (same records as the in-process ctx)."""
99
+ return self._require_orchestrator().list_objects()
@@ -16,6 +16,7 @@ import typer
16
16
  from rich.console import Console
17
17
  from rich.table import Table, box
18
18
 
19
+ from dynos_client._http_errors import resp_detail
19
20
  from dynos_client.call import DEFAULT_BACKEND, _normalize_backend_url
20
21
  from dynos_client.session_cli import _read_cache, _write_cache
21
22
 
@@ -59,12 +60,9 @@ def login(
59
60
  console.print(f"[red]Cannot reach {url}: {exc}[/red]")
60
61
  raise typer.Exit(1)
61
62
  if resp.status_code != 200:
62
- detail = resp.text
63
- try:
64
- detail = resp.json().get("detail", detail)
65
- except Exception:
66
- pass
67
- console.print(f"[red]Login failed ({resp.status_code}): {detail}[/red]")
63
+ console.print(
64
+ f"[red]Login failed ({resp.status_code}): {resp_detail(resp)}[/red]"
65
+ )
68
66
  raise typer.Exit(1)
69
67
  body = resp.json()
70
68
 
@@ -78,6 +76,32 @@ def login(
78
76
  f"[green]Logged in as {body['username']} "
79
77
  f"({body.get('role', 'user')}) at {url}[/green]"
80
78
  )
79
+ _warn_on_api_mismatch(url)
80
+
81
+
82
+ def _warn_on_api_mismatch(url: str) -> None:
83
+ """Warn when the backend speaks a different public-package line than this
84
+ client (its /health ``api``, e.g. ``0.3``). Best effort: says nothing when
85
+ the backend does not report one or cannot be reached."""
86
+ from importlib.metadata import PackageNotFoundError, version
87
+
88
+ try:
89
+ mine = ".".join(version("dynos-client").split(".")[:2])
90
+ theirs = requests.get(f"{url}/health", timeout=10).json().get("api")
91
+ except (PackageNotFoundError, requests.RequestException, ValueError):
92
+ return
93
+ if theirs and theirs != "unknown" and theirs != mine:
94
+ console.print(
95
+ f"[yellow]This backend speaks the DYNOS {theirs} public packages; you "
96
+ f"have dynos-client {mine}. Install the matching line: "
97
+ f"pip install 'dynos-client>={theirs},<{_next_line(theirs)}'[/yellow]"
98
+ )
99
+
100
+
101
+ def _next_line(line: str) -> str:
102
+ """The line after ``line`` (``0.3`` -> ``0.4``)."""
103
+ major, minor = line.split(".")[:2]
104
+ return f"{major}.{int(minor) + 1}"
81
105
 
82
106
 
83
107
  def logout() -> None: