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.
- robert_agent/__init__.py +1 -0
- robert_agent/acceptance.py +394 -0
- robert_agent/acceptance_suite.py +287 -0
- robert_agent/audit_result.py +501 -0
- robert_agent/authorize.py +117 -0
- robert_agent/board.py +538 -0
- robert_agent/chat_status.py +338 -0
- robert_agent/cli/__init__.py +1 -0
- robert_agent/cli/exit_codes.py +5 -0
- robert_agent/cli/main.py +535 -0
- robert_agent/cli/output.py +20 -0
- robert_agent/common.py +6 -0
- robert_agent/controlled_e2e_acceptance.py +394 -0
- robert_agent/daemon.py +607 -0
- robert_agent/daemon_state.py +319 -0
- robert_agent/diagnostics.py +119 -0
- robert_agent/discover.py +775 -0
- robert_agent/dispatch.py +217 -0
- robert_agent/doctor.py +94 -0
- robert_agent/github_api.py +12 -0
- robert_agent/init_config.py +126 -0
- robert_agent/integrations/__init__.py +1 -0
- robert_agent/integrations/openclaw.py +285 -0
- robert_agent/live_discovery_acceptance.py +70 -0
- robert_agent/live_worker_acceptance.py +363 -0
- robert_agent/live_worktree_acceptance.py +344 -0
- robert_agent/loop_engine.py +285 -0
- robert_agent/memory_curator.py +105 -0
- robert_agent/migrate.py +157 -0
- robert_agent/notify.py +74 -0
- robert_agent/paths.py +16 -0
- robert_agent/production_write_canary.py +254 -0
- robert_agent/project_memory.py +503 -0
- robert_agent/publish.py +743 -0
- robert_agent/publish_dedupe_acceptance.py +270 -0
- robert_agent/redaction.py +41 -0
- robert_agent/render_prompt.py +544 -0
- robert_agent/resource_files.py +8 -0
- robert_agent/resources/__init__.py +1 -0
- robert_agent/resources/acceptance-matrix.md +120 -0
- robert_agent/resources/classifier.md +19 -0
- robert_agent/resources/command-matrix.md +38 -0
- robert_agent/resources/config.example.yml +20 -0
- robert_agent/resources/db/migrations/001_legacy_dd_to_robert.sql +14 -0
- robert_agent/resources/db/schema.sql +479 -0
- robert_agent/resources/failure-modes.md +36 -0
- robert_agent/resources/fixtures/actor-permission.json +1 -0
- robert_agent/resources/fixtures/discovery.json +1 -0
- robert_agent/resources/fixtures/redaction.json +1 -0
- robert_agent/resources/fixtures/review-followup.json +1 -0
- robert_agent/resources/fixtures/worker-results.json +1 -0
- robert_agent/resources/fixtures/workstreams.json +1 -0
- robert_agent/resources/github-events.md +77 -0
- robert_agent/resources/kanban-control.md +165 -0
- robert_agent/resources/redaction.md +29 -0
- robert_agent/resources/result-contract.md +56 -0
- robert_agent/resources/routes.yml +82 -0
- robert_agent/resources/schemas/config.schema.json +123 -0
- robert_agent/resources/schemas/event.schema.json +18 -0
- robert_agent/resources/schemas/result.schema.json +99 -0
- robert_agent/resources/schemas/route.schema.json +23 -0
- robert_agent/resources/schemas/snapshot.schema.json +17 -0
- robert_agent/resources/schemas/task.schema.json +15 -0
- robert_agent/resources/trust-model.md +16 -0
- robert_agent/resources/worker-prompt.md +121 -0
- robert_agent/resources/worker-protocol.md +47 -0
- robert_agent/resources/workflow.yml +50 -0
- robert_agent/resources/workstream-model.md +17 -0
- robert_agent/route.py +232 -0
- robert_agent/route_config.py +64 -0
- robert_agent/run_once.py +5375 -0
- robert_agent/runtime_knowledge.py +392 -0
- robert_agent/service.py +161 -0
- robert_agent/skills.py +28 -0
- robert_agent/status.py +1051 -0
- robert_agent/storage.py +376 -0
- robert_agent/summarize.py +100 -0
- robert_agent/supervise.py +72 -0
- robert_agent/usage.py +192 -0
- robert_agent/validate_config.py +616 -0
- robert_agent/wakeup.py +261 -0
- robert_agent/web.py +2893 -0
- robert_agent/web_assets/board.css +255 -0
- robert_agent/web_assets/board.html +165 -0
- robert_agent/web_assets/board.js +660 -0
- robert_agent/web_assets/github-shell.css +122 -0
- robert_agent/web_assets/index.html +103 -0
- robert_agent/web_assets/operations.css +168 -0
- robert_agent/web_assets/workbench.css +131 -0
- robert_agent/web_assets/workbench.js +581 -0
- robert_agent/work_items.py +1016 -0
- robert_agent/workbench.py +701 -0
- robert_agent/worker/__init__.py +1 -0
- robert_agent/worker/heartbeat.py +190 -0
- robert_agent/worker/result.py +321 -0
- robert_agent/worker/snapshot.py +98 -0
- robert_agent/worker_adapters/__init__.py +138 -0
- robert_agent/worker_adapters/cbc.py +68 -0
- robert_agent/worker_adapters/codex.py +56 -0
- robert_agent/worker_adapters/command.py +33 -0
- robert_agent/worker_adapters/tcodex.py +56 -0
- robert_agent/worker_heartbeat.py +6 -0
- robert_agent/worker_result.py +6 -0
- robert_agent/worker_snapshot.py +6 -0
- robert_agent/workstream.py +55 -0
- robert_agent/worktree.py +297 -0
- robert_github_agent-0.1.0b1.dist-info/METADATA +217 -0
- robert_github_agent-0.1.0b1.dist-info/RECORD +111 -0
- robert_github_agent-0.1.0b1.dist-info/WHEEL +4 -0
- robert_github_agent-0.1.0b1.dist-info/entry_points.txt +2 -0
- robert_github_agent-0.1.0b1.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
|
|
6
|
+
from robert_agent.paths import default_data_dir
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
PLUGIN_ID = "robert-openclaw"
|
|
10
|
+
DEFAULT_PLUGIN_DIR = (
|
|
11
|
+
default_data_dir()
|
|
12
|
+
/ "openclaw-plugin"
|
|
13
|
+
/ PLUGIN_ID
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _run(command, timeout=180):
|
|
18
|
+
return subprocess.run(
|
|
19
|
+
command,
|
|
20
|
+
text=True,
|
|
21
|
+
stdout=subprocess.PIPE,
|
|
22
|
+
stderr=subprocess.PIPE,
|
|
23
|
+
timeout=timeout,
|
|
24
|
+
check=False,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _plugin_source():
|
|
29
|
+
return '''import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
30
|
+
import { execFile } from "node:child_process";
|
|
31
|
+
import { promisify } from "node:util";
|
|
32
|
+
|
|
33
|
+
const execFileAsync = promisify(execFile);
|
|
34
|
+
|
|
35
|
+
async function runRobert(args) {
|
|
36
|
+
try {
|
|
37
|
+
const { stdout } = await execFileAsync(
|
|
38
|
+
"robert",
|
|
39
|
+
args,
|
|
40
|
+
{
|
|
41
|
+
timeout: 30000,
|
|
42
|
+
maxBuffer: 1024 * 1024,
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
const parsed = JSON.parse(stdout);
|
|
46
|
+
if (parsed?.ok === true) {
|
|
47
|
+
return { text: JSON.stringify(parsed, null, 2) };
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
text: String(parsed?.safe_error ?? "Robert command failed."),
|
|
51
|
+
isError: true,
|
|
52
|
+
};
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return {
|
|
55
|
+
text: `Robert command failed: ${error?.message ?? String(error)}`,
|
|
56
|
+
isError: true,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function splitArgs(args) {
|
|
62
|
+
return String(args ?? "").trim().split(/\\s+/).filter(Boolean);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default definePluginEntry({
|
|
66
|
+
id: "robert-openclaw",
|
|
67
|
+
name: "Robert OpenClaw Commands",
|
|
68
|
+
description: "Read-only Robert status and artifact commands.",
|
|
69
|
+
register(api) {
|
|
70
|
+
api.registerCommand({
|
|
71
|
+
name: "robert-status",
|
|
72
|
+
description: "Show Robert status.",
|
|
73
|
+
acceptsArgs: false,
|
|
74
|
+
requireAuth: true,
|
|
75
|
+
handler: async () => runRobert(["status", "--output", "json"]),
|
|
76
|
+
});
|
|
77
|
+
api.registerCommand({
|
|
78
|
+
name: "robert-task",
|
|
79
|
+
description: "Show Robert task details.",
|
|
80
|
+
acceptsArgs: true,
|
|
81
|
+
requireAuth: true,
|
|
82
|
+
handler: async (ctx) => {
|
|
83
|
+
const [taskId] = splitArgs(ctx.args);
|
|
84
|
+
if (!taskId) {
|
|
85
|
+
return { text: "Usage: /robert-task <task-id>", isError: true };
|
|
86
|
+
}
|
|
87
|
+
return runRobert(["task", "show", taskId, "--output", "json"]);
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
api.registerCommand({
|
|
91
|
+
name: "robert-run",
|
|
92
|
+
description: "Show Robert run details.",
|
|
93
|
+
acceptsArgs: true,
|
|
94
|
+
requireAuth: true,
|
|
95
|
+
handler: async (ctx) => {
|
|
96
|
+
const [runId] = splitArgs(ctx.args);
|
|
97
|
+
if (!runId) {
|
|
98
|
+
return { text: "Usage: /robert-run <run-id>", isError: true };
|
|
99
|
+
}
|
|
100
|
+
return runRobert(["run", "show", runId, "--output", "json"]);
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
api.registerCommand({
|
|
104
|
+
name: "robert-artifact",
|
|
105
|
+
description: "Show one registered Robert artifact.",
|
|
106
|
+
acceptsArgs: true,
|
|
107
|
+
requireAuth: true,
|
|
108
|
+
handler: async (ctx) => {
|
|
109
|
+
const [taskId, artifactType] = splitArgs(ctx.args);
|
|
110
|
+
if (!taskId || !artifactType) {
|
|
111
|
+
return {
|
|
112
|
+
text: "Usage: /robert-artifact <task-id> <artifact-type>",
|
|
113
|
+
isError: true,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return runRobert([
|
|
117
|
+
"artifact",
|
|
118
|
+
"show",
|
|
119
|
+
taskId,
|
|
120
|
+
artifactType,
|
|
121
|
+
"--output",
|
|
122
|
+
"json",
|
|
123
|
+
]);
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
'''
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def write_plugin(plugin_dir, force=False):
|
|
132
|
+
path = Path(plugin_dir).expanduser()
|
|
133
|
+
if path.exists():
|
|
134
|
+
if not force:
|
|
135
|
+
return {
|
|
136
|
+
"ok": False,
|
|
137
|
+
"status": "exists",
|
|
138
|
+
"plugin_dir": str(path),
|
|
139
|
+
"safe_error": f"plugin directory already exists: {path}",
|
|
140
|
+
}
|
|
141
|
+
shutil.rmtree(path)
|
|
142
|
+
path.mkdir(parents=True)
|
|
143
|
+
package = {
|
|
144
|
+
"name": "openclaw-robert-commands-local",
|
|
145
|
+
"version": "0.1.0",
|
|
146
|
+
"type": "module",
|
|
147
|
+
"private": True,
|
|
148
|
+
"openclaw": {"extensions": ["./index.js"]},
|
|
149
|
+
}
|
|
150
|
+
manifest = {
|
|
151
|
+
"id": PLUGIN_ID,
|
|
152
|
+
"name": "Robert OpenClaw Commands",
|
|
153
|
+
"description": "Read-only Robert status and artifact commands.",
|
|
154
|
+
"activation": {"onStartup": True},
|
|
155
|
+
"configSchema": {
|
|
156
|
+
"type": "object",
|
|
157
|
+
"additionalProperties": False,
|
|
158
|
+
},
|
|
159
|
+
}
|
|
160
|
+
files = {
|
|
161
|
+
"package.json": json.dumps(
|
|
162
|
+
package,
|
|
163
|
+
ensure_ascii=False,
|
|
164
|
+
indent=2,
|
|
165
|
+
sort_keys=True,
|
|
166
|
+
)
|
|
167
|
+
+ "\n",
|
|
168
|
+
"openclaw.plugin.json": json.dumps(
|
|
169
|
+
manifest,
|
|
170
|
+
ensure_ascii=False,
|
|
171
|
+
indent=2,
|
|
172
|
+
sort_keys=True,
|
|
173
|
+
)
|
|
174
|
+
+ "\n",
|
|
175
|
+
"index.js": _plugin_source(),
|
|
176
|
+
}
|
|
177
|
+
for name, content in files.items():
|
|
178
|
+
(path / name).write_text(content, encoding="utf-8")
|
|
179
|
+
return {
|
|
180
|
+
"ok": True,
|
|
181
|
+
"status": "written",
|
|
182
|
+
"plugin_dir": str(path),
|
|
183
|
+
"files": sorted(files),
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def install_plugin(plugin_dir, dry_run=False):
|
|
188
|
+
command = ["openclaw", "plugins", "install", str(plugin_dir)]
|
|
189
|
+
if dry_run:
|
|
190
|
+
return {
|
|
191
|
+
"ok": True,
|
|
192
|
+
"status": "planned",
|
|
193
|
+
"command": command,
|
|
194
|
+
}
|
|
195
|
+
completed = _run(command)
|
|
196
|
+
return {
|
|
197
|
+
"ok": completed.returncode == 0,
|
|
198
|
+
"status": (
|
|
199
|
+
"installed"
|
|
200
|
+
if completed.returncode == 0
|
|
201
|
+
else "failed"
|
|
202
|
+
),
|
|
203
|
+
"command": command,
|
|
204
|
+
"stdout": completed.stdout.strip(),
|
|
205
|
+
"safe_error": completed.stderr.strip(),
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def restart_gateway(dry_run=False):
|
|
210
|
+
command = ["openclaw", "gateway", "restart"]
|
|
211
|
+
if dry_run:
|
|
212
|
+
return {
|
|
213
|
+
"ok": True,
|
|
214
|
+
"status": "planned",
|
|
215
|
+
"command": command,
|
|
216
|
+
}
|
|
217
|
+
completed = _run(command, timeout=60)
|
|
218
|
+
return {
|
|
219
|
+
"ok": completed.returncode == 0,
|
|
220
|
+
"status": (
|
|
221
|
+
"restarted"
|
|
222
|
+
if completed.returncode == 0
|
|
223
|
+
else "failed"
|
|
224
|
+
),
|
|
225
|
+
"command": command,
|
|
226
|
+
"stdout": completed.stdout.strip(),
|
|
227
|
+
"safe_error": completed.stderr.strip(),
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def uninstall_plugin(dry_run=False):
|
|
232
|
+
command = [
|
|
233
|
+
"openclaw",
|
|
234
|
+
"plugins",
|
|
235
|
+
"uninstall",
|
|
236
|
+
PLUGIN_ID,
|
|
237
|
+
"--force",
|
|
238
|
+
]
|
|
239
|
+
if dry_run:
|
|
240
|
+
return {
|
|
241
|
+
"ok": True,
|
|
242
|
+
"status": "planned",
|
|
243
|
+
"command": command,
|
|
244
|
+
}
|
|
245
|
+
completed = _run(command)
|
|
246
|
+
return {
|
|
247
|
+
"ok": completed.returncode == 0,
|
|
248
|
+
"status": (
|
|
249
|
+
"uninstalled"
|
|
250
|
+
if completed.returncode == 0
|
|
251
|
+
else "failed"
|
|
252
|
+
),
|
|
253
|
+
"command": command,
|
|
254
|
+
"stdout": completed.stdout.strip(),
|
|
255
|
+
"safe_error": completed.stderr.strip(),
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def plugin_status(dry_run=False):
|
|
260
|
+
command = [
|
|
261
|
+
"openclaw",
|
|
262
|
+
"plugins",
|
|
263
|
+
"inspect",
|
|
264
|
+
PLUGIN_ID,
|
|
265
|
+
"--runtime",
|
|
266
|
+
"--json",
|
|
267
|
+
]
|
|
268
|
+
if dry_run:
|
|
269
|
+
return {
|
|
270
|
+
"ok": True,
|
|
271
|
+
"status": "planned",
|
|
272
|
+
"command": command,
|
|
273
|
+
}
|
|
274
|
+
completed = _run(command)
|
|
275
|
+
return {
|
|
276
|
+
"ok": completed.returncode == 0,
|
|
277
|
+
"status": (
|
|
278
|
+
"ready"
|
|
279
|
+
if completed.returncode == 0
|
|
280
|
+
else "failed"
|
|
281
|
+
),
|
|
282
|
+
"command": command,
|
|
283
|
+
"stdout": completed.stdout.strip(),
|
|
284
|
+
"safe_error": completed.stderr.strip(),
|
|
285
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import argparse
|
|
3
|
+
import subprocess
|
|
4
|
+
|
|
5
|
+
from robert_agent.common import emit
|
|
6
|
+
from robert_agent import discover
|
|
7
|
+
from robert_agent import validate_config
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _sample_events(events, limit=5):
|
|
11
|
+
samples = []
|
|
12
|
+
for event in events[:limit]:
|
|
13
|
+
samples.append(
|
|
14
|
+
{
|
|
15
|
+
"event_fingerprint": event.get("event_fingerprint"),
|
|
16
|
+
"source_key": event.get("source_key"),
|
|
17
|
+
"source_type": event.get("source_type"),
|
|
18
|
+
"event_type": event.get("event_type"),
|
|
19
|
+
"actor_login": event.get("actor_login"),
|
|
20
|
+
"mentions_dd": bool(event.get("mentions_dd")),
|
|
21
|
+
"has_open_dd_pr": bool(event.get("has_open_dd_pr")),
|
|
22
|
+
"intent": event.get("intent"),
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
return samples
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def live_discovery_acceptance(config_path, runner=subprocess.run, limit=30):
|
|
29
|
+
config = validate_config.validate_config(config_path, skip_external=True)
|
|
30
|
+
if not config["ok"]:
|
|
31
|
+
return config
|
|
32
|
+
repo = config["repos"][0]
|
|
33
|
+
try:
|
|
34
|
+
raw_events = discover.collect_live_events(repo, runner=runner, limit=limit)
|
|
35
|
+
except subprocess.CalledProcessError as exc:
|
|
36
|
+
command = exc.cmd if isinstance(exc.cmd, list) else [exc.cmd]
|
|
37
|
+
return {
|
|
38
|
+
"ok": False,
|
|
39
|
+
"status": "failed_discovery",
|
|
40
|
+
"safe_error": f"GitHub discovery command failed with exit {exc.returncode}",
|
|
41
|
+
"command": [str(part) for part in command],
|
|
42
|
+
}
|
|
43
|
+
normalized = discover.normalize_events(raw_events, repo)
|
|
44
|
+
return {
|
|
45
|
+
"ok": True,
|
|
46
|
+
"status": "completed",
|
|
47
|
+
"read_only": True,
|
|
48
|
+
"repo": repo["full_name"],
|
|
49
|
+
"github_account": repo["github_account"],
|
|
50
|
+
"raw_event_count": len(raw_events),
|
|
51
|
+
"normalized_event_count": len(normalized),
|
|
52
|
+
"sample_events": _sample_events(normalized),
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def main(argv=None):
|
|
57
|
+
parser = argparse.ArgumentParser()
|
|
58
|
+
parser.add_argument("--config", required=True)
|
|
59
|
+
parser.add_argument("--limit", type=int, default=30)
|
|
60
|
+
args = parser.parse_args(argv)
|
|
61
|
+
result = live_discovery_acceptance(args.config, limit=args.limit)
|
|
62
|
+
if result.get("ok"):
|
|
63
|
+
return emit(result, 0)
|
|
64
|
+
if result.get("status") == "failed_config":
|
|
65
|
+
return emit(result, 3)
|
|
66
|
+
return emit(result, 2)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
if __name__ == "__main__":
|
|
70
|
+
raise SystemExit(main())
|