robert-github-agent 0.1.0b1__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 (111) hide show
  1. robert_agent/__init__.py +1 -0
  2. robert_agent/acceptance.py +394 -0
  3. robert_agent/acceptance_suite.py +287 -0
  4. robert_agent/audit_result.py +501 -0
  5. robert_agent/authorize.py +117 -0
  6. robert_agent/board.py +538 -0
  7. robert_agent/chat_status.py +338 -0
  8. robert_agent/cli/__init__.py +1 -0
  9. robert_agent/cli/exit_codes.py +5 -0
  10. robert_agent/cli/main.py +535 -0
  11. robert_agent/cli/output.py +20 -0
  12. robert_agent/common.py +6 -0
  13. robert_agent/controlled_e2e_acceptance.py +394 -0
  14. robert_agent/daemon.py +607 -0
  15. robert_agent/daemon_state.py +319 -0
  16. robert_agent/diagnostics.py +119 -0
  17. robert_agent/discover.py +775 -0
  18. robert_agent/dispatch.py +217 -0
  19. robert_agent/doctor.py +94 -0
  20. robert_agent/github_api.py +12 -0
  21. robert_agent/init_config.py +126 -0
  22. robert_agent/integrations/__init__.py +1 -0
  23. robert_agent/integrations/openclaw.py +285 -0
  24. robert_agent/live_discovery_acceptance.py +70 -0
  25. robert_agent/live_worker_acceptance.py +363 -0
  26. robert_agent/live_worktree_acceptance.py +344 -0
  27. robert_agent/loop_engine.py +285 -0
  28. robert_agent/memory_curator.py +105 -0
  29. robert_agent/migrate.py +157 -0
  30. robert_agent/notify.py +74 -0
  31. robert_agent/paths.py +16 -0
  32. robert_agent/production_write_canary.py +254 -0
  33. robert_agent/project_memory.py +503 -0
  34. robert_agent/publish.py +743 -0
  35. robert_agent/publish_dedupe_acceptance.py +270 -0
  36. robert_agent/redaction.py +41 -0
  37. robert_agent/render_prompt.py +544 -0
  38. robert_agent/resource_files.py +8 -0
  39. robert_agent/resources/__init__.py +1 -0
  40. robert_agent/resources/acceptance-matrix.md +120 -0
  41. robert_agent/resources/classifier.md +19 -0
  42. robert_agent/resources/command-matrix.md +38 -0
  43. robert_agent/resources/config.example.yml +20 -0
  44. robert_agent/resources/db/migrations/001_legacy_dd_to_robert.sql +14 -0
  45. robert_agent/resources/db/schema.sql +479 -0
  46. robert_agent/resources/failure-modes.md +36 -0
  47. robert_agent/resources/fixtures/actor-permission.json +1 -0
  48. robert_agent/resources/fixtures/discovery.json +1 -0
  49. robert_agent/resources/fixtures/redaction.json +1 -0
  50. robert_agent/resources/fixtures/review-followup.json +1 -0
  51. robert_agent/resources/fixtures/worker-results.json +1 -0
  52. robert_agent/resources/fixtures/workstreams.json +1 -0
  53. robert_agent/resources/github-events.md +77 -0
  54. robert_agent/resources/kanban-control.md +165 -0
  55. robert_agent/resources/redaction.md +29 -0
  56. robert_agent/resources/result-contract.md +56 -0
  57. robert_agent/resources/routes.yml +82 -0
  58. robert_agent/resources/schemas/config.schema.json +123 -0
  59. robert_agent/resources/schemas/event.schema.json +18 -0
  60. robert_agent/resources/schemas/result.schema.json +99 -0
  61. robert_agent/resources/schemas/route.schema.json +23 -0
  62. robert_agent/resources/schemas/snapshot.schema.json +17 -0
  63. robert_agent/resources/schemas/task.schema.json +15 -0
  64. robert_agent/resources/trust-model.md +16 -0
  65. robert_agent/resources/worker-prompt.md +121 -0
  66. robert_agent/resources/worker-protocol.md +47 -0
  67. robert_agent/resources/workflow.yml +50 -0
  68. robert_agent/resources/workstream-model.md +17 -0
  69. robert_agent/route.py +232 -0
  70. robert_agent/route_config.py +64 -0
  71. robert_agent/run_once.py +5375 -0
  72. robert_agent/runtime_knowledge.py +392 -0
  73. robert_agent/service.py +161 -0
  74. robert_agent/skills.py +28 -0
  75. robert_agent/status.py +1051 -0
  76. robert_agent/storage.py +376 -0
  77. robert_agent/summarize.py +100 -0
  78. robert_agent/supervise.py +72 -0
  79. robert_agent/usage.py +192 -0
  80. robert_agent/validate_config.py +616 -0
  81. robert_agent/wakeup.py +261 -0
  82. robert_agent/web.py +2893 -0
  83. robert_agent/web_assets/board.css +255 -0
  84. robert_agent/web_assets/board.html +165 -0
  85. robert_agent/web_assets/board.js +660 -0
  86. robert_agent/web_assets/github-shell.css +122 -0
  87. robert_agent/web_assets/index.html +103 -0
  88. robert_agent/web_assets/operations.css +168 -0
  89. robert_agent/web_assets/workbench.css +131 -0
  90. robert_agent/web_assets/workbench.js +581 -0
  91. robert_agent/work_items.py +1016 -0
  92. robert_agent/workbench.py +701 -0
  93. robert_agent/worker/__init__.py +1 -0
  94. robert_agent/worker/heartbeat.py +190 -0
  95. robert_agent/worker/result.py +321 -0
  96. robert_agent/worker/snapshot.py +98 -0
  97. robert_agent/worker_adapters/__init__.py +138 -0
  98. robert_agent/worker_adapters/cbc.py +68 -0
  99. robert_agent/worker_adapters/codex.py +56 -0
  100. robert_agent/worker_adapters/command.py +33 -0
  101. robert_agent/worker_adapters/tcodex.py +56 -0
  102. robert_agent/worker_heartbeat.py +6 -0
  103. robert_agent/worker_result.py +6 -0
  104. robert_agent/worker_snapshot.py +6 -0
  105. robert_agent/workstream.py +55 -0
  106. robert_agent/worktree.py +297 -0
  107. robert_github_agent-0.1.0b1.dist-info/METADATA +217 -0
  108. robert_github_agent-0.1.0b1.dist-info/RECORD +111 -0
  109. robert_github_agent-0.1.0b1.dist-info/WHEEL +4 -0
  110. robert_github_agent-0.1.0b1.dist-info/entry_points.txt +2 -0
  111. robert_github_agent-0.1.0b1.dist-info/licenses/LICENSE +201 -0
robert_agent/wakeup.py ADDED
@@ -0,0 +1,261 @@
1
+ """Durable local wakeup hints for the DD GitHub agent."""
2
+
3
+ from datetime import datetime, timezone
4
+ import json
5
+ from uuid import uuid4
6
+
7
+
8
+ WAKEUP_STATUSES = ("pending", "consumed", "expired", "canceled")
9
+
10
+
11
+ def utc_now():
12
+ return datetime.now(timezone.utc).isoformat()
13
+
14
+
15
+ def _table_exists(conn):
16
+ row = conn.execute(
17
+ "SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'wakeups'"
18
+ ).fetchone()
19
+ return bool(row)
20
+
21
+
22
+ def _decode_json(value, default):
23
+ if not value:
24
+ return default
25
+ try:
26
+ parsed = json.loads(value)
27
+ except (TypeError, ValueError):
28
+ return default
29
+ return parsed
30
+
31
+
32
+ def _wakeup_from_row(row):
33
+ if row is None:
34
+ return None
35
+ if hasattr(row, "keys"):
36
+ payload = dict(row)
37
+ else:
38
+ columns = [
39
+ "wakeup_id",
40
+ "repo_id",
41
+ "reason",
42
+ "dedupe_key",
43
+ "work_item_id",
44
+ "task_id",
45
+ "attempt_id",
46
+ "result_id",
47
+ "source_run_id",
48
+ "consumed_run_id",
49
+ "status",
50
+ "not_before_at",
51
+ "expires_at",
52
+ "attempt_count",
53
+ "created_at",
54
+ "updated_at",
55
+ "metadata_json",
56
+ ]
57
+ payload = {column: row[index] for index, column in enumerate(columns)}
58
+ payload["metadata"] = _decode_json(payload.pop("metadata_json"), {}) or {}
59
+ return payload
60
+
61
+
62
+ def request_wakeup(
63
+ conn,
64
+ *,
65
+ repo_id,
66
+ reason,
67
+ dedupe_key,
68
+ work_item_id=None,
69
+ task_id=None,
70
+ attempt_id=None,
71
+ result_id=None,
72
+ source_run_id=None,
73
+ metadata=None,
74
+ not_before_at=None,
75
+ expires_at=None,
76
+ now=None,
77
+ ):
78
+ now = now or utc_now()
79
+ due_at = not_before_at or now
80
+ metadata_json = json.dumps(metadata or {}, ensure_ascii=False, sort_keys=True)
81
+ wakeup_id = f"wakeup-{uuid4().hex[:12]}"
82
+ existing = conn.execute(
83
+ """
84
+ SELECT wakeup_id, repo_id, reason, dedupe_key, work_item_id, task_id, attempt_id,
85
+ result_id, source_run_id, consumed_run_id, status, not_before_at,
86
+ expires_at, attempt_count, created_at, updated_at, metadata_json
87
+ FROM wakeups
88
+ WHERE repo_id = ?
89
+ AND reason = ?
90
+ AND dedupe_key = ?
91
+ """,
92
+ (repo_id, reason, dedupe_key),
93
+ ).fetchone()
94
+ if existing:
95
+ payload = _wakeup_from_row(existing)
96
+ if payload["status"] == "pending":
97
+ payload["status"] = "already_pending"
98
+ return payload
99
+ conn.execute(
100
+ """
101
+ INSERT INTO wakeups(
102
+ wakeup_id, repo_id, reason, dedupe_key, work_item_id, task_id, attempt_id,
103
+ result_id, source_run_id, status, not_before_at, expires_at,
104
+ created_at, updated_at, metadata_json
105
+ )
106
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 'pending', ?, ?, ?, ?, ?)
107
+ """,
108
+ (
109
+ wakeup_id,
110
+ repo_id,
111
+ reason,
112
+ dedupe_key,
113
+ work_item_id,
114
+ task_id,
115
+ attempt_id,
116
+ result_id,
117
+ source_run_id,
118
+ due_at,
119
+ expires_at,
120
+ now,
121
+ now,
122
+ metadata_json,
123
+ ),
124
+ )
125
+ return {
126
+ "wakeup_id": wakeup_id,
127
+ "repo_id": repo_id,
128
+ "reason": reason,
129
+ "dedupe_key": dedupe_key,
130
+ "work_item_id": work_item_id,
131
+ "task_id": task_id,
132
+ "attempt_id": attempt_id,
133
+ "result_id": result_id,
134
+ "source_run_id": source_run_id,
135
+ "consumed_run_id": None,
136
+ "status": "pending",
137
+ "not_before_at": due_at,
138
+ "expires_at": expires_at,
139
+ "attempt_count": 0,
140
+ "created_at": now,
141
+ "updated_at": now,
142
+ "metadata": metadata or {},
143
+ }
144
+
145
+
146
+ def list_wakeups(conn, *, status=None, limit=20, now=None):
147
+ if not _table_exists(conn):
148
+ return []
149
+ clauses = []
150
+ params = []
151
+ if status:
152
+ clauses.append("status = ?")
153
+ params.append(status)
154
+ if now:
155
+ clauses.append("(expires_at IS NULL OR expires_at > ?)")
156
+ params.append(now)
157
+ where = f"WHERE {' AND '.join(clauses)}" if clauses else ""
158
+ rows = conn.execute(
159
+ f"""
160
+ SELECT wakeup_id, repo_id, reason, dedupe_key, work_item_id, task_id, attempt_id,
161
+ result_id, source_run_id, consumed_run_id, status, not_before_at,
162
+ expires_at, attempt_count, created_at, updated_at, metadata_json
163
+ FROM wakeups
164
+ {where}
165
+ ORDER BY
166
+ CASE status
167
+ WHEN 'pending' THEN 0
168
+ WHEN 'expired' THEN 1
169
+ WHEN 'consumed' THEN 2
170
+ ELSE 3
171
+ END,
172
+ not_before_at,
173
+ created_at,
174
+ wakeup_id
175
+ LIMIT ?
176
+ """,
177
+ params + [limit],
178
+ ).fetchall()
179
+ return [_wakeup_from_row(row) for row in rows]
180
+
181
+
182
+ def summarize_wakeups(conn, now=None):
183
+ if not _table_exists(conn):
184
+ return {
185
+ "available": False,
186
+ "total": 0,
187
+ "pending": 0,
188
+ "due": 0,
189
+ "by_status": {},
190
+ "by_reason": {},
191
+ }
192
+ now = now or utc_now()
193
+ by_status = {
194
+ row[0]: row[1]
195
+ for row in conn.execute(
196
+ "SELECT status, COUNT(*) FROM wakeups GROUP BY status"
197
+ )
198
+ }
199
+ by_reason = {
200
+ row[0]: row[1]
201
+ for row in conn.execute(
202
+ "SELECT reason, COUNT(*) FROM wakeups GROUP BY reason"
203
+ )
204
+ }
205
+ due = conn.execute(
206
+ """
207
+ SELECT COUNT(*)
208
+ FROM wakeups
209
+ WHERE status = 'pending'
210
+ AND not_before_at <= ?
211
+ AND (expires_at IS NULL OR expires_at > ?)
212
+ """,
213
+ (now, now),
214
+ ).fetchone()[0]
215
+ total = sum(by_status.values())
216
+ return {
217
+ "available": True,
218
+ "total": total,
219
+ "pending": by_status.get("pending", 0),
220
+ "due": due,
221
+ "by_status": dict(sorted(by_status.items())),
222
+ "by_reason": dict(sorted(by_reason.items())),
223
+ }
224
+
225
+
226
+ def consume_wakeups_for_results(conn, *, result_ids, run_id, now=None):
227
+ if not result_ids or not _table_exists(conn):
228
+ return 0
229
+ now = now or utc_now()
230
+ placeholders = ",".join("?" for _result_id in result_ids)
231
+ cur = conn.execute(
232
+ f"""
233
+ UPDATE wakeups
234
+ SET status = 'consumed',
235
+ consumed_run_id = ?,
236
+ updated_at = ?
237
+ WHERE reason = 'worker_result_ready'
238
+ AND status = 'pending'
239
+ AND result_id IN ({placeholders})
240
+ """,
241
+ [run_id, now] + list(result_ids),
242
+ )
243
+ return cur.rowcount
244
+
245
+
246
+ def expire_due_wakeups(conn, *, now=None):
247
+ if not _table_exists(conn):
248
+ return 0
249
+ now = now or utc_now()
250
+ cur = conn.execute(
251
+ """
252
+ UPDATE wakeups
253
+ SET status = 'expired',
254
+ updated_at = ?
255
+ WHERE status = 'pending'
256
+ AND expires_at IS NOT NULL
257
+ AND expires_at <= ?
258
+ """,
259
+ (now, now),
260
+ )
261
+ return cur.rowcount