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,138 @@
|
|
|
1
|
+
"""Plugin loader for DD GitHub worker launch adapters."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
import shlex
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass(frozen=True)
|
|
10
|
+
class WorkerLaunch:
|
|
11
|
+
agent: str
|
|
12
|
+
command: list
|
|
13
|
+
cwd: str
|
|
14
|
+
stdin_path: str
|
|
15
|
+
stdout_format: str
|
|
16
|
+
environment_allowlist: tuple[str, ...] = ()
|
|
17
|
+
timeout_seconds: int = 5400
|
|
18
|
+
|
|
19
|
+
def metadata(self):
|
|
20
|
+
return {
|
|
21
|
+
"agent": self.agent,
|
|
22
|
+
"cwd": self.cwd,
|
|
23
|
+
"stdin_path": self.stdin_path,
|
|
24
|
+
"stdout_format": self.stdout_format,
|
|
25
|
+
"environment_allowlist": list(self.environment_allowlist),
|
|
26
|
+
"timeout_seconds": self.timeout_seconds,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def available_worker_agents():
|
|
31
|
+
package_dir = Path(__file__).parent
|
|
32
|
+
return tuple(
|
|
33
|
+
sorted(
|
|
34
|
+
path.stem
|
|
35
|
+
for path in package_dir.glob("*.py")
|
|
36
|
+
if path.stem != "__init__" and not path.stem.startswith("_")
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
SUPPORTED_WORKER_AGENTS = available_worker_agents()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _split_command(command):
|
|
45
|
+
if isinstance(command, (list, tuple)):
|
|
46
|
+
parts = [str(part) for part in command if str(part).strip()]
|
|
47
|
+
else:
|
|
48
|
+
parts = shlex.split(str(command or "").strip())
|
|
49
|
+
if not parts:
|
|
50
|
+
raise ValueError("worker_command must not be empty")
|
|
51
|
+
if parts[0].startswith("~"):
|
|
52
|
+
parts[0] = str(Path(parts[0]).expanduser())
|
|
53
|
+
return parts
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _load_adapter(agent):
|
|
57
|
+
if not agent.isidentifier() or agent.startswith("_"):
|
|
58
|
+
raise ValueError(f"unsupported worker_agent: {agent}")
|
|
59
|
+
try:
|
|
60
|
+
module = import_module(f"{__name__}.{agent}")
|
|
61
|
+
except ModuleNotFoundError as exc:
|
|
62
|
+
if exc.name == f"{__name__}.{agent}":
|
|
63
|
+
raise ValueError(f"unsupported worker_agent: {agent}") from exc
|
|
64
|
+
raise
|
|
65
|
+
required = ["AGENT_NAME", "DEFAULT_COMMAND", "build_launch"]
|
|
66
|
+
missing = [name for name in required if not hasattr(module, name)]
|
|
67
|
+
if missing:
|
|
68
|
+
raise ValueError(
|
|
69
|
+
f"worker_agent {agent} adapter missing required symbols: {', '.join(missing)}"
|
|
70
|
+
)
|
|
71
|
+
if module.AGENT_NAME != agent:
|
|
72
|
+
raise ValueError(f"worker_agent adapter name mismatch: {agent} != {module.AGENT_NAME}")
|
|
73
|
+
return module
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def normalize_worker_agent_config(config):
|
|
77
|
+
config = config or {}
|
|
78
|
+
agent = str(config.get("worker_agent", config.get("agent", "cbc"))).strip().lower()
|
|
79
|
+
if not agent:
|
|
80
|
+
raise ValueError("worker_agent must not be empty")
|
|
81
|
+
adapter = _load_adapter(agent)
|
|
82
|
+
command = config.get("worker_command", config.get("command_argv", config.get("command")))
|
|
83
|
+
if command is None:
|
|
84
|
+
command = adapter.DEFAULT_COMMAND
|
|
85
|
+
if agent == "command" and not isinstance(command, (list, tuple)):
|
|
86
|
+
raise ValueError("command adapter requires command to be a YAML sequence")
|
|
87
|
+
command_argv = _split_command(command)
|
|
88
|
+
prompt_transport = str(config.get("prompt_transport", "stdin")).strip()
|
|
89
|
+
timeout_seconds = int(config.get("timeout_seconds", 5400))
|
|
90
|
+
if timeout_seconds < 1:
|
|
91
|
+
raise ValueError("timeout_seconds must be at least 1")
|
|
92
|
+
environment_allowlist = config.get("environment_allowlist", [])
|
|
93
|
+
if not isinstance(environment_allowlist, list) or any(
|
|
94
|
+
not isinstance(name, str) or not name.strip()
|
|
95
|
+
for name in environment_allowlist
|
|
96
|
+
):
|
|
97
|
+
raise ValueError("environment_allowlist must contain variable names")
|
|
98
|
+
return {
|
|
99
|
+
"agent": agent,
|
|
100
|
+
"command": " ".join(shlex.quote(part) for part in command_argv),
|
|
101
|
+
"command_argv": command_argv,
|
|
102
|
+
"prompt_transport": prompt_transport,
|
|
103
|
+
"timeout_seconds": timeout_seconds,
|
|
104
|
+
"environment_allowlist": [
|
|
105
|
+
name.strip()
|
|
106
|
+
for name in environment_allowlist
|
|
107
|
+
],
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def build_worker_launch(
|
|
112
|
+
prompt_path,
|
|
113
|
+
worktree_path=None,
|
|
114
|
+
model="gpt-5.4",
|
|
115
|
+
reasoning_effort="high",
|
|
116
|
+
worker_command=None,
|
|
117
|
+
worker_agent="cbc",
|
|
118
|
+
worker_agent_config=None,
|
|
119
|
+
):
|
|
120
|
+
prompt_path = Path(prompt_path)
|
|
121
|
+
config = normalize_worker_agent_config(
|
|
122
|
+
worker_agent_config
|
|
123
|
+
or {
|
|
124
|
+
"worker_agent": worker_agent,
|
|
125
|
+
"worker_command": worker_command,
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
adapter = _load_adapter(config["agent"])
|
|
129
|
+
return adapter.build_launch(
|
|
130
|
+
command_argv=config["command_argv"],
|
|
131
|
+
prompt_path=prompt_path,
|
|
132
|
+
worktree_path=worktree_path,
|
|
133
|
+
model=model,
|
|
134
|
+
reasoning_effort=reasoning_effort,
|
|
135
|
+
prompt_transport=config.get("prompt_transport", "stdin"),
|
|
136
|
+
environment_allowlist=config.get("environment_allowlist", []),
|
|
137
|
+
timeout_seconds=config.get("timeout_seconds", 5400),
|
|
138
|
+
)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from robert_agent.worker_adapters import WorkerLaunch
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
AGENT_NAME = "cbc"
|
|
7
|
+
DEFAULT_COMMAND = "cbc"
|
|
8
|
+
|
|
9
|
+
DEFAULT_DISALLOWED_WORKER_TOOLS = ",".join(
|
|
10
|
+
[
|
|
11
|
+
"TaskCreate",
|
|
12
|
+
"TaskGet",
|
|
13
|
+
"TaskUpdate",
|
|
14
|
+
"TaskList",
|
|
15
|
+
"TaskStop",
|
|
16
|
+
"TaskOutput",
|
|
17
|
+
"TeamCreate",
|
|
18
|
+
"TeamDelete",
|
|
19
|
+
"SkillManage",
|
|
20
|
+
"CronCreate",
|
|
21
|
+
"CronDelete",
|
|
22
|
+
"CronList",
|
|
23
|
+
"EnterWorktree",
|
|
24
|
+
"LeaveWorktree",
|
|
25
|
+
]
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def build_launch(
|
|
30
|
+
command_argv,
|
|
31
|
+
prompt_path,
|
|
32
|
+
worktree_path,
|
|
33
|
+
model,
|
|
34
|
+
reasoning_effort,
|
|
35
|
+
prompt_transport="stdin",
|
|
36
|
+
environment_allowlist=(),
|
|
37
|
+
timeout_seconds=5400,
|
|
38
|
+
):
|
|
39
|
+
command = [*command_argv, "-p"]
|
|
40
|
+
if model != "default":
|
|
41
|
+
command.extend(["--model", model])
|
|
42
|
+
if reasoning_effort != "default":
|
|
43
|
+
command.extend(["--effort", reasoning_effort])
|
|
44
|
+
command.extend(
|
|
45
|
+
[
|
|
46
|
+
"--permission-mode",
|
|
47
|
+
"bypassPermissions",
|
|
48
|
+
"--disallowedTools",
|
|
49
|
+
DEFAULT_DISALLOWED_WORKER_TOOLS,
|
|
50
|
+
"--input-format",
|
|
51
|
+
"text",
|
|
52
|
+
"--output-format",
|
|
53
|
+
"stream-json",
|
|
54
|
+
"--add-dir",
|
|
55
|
+
str(prompt_path.parent),
|
|
56
|
+
]
|
|
57
|
+
)
|
|
58
|
+
if worktree_path:
|
|
59
|
+
command.extend(["--add-dir", str(Path(worktree_path))])
|
|
60
|
+
return WorkerLaunch(
|
|
61
|
+
agent=AGENT_NAME,
|
|
62
|
+
command=command,
|
|
63
|
+
cwd=str(worktree_path or prompt_path.parent),
|
|
64
|
+
stdin_path=str(prompt_path),
|
|
65
|
+
stdout_format="stream-json",
|
|
66
|
+
environment_allowlist=tuple(environment_allowlist),
|
|
67
|
+
timeout_seconds=int(timeout_seconds),
|
|
68
|
+
)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from robert_agent.worker_adapters import WorkerLaunch
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
AGENT_NAME = "codex"
|
|
8
|
+
DEFAULT_COMMAND = "codex"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def build_launch(
|
|
12
|
+
command_argv,
|
|
13
|
+
prompt_path,
|
|
14
|
+
worktree_path,
|
|
15
|
+
model,
|
|
16
|
+
reasoning_effort,
|
|
17
|
+
prompt_transport="stdin",
|
|
18
|
+
environment_allowlist=(),
|
|
19
|
+
timeout_seconds=5400,
|
|
20
|
+
):
|
|
21
|
+
cwd = Path(worktree_path or prompt_path.parent)
|
|
22
|
+
command = [*command_argv]
|
|
23
|
+
if reasoning_effort != "default":
|
|
24
|
+
command.extend(
|
|
25
|
+
[
|
|
26
|
+
"--config",
|
|
27
|
+
f"model_reasoning_effort={json.dumps(reasoning_effort)}",
|
|
28
|
+
]
|
|
29
|
+
)
|
|
30
|
+
command.append("exec")
|
|
31
|
+
if model != "default":
|
|
32
|
+
command.extend(["--model", model])
|
|
33
|
+
command.extend(
|
|
34
|
+
[
|
|
35
|
+
"--dangerously-bypass-approvals-and-sandbox",
|
|
36
|
+
"--sandbox",
|
|
37
|
+
"danger-full-access",
|
|
38
|
+
"--json",
|
|
39
|
+
"--cd",
|
|
40
|
+
str(cwd),
|
|
41
|
+
"--add-dir",
|
|
42
|
+
str(prompt_path.parent),
|
|
43
|
+
]
|
|
44
|
+
)
|
|
45
|
+
if worktree_path:
|
|
46
|
+
command.extend(["--add-dir", str(Path(worktree_path))])
|
|
47
|
+
command.append("-")
|
|
48
|
+
return WorkerLaunch(
|
|
49
|
+
agent=AGENT_NAME,
|
|
50
|
+
command=command,
|
|
51
|
+
cwd=str(cwd),
|
|
52
|
+
stdin_path=str(prompt_path),
|
|
53
|
+
stdout_format="jsonl",
|
|
54
|
+
environment_allowlist=tuple(environment_allowlist),
|
|
55
|
+
timeout_seconds=int(timeout_seconds),
|
|
56
|
+
)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from robert_agent.worker_adapters import WorkerLaunch
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
AGENT_NAME = "command"
|
|
7
|
+
DEFAULT_COMMAND = ()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def build_launch(
|
|
11
|
+
command_argv,
|
|
12
|
+
prompt_path,
|
|
13
|
+
worktree_path,
|
|
14
|
+
model,
|
|
15
|
+
reasoning_effort,
|
|
16
|
+
prompt_transport="stdin",
|
|
17
|
+
environment_allowlist=(),
|
|
18
|
+
timeout_seconds=5400,
|
|
19
|
+
):
|
|
20
|
+
if prompt_transport != "stdin":
|
|
21
|
+
raise ValueError("command adapter supports prompt_transport=stdin only")
|
|
22
|
+
if not command_argv:
|
|
23
|
+
raise ValueError("command adapter requires a non-empty command array")
|
|
24
|
+
cwd = Path(worktree_path or Path(prompt_path).parent)
|
|
25
|
+
return WorkerLaunch(
|
|
26
|
+
agent=AGENT_NAME,
|
|
27
|
+
command=list(command_argv),
|
|
28
|
+
cwd=str(cwd),
|
|
29
|
+
stdin_path=str(prompt_path),
|
|
30
|
+
stdout_format="text",
|
|
31
|
+
environment_allowlist=tuple(environment_allowlist),
|
|
32
|
+
timeout_seconds=int(timeout_seconds),
|
|
33
|
+
)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from robert_agent.worker_adapters import WorkerLaunch
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
AGENT_NAME = "tcodex"
|
|
8
|
+
DEFAULT_COMMAND = "tcodex"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def build_launch(
|
|
12
|
+
command_argv,
|
|
13
|
+
prompt_path,
|
|
14
|
+
worktree_path,
|
|
15
|
+
model,
|
|
16
|
+
reasoning_effort,
|
|
17
|
+
prompt_transport="stdin",
|
|
18
|
+
environment_allowlist=(),
|
|
19
|
+
timeout_seconds=5400,
|
|
20
|
+
):
|
|
21
|
+
cwd = Path(worktree_path or prompt_path.parent)
|
|
22
|
+
command = [*command_argv]
|
|
23
|
+
if reasoning_effort != "default":
|
|
24
|
+
command.extend(
|
|
25
|
+
[
|
|
26
|
+
"--config",
|
|
27
|
+
f"model_reasoning_effort={json.dumps(reasoning_effort)}",
|
|
28
|
+
]
|
|
29
|
+
)
|
|
30
|
+
command.append("exec")
|
|
31
|
+
if model != "default":
|
|
32
|
+
command.extend(["--model", model])
|
|
33
|
+
command.extend(
|
|
34
|
+
[
|
|
35
|
+
"--dangerously-bypass-approvals-and-sandbox",
|
|
36
|
+
"--sandbox",
|
|
37
|
+
"danger-full-access",
|
|
38
|
+
"--json",
|
|
39
|
+
"--cd",
|
|
40
|
+
str(cwd),
|
|
41
|
+
"--add-dir",
|
|
42
|
+
str(prompt_path.parent),
|
|
43
|
+
]
|
|
44
|
+
)
|
|
45
|
+
if worktree_path:
|
|
46
|
+
command.extend(["--add-dir", str(Path(worktree_path))])
|
|
47
|
+
command.append("-")
|
|
48
|
+
return WorkerLaunch(
|
|
49
|
+
agent=AGENT_NAME,
|
|
50
|
+
command=command,
|
|
51
|
+
cwd=str(cwd),
|
|
52
|
+
stdin_path=str(prompt_path),
|
|
53
|
+
stdout_format="jsonl",
|
|
54
|
+
environment_allowlist=tuple(environment_allowlist),
|
|
55
|
+
timeout_seconds=int(timeout_seconds),
|
|
56
|
+
)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import argparse
|
|
3
|
+
import json
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
from robert_agent.common import emit
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def resolve_workstream_id(event):
|
|
10
|
+
return event.get("workstream_id") or event["source_key"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def source_relationship(event):
|
|
14
|
+
metadata = event.get("metadata") or {}
|
|
15
|
+
if (
|
|
16
|
+
event.get("source_type") == "pull_request"
|
|
17
|
+
and (event.get("origin_workstream_id") or metadata.get("dd_workstream"))
|
|
18
|
+
):
|
|
19
|
+
return "derived_pr"
|
|
20
|
+
return "primary"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def plan_event(event, active_workstreams=None):
|
|
24
|
+
active_workstreams = set(active_workstreams or [])
|
|
25
|
+
workstream_id = resolve_workstream_id(event)
|
|
26
|
+
fingerprint = event["event_fingerprint"]
|
|
27
|
+
if workstream_id in active_workstreams:
|
|
28
|
+
action = "append_pending_event"
|
|
29
|
+
pending_events = [fingerprint]
|
|
30
|
+
else:
|
|
31
|
+
action = "create_task"
|
|
32
|
+
pending_events = []
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
"ok": True,
|
|
36
|
+
"action": action,
|
|
37
|
+
"workstream_id": workstream_id,
|
|
38
|
+
"source_key": event["source_key"],
|
|
39
|
+
"source_relationship": source_relationship(event),
|
|
40
|
+
"event_fingerprint": fingerprint,
|
|
41
|
+
"pending_events": pending_events,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def main(argv=None):
|
|
46
|
+
parser = argparse.ArgumentParser()
|
|
47
|
+
parser.add_argument("--active-workstream", action="append", default=[])
|
|
48
|
+
args = parser.parse_args(argv)
|
|
49
|
+
event = json.load(sys.stdin)
|
|
50
|
+
result = plan_event(event, active_workstreams=set(args.active_workstream))
|
|
51
|
+
return emit(result)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
if __name__ == "__main__":
|
|
55
|
+
raise SystemExit(main())
|