agent-control-plane 0.1.8 → 0.1.12
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.
- package/bin/pr-risk.sh +54 -10
- package/hooks/heartbeat-hooks.sh +166 -13
- package/package.json +8 -2
- package/references/commands.md +1 -0
- package/tools/bin/agent-project-cleanup-session +143 -2
- package/tools/bin/agent-project-heartbeat-loop +29 -2
- package/tools/bin/agent-project-publish-issue-pr +178 -62
- package/tools/bin/agent-project-reconcile-issue-session +230 -5
- package/tools/bin/agent-project-reconcile-pr-session +104 -13
- package/tools/bin/agent-project-run-claude-session +19 -1
- package/tools/bin/agent-project-run-codex-resilient +121 -16
- package/tools/bin/agent-project-run-codex-session +61 -11
- package/tools/bin/agent-project-run-openclaw-session +274 -7
- package/tools/bin/agent-project-sync-anchor-repo +13 -2
- package/tools/bin/agent-project-worker-status +19 -14
- package/tools/bin/cleanup-worktree.sh +4 -1
- package/tools/bin/dashboard-launchd-bootstrap.sh +16 -4
- package/tools/bin/ensure-runtime-sync.sh +182 -0
- package/tools/bin/flow-config-lib.sh +76 -30
- package/tools/bin/flow-resident-worker-lib.sh +28 -2
- package/tools/bin/flow-shell-lib.sh +28 -8
- package/tools/bin/heartbeat-safe-auto.sh +32 -0
- package/tools/bin/issue-publish-localization-guard.sh +142 -0
- package/tools/bin/prepare-worktree.sh +3 -1
- package/tools/bin/project-launchd-bootstrap.sh +17 -4
- package/tools/bin/project-runtime-supervisor.sh +7 -1
- package/tools/bin/project-runtimectl.sh +78 -15
- package/tools/bin/provider-cooldown-state.sh +1 -1
- package/tools/bin/render-flow-config.sh +16 -1
- package/tools/bin/reuse-issue-worktree.sh +46 -0
- package/tools/bin/run-codex-task.sh +2 -2
- package/tools/bin/scaffold-profile.sh +2 -2
- package/tools/bin/start-issue-worker.sh +118 -16
- package/tools/bin/start-resident-issue-loop.sh +1 -0
- package/tools/bin/sync-shared-agent-home.sh +26 -0
- package/tools/bin/test-smoke.sh +6 -1
- package/tools/dashboard/app.js +91 -3
- package/tools/dashboard/dashboard_snapshot.py +119 -0
- package/tools/dashboard/styles.css +43 -0
- package/tools/templates/issue-prompt-template.md +18 -66
- package/tools/templates/legacy/issue-prompt-template-pre-slim.md +109 -0
- package/bin/audit-issue-routing.sh +0 -74
- package/tools/bin/audit-agent-worktrees.sh +0 -310
- package/tools/bin/audit-issue-routing.sh +0 -11
- package/tools/bin/audit-retained-layout.sh +0 -58
- package/tools/bin/audit-retained-overlap.sh +0 -135
- package/tools/bin/audit-retained-worktrees.sh +0 -228
- package/tools/bin/check-skill-contracts.sh +0 -324
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
usage() {
|
|
5
|
+
cat <<'EOF'
|
|
6
|
+
Usage:
|
|
7
|
+
issue-publish-localization-guard.sh --worktree <path> --base-ref <git-ref>
|
|
8
|
+
|
|
9
|
+
Fail fast when an issue branch updates locale resources but still leaves obvious
|
|
10
|
+
hardcoded user-facing strings in the touched UI files.
|
|
11
|
+
EOF
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
worktree=""
|
|
15
|
+
base_ref=""
|
|
16
|
+
|
|
17
|
+
while [[ $# -gt 0 ]]; do
|
|
18
|
+
case "$1" in
|
|
19
|
+
--worktree) worktree="${2:-}"; shift 2 ;;
|
|
20
|
+
--base-ref) base_ref="${2:-}"; shift 2 ;;
|
|
21
|
+
--help|-h) usage; exit 0 ;;
|
|
22
|
+
*) echo "Unknown argument: $1" >&2; usage >&2; exit 1 ;;
|
|
23
|
+
esac
|
|
24
|
+
done
|
|
25
|
+
|
|
26
|
+
if [[ -z "$worktree" || -z "$base_ref" ]]; then
|
|
27
|
+
usage >&2
|
|
28
|
+
exit 1
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
if [[ ! -d "$worktree" ]]; then
|
|
32
|
+
echo "missing worktree: $worktree" >&2
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
changed_files="$(
|
|
37
|
+
git -C "$worktree" diff --name-only --diff-filter=ACMR "${base_ref}...HEAD"
|
|
38
|
+
)"
|
|
39
|
+
|
|
40
|
+
CHANGED_FILES="${changed_files}" WORKTREE="${worktree}" node <<'EOF'
|
|
41
|
+
const fs = require('fs');
|
|
42
|
+
const path = require('path');
|
|
43
|
+
|
|
44
|
+
const changedFiles = String(process.env.CHANGED_FILES || '')
|
|
45
|
+
.split('\n')
|
|
46
|
+
.map((file) => file.trim())
|
|
47
|
+
.filter(Boolean);
|
|
48
|
+
const worktree = String(process.env.WORKTREE || '');
|
|
49
|
+
|
|
50
|
+
const localeFiles = changedFiles.filter((file) =>
|
|
51
|
+
/^packages\/i18n\/src\/resources\/[^/]+\.json$/.test(file),
|
|
52
|
+
);
|
|
53
|
+
if (localeFiles.length === 0) {
|
|
54
|
+
process.stdout.write('LOCALIZATION_GUARD_STATUS=skipped-no-locale-files\n');
|
|
55
|
+
process.exit(0);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const uiFiles = changedFiles.filter((file) =>
|
|
59
|
+
/^(?:apps\/web\/|apps\/mobile\/|packages\/ui\/).+\.[cm]?[jt]sx?$/.test(file),
|
|
60
|
+
);
|
|
61
|
+
if (uiFiles.length === 0) {
|
|
62
|
+
process.stdout.write('LOCALIZATION_GUARD_STATUS=skipped-no-ui-files\n');
|
|
63
|
+
process.exit(0);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const suspiciousPatterns = [
|
|
67
|
+
{
|
|
68
|
+
reason: 'validation_literal',
|
|
69
|
+
test: (line) =>
|
|
70
|
+
/\.(?:min|max|length|email|regex|nonempty)\([^)]*,\s*['"`][^'"`]*[A-Za-z][^'"`]*['"`]/.test(line),
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
reason: 'string_prop',
|
|
74
|
+
test: (line) =>
|
|
75
|
+
/\b(?:title|description|actionLabel|aria-label|placeholder)\s*=\s*['"][^'{"][^'"]*[A-Za-z][^'"]*['"]/.test(
|
|
76
|
+
line,
|
|
77
|
+
),
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
reason: 'object_label_literal',
|
|
81
|
+
test: (line) =>
|
|
82
|
+
/\blabel\s*:\s*['"][A-Za-z][^'"]*['"]/.test(line),
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
const ignoreLine = (line) => {
|
|
87
|
+
const trimmed = line.trim();
|
|
88
|
+
if (!trimmed) return true;
|
|
89
|
+
if (/^\s*\/\//.test(trimmed)) return true;
|
|
90
|
+
if (/\bt\(/.test(trimmed)) return true;
|
|
91
|
+
if (/\buseSafeTranslation\b|\buseTranslation\b|\bi18nKey=/.test(trimmed)) return true;
|
|
92
|
+
if (/^import\s/.test(trimmed)) return true;
|
|
93
|
+
return false;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const findings = [];
|
|
97
|
+
for (const relativeFile of uiFiles) {
|
|
98
|
+
const absoluteFile = path.join(worktree, relativeFile);
|
|
99
|
+
if (!fs.existsSync(absoluteFile)) continue;
|
|
100
|
+
const lines = fs.readFileSync(absoluteFile, 'utf8').split(/\r?\n/);
|
|
101
|
+
lines.forEach((line, index) => {
|
|
102
|
+
if (ignoreLine(line)) return;
|
|
103
|
+
for (const pattern of suspiciousPatterns) {
|
|
104
|
+
if (pattern.test(line)) {
|
|
105
|
+
findings.push({
|
|
106
|
+
file: relativeFile,
|
|
107
|
+
line: index + 1,
|
|
108
|
+
reason: pattern.reason,
|
|
109
|
+
text: line.trim(),
|
|
110
|
+
});
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (findings.length === 0) {
|
|
118
|
+
process.stdout.write('LOCALIZATION_GUARD_STATUS=ok\n');
|
|
119
|
+
process.stdout.write(`LOCALE_RESOURCE_COUNT=${localeFiles.length}\n`);
|
|
120
|
+
process.stdout.write(`UI_FILE_COUNT=${uiFiles.length}\n`);
|
|
121
|
+
process.exit(0);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const lines = [
|
|
125
|
+
'Localization guard blocked branch publication.',
|
|
126
|
+
'',
|
|
127
|
+
'The branch updates locale resources but still leaves obvious hardcoded user-facing strings in touched UI files.',
|
|
128
|
+
'',
|
|
129
|
+
'Why it was blocked:',
|
|
130
|
+
];
|
|
131
|
+
for (const finding of findings.slice(0, 20)) {
|
|
132
|
+
lines.push(`- ${finding.reason}: ${finding.file}:${finding.line} -> ${finding.text}`);
|
|
133
|
+
}
|
|
134
|
+
lines.push(
|
|
135
|
+
'',
|
|
136
|
+
'Required next step:',
|
|
137
|
+
'- move the remaining user-facing literals behind translation keys before publishing this issue branch',
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
process.stderr.write(`${lines.join('\n')}\n`);
|
|
141
|
+
process.exit(44);
|
|
142
|
+
EOF
|
|
@@ -119,7 +119,9 @@ mkdir -p "$WORKTREE/.openclaw-artifacts"
|
|
|
119
119
|
configure_worktree_excludes "$WORKTREE"
|
|
120
120
|
|
|
121
121
|
if [[ -x "$SYNC_DEPENDENCY_BASELINE_SCRIPT" && "$DEPENDENCY_REAL" == "$CANONICAL_REAL" ]]; then
|
|
122
|
-
|
|
122
|
+
# Sync dependency baseline is non-fatal — worker can function without it
|
|
123
|
+
# (especially for repos with zero dependencies or external volume issues)
|
|
124
|
+
"$SYNC_DEPENDENCY_BASELINE_SCRIPT" >/dev/null 2>&1 || true
|
|
123
125
|
fi
|
|
124
126
|
|
|
125
127
|
if [[ "$LOCAL_WORKSPACE_INSTALL" == "true" ]]; then
|
|
@@ -4,13 +4,14 @@ set -euo pipefail
|
|
|
4
4
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
5
|
FLOW_SKILL_DIR="$(cd "${SCRIPT_DIR}/../.." && pwd)"
|
|
6
6
|
HOME_DIR="${ACP_PROJECT_RUNTIME_HOME_DIR:-${HOME:-}}"
|
|
7
|
-
SOURCE_HOME="${ACP_PROJECT_RUNTIME_SOURCE_HOME
|
|
7
|
+
SOURCE_HOME="${ACP_PROJECT_RUNTIME_SOURCE_HOME:-}"
|
|
8
8
|
RUNTIME_HOME="${ACP_PROJECT_RUNTIME_RUNTIME_HOME:-${HOME_DIR}/.agent-runtime/runtime-home}"
|
|
9
9
|
PROFILE_REGISTRY_ROOT="${ACP_PROJECT_RUNTIME_PROFILE_REGISTRY_ROOT:-${ACP_PROFILE_REGISTRY_ROOT:-${HOME_DIR}/.agent-runtime/control-plane/profiles}}"
|
|
10
10
|
PROFILE_ID="${ACP_PROJECT_RUNTIME_PROFILE_ID:-${ACP_PROJECT_ID:-${AGENT_PROJECT_ID:-}}}"
|
|
11
11
|
ENV_FILE="${ACP_PROJECT_RUNTIME_ENV_FILE:-${PROFILE_REGISTRY_ROOT}/${PROFILE_ID}/runtime.env}"
|
|
12
12
|
BASE_PATH="${ACP_PROJECT_RUNTIME_PATH:-/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin}"
|
|
13
13
|
SYNC_SCRIPT="${ACP_PROJECT_RUNTIME_SYNC_SCRIPT:-${FLOW_SKILL_DIR}/tools/bin/sync-shared-agent-home.sh}"
|
|
14
|
+
ENSURE_SYNC_SCRIPT="${ACP_PROJECT_RUNTIME_ENSURE_SYNC_SCRIPT:-${FLOW_SKILL_DIR}/tools/bin/ensure-runtime-sync.sh}"
|
|
14
15
|
RUNTIME_HEARTBEAT_SCRIPT="${ACP_PROJECT_RUNTIME_HEARTBEAT_SCRIPT:-${RUNTIME_HOME}/skills/openclaw/agent-control-plane/tools/bin/heartbeat-safe-auto.sh}"
|
|
15
16
|
ALWAYS_SYNC="${ACP_PROJECT_RUNTIME_ALWAYS_SYNC:-0}"
|
|
16
17
|
|
|
@@ -37,12 +38,24 @@ if [[ -f "${ENV_FILE}" ]]; then
|
|
|
37
38
|
set +a
|
|
38
39
|
fi
|
|
39
40
|
|
|
40
|
-
if [[ ! -x "${SYNC_SCRIPT}" ]]; then
|
|
41
|
-
echo "project launchd bootstrap missing sync
|
|
41
|
+
if [[ ! -x "${ENSURE_SYNC_SCRIPT}" && ! -x "${SYNC_SCRIPT}" ]]; then
|
|
42
|
+
echo "project launchd bootstrap missing sync helper: ${ENSURE_SYNC_SCRIPT}" >&2
|
|
42
43
|
exit 65
|
|
43
44
|
fi
|
|
44
45
|
|
|
45
|
-
if [[
|
|
46
|
+
if [[ -x "${ENSURE_SYNC_SCRIPT}" ]]; then
|
|
47
|
+
ensure_args=(--runtime-home "${RUNTIME_HOME}" --quiet)
|
|
48
|
+
if [[ -n "${SOURCE_HOME}" ]]; then
|
|
49
|
+
ensure_args=(--source-home "${SOURCE_HOME}" "${ensure_args[@]}")
|
|
50
|
+
fi
|
|
51
|
+
if [[ "${ALWAYS_SYNC}" == "1" ]]; then
|
|
52
|
+
ensure_args=(--force "${ensure_args[@]}")
|
|
53
|
+
fi
|
|
54
|
+
bash "${ENSURE_SYNC_SCRIPT}" "${ensure_args[@]}"
|
|
55
|
+
elif [[ "${ALWAYS_SYNC}" == "1" || ! -x "${RUNTIME_HEARTBEAT_SCRIPT}" ]]; then
|
|
56
|
+
if [[ -z "${SOURCE_HOME}" ]]; then
|
|
57
|
+
SOURCE_HOME="${FLOW_SKILL_DIR}"
|
|
58
|
+
fi
|
|
46
59
|
bash "${SYNC_SCRIPT}" "${SOURCE_HOME}" "${RUNTIME_HOME}" >/dev/null
|
|
47
60
|
fi
|
|
48
61
|
|
|
@@ -47,10 +47,16 @@ trap '' HUP
|
|
|
47
47
|
|
|
48
48
|
first_pass="1"
|
|
49
49
|
while true; do
|
|
50
|
+
printf '[%s] supervisor bootstrap start pid=%s script=%s\n' "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" "$$" "${bootstrap_script}" >&2
|
|
50
51
|
if [[ "${first_pass}" == "1" && "${delay_seconds}" != "0" ]]; then
|
|
51
52
|
sleep "${delay_seconds}"
|
|
52
53
|
fi
|
|
53
54
|
first_pass="0"
|
|
54
|
-
"${bootstrap_script}"
|
|
55
|
+
if "${bootstrap_script}"; then
|
|
56
|
+
printf '[%s] supervisor bootstrap end status=0 pid=%s\n' "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" "$$" >&2
|
|
57
|
+
else
|
|
58
|
+
bootstrap_status=$?
|
|
59
|
+
printf '[%s] supervisor bootstrap end status=%s pid=%s\n' "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" "${bootstrap_status}" "$$" >&2
|
|
60
|
+
fi
|
|
55
61
|
sleep "${interval_seconds}"
|
|
56
62
|
done
|
|
@@ -8,7 +8,7 @@ source "${SCRIPT_DIR}/flow-config-lib.sh"
|
|
|
8
8
|
usage() {
|
|
9
9
|
cat <<'EOF'
|
|
10
10
|
Usage:
|
|
11
|
-
project-runtimectl.sh <status|start|stop|restart> --profile-id <id> [options]
|
|
11
|
+
project-runtimectl.sh <status|start|stop|restart|sync> --profile-id <id> [options]
|
|
12
12
|
|
|
13
13
|
Manage runtime processes for one installed profile.
|
|
14
14
|
|
|
@@ -16,6 +16,7 @@ Options:
|
|
|
16
16
|
--profile-id <id> Profile id to manage
|
|
17
17
|
--delay-seconds <n> Delay for start via kick-scheduler (default: 0)
|
|
18
18
|
--wait-seconds <n> Wait for stop to settle before SIGKILL (default: 10)
|
|
19
|
+
--force Force a runtime sync refresh when using `sync`
|
|
19
20
|
--help Show this help
|
|
20
21
|
EOF
|
|
21
22
|
}
|
|
@@ -30,19 +31,21 @@ shift || true
|
|
|
30
31
|
profile_id_override=""
|
|
31
32
|
delay_seconds="0"
|
|
32
33
|
wait_seconds="10"
|
|
34
|
+
force_sync="0"
|
|
33
35
|
|
|
34
36
|
while [[ $# -gt 0 ]]; do
|
|
35
37
|
case "$1" in
|
|
36
38
|
--profile-id) profile_id_override="${2:-}"; shift 2 ;;
|
|
37
39
|
--delay-seconds) delay_seconds="${2:-}"; shift 2 ;;
|
|
38
40
|
--wait-seconds) wait_seconds="${2:-}"; shift 2 ;;
|
|
41
|
+
--force) force_sync="1"; shift ;;
|
|
39
42
|
--help|-h) usage; exit 0 ;;
|
|
40
43
|
*) echo "Unknown argument: $1" >&2; usage >&2; exit 64 ;;
|
|
41
44
|
esac
|
|
42
45
|
done
|
|
43
46
|
|
|
44
47
|
case "${subcommand}" in
|
|
45
|
-
status|start|stop|restart) ;;
|
|
48
|
+
status|start|stop|restart|sync) ;;
|
|
46
49
|
*)
|
|
47
50
|
echo "Unknown subcommand: ${subcommand}" >&2
|
|
48
51
|
usage >&2
|
|
@@ -92,16 +95,21 @@ REPO_SLUG="$(flow_resolve_repo_slug "${CONFIG_YAML}")"
|
|
|
92
95
|
RUNS_ROOT="$(flow_resolve_runs_root "${CONFIG_YAML}")"
|
|
93
96
|
STATE_ROOT="$(flow_resolve_state_root "${CONFIG_YAML}")"
|
|
94
97
|
SUPERVISOR_PID_FILE="${STATE_ROOT}/runtime-supervisor.pid"
|
|
98
|
+
SUPERVISOR_LOG_FILE="${STATE_ROOT}/runtime-supervisor.log"
|
|
95
99
|
PROFILE_ID_SLUG="$(printf '%s' "${PROFILE_ID}" | tr -c 'A-Za-z0-9._-' '-')"
|
|
96
100
|
BOOTSTRAP_SCRIPT="${ACP_PROJECT_RUNTIME_BOOTSTRAP_SCRIPT:-${FLOW_SKILL_DIR}/tools/bin/project-launchd-bootstrap.sh}"
|
|
97
101
|
KICK_SCRIPT="${ACP_PROJECT_RUNTIME_KICK_SCRIPT:-${FLOW_SKILL_DIR}/tools/bin/kick-scheduler.sh}"
|
|
98
102
|
SUPERVISOR_SCRIPT="${ACP_PROJECT_RUNTIME_SUPERVISOR_SCRIPT:-${FLOW_SKILL_DIR}/tools/bin/project-runtime-supervisor.sh}"
|
|
103
|
+
ENSURE_SYNC_SCRIPT="${ACP_PROJECT_RUNTIME_ENSURE_SYNC_SCRIPT:-${FLOW_SKILL_DIR}/tools/bin/ensure-runtime-sync.sh}"
|
|
99
104
|
UPDATE_LABELS_SCRIPT="${ACP_PROJECT_RUNTIME_UPDATE_LABELS_SCRIPT:-${FLOW_SKILL_DIR}/tools/bin/agent-github-update-labels}"
|
|
100
105
|
TMUX_BIN="${ACP_PROJECT_RUNTIME_TMUX_BIN:-$(command -v tmux || true)}"
|
|
101
106
|
LAUNCHCTL_BIN="${ACP_PROJECT_RUNTIME_LAUNCHCTL_BIN:-$(command -v launchctl || true)}"
|
|
102
107
|
LAUNCH_AGENTS_DIR="${ACP_PROJECT_RUNTIME_LAUNCH_AGENTS_DIR:-${HOME}/Library/LaunchAgents}"
|
|
103
108
|
LAUNCHD_LABEL="${ACP_PROJECT_RUNTIME_LAUNCHD_LABEL:-ai.agent.project.${PROFILE_ID_SLUG}}"
|
|
104
109
|
LAUNCHD_PLIST="${ACP_PROJECT_RUNTIME_LAUNCHD_PLIST:-${LAUNCH_AGENTS_DIR}/${LAUNCHD_LABEL}.plist}"
|
|
110
|
+
SOURCE_HOME="${ACP_PROJECT_RUNTIME_SOURCE_HOME:-}"
|
|
111
|
+
RUNTIME_HOME="${ACP_PROJECT_RUNTIME_RUNTIME_HOME:-$(resolve_runtime_home)}"
|
|
112
|
+
SYNC_STAMP_FILE="${RUNTIME_HOME}/.agent-control-plane-runtime-sync.env"
|
|
105
113
|
|
|
106
114
|
case "${delay_seconds}" in
|
|
107
115
|
''|*[!0-9]*) echo "--delay-seconds must be numeric" >&2; exit 64 ;;
|
|
@@ -160,17 +168,13 @@ join_by_comma() {
|
|
|
160
168
|
runtime_started() {
|
|
161
169
|
local heartbeat=""
|
|
162
170
|
local shared_loop=""
|
|
163
|
-
local controller_pid=""
|
|
164
|
-
local active_session=""
|
|
165
171
|
local supervisor=""
|
|
166
172
|
|
|
167
173
|
heartbeat="$(heartbeat_pid)"
|
|
168
174
|
shared_loop="$(shared_loop_pid)"
|
|
169
|
-
controller_pid="$(collect_controller_pids | head -n 1 || true)"
|
|
170
|
-
active_session="$(collect_active_tmux_sessions | head -n 1 || true)"
|
|
171
175
|
supervisor="$(supervisor_pid)"
|
|
172
176
|
|
|
173
|
-
[[ -n "${heartbeat}" || -n "${shared_loop}" || -n "${
|
|
177
|
+
[[ -n "${heartbeat}" || -n "${shared_loop}" || -n "${supervisor}" ]]
|
|
174
178
|
}
|
|
175
179
|
|
|
176
180
|
wait_for_runtime_start() {
|
|
@@ -186,6 +190,13 @@ wait_for_runtime_start() {
|
|
|
186
190
|
return 1
|
|
187
191
|
}
|
|
188
192
|
|
|
193
|
+
sync_stamp_value() {
|
|
194
|
+
local key="${1:?key required}"
|
|
195
|
+
[[ -f "${SYNC_STAMP_FILE}" ]] || return 1
|
|
196
|
+
awk -F= -v target="${key}" '$1 == target {print $2; exit}' "${SYNC_STAMP_FILE}" 2>/dev/null \
|
|
197
|
+
| sed -e "s/^'//" -e "s/'$//"
|
|
198
|
+
}
|
|
199
|
+
|
|
189
200
|
tmux_session_exists() {
|
|
190
201
|
local session="${1:-}"
|
|
191
202
|
[[ -n "${TMUX_BIN}" && -n "${session}" ]] || return 1
|
|
@@ -331,6 +342,9 @@ print_status() {
|
|
|
331
342
|
local active_session_count="0"
|
|
332
343
|
local pending_count="0"
|
|
333
344
|
local launchd_state=""
|
|
345
|
+
local runtime_sync_status=""
|
|
346
|
+
local runtime_sync_updated_at=""
|
|
347
|
+
local runtime_sync_fingerprint=""
|
|
334
348
|
|
|
335
349
|
heartbeat="$(heartbeat_pid)"
|
|
336
350
|
shared_loop="$(shared_loop_pid)"
|
|
@@ -352,6 +366,9 @@ print_status() {
|
|
|
352
366
|
fi
|
|
353
367
|
|
|
354
368
|
launchd_state="$(launchd_service_state)"
|
|
369
|
+
runtime_sync_status="$(sync_stamp_value "SYNC_STATUS" || true)"
|
|
370
|
+
runtime_sync_updated_at="$(sync_stamp_value "UPDATED_AT" || true)"
|
|
371
|
+
runtime_sync_fingerprint="$(sync_stamp_value "SOURCE_FINGERPRINT" || true)"
|
|
355
372
|
|
|
356
373
|
printf 'PROFILE_ID=%s\n' "${PROFILE_ID}"
|
|
357
374
|
printf 'CONFIG_YAML=%s\n' "${CONFIG_YAML}"
|
|
@@ -372,6 +389,10 @@ print_status() {
|
|
|
372
389
|
printf 'CONTROLLER_PIDS=%s\n' "$(printf '%s\n' "${controller_pids}" | join_by_comma)"
|
|
373
390
|
printf 'ACTIVE_TMUX_SESSIONS=%s\n' "$(printf '%s\n' "${active_sessions}" | join_by_comma)"
|
|
374
391
|
printf 'PENDING_LAUNCH_PIDS=%s\n' "$(printf '%s\n' "${pending_pids}" | join_by_comma)"
|
|
392
|
+
printf 'SYNC_STAMP_FILE=%s\n' "${SYNC_STAMP_FILE}"
|
|
393
|
+
printf 'RUNTIME_SYNC_STATUS=%s\n' "${runtime_sync_status}"
|
|
394
|
+
printf 'RUNTIME_SYNC_UPDATED_AT=%s\n' "${runtime_sync_updated_at}"
|
|
395
|
+
printf 'RUNTIME_SYNC_FINGERPRINT=%s\n' "${runtime_sync_fingerprint}"
|
|
375
396
|
}
|
|
376
397
|
|
|
377
398
|
terminate_pid_list() {
|
|
@@ -499,6 +520,7 @@ stop_runtime() {
|
|
|
499
520
|
start_runtime() {
|
|
500
521
|
local kick_output=""
|
|
501
522
|
local fallback_pid=""
|
|
523
|
+
local fallback_log_file="${SUPERVISOR_LOG_FILE}"
|
|
502
524
|
local start_timeout="${ACP_PROJECT_RUNTIME_START_WAIT_SECONDS:-${wait_seconds}}"
|
|
503
525
|
local runtime_started_after_kick="0"
|
|
504
526
|
local supervisor_spawned="0"
|
|
@@ -537,14 +559,26 @@ start_runtime() {
|
|
|
537
559
|
|
|
538
560
|
if [[ "${runtime_started_after_kick}" != "1" && -z "$(supervisor_pid)" ]]; then
|
|
539
561
|
mkdir -p "${STATE_ROOT}"
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
562
|
+
: >"${fallback_log_file}"
|
|
563
|
+
if command -v setsid >/dev/null 2>&1; then
|
|
564
|
+
setsid env ACP_PROJECT_ID="${PROFILE_ID}" AGENT_PROJECT_ID="${PROFILE_ID}" \
|
|
565
|
+
bash "${SUPERVISOR_SCRIPT}" \
|
|
566
|
+
--bootstrap-script "${BOOTSTRAP_SCRIPT}" \
|
|
567
|
+
--pid-file "${SUPERVISOR_PID_FILE}" \
|
|
568
|
+
--delay-seconds "${delay_seconds}" \
|
|
569
|
+
--interval-seconds "${ACP_PROJECT_RUNTIME_SUPERVISOR_INTERVAL_SECONDS:-15}" \
|
|
570
|
+
</dev/null >>"${fallback_log_file}" 2>&1 &
|
|
571
|
+
fallback_pid="$!"
|
|
572
|
+
else
|
|
573
|
+
nohup env ACP_PROJECT_ID="${PROFILE_ID}" AGENT_PROJECT_ID="${PROFILE_ID}" \
|
|
574
|
+
bash "${SUPERVISOR_SCRIPT}" \
|
|
575
|
+
--bootstrap-script "${BOOTSTRAP_SCRIPT}" \
|
|
576
|
+
--pid-file "${SUPERVISOR_PID_FILE}" \
|
|
577
|
+
--delay-seconds "${delay_seconds}" \
|
|
578
|
+
--interval-seconds "${ACP_PROJECT_RUNTIME_SUPERVISOR_INTERVAL_SECONDS:-15}" \
|
|
579
|
+
</dev/null >>"${fallback_log_file}" 2>&1 &
|
|
580
|
+
fallback_pid="$!"
|
|
581
|
+
fi
|
|
548
582
|
supervisor_spawned="1"
|
|
549
583
|
wait_for_runtime_start "${start_timeout}" || true
|
|
550
584
|
fi
|
|
@@ -563,9 +597,35 @@ start_runtime() {
|
|
|
563
597
|
printf '%s\n' "${kick_output}"
|
|
564
598
|
if [[ -n "${fallback_pid}" ]]; then
|
|
565
599
|
printf 'FALLBACK_SUPERVISOR_PID=%s\n' "${fallback_pid}"
|
|
600
|
+
printf 'FALLBACK_SUPERVISOR_LOG=%s\n' "${fallback_log_file}"
|
|
566
601
|
fi
|
|
567
602
|
}
|
|
568
603
|
|
|
604
|
+
sync_runtime() {
|
|
605
|
+
local ensure_output=""
|
|
606
|
+
local ensure_args=()
|
|
607
|
+
|
|
608
|
+
if [[ ! -x "${ENSURE_SYNC_SCRIPT}" ]]; then
|
|
609
|
+
echo "missing runtime sync helper: ${ENSURE_SYNC_SCRIPT}" >&2
|
|
610
|
+
exit 65
|
|
611
|
+
fi
|
|
612
|
+
|
|
613
|
+
ensure_args=(--runtime-home "${RUNTIME_HOME}")
|
|
614
|
+
if [[ -n "${SOURCE_HOME}" ]]; then
|
|
615
|
+
ensure_args=(--source-home "${SOURCE_HOME}" "${ensure_args[@]}")
|
|
616
|
+
fi
|
|
617
|
+
if [[ "${force_sync}" == "1" ]]; then
|
|
618
|
+
ensure_args=(--force "${ensure_args[@]}")
|
|
619
|
+
ensure_output="$(bash "${ENSURE_SYNC_SCRIPT}" "${ensure_args[@]}")"
|
|
620
|
+
else
|
|
621
|
+
ensure_output="$(bash "${ENSURE_SYNC_SCRIPT}" "${ensure_args[@]}")"
|
|
622
|
+
fi
|
|
623
|
+
|
|
624
|
+
printf 'ACTION=sync\n'
|
|
625
|
+
printf 'PROFILE_ID=%s\n' "${PROFILE_ID}"
|
|
626
|
+
printf '%s\n' "${ensure_output}"
|
|
627
|
+
}
|
|
628
|
+
|
|
569
629
|
case "${subcommand}" in
|
|
570
630
|
status)
|
|
571
631
|
print_status
|
|
@@ -583,4 +643,7 @@ case "${subcommand}" in
|
|
|
583
643
|
start_runtime
|
|
584
644
|
print_status
|
|
585
645
|
;;
|
|
646
|
+
sync)
|
|
647
|
+
sync_runtime
|
|
648
|
+
;;
|
|
586
649
|
esac
|
|
@@ -12,7 +12,7 @@ Usage:
|
|
|
12
12
|
|
|
13
13
|
Examples:
|
|
14
14
|
provider-cooldown-state.sh get
|
|
15
|
-
provider-cooldown-state.sh openclaw openrouter/
|
|
15
|
+
provider-cooldown-state.sh openclaw openrouter/qwen/qwen3.6-plus-preview:free schedule provider-quota-limit
|
|
16
16
|
EOF
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -8,7 +8,22 @@ source "${SCRIPT_DIR}/flow-config-lib.sh"
|
|
|
8
8
|
FLOW_SKILL_DIR="$(resolve_flow_skill_dir "${BASH_SOURCE[0]}")"
|
|
9
9
|
PROFILE_REGISTRY_ROOT="$(resolve_flow_profile_registry_root)"
|
|
10
10
|
CONFIG_YAML="$(resolve_flow_config_yaml "${BASH_SOURCE[0]}")"
|
|
11
|
-
|
|
11
|
+
# Do NOT export execution env for the current profile here — render-flow-config
|
|
12
|
+
# is meant to render the SELECTED profile's config (via CONFIG_YAML), and exporting
|
|
13
|
+
# the ambient profile's vars into the shell causes config_or_env to silently override
|
|
14
|
+
# per-profile YAML with defaults from the current resident worker's own config.
|
|
15
|
+
# Also, ambient env vars from the shell are cleared below so they don't leak into
|
|
16
|
+
# profile-smoke or other callers.
|
|
17
|
+
for _clean in ACP_CODING_WORKER ACP_OPENCLAW_MODEL ACP_CLAUDE_MODEL \
|
|
18
|
+
ACP_CLAUDE_TIMEOUT_SECONDS ACP_CLAUDE_MAX_ATTEMPTS ACP_CLAUDE_RETRY_BACKOFF_SECONDS \
|
|
19
|
+
ACP_OPENCLAW_THINKING ACP_OPENCLAW_TIMEOUT_SECONDS \
|
|
20
|
+
F_LOSNING_CODING_WORKER F_LOSNING_OPENCLAW_MODEL F_LOSNING_CLAUDE_MODEL \
|
|
21
|
+
F_LOSNING_CLAUDE_TIMEOUT_SECONDS F_LOSNING_CLAUDE_MAX_ATTEMPTS F_LOSNING_CLAUDE_RETRY_BACKOFF_SECONDS \
|
|
22
|
+
F_LOSNING_OPENCLAW_THINKING F_LOSNING_OPENCLAW_TIMEOUT_SECONDS \
|
|
23
|
+
CODING_WORKER; do
|
|
24
|
+
unset "${_clean}" 2>/dev/null || true
|
|
25
|
+
done
|
|
26
|
+
unset _clean
|
|
12
27
|
AVAILABLE_PROFILES="$(flow_list_profile_ids "${FLOW_SKILL_DIR}" | paste -sd, -)"
|
|
13
28
|
INSTALLED_PROFILES="$(flow_list_installed_profile_ids | paste -sd, -)"
|
|
14
29
|
PROFILE_ID="$(flow_resolve_adapter_id "${CONFIG_YAML}")"
|
|
@@ -31,6 +31,7 @@ fi
|
|
|
31
31
|
|
|
32
32
|
CONFIG_YAML="$(resolve_flow_config_yaml "${BASH_SOURCE[0]}")"
|
|
33
33
|
AGENT_REPO_ROOT="$(flow_resolve_agent_repo_root "${CONFIG_YAML}")"
|
|
34
|
+
WORKTREE_ROOT="$(flow_resolve_worktree_root "${CONFIG_YAML}")"
|
|
34
35
|
ISSUE_BRANCH_PREFIX="$(flow_resolve_issue_branch_prefix "${CONFIG_YAML}")"
|
|
35
36
|
DEFAULT_BRANCH="$(flow_resolve_default_branch "${CONFIG_YAML}")"
|
|
36
37
|
BASE_REF="origin/${DEFAULT_BRANCH}"
|
|
@@ -46,6 +47,9 @@ fi
|
|
|
46
47
|
stamp="$(date +%Y%m%d-%H%M%S)"
|
|
47
48
|
branch_name="${ISSUE_BRANCH_PREFIX}-${ISSUE_ID}-${safe_slug}-${stamp}"
|
|
48
49
|
previous_branch="$(git -C "${WORKTREE}" branch --show-current 2>/dev/null || true)"
|
|
50
|
+
resolved_worktree=""
|
|
51
|
+
actual_branch=""
|
|
52
|
+
rotated_worktree=""
|
|
49
53
|
|
|
50
54
|
if ! git -C "${WORKTREE}" rev-parse --git-dir >/dev/null 2>&1; then
|
|
51
55
|
echo "invalid managed worktree: ${WORKTREE}" >&2
|
|
@@ -69,6 +73,48 @@ fi
|
|
|
69
73
|
|
|
70
74
|
"${PREPARE_SCRIPT}" "${WORKTREE}" >/dev/null
|
|
71
75
|
|
|
76
|
+
if ! git -C "${WORKTREE}" rev-parse --git-dir >/dev/null 2>&1; then
|
|
77
|
+
echo "invalid managed worktree after reuse: ${WORKTREE}" >&2
|
|
78
|
+
exit 1
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
resolved_worktree="$(cd "${WORKTREE}" 2>/dev/null && pwd -P || true)"
|
|
82
|
+
if [[ -z "${resolved_worktree}" || ! -d "${resolved_worktree}" ]]; then
|
|
83
|
+
echo "reused worktree path is unavailable: ${WORKTREE}" >&2
|
|
84
|
+
exit 1
|
|
85
|
+
fi
|
|
86
|
+
WORKTREE="${resolved_worktree}"
|
|
87
|
+
|
|
88
|
+
if [[ -n "${WORKTREE_ROOT}" ]]; then
|
|
89
|
+
mkdir -p "${WORKTREE_ROOT}"
|
|
90
|
+
rotated_worktree="${WORKTREE_ROOT}/issue-${ISSUE_ID}-${stamp}"
|
|
91
|
+
if [[ "${resolved_worktree}" != "${rotated_worktree}" ]]; then
|
|
92
|
+
if [[ -e "${rotated_worktree}" ]]; then
|
|
93
|
+
echo "rotated worktree path already exists: ${rotated_worktree}" >&2
|
|
94
|
+
exit 1
|
|
95
|
+
fi
|
|
96
|
+
git -C "${AGENT_REPO_ROOT}" worktree move "${resolved_worktree}" "${rotated_worktree}" >/dev/null
|
|
97
|
+
WORKTREE="${rotated_worktree}"
|
|
98
|
+
resolved_worktree="$(cd "${WORKTREE}" 2>/dev/null && pwd -P || true)"
|
|
99
|
+
if [[ -z "${resolved_worktree}" || ! -d "${resolved_worktree}" ]]; then
|
|
100
|
+
echo "rotated worktree path is unavailable: ${WORKTREE}" >&2
|
|
101
|
+
exit 1
|
|
102
|
+
fi
|
|
103
|
+
WORKTREE="${resolved_worktree}"
|
|
104
|
+
fi
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
if ! git -C "${AGENT_REPO_ROOT}" worktree list --porcelain | grep -Fqx "worktree ${resolved_worktree}"; then
|
|
108
|
+
echo "reused worktree is no longer registered: ${resolved_worktree}" >&2
|
|
109
|
+
exit 1
|
|
110
|
+
fi
|
|
111
|
+
|
|
112
|
+
actual_branch="$(git -C "${WORKTREE}" branch --show-current 2>/dev/null || true)"
|
|
113
|
+
if [[ -z "${actual_branch}" || "${actual_branch}" != "${branch_name}" ]]; then
|
|
114
|
+
echo "reused worktree branch mismatch: expected ${branch_name} got ${actual_branch:-<none>}" >&2
|
|
115
|
+
exit 1
|
|
116
|
+
fi
|
|
117
|
+
|
|
72
118
|
printf 'WORKTREE=%s\n' "${WORKTREE}"
|
|
73
119
|
printf 'BRANCH=%s\n' "${branch_name}"
|
|
74
120
|
printf 'BASE_REF=%s\n' "${BASE_REF}"
|
|
@@ -61,8 +61,8 @@ RESIDENT_OPENCLAW_AGENT_DIR="${ACP_RESIDENT_OPENCLAW_AGENT_DIR:-${F_LOSNING_RESI
|
|
|
61
61
|
RESIDENT_OPENCLAW_STATE_DIR="${ACP_RESIDENT_OPENCLAW_STATE_DIR:-${F_LOSNING_RESIDENT_OPENCLAW_STATE_DIR:-}}"
|
|
62
62
|
RESIDENT_OPENCLAW_CONFIG_PATH="${ACP_RESIDENT_OPENCLAW_CONFIG_PATH:-${F_LOSNING_RESIDENT_OPENCLAW_CONFIG_PATH:-}}"
|
|
63
63
|
# Set defaults if not set from yaml or env
|
|
64
|
-
OPENCLAW_MODEL="${OPENCLAW_MODEL:-${ACP_OPENCLAW_MODEL:-${F_LOSNING_OPENCLAW_MODEL:-openrouter/
|
|
65
|
-
OPENCLAW_THINKING="${OPENCLAW_THINKING:-${ACP_OPENCLAW_THINKING:-${F_LOSNING_OPENCLAW_THINKING:-
|
|
64
|
+
OPENCLAW_MODEL="${OPENCLAW_MODEL:-${ACP_OPENCLAW_MODEL:-${F_LOSNING_OPENCLAW_MODEL:-openrouter/qwen/qwen3.6-plus-preview:free}}}"
|
|
65
|
+
OPENCLAW_THINKING="${OPENCLAW_THINKING:-${ACP_OPENCLAW_THINKING:-${F_LOSNING_OPENCLAW_THINKING:-low}}}"
|
|
66
66
|
OPENCLAW_TIMEOUT_SECONDS="${OPENCLAW_TIMEOUT_SECONDS:-${ACP_OPENCLAW_TIMEOUT_SECONDS:-${F_LOSNING_OPENCLAW_TIMEOUT_SECONDS:-900}}}"
|
|
67
67
|
printf -v SESSION_Q '%q' "$SESSION"
|
|
68
68
|
printf -v CONFIG_YAML_Q '%q' "$CONFIG_YAML"
|
|
@@ -54,8 +54,8 @@ claude_effort="medium"
|
|
|
54
54
|
claude_timeout_seconds="900"
|
|
55
55
|
claude_max_attempts="3"
|
|
56
56
|
claude_retry_backoff_seconds="30"
|
|
57
|
-
openclaw_model="openrouter/
|
|
58
|
-
openclaw_thinking="
|
|
57
|
+
openclaw_model="openrouter/qwen/qwen3.6-plus-preview:free"
|
|
58
|
+
openclaw_thinking="low"
|
|
59
59
|
openclaw_timeout_seconds="600"
|
|
60
60
|
force="0"
|
|
61
61
|
|