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
@@ -0,0 +1,270 @@
1
+ #!/usr/bin/env python3
2
+ import argparse
3
+ from contextlib import closing
4
+ import json
5
+ import sqlite3
6
+ import tempfile
7
+ from datetime import datetime, timezone
8
+ from pathlib import Path
9
+
10
+ from robert_agent.common import emit
11
+ from robert_agent import storage
12
+ from robert_agent import publish
13
+
14
+
15
+ COMMENT_BODY = (
16
+ "<!-- robert-comment task_id=task-comment attempt_id=attempt-comment "
17
+ "event_fingerprints=comment:1 -->\nExisting comment"
18
+ )
19
+ PR_BODY = (
20
+ "<!-- robert-workstream\n"
21
+ "origin_workstream_id: github:x/y#1\n"
22
+ "source_issue: 1\n"
23
+ "task_id: task-pr\n"
24
+ "created_by: robert\n"
25
+ "-->\nExisting PR"
26
+ )
27
+ EXISTING_PR_BODY_WITH_DIFFERENT_TASK = (
28
+ "<!-- robert-workstream\n"
29
+ "origin_workstream_id: github:x/y#1\n"
30
+ "source_issue: 1\n"
31
+ "task_id: task-pr-old\n"
32
+ "created_by: robert\n"
33
+ "-->\nExisting PR"
34
+ )
35
+
36
+
37
+ class _Completed:
38
+ returncode = 0
39
+ stderr = ""
40
+
41
+ def __init__(self, stdout):
42
+ self.stdout = stdout
43
+
44
+
45
+ class _DedupeRunner:
46
+ def __init__(self):
47
+ self.calls = []
48
+
49
+ def __call__(self, command, **kwargs):
50
+ self.calls.append({"command": list(command), "kwargs": dict(kwargs)})
51
+ if command == ["gh", "api", "repos/x/y/issues/1/comments?per_page=100", "--paginate", "--slurp"]:
52
+ return _Completed(
53
+ json.dumps(
54
+ [
55
+ [
56
+ {
57
+ "id": 987,
58
+ "html_url": "https://github.com/x/y/issues/1#issuecomment-987",
59
+ "body": COMMENT_BODY,
60
+ }
61
+ ]
62
+ ]
63
+ )
64
+ )
65
+ if command[:3] == ["gh", "pr", "list"]:
66
+ return _Completed(
67
+ json.dumps(
68
+ [
69
+ {
70
+ "number": 42,
71
+ "url": "https://github.com/x/y/pull/42",
72
+ "baseRefName": "main",
73
+ "headRefName": "codex/dd-1",
74
+ "headRepositoryOwner": {"login": "x"},
75
+ }
76
+ ]
77
+ )
78
+ )
79
+ if command == [
80
+ "gh",
81
+ "pr",
82
+ "view",
83
+ "42",
84
+ "--repo",
85
+ "x/y",
86
+ "--json",
87
+ "number,url,body,baseRefName",
88
+ ]:
89
+ return _Completed(
90
+ json.dumps(
91
+ {
92
+ "number": 42,
93
+ "url": "https://github.com/x/y/pull/42",
94
+ "body": EXISTING_PR_BODY_WITH_DIFFERENT_TASK,
95
+ "baseRefName": "main",
96
+ "headRefName": "codex/dd-1",
97
+ "headRepositoryOwner": {"login": "x"},
98
+ },
99
+ sort_keys=True,
100
+ )
101
+ )
102
+ return _Completed("")
103
+
104
+
105
+ def _workspace_dir(workspace_dir):
106
+ if workspace_dir:
107
+ path = Path(workspace_dir).expanduser().resolve()
108
+ path.mkdir(parents=True, exist_ok=True)
109
+ return path
110
+ return Path(tempfile.mkdtemp(prefix="dd-publish-dedupe-")).resolve()
111
+
112
+
113
+ def _insert_fixture(db_path):
114
+ storage.init_database(db_path)
115
+ now = datetime.now(timezone.utc).isoformat()
116
+ with closing(sqlite3.connect(db_path)) as conn, conn:
117
+ conn.execute(
118
+ """
119
+ INSERT INTO repos(repo_id, full_name, github_account, default_base_branch, repo_root, worktree_root)
120
+ VALUES ('repo-1', 'x/y', 'robot', 'main', '/repo', '/repo/.worktrees')
121
+ """
122
+ )
123
+ conn.execute(
124
+ """
125
+ INSERT INTO github_sources(source_id, repo_id, source_key, source_type, number, html_url)
126
+ VALUES ('source-1', 'repo-1', 'github:x/y#1', 'issue', 1, 'https://github.com/x/y/issues/1')
127
+ """
128
+ )
129
+ conn.execute(
130
+ """
131
+ INSERT INTO workstreams(workstream_id, repo_id, primary_source_id, lifecycle, created_at, updated_at)
132
+ VALUES ('github:x/y#1', 'repo-1', 'source-1', 'active', ?, ?)
133
+ """,
134
+ (now, now),
135
+ )
136
+ conn.executemany(
137
+ """
138
+ INSERT INTO tasks(task_id, workstream_id, lifecycle, priority, created_at, updated_at)
139
+ VALUES (?, 'github:x/y#1', ?, 'P1', ?, ?)
140
+ """,
141
+ [
142
+ ("task-comment", "completed", now, now),
143
+ ("task-pr", "running", now, now),
144
+ ],
145
+ )
146
+ conn.executemany(
147
+ """
148
+ INSERT INTO attempts(attempt_id, task_id, attempt_no, status, started_at, heartbeat_at)
149
+ VALUES (?, ?, 1, 'completed', ?, ?)
150
+ """,
151
+ [
152
+ ("attempt-comment", "task-comment", now, now),
153
+ ("attempt-pr", "task-pr", now, now),
154
+ ],
155
+ )
156
+ conn.executemany(
157
+ """
158
+ INSERT INTO worker_results(
159
+ result_id, task_id, attempt_id, output_type,
160
+ consumed_event_fingerprints_json, verification_json, handoff, created_at
161
+ )
162
+ VALUES (?, ?, ?, ?, '["comment:1"]', '[]', 'ready', ?)
163
+ """,
164
+ [
165
+ ("result-comment", "task-comment", "attempt-comment", "comment_analysis", now),
166
+ ("result-pr", "task-pr", "attempt-pr", "new_pr", now),
167
+ ],
168
+ )
169
+ conn.executemany(
170
+ """
171
+ INSERT INTO github_actions(
172
+ action_id, result_id, task_id, action_type, target_url,
173
+ audit_status, publish_status, created_at, metadata_json
174
+ )
175
+ VALUES (?, ?, ?, ?, ?, 'accepted', 'not_published', ?, ?)
176
+ """,
177
+ [
178
+ (
179
+ "action-comment",
180
+ "result-comment",
181
+ "task-comment",
182
+ "comment",
183
+ "https://github.com/x/y/issues/1",
184
+ now,
185
+ json.dumps({"body": COMMENT_BODY}, sort_keys=True),
186
+ ),
187
+ (
188
+ "action-pr",
189
+ "result-pr",
190
+ "task-pr",
191
+ "open_pr",
192
+ None,
193
+ now,
194
+ json.dumps(
195
+ {
196
+ "repo": "x/y",
197
+ "head": "codex/dd-1",
198
+ "head_owner": "x",
199
+ "base": "main",
200
+ "title": "Existing PR",
201
+ "body": PR_BODY,
202
+ },
203
+ sort_keys=True,
204
+ ),
205
+ ),
206
+ ],
207
+ )
208
+
209
+
210
+ def _action_counts(db_path):
211
+ with closing(sqlite3.connect(db_path)) as conn:
212
+ rows = conn.execute(
213
+ """
214
+ SELECT publish_status, metadata_json
215
+ FROM github_actions
216
+ ORDER BY action_id
217
+ """
218
+ ).fetchall()
219
+ published = 0
220
+ deduplicated = 0
221
+ for publish_status, metadata_json in rows:
222
+ if publish_status == "published":
223
+ published += 1
224
+ metadata = json.loads(metadata_json or "{}")
225
+ if (metadata.get("publish") or {}).get("deduplicated"):
226
+ deduplicated += 1
227
+ return {"published": published, "deduplicated": deduplicated}
228
+
229
+
230
+ def publish_dedupe_acceptance(workspace_dir=None):
231
+ workspace = _workspace_dir(workspace_dir)
232
+ db_path = workspace / "dd.sqlite3"
233
+ _insert_fixture(db_path)
234
+ runner = _DedupeRunner()
235
+ publish_result = publish.publish_ready_actions(db_path, dry_run=False, run_command=runner)
236
+ action_counts = _action_counts(db_path)
237
+ create_commands = [
238
+ call
239
+ for call in runner.calls
240
+ if call["command"][:3] == ["gh", "api", "repos/x/y/issues/1/comments"]
241
+ or call["command"][:3] == ["gh", "pr", "create"]
242
+ ]
243
+ ok = (
244
+ publish_result.get("ok")
245
+ and publish_result.get("published_count") == 2
246
+ and publish_result.get("deduplicated_count") == 2
247
+ and not create_commands
248
+ )
249
+ return {
250
+ "ok": bool(ok),
251
+ "status": "completed" if ok else "failed_dedupe_verification",
252
+ "workspace_dir": str(workspace),
253
+ "db_path": str(db_path),
254
+ "publish_result": publish_result,
255
+ "action_counts": action_counts,
256
+ "gh_calls": runner.calls,
257
+ "create_commands": create_commands,
258
+ }
259
+
260
+
261
+ def main(argv=None):
262
+ parser = argparse.ArgumentParser()
263
+ parser.add_argument("--workspace-dir")
264
+ args = parser.parse_args(argv)
265
+ result = publish_dedupe_acceptance(workspace_dir=args.workspace_dir)
266
+ return emit(result, 0 if result.get("ok") else 2)
267
+
268
+
269
+ if __name__ == "__main__":
270
+ raise SystemExit(main())
@@ -0,0 +1,41 @@
1
+ """Redaction helpers for the rewritten DD GitHub agent."""
2
+
3
+ import re
4
+
5
+
6
+ SECRET_PATTERNS = [
7
+ re.compile(r"Authorization\s*:", re.I),
8
+ re.compile(r"Cookie\s*:", re.I),
9
+ re.compile(r"-----BEGIN [A-Z ]*PRIVATE KEY-----"),
10
+ re.compile(r"\b[A-Za-z0-9_]*TOKEN[A-Za-z0-9_]*\s*=", re.I),
11
+ re.compile(r"\btoken\s*:\s*(?:ghp|github_pat|gho|ghu|ghs|ghr)_[A-Za-z0-9_]+", re.I),
12
+ re.compile(r"\b(?:ghp|github_pat|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{12,}\b"),
13
+ re.compile(r"\b(?:AKIA|ASIA)[A-Z0-9]{16}\b"),
14
+ re.compile(r"\bxox[baprs]-[A-Za-z0-9-]{20,}\b"),
15
+ re.compile(r"\bsk-(?:proj-)?[A-Za-z0-9_-]{20,}\b"),
16
+ re.compile(r"\bAIza[0-9A-Za-z_-]{20,}\b"),
17
+ re.compile(r"\bBearer\s+[A-Za-z0-9._~+/=-]{20,}\b", re.I),
18
+ ]
19
+
20
+ LOCAL_PATH = re.compile(r"(?:/Users|/home|/root|/data|/tmp|/var/folders)/[^\s:;,)]+")
21
+ INTERNAL_IP = re.compile(r"\b(?:10\.\d{1,3}\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3}|172\.(?:1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3})\b")
22
+ INTERNAL_DOMAIN = re.compile(r"\b[A-Za-z0-9.-]+\.(?:woa\.com|corp|internal|local)\b")
23
+
24
+
25
+ def redact_text(text):
26
+ for pattern in SECRET_PATTERNS:
27
+ if pattern.search(text):
28
+ return {
29
+ "ok": False,
30
+ "status": "blocked_secret",
31
+ "safe_error": "text contains a high-risk secret pattern",
32
+ }
33
+
34
+ redacted = LOCAL_PATH.sub("<local-path>", text)
35
+ redacted = INTERNAL_IP.sub("<internal-ip>", redacted)
36
+ redacted = INTERNAL_DOMAIN.sub("<internal-domain>", redacted)
37
+ return {
38
+ "ok": True,
39
+ "status": "redacted",
40
+ "text": redacted,
41
+ }