devzone 1.0.0 → 2.0.0
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/.devcontainer/Dockerfile +4 -4
- package/.devcontainer/agent-errors.sh +154 -0
- package/.devcontainer/agent-local.sh +2 -2
- package/.devcontainer/{agent-modele.messages → agent-model.messages} +1 -1
- package/.devcontainer/{agent-modele.sh → agent-model.sh} +8 -8
- package/.devcontainer/{agent-droits.sh → agent-rights.sh} +2 -2
- package/.devcontainer/agent-session.sh +122 -125
- package/.devcontainer/agent-state-json.sh +117 -0
- package/.devcontainer/agent-workspace.sh +53 -53
- package/.devcontainer/agent.sh +113 -115
- package/.devcontainer/{ia/docker-garde.sh → ai/docker-guard.sh} +1 -1
- package/.devcontainer/{ia/plugins/devzone-garde-v2.js → ai/plugins/devzone-guard-v2.js} +4 -4
- package/.devcontainer/{ia/plugins/devzone-garde.js → ai/plugins/devzone-guard.js} +3 -3
- package/.devcontainer/argocd/argocd.sh +8 -8
- package/.devcontainer/argocd/{catalogue-argocd.sh → catalog-argocd.sh} +1 -1
- package/.devcontainer/argocd/services-hook.sh +5 -5
- package/.devcontainer/{catalogue → catalog}/app.sh +4 -4
- package/.devcontainer/{catalogue/catalogue-veilleur.sh → catalog/catalog-watcher.sh} +7 -7
- package/.devcontainer/{catalogue → catalog}/mysql/mysql.sh +7 -7
- package/.devcontainer/{catalogue.sh → catalog.sh} +13 -13
- package/.devcontainer/cluster.sh +8 -8
- package/.devcontainer/devcontainer.json +1 -1
- package/.devcontainer/devzone +55 -54
- package/.devcontainer/{docker-relais.sh → docker-relay.sh} +2 -2
- package/.devcontainer/gitlab/argocd.sh +2 -2
- package/.devcontainer/gitlab/gitlab.sh +4 -4
- package/.devcontainer/gitlab/installation.sh +5 -5
- package/.devcontainer/gitlab/secrets.sh +1 -1
- package/.devcontainer/help.sh +1 -0
- package/.devcontainer/{kind-enveloppe.sh → kind-wrapper.sh} +5 -5
- package/.devcontainer/{kube-compte.sh → kube-account.sh} +3 -3
- package/.devcontainer/{kube-joignable.sh → kube-reachable.sh} +1 -1
- package/.devcontainer/memory.sh +113 -0
- package/.devcontainer/metrics-server.sh +52 -51
- package/.devcontainer/{paquets.sh → packages.sh} +4 -4
- package/.devcontainer/password.sh +88 -87
- package/.devcontainer/ports-auto.sh +7 -7
- package/.devcontainer/ports.sh +4 -4
- package/.devcontainer/post-create.sh +2 -2
- package/.devcontainer/postgres/postgres.sh +3 -3
- package/.devcontainer/services-admin.sh +5 -5
- package/.devcontainer/skills/devzone/SKILL.md +1 -1
- package/.devcontainer/{demarrage.sh → startup.sh} +5 -5
- package/.devcontainer/state-json.sh +308 -0
- package/.devcontainer/state-lock.sh +53 -0
- package/.devcontainer/state.sh +219 -0
- package/.devcontainer/workspace-init.sh +1 -1
- package/Makefile +7 -7
- package/README.md +2 -2
- package/charts/devzone-workspace/templates/statefulset.yaml +3 -0
- package/manage/devzone +3 -3
- package/manage/scripts/check-go-layout.sh +40 -0
- package/manage/scripts/check-names.sh +60 -0
- package/manage/scripts/devzone-create.sh +2 -2
- package/manage/scripts/devzone-manifest.sh +2 -2
- package/manage/scripts/docker-workstation.sh +2 -2
- package/manage/scripts/docker.sh +2 -2
- package/manage/scripts/{lancer.sh → launch.sh} +3 -3
- package/manage/scripts/{migrer-retour.sh → migrate-revert.sh} +1 -1
- package/manage/scripts/{migrer.sh → migrate.sh} +1 -1
- package/manage/workspace.sh +4 -4
- package/package.json +1 -1
- package/.devcontainer/agent-erreurs.sh +0 -138
- package/.devcontainer/agent-etat-json.sh +0 -115
- package/.devcontainer/etat-json.sh +0 -308
- package/.devcontainer/etat-verrou.sh +0 -52
- package/.devcontainer/etat.sh +0 -220
- package/.devcontainer/memoire.sh +0 -113
- /package/.devcontainer/{ia/docker-garde.message → ai/docker-guard.message} +0 -0
- /package/.devcontainer/{ia → ai}/host-check.message +0 -0
- /package/.devcontainer/{ia → ai}/host-check.sh +0 -0
- /package/.devcontainer/{ia → ai}/host-models.sh +0 -0
- /package/.devcontainer/{catalogue → catalog}/mysql/app.conf +0 -0
- /package/.devcontainer/{catalogue/mysql/installer.sh → catalog/mysql/install.sh} +0 -0
- /package/.devcontainer/{catalogue → catalog}/mysql/volume.sh +0 -0
- /package/.devcontainer/{docker-sans-hote.sh → docker-without-host.sh} +0 -0
- /package/.devcontainer/{isolement.sh → isolation.sh} +0 -0
- /package/.devcontainer/{etat-gitops.sh → state-gitops.sh} +0 -0
- /package/manage/scripts/{desinstaller.sh → uninstall.sh} +0 -0
package/.devcontainer/Dockerfile
CHANGED
|
@@ -108,10 +108,10 @@ RUN set -eu; \
|
|
|
108
108
|
rm -rf "$tmp"
|
|
109
109
|
|
|
110
110
|
# kind passe par une enveloppe (#291) : avec le Docker de l'hôte, un cluster
|
|
111
|
-
# créé à la main doit être rendu joignable depuis le conteneur (kube-
|
|
112
|
-
COPY kube-
|
|
113
|
-
COPY kind-
|
|
114
|
-
RUN chmod 0644 /usr/local/lib/devzone/kube-
|
|
111
|
+
# créé à la main doit être rendu joignable depuis le conteneur (kube-reachable.sh)
|
|
112
|
+
COPY kube-reachable.sh /usr/local/lib/devzone/kube-reachable.sh
|
|
113
|
+
COPY kind-wrapper.sh /usr/local/bin/kind
|
|
114
|
+
RUN chmod 0644 /usr/local/lib/devzone/kube-reachable.sh && chmod 0755 /usr/local/bin/kind
|
|
115
115
|
|
|
116
116
|
COPY --from=uv /uv /uvx /usr/local/bin/
|
|
117
117
|
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck disable=SC2034
|
|
3
|
+
# Model exclusions and network wait of the agent supervisor (#328).
|
|
4
|
+
# Library sourced by agent.sh: no command is launched here.
|
|
5
|
+
|
|
6
|
+
# Known opencode error texts (grep -E); error_cause takes the cause from them.
|
|
7
|
+
ERRORS='not available in your country|Free usage limit|content filter|Model is unavailable|Upstream request failed|ProviderHeaderTimeout|ENOTFOUND|ECONNREFUSED|ETIMEDOUT|EAI_AGAIN|ECONNRESET|fetch failed|network'
|
|
8
|
+
# Prefix of an opencode error line. Erreur: stays so that French output still matches.
|
|
9
|
+
ERROR_LINE='(^|[[:space:]])(Error|ERROR|Erreur):'
|
|
10
|
+
|
|
11
|
+
# Cause of a failure: pays (country, lasting), quota, filtre (filter), reseau
|
|
12
|
+
# (network, no exclusion) or autre (other). The stored names stay as they are:
|
|
13
|
+
# they are written to the state files and to devzone agent etat --json.
|
|
14
|
+
error_cause() {
|
|
15
|
+
local t="$1"
|
|
16
|
+
case "$t" in
|
|
17
|
+
*"not available in your country"*) echo "pays" ;;
|
|
18
|
+
*"Free usage limit"*) echo "quota" ;;
|
|
19
|
+
*"content filter"*) echo "filtre" ;;
|
|
20
|
+
*"ENOTFOUND"* | *"ECONNREFUSED"* | *"ETIMEDOUT"* | *"EAI_AGAIN"* | *"ECONNRESET"* | *"fetch failed"* | *"network"*)
|
|
21
|
+
echo "reseau" ;;
|
|
22
|
+
*) echo "autre" ;;
|
|
23
|
+
esac
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
# Cause name shown to the user, from a stored cause (mute and muet are both silent).
|
|
27
|
+
cause_label() {
|
|
28
|
+
case "$1" in
|
|
29
|
+
pays) echo "country" ;;
|
|
30
|
+
quota) echo "quota" ;;
|
|
31
|
+
filtre) echo "filter" ;;
|
|
32
|
+
reseau) echo "network" ;;
|
|
33
|
+
mute | muet) echo "silent" ;;
|
|
34
|
+
*) echo "other" ;;
|
|
35
|
+
esac
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# Duration of an exclusion in seconds: country 7 days (DEVZONE_AGENT_ECART_PAYS), the others 1 h.
|
|
39
|
+
exclusion_duration() {
|
|
40
|
+
case "$1" in
|
|
41
|
+
pays) echo "${DEVZONE_AGENT_ECART_PAYS:-604800}" ;;
|
|
42
|
+
*) echo 3600 ;;
|
|
43
|
+
esac
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# Readable duration of an exclusion for the journal: "7 d", "1 h" or "30 s".
|
|
47
|
+
exclusion_label() {
|
|
48
|
+
local d
|
|
49
|
+
d="$(exclusion_duration "$1")"
|
|
50
|
+
if [ "$d" -ge 86400 ]; then
|
|
51
|
+
echo "$(( d / 86400 )) d"
|
|
52
|
+
elif [ "$d" -ge 3600 ]; then
|
|
53
|
+
echo "$(( d / 3600 )) h"
|
|
54
|
+
else
|
|
55
|
+
echo "${d} s"
|
|
56
|
+
fi
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Writes the exclusion of the model: "<start> <cause> <duration>" in $AGENT_ETAT/ecart-<model>
|
|
60
|
+
# (the state file keeps its name on disk).
|
|
61
|
+
model_exclude() {
|
|
62
|
+
printf '%s %s %s\n' "$(date +%s)" "$2" "$(exclusion_duration "$2")" >"$AGENT_ETAT/ecart-$1"
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# True (0) when the model is excluded right now. Also reads the old muet-<model>
|
|
66
|
+
# format (timestamp only, 1 h).
|
|
67
|
+
model_excluded() {
|
|
68
|
+
local f e cause d
|
|
69
|
+
f="$AGENT_ETAT/ecart-$1"
|
|
70
|
+
if [ ! -f "$f" ]; then f="$AGENT_ETAT/muet-$1"; fi
|
|
71
|
+
if [ ! -f "$f" ]; then return 1; fi
|
|
72
|
+
read -r e cause d <<<"$(cat "$f")"
|
|
73
|
+
[ "$(date +%s)" -lt $(( e + ${d:-3600} )) ]
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
# True (0) when opencode.ai resolves and answers over HTTPS: one try, no wait.
|
|
77
|
+
network_reachable() {
|
|
78
|
+
getent hosts opencode.ai >/dev/null 2>&1 && curl -sI --max-time 5 https://opencode.ai >/dev/null 2>&1
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
# Waits for the network to come back: a try every DEVZONE_AGENT_RESEAU_PAS s, for
|
|
82
|
+
# DEVZONE_AGENT_RESEAU_MAX s at most. Returns 0 when it is back.
|
|
83
|
+
network_wait() {
|
|
84
|
+
local end
|
|
85
|
+
end=$(( $(date +%s) + ${DEVZONE_AGENT_RESEAU_MAX:-1800} ))
|
|
86
|
+
echo "=== network down, waiting" >>"$AGENT_JOURNAL"
|
|
87
|
+
while [ "$(date +%s)" -lt "$end" ]; do
|
|
88
|
+
if network_reachable; then
|
|
89
|
+
echo "=== network back" >>"$AGENT_JOURNAL"
|
|
90
|
+
return 0
|
|
91
|
+
fi
|
|
92
|
+
sleep "${DEVZONE_AGENT_RESEAU_PAS:-30}"
|
|
93
|
+
done
|
|
94
|
+
return 1
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
# Lists the current exclusions for devzone agent etat (muet- too, without cause).
|
|
98
|
+
agent_exclusions() {
|
|
99
|
+
local f m e cause d end now
|
|
100
|
+
now="$(date +%s)"
|
|
101
|
+
for f in "$AGENT_ETAT"/ecart-*; do
|
|
102
|
+
[ -e "$f" ] || continue
|
|
103
|
+
m="${f##*/ecart-}"
|
|
104
|
+
read -r e cause d <<<"$(cat "$f")"
|
|
105
|
+
end=$(( e + ${d:-3600} ))
|
|
106
|
+
[ "$now" -lt "$end" ] || continue
|
|
107
|
+
echo " model $m excluded ($(cause_label "$cause")) until $(utc_time "$end")"
|
|
108
|
+
done
|
|
109
|
+
for f in "$AGENT_ETAT"/muet-*; do
|
|
110
|
+
[ -e "$f" ] || continue
|
|
111
|
+
m="${f##*/muet-}"
|
|
112
|
+
e="$(cat "$f" 2>/dev/null || true)"
|
|
113
|
+
[ -n "$e" ] || continue
|
|
114
|
+
end=$(( e + 3600 ))
|
|
115
|
+
[ "$now" -lt "$end" ] || continue
|
|
116
|
+
echo " model $m excluded (silent) until $(utc_time "$end")"
|
|
117
|
+
done
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
# Lifts the exclusion of a model, or of all (--tous): devzone agent liberer.
|
|
121
|
+
exclusion_clear() {
|
|
122
|
+
case "$1" in
|
|
123
|
+
--tous) rm -f "$AGENT_ETAT"/ecart-* "$AGENT_ETAT"/muet-* ;;
|
|
124
|
+
*) rm -f "$AGENT_ETAT/ecart-$1" "$AGENT_ETAT/muet-$1" ;;
|
|
125
|
+
esac
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
# Keeps the opencode log lines of the session written by --print-logs: only the
|
|
129
|
+
# "timestamp=... level=ERROR ..." lines of a failure declare an exclusion, not the
|
|
130
|
+
# rest of the text read or written by the model.
|
|
131
|
+
error_lines() {
|
|
132
|
+
printf '%s\n' "$1" | sed -e $'s/\033\[[0-9;]*m//g' | grep -a -E '^timestamp=.* level=ERROR ' || true
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
# Stops the current session when the journal holds quota, country or filter since
|
|
136
|
+
# its start: the model is excluded and the session is killed (process and children).
|
|
137
|
+
session_fatal_error() {
|
|
138
|
+
local pid="$1" journal="$2" offset="$3" m="$4" folder="$5"
|
|
139
|
+
local output cause
|
|
140
|
+
output="$(tail -c "+$(( offset + 1 ))" "$journal" 2>/dev/null || true)"
|
|
141
|
+
cause="$(error_cause "$(error_lines "$output")")"
|
|
142
|
+
case "$cause" in
|
|
143
|
+
quota | pays | filtre) ;;
|
|
144
|
+
*) return 1 ;;
|
|
145
|
+
esac
|
|
146
|
+
pkill -P "$pid" 2>/dev/null || true
|
|
147
|
+
kill "$pid" 2>/dev/null || true
|
|
148
|
+
wait "$pid" 2>/dev/null || true
|
|
149
|
+
droits_verifier "$folder"
|
|
150
|
+
model_exclude "$m" "$cause"
|
|
151
|
+
modele_demande_ecart "$m" "$cause" "$journal"
|
|
152
|
+
printf '%s\n' "=== opencode/$m excluded ($(cause_label "$cause")): next model" >>"$journal"
|
|
153
|
+
return 0
|
|
154
|
+
}
|
|
@@ -9,9 +9,9 @@ LOCAL_HOTE_REEL=""
|
|
|
9
9
|
# Internal (slash-free) name of the host model chosen for this attempt.
|
|
10
10
|
LOCAL_HOTE_INTERNE=""
|
|
11
11
|
|
|
12
|
-
# shellcheck source=SCRIPTDIR/
|
|
12
|
+
# shellcheck source=SCRIPTDIR/ai/host-models.sh
|
|
13
13
|
# shellcheck disable=SC1091
|
|
14
|
-
. "$ICI/
|
|
14
|
+
. "$ICI/ai/host-models.sh"
|
|
15
15
|
|
|
16
16
|
# Sanitizes a model name into an internal name: every character outside
|
|
17
17
|
# [A-Za-z0-9._-] becomes '_'. Used for ecart-<name> files, the journal and
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Messages of devzone agent --modele (#420), in French like the journal they go to.
|
|
2
|
-
# Sourced by agent-
|
|
2
|
+
# Sourced by agent-model.sh. Kept out of .english on purpose: the accents are
|
|
3
3
|
# the point. Each %s is replaced by a model name or a cause (printf formats).
|
|
4
4
|
MSG_AUCUN_MODELE='aucun modèle gratuit disponible'
|
|
5
5
|
MSG_CHOISI='=== modèle choisi : %s (demandé)'
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
# Library sourced by agent.sh: no command is launched here.
|
|
5
5
|
|
|
6
6
|
# Journal and refusal texts (French), printf formats.
|
|
7
|
-
# shellcheck source=SCRIPTDIR/agent-
|
|
8
|
-
. "$ICI/agent-
|
|
7
|
+
# shellcheck source=SCRIPTDIR/agent-model.messages disable=SC1091
|
|
8
|
+
. "$ICI/agent-model.messages"
|
|
9
9
|
|
|
10
10
|
# Option --modele as typed (comma-separated list), empty when absent.
|
|
11
11
|
MODELE_LISTE=""
|
|
@@ -16,7 +16,7 @@ ORDRE=()
|
|
|
16
16
|
|
|
17
17
|
# Refuses a name missing from the free models: nothing is launched (code 2).
|
|
18
18
|
refuse_modele() {
|
|
19
|
-
# shellcheck disable=SC2059 # the format comes from agent-
|
|
19
|
+
# shellcheck disable=SC2059 # the format comes from agent-model.messages
|
|
20
20
|
printf "$MSG_INCONNU\n" "$1" >&2
|
|
21
21
|
printf ' %s\n' "${FREE_MODELS[@]}" >&2
|
|
22
22
|
exit 2
|
|
@@ -29,7 +29,7 @@ modeles_charger() {
|
|
|
29
29
|
FREE_MODELS=()
|
|
30
30
|
while IFS= read -r m; do
|
|
31
31
|
if [ -n "$m" ]; then FREE_MODELS+=("$m"); fi
|
|
32
|
-
done < <(
|
|
32
|
+
done < <(list_models)
|
|
33
33
|
[ "${#FREE_MODELS[@]}" -gt 0 ] || refuse "$MSG_AUCUN_MODELE"
|
|
34
34
|
MODELES_DEMANDES=()
|
|
35
35
|
if [ -n "$MODELE_LISTE" ]; then
|
|
@@ -40,7 +40,7 @@ modeles_charger() {
|
|
|
40
40
|
esac
|
|
41
41
|
done < <(printf '%s\n' "$MODELE_LISTE" | tr ',' '\n')
|
|
42
42
|
fi
|
|
43
|
-
echo "=== --modele : ${MODELE_LISTE:-
|
|
43
|
+
echo "=== --modele : ${MODELE_LISTE:-none}" >>"$journal"
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
# True when model $1 was asked with --modele.
|
|
@@ -54,7 +54,7 @@ modele_demande_p() {
|
|
|
54
54
|
# Journal line when requested model $1 starts; other models get no line.
|
|
55
55
|
modele_demande_choisi() {
|
|
56
56
|
if modele_demande_p "$1"; then
|
|
57
|
-
# shellcheck disable=SC2059 # the format comes from agent-
|
|
57
|
+
# shellcheck disable=SC2059 # the format comes from agent-model.messages
|
|
58
58
|
printf "$MSG_CHOISI\n" "$1" >>"$2"
|
|
59
59
|
fi
|
|
60
60
|
}
|
|
@@ -63,7 +63,7 @@ modele_demande_choisi() {
|
|
|
63
63
|
# journal $3. Other models keep their own lines.
|
|
64
64
|
modele_demande_ecart() {
|
|
65
65
|
if modele_demande_p "$1"; then
|
|
66
|
-
# shellcheck disable=SC2059 # the format comes from agent-
|
|
66
|
+
# shellcheck disable=SC2059 # the format comes from agent-model.messages
|
|
67
67
|
printf "$MSG_ECARTE\n" "$1" "$2" >>"$3"
|
|
68
68
|
fi
|
|
69
69
|
}
|
|
@@ -107,7 +107,7 @@ modele_ordre() {
|
|
|
107
107
|
modele_rang_avance() {
|
|
108
108
|
local k
|
|
109
109
|
for ((k = 0; k < ${#MODELES_DEMANDES[@]}; k++)); do
|
|
110
|
-
if !
|
|
110
|
+
if ! model_excluded "${MODELES_DEMANDES[$k]}"; then return 1; fi
|
|
111
111
|
done
|
|
112
112
|
return 0
|
|
113
113
|
}
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
# Fichiers de droits, chemins relatifs à la racine du dossier de travail. Liste
|
|
6
6
|
# fixe : aucune variable d'environnement ne la change, un agent peut en poser.
|
|
7
|
-
# agent-
|
|
7
|
+
# agent-rights.sh y figure, sinon un agent pourrait vider la liste.
|
|
8
8
|
DROITS_AGENT=(
|
|
9
9
|
.devcontainer/opencode/agent.json
|
|
10
10
|
.devcontainer/opencode.jsonc
|
|
11
11
|
.repowarden.conf
|
|
12
|
-
.devcontainer/agent-
|
|
12
|
+
.devcontainer/agent-rights.sh
|
|
13
13
|
)
|
|
14
14
|
|
|
15
15
|
# Dossier de la photo des droits d'un projet, dans l'état de l'agent.
|