kaiten-cli 0.3.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. kaiten_cli/__init__.py +5 -0
  2. kaiten_cli/__main__.py +9 -0
  3. kaiten_cli/agent_gateway.py +577 -0
  4. kaiten_cli/app.py +1636 -0
  5. kaiten_cli/completion.py +570 -0
  6. kaiten_cli/discovery.py +39 -0
  7. kaiten_cli/errors.py +79 -0
  8. kaiten_cli/i18n.py +92 -0
  9. kaiten_cli/locales/ru.json +2967 -0
  10. kaiten_cli/localized_click.py +160 -0
  11. kaiten_cli/models.py +202 -0
  12. kaiten_cli/profiles.py +316 -0
  13. kaiten_cli/registry/__init__.py +260 -0
  14. kaiten_cli/registry/addons.py +392 -0
  15. kaiten_cli/registry/audit_and_analytics.py +451 -0
  16. kaiten_cli/registry/automation_schema.py +44 -0
  17. kaiten_cli/registry/automation_schemas.json +7417 -0
  18. kaiten_cli/registry/automations.py +342 -0
  19. kaiten_cli/registry/base.py +62 -0
  20. kaiten_cli/registry/blockers.py +320 -0
  21. kaiten_cli/registry/boards.py +520 -0
  22. kaiten_cli/registry/card_relations.py +376 -0
  23. kaiten_cli/registry/card_types.py +363 -0
  24. kaiten_cli/registry/cards.py +1329 -0
  25. kaiten_cli/registry/charts.py +539 -0
  26. kaiten_cli/registry/checklists.py +600 -0
  27. kaiten_cli/registry/columns.py +558 -0
  28. kaiten_cli/registry/comments.py +224 -0
  29. kaiten_cli/registry/custom_directories.py +980 -0
  30. kaiten_cli/registry/custom_properties.py +1460 -0
  31. kaiten_cli/registry/dashboards.py +564 -0
  32. kaiten_cli/registry/documents.py +761 -0
  33. kaiten_cli/registry/external_links.py +128 -0
  34. kaiten_cli/registry/files.py +738 -0
  35. kaiten_cli/registry/github_addon.py +613 -0
  36. kaiten_cli/registry/iterations.py +397 -0
  37. kaiten_cli/registry/lanes.py +205 -0
  38. kaiten_cli/registry/live_contracts.py +361 -0
  39. kaiten_cli/registry/members.py +336 -0
  40. kaiten_cli/registry/module_docs.py +108 -0
  41. kaiten_cli/registry/projects.py +369 -0
  42. kaiten_cli/registry/query.py +129 -0
  43. kaiten_cli/registry/restrictions.py +249 -0
  44. kaiten_cli/registry/roles_and_groups.py +1102 -0
  45. kaiten_cli/registry/scim.py +263 -0
  46. kaiten_cli/registry/service_desk.py +1270 -0
  47. kaiten_cli/registry/snapshot.py +187 -0
  48. kaiten_cli/registry/spaces.py +272 -0
  49. kaiten_cli/registry/subscribers.py +168 -0
  50. kaiten_cli/registry/tags.py +193 -0
  51. kaiten_cli/registry/time_logs.py +353 -0
  52. kaiten_cli/registry/tree.py +352 -0
  53. kaiten_cli/registry/utilities.py +287 -0
  54. kaiten_cli/registry/webhooks.py +265 -0
  55. kaiten_cli/runtime/__init__.py +1 -0
  56. kaiten_cli/runtime/automation_validation.py +115 -0
  57. kaiten_cli/runtime/behaviors.py +787 -0
  58. kaiten_cli/runtime/cache.py +733 -0
  59. kaiten_cli/runtime/client.py +387 -0
  60. kaiten_cli/runtime/endpoints.py +59 -0
  61. kaiten_cli/runtime/executor.py +269 -0
  62. kaiten_cli/runtime/fs_security.py +168 -0
  63. kaiten_cli/runtime/input.py +310 -0
  64. kaiten_cli/runtime/output.py +59 -0
  65. kaiten_cli/runtime/public_validation.py +35 -0
  66. kaiten_cli/runtime/snapshot_build.py +527 -0
  67. kaiten_cli/runtime/snapshot_common.py +363 -0
  68. kaiten_cli/runtime/snapshot_query.py +306 -0
  69. kaiten_cli/runtime/snapshot_store.py +1192 -0
  70. kaiten_cli/runtime/snapshots.py +62 -0
  71. kaiten_cli/runtime/sqlite_errors.py +23 -0
  72. kaiten_cli/runtime/support/__init__.py +1 -0
  73. kaiten_cli/runtime/support/addons.py +953 -0
  74. kaiten_cli/runtime/support/audit.py +70 -0
  75. kaiten_cli/runtime/support/batch.py +234 -0
  76. kaiten_cli/runtime/support/card_move_url.py +213 -0
  77. kaiten_cli/runtime/support/cards.py +174 -0
  78. kaiten_cli/runtime/support/checklists.py +21 -0
  79. kaiten_cli/runtime/support/company_users.py +117 -0
  80. kaiten_cli/runtime/support/dashboards.py +35 -0
  81. kaiten_cli/runtime/support/documents.py +175 -0
  82. kaiten_cli/runtime/support/files.py +561 -0
  83. kaiten_cli/runtime/support/markdown_export.py +525 -0
  84. kaiten_cli/runtime/support/pagination.py +167 -0
  85. kaiten_cli/runtime/support/projects.py +66 -0
  86. kaiten_cli/runtime/support/relations.py +86 -0
  87. kaiten_cli/runtime/support/restrictions.py +62 -0
  88. kaiten_cli/runtime/support/spaces.py +20 -0
  89. kaiten_cli/runtime/support/time_logs.py +61 -0
  90. kaiten_cli/runtime/support/tree.py +140 -0
  91. kaiten_cli/runtime/support/tree_sharing.py +447 -0
  92. kaiten_cli/runtime/trace.py +500 -0
  93. kaiten_cli/runtime/transforms.py +128 -0
  94. kaiten_cli/schema_docs.py +22 -0
  95. kaiten_cli/update_check.py +519 -0
  96. kaiten_cli-0.3.3.dist-info/METADATA +1110 -0
  97. kaiten_cli-0.3.3.dist-info/RECORD +99 -0
  98. kaiten_cli-0.3.3.dist-info/WHEEL +4 -0
  99. kaiten_cli-0.3.3.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,265 @@
1
+ """Webhook tool specs."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from kaiten_cli.models import ExampleSpec, OperationSpec
6
+ from kaiten_cli.registry.base import make_tool
7
+
8
+
9
+ TOOLS = (
10
+ make_tool(
11
+ canonical_name="webhooks.list",
12
+ mcp_alias="kaiten_list_webhooks",
13
+ description="List all external webhooks for a Kaiten space.",
14
+ input_schema={
15
+ "type": "object",
16
+ "properties": {
17
+ "space_id": {"type": "integer", "description": "Space ID"},
18
+ },
19
+ "required": ["space_id"],
20
+ },
21
+ operation=OperationSpec(
22
+ method="GET",
23
+ path_template="/spaces/{space_id}/external-webhooks",
24
+ path_fields=("space_id",),
25
+ ),
26
+ examples=(
27
+ ExampleSpec(
28
+ command="kaiten --json webhooks list --space-id 1",
29
+ description="List external webhooks.",
30
+ ),
31
+ ),
32
+ ),
33
+ make_tool(
34
+ canonical_name="webhooks.create",
35
+ mcp_alias="kaiten_create_webhook",
36
+ description="Create an external webhook for a Kaiten space.",
37
+ input_schema={
38
+ "type": "object",
39
+ "properties": {
40
+ "space_id": {"type": "integer", "description": "Space ID"},
41
+ "url": {"type": "string", "description": "Webhook URL"},
42
+ },
43
+ "required": ["space_id", "url"],
44
+ },
45
+ operation=OperationSpec(
46
+ method="POST",
47
+ path_template="/spaces/{space_id}/external-webhooks",
48
+ path_fields=("space_id",),
49
+ body_fields=("url",),
50
+ ),
51
+ examples=(
52
+ ExampleSpec(
53
+ command='kaiten --json webhooks create --space-id 1 --url "https://example.test"',
54
+ description="Create an external webhook.",
55
+ ),
56
+ ),
57
+ ),
58
+ make_tool(
59
+ canonical_name="webhooks.get",
60
+ mcp_alias="kaiten_get_webhook",
61
+ description="Get a specific external webhook for a Kaiten space.",
62
+ input_schema={
63
+ "type": "object",
64
+ "properties": {
65
+ "space_id": {"type": "integer", "description": "Space ID"},
66
+ "webhook_id": {"type": "integer", "description": "Webhook ID"},
67
+ },
68
+ "required": ["space_id", "webhook_id"],
69
+ },
70
+ operation=OperationSpec(
71
+ method="GET",
72
+ path_template="/spaces/{space_id}/external-webhooks/{webhook_id}",
73
+ path_fields=("space_id", "webhook_id"),
74
+ ),
75
+ examples=(
76
+ ExampleSpec(
77
+ command="kaiten --json webhooks get --space-id 1 --webhook-id 2",
78
+ description="Get an external webhook.",
79
+ ),
80
+ ),
81
+ ),
82
+ make_tool(
83
+ canonical_name="webhooks.update",
84
+ mcp_alias="kaiten_update_webhook",
85
+ description="Update an external webhook for a Kaiten space.",
86
+ input_schema={
87
+ "type": "object",
88
+ "properties": {
89
+ "space_id": {"type": "integer", "description": "Space ID"},
90
+ "webhook_id": {"type": "integer", "description": "Webhook ID"},
91
+ "url": {"type": "string", "description": "Webhook URL"},
92
+ "enabled": {"type": "boolean", "description": "Whether the webhook is enabled"},
93
+ },
94
+ "required": ["space_id", "webhook_id"],
95
+ },
96
+ operation=OperationSpec(
97
+ method="PATCH",
98
+ path_template="/spaces/{space_id}/external-webhooks/{webhook_id}",
99
+ path_fields=("space_id", "webhook_id"),
100
+ body_fields=("url", "enabled"),
101
+ ),
102
+ examples=(
103
+ ExampleSpec(
104
+ command="kaiten --json webhooks update --space-id 1 --webhook-id 2 --enabled",
105
+ description="Update an external webhook.",
106
+ ),
107
+ ),
108
+ ),
109
+ make_tool(
110
+ canonical_name="webhooks.delete",
111
+ mcp_alias="kaiten_delete_webhook",
112
+ description="Delete an external webhook from a Kaiten space.",
113
+ input_schema={
114
+ "type": "object",
115
+ "properties": {
116
+ "space_id": {"type": "integer", "description": "Space ID"},
117
+ "webhook_id": {"type": "integer", "description": "Webhook ID"},
118
+ },
119
+ "required": ["space_id", "webhook_id"],
120
+ },
121
+ operation=OperationSpec(
122
+ method="DELETE",
123
+ path_template="/spaces/{space_id}/external-webhooks/{webhook_id}",
124
+ path_fields=("space_id", "webhook_id"),
125
+ ),
126
+ examples=(
127
+ ExampleSpec(
128
+ command="kaiten --json webhooks delete --space-id 1 --webhook-id 2",
129
+ description="Delete an external webhook.",
130
+ ),
131
+ ),
132
+ ),
133
+ make_tool(
134
+ canonical_name="incoming-webhooks.list",
135
+ mcp_alias="kaiten_list_incoming_webhooks",
136
+ description="List incoming card-creation webhooks for a Kaiten space.",
137
+ input_schema={
138
+ "type": "object",
139
+ "properties": {
140
+ "space_id": {"type": "integer", "description": "Space ID"},
141
+ },
142
+ "required": ["space_id"],
143
+ },
144
+ operation=OperationSpec(
145
+ method="GET", path_template="/spaces/{space_id}/webhooks", path_fields=("space_id",)
146
+ ),
147
+ examples=(
148
+ ExampleSpec(
149
+ command="kaiten --json incoming-webhooks list --space-id 1",
150
+ description="List incoming webhooks.",
151
+ ),
152
+ ),
153
+ ),
154
+ make_tool(
155
+ canonical_name="incoming-webhooks.create",
156
+ mcp_alias="kaiten_create_incoming_webhook",
157
+ description="Create an incoming card-creation webhook for a Kaiten space.",
158
+ input_schema={
159
+ "type": "object",
160
+ "properties": {
161
+ "space_id": {"type": "integer", "description": "Space ID"},
162
+ "board_id": {"type": "integer", "description": "Board ID"},
163
+ "column_id": {"type": "integer", "description": "Column ID"},
164
+ "lane_id": {"type": "integer", "description": "Lane ID"},
165
+ "owner_id": {"type": "integer", "description": "Owner user ID"},
166
+ "type_id": {"type": "integer", "description": "Card type ID"},
167
+ "position": {"type": "integer", "description": "Position in the column"},
168
+ "format": {
169
+ "type": "integer",
170
+ "enum": [1, 2, 3, 4, 5, 6, 7],
171
+ "description": "Payload format",
172
+ },
173
+ },
174
+ "required": ["space_id", "board_id", "column_id", "lane_id", "owner_id"],
175
+ },
176
+ operation=OperationSpec(
177
+ method="POST",
178
+ path_template="/spaces/{space_id}/webhooks",
179
+ path_fields=("space_id",),
180
+ body_fields=(
181
+ "board_id",
182
+ "column_id",
183
+ "lane_id",
184
+ "owner_id",
185
+ "type_id",
186
+ "position",
187
+ "format",
188
+ ),
189
+ ),
190
+ examples=(
191
+ ExampleSpec(
192
+ command="kaiten --json incoming-webhooks create --space-id 1 --board-id 2 --column-id 3 --lane-id 4 --owner-id 5",
193
+ description="Create an incoming webhook.",
194
+ ),
195
+ ),
196
+ ),
197
+ make_tool(
198
+ canonical_name="incoming-webhooks.update",
199
+ mcp_alias="kaiten_update_incoming_webhook",
200
+ description="Update an incoming card-creation webhook in a Kaiten space.",
201
+ input_schema={
202
+ "type": "object",
203
+ "properties": {
204
+ "space_id": {"type": "integer", "description": "Space ID"},
205
+ "webhook_id": {"type": "string", "description": "Webhook ID (hash string)"},
206
+ "board_id": {"type": "integer", "description": "Board ID"},
207
+ "column_id": {"type": "integer", "description": "Column ID"},
208
+ "lane_id": {"type": "integer", "description": "Lane ID"},
209
+ "owner_id": {"type": "integer", "description": "Owner user ID"},
210
+ "type_id": {"type": "integer", "description": "Card type ID"},
211
+ "position": {"type": "integer", "description": "Position in the column"},
212
+ "format": {
213
+ "type": "integer",
214
+ "enum": [1, 2, 3, 4, 5, 6, 7],
215
+ "description": "Payload format",
216
+ },
217
+ },
218
+ "required": ["space_id", "webhook_id"],
219
+ },
220
+ operation=OperationSpec(
221
+ method="PATCH",
222
+ path_template="/spaces/{space_id}/webhooks/{webhook_id}",
223
+ path_fields=("space_id", "webhook_id"),
224
+ body_fields=(
225
+ "board_id",
226
+ "column_id",
227
+ "lane_id",
228
+ "owner_id",
229
+ "type_id",
230
+ "position",
231
+ "format",
232
+ ),
233
+ ),
234
+ examples=(
235
+ ExampleSpec(
236
+ command="kaiten --json incoming-webhooks update --space-id 1 --webhook-id hook-1 --position 1",
237
+ description="Update an incoming webhook.",
238
+ ),
239
+ ),
240
+ ),
241
+ make_tool(
242
+ canonical_name="incoming-webhooks.delete",
243
+ mcp_alias="kaiten_delete_incoming_webhook",
244
+ description="Delete an incoming card-creation webhook from a Kaiten space.",
245
+ input_schema={
246
+ "type": "object",
247
+ "properties": {
248
+ "space_id": {"type": "integer", "description": "Space ID"},
249
+ "webhook_id": {"type": "string", "description": "Webhook ID (hash string)"},
250
+ },
251
+ "required": ["space_id", "webhook_id"],
252
+ },
253
+ operation=OperationSpec(
254
+ method="DELETE",
255
+ path_template="/spaces/{space_id}/webhooks/{webhook_id}",
256
+ path_fields=("space_id", "webhook_id"),
257
+ ),
258
+ examples=(
259
+ ExampleSpec(
260
+ command="kaiten --json incoming-webhooks delete --space-id 1 --webhook-id hook-1",
261
+ description="Delete an incoming webhook.",
262
+ ),
263
+ ),
264
+ ),
265
+ )
@@ -0,0 +1 @@
1
+ """Runtime layer for request building, transport, and response shaping."""
@@ -0,0 +1,115 @@
1
+ """Validate known automation variants while preserving server extensions."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from kaiten_cli.errors import ValidationError
6
+ from kaiten_cli.i18n import tr
7
+ from kaiten_cli.runtime.input import _validate_schema
8
+
9
+
10
+ def validate_automation(tool, payload):
11
+ # Lazy import avoids registry -> runtime -> registry initialization cycles.
12
+ from kaiten_cli.registry.automation_schema import AUTOMATION_SCHEMAS
13
+
14
+ creating = tool.action == "create"
15
+ kind = payload.get("type")
16
+ if creating:
17
+ required = ["actions"]
18
+ if kind in ("on_action", "on_date") or kind is None:
19
+ required.append("trigger")
20
+ if kind == "on_demand" or kind is None:
21
+ required.append("name")
22
+ missing = [key for key in required if key not in payload]
23
+ if missing:
24
+ raise ValidationError(
25
+ tr("Missing required field(s): {fields}", fields=", ".join(missing))
26
+ )
27
+
28
+ def validate_variant(value, family, path, partial=False):
29
+ _validate_schema(value, {"type": "object"}, path=path)
30
+ if "type" not in value:
31
+ if partial:
32
+ return
33
+ raise ValidationError(tr("Missing required field(s) at {value_0}: type", value_0=path))
34
+ _validate_schema(value["type"], {"type": "string"}, path=f"{path}.type")
35
+ schema = AUTOMATION_SCHEMAS[family].get(value["type"])
36
+ if schema is None:
37
+ return # Unknown variants are intentional extension points.
38
+ if partial:
39
+ schema = {**schema, "required": []}
40
+ _validate_schema(value, schema, path=path)
41
+
42
+ trigger = payload.get("trigger")
43
+ if trigger is not None:
44
+ validate_variant(trigger, "triggers", "trigger", partial=not creating)
45
+ known = AUTOMATION_SCHEMAS["triggers"].get(trigger.get("type"))
46
+ if creating and known and kind in ("on_action", "on_date"):
47
+ if known["x-automation-type"] != kind:
48
+ raise ValidationError(
49
+ tr(
50
+ "Field trigger.type is incompatible with automation type {value_0}.",
51
+ value_0=kind,
52
+ )
53
+ )
54
+ if known and known["x-automation-type"] == "on_date":
55
+ data = trigger.get("data", {})
56
+ if data.get("variant") in ("time_left_before_date", "time_passed_after_date"):
57
+ if "offset" not in data:
58
+ raise ValidationError(tr("Missing required field(s) at trigger.data: offset"))
59
+ if not any(key in data for key in ("offset_unit", "offset_units")):
60
+ raise ValidationError(
61
+ tr("Missing required field(s) at trigger.data: offset_unit or offset_units")
62
+ )
63
+ else:
64
+ known = None
65
+ for index, action in enumerate(payload.get("actions", [])):
66
+ path = f"actions[{index}]"
67
+ validate_variant(action, "actions", path)
68
+ if known and action["type"] in AUTOMATION_SCHEMAS["actions"]:
69
+ if action["type"] not in known["x-allowed-actions"]:
70
+ raise ValidationError(
71
+ tr(
72
+ "Field {value_0}.type is not allowed for trigger {value_1}.",
73
+ value_0=path,
74
+ value_1=trigger["type"],
75
+ )
76
+ )
77
+
78
+ def conditions(value, path, depth=0):
79
+ if depth > 64:
80
+ raise ValidationError(
81
+ tr("Field {value_0} exceeds maximum condition nesting depth (64).", value_0=path)
82
+ )
83
+ _validate_schema(value, {"type": "object"}, path=path)
84
+ if not value:
85
+ return
86
+ if "conditions" in value or "clause" in value:
87
+ _validate_schema(
88
+ value,
89
+ {
90
+ "type": "object",
91
+ "properties": {
92
+ "clause": {"type": "string", "enum": ["and", "or"]},
93
+ "conditions": {"type": "array", "items": {"type": "object"}},
94
+ "created": {"type": "string"},
95
+ },
96
+ "required": ["clause", "conditions"],
97
+ },
98
+ path=path,
99
+ )
100
+ for i, child in enumerate(value["conditions"]):
101
+ conditions(child, f"{path}.conditions[{i}]", depth + 1)
102
+ else:
103
+ validate_variant(value, "conditions", path)
104
+ if known and value["type"] in AUTOMATION_SCHEMAS["conditions"]:
105
+ if value["type"] not in known["x-allowed-conditions"]:
106
+ raise ValidationError(
107
+ tr(
108
+ "Field {value_0}.type is not allowed for trigger {value_1}.",
109
+ value_0=path,
110
+ value_1=trigger["type"],
111
+ )
112
+ )
113
+
114
+ if "conditions" in payload:
115
+ conditions(payload["conditions"], "conditions")