continuum-task-server-bundle 1.0.0__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 (90) hide show
  1. continuum_task_server_bundle/__init__.py +1 -0
  2. continuum_task_server_bundle/daytona/__init__.py +4 -0
  3. continuum_task_server_bundle/daytona/common.py +534 -0
  4. continuum_task_server_bundle/daytona/create_sandbox.py +166 -0
  5. continuum_task_server_bundle/daytona/dispatch.py +125 -0
  6. continuum_task_server_bundle/daytona/execute_sandbox.py +243 -0
  7. continuum_task_server_bundle/daytona/filesystem.py +330 -0
  8. continuum_task_server_bundle/daytona/fs_edit.py +127 -0
  9. continuum_task_server_bundle/daytona/git_ops.py +585 -0
  10. continuum_task_server_bundle/daytona/github_app.py +207 -0
  11. continuum_task_server_bundle/daytona/manage_sandbox.py +104 -0
  12. continuum_task_server_bundle/daytona/plugin.py +18 -0
  13. continuum_task_server_bundle/daytona/s3_transfer.py +207 -0
  14. continuum_task_server_bundle/discord/__init__.py +4 -0
  15. continuum_task_server_bundle/discord/attachment_registry_db.py +127 -0
  16. continuum_task_server_bundle/discord/attachment_resolve.py +213 -0
  17. continuum_task_server_bundle/discord/await_cleanup.py +105 -0
  18. continuum_task_server_bundle/discord/discord_ready.py +39 -0
  19. continuum_task_server_bundle/discord/message_await_apply.py +143 -0
  20. continuum_task_server_bundle/discord/message_await_db.py +197 -0
  21. continuum_task_server_bundle/discord/message_await_inbound.py +54 -0
  22. continuum_task_server_bundle/discord/message_await_logic.py +133 -0
  23. continuum_task_server_bundle/discord/message_await_poller.py +122 -0
  24. continuum_task_server_bundle/discord/message_chunking.py +45 -0
  25. continuum_task_server_bundle/discord/methods.py +408 -0
  26. continuum_task_server_bundle/discord/plugin.py +105 -0
  27. continuum_task_server_bundle/discord/reaction_await_apply.py +238 -0
  28. continuum_task_server_bundle/discord/reaction_await_db.py +174 -0
  29. continuum_task_server_bundle/discord/reaction_await_inbound.py +47 -0
  30. continuum_task_server_bundle/discord/reaction_await_logic.py +118 -0
  31. continuum_task_server_bundle/discord/reaction_await_poller.py +131 -0
  32. continuum_task_server_bundle/discord/s3_attachment_config.py +25 -0
  33. continuum_task_server_bundle/discord/s3_message_attachments.py +139 -0
  34. continuum_task_server_bundle/discord/sql/001_message_awaits.sql +112 -0
  35. continuum_task_server_bundle/discord/sql/002_reaction_awaits.sql +61 -0
  36. continuum_task_server_bundle/github/__init__.py +4 -0
  37. continuum_task_server_bundle/github/awaits/__init__.py +1 -0
  38. continuum_task_server_bundle/github/awaits/apply.py +92 -0
  39. continuum_task_server_bundle/github/awaits/cleanup.py +94 -0
  40. continuum_task_server_bundle/github/awaits/db.py +220 -0
  41. continuum_task_server_bundle/github/awaits/evaluators.py +325 -0
  42. continuum_task_server_bundle/github/awaits/fetch.py +192 -0
  43. continuum_task_server_bundle/github/awaits/poller.py +82 -0
  44. continuum_task_server_bundle/github/awaits/register.py +37 -0
  45. continuum_task_server_bundle/github/ci_status.py +70 -0
  46. continuum_task_server_bundle/github/comment_normalize.py +76 -0
  47. continuum_task_server_bundle/github/errors.py +52 -0
  48. continuum_task_server_bundle/github/github_app.py +291 -0
  49. continuum_task_server_bundle/github/github_http.py +377 -0
  50. continuum_task_server_bundle/github/methods/__init__.py +90 -0
  51. continuum_task_server_bundle/github/methods/_common.py +183 -0
  52. continuum_task_server_bundle/github/methods/awaits.py +107 -0
  53. continuum_task_server_bundle/github/methods/ci.py +158 -0
  54. continuum_task_server_bundle/github/methods/comments.py +214 -0
  55. continuum_task_server_bundle/github/methods/credentials.py +59 -0
  56. continuum_task_server_bundle/github/methods/issues.py +131 -0
  57. continuum_task_server_bundle/github/methods/pulls.py +329 -0
  58. continuum_task_server_bundle/github/methods/repos.py +424 -0
  59. continuum_task_server_bundle/github/methods/search.py +109 -0
  60. continuum_task_server_bundle/github/plugin.py +91 -0
  61. continuum_task_server_bundle/github/sql/001_github_awaits.sql +65 -0
  62. continuum_task_server_bundle/github/webhook_server.py +126 -0
  63. continuum_task_server_bundle/jira/__init__.py +4 -0
  64. continuum_task_server_bundle/jira/await_poller.py +236 -0
  65. continuum_task_server_bundle/jira/await_store.py +271 -0
  66. continuum_task_server_bundle/jira/config.py +68 -0
  67. continuum_task_server_bundle/jira/jira_client.py +382 -0
  68. continuum_task_server_bundle/jira/methods.py +246 -0
  69. continuum_task_server_bundle/jira/plugin.py +86 -0
  70. continuum_task_server_bundle/jira/sql/001_jira_issue_comment_waits.sql +19 -0
  71. continuum_task_server_bundle/jira/webhook.py +70 -0
  72. continuum_task_server_bundle/openrouter/__init__.py +4 -0
  73. continuum_task_server_bundle/openrouter/chat_service.py +1037 -0
  74. continuum_task_server_bundle/openrouter/chat_store.py +849 -0
  75. continuum_task_server_bundle/openrouter/environment.py +29 -0
  76. continuum_task_server_bundle/openrouter/handler.py +59 -0
  77. continuum_task_server_bundle/openrouter/image_context.py +207 -0
  78. continuum_task_server_bundle/openrouter/openrouter_client.py +324 -0
  79. continuum_task_server_bundle/openrouter/plugin.py +37 -0
  80. continuum_task_server_bundle/openrouter/prompt_projection.py +417 -0
  81. continuum_task_server_bundle/openrouter/sql/chat.sql +50 -0
  82. continuum_task_server_bundle/openrouter/sql/migrate_prune_then_chunk_v1.sql +11 -0
  83. continuum_task_server_bundle/roblox/__init__.py +4 -0
  84. continuum_task_server_bundle/roblox/open_cloud.py +335 -0
  85. continuum_task_server_bundle/roblox/plugin.py +30 -0
  86. continuum_task_server_bundle/roblox/storage_s3.py +55 -0
  87. continuum_task_server_bundle-1.0.0.dist-info/METADATA +109 -0
  88. continuum_task_server_bundle-1.0.0.dist-info/RECORD +90 -0
  89. continuum_task_server_bundle-1.0.0.dist-info/WHEEL +5 -0
  90. continuum_task_server_bundle-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,68 @@
1
+ """Environment-backed configuration for the Jira task server.
2
+
3
+ Secrets are read only from the process environment; this module never loads a
4
+ .env file so deployments can use their secret manager's injection mechanism.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from dataclasses import dataclass
10
+ from os import getenv
11
+
12
+
13
+ @dataclass(frozen=True)
14
+ class Settings:
15
+ continuum_url: str
16
+ continuum_api_key: str
17
+ continuum_layer: str
18
+ continuum_transport: str
19
+ jira_base_url: str
20
+ jira_email: str
21
+ jira_api_token: str
22
+ jira_basic_auth: str
23
+ database_url: str
24
+ webhook_secret: str
25
+ webhook_host: str
26
+ webhook_port: int
27
+ database_poll_seconds: float
28
+ max_workers: int
29
+
30
+ @classmethod
31
+ def from_env(cls) -> "Settings":
32
+ return cls(
33
+ continuum_url=(getenv("CONTINUUM_URL") or "").strip().rstrip("/"),
34
+ continuum_api_key=(getenv("CONTINUUM_API_KEY") or "").strip(),
35
+ continuum_layer=(getenv("CONTINUUM_LAYER") or "").strip(),
36
+ continuum_transport=(getenv("CONTINUUM_TRANSPORT") or "http").strip() or "http",
37
+ jira_base_url=(getenv("JIRA_BASE_URL") or "").strip().rstrip("/"),
38
+ jira_email=(getenv("JIRA_EMAIL") or "").strip(),
39
+ jira_api_token=(getenv("JIRA_API_TOKEN") or "").strip(),
40
+ jira_basic_auth=(getenv("STARSTREAM_JIRA_BASIC_AUTH") or getenv("JIRA_BASIC_AUTH") or "").strip(),
41
+ database_url=(getenv("DATABASE_URL") or "").strip(),
42
+ webhook_secret=(getenv("JIRA_WEBHOOK_SECRET") or "").strip(),
43
+ webhook_host=(getenv("JIRA_WEBHOOK_HOST") or getenv("WEBHOOK_HOST") or "0.0.0.0").strip() or "0.0.0.0",
44
+ webhook_port=int(getenv("JIRA_WEBHOOK_PORT") or getenv("WEBHOOK_PORT") or "8080"),
45
+ database_poll_seconds=float(getenv("DATABASE_POLL_SECONDS") or "5"),
46
+ max_workers=int(getenv("MAX_WORKERS") or "16"),
47
+ )
48
+
49
+ def validate(self, *, require_continuum: bool = True) -> None:
50
+ required = {
51
+ "JIRA_BASE_URL": self.jira_base_url,
52
+ "DATABASE_URL": self.database_url,
53
+ }
54
+ if require_continuum:
55
+ required.update(CONTINUUM_URL=self.continuum_url, CONTINUUM_API_KEY=self.continuum_api_key)
56
+ missing = [name for name, value in required.items() if not value]
57
+ if missing:
58
+ raise RuntimeError("Missing required environment variables: " + ", ".join(missing))
59
+ if not self.jira_basic_auth and not (self.jira_email and self.jira_api_token):
60
+ raise RuntimeError("Set STARSTREAM_JIRA_BASIC_AUTH, JIRA_BASIC_AUTH or both JIRA_EMAIL and JIRA_API_TOKEN")
61
+ if self.continuum_transport not in {"http", "websocket"}:
62
+ raise RuntimeError("CONTINUUM_TRANSPORT must be 'http' or 'websocket'")
63
+ if not 1 <= self.webhook_port <= 65535:
64
+ raise RuntimeError("WEBHOOK_PORT must be between 1 and 65535")
65
+ if not 0.25 <= self.database_poll_seconds <= 60:
66
+ raise RuntimeError("DATABASE_POLL_SECONDS must be between 0.25 and 60")
67
+ if not 1 <= self.max_workers <= 128:
68
+ raise RuntimeError("MAX_WORKERS must be between 1 and 128")
@@ -0,0 +1,382 @@
1
+ """Small Jira Cloud REST v3 client with bounded, explicit API operations."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+ from urllib.parse import quote
7
+
8
+ import httpx
9
+
10
+
11
+ class JiraApiError(RuntimeError):
12
+ """An HTTP/API error without response bodies or credential material."""
13
+
14
+ def __init__(self, status_code: int, method: str, path: str) -> None:
15
+ super().__init__(f"Jira API {method} {path} failed with HTTP {status_code}")
16
+ self.status_code = status_code
17
+ self.method = method
18
+ self.path = path
19
+
20
+
21
+ def text_to_adf(text: str) -> dict[str, Any]:
22
+ """Wrap plain text in a minimal Atlassian Document Format document."""
23
+ paragraphs = []
24
+ for line in text.splitlines() or [""]:
25
+ paragraphs.append({"type": "paragraph", "content": [{"type": "text", "text": line}]})
26
+ return {"type": "doc", "version": 1, "content": paragraphs}
27
+
28
+
29
+ def adf_to_plain_text(node: Any) -> str:
30
+ """Best-effort ADF to readable text for task outputs."""
31
+ if node is None:
32
+ return ""
33
+ if isinstance(node, str):
34
+ return node
35
+ if isinstance(node, list):
36
+ return "".join(adf_to_plain_text(child) for child in node)
37
+ if not isinstance(node, dict):
38
+ return ""
39
+ kind = node.get("type")
40
+ if kind == "text":
41
+ return str(node.get("text") or "")
42
+ if kind == "mention":
43
+ return str((node.get("attrs") or {}).get("text") or "")
44
+ if kind == "hardBreak":
45
+ return "\n"
46
+ content = adf_to_plain_text(node.get("content"))
47
+ return content + ("\n" if kind in {"paragraph", "heading", "blockquote"} else "")
48
+
49
+
50
+ def mention_account_ids(body: Any) -> set[str]:
51
+ """Collect Atlassian account IDs referenced by ADF mention nodes."""
52
+ found: set[str] = set()
53
+ if isinstance(body, list):
54
+ for child in body:
55
+ found.update(mention_account_ids(child))
56
+ elif isinstance(body, dict):
57
+ if body.get("type") == "mention":
58
+ attrs = body.get("attrs") or {}
59
+ account_id = attrs.get("id") or attrs.get("accountId")
60
+ if account_id:
61
+ found.add(str(account_id))
62
+ found.update(mention_account_ids(body.get("content")))
63
+ return found
64
+
65
+
66
+ class JiraClient:
67
+ """Jira Cloud REST v3 client. Credentials are supplied only at construction."""
68
+
69
+ ISSUE_FIELDS = [
70
+ "summary",
71
+ "description",
72
+ "status",
73
+ "labels",
74
+ "reporter",
75
+ "project",
76
+ "issuetype",
77
+ "attachment",
78
+ "updated",
79
+ ]
80
+ SEARCH_FIELDS = ["summary", "status", "project", "issuetype", "labels", "updated"]
81
+
82
+ def __init__(
83
+ self,
84
+ base_url: str,
85
+ email: str | None = None,
86
+ api_token: str | None = None,
87
+ *,
88
+ basic_auth: str | None = None,
89
+ transport: httpx.BaseTransport | None = None,
90
+ timeout: float = 30.0,
91
+ ) -> None:
92
+ if not base_url:
93
+ raise ValueError("JIRA_BASE_URL is required")
94
+ auth = None
95
+ headers = {"Accept": "application/json"}
96
+ if basic_auth:
97
+ # Daytona egress secrets may be opaque placeholders that are replaced
98
+ # by the proxy. Keep the value unencoded in this header; httpx.BasicAuth
99
+ # would base64-encode the placeholder before the proxy can substitute it.
100
+ headers["Authorization"] = f"Basic {basic_auth}"
101
+ elif email and api_token:
102
+ auth = (email, api_token)
103
+ else:
104
+ raise ValueError(
105
+ "Set JIRA_BASIC_AUTH or both JIRA_EMAIL and JIRA_API_TOKEN"
106
+ )
107
+ self._client = httpx.Client(
108
+ base_url=f"{base_url.rstrip('/')}/rest/api/3",
109
+ auth=auth,
110
+ headers=headers,
111
+ timeout=timeout,
112
+ transport=transport,
113
+ )
114
+
115
+ def close(self) -> None:
116
+ self._client.close()
117
+
118
+ def _request(
119
+ self,
120
+ method: str,
121
+ path: str,
122
+ *,
123
+ params: dict[str, Any] | None = None,
124
+ json_body: dict[str, Any] | None = None,
125
+ ) -> dict[str, Any]:
126
+ response = self._client.request(method, path, params=params, json=json_body)
127
+ if response.is_error:
128
+ # Do not include the response body: Jira errors can echo user-supplied data.
129
+ raise JiraApiError(response.status_code, method, path)
130
+ if not response.content:
131
+ return {}
132
+ payload = response.json()
133
+ return payload if isinstance(payload, dict) else {"values": payload}
134
+
135
+ @staticmethod
136
+ def _issue_path(issue_key: str) -> str:
137
+ return f"/issue/{quote(issue_key, safe='')}"
138
+
139
+ def myself(self) -> dict[str, Any]:
140
+ return self._request("GET", "/myself")
141
+
142
+ def get_issue(self, issue_key: str, *, include_comments: bool = True, comment_limit: int = 100) -> dict[str, Any]:
143
+ payload = self._request(
144
+ "GET",
145
+ self._issue_path(issue_key),
146
+ params={"fields": ",".join(self.ISSUE_FIELDS)},
147
+ )
148
+ fields = payload.get("fields") or {}
149
+ project = fields.get("project") or {}
150
+ status = fields.get("status") or {}
151
+ reporter = fields.get("reporter") or {}
152
+ issue_type = fields.get("issuetype") or {}
153
+ attachments = []
154
+ for attachment in fields.get("attachment") or []:
155
+ if isinstance(attachment, dict):
156
+ attachments.append(
157
+ {
158
+ "id": str(attachment.get("id") or ""),
159
+ "filename": attachment.get("filename"),
160
+ "mime_type": attachment.get("mimeType"),
161
+ "size": attachment.get("size"),
162
+ "created": attachment.get("created"),
163
+ }
164
+ )
165
+ result: dict[str, Any] = {
166
+ "success": True,
167
+ "issue_key": payload.get("key") or issue_key,
168
+ "project_key": project.get("key"),
169
+ "project_name": project.get("name"),
170
+ "summary": fields.get("summary"),
171
+ "description": adf_to_plain_text(fields.get("description")).strip() or None,
172
+ "status": status.get("name"),
173
+ "status_category": (status.get("statusCategory") or {}).get("key"),
174
+ "issue_type": issue_type.get("name"),
175
+ "reporter_account_id": reporter.get("accountId"),
176
+ "labels": list(fields.get("labels") or []),
177
+ "updated": fields.get("updated"),
178
+ "attachments": attachments,
179
+ }
180
+ if include_comments:
181
+ result["comments"] = self.get_comments(issue_key, max_results=comment_limit)
182
+ return result
183
+
184
+ def get_comments(self, issue_key: str, *, max_results: int = 100) -> list[dict[str, Any]]:
185
+ limit = max(1, min(int(max_results), 100))
186
+ start_at = 0
187
+ comments: list[dict[str, Any]] = []
188
+ while len(comments) < limit:
189
+ batch_size = min(50, limit - len(comments))
190
+ page = self._request(
191
+ "GET",
192
+ f"{self._issue_path(issue_key)}/comment",
193
+ params={"startAt": start_at, "maxResults": batch_size, "orderBy": "-created"},
194
+ )
195
+ values = page.get("comments") or []
196
+ if not values:
197
+ break
198
+ for comment in values:
199
+ author = comment.get("author") or {}
200
+ comments.append(
201
+ {
202
+ "id": str(comment.get("id") or ""),
203
+ "author_account_id": author.get("accountId"),
204
+ "body_text": adf_to_plain_text(comment.get("body")).strip(),
205
+ "body_adf": comment.get("body"),
206
+ "created": comment.get("created"),
207
+ "updated": comment.get("updated"),
208
+ }
209
+ )
210
+ start_at += len(values)
211
+ if len(values) < batch_size or start_at >= int(page.get("total") or 0):
212
+ break
213
+ return comments[:limit]
214
+
215
+ def search_issues(
216
+ self,
217
+ jql: str,
218
+ *,
219
+ max_results: int = 50,
220
+ next_page_token: str | None = None,
221
+ ) -> dict[str, Any]:
222
+ limit = max(1, min(int(max_results), 100))
223
+ body: dict[str, Any] = {"jql": jql, "maxResults": limit, "fields": self.SEARCH_FIELDS}
224
+ if next_page_token:
225
+ body["nextPageToken"] = next_page_token
226
+ payload = self._request("POST", "/search/jql", json_body=body)
227
+ issues = []
228
+ for issue in payload.get("issues") or []:
229
+ fields = issue.get("fields") or {}
230
+ project = fields.get("project") or {}
231
+ status = fields.get("status") or {}
232
+ issue_type = fields.get("issuetype") or {}
233
+ issues.append(
234
+ {
235
+ "issue_key": issue.get("key"),
236
+ "summary": fields.get("summary"),
237
+ "project_key": project.get("key"),
238
+ "project_name": project.get("name"),
239
+ "status": status.get("name"),
240
+ "issue_type": issue_type.get("name"),
241
+ "labels": list(fields.get("labels") or []),
242
+ "updated": fields.get("updated"),
243
+ }
244
+ )
245
+ return {
246
+ "success": True,
247
+ "issues": issues,
248
+ "next_page_token": payload.get("nextPageToken"),
249
+ "is_last": bool(payload.get("isLast", payload.get("nextPageToken") is None)),
250
+ }
251
+
252
+ def list_projects(self, *, start_at: int = 0, max_results: int = 50) -> dict[str, Any]:
253
+ limit = max(1, min(int(max_results), 100))
254
+ start = max(0, int(start_at))
255
+ payload = self._request(
256
+ "GET", "/project/search", params={"startAt": start, "maxResults": limit}
257
+ )
258
+ projects = [
259
+ {
260
+ "project_id": str(project.get("id") or ""),
261
+ "project_key": project.get("key"),
262
+ "name": project.get("name"),
263
+ "project_type": project.get("projectTypeKey"),
264
+ "style": project.get("style"),
265
+ }
266
+ for project in payload.get("values") or []
267
+ ]
268
+ return {
269
+ "success": True,
270
+ "projects": projects,
271
+ "start_at": payload.get("startAt", start),
272
+ "max_results": payload.get("maxResults", limit),
273
+ "total": payload.get("total"),
274
+ "is_last": bool(payload.get("isLast", True)),
275
+ }
276
+
277
+ def get_project(self, project_key: str) -> dict[str, Any]:
278
+ payload = self._request("GET", f"/project/{quote(project_key, safe='')}")
279
+ return {
280
+ "success": True,
281
+ "project_id": str(payload.get("id") or ""),
282
+ "project_key": payload.get("key"),
283
+ "name": payload.get("name"),
284
+ "project_type": payload.get("projectTypeKey"),
285
+ "style": payload.get("style"),
286
+ "url": payload.get("url"),
287
+ "lead_account_id": (payload.get("lead") or {}).get("accountId"),
288
+ }
289
+
290
+ def list_issue_types(self, project_key: str) -> dict[str, Any]:
291
+ project = self.get_project(project_key)
292
+ payload = self._request(
293
+ "GET", "/issuetype/project", params={"projectId": project["project_id"]}
294
+ )
295
+ return {
296
+ "success": True,
297
+ "project_key": project_key,
298
+ "issue_types": [
299
+ {"id": str(value.get("id") or ""), "name": value.get("name"), "description": value.get("description")}
300
+ for value in payload.get("values", payload if isinstance(payload, list) else [])
301
+ ],
302
+ }
303
+
304
+ def create_issue(
305
+ self,
306
+ *,
307
+ project_key: str,
308
+ issue_type_id: str,
309
+ summary: str,
310
+ description: str | None = None,
311
+ labels: list[str] | None = None,
312
+ ) -> dict[str, Any]:
313
+ fields: dict[str, Any] = {
314
+ "project": {"key": project_key},
315
+ "issuetype": {"id": str(issue_type_id)},
316
+ "summary": summary,
317
+ }
318
+ if description is not None:
319
+ fields["description"] = text_to_adf(description)
320
+ if labels is not None:
321
+ fields["labels"] = [str(label) for label in labels]
322
+ payload = self._request("POST", "/issue", json_body={"fields": fields})
323
+ return {"success": True, "issue_key": payload.get("key"), "issue_id": payload.get("id")}
324
+
325
+ def update_issue(self, issue_key: str, fields: dict[str, Any]) -> dict[str, Any]:
326
+ allowed = {"summary", "description", "labels"}
327
+ unknown = set(fields) - allowed
328
+ if unknown:
329
+ raise ValueError("Unsupported update fields: " + ", ".join(sorted(unknown)))
330
+ if not fields:
331
+ raise ValueError("At least one supported field is required")
332
+ jira_fields: dict[str, Any] = dict(fields)
333
+ if isinstance(jira_fields.get("description"), str):
334
+ jira_fields["description"] = text_to_adf(jira_fields["description"])
335
+ if "labels" in jira_fields:
336
+ if not isinstance(jira_fields["labels"], list):
337
+ raise ValueError("labels must be an array of strings")
338
+ jira_fields["labels"] = [str(label) for label in jira_fields["labels"]]
339
+ self._request("PUT", self._issue_path(issue_key), json_body={"fields": jira_fields})
340
+ return {"success": True, "issue_key": issue_key, "updated_fields": sorted(fields)}
341
+
342
+ def add_comment(
343
+ self,
344
+ issue_key: str,
345
+ *,
346
+ body: str | None = None,
347
+ body_adf: dict[str, Any] | None = None,
348
+ ) -> dict[str, Any]:
349
+ if body_adf is None and (body is None or not body.strip()):
350
+ raise ValueError("body or body_adf is required")
351
+ if body_adf is not None and not isinstance(body_adf, dict):
352
+ raise ValueError("body_adf must be an object")
353
+ document = body_adf if body_adf is not None else text_to_adf(body or "")
354
+ payload = self._request(
355
+ "POST", f"{self._issue_path(issue_key)}/comment", json_body={"body": document}
356
+ )
357
+ return {"success": True, "issue_key": issue_key, "comment_id": str(payload.get("id") or "")}
358
+
359
+ def get_transitions(self, issue_key: str) -> dict[str, Any]:
360
+ payload = self._request("GET", f"{self._issue_path(issue_key)}/transitions")
361
+ return {
362
+ "success": True,
363
+ "issue_key": issue_key,
364
+ "transitions": [
365
+ {
366
+ "id": str(transition.get("id") or ""),
367
+ "name": transition.get("name"),
368
+ "to_status": (transition.get("to") or {}).get("name"),
369
+ }
370
+ for transition in payload.get("transitions") or []
371
+ ],
372
+ }
373
+
374
+ def transition_issue(self, issue_key: str, transition_id: str) -> dict[str, Any]:
375
+ if not transition_id:
376
+ raise ValueError("transition_id is required")
377
+ self._request(
378
+ "POST",
379
+ f"{self._issue_path(issue_key)}/transitions",
380
+ json_body={"transition": {"id": str(transition_id)}},
381
+ )
382
+ return {"success": True, "issue_key": issue_key, "transition_id": str(transition_id)}