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
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
2
|
+
# Why: outside the pod, devzone agent launches opencode in the Kubernetes workspace
|
|
3
|
+
# already started (projects and journals of the pod), or locally with --local; the
|
|
4
|
+
# journal of the pod is brought back into that of the workstation (#431).
|
|
5
|
+
# Library sourced by agent.sh: no command is launched here.
|
|
6
6
|
|
|
7
|
-
#
|
|
8
|
-
|
|
7
|
+
# True in the workspace container of the cluster, which carries the chart marker.
|
|
8
|
+
agent_in_pod() {
|
|
9
9
|
[ "${DEVZONE_WORKSPACE:-}" = kubernetes ]
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
# kubectl
|
|
12
|
+
# kubectl of the workstation: devzone context if it exists, then the workspace namespace.
|
|
13
13
|
agent_kc() {
|
|
14
14
|
if kubectl config get-contexts -o name 2>/dev/null | grep -qx devzone; then
|
|
15
15
|
kubectl --context devzone --namespace devzone-workspace "$@"
|
|
@@ -18,80 +18,80 @@ agent_kc() {
|
|
|
18
18
|
fi
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
local
|
|
26
|
-
local agent_kube="$
|
|
27
|
-
if
|
|
28
|
-
#
|
|
29
|
-
# kubeconfig
|
|
30
|
-
(cd "$
|
|
21
|
+
# Why: launching opencode is common to each model attempt, and the kubeconfig
|
|
22
|
+
# preparation depends on the Kubernetes workspace; this block lives here with the rest
|
|
23
|
+
# of the pod (#431), agent.sh only keeps the model loop.
|
|
24
|
+
opencode_launch() {
|
|
25
|
+
local folder="$1" m="$2" brief="$3" journal="$4" state="$5"
|
|
26
|
+
local agent_kube="$state/kubeconfig"
|
|
27
|
+
if agent_in_pod; then
|
|
28
|
+
# In the pod, the limited service account is the only access: no workstation
|
|
29
|
+
# kubeconfig enters the environment of opencode.
|
|
30
|
+
(cd "$folder" && env -u KUBECONFIG DEVZONE_AGENT_SESSION=1 opencode run --print-logs --log-level ERROR --auto -m "$(modele_ref "$m")" "$(cat "$brief")" </dev/null >>"$journal" 2>&1) &
|
|
31
31
|
else
|
|
32
32
|
if [ -f "$HOME/.kube/config" ]; then
|
|
33
33
|
(umask 077; KUBECONFIG="$HOME/.kube/config" kubectl config view --minify --flatten --context devzone >"$agent_kube") 2>/dev/null || : >"$agent_kube"
|
|
34
34
|
chmod 600 "$agent_kube"
|
|
35
|
-
[ -s "$agent_kube" ] || echo "=== kubernetes
|
|
35
|
+
[ -s "$agent_kube" ] || echo "=== kubernetes: no devzone context, session without access" >>"$journal"
|
|
36
36
|
else
|
|
37
37
|
: >"$agent_kube"
|
|
38
38
|
fi
|
|
39
|
-
(cd "$
|
|
39
|
+
(cd "$folder" && KUBECONFIG="$agent_kube" DEVZONE_AGENT_SESSION=1 opencode run --print-logs --log-level ERROR --auto -m "$(modele_ref "$m")" "$(cat "$brief")" </dev/null >>"$journal" 2>&1) &
|
|
40
40
|
fi
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
#
|
|
44
|
-
|
|
45
|
-
if
|
|
43
|
+
# True when the pod of the workspace runs and the command comes from the workstation.
|
|
44
|
+
workspace_available() {
|
|
45
|
+
if agent_in_pod; then return 1; fi
|
|
46
46
|
local phase
|
|
47
47
|
phase="$(agent_kc get pod devzone-workspace-0 -o jsonpath='{.status.phase}' --request-timeout=5s 2>/dev/null)" || return 1
|
|
48
48
|
[ "$phase" = Running ]
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
# (clone
|
|
51
|
+
# Runs the brief in the pod, then brings its journal back even on failure.
|
|
52
|
+
# A /workspaces/projets/... path absent from here designates a folder of the pod
|
|
53
|
+
# (clone or worktree of devzone ticket, #558): nothing is copied.
|
|
54
54
|
agent_workspace() {
|
|
55
|
-
local
|
|
56
|
-
local
|
|
57
|
-
case "$
|
|
58
|
-
/workspaces/projets/*) [ -d "$
|
|
55
|
+
local folder="$1" brief="$2" name journal code=0 in_pod=""
|
|
56
|
+
local pod_root=/home/vscode/.local/share/devzone
|
|
57
|
+
case "$folder" in
|
|
58
|
+
/workspaces/projets/*) [ -d "$folder" ] || in_pod="$folder" ;;
|
|
59
59
|
esac
|
|
60
|
-
if [ -n "$
|
|
61
|
-
|
|
62
|
-
if ! agent_kc exec devzone-workspace-0 -c workspace -- test -d "$
|
|
63
|
-
refuse "
|
|
60
|
+
if [ -n "$in_pod" ]; then
|
|
61
|
+
name="$(basename "$in_pod")"
|
|
62
|
+
if ! agent_kc exec devzone-workspace-0 -c workspace -- test -d "$in_pod" 2>/dev/null; then
|
|
63
|
+
refuse "folder not found in the pod: $in_pod (devzone workspace clone, then devzone ticket <n> in the pod)"
|
|
64
64
|
fi
|
|
65
65
|
else
|
|
66
|
-
[ -d "$
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if ! agent_kc exec devzone-workspace-0 -c workspace -- test -d "$
|
|
70
|
-
refuse "
|
|
66
|
+
[ -d "$folder" ] || refuse "folder not found: $folder (searched from $(pwd))"
|
|
67
|
+
name="$(basename "$(cd "$folder" && pwd -P)")"
|
|
68
|
+
in_pod="/workspaces/projets/$name"
|
|
69
|
+
if ! agent_kc exec devzone-workspace-0 -c workspace -- test -d "$in_pod" 2>/dev/null; then
|
|
70
|
+
refuse "project $name missing from the Kubernetes workspace: devzone workspace copy-to $folder (on this machine), or --local"
|
|
71
71
|
fi
|
|
72
72
|
fi
|
|
73
|
-
echo "devzone agent
|
|
74
|
-
agent_kc cp "$
|
|
75
|
-
# shellcheck disable=SC2016 # the pod shell expands
|
|
76
|
-
agent_kc exec devzone-workspace-0 -c workspace -- env DEVZONE_RACINE="$
|
|
77
|
-
journal="$(
|
|
73
|
+
echo "devzone agent: Kubernetes workspace (pod devzone-workspace-0, $in_pod); --local for the container"
|
|
74
|
+
agent_kc cp "$brief" "devzone-workspace-0:/tmp/devzone-agent-$name.md" -c workspace
|
|
75
|
+
# shellcheck disable=SC2016 # the pod shell expands MODEL_OPT, not this one
|
|
76
|
+
agent_kc exec devzone-workspace-0 -c workspace -- env DEVZONE_RACINE="$pod_root" MODEL_OPT="$MODELE_LISTE" bash -lc 'devzone agent ${MODEL_OPT:+--modele "$MODEL_OPT"} "$1" "$2"' _ "$in_pod" "/tmp/devzone-agent-$name.md" || code=$?
|
|
77
|
+
journal="$(journal_of "$name")"
|
|
78
78
|
mkdir -p "$(dirname "$journal")"
|
|
79
|
-
if ! agent_kc exec devzone-workspace-0 -c workspace -- cat "$
|
|
80
|
-
echo "=== journal
|
|
79
|
+
if ! agent_kc exec devzone-workspace-0 -c workspace -- cat "$pod_root/workspace/.agents/$name.log" >>"$journal"; then
|
|
80
|
+
echo "=== pod journal not found" >>"$journal"
|
|
81
81
|
fi
|
|
82
82
|
return "$code"
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
agent_aide() {
|
|
86
86
|
cat <<'AGENTEOF2'
|
|
87
|
-
usage
|
|
88
|
-
|
|
89
|
-
--modele
|
|
90
|
-
workspace
|
|
91
|
-
|
|
87
|
+
usage: devzone agent [--modele <m>[,<m2>…]] [--local] <folder> <brief-file>
|
|
88
|
+
runs opencode on the brief, free models in rotation
|
|
89
|
+
--modele: models tried first, in order, then the rotation
|
|
90
|
+
Kubernetes workspace first if it runs; --local: this container
|
|
91
|
+
a /workspaces/projets/... path absent from here is a folder of the pod, without copy
|
|
92
92
|
devzone agent etat
|
|
93
|
-
sessions
|
|
94
|
-
devzone agent liberer [<
|
|
95
|
-
|
|
93
|
+
known sessions and excluded models
|
|
94
|
+
devzone agent liberer [<model>|--tous]
|
|
95
|
+
lifts a model exclusion
|
|
96
96
|
AGENTEOF2
|
|
97
97
|
}
|
package/.devcontainer/agent.sh
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# shellcheck disable=SC2034 # RACINE, FREE_MODELS,
|
|
2
|
+
# Drives opencode on a brief: rotation, silence at start, resume.
|
|
3
|
+
# ia module (#221). devzone agent <folder> <brief> | etat | liberer.
|
|
4
|
+
# shellcheck disable=SC2034 # RACINE, FREE_MODELS, PAUSE_RANK: read by the sourced agent-*.sh
|
|
5
5
|
set -euo pipefail
|
|
6
|
-
#
|
|
7
|
-
#
|
|
6
|
+
# Folder of the script, symbolic links followed by hand: readlink -f does not exist
|
|
7
|
+
# on macOS (tests under bash 3.2).
|
|
8
8
|
SOURCE="${BASH_SOURCE[0]}"
|
|
9
9
|
while [ -L "$SOURCE" ]; do
|
|
10
10
|
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
@@ -16,203 +16,201 @@ while [ -L "$SOURCE" ]; do
|
|
|
16
16
|
done
|
|
17
17
|
ICI="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
18
18
|
RACINE="${DEVZONE_RACINE:-$(dirname "$ICI")}"
|
|
19
|
-
# shellcheck source=agent-
|
|
20
|
-
. "$ICI/agent-
|
|
21
|
-
# shellcheck source=agent-
|
|
22
|
-
. "$ICI/agent-
|
|
19
|
+
# shellcheck source=agent-errors.sh disable=SC1091
|
|
20
|
+
. "$ICI/agent-errors.sh"
|
|
21
|
+
# shellcheck source=agent-rights.sh disable=SC1091
|
|
22
|
+
. "$ICI/agent-rights.sh"
|
|
23
23
|
# shellcheck source=SCRIPTDIR/agent-session.sh disable=SC1091
|
|
24
24
|
. "$ICI/agent-session.sh"
|
|
25
25
|
# shellcheck source=agent-workspace.sh disable=SC1091
|
|
26
26
|
. "$ICI/agent-workspace.sh"
|
|
27
27
|
# shellcheck source=agent-local.sh disable=SC1091
|
|
28
28
|
. "$ICI/agent-local.sh"
|
|
29
|
-
# shellcheck source=SCRIPTDIR/agent-
|
|
30
|
-
. "$ICI/agent-
|
|
29
|
+
# shellcheck source=SCRIPTDIR/agent-model.sh disable=SC1091
|
|
30
|
+
. "$ICI/agent-model.sh"
|
|
31
31
|
FREE_MODELS=(big-pickle deepseek-v4.1-flash-free hy4-flash-free nemotron-3.5-super-vl-free
|
|
32
32
|
nemotron-3.5-lightning-free mimo-v2.6-flash-free beam-free flint-40b-free longcat-2.5-free)
|
|
33
33
|
# Session pod ephemere (#222)
|
|
34
34
|
# shellcheck source=agent-pod.sh disable=SC1091
|
|
35
35
|
. "$ICI/agent-pod.sh"
|
|
36
36
|
SILENCE="${DEVZONE_AGENT_SILENCE:-45}"
|
|
37
|
-
|
|
37
|
+
FROZEN="${DEVZONE_AGENT_FIGEE:-600}"
|
|
38
38
|
AGENT_ETAT="${DEVZONE_AGENT_ETAT:-$HOME/.local/state/oc-lancer}"
|
|
39
|
-
# Pause
|
|
40
|
-
#
|
|
41
|
-
|
|
42
|
-
if [ -n "${DEVZONE_AGENT_PAUSE_RANG:-}" ] && [ -n "${BATS_TEST_TMPDIR:-}" ]; then
|
|
43
|
-
#
|
|
44
|
-
|
|
45
|
-
refuse() { echo "devzone agent
|
|
46
|
-
|
|
47
|
-
local
|
|
48
|
-
local journal
|
|
49
|
-
local
|
|
50
|
-
local
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
[ -d "$
|
|
54
|
-
[ -r "$
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
#
|
|
39
|
+
# Pause between read and write of the rank (tests only): active only when
|
|
40
|
+
# DEVZONE_AGENT_PAUSE_RANG is set under bats; never a pause by default.
|
|
41
|
+
PAUSE_RANK=0
|
|
42
|
+
if [ -n "${DEVZONE_AGENT_PAUSE_RANG:-}" ] && [ -n "${BATS_TEST_TMPDIR:-}" ]; then PAUSE_RANK="$DEVZONE_AGENT_PAUSE_RANG"; fi
|
|
43
|
+
# Retries of the same session for a network cause, per model, before the next model
|
|
44
|
+
NETWORK_RETRIES=3
|
|
45
|
+
refuse() { echo "devzone agent: $*" >&2; exit 2; }
|
|
46
|
+
agent_launch() {
|
|
47
|
+
local folder="$1" brief="$2"
|
|
48
|
+
local journal state start m i pid code offset size started freeze discard new
|
|
49
|
+
local brief_current resumed=0 now last output recent cause start_t
|
|
50
|
+
local network_for="" network_n=0
|
|
51
|
+
# Paths relative to the calling folder: made absolute before any cd, lock or
|
|
52
|
+
# state write; the name of the brief is kept.
|
|
53
|
+
[ -d "$folder" ] || refuse "folder not found: $folder (searched from $(pwd))"
|
|
54
|
+
[ -r "$brief" ] || refuse "brief not found: $brief (searched from $(pwd))"
|
|
55
|
+
folder="$(cd "$folder" && pwd -P)"
|
|
56
|
+
brief="$(cd "$(dirname "$brief")" && pwd -P)/$(basename "$brief")"
|
|
57
|
+
# ia module required: without assistants, nothing to drive.
|
|
58
58
|
if ! bash "$ICI/devzone" is-enabled ia >/dev/null 2>&1; then
|
|
59
|
-
refuse "
|
|
59
|
+
refuse "ia module disabled: devzone enable ia"
|
|
60
60
|
fi
|
|
61
61
|
configurer
|
|
62
|
-
journal="$(
|
|
62
|
+
journal="$(journal_of "$folder")"
|
|
63
63
|
export AGENT_JOURNAL="$journal"
|
|
64
|
-
|
|
65
|
-
mkdir -p "$(dirname "$journal")" "$
|
|
66
|
-
droits_photo "$
|
|
64
|
+
state="$AGENT_ETAT"
|
|
65
|
+
mkdir -p "$(dirname "$journal")" "$state"
|
|
66
|
+
droits_photo "$folder"
|
|
67
67
|
modeles_charger "$journal"
|
|
68
68
|
local_charge
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
#
|
|
72
|
-
# diff, log),
|
|
73
|
-
|
|
74
|
-
if [ "$
|
|
75
|
-
|
|
69
|
+
start="$(rank_take "$state" "$journal")" || refuse "model rank locked: retry later"
|
|
70
|
+
brief_current="$brief"
|
|
71
|
+
# Resume: a new session restarts from the work already present (git status,
|
|
72
|
+
# diff, log), without conversation history.
|
|
73
|
+
resume() {
|
|
74
|
+
if [ "$resumed" = 1 ]; then return 0; fi
|
|
75
|
+
resumed=1
|
|
76
76
|
local c
|
|
77
77
|
c="$(mktemp)"
|
|
78
|
-
cat "$
|
|
79
|
-
printf '\n\
|
|
80
|
-
|
|
78
|
+
cat "$brief_current" >"$c"
|
|
79
|
+
printf '\n\nRESUME: a previous session was interrupted. Read git status, git diff and git log in the folder, check this work against the brief above, fix what deviates from it and finish what is missing.\n' >>"$c"
|
|
80
|
+
brief_current="$c"
|
|
81
81
|
}
|
|
82
|
-
modele_ordre "$
|
|
82
|
+
modele_ordre "$start"
|
|
83
83
|
i=0
|
|
84
84
|
while [ "$i" -lt "${#ORDRE[@]}" ]; do
|
|
85
85
|
m="${ORDRE[$i]}"
|
|
86
|
-
if [ "$m" != "$
|
|
87
|
-
if
|
|
86
|
+
if [ "$m" != "$network_for" ]; then network_for="$m"; network_n=0; fi
|
|
87
|
+
if model_excluded "$m"; then
|
|
88
88
|
modele_demande_ecart "$m" "$(modele_ecart_cause "$m")" "$journal"
|
|
89
89
|
i=$(( i + 1 ))
|
|
90
90
|
continue
|
|
91
91
|
fi
|
|
92
92
|
modele_demande_choisi "$m" "$journal"
|
|
93
|
-
echo "===
|
|
93
|
+
echo "=== model opencode/$m start $(date -u +%Y-%m-%dT%H:%M:%SZ)" >>"$journal"
|
|
94
94
|
offset="$(wc -c <"$journal")"
|
|
95
|
-
|
|
95
|
+
opencode_launch "$folder" "$m" "$brief_current" "$journal" "$state"
|
|
96
96
|
pid=$!
|
|
97
|
-
|
|
97
|
+
started=0
|
|
98
98
|
discard=0
|
|
99
|
-
|
|
100
|
-
debut_t="$(date +%s)"
|
|
99
|
+
start_t="$(date +%s)"
|
|
101
100
|
while kill -0 "$pid" 2>/dev/null; do
|
|
102
|
-
if
|
|
101
|
+
if session_fatal_error "$pid" "$journal" "$offset" "$m" "$folder"; then discard=1; break; fi
|
|
103
102
|
if [ "$(wc -c <"$journal")" -gt "$offset" ]; then
|
|
104
|
-
|
|
105
|
-
if [ "$(
|
|
103
|
+
new="$(tail -c "+$(( offset + 1 ))" "$journal" 2>/dev/null || true)"
|
|
104
|
+
if [ "$(error_cause "$(error_lines "$new")")" != "quota" ]; then started=1; break; fi
|
|
106
105
|
fi
|
|
107
|
-
if [ $(( $(date +%s) -
|
|
106
|
+
if [ $(( $(date +%s) - start_t )) -ge "$SILENCE" ]; then break; fi
|
|
108
107
|
sleep "${DEVZONE_AGENT_PAS:-1}"
|
|
109
108
|
done
|
|
110
|
-
if [ "$discard" = 1 ]; then
|
|
111
|
-
if kill -0 "$pid" 2>/dev/null && [ "$
|
|
109
|
+
if [ "$discard" = 1 ]; then resume; i=$(( i + 1 )); continue; fi
|
|
110
|
+
if kill -0 "$pid" 2>/dev/null && [ "$started" = 0 ]; then
|
|
112
111
|
pkill -P "$pid" 2>/dev/null || true
|
|
113
112
|
kill "$pid" 2>/dev/null || true
|
|
114
113
|
wait "$pid" 2>/dev/null || true
|
|
115
|
-
droits_verifier "$
|
|
116
|
-
echo "=== opencode/$m
|
|
117
|
-
|
|
114
|
+
droits_verifier "$folder"
|
|
115
|
+
echo "=== opencode/$m silent at start: excluded 1 h, next model" >>"$journal"
|
|
116
|
+
model_exclude "$m" mute
|
|
118
117
|
modele_demande_ecart "$m" mute "$journal"
|
|
119
|
-
|
|
118
|
+
resume
|
|
120
119
|
i=$(( i + 1 ))
|
|
121
120
|
continue
|
|
122
121
|
fi
|
|
123
|
-
#
|
|
124
|
-
#
|
|
122
|
+
# Frozen session: nothing written for FROZEN seconds during the run -> stopped,
|
|
123
|
+
# then a new session with the resume brief.
|
|
125
124
|
freeze=0
|
|
126
|
-
if kill -0 "$pid" 2>/dev/null && [ "$
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
if kill -0 "$pid" 2>/dev/null && [ "$started" = 1 ]; then
|
|
126
|
+
last="$(date +%s)"
|
|
127
|
+
size="$(wc -c <"$journal")"
|
|
129
128
|
while kill -0 "$pid" 2>/dev/null; do
|
|
130
|
-
if
|
|
129
|
+
if session_fatal_error "$pid" "$journal" "$offset" "$m" "$folder"; then discard=1; break; fi
|
|
131
130
|
sleep "${DEVZONE_AGENT_PAS:-1}"
|
|
132
|
-
|
|
133
|
-
if [ "$(wc -c <"$journal")" -gt "$
|
|
134
|
-
|
|
135
|
-
|
|
131
|
+
now="$(date +%s)"
|
|
132
|
+
if [ "$(wc -c <"$journal")" -gt "$size" ]; then
|
|
133
|
+
size="$(wc -c <"$journal")"
|
|
134
|
+
last="$now"
|
|
136
135
|
fi
|
|
137
|
-
if [ $((
|
|
136
|
+
if [ $(( now - last )) -gt "$FROZEN" ]; then
|
|
138
137
|
pkill -P "$pid" 2>/dev/null || true
|
|
139
138
|
kill "$pid" 2>/dev/null || true
|
|
140
139
|
wait "$pid" 2>/dev/null || true
|
|
141
|
-
droits_verifier "$
|
|
140
|
+
droits_verifier "$folder"
|
|
142
141
|
freeze=1
|
|
143
142
|
break
|
|
144
143
|
fi
|
|
145
144
|
done
|
|
146
145
|
fi
|
|
147
|
-
if [ "$discard" = 1 ]; then
|
|
146
|
+
if [ "$discard" = 1 ]; then resume; i=$(( i + 1 )); continue; fi
|
|
148
147
|
if [ "$freeze" = 1 ]; then
|
|
149
|
-
echo "=== opencode/$m
|
|
150
|
-
|
|
148
|
+
echo "=== opencode/$m frozen ($FROZEN s without writing): new session, next model" >>"$journal"
|
|
149
|
+
resume
|
|
151
150
|
i=$(( i + 1 ))
|
|
152
151
|
continue
|
|
153
152
|
fi
|
|
154
153
|
code=0
|
|
155
154
|
wait "$pid" || code=$?
|
|
156
|
-
droits_verifier "$
|
|
157
|
-
#
|
|
158
|
-
#
|
|
159
|
-
#
|
|
160
|
-
#
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
#
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
echo "=== erreur réseau signalée mais réseau joignable : traité comme autre" >>"$journal"
|
|
155
|
+
droits_verifier "$folder"
|
|
156
|
+
# Only the output of this attempt counts: an error of a previous model must not
|
|
157
|
+
# condemn the next one. Only its last 30 lines are read, and only when the exit
|
|
158
|
+
# code is non-zero or opencode wrote its own error line: a printed "Free usage
|
|
159
|
+
# limit" in text that ends normally is not a failure.
|
|
160
|
+
output="$(tail -c "+$(( offset + 1 ))" "$journal" 2>/dev/null || true)"
|
|
161
|
+
recent="$(printf '%s\n' "$output" | tail -n 30)"
|
|
162
|
+
if [ "$code" -ne 0 ] || printf '%s\n' "$recent" | grep -qE "$ERROR_LINE"; then
|
|
163
|
+
if printf '%s\n' "$recent" | grep -qE "$ERRORS"; then
|
|
164
|
+
cause="$(error_cause "$(printf '%s\n' "$recent" | grep -oE "$ERRORS" | tail -1)")"
|
|
165
|
+
# A network error is kept only if the network is down now: otherwise it
|
|
166
|
+
# would repeat endlessly on a good network.
|
|
167
|
+
if [ "$cause" = reseau ] && network_reachable; then
|
|
168
|
+
echo "=== network error reported but network reachable: treated as other" >>"$journal"
|
|
171
169
|
cause=autre
|
|
172
170
|
fi
|
|
173
|
-
if [ "$cause" = reseau ] && [ "$
|
|
174
|
-
echo "=== opencode/$m
|
|
171
|
+
if [ "$cause" = reseau ] && [ "$network_n" -ge "$NETWORK_RETRIES" ]; then
|
|
172
|
+
echo "=== opencode/$m network down $NETWORK_RETRIES times: next model, no exclusion" >>"$journal"
|
|
175
173
|
cause=autre
|
|
176
174
|
fi
|
|
177
175
|
if [ "$cause" = reseau ]; then
|
|
178
|
-
if
|
|
179
|
-
|
|
180
|
-
|
|
176
|
+
if network_wait; then
|
|
177
|
+
network_n=$(( network_n + 1 ))
|
|
178
|
+
resume
|
|
181
179
|
continue
|
|
182
180
|
fi
|
|
183
|
-
echo "===
|
|
181
|
+
echo "=== network unavailable" >>"$journal"
|
|
184
182
|
exit 4
|
|
185
183
|
fi
|
|
186
184
|
if [ "$cause" = autre ]; then
|
|
187
|
-
echo "=== opencode/$m
|
|
185
|
+
echo "=== opencode/$m error, no exclusion: next model" >>"$journal"
|
|
188
186
|
else
|
|
189
|
-
|
|
187
|
+
model_exclude "$m" "$cause"
|
|
190
188
|
modele_demande_ecart "$m" "$cause" "$journal"
|
|
191
|
-
echo "=== opencode/$m
|
|
189
|
+
echo "=== opencode/$m excluded ($(cause_label "$cause"), $(exclusion_label "$cause")): next model" >>"$journal"
|
|
192
190
|
fi
|
|
193
|
-
|
|
191
|
+
resume
|
|
194
192
|
i=$(( i + 1 ))
|
|
195
193
|
continue
|
|
196
194
|
fi
|
|
197
195
|
fi
|
|
198
196
|
if [ "$code" -ne 0 ]; then
|
|
199
|
-
echo "=== opencode/$m
|
|
200
|
-
|
|
197
|
+
echo "=== opencode/$m stopped on error (code $code): next model" >>"$journal"
|
|
198
|
+
resume
|
|
201
199
|
i=$(( i + 1 ))
|
|
202
200
|
continue
|
|
203
201
|
fi
|
|
204
|
-
echo "===
|
|
202
|
+
echo "=== end with opencode/$m (code $code)" >>"$journal"
|
|
205
203
|
exit "$code"
|
|
206
204
|
done
|
|
207
|
-
echo "===
|
|
205
|
+
echo "=== no free model available" >>"$journal"
|
|
208
206
|
exit 3
|
|
209
207
|
}
|
|
210
208
|
case "${1:-}" in
|
|
211
209
|
status) agent_pod_status ;;
|
|
212
|
-
etat) if [ "${2:-}" = "--json" ]; then exec bash "$ICI/agent-
|
|
210
|
+
etat) if [ "${2:-}" = "--json" ]; then exec bash "$ICI/agent-state-json.sh"; else agent_state; fi ;;
|
|
213
211
|
liberer)
|
|
214
212
|
[ -n "${2:-}" ] || { agent_aide >&2; exit 2; }
|
|
215
|
-
|
|
213
|
+
exclusion_clear "$2"
|
|
216
214
|
;;
|
|
217
215
|
-h | --help | aide) agent_aide ;;
|
|
218
216
|
"")
|
|
@@ -222,7 +220,7 @@ case "${1:-}" in
|
|
|
222
220
|
*)
|
|
223
221
|
if [ "${1:-}" = "--modele" ]; then [ -n "${2:-}" ] || { agent_aide >&2; exit 2; }; MODELE_LISTE="$2"; shift 2; fi
|
|
224
222
|
if [ "${1:-}" = "--pod" ]; then
|
|
225
|
-
[ -z "$MODELE_LISTE" ] || refuse "--modele
|
|
223
|
+
[ -z "$MODELE_LISTE" ] || refuse "--modele is not supported with --pod"
|
|
226
224
|
shift
|
|
227
225
|
if [ -z "${1:-}" ] || [ -z "${2:-}" ]; then
|
|
228
226
|
agent_aide >&2
|
|
@@ -230,20 +228,20 @@ case "${1:-}" in
|
|
|
230
228
|
fi
|
|
231
229
|
agent_pod_lancer "$1" "$2"
|
|
232
230
|
fi
|
|
233
|
-
|
|
231
|
+
local_mode=0
|
|
234
232
|
if [ "${1:-}" = "--local" ]; then
|
|
235
|
-
|
|
233
|
+
local_mode=1
|
|
236
234
|
shift
|
|
237
235
|
fi
|
|
238
236
|
if [ "$#" -lt 2 ]; then
|
|
239
237
|
agent_aide >&2
|
|
240
238
|
exit 2
|
|
241
239
|
fi
|
|
242
|
-
if [ "$
|
|
240
|
+
if [ "$local_mode" = 0 ] && workspace_available; then
|
|
243
241
|
code=0
|
|
244
242
|
agent_workspace "$1" "$2" || code=$?
|
|
245
243
|
exit "$code"
|
|
246
244
|
fi
|
|
247
|
-
|
|
245
|
+
agent_launch "$1" "$2"
|
|
248
246
|
;;
|
|
249
247
|
esac
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
set -u
|
|
10
10
|
|
|
11
11
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
12
|
-
MESSAGE_FILE="$SCRIPT_DIR/docker-
|
|
12
|
+
MESSAGE_FILE="$SCRIPT_DIR/docker-guard.message"
|
|
13
13
|
FALLBACK="devzone is Kubernetes-first: only pods are containers. Use kubectl, or a throwaway pod or namespace. Host action: set DEVZONE_ALLOW_DOCKER to 1."
|
|
14
14
|
MESSAGE="$FALLBACK"
|
|
15
15
|
if [ -r "$MESSAGE_FILE" ]; then
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Guard for opencode 2.x: blocks Docker commands in devzone (Kubernetes-first).
|
|
2
|
-
// Each shell tool call is checked by docker-
|
|
2
|
+
// Each shell tool call is checked by docker-guard.sh. Exit code 2: error shown
|
|
3
3
|
// to the agent with stderr message. Script absent or failing: nothing blocked.
|
|
4
4
|
// The installed copy (devzone enable ia) replaces the placeholder below with
|
|
5
5
|
// the script path; DEVZONE_DOCKER_GARDE overrides it. The script is resolved
|
|
6
|
-
// from the plugin location itself (.devcontainer/
|
|
6
|
+
// from the plugin location itself (.devcontainer/ai/plugins -> ../docker-guard.sh).
|
|
7
7
|
// opencode 1.x also loads default exports with an id; without ctx.tool.hook the
|
|
8
|
-
// 1.x guard in devzone-
|
|
8
|
+
// 1.x guard in devzone-guard.js remains active.
|
|
9
9
|
import { spawnSync } from "node:child_process"
|
|
10
10
|
import { existsSync } from "node:fs"
|
|
11
11
|
import { fileURLToPath } from "node:url"
|
|
@@ -17,7 +17,7 @@ function guardScript() {
|
|
|
17
17
|
if (INSTALLED && INSTALLED.indexOf("__DEVZONE_DOCKER_GARDE__") !== 0 && existsSync(INSTALLED)) {
|
|
18
18
|
return INSTALLED
|
|
19
19
|
}
|
|
20
|
-
const script = join(dirname(fileURLToPath(import.meta.url)), "..", "docker-
|
|
20
|
+
const script = join(dirname(fileURLToPath(import.meta.url)), "..", "docker-guard.sh")
|
|
21
21
|
if (existsSync(script)) {
|
|
22
22
|
return script
|
|
23
23
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Guard for opencode 1.x: blocks Docker commands in devzone (Kubernetes-first).
|
|
2
|
-
// Each shell tool call is checked by docker-
|
|
2
|
+
// Each shell tool call is checked by docker-guard.sh. Exit code 2: error shown
|
|
3
3
|
// to the agent with stderr message. Script absent or failing: nothing blocked.
|
|
4
4
|
// The installed copy (devzone enable ia) replaces the placeholder below with
|
|
5
5
|
// the script path; DEVZONE_DOCKER_GARDE overrides it. The script is resolved
|
|
6
|
-
// from the plugin location itself (.devcontainer/
|
|
6
|
+
// from the plugin location itself (.devcontainer/ai/plugins -> ../docker-guard.sh).
|
|
7
7
|
import { spawnSync } from "node:child_process"
|
|
8
8
|
import { existsSync } from "node:fs"
|
|
9
9
|
import { fileURLToPath } from "node:url"
|
|
@@ -15,7 +15,7 @@ function guardScript() {
|
|
|
15
15
|
if (INSTALLED && INSTALLED.indexOf("__DEVZONE_DOCKER_GARDE__") !== 0 && existsSync(INSTALLED)) {
|
|
16
16
|
return INSTALLED
|
|
17
17
|
}
|
|
18
|
-
const script = join(dirname(fileURLToPath(import.meta.url)), "..", "docker-
|
|
18
|
+
const script = join(dirname(fileURLToPath(import.meta.url)), "..", "docker-guard.sh")
|
|
19
19
|
if (existsSync(script)) {
|
|
20
20
|
return script
|
|
21
21
|
}
|