The checkpoint status/relink-env armed probe calls GET /users/info, which requires Dolibarr right 251 (user->user->lire). WRITE_IDS didn't include it, so a freshly provisioned agent answered 403 on the probe — reported NOT armed — while its key actually authenticates (GET /thirdparties -> 200). Right 251 was granted live in SQL on the sandbox (fk_user=4) today; this persists it in WRITE_IDS so every future provision grants it. Also teach both probes to tell the failure modes apart instead of one opaque message: 401 = key rejected (stale/instance-encrypted -> re-provision), 403 = key OK but right 251 missing (-> grant it / re-provision), 200 = armed. Docs updated accordingly (checkpoint SKILL.md probe outcomes, sandbox-write SKILL.md gotcha, test/README.md rights table synced to WRITE_IDS incl. 262/111). Co-Authored-By: Claude Fable 5 <[email protected]>
37 lines
1.7 KiB
Bash
Executable File
37 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# (Re)write the dolibarr-sandbox-write skill .env from the provisioned key file,
|
|
# then verify it authenticates. Run this after 'provision' (or any time the key
|
|
# changed). The key is instance-encrypted per Dolibarr instance, so a refresh
|
|
# invalidates it — re-provision first if this fails to authenticate.
|
|
set -euo pipefail
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
ROOT="${ARCO_ROOT:-$(cd "${SCRIPT_DIR}/../../../.." && pwd)}"
|
|
SB_URL="${DOLIBARR_SANDBOX_URL:-https://erp-sandbox.arcodange.lab}"
|
|
KEY="${ROOT}/test/.ai_agent_sandbox.key"
|
|
ENV="${ROOT}/.claude/skills/dolibarr-sandbox-write/.env"
|
|
DOLW="${ROOT}/.claude/skills/dolibarr-sandbox-write/scripts/dol-write.sh"
|
|
|
|
[[ -s "${KEY}" ]] || { echo "checkpoint-relink-env: no key at ${KEY}" >&2
|
|
echo " run 'arcodange sandbox checkpoint provision' first." >&2; exit 1; }
|
|
|
|
umask 077
|
|
{ echo "DOLIBARR_SANDBOX_URL=${SB_URL}"
|
|
printf 'DOLIBARR_SANDBOX_API_KEY=%s\n' "$(tr -d '\r\n' < "${KEY}")"; } > "${ENV}"
|
|
chmod 600 "${ENV}"
|
|
echo "✓ wrote ${ENV} (mode 600)"
|
|
|
|
printf 'verify: '
|
|
"${DOLW}" GET /users/info | python3 -c "import json,sys
|
|
d = json.load(sys.stdin)
|
|
if isinstance(d, dict) and d.get('login'):
|
|
print('OK — armed as %s (id %s)' % (d['login'], d.get('id'))); sys.exit(0)
|
|
err = d.get('error', {}) if isinstance(d, dict) else {}
|
|
code = str(err.get('code', ''))
|
|
if code == '401':
|
|
print('FAILED — 401 key rejected (stale/instance-encrypted) → re-run checkpoint provision')
|
|
elif code == '403':
|
|
print('FAILED — 403 key authenticates but right 251 (user lire) is missing → re-provision or grant 251 (WRITE_IDS, test/provisionSandbox.ts)')
|
|
else:
|
|
print('FAILED — %s' % (err.get('message', '?') if isinstance(d, dict) else str(d)))
|
|
sys.exit(1)"
|