devops-bot-sdk 1.4.35__tar.gz → 1.4.39__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 (38) hide show
  1. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/PKG-INFO +1 -1
  2. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/devops_bot_sdk.egg-info/PKG-INFO +1 -1
  3. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/pyproject.toml +1 -1
  4. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/__init__.py +2 -2
  5. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/client.py +100 -1
  6. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/ipc/handlers.py +233 -6
  7. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/run_auto.py +58 -8
  8. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/README.md +0 -0
  9. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/devops_bot_sdk.egg-info/SOURCES.txt +0 -0
  10. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/devops_bot_sdk.egg-info/dependency_links.txt +0 -0
  11. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/devops_bot_sdk.egg-info/entry_points.txt +0 -0
  12. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/devops_bot_sdk.egg-info/requires.txt +0 -0
  13. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/devops_bot_sdk.egg-info/top_level.txt +0 -0
  14. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/collectors/__init__.py +0 -0
  15. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/collectors/files.py +0 -0
  16. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/collectors/process.py +0 -0
  17. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/collectors/screenshot.py +0 -0
  18. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/config.py +0 -0
  19. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/crucial.py +0 -0
  20. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/exceptions.py +0 -0
  21. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/git_ops.py +0 -0
  22. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/graphify.py +0 -0
  23. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/hooks/__init__.py +0 -0
  24. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/hooks/crucial_guard.py +0 -0
  25. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/ipc/__init__.py +0 -0
  26. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/ipc/electron_bridge.py +0 -0
  27. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/local_exec.py +0 -0
  28. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/models/__init__.py +0 -0
  29. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/models/envelope.py +0 -0
  30. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/models/requests.py +0 -0
  31. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/models/responses.py +0 -0
  32. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/models/snapshots.py +0 -0
  33. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/py.typed +0 -0
  34. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/sse.py +0 -0
  35. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/test.py +0 -0
  36. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/test_pipeline.py +0 -0
  37. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/sdk/updater.py +0 -0
  38. {devops_bot_sdk-1.4.35 → devops_bot_sdk-1.4.39}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: devops-bot-sdk
3
- Version: 1.4.35
3
+ Version: 1.4.39
4
4
  Summary: DevOps Bot Desktop SDK — thin client for the AgentOS Electron desktop app
5
5
  Author: noumanaziz2128
6
6
  License-Expression: LicenseRef-Proprietary
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: devops-bot-sdk
3
- Version: 1.4.35
3
+ Version: 1.4.39
4
4
  Summary: DevOps Bot Desktop SDK — thin client for the AgentOS Electron desktop app
5
5
  Author: noumanaziz2128
6
6
  License-Expression: LicenseRef-Proprietary
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "devops-bot-sdk"
7
- version = "1.4.35"
7
+ version = "1.4.39"
8
8
  description = "DevOps Bot Desktop SDK — thin client for the AgentOS Electron desktop app"
9
9
  readme = "README.md"
10
10
  license = "LicenseRef-Proprietary"
@@ -1,6 +1,6 @@
1
1
  """AgentOS Desktop SDK — thin HTTPS/SSE client for the Electron app.
2
2
 
3
- Version: 1.4.35
3
+ Version: 1.4.39
4
4
 
5
5
  Public surface:
6
6
  BackendClient.from_config() — create client from ~/.agentos/config.toml
@@ -30,7 +30,7 @@ Rules:
30
30
  - All data egress through submit_webhook only
31
31
  """
32
32
 
33
- __version__ = "1.4.35"
33
+ __version__ = "1.4.39"
34
34
  __author__ = "AgentOS"
35
35
 
36
36
  from sdk.client import BackendClient
@@ -58,7 +58,7 @@ def _notify_status(task_id: str, status: str) -> None:
58
58
  pass
59
59
 
60
60
 
61
- SDK_VERSION = "1.4.35"
61
+ SDK_VERSION = "1.4.39"
62
62
  _POLL_INTERVAL = 3.0
63
63
  _POLL_TIMEOUT = 600.0
64
64
  _ORCHESTRATE_TIMEOUT = 2700.0 # 45 min — covers approval wait + VPS execution time
@@ -621,6 +621,40 @@ class BackendClient:
621
621
  except Exception:
622
622
  return []
623
623
 
624
+ async def list_tasks_by_keys(self, keys: list[str], limit: int = 10000) -> list[dict]:
625
+ """GET /tasks-ml (ML backend) — RAW records for specific Jira keys.
626
+
627
+ Unlike list_todo_tasks_raw this does NOT filter by board status: a
628
+ targeted run (`agentos-auto ticket BBW-81`) should start the named ticket
629
+ whatever its current status (To Do / In Progress / Done), so a finished
630
+ ticket can be re-run on demand. Matches `jiraIssueKey` (falls back to
631
+ `jiraKey`) case-insensitively. Best-effort: returns [] on error. Preserves
632
+ the order of `keys` (each key's first matching record), so the run follows
633
+ the order the caller asked for.
634
+ """
635
+ from sdk.config import BE_DEFAULT_URL
636
+
637
+ want = [k.strip().upper() for k in keys if k and k.strip()]
638
+ if not want:
639
+ return []
640
+ url = f"{BE_DEFAULT_URL.rstrip('/')}/tasks-ml"
641
+ headers = {**self._headers, "accept": "*/*", "developer-name": "null", "product": ""}
642
+ try:
643
+ async with httpx.AsyncClient(timeout=30.0) as client:
644
+ resp = await client.get(url, params={"limit": limit}, headers=headers)
645
+ if resp.status_code >= 400:
646
+ return []
647
+ records = ((resp.json() or {}).get("data") or {}).get("records") or []
648
+ except Exception:
649
+ return []
650
+
651
+ by_key: dict[str, dict] = {}
652
+ for rec in records:
653
+ k = str(rec.get("jiraIssueKey") or rec.get("jiraKey") or "").strip().upper()
654
+ if k and k not in by_key:
655
+ by_key[k] = rec
656
+ return [by_key[k] for k in want if k in by_key]
657
+
624
658
  async def approval_record(self, task_id: str) -> dict | None:
625
659
  """GET /api/v1/mgmt/approve/{task_id} → the full decision record (or None).
626
660
 
@@ -769,6 +803,71 @@ class BackendClient:
769
803
  logger.warning("client.mark_in_progress error task=%s err=%s", task_id, exc)
770
804
  return False
771
805
 
806
+ async def update_task_ml(
807
+ self, task_id: str, fields: dict, model_used: list[str] | None = None,
808
+ ) -> bool:
809
+ """PUT {BE}/tasks-ml/{id} with arbitrary multipart form fields (best-effort).
810
+
811
+ Generic form-update used e.g. to mark an Epic Done while attaching the
812
+ generated detailed description + AI plan. `model_used` is sent as repeated
813
+ `modelUsed` fields. None-valued fields are dropped. Returns True on 2xx.
814
+ """
815
+ from sdk.config import BE_DEFAULT_URL
816
+
817
+ url = f"{BE_DEFAULT_URL.rstrip('/')}/tasks-ml/{task_id}"
818
+ headers = {k: v for k, v in self._headers.items() if k.lower() != "content-type"}
819
+ headers.update({"accept": "*/*", "developer-name": "null", "product": ""})
820
+ # httpx multipart wants a list of (name, (filename, value)) tuples so a
821
+ # field like `modelUsed` can repeat.
822
+ files = [(k, (None, str(v))) for k, v in fields.items() if v is not None]
823
+ for m in (model_used or []):
824
+ files.append(("modelUsed", (None, str(m))))
825
+ try:
826
+ async with httpx.AsyncClient(timeout=30.0) as client:
827
+ resp = await client.put(url, files=files, headers=headers)
828
+ if resp.status_code >= 400:
829
+ logger.warning("client.update_task_ml failed task=%s status=%s body=%s",
830
+ task_id, resp.status_code, resp.text[:200])
831
+ return False
832
+ return True
833
+ except Exception as exc: # noqa: BLE001
834
+ logger.warning("client.update_task_ml error task=%s err=%s", task_id, exc)
835
+ return False
836
+
837
+ async def create_task_ml(
838
+ self, fields: dict, model_used: list[str] | None = None,
839
+ ) -> str | None:
840
+ """POST {BE}/tasks-ml — create a task via multipart form; return its id.
841
+
842
+ Required fields per the API: projectKey, type, summary (description
843
+ optional but recommended). Used to spin a To Do child Task off a decomposed
844
+ Epic. Returns the new task id on success, else None (best-effort).
845
+ """
846
+ from sdk.config import BE_DEFAULT_URL
847
+
848
+ url = f"{BE_DEFAULT_URL.rstrip('/')}/tasks-ml"
849
+ headers = {k: v for k, v in self._headers.items() if k.lower() != "content-type"}
850
+ headers.update({"accept": "*/*", "developer-name": "null", "product": ""})
851
+ files = [(k, (None, str(v))) for k, v in fields.items() if v is not None]
852
+ for m in (model_used or []):
853
+ files.append(("modelUsed", (None, str(m))))
854
+ try:
855
+ async with httpx.AsyncClient(timeout=30.0) as client:
856
+ resp = await client.post(url, files=files, headers=headers)
857
+ if resp.status_code >= 400:
858
+ logger.warning("client.create_task_ml failed status=%s body=%s",
859
+ resp.status_code, resp.text[:300])
860
+ return None
861
+ body = resp.json() or {}
862
+ rec = body.get("data") or body
863
+ # The created record's id may sit at data.id or data.record.id.
864
+ if isinstance(rec, dict):
865
+ return rec.get("id") or ((rec.get("record") or {}).get("id"))
866
+ return None
867
+ except Exception as exc: # noqa: BLE001
868
+ logger.warning("client.create_task_ml error err=%s", exc)
869
+ return None
870
+
772
871
  async def log_activity(self, activity: str) -> bool:
773
872
  """POST /ml-api/agent-activity — emit an agent activity event (best-effort).
774
873
 
@@ -351,6 +351,196 @@ def _parse_scope(recon_text: str | None) -> str:
351
351
  return "in"
352
352
 
353
353
 
354
+ # ── Epic decomposition ────────────────────────────────────────────────────
355
+ # An EPIC is not coded directly. It is analysed (grounded in the codebase when a
356
+ # project path exists) into a detailed user-story description + an implementation
357
+ # plan; the Epic is then marked Done with that content and one To Do child Task is
358
+ # created per generated story (inheriting the Epic's project/assignee/priority/…).
359
+ _MAX_EPIC_STORIES = int(os.getenv("AGENTOS_MAX_EPIC_STORIES", "") or 8)
360
+ # Label recorded in the ticket's modelUsed on Epic completion.
361
+ _EPIC_MODELS = [m.strip() for m in (os.getenv("AGENTOS_EPIC_MODELS", "") or "claude-code").split(",") if m.strip()]
362
+
363
+
364
+ def _build_epic_prompt(jira_key: str, summary: str, description: str | None,
365
+ human_instructions: str | None) -> str:
366
+ """Read-only prompt that turns an Epic into a decomposition JSON."""
367
+ parts: list[str] = [
368
+ "You are decomposing a JIRA EPIC into implementable work. This is ANALYSIS "
369
+ "ONLY — do NOT create, edit, or delete any file.",
370
+ f"=== EPIC {jira_key} ===\nSummary: {summary}",
371
+ ]
372
+ if description and description.strip():
373
+ parts.append("Description:\n" + _clip_text(description.strip()))
374
+ if human_instructions and human_instructions.strip():
375
+ parts.append(
376
+ "Operator instructions (authoritative — carry any project location / "
377
+ "constraints into each story's humanInstructions):\n"
378
+ + human_instructions.strip()
379
+ )
380
+ parts.append(
381
+ "First understand the existing codebase in this directory (read CLAUDE.md, "
382
+ "use graphify / Read / Glob / Grep) so the stories fit the REAL architecture. "
383
+ "Then produce the decomposition.\n\n"
384
+ "Output ONLY a single fenced ```json block and nothing after it, with shape:\n"
385
+ "{\n"
386
+ ' "epic_description": "A detailed description for the epic: a full user-story '
387
+ "write-up covering goal, the user stories, acceptance criteria and scope.\",\n"
388
+ ' "plan": "An ordered, numbered high-level implementation plan.",\n'
389
+ ' "stories": [\n'
390
+ ' {\n'
391
+ ' "summary": "Short imperative story title (a JIRA task summary)",\n'
392
+ ' "description": "Detailed description: what to build + acceptance criteria.",\n'
393
+ ' "humanInstructions": "Operator instructions to implement THIS story. MUST '
394
+ "repeat the same project location/path and constraints from the epic so the "
395
+ 'coding run works in the right place.",\n'
396
+ ' "points": 5\n'
397
+ " }\n"
398
+ " ]\n"
399
+ "}\n"
400
+ "Create as many stories as the epic genuinely needs (do not pad or truncate "
401
+ "artificially); each story must be independently implementable."
402
+ )
403
+ return "\n\n".join(parts)
404
+
405
+
406
+ def _extract_json_block(text: str | None) -> dict | None:
407
+ """Parse the decomposition JSON from a claude response (fenced block preferred)."""
408
+ if not text:
409
+ return None
410
+ import json as _json
411
+ candidates = re.findall(r"```(?:json)?\s*(\{.*?\})\s*```", text, re.S | re.I)
412
+ if not candidates:
413
+ start, end = text.find("{"), text.rfind("}")
414
+ if start != -1 and end > start:
415
+ candidates = [text[start:end + 1]]
416
+ for c in reversed(candidates):
417
+ try:
418
+ obj = _json.loads(c)
419
+ if isinstance(obj, dict):
420
+ return obj
421
+ except Exception: # noqa: BLE001
422
+ continue
423
+ return None
424
+
425
+
426
+ def _epic_inherited_fields(task: dict) -> dict:
427
+ """Parent-Epic fields a child Task should inherit (drops empties)."""
428
+ def _date(v: object) -> str | None:
429
+ s = str(v or "")
430
+ return s[:10] if s else None # ISO datetime → YYYY-MM-DD
431
+
432
+ fields = {
433
+ "projectKey": task.get("projectKey"),
434
+ "priority": task.get("priority"),
435
+ "assigneeEmail": (task.get("assignee") or {}).get("email"),
436
+ "teamId": task.get("teamId"),
437
+ "startDate": _date(task.get("startDate")),
438
+ "dueDate": _date(task.get("dueDate")),
439
+ "slaTarget": task.get("slaTarget"),
440
+ }
441
+ sprint = task.get("sprint") or {}
442
+ if sprint.get("jiraSprintId"):
443
+ fields["jiraSprintId"] = sprint["jiraSprintId"]
444
+ return {k: v for k, v in fields.items() if v}
445
+
446
+
447
+ async def _handle_epic(
448
+ client: BackendClient, task: dict, payload: dict, send: Callable, thread_id: str,
449
+ ) -> None:
450
+ """Decompose an Epic: generate user stor(y|ies), mark the Epic Done with the
451
+ detailed description + plan, then create a To Do child Task per story.
452
+
453
+ Child tasks are created in "To Do"; a later `agentos-auto` run picks them up and
454
+ implements them through the normal grounded pipeline. Best-effort throughout —
455
+ a failure returns the Epic to Backlog for human review rather than raising.
456
+ """
457
+ from sdk import local_exec, graphify
458
+
459
+ tid = str(task.get("id", ""))
460
+ jira_key = task.get("jiraIssueKey") or task.get("jiraKey", "") or "EPIC"
461
+ summary = task.get("summary", "") or ""
462
+ description = task.get("description")
463
+ human = task.get("humanInstructions")
464
+ project_path = _resolve_local_project_path(task, payload)
465
+
466
+ await client.mark_in_progress(tid)
467
+ await send(Envelope(
468
+ type="step_update", thread_id=thread_id,
469
+ data={"jira_task_id": tid, "task_id": tid,
470
+ "current_step": f"Epic {jira_key}: analysing & generating user stories"},
471
+ ).model_dump())
472
+
473
+ # 1. Generate the decomposition, grounded in the codebase where one exists.
474
+ try:
475
+ await graphify.prepare(project_path)
476
+ except Exception: # noqa: BLE001
477
+ pass
478
+ gen = await local_exec.run_claude_local(
479
+ _build_epic_prompt(jira_key, summary, description, human),
480
+ project_path, allowed_tools=_RECON_ALLOWED_TOOLS, # read-only analysis
481
+ github_token=await client.github_token(),
482
+ )
483
+ doc = _extract_json_block(gen.get("result")) if gen.get("ok") else None
484
+ stories = (doc or {}).get("stories") or []
485
+ if not doc or not stories:
486
+ reason = (gen.get("error") or "could not generate a valid decomposition")[:200]
487
+ await client.log_activity(f"Epic {jira_key}: decomposition failed — {reason}")
488
+ await client.move_to_backlog(tid)
489
+ await send(Envelope(
490
+ type=Envelope.TYPE_ERROR, thread_id=thread_id,
491
+ data={"code": "EPIC_DECOMPOSE_FAILED", "task_id": tid, "message": reason},
492
+ ).model_dump())
493
+ return
494
+
495
+ # 2. Mark the Epic Done with the detailed description + plan.
496
+ epic_desc = (doc.get("epic_description") or description or summary or "")[:20000]
497
+ plan = (doc.get("plan") or "")[:8000]
498
+ await client.update_task_ml(
499
+ tid, {"status": "Done", "description": epic_desc, "initialAiPlan": plan},
500
+ model_used=_EPIC_MODELS,
501
+ )
502
+ await send(Envelope(
503
+ type="step_update", thread_id=thread_id,
504
+ data={"jira_task_id": tid, "current_step": f"Epic {jira_key}: marked Done — "
505
+ f"creating {min(len(stories), _MAX_EPIC_STORIES)} child task(s)"},
506
+ ).model_dump())
507
+
508
+ # 3. Create a To Do child Task per story, inheriting the Epic's fields.
509
+ inherited = _epic_inherited_fields(task)
510
+ created: list[str] = []
511
+ for st in stories[:_MAX_EPIC_STORIES]:
512
+ if not isinstance(st, dict) or not (st.get("summary") or "").strip():
513
+ continue
514
+ fields = {
515
+ **inherited,
516
+ "type": "Task",
517
+ "status": "To Do",
518
+ "summary": str(st.get("summary", "")).strip()[:250],
519
+ "description": str(st.get("description", "") or "")[:20000],
520
+ "humanInstructions": str(st.get("humanInstructions") or human or "")[:20000] or None,
521
+ "parentTaskId": tid,
522
+ }
523
+ if st.get("points"):
524
+ fields["points"] = st["points"]
525
+ new_id = await client.create_task_ml(fields, model_used=_EPIC_MODELS)
526
+ if new_id:
527
+ created.append(new_id)
528
+ await send(Envelope(
529
+ type="step_update", thread_id=thread_id,
530
+ data={"current_step": f" ↳ created To Do task: {fields['summary']}"},
531
+ ).model_dump())
532
+
533
+ await client.log_activity(
534
+ f"Epic {jira_key}: Done — created {len(created)}/{len(stories)} child To Do task(s)"
535
+ )
536
+ await send(Envelope(
537
+ type="step_update", thread_id=thread_id,
538
+ data={"jira_task_id": tid,
539
+ "current_step": f"Epic {jira_key} complete — {len(created)} child task(s) queued "
540
+ "(run again to implement them)"},
541
+ ).model_dump())
542
+
543
+
354
544
  async def _run_local_pipeline(
355
545
  client: BackendClient, payload: dict, send: Callable
356
546
  ) -> None:
@@ -2129,15 +2319,31 @@ async def handle_orchestrate_auto_local_run(
2129
2319
  ).model_dump())
2130
2320
  return
2131
2321
 
2132
- # RAW /tasks-ml records carry agentMode / jiraIssueKey / humanInstructions.
2133
- tasks = await client.list_todo_tasks_raw(status="To Do")
2134
- # Process oldest-created first (FIFO by Jira `createdAt`) so the ticket
2135
- # raised earliest is started first. Unknown/invalid timestamps sort last.
2136
- tasks = sorted(tasks, key=_task_created_key)
2322
+ # Targeted run: `only_keys` names specific Jira tickets to run (via
2323
+ # `agentos-auto ticket BBW-81 …`). Those run regardless of board status and
2324
+ # in the ORDER requested. Otherwise fetch the whole To Do queue (default).
2325
+ only_keys = [str(k).strip().upper() for k in (payload.get("only_keys") or []) if str(k).strip()]
2326
+ if only_keys:
2327
+ tasks = await client.list_tasks_by_keys(only_keys)
2328
+ found = {str(t.get("jiraIssueKey") or t.get("jiraKey") or "").strip().upper() for t in tasks}
2329
+ missing = [k for k in only_keys if k not in found]
2330
+ if missing:
2331
+ await send(Envelope(
2332
+ type="step_update", thread_id=thread_id,
2333
+ data={"current_step": f"⚠ not found (skipped): {', '.join(missing)}"},
2334
+ ).model_dump())
2335
+ # Keep the requested order (list_tasks_by_keys already does), no re-sort.
2336
+ else:
2337
+ # RAW /tasks-ml records carry agentMode / jiraIssueKey / humanInstructions.
2338
+ tasks = await client.list_todo_tasks_raw(status="To Do")
2339
+ # Process oldest-created first (FIFO by Jira `createdAt`) so the ticket
2340
+ # raised earliest is started first. Unknown/invalid timestamps sort last.
2341
+ tasks = sorted(tasks, key=_task_created_key)
2137
2342
 
2138
2343
  await send(Envelope(
2139
2344
  type="pipeline_started", thread_id=thread_id,
2140
- data={"mode": "orchestrate-auto-local", "task_count": len(tasks)},
2345
+ data={"mode": "orchestrate-auto-local", "task_count": len(tasks),
2346
+ "only_keys": only_keys or None},
2141
2347
  ).model_dump())
2142
2348
 
2143
2349
  if not tasks:
@@ -2173,6 +2379,27 @@ async def handle_orchestrate_auto_local_run(
2173
2379
  "project_path": project_path, "jira_task_id": tid, "agent_mode": agent_mode},
2174
2380
  ).model_dump())
2175
2381
 
2382
+ # EPIC → decompose (generate user stories, mark Done, create To Do
2383
+ # child tasks) instead of coding it directly. Isolated like every other
2384
+ # task: a failure here must not abort the remaining queue.
2385
+ if str(task.get("type") or "").strip().lower() == "epic":
2386
+ try:
2387
+ await _handle_epic(client, task, payload, send, thread_id)
2388
+ except Exception as exc: # noqa: BLE001
2389
+ logger.warning("auto_local.epic_failed task=%s err=%s", tid, exc)
2390
+ try:
2391
+ await client.log_activity(f"Task {tid}: epic decomposition errored — {str(exc)[:200]}")
2392
+ await client.move_to_backlog(tid)
2393
+ except Exception: # noqa: BLE001
2394
+ pass
2395
+ await send(Envelope(
2396
+ type=Envelope.TYPE_ERROR, thread_id=thread_id,
2397
+ data={"code": "EPIC_DECOMPOSE_FAILED", "task_id": tid,
2398
+ "message": str(exc)[:200]},
2399
+ ).model_dump())
2400
+ processed += 1
2401
+ continue
2402
+
2176
2403
  task_payload = {
2177
2404
  "thread_id": thread_id,
2178
2405
  "jira_task_id": tid,
@@ -9,6 +9,8 @@ directory, and the result is reported back. The only required input is the
9
9
  Commands:
10
10
  agentos-auto run every To Do task locally, in the BACKGROUND
11
11
  agentos-auto resume alias for run — re-fetches remaining To Do tasks
12
+ agentos-auto ticket K [K...] run ONLY the named Jira ticket(s), e.g. BBW-81 —
13
+ any status, in the order given (alias: tickets)
12
14
  agentos-auto stop ask the running loop to pause after the current task
13
15
  agentos-auto status show whether the background loop is running / stop pending
14
16
  agentos-auto update upgrade the SDK to the latest version
@@ -224,6 +226,39 @@ def _parse_workspace_root(argv: list[str]) -> str | None:
224
226
  return None
225
227
 
226
228
 
229
+ def _parse_ticket_keys(argv: list[str]) -> list[str]:
230
+ """Jira keys passed to `agentos-auto ticket <KEY> [<KEY> ...]`.
231
+
232
+ Accepts space- and/or comma-separated keys (e.g. `BBW-81 BBW-80` or
233
+ `BBW-81,BBW-80`), skips the leading subcommand and any flags (and the value
234
+ of --workspace-root), upper-cases and de-dupes while preserving order.
235
+ """
236
+ keys: list[str] = []
237
+ skip_next = False
238
+ for i, tok in enumerate(argv):
239
+ if i == 0:
240
+ continue # the subcommand itself (ticket/tickets)
241
+ if skip_next:
242
+ skip_next = False
243
+ continue
244
+ if tok.startswith("-"):
245
+ if tok == "--workspace-root":
246
+ skip_next = True # its value is a directory, not a ticket key
247
+ continue
248
+ for part in tok.split(","):
249
+ k = part.strip()
250
+ if k:
251
+ keys.append(k)
252
+ seen: set[str] = set()
253
+ out: list[str] = []
254
+ for k in keys:
255
+ ku = k.upper()
256
+ if ku not in seen:
257
+ seen.add(ku)
258
+ out.append(ku)
259
+ return out
260
+
261
+
227
262
  _current_task: str | None = None
228
263
 
229
264
 
@@ -263,7 +298,7 @@ async def _send(env: dict) -> None:
263
298
  print(f" [{etype}] {json.dumps(data)[:200]}")
264
299
 
265
300
 
266
- def _run_loop(workspace_root: str | None) -> None:
301
+ def _run_loop(workspace_root: str | None, only_keys: list[str] | None = None) -> None:
267
302
  from sdk import local_exec
268
303
  from sdk.client import BackendClient, register_status_observer
269
304
  from sdk.ipc import handlers
@@ -282,6 +317,9 @@ def _run_loop(workspace_root: str | None) -> None:
282
317
  payload: dict = {"thread_id": "agentos-auto-cli"}
283
318
  if workspace_root:
284
319
  payload["workspace_root"] = workspace_root
320
+ if only_keys:
321
+ # Targeted run: only these Jira tickets, in this order, regardless of status.
322
+ payload["only_keys"] = only_keys
285
323
 
286
324
  _clear_stop() # a fresh run/resume clears any stale stop flag
287
325
  _clear_backlogged() # session-scoped: only track Backlog moves from THIS run
@@ -420,7 +458,18 @@ def main() -> None:
420
458
  print("stop pending: yes" if _stop_requested() else "stop pending: no")
421
459
  return
422
460
 
423
- if cmd in ("run", "resume"):
461
+ if cmd in ("run", "resume", "ticket", "tickets"):
462
+ # Targeted run: `ticket`/`tickets` runs ONLY the named Jira keys (any
463
+ # status, in the order given); `run`/`resume` runs the whole To Do queue.
464
+ only_keys: list[str] | None = None
465
+ if cmd in ("ticket", "tickets"):
466
+ only_keys = _parse_ticket_keys(argv)
467
+ if not only_keys:
468
+ print("usage: agentos-auto ticket <JIRA-KEY> [<JIRA-KEY> ...]")
469
+ print(" e.g. agentos-auto ticket BBW-81")
470
+ print(" agentos-auto ticket BBW-81 BBW-80")
471
+ sys.exit(1)
472
+
424
473
  # Self-update FIRST (before the already-running check) so the installed
425
474
  # package is refreshed even when a daemon is already running — otherwise a
426
475
  # long-lived old daemon would pin `stop`/`status` to a stale version. Runs
@@ -430,7 +479,7 @@ def main() -> None:
430
479
  from sdk.updater import auto_update_and_reexec
431
480
  auto_update_and_reexec("sdk.run_auto", sys.argv[1:])
432
481
 
433
- # Refuse to start a second loop — one background daemon owns the To Do queue.
482
+ # Refuse to start a second loop — one background daemon owns the queue.
434
483
  pid = _daemon_running()
435
484
  if pid:
436
485
  print(f"agentos-auto is already running in the background (pid {pid}).")
@@ -445,13 +494,14 @@ def main() -> None:
445
494
  # attached (useful for debugging). On platforms without fork we stay attached.
446
495
  foreground = "--foreground" in argv or "-f" in argv
447
496
  if not foreground and hasattr(os, "fork"):
448
- print("▶ agentos-auto started in the background it keeps running after you "
449
- "close this terminal.")
497
+ target = f" tickets: {', '.join(only_keys)}" if only_keys else ""
498
+ print(f" agentos-auto started in the background{target} — it keeps running "
499
+ "after you close this terminal.")
450
500
  print(f" logs: {_LOG_FILE}")
451
501
  print(" status: agentos-auto status")
452
502
  print(" stop: agentos-auto stop")
453
503
  if not foreground and _daemonize():
454
- _run_loop(workspace_root) # only the detached daemon child reaches here
504
+ _run_loop(workspace_root, only_keys) # only the detached daemon child reaches here
455
505
  return
456
506
  if not foreground:
457
507
  print("note: background mode unavailable on this platform — running in the "
@@ -460,10 +510,10 @@ def main() -> None:
460
510
  # Foreground run still records a PID so stop/status can find it.
461
511
  _AGENTOS_DIR.mkdir(parents=True, exist_ok=True)
462
512
  _PID_FILE.write_text(str(os.getpid()))
463
- _run_loop(workspace_root)
513
+ _run_loop(workspace_root, only_keys)
464
514
  return
465
515
 
466
- print(f"unknown command '{cmd}'. use: run | resume | stop | status | update")
516
+ print(f"unknown command '{cmd}'. use: run | resume | ticket | stop | status | update")
467
517
  sys.exit(1)
468
518
 
469
519