devzone 7.3.0 → 7.4.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/devcontainer.json +1 -1
- package/.devcontainer/devzone +1 -4
- package/README.md +1 -1
- package/bin/SHA256SUMS +6 -6
- package/bin/devzone-darwin-amd64 +0 -0
- package/bin/devzone-darwin-arm64 +0 -0
- package/bin/devzone-linux-amd64 +0 -0
- package/bin/devzone-linux-arm64 +0 -0
- package/bin/devzone-windows-amd64.exe +0 -0
- package/bin/devzone-windows-arm64.exe +0 -0
- package/package.json +1 -1
- package/.devcontainer/agent-errors.sh +0 -156
- package/.devcontainer/agent-local.sh +0 -63
- package/.devcontainer/agent-model.sh +0 -113
- package/.devcontainer/agent-pod-egress.sh +0 -36
- package/.devcontainer/agent-pod-manifest.sh +0 -250
- package/.devcontainer/agent-pod.sh +0 -243
- package/.devcontainer/agent-session.sh +0 -242
- package/.devcontainer/agent-state-json.sh +0 -117
- package/.devcontainer/agent-workspace.sh +0 -97
- package/.devcontainer/agent.sh +0 -247
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"source=${localEnv:DEVZONE_VOLUMES:devzone}-opencode-config,target=/home/vscode/.config/opencode,type=volume",
|
|
45
45
|
"source=${localEnv:DEVZONE_VOLUMES:devzone}-opencode-data,target=/home/vscode/.local/share/opencode,type=volume",
|
|
46
46
|
// devzone agent (#377): state (discarded models, rank, lock, snapshots of the
|
|
47
|
-
// rights) at the path where agent
|
|
47
|
+
// rights) at the path where devzone agent writes it; shared like the logins
|
|
48
48
|
"source=${localEnv:DEVZONE_VOLUMES:devzone}-agent,target=/home/vscode/.local/state/oc-lancer,type=volume",
|
|
49
49
|
// Connexion gh et identité git (~/.config/git/config, lu par git comme
|
|
50
50
|
// config globale) : le conteneur reconstruit peut commiter et pousser
|
package/.devcontainer/devzone
CHANGED
|
@@ -169,9 +169,6 @@ case "${1:-}" in
|
|
|
169
169
|
# writing anything
|
|
170
170
|
[ "$(value_of "$2")" = on ]
|
|
171
171
|
;;
|
|
172
|
-
agent)
|
|
173
|
-
bash "$ICI/agent.sh" "${@:2}"
|
|
174
|
-
;;
|
|
175
172
|
ai)
|
|
176
173
|
case "${2:-}" in
|
|
177
174
|
check)
|
|
@@ -208,7 +205,7 @@ case "${1:-}" in
|
|
|
208
205
|
cluster) change_cluster "${@:2}" ;;
|
|
209
206
|
# Go only: reached when the binary did not take the call. Never call
|
|
210
207
|
# "devzone" again from here, it would loop forever, see #864
|
|
211
|
-
postgres | mysql | gitlab | test-gitlab)
|
|
208
|
+
agent | postgres | mysql | gitlab | test-gitlab)
|
|
212
209
|
echo "devzone $1: Go binary of the pod unavailable (.devcontainer/bin)" >&2
|
|
213
210
|
exit 1
|
|
214
211
|
;;
|
package/README.md
CHANGED
|
@@ -357,7 +357,7 @@ A project's user owns **its** database (it creates tables, indexes, data in it)
|
|
|
357
357
|
|
|
358
358
|
## See my application in the browser
|
|
359
359
|
|
|
360
|
-
On the Kubernetes workstation, `devzone workspace start` starts a port watcher: each TCP port ≥ 1024 that listens in the pod is relayed to `127.0.0.1` of the workstation, at the same number, by `kubectl port-forward`. A server started in the pod (`npm run dev`, port 5173) therefore answers at `http://localhost:5173`, without a command. The enabled services (PostgreSQL, MySQL, Argo CD) are relayed too, on their usual port. The Services of applications deployed in the cluster are relayed the same way, each on a local port (80 → 8080; a port already taken elsewhere becomes another port): `devzone workspace ports status` shows their URL `http://127.0.0.1:<port>`. A Service can be excluded with the annotation `devzone.io/relay: "false"`. The watcher is driven with `devzone workspace ports start|stop|status`; details in the [reference](manage/docs/reference.md#applications-and-services-on-the-workstations-localhost).
|
|
360
|
+
On the Kubernetes workstation, `devzone workspace start` starts a port watcher: each TCP port ≥ 1024 that listens in the pod is relayed to `127.0.0.1` of the workstation, at the same number, by `kubectl port-forward`. A server started in the pod (`npm run dev`, port 5173) therefore answers at `http://localhost:5173`, without a command. The enabled services (PostgreSQL, MySQL, Argo CD) are relayed too, on their usual port. The Services of applications deployed in the cluster are relayed the same way, each on a local port (80 → 8080; a port already taken elsewhere becomes another port): `devzone workspace ports status` shows their URL `http://127.0.0.1:<port>`. A Service can be excluded with the annotation `devzone.io/relay: "false"`. The watcher is driven with `devzone workspace ports start|stop|status`; details in the [reference](manage/docs/reference.md#applications-and-services-on-the-workstations-localhost). Its automatic start needs no command: the Go program installs or repairs it after a folder creation, an update or any successful devzone command from a devzone folder, silently once it is current. `devzone workspace ports disable` and `devzone uninstall` remember the refusal in `.devzone.ports-disabled` in that folder; `devzone workspace ports enable` removes the marker.
|
|
361
361
|
|
|
362
362
|
The relays kept in the state of a workstation instance are listed and closed with `devzone port`:
|
|
363
363
|
|
package/bin/SHA256SUMS
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
9b7d99ffa3a8420bca697c1c568f04ae4a282a71ea3d9f37202a02fc46601050 devzone-linux-amd64
|
|
2
|
+
d2e87e6498668026ad8591475cb0336af72a8aef845f235fb5466ca121cd50ff devzone-linux-arm64
|
|
3
|
+
c2a71b049e542c41ec627cd773f5ebdea676c4d2a5e3f02271fe04610245e3b9 devzone-darwin-amd64
|
|
4
|
+
e615af41aba2eb1e4b3d4a9d7bd7e7423f793bb72319c5fe7e96ff0e3221eb2d devzone-darwin-arm64
|
|
5
|
+
d6a3251e678bd5a35239d175ef7024be585602118cb85dc78d91ba3e94d74224 devzone-windows-amd64.exe
|
|
6
|
+
e82d667af1d00c9e8eebc96fa1a039b8032fa0d20ab51eea95dbc8abf75328e9 devzone-windows-arm64.exe
|
package/bin/devzone-darwin-amd64
CHANGED
|
Binary file
|
package/bin/devzone-darwin-arm64
CHANGED
|
Binary file
|
package/bin/devzone-linux-amd64
CHANGED
|
Binary file
|
package/bin/devzone-linux-arm64
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,156 +0,0 @@
|
|
|
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 state --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_COUNTRY_EXCLUSION), the others 1 h.
|
|
39
|
-
exclusion_duration() {
|
|
40
|
-
case "$1" in
|
|
41
|
-
pays) echo "${DEVZONE_AGENT_COUNTRY_EXCLUSION:-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_STATE/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_STATE/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_STATE/ecart-$1"
|
|
70
|
-
if [ ! -f "$f" ]; then f="$AGENT_STATE/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_NETWORK_STEP s, for
|
|
82
|
-
# DEVZONE_AGENT_NETWORK_MAX s at most. Returns 0 when it is back.
|
|
83
|
-
network_wait() {
|
|
84
|
-
local end
|
|
85
|
-
end=$(( $(date +%s) + ${DEVZONE_AGENT_NETWORK_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_NETWORK_STEP:-30}"
|
|
93
|
-
done
|
|
94
|
-
return 1
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
# Lists the current exclusions for devzone agent state (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_STATE"/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_STATE"/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 (--all): devzone agent release.
|
|
121
|
-
exclusion_clear() {
|
|
122
|
-
case "$1" in
|
|
123
|
-
--all) rm -f "$AGENT_STATE"/ecart-* "$AGENT_STATE"/muet-* ;;
|
|
124
|
-
*) rm -f "$AGENT_STATE/ecart-$1" "$AGENT_STATE/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
|
-
# Errors from the title model (agent=title) are ignored, as they say nothing about
|
|
132
|
-
# the model that is working.
|
|
133
|
-
error_lines() {
|
|
134
|
-
printf '%s\n' "$1" | sed -e $'s/\033\[[0-9;]*m//g' | grep -a -E '^timestamp=.* level=ERROR ' | grep -a -v ' agent=title ' || true
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
# Stops the current session when the journal holds quota, country or filter since
|
|
138
|
-
# its start: the model is excluded and the session is killed (process and children).
|
|
139
|
-
session_fatal_error() {
|
|
140
|
-
local pid="$1" journal="$2" offset="$3" m="$4" folder="$5"
|
|
141
|
-
local output cause
|
|
142
|
-
output="$(tail -c "+$(( offset + 1 ))" "$journal" 2>/dev/null || true)"
|
|
143
|
-
cause="$(error_cause "$(error_lines "$output")")"
|
|
144
|
-
case "$cause" in
|
|
145
|
-
quota | pays | filtre) ;;
|
|
146
|
-
*) return 1 ;;
|
|
147
|
-
esac
|
|
148
|
-
pkill -P "$pid" 2>/dev/null || true
|
|
149
|
-
kill "$pid" 2>/dev/null || true
|
|
150
|
-
wait "$pid" 2>/dev/null || true
|
|
151
|
-
rights_verify "$folder"
|
|
152
|
-
model_exclude "$m" "$cause"
|
|
153
|
-
model_requested_excluded "$m" "$cause" "$journal"
|
|
154
|
-
printf '%s\n' "=== opencode/$m excluded ($(cause_label "$cause")): next model" >>"$journal"
|
|
155
|
-
return 0
|
|
156
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Local model in the rotation of devzone agent (#586), sourced by agent.sh.
|
|
3
|
-
# The local slot is the host model when Ollama answers /api/tags with at least
|
|
4
|
-
# one model (reference devzone-host/<model>). It always comes after every online
|
|
5
|
-
# model; its internal name has no slash (an ecart-<name> file is written for it);
|
|
6
|
-
# opencode gets the reference.
|
|
7
|
-
# Real host model name (Ollama) chosen for this attempt, empty otherwise.
|
|
8
|
-
LOCAL_HOST_REAL=""
|
|
9
|
-
# Internal (slash-free) name of the host model chosen for this attempt.
|
|
10
|
-
LOCAL_HOST_INTERNAL=""
|
|
11
|
-
|
|
12
|
-
# shellcheck source=SCRIPTDIR/ai/host-models.sh
|
|
13
|
-
# shellcheck disable=SC1091
|
|
14
|
-
. "$ICI/ai/host-models.sh"
|
|
15
|
-
|
|
16
|
-
# Sanitizes a model name into an internal name: every character outside
|
|
17
|
-
# [A-Za-z0-9._-] becomes '_'. Used for ecart-<name> files, the journal and
|
|
18
|
-
# the rotation, so a host model such as hf.co/org/model:tag never creates a
|
|
19
|
-
# nested or invalid path.
|
|
20
|
-
internal_name() {
|
|
21
|
-
printf '%s' "$1" | sed 's/[^A-Za-z0-9._-]/_/g'
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
# Sets LOCAL_MODEL for this attempt, read by model_at_rank and
|
|
25
|
-
# models_total. Also records the real host model name when the host is chosen.
|
|
26
|
-
local_charge() {
|
|
27
|
-
local nom
|
|
28
|
-
LOCAL_MODEL=""
|
|
29
|
-
LOCAL_HOST_REAL=""
|
|
30
|
-
LOCAL_HOST_INTERNAL=""
|
|
31
|
-
nom="$(premier 2>/dev/null || true)"
|
|
32
|
-
[ -n "$nom" ] || return 0
|
|
33
|
-
LOCAL_HOST_REAL="$nom"
|
|
34
|
-
LOCAL_HOST_INTERNAL="$(internal_name "$nom")"
|
|
35
|
-
LOCAL_MODEL="$LOCAL_HOST_INTERNAL"
|
|
36
|
-
return 0
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
# Model reference given to opencode -m
|
|
40
|
-
model_ref() {
|
|
41
|
-
if [ -n "$LOCAL_HOST_INTERNAL" ] && [ "$1" = "$LOCAL_HOST_INTERNAL" ]; then
|
|
42
|
-
echo "devzone-host/$LOCAL_HOST_REAL"
|
|
43
|
-
else
|
|
44
|
-
echo "opencode/$1"
|
|
45
|
-
fi
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
# Model of rank $1 in the attempt that starts at $2: online ones in rotation,
|
|
49
|
-
# then the local host model
|
|
50
|
-
model_at_rank() {
|
|
51
|
-
if [ "$1" -lt "${#FREE_MODELS[@]}" ]; then
|
|
52
|
-
echo "${FREE_MODELS[$(( ($2 + $1) % ${#FREE_MODELS[@]} ))]}"
|
|
53
|
-
else
|
|
54
|
-
echo "$LOCAL_MODEL"
|
|
55
|
-
fi
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
# Number of models to try: the online ones, plus the local host model if ready
|
|
59
|
-
models_total() {
|
|
60
|
-
local total="${#FREE_MODELS[@]}"
|
|
61
|
-
[ -n "$LOCAL_MODEL" ] && total=$((total + 1))
|
|
62
|
-
echo "$total"
|
|
63
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Models asked with devzone agent --model (#420): list check, attempt order
|
|
3
|
-
# (requested models first, then the usual rotation) and the shared rank rule.
|
|
4
|
-
# Library sourced by agent.sh: no command is launched here.
|
|
5
|
-
|
|
6
|
-
# Journal and refusal texts, printf formats.
|
|
7
|
-
# shellcheck source=SCRIPTDIR/agent-model.messages disable=SC1091
|
|
8
|
-
. "$ICI/agent-model.messages"
|
|
9
|
-
|
|
10
|
-
# Option --model as typed (comma-separated list), empty when absent.
|
|
11
|
-
MODEL_LIST=""
|
|
12
|
-
# Requested models, in order, checked by models_load.
|
|
13
|
-
MODELS_REQUESTED=()
|
|
14
|
-
# Attempt order of the session (internal names), set by model_order.
|
|
15
|
-
ORDER=()
|
|
16
|
-
|
|
17
|
-
# Refuses a name missing from the free models: nothing is launched (code 2).
|
|
18
|
-
refuse_model() {
|
|
19
|
-
# shellcheck disable=SC2059 # the format comes from agent-model.messages
|
|
20
|
-
printf "$MSG_UNKNOWN\n" "$1" >&2
|
|
21
|
-
printf ' %s\n' "${FREE_MODELS[@]}" >&2
|
|
22
|
-
exit 2
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
# Loads the free models, checks the --model list and writes its header to the
|
|
26
|
-
# journal $1: the last header tells devzone agent state what was asked.
|
|
27
|
-
models_load() {
|
|
28
|
-
local journal="$1" m nom
|
|
29
|
-
FREE_MODELS=()
|
|
30
|
-
while IFS= read -r m; do
|
|
31
|
-
if [ -n "$m" ]; then FREE_MODELS+=("$m"); fi
|
|
32
|
-
done < <(list_models)
|
|
33
|
-
[ "${#FREE_MODELS[@]}" -gt 0 ] || refuse "$MSG_NO_MODEL"
|
|
34
|
-
MODELS_REQUESTED=()
|
|
35
|
-
if [ -n "$MODEL_LIST" ]; then
|
|
36
|
-
while IFS= read -r nom; do
|
|
37
|
-
case " ${FREE_MODELS[*]} " in
|
|
38
|
-
*" $nom "*) MODELS_REQUESTED+=("$nom") ;;
|
|
39
|
-
*) refuse_model "$nom" ;;
|
|
40
|
-
esac
|
|
41
|
-
done < <(printf '%s\n' "$MODEL_LIST" | tr ',' '\n')
|
|
42
|
-
fi
|
|
43
|
-
echo "=== --model : ${MODEL_LIST:-none}" >>"$journal"
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
# True when model $1 was asked with --model.
|
|
47
|
-
model_requested_p() {
|
|
48
|
-
case " ${MODELS_REQUESTED[*]:-} " in
|
|
49
|
-
*" $1 "*) return 0 ;;
|
|
50
|
-
esac
|
|
51
|
-
return 1
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
# Journal line when requested model $1 starts; other models get no line.
|
|
55
|
-
model_requested_chosen() {
|
|
56
|
-
if model_requested_p "$1"; then
|
|
57
|
-
# shellcheck disable=SC2059 # the format comes from agent-model.messages
|
|
58
|
-
printf "$MSG_CHOSEN\n" "$1" >>"$2"
|
|
59
|
-
fi
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
# Journal line when requested model $1 is excluded for cause $2, written to the
|
|
63
|
-
# journal $3. Other models keep their own lines.
|
|
64
|
-
model_requested_excluded() {
|
|
65
|
-
if model_requested_p "$1"; then
|
|
66
|
-
# shellcheck disable=SC2059 # the format comes from agent-model.messages
|
|
67
|
-
printf "$MSG_EXCLUDED\n" "$1" "$2" >>"$3"
|
|
68
|
-
fi
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
# Cause of the current exclusion of model $1: ecart-<model> gives it, muet-<model>
|
|
72
|
-
# has none and counts as muet.
|
|
73
|
-
model_exclusion_cause() {
|
|
74
|
-
local f cause=""
|
|
75
|
-
f="$AGENT_STATE/ecart-$1"
|
|
76
|
-
if [ ! -f "$f" ]; then f="$AGENT_STATE/muet-$1"; fi
|
|
77
|
-
if [ -f "$f" ]; then read -r _ cause _ <"$f" || true; fi
|
|
78
|
-
echo "${cause:-muet}"
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
# Adds model $1 to ORDER unless it is already there.
|
|
82
|
-
order_add() {
|
|
83
|
-
case " ${ORDER[*]:-} " in
|
|
84
|
-
*" $1 "*) ;;
|
|
85
|
-
*) ORDER+=("$1") ;;
|
|
86
|
-
esac
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
# Attempt order of the session from rank $1: requested models in their order,
|
|
90
|
-
# then the usual rotation (online models, then the local one). Each model
|
|
91
|
-
# appears once, so the rotation never tries again a requested model.
|
|
92
|
-
model_order() {
|
|
93
|
-
local start="$1" total i k
|
|
94
|
-
ORDER=()
|
|
95
|
-
for ((k = 0; k < ${#MODELS_REQUESTED[@]}; k++)); do
|
|
96
|
-
order_add "${MODELS_REQUESTED[$k]}"
|
|
97
|
-
done
|
|
98
|
-
total="$(models_total)"
|
|
99
|
-
for ((i = 0; i < total; i++)); do
|
|
100
|
-
order_add "$(model_at_rank "$i" "$start")"
|
|
101
|
-
done
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
# True when the shared rank may advance: no requested model is available.
|
|
105
|
-
# A requested model that starts leaves the rank alone, so the rotation of the
|
|
106
|
-
# other sessions does not move.
|
|
107
|
-
model_rank_advance() {
|
|
108
|
-
local k
|
|
109
|
-
for ((k = 0; k < ${#MODELS_REQUESTED[@]}; k++)); do
|
|
110
|
-
if ! model_excluded "${MODELS_REQUESTED[$k]}"; then return 1; fi
|
|
111
|
-
done
|
|
112
|
-
return 0
|
|
113
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Egress proxy helpers for the ephemeral session pod (#220).
|
|
3
|
-
# Sourced by agent-pod-manifest.sh. bash 3.2 compatible ; shellcheck -x clean.
|
|
4
|
-
|
|
5
|
-
agent_pod_egress_mode() {
|
|
6
|
-
kubectl get service -l app.kubernetes.io/component=egress-proxy \
|
|
7
|
-
-o jsonpath='{.items[0].metadata.labels.devzone\.io/egress-mode}' 2>/dev/null || true
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
agent_pod_egress_manifest_lines() {
|
|
11
|
-
local mode="$1"
|
|
12
|
-
[ -n "$mode" ] || return 0
|
|
13
|
-
printf '%s\n' " - name: HTTP_PROXY"
|
|
14
|
-
printf '%s\n' " value: \"http://egress-proxy:3128\""
|
|
15
|
-
printf '%s\n' " - name: HTTPS_PROXY"
|
|
16
|
-
printf '%s\n' " value: \"http://egress-proxy:3128\""
|
|
17
|
-
printf '%s\n' " - name: NO_PROXY"
|
|
18
|
-
printf '%s\n' " value: \"localhost,127.0.0.1,.svc,.cluster.local\""
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
agent_pod_egress_init_lines() {
|
|
22
|
-
local mode="$1" ws_image="$2"
|
|
23
|
-
[ "$mode" = "strict" ] || return 0
|
|
24
|
-
printf '%s\n' " initContainers:"
|
|
25
|
-
printf '%s\n' " - name: wait-egress-restriction"
|
|
26
|
-
printf '%s\n' " image: ${ws_image}"
|
|
27
|
-
printf '%s\n' " command: [\"/bin/bash\", \"-lc\"]"
|
|
28
|
-
printf '%s\n' " args:"
|
|
29
|
-
printf '%s\n' " - 'i=0; while [ \$i -lt 20 ]; do if ! curl --noproxy \"*\" -m 3 -sS https://opencode.ai >/dev/null 2>&1; then exit 0; fi; i=\$((i+1)); sleep 1; done; echo \"egress restriction never became effective: session refused\" >&2; exit 1'"
|
|
30
|
-
printf '%s\n' " securityContext:"
|
|
31
|
-
printf '%s\n' " runAsUser: 1000"
|
|
32
|
-
printf '%s\n' " runAsGroup: 1000"
|
|
33
|
-
printf '%s\n' " allowPrivilegeEscalation: false"
|
|
34
|
-
printf '%s\n' " capabilities:"
|
|
35
|
-
printf '%s\n' " drop: [\"ALL\"]"
|
|
36
|
-
}
|