Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- ar_aging_001/_cua_gym_vm_bridge.sh +106 -0
- ar_aging_001/initial_setup.py +200 -0
- ar_aging_001/reward.py +226 -0
- ar_aging_001/reward_label.json +67 -0
- ar_invoice_003/_cua_gym_vm_bridge.sh +106 -0
- ar_invoice_003/reward_label.json +49 -0
- fin_expense_claim_002__long__cond/.PLACEHOLDER +5 -0
- fin_expense_claim_002__long__cond/0a7fc64f-9ca0-54e1-90d0-9bdb1fea4b10_oa_server.py +779 -0
- fin_expense_claim_002__long__cond/5cb11caa-90fb-53cc-9f6b-1489523366db_manager_approval.pdf +74 -0
- fin_expense_claim_002__long__cond/999fca2d-ceec-581b-9623-500d62780607_invoice_1.pdf +80 -0
- fin_expense_claim_002__long__cond/c97f91fe-8f04-5f0f-a397-971c012d254d_invoice_2.pdf +80 -0
- fin_expense_claim_002__long__cond/ce9481c5-7ab8-50e7-a97b-0f4f833ad690_justification.txt +12 -0
- hr_onboarding_checklist_004/_cua_gym_vm_bridge.sh +106 -0
- hr_onboarding_checklist_004/initial_setup.py +220 -0
- hr_onboarding_checklist_004/reward.py +192 -0
- hr_onboarding_checklist_004/reward_label.json +50 -0
- img_contrast_002__long/.PLACEHOLDER +5 -0
- legacy/23a66d5f-baa6-5303-a1d6-6275229ebfa9/_cua_gym_vm_bridge.sh +106 -0
- legacy/23a66d5f-baa6-5303-a1d6-6275229ebfa9/initial_setup.py +365 -0
- legacy/23a66d5f-baa6-5303-a1d6-6275229ebfa9/reward.py +129 -0
- legacy/23a66d5f-baa6-5303-a1d6-6275229ebfa9/reward_label.json +77 -0
- legacy/4619652a-02e6-5961-83df-6860dfb3ef29/_cua_gym_vm_bridge.sh +106 -0
- legacy/4619652a-02e6-5961-83df-6860dfb3ef29/initial_setup.py +327 -0
- legacy/4619652a-02e6-5961-83df-6860dfb3ef29/reward.py +116 -0
- legacy/4619652a-02e6-5961-83df-6860dfb3ef29/reward_label.json +71 -0
- legacy/57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f/_cua_gym_vm_bridge.sh +106 -0
- legacy/57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f/initial_setup.py +307 -0
- legacy/57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f/reward.py +146 -0
- legacy/57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f/reward_label.json +88 -0
- legacy/a91f29df-e380-5d54-b965-27aecef4d2b3/reward.py +112 -0
- legacy/ae_forecast_001/_cua_gym_vm_bridge.sh +106 -0
- legacy/ae_forecast_001/initial_setup.py +553 -0
- legacy/ae_forecast_001/reward.py +524 -0
- legacy/ae_forecast_001/reward_label.json +68 -0
- legacy/ae_meeting_followup_002/_cua_gym_vm_bridge.sh +106 -0
- legacy/ae_meeting_followup_002/initial_setup.py +576 -0
- legacy/ae_meeting_followup_002/reward.py +560 -0
- legacy/ae_meeting_followup_002/reward_label.json +75 -0
- legacy/am_renewal_cycle_004/_cua_gym_vm_bridge.sh +106 -0
- legacy/am_renewal_cycle_004/initial_setup.py +675 -0
- legacy/am_renewal_cycle_004/reward.py +0 -0
- legacy/am_renewal_cycle_004/reward_label.json +23 -0
- legacy/ar_collections_001/_cua_gym_vm_bridge.sh +106 -0
- legacy/ar_collections_001/initial_setup.py +186 -0
- legacy/ar_collections_001/reward.py +206 -0
- legacy/ar_collections_001/reward_label.json +84 -0
- legacy/beacea76-e300-578d-8dc9-5bf0f1a16d13/_cua_gym_vm_bridge.sh +106 -0
- legacy/beacea76-e300-578d-8dc9-5bf0f1a16d13/initial_setup.py +416 -0
- legacy/beacea76-e300-578d-8dc9-5bf0f1a16d13/reward.py +122 -0
- legacy/beacea76-e300-578d-8dc9-5bf0f1a16d13/reward_label.json +67 -0
ar_aging_001/_cua_gym_vm_bridge.sh
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# CUA-Gym VM-side network fix (direct-IP mock access).
|
| 3 |
+
#
|
| 4 |
+
# Runs INSIDE the QEMU guest. The CUA-Gym mock services are now reached by
|
| 5 |
+
# their real IDC address (http://28.7.184.198:81xx) instead of the old
|
| 6 |
+
# localhost:9000-9097 socat bridge, so the VM only needs two fixes:
|
| 7 |
+
#
|
| 8 |
+
# 1. Working DNS — the qcow2-baked /etc/resolv.conf points at the Pod's
|
| 9 |
+
# cluster DNS, which is unreachable from QEMU SLIRP NAT
|
| 10 |
+
# ("Temporary failure in name resolution").
|
| 11 |
+
# 2. The mock host excluded from the woa http proxy — otherwise the VM's
|
| 12 |
+
# Chrome (gsettings proxy) and initial_setup.py's `requests` get a 403
|
| 13 |
+
# from the proxy when hitting 28.7.184.198:81xx. (The old socat path never
|
| 14 |
+
# hit this because localhost is bypassed by default.)
|
| 15 |
+
#
|
| 16 |
+
# Idempotent. Scoped to the CUA-Gym bridge step; does not touch the generic
|
| 17 |
+
# OSWorld setup pipeline.
|
| 18 |
+
#
|
| 19 |
+
# Argv:
|
| 20 |
+
# $1 optional sudo password (default "password"; SetupController
|
| 21 |
+
# substitutes {CLIENT_PASSWORD} when uploaded as a cache file).
|
| 22 |
+
# $2 unused (kept for backward compat — was socat first port 9000).
|
| 23 |
+
# $3 unused (kept for backward compat — was socat last port 9097).
|
| 24 |
+
# $4 optional mock host IP (default 28.7.184.198).
|
| 25 |
+
|
| 26 |
+
set +e
|
| 27 |
+
|
| 28 |
+
PASS="${1:-password}"
|
| 29 |
+
MOCK_HOST="${4:-28.7.184.198}"
|
| 30 |
+
# Derive the /16 IDC subnet so future port/host tweaks on the same segment
|
| 31 |
+
# stay bypassed too (28.7.184.198 -> 28.7.0.0/16).
|
| 32 |
+
MOCK_NET="$(echo "${MOCK_HOST}" | awk -F. 'NF==4{print $1"."$2".0.0/16"}')"
|
| 33 |
+
|
| 34 |
+
run_root() {
|
| 35 |
+
echo "$PASS" | sudo -S -p "" bash -c "$1"
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
# Detect SLIRP gateway from VM's routing table; fall back to 10.0.2.2.
|
| 39 |
+
GW="$(ip route 2>/dev/null | awk '/default/ {print $3; exit}')"
|
| 40 |
+
GW="${GW:-10.0.2.2}"
|
| 41 |
+
|
| 42 |
+
# ─── CUA-Gym network fix (Taiji-specific) ─────────────────────────────
|
| 43 |
+
fix_vm_network() {
|
| 44 |
+
# 0) Discover VM network state at runtime — gateway, own IP/CIDR, SLIRP
|
| 45 |
+
# DNS forwarder. Nothing hardcoded except the mock host above.
|
| 46 |
+
local GW_NET="${GW%.*}"
|
| 47 |
+
local SLIRP_DNS="${GW_NET}.3" # QEMU SLIRP DNS proxy is always .3
|
| 48 |
+
local OWN_CIDR
|
| 49 |
+
OWN_CIDR="$(ip -4 -o addr show scope global 2>/dev/null \
|
| 50 |
+
| awk '{print $4; exit}')"
|
| 51 |
+
local OWN_IP="${OWN_CIDR%/*}"
|
| 52 |
+
local OWN_NET=""
|
| 53 |
+
[ -n "${OWN_IP}" ] && OWN_NET="${OWN_IP%.*}.0/24"
|
| 54 |
+
|
| 55 |
+
# 1) DNS — point at SLIRP DNS proxy + public fallbacks. chattr +i keeps
|
| 56 |
+
# systemd-resolved/NetworkManager from clobbering it.
|
| 57 |
+
if run_root "printf 'nameserver ${SLIRP_DNS}\\nnameserver 114.114.114.114\\nnameserver 8.8.8.8\\n' > /etc/resolv.conf
|
| 58 |
+
chattr +i /etc/resolv.conf 2>/dev/null || true"; then
|
| 59 |
+
echo "[cua_gym_vm_bridge] DNS set: ${SLIRP_DNS}, 114.114.114.114, 8.8.8.8 (gw=${GW})"
|
| 60 |
+
else
|
| 61 |
+
echo "[cua_gym_vm_bridge] WARN: failed to write /etc/resolv.conf"
|
| 62 |
+
fi
|
| 63 |
+
|
| 64 |
+
# 2) Build the proxy bypass list from detected values + the direct-IP
|
| 65 |
+
# mock host (and its /16 subnet). THIS is what makes 28.7.184.198:81xx
|
| 66 |
+
# reachable from inside the VM — without it the woa proxy 403s it.
|
| 67 |
+
local ignore_list="['localhost', '127.0.0.0/8', '${GW}'"
|
| 68 |
+
[ -n "${OWN_IP}" ] && ignore_list="${ignore_list}, '${OWN_IP}'"
|
| 69 |
+
[ -n "${OWN_NET}" ] && ignore_list="${ignore_list}, '${OWN_NET}'"
|
| 70 |
+
[ -n "${GW_NET}" ] && ignore_list="${ignore_list}, '${GW_NET}.0/24'"
|
| 71 |
+
[ -n "${MOCK_HOST}" ] && ignore_list="${ignore_list}, '${MOCK_HOST}'"
|
| 72 |
+
[ -n "${MOCK_NET}" ] && ignore_list="${ignore_list}, '${MOCK_NET}'"
|
| 73 |
+
ignore_list="${ignore_list}]"
|
| 74 |
+
|
| 75 |
+
# 3) GNOME proxy ignore-hosts — Chrome bypasses the woa proxy for these.
|
| 76 |
+
if gsettings set org.gnome.system.proxy ignore-hosts "${ignore_list}" 2>/tmp/gsettings_err; then
|
| 77 |
+
echo "[cua_gym_vm_bridge] gsettings ignore-hosts = ${ignore_list}"
|
| 78 |
+
else
|
| 79 |
+
echo "[cua_gym_vm_bridge] WARN: gsettings ignore-hosts failed: $(cat /tmp/gsettings_err 2>/dev/null)"
|
| 80 |
+
fi
|
| 81 |
+
|
| 82 |
+
# 4) Shell env — comma-separated form for no_proxy/NO_PROXY (requests/curl).
|
| 83 |
+
local NP="localhost,127.0.0.1,${GW}"
|
| 84 |
+
[ -n "${OWN_IP}" ] && NP="${NP},${OWN_IP}"
|
| 85 |
+
[ -n "${OWN_NET}" ] && NP="${NP},${OWN_NET}"
|
| 86 |
+
[ -n "${GW_NET}" ] && NP="${NP},${GW_NET}.0/24"
|
| 87 |
+
[ -n "${MOCK_HOST}" ] && NP="${NP},${MOCK_HOST}"
|
| 88 |
+
[ -n "${MOCK_NET}" ] && NP="${NP},${MOCK_NET}"
|
| 89 |
+
|
| 90 |
+
for var in no_proxy NO_PROXY; do
|
| 91 |
+
if ! grep -q "export ${var}=${NP}" /home/user/.bashrc 2>/dev/null; then
|
| 92 |
+
echo "export ${var}=${NP}" >> /home/user/.bashrc
|
| 93 |
+
fi
|
| 94 |
+
done
|
| 95 |
+
run_root "grep -q '^no_proxy=' /etc/environment 2>/dev/null \
|
| 96 |
+
&& sed -i 's|^no_proxy=.*|no_proxy=\"${NP}\"|' /etc/environment \
|
| 97 |
+
|| echo 'no_proxy=\"${NP}\"' >> /etc/environment
|
| 98 |
+
grep -q '^NO_PROXY=' /etc/environment 2>/dev/null \
|
| 99 |
+
&& sed -i 's|^NO_PROXY=.*|NO_PROXY=\"${NP}\"|' /etc/environment \
|
| 100 |
+
|| echo 'NO_PROXY=\"${NP}\"' >> /etc/environment" >/dev/null 2>&1
|
| 101 |
+
echo "[cua_gym_vm_bridge] no_proxy=${NP}"
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
fix_vm_network
|
| 105 |
+
|
| 106 |
+
echo "[cua_gym_vm_bridge] direct-IP mode: ${MOCK_HOST} (+${MOCK_NET}) bypassed from woa proxy; no socat forwarding needed"
|
ar_aging_001/initial_setup.py
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Initial Setup: AR aging snapshot — build aging summary in Google Sheets + post to Slack #finance
|
| 3 |
+
Task ID: ar_aging_001
|
| 4 |
+
Domain: mock_websites (google_sheets_mock + slack_mock)
|
| 5 |
+
|
| 6 |
+
Pre-task state:
|
| 7 |
+
- Google Sheet 'AR Invoice Ledger' with 8 unpaid invoices (rows 2-9) plus a few
|
| 8 |
+
paid rows, fixed columns A..H. NO summary block below the data.
|
| 9 |
+
- Slack workspace with a #finance channel. NO AR aging message posted yet.
|
| 10 |
+
"""
|
| 11 |
+
import os
|
| 12 |
+
import shlex
|
| 13 |
+
import subprocess
|
| 14 |
+
import time
|
| 15 |
+
import uuid
|
| 16 |
+
|
| 17 |
+
import requests
|
| 18 |
+
|
| 19 |
+
SHEETS_URL = 'http://28.7.184.198:8145'
|
| 20 |
+
SLACK_URL = 'http://28.7.184.198:8178'
|
| 21 |
+
|
| 22 |
+
sid = str(uuid.uuid4())
|
| 23 |
+
with open('/tmp/task_web_sid', 'w') as f:
|
| 24 |
+
f.write(sid)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
# ---------------------------------------------------------------------------
|
| 28 |
+
# Google Sheets initial state — AR Invoice Ledger
|
| 29 |
+
# ---------------------------------------------------------------------------
|
| 30 |
+
def build_sheets_state():
|
| 31 |
+
headers = ['Invoice #', 'Customer', 'Deal/Contract', 'Amount',
|
| 32 |
+
'Issue Date', 'Due Date', 'Status', 'AE/Owner']
|
| 33 |
+
# Invoice rows: (inv, customer, deal, amount, issue, due, status, owner)
|
| 34 |
+
rows = [
|
| 35 |
+
['INV-2998', 'Stark Industries', 'Renewal FY25', 52000, '2026-02-01', '2026-03-03', 'Paid', 'Diane Wu'],
|
| 36 |
+
['INV-2999', 'Cyberdyne Systems', 'New Logo', 31000, '2026-02-10', '2026-03-12', 'Paid', 'Raj Patel'],
|
| 37 |
+
['INV-3000', 'Pied Piper', 'Expansion', 18500, '2026-03-01', '2026-03-31', 'Paid', 'Diane Wu'],
|
| 38 |
+
['INV-3001', 'Acme Corp', 'Platform Annual', 48000, '2026-06-10', '2026-07-10', 'Sent', 'Diane Wu'],
|
| 39 |
+
['INV-3002', 'Globex Inc', 'Support Tier 2', 24000, '2026-05-16', '2026-06-15', 'Overdue', 'Raj Patel'],
|
| 40 |
+
['INV-3003', 'Initech', 'Implementation', 72000, '2026-05-02', '2026-06-01', 'Overdue', 'Diane Wu'],
|
| 41 |
+
['INV-3004', 'Umbrella Health', 'Enterprise Suite', 115000, '2026-04-20', '2026-05-20', 'Overdue', 'Maria Lopez'],
|
| 42 |
+
['INV-3005', 'Soylent Foods', 'Data Add-on', 36500, '2026-04-10', '2026-05-10', 'Overdue', 'Raj Patel'],
|
| 43 |
+
['INV-3006', 'Vandelay Industries', 'Pilot', 15000, '2026-03-16', '2026-04-15', 'Overdue', 'Maria Lopez'],
|
| 44 |
+
['INV-3007', 'Wayne Enterprises', 'Security Bundle', 90000, '2026-06-01', '2026-07-01', 'Sent', 'Diane Wu'],
|
| 45 |
+
['INV-3008', 'Hooli', 'Cloud Migration', 63000, '2026-03-02', '2026-04-01', 'Overdue', 'Maria Lopez'],
|
| 46 |
+
]
|
| 47 |
+
|
| 48 |
+
def col_letter(idx): # 0 -> A
|
| 49 |
+
return chr(ord('A') + idx)
|
| 50 |
+
|
| 51 |
+
data = {}
|
| 52 |
+
# Header row (row 1), bold + light grey background
|
| 53 |
+
for c, h in enumerate(headers):
|
| 54 |
+
cell = f'{col_letter(c)}1'
|
| 55 |
+
data[cell] = {
|
| 56 |
+
'value': h, 'formula': h,
|
| 57 |
+
'style': {'bold': True, 'bg': '#E8EAED', 'align': 'center'},
|
| 58 |
+
}
|
| 59 |
+
# Data rows (rows 2..)
|
| 60 |
+
for r, row in enumerate(rows, start=2):
|
| 61 |
+
for c, val in enumerate(row):
|
| 62 |
+
cell = f'{col_letter(c)}{r}'
|
| 63 |
+
entry = {'value': str(val), 'formula': str(val)}
|
| 64 |
+
if c == 3: # Amount column -> currency
|
| 65 |
+
entry['format'] = 'currency'
|
| 66 |
+
elif c in (4, 5): # Issue / Due Date
|
| 67 |
+
entry['format'] = 'date'
|
| 68 |
+
data[cell] = entry
|
| 69 |
+
|
| 70 |
+
sheet = {
|
| 71 |
+
'id': 'sheet_1',
|
| 72 |
+
'name': 'AR Invoice Ledger',
|
| 73 |
+
'rowCount': 100,
|
| 74 |
+
'colCount': 26,
|
| 75 |
+
'frozenRows': 1,
|
| 76 |
+
'frozenCols': 0,
|
| 77 |
+
'tabColor': None,
|
| 78 |
+
'isHidden': False,
|
| 79 |
+
'columnWidths': {'0': 90, '1': 150, '2': 140, '3': 100, '4': 100, '5': 100, '6': 80, '7': 110},
|
| 80 |
+
'data': data,
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
return {
|
| 84 |
+
'id': 'workbook_1',
|
| 85 |
+
'title': 'AR Invoice Ledger',
|
| 86 |
+
'activeSheetId': 'sheet_1',
|
| 87 |
+
'selectedCell': 'A1',
|
| 88 |
+
'selectionRange': None,
|
| 89 |
+
'clipboard': None,
|
| 90 |
+
'isDragging': False,
|
| 91 |
+
'undoStack': [],
|
| 92 |
+
'redoStack': [],
|
| 93 |
+
'namedRanges': [],
|
| 94 |
+
'conditionalFormats': [],
|
| 95 |
+
'charts': [],
|
| 96 |
+
'showGridlines': True,
|
| 97 |
+
'showFormulas': False,
|
| 98 |
+
'zoom': 100,
|
| 99 |
+
'sheets': [sheet],
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
# ---------------------------------------------------------------------------
|
| 104 |
+
# Slack initial state — workspace with #finance channel, no AR message yet
|
| 105 |
+
# ---------------------------------------------------------------------------
|
| 106 |
+
def build_slack_state():
|
| 107 |
+
users = [
|
| 108 |
+
{'userId': 'user_1', 'fullName': 'Diane Wu', 'displayName': 'Diane',
|
| 109 |
+
'email': 'diane.wu@company.com', 'avatar': 'https://picsum.photos/200/200?random=1',
|
| 110 |
+
'title': 'AR Analyst', 'status': 'online', 'statusMessage': '', 'statusEmoji': '',
|
| 111 |
+
'timeZone': 'America/New_York'},
|
| 112 |
+
{'userId': 'user_2', 'fullName': 'Maria Lopez', 'displayName': 'Maria',
|
| 113 |
+
'email': 'maria.lopez@company.com', 'avatar': 'https://picsum.photos/200/200?random=2',
|
| 114 |
+
'title': 'Controller', 'status': 'online', 'statusMessage': '', 'statusEmoji': '',
|
| 115 |
+
'timeZone': 'America/New_York'},
|
| 116 |
+
{'userId': 'user_3', 'fullName': 'Raj Patel', 'displayName': 'Raj',
|
| 117 |
+
'email': 'raj.patel@company.com', 'avatar': 'https://picsum.photos/200/200?random=3',
|
| 118 |
+
'title': 'CFO', 'status': 'away', 'statusMessage': '', 'statusEmoji': '',
|
| 119 |
+
'timeZone': 'America/Los_Angeles'},
|
| 120 |
+
]
|
| 121 |
+
current_user = dict(users[0])
|
| 122 |
+
|
| 123 |
+
channels = [
|
| 124 |
+
{'channelId': 'general', 'name': 'general', 'description': 'Company-wide announcements',
|
| 125 |
+
'topic': '', 'isPrivate': False, 'isStarred': False, 'members': ['user_1', 'user_2', 'user_3'],
|
| 126 |
+
'createdBy': 'user_3', 'createdAt': '2026-01-01T09:00:00Z', 'pinnedMessages': [], 'unreadCount': 0},
|
| 127 |
+
{'channelId': 'finance', 'name': 'finance', 'description': 'Finance team — AR, AP, reporting',
|
| 128 |
+
'topic': 'Month-end close & receivables', 'isPrivate': False, 'isStarred': True,
|
| 129 |
+
'members': ['user_1', 'user_2', 'user_3'], 'createdBy': 'user_3',
|
| 130 |
+
'createdAt': '2026-01-02T09:00:00Z', 'pinnedMessages': [], 'unreadCount': 0},
|
| 131 |
+
{'channelId': 'random', 'name': 'random', 'description': 'Watercooler',
|
| 132 |
+
'topic': '', 'isPrivate': False, 'isStarred': False, 'members': ['user_1', 'user_2', 'user_3'],
|
| 133 |
+
'createdBy': 'user_1', 'createdAt': '2026-01-01T09:00:00Z', 'pinnedMessages': [], 'unreadCount': 0},
|
| 134 |
+
]
|
| 135 |
+
|
| 136 |
+
messages = {
|
| 137 |
+
'general': [
|
| 138 |
+
{'messageId': 'msg_g1', 'senderId': 'user_3',
|
| 139 |
+
'content': 'Reminder: finance review meeting Thursday at 2pm.',
|
| 140 |
+
'timestamp': '2026-06-22T15:00:00Z', 'threadId': None, 'reactions': [],
|
| 141 |
+
'attachments': [], 'isEdited': False},
|
| 142 |
+
],
|
| 143 |
+
'finance': [
|
| 144 |
+
{'messageId': 'msg_f1', 'senderId': 'user_2',
|
| 145 |
+
'content': 'Can someone pull the AR aging snapshot before the review?',
|
| 146 |
+
'timestamp': '2026-06-23T16:20:00Z', 'threadId': None, 'reactions': [],
|
| 147 |
+
'attachments': [], 'isEdited': False},
|
| 148 |
+
{'messageId': 'msg_f2', 'senderId': 'user_1',
|
| 149 |
+
'content': 'On it — will post bucket totals and the worst offenders shortly.',
|
| 150 |
+
'timestamp': '2026-06-23T16:25:00Z', 'threadId': None, 'reactions': [],
|
| 151 |
+
'attachments': [], 'isEdited': False},
|
| 152 |
+
],
|
| 153 |
+
'random': [],
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
return {
|
| 157 |
+
'currentUser': current_user,
|
| 158 |
+
'workspace': {'workspaceId': 'ws_1', 'workspaceName': 'Northwind Finance', 'icon': ''},
|
| 159 |
+
'users': users,
|
| 160 |
+
'channels': channels,
|
| 161 |
+
'messages': messages,
|
| 162 |
+
'threads': {},
|
| 163 |
+
'dms': [],
|
| 164 |
+
'bookmarkedMessages': [],
|
| 165 |
+
'callHistory': [],
|
| 166 |
+
'settings': {'theme': 'light', 'notifications': 'all', 'displayDensity': 'comfortable',
|
| 167 |
+
'showAvatars': True, 'use24Hour': False},
|
| 168 |
+
'invitations': [],
|
| 169 |
+
'notifications': [],
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
def inject(url, state):
|
| 174 |
+
resp = requests.post(f'{url}/post?sid={sid}',
|
| 175 |
+
json={'action': 'set', 'state': state}, timeout=30)
|
| 176 |
+
assert resp.status_code == 200, f'Inject failed for {url}: {resp.status_code} {resp.text}'
|
| 177 |
+
go = requests.get(f'{url}/go?sid={sid}', timeout=15).json()
|
| 178 |
+
assert go.get('initial_state') is not None, f'initial_state is None for {url}'
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
inject(SHEETS_URL, build_sheets_state())
|
| 182 |
+
print(f'Google Sheets state injected: sid={sid}')
|
| 183 |
+
inject(SLACK_URL, build_slack_state())
|
| 184 |
+
print(f'Slack state injected: sid={sid}')
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
# ---------------------------------------------------------------------------
|
| 188 |
+
# Launch browser (GUI-ready) — primary app is the Google Sheet
|
| 189 |
+
# ---------------------------------------------------------------------------
|
| 190 |
+
def launch_gui(command, delay_sec=1.0):
|
| 191 |
+
env = os.environ.copy()
|
| 192 |
+
env['DISPLAY'] = ':0'
|
| 193 |
+
subprocess.Popen(shlex.split(command), stdout=subprocess.DEVNULL,
|
| 194 |
+
stderr=subprocess.DEVNULL, env=env)
|
| 195 |
+
time.sleep(delay_sec)
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
launch_gui(f'google-chrome "{SHEETS_URL}/?sid={sid}"', delay_sec=2.0)
|
| 199 |
+
launch_gui(f'google-chrome "{SLACK_URL}/?sid={sid}"', delay_sec=1.0)
|
| 200 |
+
print(f'GUI_READY: launched Chrome for Sheets and Slack with sid={sid}')
|
ar_aging_001/reward.py
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Reward Script: AR aging snapshot — Google Sheets summary block + Slack #finance post
|
| 3 |
+
Task ID: ar_aging_001
|
| 4 |
+
Domain: mock_websites (google_sheets_mock + slack_mock)
|
| 5 |
+
|
| 6 |
+
Task: classify unpaid invoices into aging buckets, write a labeled summary block
|
| 7 |
+
below the ledger data totaling each bucket, then post the top three overdue
|
| 8 |
+
customers and total outstanding in Slack #finance.
|
| 9 |
+
|
| 10 |
+
Scoring (only task-introduced changes are scored; everything is derived from the
|
| 11 |
+
diff between initial_state and current_state of the SAME /go response, so the
|
| 12 |
+
initial_env — where current == initial — scores exactly 0.0):
|
| 13 |
+
|
| 14 |
+
Google Sheets (0.50):
|
| 15 |
+
- 4 aging-bucket totals appear in cells added below the ledger ......... 0.30 (0.075 each)
|
| 16 |
+
Current=138000, 1-30=96000, 31-60=151500, 60+=78000
|
| 17 |
+
- Total Outstanding (463500) appears in added cells .................... 0.20
|
| 18 |
+
|
| 19 |
+
Slack #finance (0.50):
|
| 20 |
+
- A new message was posted in #finance by user_1 ...................... 0.10
|
| 21 |
+
- Message lists the top three overdue customers + their balances ..... 0.25
|
| 22 |
+
Umbrella Health $115,000, Initech $72,000, Hooli $63,000
|
| 23 |
+
- Message states the total outstanding of $463,500 ................... 0.15
|
| 24 |
+
|
| 25 |
+
Total = 1.0
|
| 26 |
+
"""
|
| 27 |
+
import json
|
| 28 |
+
import re
|
| 29 |
+
import sys
|
| 30 |
+
|
| 31 |
+
import requests
|
| 32 |
+
|
| 33 |
+
GS_URL = 'http://28.7.184.198:8145'
|
| 34 |
+
SLACK_URL = 'http://28.7.184.198:8178'
|
| 35 |
+
|
| 36 |
+
# Ground-truth values from task context
|
| 37 |
+
BUCKETS = {
|
| 38 |
+
'Current': 138000.0,
|
| 39 |
+
'1-30': 96000.0,
|
| 40 |
+
'31-60': 151500.0,
|
| 41 |
+
'60+': 78000.0,
|
| 42 |
+
}
|
| 43 |
+
TOTAL_OUTSTANDING = 463500.0
|
| 44 |
+
TOP3 = {
|
| 45 |
+
'Umbrella Health': 115000.0,
|
| 46 |
+
'Initech': 72000.0,
|
| 47 |
+
'Hooli': 63000.0,
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def read_sid():
|
| 52 |
+
try:
|
| 53 |
+
with open('/tmp/task_web_sid') as f:
|
| 54 |
+
sid = f.read().strip()
|
| 55 |
+
if not sid:
|
| 56 |
+
raise ValueError('sid empty')
|
| 57 |
+
return sid
|
| 58 |
+
except Exception as e:
|
| 59 |
+
print(f'CRITICAL: cannot read sid: {e}')
|
| 60 |
+
return None
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def fetch(url, sid):
|
| 64 |
+
"""Fetch /go state for a mock. Returns (initial, current) or (None, None)."""
|
| 65 |
+
try:
|
| 66 |
+
resp = requests.get(f'{url}/go?sid={sid}', timeout=30)
|
| 67 |
+
resp.raise_for_status()
|
| 68 |
+
data = resp.json()
|
| 69 |
+
return data.get('initial_state'), data.get('current_state')
|
| 70 |
+
except Exception as e:
|
| 71 |
+
print(f'CRITICAL: cannot fetch {url}: {e}')
|
| 72 |
+
return None, None
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def to_number(v):
|
| 76 |
+
"""Parse a cell/text token into a float, stripping $ , and spaces. None if not numeric."""
|
| 77 |
+
if v is None:
|
| 78 |
+
return None
|
| 79 |
+
s = str(v).strip().replace('$', '').replace(',', '').replace(' ', '')
|
| 80 |
+
if s == '':
|
| 81 |
+
return None
|
| 82 |
+
try:
|
| 83 |
+
return float(s)
|
| 84 |
+
except ValueError:
|
| 85 |
+
return None
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def num_matches(value_set, target, tol=0.5):
|
| 89 |
+
return any(abs(n - target) <= tol for n in value_set)
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
def added_cell_numbers(initial, current):
|
| 93 |
+
"""
|
| 94 |
+
Collect numeric values from cells that were ADDED or CHANGED between
|
| 95 |
+
initial and current across all sheets. This guarantees pre-existing ledger
|
| 96 |
+
values are never counted, so the initial_env (current == initial) yields an
|
| 97 |
+
empty set.
|
| 98 |
+
"""
|
| 99 |
+
nums = []
|
| 100 |
+
|
| 101 |
+
def index_sheets(state):
|
| 102 |
+
idx = {}
|
| 103 |
+
for sh in (state or {}).get('sheets', []) or []:
|
| 104 |
+
idx[sh.get('id')] = sh.get('data', {}) or {}
|
| 105 |
+
return idx
|
| 106 |
+
|
| 107 |
+
init_idx = index_sheets(initial)
|
| 108 |
+
cur_idx = index_sheets(current)
|
| 109 |
+
|
| 110 |
+
for sid_, cur_data in cur_idx.items():
|
| 111 |
+
init_data = init_idx.get(sid_, {})
|
| 112 |
+
for cell_id, cell in cur_data.items():
|
| 113 |
+
init_cell = init_data.get(cell_id)
|
| 114 |
+
# Only consider cells that are new or whose value/computed changed
|
| 115 |
+
if init_cell is not None and init_cell == cell:
|
| 116 |
+
continue
|
| 117 |
+
# Prefer computed result of a formula, else raw value
|
| 118 |
+
n = to_number(cell.get('computed'))
|
| 119 |
+
if n is None:
|
| 120 |
+
n = to_number(cell.get('value'))
|
| 121 |
+
if n is None:
|
| 122 |
+
n = to_number(cell.get('formula'))
|
| 123 |
+
if n is not None:
|
| 124 |
+
nums.append(n)
|
| 125 |
+
return nums
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def new_finance_messages(initial, current):
|
| 129 |
+
"""Return list of message dicts present in current #finance but not in initial."""
|
| 130 |
+
def fin_msgs(state):
|
| 131 |
+
return ((state or {}).get('messages', {}) or {}).get('finance', []) or []
|
| 132 |
+
|
| 133 |
+
init_ids = {m.get('messageId') for m in fin_msgs(initial)}
|
| 134 |
+
return [m for m in fin_msgs(current) if m.get('messageId') not in init_ids]
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
def verify_task():
|
| 138 |
+
total_score = 0.0
|
| 139 |
+
|
| 140 |
+
sid = read_sid()
|
| 141 |
+
if not sid:
|
| 142 |
+
print('REWARD: 0.0')
|
| 143 |
+
return 0.0
|
| 144 |
+
|
| 145 |
+
gs_init, gs_cur = fetch(GS_URL, sid)
|
| 146 |
+
sl_init, sl_cur = fetch(SLACK_URL, sid)
|
| 147 |
+
if gs_cur is None or sl_cur is None:
|
| 148 |
+
print('REWARD: 0.0')
|
| 149 |
+
return 0.0
|
| 150 |
+
|
| 151 |
+
# ---------- Google Sheets: added cells only ----------
|
| 152 |
+
added_nums = added_cell_numbers(gs_init, gs_cur)
|
| 153 |
+
|
| 154 |
+
# Component 1: 4 aging-bucket totals present in added cells (0.30, 0.075 each)
|
| 155 |
+
try:
|
| 156 |
+
for label, target in BUCKETS.items():
|
| 157 |
+
if num_matches(added_nums, target):
|
| 158 |
+
print(f'PASS: bucket {label} total {target:.0f} found in added cells (0.075 pts)')
|
| 159 |
+
total_score += 0.075
|
| 160 |
+
else:
|
| 161 |
+
print(f'FAIL: bucket {label} total {target:.0f} not found in added cells')
|
| 162 |
+
except Exception as e:
|
| 163 |
+
print(f'ERROR: Component 1 (bucket totals) — {e}')
|
| 164 |
+
|
| 165 |
+
# Component 2: Total Outstanding 463500 present in added cells (0.20)
|
| 166 |
+
try:
|
| 167 |
+
if num_matches(added_nums, TOTAL_OUTSTANDING):
|
| 168 |
+
print(f'PASS: Total Outstanding {TOTAL_OUTSTANDING:.0f} found in added cells (0.20 pts)')
|
| 169 |
+
total_score += 0.20
|
| 170 |
+
else:
|
| 171 |
+
print(f'FAIL: Total Outstanding {TOTAL_OUTSTANDING:.0f} not found in added cells')
|
| 172 |
+
except Exception as e:
|
| 173 |
+
print(f'ERROR: Component 2 (total outstanding) — {e}')
|
| 174 |
+
|
| 175 |
+
# ---------- Slack #finance: new message only ----------
|
| 176 |
+
new_msgs = new_finance_messages(sl_init, sl_cur)
|
| 177 |
+
|
| 178 |
+
# Component 3: a new message was posted in #finance by user_1 (0.10)
|
| 179 |
+
user_1_msgs = [m for m in new_msgs if m.get('senderId') == 'user_1']
|
| 180 |
+
try:
|
| 181 |
+
if user_1_msgs:
|
| 182 |
+
print(f'PASS: {len(user_1_msgs)} new #finance message(s) by user_1 (0.10 pts)')
|
| 183 |
+
total_score += 0.10
|
| 184 |
+
else:
|
| 185 |
+
print(f'FAIL: no new #finance message by user_1 (new msgs: {len(new_msgs)})')
|
| 186 |
+
except Exception as e:
|
| 187 |
+
print(f'ERROR: Component 3 (new message) — {e}')
|
| 188 |
+
|
| 189 |
+
# Combine all new user_1 message text (the snapshot post) for content checks.
|
| 190 |
+
combined = '\n'.join(m.get('content', '') or '' for m in user_1_msgs)
|
| 191 |
+
combined_lower = combined.lower()
|
| 192 |
+
# Normalized digits-only version for amount matching ($115,000 -> 115000)
|
| 193 |
+
combined_norm = combined.replace('$', '').replace(',', '').replace(' ', '')
|
| 194 |
+
|
| 195 |
+
# Component 4: top three overdue customers + balances present (0.25)
|
| 196 |
+
try:
|
| 197 |
+
hits = 0
|
| 198 |
+
for name, amount in TOP3.items():
|
| 199 |
+
name_ok = name.lower() in combined_lower
|
| 200 |
+
amt_ok = str(int(amount)) in combined_norm
|
| 201 |
+
if name_ok and amt_ok:
|
| 202 |
+
print(f'PASS: top-3 customer {name} (${int(amount)}) present (0.0833 pts)')
|
| 203 |
+
hits += 1
|
| 204 |
+
else:
|
| 205 |
+
print(f'FAIL: top-3 customer {name} (${int(amount)}) — name={name_ok} amount={amt_ok}')
|
| 206 |
+
total_score += 0.25 * (hits / 3.0)
|
| 207 |
+
except Exception as e:
|
| 208 |
+
print(f'ERROR: Component 4 (top 3 customers) — {e}')
|
| 209 |
+
|
| 210 |
+
# Component 5: total outstanding 463500 stated in the message (0.15)
|
| 211 |
+
try:
|
| 212 |
+
if str(int(TOTAL_OUTSTANDING)) in combined_norm:
|
| 213 |
+
print(f'PASS: total outstanding {int(TOTAL_OUTSTANDING)} stated in message (0.15 pts)')
|
| 214 |
+
total_score += 0.15
|
| 215 |
+
else:
|
| 216 |
+
print(f'FAIL: total outstanding {int(TOTAL_OUTSTANDING)} not stated in message')
|
| 217 |
+
except Exception as e:
|
| 218 |
+
print(f'ERROR: Component 5 (message total) — {e}')
|
| 219 |
+
|
| 220 |
+
final_score = round(min(total_score, 1.0), 4)
|
| 221 |
+
print(f'\nScore: {total_score:.4f}/1.0')
|
| 222 |
+
print(f'REWARD: {final_score}')
|
| 223 |
+
return final_score
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
verify_task()
|
ar_aging_001/reward_label.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"reward_file": "/apdcephfs_sh2/share_300000800/user/jackwkwang/long-horizon-tasks/mini_osworld_xiangwu/cache/ar_aging_001/reward.py",
|
| 3 |
+
"api_url": "http://28.7.184.184:8000/v1/chat/completions",
|
| 4 |
+
"model": "Kimi-K2.6",
|
| 5 |
+
"max_code_chars": 100000,
|
| 6 |
+
"created_at": "2026-07-14 10:21:59",
|
| 7 |
+
"label": {
|
| 8 |
+
"task_id": "ar_aging_001",
|
| 9 |
+
"domain": "mock_websites",
|
| 10 |
+
"summary": "验证用户在 Google Sheets 应收账款账龄表下方新增四个账龄区间合计与总欠款金额,并在 Slack #finance 频道以 user_1 身份发布包含前三位逾期客户及其余额和总欠款的新消息。",
|
| 11 |
+
"is_placeholder": false,
|
| 12 |
+
"data_sources": [
|
| 13 |
+
"/tmp/task_web_sid",
|
| 14 |
+
"google_sheets_mock",
|
| 15 |
+
"slack_mock"
|
| 16 |
+
],
|
| 17 |
+
"scoring_components": [
|
| 18 |
+
{
|
| 19 |
+
"name": "Component 1",
|
| 20 |
+
"weight": 0.3,
|
| 21 |
+
"description": "Google Sheets 中新增或修改的单元格内包含四个账龄区间(Current、1-30、31-60、60+)的正确合计金额",
|
| 22 |
+
"check_logic": "调用 added_cell_numbers 提取所有新增/修改单元格中的数值集合 added_nums,使用 num_matches 逐一检查 BUCKETS 中的四个目标值(138000.0、96000.0、151500.0、78000.0,容差 0.5)是否存在于该集合中。每匹配一个加 0.075 分。",
|
| 23 |
+
"pass_condition": "added_nums 中同时包含 138000、96000、151500、78000(容差 0.5)"
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"name": "Component 2",
|
| 27 |
+
"weight": 0.2,
|
| 28 |
+
"description": "Google Sheets 中新增或修改的单元格内包含总欠款金额 463500",
|
| 29 |
+
"check_logic": "使用 num_matches 检查 added_nums 中是否存在 TOTAL_OUTSTANDING(463500.0,容差 0.5)。存在则加 0.20 分。",
|
| 30 |
+
"pass_condition": "added_nums 中包含 463500(容差 0.5)"
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"name": "Component 3",
|
| 34 |
+
"weight": 0.1,
|
| 35 |
+
"description": "Slack #finance 频道中有 user_1 发布的新消息",
|
| 36 |
+
"check_logic": "调用 new_finance_messages 获取 current 相对 initial 的新消息列表,筛选 senderId 为 'user_1' 的消息。若列表非空则加 0.10 分。",
|
| 37 |
+
"pass_condition": "new_msgs 中存在至少一条 senderId 为 'user_1' 的新消息"
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"name": "Component 4",
|
| 41 |
+
"weight": 0.25,
|
| 42 |
+
"description": "Slack 新消息内容中列出前三位逾期客户及其余额(Umbrella Health $115,000、Initech $72,000、Hooli $63,000)",
|
| 43 |
+
"check_logic": "合并所有 user_1 新消息的 content 文本,生成 combined_lower(小写)和 combined_norm(去除 $、逗号、空格)。对 TOP3 中每个客户,检查 name.lower() 是否在 combined_lower 中,且 str(int(amount)) 是否在 combined_norm 中。每完全匹配一个客户计 1 hit,最终得分 = 0.25 × (hits / 3.0)。",
|
| 44 |
+
"pass_condition": "消息文本中同时出现三位客户名称(不区分大小写)及其对应金额数字(115000、72000、63000)"
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"name": "Component 5",
|
| 48 |
+
"weight": 0.15,
|
| 49 |
+
"description": "Slack 新消息内容中声明总欠款 463500",
|
| 50 |
+
"check_logic": "检查 str(int(TOTAL_OUTSTANDING)) 即 '463500' 是否存在于 combined_norm 中。存在则加 0.15 分。",
|
| 51 |
+
"pass_condition": "规范化后的消息文本中包含 463500"
|
| 52 |
+
}
|
| 53 |
+
],
|
| 54 |
+
"total_max_score": 1.0,
|
| 55 |
+
"score_aggregation": "各组件分数累加求和,最终通过 min(total_score, 1.0) 钳制到上限 1.0,并四舍五入保留 4 位小数。",
|
| 56 |
+
"failure_modes": [
|
| 57 |
+
"读取 /tmp/task_web_sid 失败或为空,直接返回 0.0",
|
| 58 |
+
"从 google_sheets_mock 或 slack_mock 拉取 /go 状态失败,直接返回 0.0",
|
| 59 |
+
"initial_env 下 current 与 initial 完全相同,导致 added_cell_numbers 返回空集,所有 Sheets 相关组件无法得分",
|
| 60 |
+
"Slack #finance 中无 user_1 发送的新消息,导致 Component 3 得 0 分且后续内容检查基于空文本进行",
|
| 61 |
+
"各组件内部异常被 try/except 捕获,打印 ERROR 但不中断流程,该组件得 0 分"
|
| 62 |
+
],
|
| 63 |
+
"scoring_logic_explanation": "脚本首先读取 /tmp/task_web_sid 获取会话 ID,随后并行(逻辑上顺序)向 google_sheets_mock 和 slack_mock 请求 /go 接口,获取 initial_state 与 current_state。若任一环节失败则直接返回 0.0。对于 Google Sheets,脚本通过 added_cell_numbers 函数对比 initial 与 current,仅收集新增或修改单元格中的数值,避免计入原有账簿数据;然后逐项匹配四个账龄区间合计(各 0.075 分)与总欠款(0.20 分)。对于 Slack,脚本通过 new_finance_messages 提取 #finance 频道中 messageId 为新增的消息,并筛选 senderId 为 user_1 的消息;若存在则得 0.10 分,随后将所有 user_1 消息内容合并,进行文本检查:验证前三位逾期客户名称与金额是否同时出现(按命中比例 0.25 × hits/3 计分),以及总欠款 463500 是否出现(0.15 分)。所有组件得分累加后钳制到 1.0 并输出。",
|
| 64 |
+
"confidence": 1.0
|
| 65 |
+
},
|
| 66 |
+
"raw_response": "用户要求我分析一个 reward.py 评分脚本的评分逻辑,并以 JSON 格式输出分析结果。\n\n让我仔细阅读代码:\n\n1. **任务信息**:\n - Task ID: ar_aging_001\n - Domain: mock_websites (google_sheets_mock + slack_mock)\n - 这是一个关于 AR aging snapshot 的任务,需要在 Google Sheets 中分类未付发票到 aging buckets,写一个标记的摘要块,然后在 Slack #finance 中发布前三位逾期客户和总欠款。\n\n2. **数据源**:\n - Google Sheets mock: `http://28.7.186.212:8165`\n - Slack mock: `http://28.7.186.212:8198`\n - `/tmp/task_web_sid` 文件读取 session ID\n\n3. **评分组件**:\n - **Component 1**: Google Sheets 中 4 个 aging-bucket 总计出现在新增/修改的单元格中 (0.30, 每个 0.075)\n - Current=138000, 1-30=96000, 31-60=151500, 60+=78000\n - 检查逻辑:`added_cell_numbers` 函数收集所有新增或修改的单元格中的数字,然后 `num_matches` 检查这些数字中是否包含目标值(容差 0.5)\n \n - **Component 2**: Google Sheets 中 Total Outstanding (463500) 出现在新增/修改的单元格中 (0.20)\n - 检查逻辑:同上,检查 added_nums 中是否有 463500.0\n\n - **Component 3**: Slack #finance 中有 user_1 发布的新消息 (0.10)\n - 检查逻辑:`new_finance_messages` 获取 current 中但不在 initial 中的 finance 频道消息,筛选 senderId 为 'user_1' 的消息\n\n - **Component 4**: 消息中列出前三位逾期客户及其余额 (0.25)\n - Umbrella Health $115,000, Initech $72,000, Hooli $63,000\n - 检查逻辑:合并所有 user_1 消息文本,检查每个客户名称(不区分大小写)和金额(去除 $, , 空格后匹配数字字符串)是否都出现\n - 得分:0.25 * (hits / 3.0),即每个客户约 0.0833 分\n\n - **Component 5**: 消息中说明总欠款 $463,500 (0.15)\n - 检查逻辑:在规范化后的消息文本中查找 \"463500\"\n\n4. **分数汇总**:\n - 各组件分数相加\n - 最后 `round(min(total_score, 1.0), 4)`,即上限为 1.0\n\n5. **失败模式**:\n - 读取 sid 失败:返回 0.0\n - 获取 Google Sheets 或 Slack 状态失败:返回 0.0\n - 各组件检查中的异常会被捕获并打印 ERROR,但不会导致提前退出(除了上面的 CRITICAL)\n - 如果 initial_env (current == initial),added_cell_numbers 返回空集,所有依赖 added cells 的组件都会失败\n\n6. **is_placeholder**:\n - false,因为脚本确实进行了详细的状态检查和评分\n\n7. **confidence**:\n - 1.0,因为代码逻辑清晰完整\n\n现在构建 JSON:\n\n- task_id: \"ar_aging_001\"\n- domain: \"mock_websites\"\n- summary: \"验证用户在 Google Sheets 的应收账款账龄表中新增四个账龄区间合计与总欠款金额,并在 Slack #finance 频道发布包含前三位逾期客户及其余额和总欠款的新消息。\"\n- is_placeholder: false\n- data_sources: [\"/tmp/task_web_sid\", \"google_sheets_mock\", \"slack_mock\"]\n- scoring_components:\n 1. Component 1: 4个账龄区间合计, weight 0.30, 每个0.075\n 2. Component 2: 总欠款金额, weight 0.20\n 3. Component 3: user_1在#finance发新消息, weight 0.10\n 4. Component 4: 前三位逾期客户及余额, weight 0.25\n 5. Component 5: 消息中声明总欠款, weight 0.15\n\n- total_max_score: 1.0\n- score_aggregation: \"各组件分数相加,最终通过 min(total_score, 1.0) 钳制到上限 1.0 并四舍五入到 4 位小数\"\n- failure_modes: [\n \"读取 /tmp/task_web_sid 失败返回 0.0\",\n \"从 google_sheets_mock 或 slack_mock 获取 /go 状态失败返回 0.0\",\n \"initial_env 下 current == initial 导致 added_cell_numbers 为空集,所有 Sheets 相关组件得 0 分\",\n \"Slack #finance 无 user_1 发送的新消息导致 Component 3 得 0 分并影响后续内容检查\"\n ]\n\n- scoring_logic_explanation: 详细说明执行顺序...\n\n让我确保所有字符串 value 使用中文,但代码标识符保留原样。\n\n检查 weight 字段:\n- Component 1: 0.30 (代码中显式 0.075 each, 共4个)\n- Component 2: 0.20\n- Component 3: 0.10\n- Component 4: 0.25\n- Component 5: 0.15\n\n这些在 docstring 和代码中都明确给出了。\n\npass_condition 需要具体:\n- Component 1: added_nums 中包含 138000.0、96000.0、151500.0、78000.0 中的对应值(容差 0.5)\n- Component 2: added_nums 中包含 463500.0(容差 0.5)\n- Component 3: new_msgs 中存在 senderId 为 'user_1' 的消息\n- Component 4: combined_lower 中包含客户名称(不区分大小写)且 combined_norm 中包含对应金额数字(如 115000)\n- Component 5: combined_norm 中包含 463500\n\n注意 Component 4 是部分得分:0.25 * (hits/3.0)\n\nJSON 格式要求:\n- 不要 Markdown 代码块\n- 第一个字符是 {,最后一个字符是 }\n- 不要额外解释\n\n让我再仔细检查一下代码细节:\n\n`added_cell_numbers` 函数:\n- 遍历 current 的所有 sheet\n- 对比 initial 中相同 cell_id 的值\n- 如果 init_cell == cell,跳过(完全相同的不算)\n- 否则提取 computed, value, formula 中的数字\n- 这意味着修改现有单元格也算 \"added\"(函数名是 added_cell_numbers,但注释说 ADDED or CHANGED)\n\n`num_matches`:容差 0.5\n\n`new_finance_messages`:通过 messageId 判断是否是新消息\n\n`combined_norm`:去掉了 $, , 空格\n\n好的,开始写 JSON。 </think> {\"task_id\":\"ar_aging_001\",\"domain\":\"mock_websites\",\"summary\":\"验证用户在 Google Sheets 应收账款账龄表下方新增四个账龄区间合计与总欠款金额,并在 Slack #finance 频道以 user_1 身份发布包含前三位逾期客户及其余额和总欠款的新消息。\",\"is_placeholder\":false,\"data_sources\":[\"/tmp/task_web_sid\",\"google_sheets_mock\",\"slack_mock\"],\"scoring_components\":[{\"name\":\"Component 1\",\"weight\":0.3,\"description\":\"Google Sheets 中新增或修改的单元格内包含四个账龄区间(Current、1-30、31-60、60+)的正确合计金额\",\"check_logic\":\"调用 added_cell_numbers 提取所有新增/修改单元格中的数值集合 added_nums,使用 num_matches 逐一检查 BUCKETS 中的四个目标值(138000.0、96000.0、151500.0、78000.0,容差 0.5)是否存在于该集合中。每匹配一个加 0.075 分。\",\"pass_condition\":\"added_nums 中同时包含 138000、96000、151500、78000(容差 0.5)\"},{\"name\":\"Component 2\",\"weight\":0.2,\"description\":\"Google Sheets 中新增或修改的单元格内包含总欠款金额 463500\",\"check_logic\":\"使用 num_matches 检查 added_nums 中是否存在 TOTAL_OUTSTANDING(463500.0,容差 0.5)。存在则加 0.20 分。\",\"pass_condition\":\"added_nums 中包含 463500(容差 0.5)\"},{\"name\":\"Component 3\",\"weight\":0.1,\"description\":\"Slack #finance 频道中有 user_1 发布的新消息\",\"check_logic\":\"调用 new_finance_messages 获取 current 相对 initial 的新消息列表,筛选 senderId 为 'user_1' 的消息。若列表非空则加 0.10 分。\",\"pass_condition\":\"new_msgs 中存在至少一条 senderId 为 'user_1' 的新消息\"},{\"name\":\"Component 4\",\"weight\":0.25,\"description\":\"Slack 新消息内容中列出前三位逾期客户及其余额(Umbrella Health $115,000、Initech $72,000、Hooli $63,000)\",\"check_logic\":\"合并所有 user_1 新消息的 content 文本,生成 combined_lower(小写)和 combined_norm(去除 $、逗号、空格)。对 TOP3 中每个客户,检查 name.lower() 是否在 combined_lower 中,且 str(int(amount)) 是否在 combined_norm 中。每完全匹配一个客户计 1 hit,最终得分 = 0.25 × (hits / 3.0)。\",\"pass_condition\":\"消息文本中同时出现三位客户名称(不区分大小写)及其对应金额数字(115000、72000、63000)\"},{\"name\":\"Component 5\",\"weight\":0.15,\"description\":\"Slack 新消息内容中声明总欠款 463500\",\"check_logic\":\"检查 str(int(TOTAL_OUTSTANDING)) 即 '463500' 是否存在于 combined_norm 中。存在则加 0.15 分。\",\"pass_condition\":\"规范化后的消息文本中包含 463500\"}],\"total_max_score\":1.0,\"score_aggregation\":\"各组件分数累加求和,最终通过 min(total_score, 1.0) 钳制到上限 1.0,并四舍五入保留 4 位小数。\",\"failure_modes\":[\"读取 /tmp/task_web_sid 失败或为空,直接返回 0.0\",\"从 google_sheets_mock 或 slack_mock 拉取 /go 状态失败,直接返回 0.0\",\"initial_env 下 current 与 initial 完全相同,导致 added_cell_numbers 返回空集,所有 Sheets 相关组件无法得分\",\"Slack #finance 中无 user_1 发送的新消息,导致 Component 3 得 0 分且后续内容检查基于空文本进行\",\"各组件内部异常被 try/except 捕获,打印 ERROR 但不中断流程,该组件得 0 分\"],\"scoring_logic_explanation\":\"脚本首先读取 /tmp/task_web_sid 获取会话 ID,随后并行(逻辑上顺序)向 google_sheets_mock 和 slack_mock 请求 /go 接口,获取 initial_state 与 current_state。若任一环节失败则直接返回 0.0。对于 Google Sheets,脚本通过 added_cell_numbers 函数对比 initial 与 current,仅收集新增或修改单元格中的数值,避免计入原有账簿数据;然后逐项匹配四个账龄区间合计(各 0.075 分)与总欠款(0.20 分)。对于 Slack,脚本通过 new_finance_messages 提取 #finance 频道中 messageId 为新增的消息,并筛选 senderId 为 user_1 的消息;若存在则得 0.10 分,随后将所有 user_1 消息内容合并,进行文本检查:验证前三位逾期客户名称与金额是否同时出现(按命中比例 0.25 × hits/3 计分),以及总欠款 463500 是否出现(0.15 分)。所有组件得分累加后钳制到 1.0 并输出。\",\"confidence\":1.0}"
|
| 67 |
+
}
|
ar_invoice_003/_cua_gym_vm_bridge.sh
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# CUA-Gym VM-side network fix (direct-IP mock access).
|
| 3 |
+
#
|
| 4 |
+
# Runs INSIDE the QEMU guest. The CUA-Gym mock services are now reached by
|
| 5 |
+
# their real IDC address (http://28.7.184.198:81xx) instead of the old
|
| 6 |
+
# localhost:9000-9097 socat bridge, so the VM only needs two fixes:
|
| 7 |
+
#
|
| 8 |
+
# 1. Working DNS — the qcow2-baked /etc/resolv.conf points at the Pod's
|
| 9 |
+
# cluster DNS, which is unreachable from QEMU SLIRP NAT
|
| 10 |
+
# ("Temporary failure in name resolution").
|
| 11 |
+
# 2. The mock host excluded from the woa http proxy — otherwise the VM's
|
| 12 |
+
# Chrome (gsettings proxy) and initial_setup.py's `requests` get a 403
|
| 13 |
+
# from the proxy when hitting 28.7.184.198:81xx. (The old socat path never
|
| 14 |
+
# hit this because localhost is bypassed by default.)
|
| 15 |
+
#
|
| 16 |
+
# Idempotent. Scoped to the CUA-Gym bridge step; does not touch the generic
|
| 17 |
+
# OSWorld setup pipeline.
|
| 18 |
+
#
|
| 19 |
+
# Argv:
|
| 20 |
+
# $1 optional sudo password (default "password"; SetupController
|
| 21 |
+
# substitutes {CLIENT_PASSWORD} when uploaded as a cache file).
|
| 22 |
+
# $2 unused (kept for backward compat — was socat first port 9000).
|
| 23 |
+
# $3 unused (kept for backward compat — was socat last port 9097).
|
| 24 |
+
# $4 optional mock host IP (default 28.7.184.198).
|
| 25 |
+
|
| 26 |
+
set +e
|
| 27 |
+
|
| 28 |
+
PASS="${1:-password}"
|
| 29 |
+
MOCK_HOST="${4:-28.7.184.198}"
|
| 30 |
+
# Derive the /16 IDC subnet so future port/host tweaks on the same segment
|
| 31 |
+
# stay bypassed too (28.7.184.198 -> 28.7.0.0/16).
|
| 32 |
+
MOCK_NET="$(echo "${MOCK_HOST}" | awk -F. 'NF==4{print $1"."$2".0.0/16"}')"
|
| 33 |
+
|
| 34 |
+
run_root() {
|
| 35 |
+
echo "$PASS" | sudo -S -p "" bash -c "$1"
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
# Detect SLIRP gateway from VM's routing table; fall back to 10.0.2.2.
|
| 39 |
+
GW="$(ip route 2>/dev/null | awk '/default/ {print $3; exit}')"
|
| 40 |
+
GW="${GW:-10.0.2.2}"
|
| 41 |
+
|
| 42 |
+
# ─── CUA-Gym network fix (Taiji-specific) ─────────────────────────────
|
| 43 |
+
fix_vm_network() {
|
| 44 |
+
# 0) Discover VM network state at runtime — gateway, own IP/CIDR, SLIRP
|
| 45 |
+
# DNS forwarder. Nothing hardcoded except the mock host above.
|
| 46 |
+
local GW_NET="${GW%.*}"
|
| 47 |
+
local SLIRP_DNS="${GW_NET}.3" # QEMU SLIRP DNS proxy is always .3
|
| 48 |
+
local OWN_CIDR
|
| 49 |
+
OWN_CIDR="$(ip -4 -o addr show scope global 2>/dev/null \
|
| 50 |
+
| awk '{print $4; exit}')"
|
| 51 |
+
local OWN_IP="${OWN_CIDR%/*}"
|
| 52 |
+
local OWN_NET=""
|
| 53 |
+
[ -n "${OWN_IP}" ] && OWN_NET="${OWN_IP%.*}.0/24"
|
| 54 |
+
|
| 55 |
+
# 1) DNS — point at SLIRP DNS proxy + public fallbacks. chattr +i keeps
|
| 56 |
+
# systemd-resolved/NetworkManager from clobbering it.
|
| 57 |
+
if run_root "printf 'nameserver ${SLIRP_DNS}\\nnameserver 114.114.114.114\\nnameserver 8.8.8.8\\n' > /etc/resolv.conf
|
| 58 |
+
chattr +i /etc/resolv.conf 2>/dev/null || true"; then
|
| 59 |
+
echo "[cua_gym_vm_bridge] DNS set: ${SLIRP_DNS}, 114.114.114.114, 8.8.8.8 (gw=${GW})"
|
| 60 |
+
else
|
| 61 |
+
echo "[cua_gym_vm_bridge] WARN: failed to write /etc/resolv.conf"
|
| 62 |
+
fi
|
| 63 |
+
|
| 64 |
+
# 2) Build the proxy bypass list from detected values + the direct-IP
|
| 65 |
+
# mock host (and its /16 subnet). THIS is what makes 28.7.184.198:81xx
|
| 66 |
+
# reachable from inside the VM — without it the woa proxy 403s it.
|
| 67 |
+
local ignore_list="['localhost', '127.0.0.0/8', '${GW}'"
|
| 68 |
+
[ -n "${OWN_IP}" ] && ignore_list="${ignore_list}, '${OWN_IP}'"
|
| 69 |
+
[ -n "${OWN_NET}" ] && ignore_list="${ignore_list}, '${OWN_NET}'"
|
| 70 |
+
[ -n "${GW_NET}" ] && ignore_list="${ignore_list}, '${GW_NET}.0/24'"
|
| 71 |
+
[ -n "${MOCK_HOST}" ] && ignore_list="${ignore_list}, '${MOCK_HOST}'"
|
| 72 |
+
[ -n "${MOCK_NET}" ] && ignore_list="${ignore_list}, '${MOCK_NET}'"
|
| 73 |
+
ignore_list="${ignore_list}]"
|
| 74 |
+
|
| 75 |
+
# 3) GNOME proxy ignore-hosts — Chrome bypasses the woa proxy for these.
|
| 76 |
+
if gsettings set org.gnome.system.proxy ignore-hosts "${ignore_list}" 2>/tmp/gsettings_err; then
|
| 77 |
+
echo "[cua_gym_vm_bridge] gsettings ignore-hosts = ${ignore_list}"
|
| 78 |
+
else
|
| 79 |
+
echo "[cua_gym_vm_bridge] WARN: gsettings ignore-hosts failed: $(cat /tmp/gsettings_err 2>/dev/null)"
|
| 80 |
+
fi
|
| 81 |
+
|
| 82 |
+
# 4) Shell env — comma-separated form for no_proxy/NO_PROXY (requests/curl).
|
| 83 |
+
local NP="localhost,127.0.0.1,${GW}"
|
| 84 |
+
[ -n "${OWN_IP}" ] && NP="${NP},${OWN_IP}"
|
| 85 |
+
[ -n "${OWN_NET}" ] && NP="${NP},${OWN_NET}"
|
| 86 |
+
[ -n "${GW_NET}" ] && NP="${NP},${GW_NET}.0/24"
|
| 87 |
+
[ -n "${MOCK_HOST}" ] && NP="${NP},${MOCK_HOST}"
|
| 88 |
+
[ -n "${MOCK_NET}" ] && NP="${NP},${MOCK_NET}"
|
| 89 |
+
|
| 90 |
+
for var in no_proxy NO_PROXY; do
|
| 91 |
+
if ! grep -q "export ${var}=${NP}" /home/user/.bashrc 2>/dev/null; then
|
| 92 |
+
echo "export ${var}=${NP}" >> /home/user/.bashrc
|
| 93 |
+
fi
|
| 94 |
+
done
|
| 95 |
+
run_root "grep -q '^no_proxy=' /etc/environment 2>/dev/null \
|
| 96 |
+
&& sed -i 's|^no_proxy=.*|no_proxy=\"${NP}\"|' /etc/environment \
|
| 97 |
+
|| echo 'no_proxy=\"${NP}\"' >> /etc/environment
|
| 98 |
+
grep -q '^NO_PROXY=' /etc/environment 2>/dev/null \
|
| 99 |
+
&& sed -i 's|^NO_PROXY=.*|NO_PROXY=\"${NP}\"|' /etc/environment \
|
| 100 |
+
|| echo 'NO_PROXY=\"${NP}\"' >> /etc/environment" >/dev/null 2>&1
|
| 101 |
+
echo "[cua_gym_vm_bridge] no_proxy=${NP}"
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
fix_vm_network
|
| 105 |
+
|
| 106 |
+
echo "[cua_gym_vm_bridge] direct-IP mode: ${MOCK_HOST} (+${MOCK_NET}) bypassed from woa proxy; no socat forwarding needed"
|
ar_invoice_003/reward_label.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"reward_file": "/apdcephfs_sh2/share_300000800/user/jackwkwang/long-horizon-tasks/mini_osworld_xiangwu/cache/ar_invoice_001/reward.py",
|
| 3 |
+
"api_url": "http://28.7.184.184:8000/v1/chat/completions",
|
| 4 |
+
"model": "Kimi-K2.6",
|
| 5 |
+
"max_code_chars": 100000,
|
| 6 |
+
"created_at": "2026-07-14 10:22:38",
|
| 7 |
+
"label": {
|
| 8 |
+
"task_id": "ar_invoice_003",
|
| 9 |
+
"domain": "mock_websites",
|
| 10 |
+
"summary": "验证在Google Sheets中新增INV-1043发票台账行且未改动原有数据,并在Slack的#finance频道向Sarah Chen发送关于该发票的新消息",
|
| 11 |
+
"is_placeholder": false,
|
| 12 |
+
"data_sources": [
|
| 13 |
+
"/tmp/task_web_sid",
|
| 14 |
+
"google-sheets mock 服务 (/go?sid=...)",
|
| 15 |
+
"slack mock 服务 (/go?sid=...)"
|
| 16 |
+
],
|
| 17 |
+
"scoring_components": [
|
| 18 |
+
{
|
| 19 |
+
"name": "Sheet",
|
| 20 |
+
"weight": 0.5,
|
| 21 |
+
"description": "检查Google Sheets中是否新增了INV-1043发票行,且原有行未被修改",
|
| 22 |
+
"check_logic": "先通过fetch_state获取google-sheets的initial_state和current_state;构建发票号到行数据的映射;检查所有initial中的发票行在current中是否完全一致(norm后比较),若不一致则返回0.0;检查INV-1043是否已存在于initial中,若存在则返回0.0;在current中查找INV-1043新行,若不存在则返回0.0;对A..H共8个单元格逐格比对,text类型用norm比较,amount类型用norm_amount比较,date类型用digits比较",
|
| 23 |
+
"pass_condition": "现有发票行完全未被修改;INV-1043为新增行;8个单元格分别匹配预期值(A=INV-1043, B=Acme Corp, C=Acme Corp - Platform License, D=48000, E=20260624, F=20260724, G=Sent, H=Sarah Chen)"
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"name": "Slack",
|
| 27 |
+
"weight": 0.5,
|
| 28 |
+
"description": "检查Slack的#finance频道是否新增了发给Sarah Chen的关于INV-1043发票的消息",
|
| 29 |
+
"check_logic": "获取slack的initial_state和current_state;比较#finance频道消息数,若current消息数不大于initial则返回0.0;取新增消息(cur_msgs[len(init_msgs):]);对每条新增消息归一化后检查5个关键词条件,取命中数最多的消息;5个条件各值0.1分",
|
| 30 |
+
"pass_condition": "#finance频道至少有一条新增消息;该消息同时满足5个关键词条件:包含sarah chen或@sarah、包含inv-1043、包含acme、包含金额48000、包含日期2026-07-24(经过去分隔符处理后匹配20260724)"
|
| 31 |
+
}
|
| 32 |
+
],
|
| 33 |
+
"total_max_score": 1.0,
|
| 34 |
+
"score_aggregation": "两个组件分数相加,最终用min(total, 1.0)钳制到上限1.0,再四舍五入到4位小数",
|
| 35 |
+
"failure_modes": [
|
| 36 |
+
"读取/tmp/task_web_sid失败或为空时打印CRITICAL并直接退出,REWARD为0.0",
|
| 37 |
+
"fetch_state拉取google-sheets或slack状态失败时该组件返回0.0",
|
| 38 |
+
"current_state为空时该组件返回0.0",
|
| 39 |
+
"Sheet组件中任何现有初始行被修改或删除,该组件直接返回0.0",
|
| 40 |
+
"Sheet组件中INV-1043在initial_state已存在,直接返回0.0",
|
| 41 |
+
"Sheet组件中未找到INV-1043新行,直接返回0.0",
|
| 42 |
+
"Slack组件中#finance频道无新增消息(消息数未增加),直接返回0.0",
|
| 43 |
+
"任一组件内部抛出异常时该组件得0.0,不影响另一组件评分"
|
| 44 |
+
],
|
| 45 |
+
"scoring_logic_explanation": "脚本首先读取/tmp/task_web_sid获取会话ID。然后分别调用verify_sheet()和verify_slack()两个组件。verify_sheet通过mock API获取Google Sheets的initial_state和current_state,先进行两个硬性门控:1)所有原有发票行必须完全不变;2)目标行INV-1043必须是新增且存在于current_state中。门控通过后,对A到H共8个单元格逐格匹配预期值,按匹配单元格比例乘以0.5计分。verify_slack通过mock API获取Slack状态,检查#finance频道消息数是否增加,若无增加则得0分;若有新增消息,则在新增消息中寻找命中5个关键词条件最多的一条,按命中比例乘以0.5计分。两个组件得分相加后,最终分数被钳制在1.0以内并四舍五入到4位小数输出。",
|
| 46 |
+
"confidence": 1.0
|
| 47 |
+
},
|
| 48 |
+
"raw_response": "用户要求我分析一个 reward.py 评分脚本的评分逻辑,并以 JSON 格式输出结果。我需要仔细阅读源码,提取关键信息。\n\n首先,从 docstring 中提取信息:\n- Task ID: ar_invoice_001\n- Domain: mock_websites (google_sheets + slack)\n- 这是一个链式任务:Salesforce -> Google Sheets -> Slack\n- Salesforce 是只读的,只评分 Google Sheet 和 Slack\n\n数据源:\n- /tmp/task_web_sid:读取 sid\n- google-sheets mock:通过 _cua_gym_base('google-sheets')/go?sid={SID} 获取状态\n- slack mock:通过 _cua_gym_base('slack')/go?sid={SID} 获取状态\n\n评分组件:\n\n1. Sheet (0.5分):\n - 检查是否新增了 INV-1043 行\n - 检查现有行是否未被修改\n - 8个单元格 (A..H) 逐单元格评分,每个单元格匹配得 0.5/8\n - 期望值:\n - A: INV-1043 (text)\n - B: Acme Corp (text)\n - C: Acme Corp - Platform License (text)\n - D: 48000 (amount)\n - E: 20260624 (date)\n - F: 20260724 (date)\n - G: Sent (text)\n - H: Sarah Chen (text)\n - 如果现有行被修改或删除,得 0.0\n - 如果 INV-1043 在 initial_state 中已存在,得 0.0\n - 如果没有找到 INV-1043 新行,得 0.0\n\n2. Slack (0.5分):\n - 检查 #finance 频道是否有新消息\n - 新消息数量必须大于初始消息数量\n - 在新增消息中找最佳匹配\n - 5个关键词标准,每个 0.1分 (0.5/5):\n 1. addressed to Sarah Chen ('sarah chen' in t or '@sarah' in t)\n 2. invoice INV-1043 ('inv-1043' in t)\n 3. customer Acme ('acme' in t)\n 4. amount 48000 ('48000' in re.sub(r'[$,\\s]', '', t))\n 5. due date 2026-07-24 ('20260724' in re.sub(r'[^0-9]', '', t))\n\n分数汇总:\n- total = verify_sheet() + verify_slack()\n- final = round(min(total, 1.0), 4)\n- 两个组件相加,钳制到 1.0\n\n失败路径:\n- 读取 /tmp/task_web_sid 失败会打印 CRITICAL 并退出,返回 0.0\n- fetch_state('google-sheets') 失败返回 None,verify_sheet 返回 0.0\n- fetch_state('slack') 失败返回 None,verify_slack 返回 0.0\n- current_state 为空返回 0.0\n- Sheet:现有行被修改或删除返回 0.0\n- Sheet:INV-1043 已存在于 initial_state 返回 0.0\n- Sheet:未找到 INV-1043 新行返回 0.0\n- Slack:#finance 无新消息返回 0.0\n- 各组件异常被捕获,打印 ERROR,该组件得 0.0\n\nis_placeholder: false,因为脚本有详细的检查逻辑。\n\nconfidence: 1.0,因为源码完整且逻辑清晰。\n\n现在构建 JSON。 </think> {\"task_id\":\"ar_invoice_001\",\"domain\":\"mock_websites\",\"summary\":\"验证在Google Sheets中新增INV-1043发票台账行且未改动原有数据,并在Slack的#finance频道向Sarah Chen发送关于该发票的新消息\",\"is_placeholder\":false,\"data_sources\":[\"/tmp/task_web_sid\",\"google-sheets mock 服务 (/go?sid=...)\",\"slack mock 服务 (/go?sid=...)\"],\"scoring_components\":[{\"name\":\"Sheet\",\"weight\":0.5,\"description\":\"检查Google Sheets中是否新增了INV-1043发票行,且原有行未被修改\",\"check_logic\":\"先通过fetch_state获取google-sheets的initial_state和current_state;构建发票号到行数据的映射;检查所有initial中的发票行在current中是否完全一致(norm后比较),若不一致则返回0.0;检查INV-1043是否已存在于initial中,若存在则返回0.0;在current中查找INV-1043新行,若不存在则返回0.0;对A..H共8个单元格逐格比对,text类型用norm比较,amount类型用norm_amount比较,date类型用digits比较\",\"pass_condition\":\"现有发票行完全未被修改;INV-1043为新增行;8个单元格分别匹配预期值(A=INV-1043, B=Acme Corp, C=Acme Corp - Platform License, D=48000, E=20260624, F=20260724, G=Sent, H=Sarah Chen)\"},{\"name\":\"Slack\",\"weight\":0.5,\"description\":\"检查Slack的#finance频道是否新增了发给Sarah Chen的关于INV-1043发票的消息\",\"check_logic\":\"获取slack的initial_state和current_state;比较#finance频道消息数,若current消息数不大于initial则返回0.0;取新增消息(cur_msgs[len(init_msgs):]);对每条新增消息归一化后检查5个关键词条件,取命中数最多的消息;5个条件各值0.1分\",\"pass_condition\":\"#finance频道至少有一条新增消息;该消息同时满足5个关键词条件:包含sarah chen或@sarah、包含inv-1043、包含acme、包含金额48000、包含日期2026-07-24(经过去分隔符处理后匹配20260724)\"}],\"total_max_score\":1.0,\"score_aggregation\":\"两个组件分数相加,最终用min(total, 1.0)钳制到上限1.0,再四舍五入到4位小数\",\"failure_modes\":[\"读取/tmp/task_web_sid失败或为空时打印CRITICAL并直接退出,REWARD为0.0\",\"fetch_state拉取google-sheets或slack状态失败时该组件返回0.0\",\"current_state为空时该组件返回0.0\",\"Sheet组件中任何现有初始行被修改或删除,该组件直接返回0.0\",\"Sheet组件中INV-1043在initial_state已存在,直接返回0.0\",\"Sheet组件中未找到INV-1043新行,直接返回0.0\",\"Slack组件中#finance频道无新增消息(消息数未增加),直接返回0.0\",\"任一组件内部抛出异常时该组件得0.0,不影响另一组件评分\"],\"scoring_logic_explanation\":\"脚本首先读取/tmp/task_web_sid获取会话ID。然后分别调用verify_sheet()和verify_slack()两个组件。verify_sheet通过mock API获取Google Sheets的initial_state和current_state,先进行两个硬性门控:1)所有原有发票行必须完全不变;2)目标行INV-1043必须是新增且存在于current_state中。门控通过后,对A到H共8个单元格逐格匹配预期值,按匹配单元格比例乘以0.5计分。verify_slack通过mock API获取Slack状态,检查#finance频道消息数是否增加,若无增加则得0分;若有新增消息,则在新增消息中寻找命中5个关键词条件最多的一条,按命中比例乘以0.5计分。两���组件得分相加后,最终分数被钳制在1.0以内并四舍五入到4位小数输出。\",\"confidence\":1.0}"
|
| 49 |
+
}
|
fin_expense_claim_002__long__cond/.PLACEHOLDER
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
This directory is intentionally empty.
|
| 2 |
+
It exists only to satisfy start_our_benchmark_test.sh's uniform
|
| 3 |
+
'cache_dir/<tid>/ must exist' precheck. Non-mock tasks do not use
|
| 4 |
+
cua_gym cache; their evaluators read a vm_file tarball instead.
|
| 5 |
+
See docs/0716_迁移执行日志.md § S15 for details.
|
fin_expense_claim_002__long__cond/0a7fc64f-9ca0-54e1-90d0-9bdb1fea4b10_oa_server.py
ADDED
|
@@ -0,0 +1,779 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
TechCorp Expense Reimbursement System - Fake OA Server
|
| 4 |
+
======================================================
|
| 5 |
+
A single-file, zero-dependency web server for OSWorld condition-branch tasks.
|
| 6 |
+
|
| 7 |
+
Usage:
|
| 8 |
+
python3 oa_server.py --user zhang_wei --role employee --port 8765
|
| 9 |
+
python3 oa_server.py --user li_ming --role intern --port 8765
|
| 10 |
+
|
| 11 |
+
All submitted data is persisted to DATA_DIR (default: /home/user/oa_data/).
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
import argparse
|
| 15 |
+
import json
|
| 16 |
+
import os
|
| 17 |
+
import re
|
| 18 |
+
import sys
|
| 19 |
+
import time
|
| 20 |
+
from http.server import HTTPServer, BaseHTTPRequestHandler
|
| 21 |
+
from urllib.parse import urlparse, parse_qs
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
# --- Multipart Form Data Parser (replaces deprecated cgi module) ---
|
| 25 |
+
|
| 26 |
+
class UploadedFile:
|
| 27 |
+
"""Represents an uploaded file from multipart form data."""
|
| 28 |
+
def __init__(self, filename, data):
|
| 29 |
+
self.filename = filename
|
| 30 |
+
self.data = data
|
| 31 |
+
|
| 32 |
+
def read(self):
|
| 33 |
+
return self.data
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def parse_multipart(body, boundary):
|
| 37 |
+
"""
|
| 38 |
+
Parse multipart/form-data body into a dict.
|
| 39 |
+
Returns: {field_name: value_or_UploadedFile_or_list}
|
| 40 |
+
For file fields: value is UploadedFile (or list of UploadedFile)
|
| 41 |
+
For text fields: value is string (or list of strings)
|
| 42 |
+
"""
|
| 43 |
+
result = {}
|
| 44 |
+
# Boundary comes as string, body is bytes
|
| 45 |
+
if isinstance(boundary, str):
|
| 46 |
+
boundary = boundary.encode()
|
| 47 |
+
|
| 48 |
+
# Split by boundary
|
| 49 |
+
delimiter = b"--" + boundary
|
| 50 |
+
parts = body.split(delimiter)
|
| 51 |
+
|
| 52 |
+
for part in parts:
|
| 53 |
+
# Skip preamble and epilogue
|
| 54 |
+
if part in (b"", b"--", b"--\r\n", b"\r\n"):
|
| 55 |
+
continue
|
| 56 |
+
if part.startswith(b"--"):
|
| 57 |
+
continue
|
| 58 |
+
|
| 59 |
+
# Strip leading \r\n
|
| 60 |
+
if part.startswith(b"\r\n"):
|
| 61 |
+
part = part[2:]
|
| 62 |
+
|
| 63 |
+
# Split headers from body
|
| 64 |
+
header_end = part.find(b"\r\n\r\n")
|
| 65 |
+
if header_end == -1:
|
| 66 |
+
continue
|
| 67 |
+
|
| 68 |
+
header_data = part[:header_end].decode("utf-8", errors="replace")
|
| 69 |
+
file_data = part[header_end + 4:]
|
| 70 |
+
|
| 71 |
+
# Remove trailing \r\n from file_data
|
| 72 |
+
if file_data.endswith(b"\r\n"):
|
| 73 |
+
file_data = file_data[:-2]
|
| 74 |
+
|
| 75 |
+
# Parse Content-Disposition header
|
| 76 |
+
name = None
|
| 77 |
+
filename = None
|
| 78 |
+
for line in header_data.split("\r\n"):
|
| 79 |
+
if line.lower().startswith("content-disposition"):
|
| 80 |
+
# Extract name
|
| 81 |
+
name_match = re.search(r'name="([^"]*)"', line)
|
| 82 |
+
if name_match:
|
| 83 |
+
name = name_match.group(1)
|
| 84 |
+
# Extract filename
|
| 85 |
+
filename_match = re.search(r'filename="([^"]*)"', line)
|
| 86 |
+
if filename_match:
|
| 87 |
+
filename = filename_match.group(1)
|
| 88 |
+
|
| 89 |
+
if name is None:
|
| 90 |
+
continue
|
| 91 |
+
|
| 92 |
+
# Determine if this is a file upload or text field
|
| 93 |
+
if filename is not None:
|
| 94 |
+
# File field (could be empty filename for no file selected)
|
| 95 |
+
if filename:
|
| 96 |
+
value = UploadedFile(filename, file_data)
|
| 97 |
+
else:
|
| 98 |
+
continue # Skip empty file fields
|
| 99 |
+
else:
|
| 100 |
+
# Text field
|
| 101 |
+
value = file_data.decode("utf-8", errors="replace")
|
| 102 |
+
|
| 103 |
+
# Append to result (support multiple values for same name)
|
| 104 |
+
if name in result:
|
| 105 |
+
existing = result[name]
|
| 106 |
+
if isinstance(existing, list):
|
| 107 |
+
existing.append(value)
|
| 108 |
+
else:
|
| 109 |
+
result[name] = [existing, value]
|
| 110 |
+
else:
|
| 111 |
+
result[name] = value
|
| 112 |
+
|
| 113 |
+
return result
|
| 114 |
+
|
| 115 |
+
# --- Configuration ---
|
| 116 |
+
DEFAULT_PORT = 8765
|
| 117 |
+
DATA_DIR = os.environ.get("OA_DATA_DIR", "/home/user/oa_data")
|
| 118 |
+
|
| 119 |
+
# --- HTML Templates ---
|
| 120 |
+
|
| 121 |
+
HOMEPAGE_HTML = """<!DOCTYPE html>
|
| 122 |
+
<html lang="en">
|
| 123 |
+
<head>
|
| 124 |
+
<meta charset="UTF-8">
|
| 125 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 126 |
+
<title>TechCorp Expense Reimbursement System</title>
|
| 127 |
+
<style>
|
| 128 |
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 129 |
+
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #f0f2f5; color: #333; }
|
| 130 |
+
.header { background: linear-gradient(135deg, #1a237e, #283593); color: white; padding: 12px 40px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
|
| 131 |
+
.header h1 { font-size: 22px; font-weight: 600; }
|
| 132 |
+
.header .subtitle { font-size: 13px; opacity: 0.85; margin-top: 2px; }
|
| 133 |
+
.container { max-width: 900px; margin: 16px auto; padding: 0 20px; }
|
| 134 |
+
.welcome-card { background: white; border-radius: 8px; padding: 14px 28px; margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); display: flex; align-items: center; gap: 12px; }
|
| 135 |
+
.welcome-card h2 { color: #1a237e; margin-bottom: 0; font-size: 18px; }
|
| 136 |
+
.welcome-card .role-badge { display: inline-block; padding: 4px 14px; border-radius: 12px; font-size: 13px; font-weight: 600; letter-spacing: 0.3px; }
|
| 137 |
+
.welcome-card .role-badge.employee { background: #1a237e; color: #fff; }
|
| 138 |
+
.welcome-card .role-badge.intern { background: #00796b; color: #fff; }
|
| 139 |
+
.guide-card { background: white; border-radius: 8px; padding: 16px 28px; margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
|
| 140 |
+
.guide-card h3 { color: #1a237e; margin-bottom: 8px; font-size: 16px; }
|
| 141 |
+
.guide-card ol { padding-left: 22px; line-height: 1.6; font-size: 14px; }
|
| 142 |
+
.guide-card li { margin-bottom: 2px; }
|
| 143 |
+
.guide-card .note { background: #fff3e0; border-left: 4px solid #ff9800; padding: 8px 14px; margin-top: 10px; border-radius: 4px; font-size: 13px; }
|
| 144 |
+
.guide-card .warning { background: #fce4ec; border-left: 4px solid #e53935; padding: 8px 14px; margin-top: 8px; border-radius: 4px; font-size: 13px; }
|
| 145 |
+
.portals { display: flex; gap: 20px; justify-content: center; margin-bottom: 12px; background: white; border-radius: 8px; padding: 16px 28px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
|
| 146 |
+
.portal-btn { display: inline-flex; align-items: center; gap: 8px; padding: 14px 36px; border-radius: 8px; font-size: 16px; font-weight: 600; text-decoration: none; cursor: pointer; transition: all 0.2s; border: none; }
|
| 147 |
+
.portal-btn.employee { background: #1a237e; color: white; }
|
| 148 |
+
.portal-btn.employee:hover { background: #283593; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(26,35,126,0.3); }
|
| 149 |
+
.portal-btn.intern { background: #00695c; color: white; }
|
| 150 |
+
.portal-btn.intern:hover { background: #00796b; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,105,92,0.3); }
|
| 151 |
+
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; }
|
| 152 |
+
.modal-overlay.active { display: flex; }
|
| 153 |
+
.modal { background: white; border-radius: 12px; padding: 32px; max-width: 480px; width: 90%; box-shadow: 0 8px 32px rgba(0,0,0,0.2); text-align: center; }
|
| 154 |
+
.modal .icon { font-size: 48px; margin-bottom: 16px; }
|
| 155 |
+
.modal h3 { color: #c62828; margin-bottom: 12px; }
|
| 156 |
+
.modal p { color: #555; line-height: 1.6; margin-bottom: 20px; }
|
| 157 |
+
.modal button { background: #c62828; color: white; border: none; padding: 10px 24px; border-radius: 6px; font-size: 14px; cursor: pointer; }
|
| 158 |
+
.modal button:hover { background: #b71c1c; }
|
| 159 |
+
</style>
|
| 160 |
+
</head>
|
| 161 |
+
<body>
|
| 162 |
+
<div class="header">
|
| 163 |
+
<h1>🏢 TechCorp Expense Reimbursement System</h1>
|
| 164 |
+
<div class="subtitle">Internal Finance Portal</div>
|
| 165 |
+
</div>
|
| 166 |
+
<div class="container">
|
| 167 |
+
<div class="welcome-card">
|
| 168 |
+
<h2>Welcome, {display_name}</h2>
|
| 169 |
+
<span class="role-badge {role}">{role_label}</span>
|
| 170 |
+
</div>
|
| 171 |
+
<div class="portals">
|
| 172 |
+
<button class="portal-btn employee" onclick="tryPortal('employee')">💼 Employee Portal</button>
|
| 173 |
+
<button class="portal-btn intern" onclick="tryPortal('intern')">🎓 Intern Portal</button>
|
| 174 |
+
</div>
|
| 175 |
+
<div class="guide-card">
|
| 176 |
+
<h3>📋 How to Submit a Reimbursement</h3>
|
| 177 |
+
<ol>
|
| 178 |
+
<li><strong>Choose the portal that matches your role</strong></li>
|
| 179 |
+
<li><strong>Upload your invoice files</strong> (PDF or image format)</li>
|
| 180 |
+
<li><strong>Fill in the details:</strong> total amount, expense category, and a brief description</li>
|
| 181 |
+
<li><strong>If your total amount exceeds ¥1,000:</strong>
|
| 182 |
+
<ul style="list-style: none; padding-left: 16px; margin-top: 4px;">
|
| 183 |
+
<li>• You must provide a written justification (at least 20 characters)</li>
|
| 184 |
+
<li>• You must upload a manager-approved report (PDF)</li>
|
| 185 |
+
</ul>
|
| 186 |
+
</li>
|
| 187 |
+
<li><strong>(Interns only)</strong> Provide your mentor's ID and department approval code</li>
|
| 188 |
+
<li><strong>Click "Submit Reimbursement"</strong></li>
|
| 189 |
+
</ol>
|
| 190 |
+
<div class="note">💡 <strong>Tip:</strong> Have all your documents ready before starting. You can find invoice files and any required documents in your designated folder.</div>
|
| 191 |
+
</div>
|
| 192 |
+
</div>
|
| 193 |
+
|
| 194 |
+
<div class="modal-overlay" id="warningModal">
|
| 195 |
+
<div class="modal">
|
| 196 |
+
<div class="icon">⚠️</div>
|
| 197 |
+
<h3>Access Denied</h3>
|
| 198 |
+
<p id="warningMsg"></p>
|
| 199 |
+
<button onclick="closeModal()">OK, I understand</button>
|
| 200 |
+
</div>
|
| 201 |
+
</div>
|
| 202 |
+
|
| 203 |
+
<script>
|
| 204 |
+
var USER_ROLE = "{role}";
|
| 205 |
+
function tryPortal(portal) {
|
| 206 |
+
if (portal !== USER_ROLE) {
|
| 207 |
+
var roleLabel = USER_ROLE === 'employee' ? 'a Full-time Employee' : 'an Intern';
|
| 208 |
+
var correctPortal = USER_ROLE === 'employee' ? 'Employee Portal' : 'Intern Portal';
|
| 209 |
+
document.getElementById('warningMsg').textContent =
|
| 210 |
+
'You are logged in as ' + roleLabel + '. Please use the ' + correctPortal + ' instead.';
|
| 211 |
+
document.getElementById('warningModal').classList.add('active');
|
| 212 |
+
} else {
|
| 213 |
+
window.location.href = '/form?portal=' + portal;
|
| 214 |
+
}
|
| 215 |
+
}
|
| 216 |
+
function closeModal() {
|
| 217 |
+
document.getElementById('warningModal').classList.remove('active');
|
| 218 |
+
}
|
| 219 |
+
</script>
|
| 220 |
+
</body>
|
| 221 |
+
</html>"""
|
| 222 |
+
|
| 223 |
+
FORM_HTML = """<!DOCTYPE html>
|
| 224 |
+
<html lang="en">
|
| 225 |
+
<head>
|
| 226 |
+
<meta charset="UTF-8">
|
| 227 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 228 |
+
<title>Reimbursement Form - TechCorp</title>
|
| 229 |
+
<style>
|
| 230 |
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 231 |
+
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #f0f2f5; color: #333; }
|
| 232 |
+
.header { background: linear-gradient(135deg, #1a237e, #283593); color: white; padding: 20px 40px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
|
| 233 |
+
.header h1 { font-size: 24px; font-weight: 600; }
|
| 234 |
+
.breadcrumb { font-size: 13px; opacity: 0.8; margin-top: 4px; }
|
| 235 |
+
.breadcrumb a { color: white; text-decoration: underline; }
|
| 236 |
+
.container { max-width: 720px; margin: 30px auto; padding: 0 20px; }
|
| 237 |
+
.form-card { background: white; border-radius: 8px; padding: 32px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
|
| 238 |
+
.form-card h2 { color: #1a237e; margin-bottom: 24px; font-size: 20px; }
|
| 239 |
+
.form-group { margin-bottom: 20px; }
|
| 240 |
+
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
|
| 241 |
+
.form-group label .required { color: #c62828; }
|
| 242 |
+
.form-group input[type="text"],
|
| 243 |
+
.form-group input[type="number"],
|
| 244 |
+
.form-group textarea,
|
| 245 |
+
.form-group select { width: 100%; padding: 10px 14px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; transition: border-color 0.2s; }
|
| 246 |
+
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: #1a237e; outline: none; box-shadow: 0 0 0 2px rgba(26,35,126,0.1); }
|
| 247 |
+
.form-group textarea { resize: vertical; min-height: 80px; }
|
| 248 |
+
.form-group input[type="file"] { padding: 8px; }
|
| 249 |
+
.form-group .help-text { font-size: 12px; color: #777; margin-top: 4px; }
|
| 250 |
+
.section-divider { border: none; border-top: 1px solid #e0e0e0; margin: 24px 0; }
|
| 251 |
+
.intern-section { background: #e0f2f1; border: 1px solid #80cbc4; border-radius: 8px; padding: 20px; margin-bottom: 20px; }
|
| 252 |
+
.intern-section h3 { color: #00695c; margin-bottom: 12px; font-size: 16px; }
|
| 253 |
+
.high-value-section { background: #fff3e0; border: 1px solid #ffb74d; border-radius: 8px; padding: 20px; margin-bottom: 20px; display: none; }
|
| 254 |
+
.high-value-section.visible { display: block; }
|
| 255 |
+
.high-value-section h3 { color: #e65100; margin-bottom: 12px; font-size: 16px; }
|
| 256 |
+
.submit-btn { background: #1a237e; color: white; border: none; padding: 14px 32px; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer; width: 100%; margin-top: 16px; transition: all 0.2s; }
|
| 257 |
+
.submit-btn:hover { background: #283593; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,35,126,0.3); }
|
| 258 |
+
.error-msg { color: #c62828; font-size: 13px; margin-top: 4px; display: none; }
|
| 259 |
+
.error-msg.visible { display: block; }
|
| 260 |
+
.form-error-banner { background: #fce4ec; border: 1px solid #ef9a9a; border-radius: 8px; padding: 16px; margin-bottom: 20px; display: none; }
|
| 261 |
+
.form-error-banner.visible { display: block; }
|
| 262 |
+
.form-error-banner p { color: #c62828; font-size: 14px; }
|
| 263 |
+
</style>
|
| 264 |
+
</head>
|
| 265 |
+
<body>
|
| 266 |
+
<div class="header">
|
| 267 |
+
<h1>🏢 TechCorp Expense Reimbursement System</h1>
|
| 268 |
+
<div class="breadcrumb"><a href="/">Home</a> → {portal_label} → Reimbursement Form</div>
|
| 269 |
+
</div>
|
| 270 |
+
<div class="container">
|
| 271 |
+
<div class="form-card">
|
| 272 |
+
<h2>📝 Expense Reimbursement Form</h2>
|
| 273 |
+
<p style="margin-bottom: 20px; color: #555;">Logged in as: <strong>{display_name}</strong> ({role_label})</p>
|
| 274 |
+
|
| 275 |
+
<div class="form-error-banner" id="errorBanner">
|
| 276 |
+
<p id="errorBannerMsg">⚠️ Please fix the errors below before submitting.</p>
|
| 277 |
+
</div>
|
| 278 |
+
|
| 279 |
+
<form id="reimbursementForm" action="/submit" method="POST" enctype="multipart/form-data">
|
| 280 |
+
<input type="hidden" name="portal_used" value="{portal}">
|
| 281 |
+
|
| 282 |
+
<div class="form-group">
|
| 283 |
+
<label>Invoice Files <span class="required">*</span></label>
|
| 284 |
+
<input type="file" name="invoices" id="invoices" multiple accept=".pdf,.png,.jpg,.jpeg">
|
| 285 |
+
<div class="help-text">Upload your invoice files (PDF or image). You can select multiple files.</div>
|
| 286 |
+
<div class="error-msg" id="err-invoices">Please upload at least one invoice file.</div>
|
| 287 |
+
</div>
|
| 288 |
+
|
| 289 |
+
<div class="form-group">
|
| 290 |
+
<label>Total Amount (¥) <span class="required">*</span></label>
|
| 291 |
+
<input type="number" name="amount" id="amount" step="0.01" min="0.01" placeholder="e.g. 605.00" oninput="checkAmount()">
|
| 292 |
+
<div class="help-text">Enter the combined total of all invoices.</div>
|
| 293 |
+
<div class="error-msg" id="err-amount">Please enter a valid amount greater than 0.</div>
|
| 294 |
+
</div>
|
| 295 |
+
|
| 296 |
+
<div class="form-group">
|
| 297 |
+
<label>Expense Category <span class="required">*</span></label>
|
| 298 |
+
<select name="category" id="category">
|
| 299 |
+
<option value="">-- Select a category --</option>
|
| 300 |
+
<option value="Transportation">Transportation</option>
|
| 301 |
+
<option value="Meals">Meals</option>
|
| 302 |
+
<option value="Office Supplies">Office Supplies</option>
|
| 303 |
+
<option value="Training">Training</option>
|
| 304 |
+
<option value="Other">Other</option>
|
| 305 |
+
</select>
|
| 306 |
+
<div class="error-msg" id="err-category">Please select a category.</div>
|
| 307 |
+
</div>
|
| 308 |
+
|
| 309 |
+
<div class="form-group">
|
| 310 |
+
<label>Description <span class="required">*</span></label>
|
| 311 |
+
<input type="text" name="description" id="description" placeholder="Brief description of the expense">
|
| 312 |
+
<div class="error-msg" id="err-description">Please enter a description.</div>
|
| 313 |
+
</div>
|
| 314 |
+
|
| 315 |
+
{intern_section}
|
| 316 |
+
|
| 317 |
+
<div class="high-value-section" id="highValueSection">
|
| 318 |
+
<h3>⚠️ High-Value Expense (Amount exceeds ¥1,000)</h3>
|
| 319 |
+
<p style="margin-bottom: 16px; font-size: 14px; color: #555;">Additional documentation is required for expenses over ¥1,000.</p>
|
| 320 |
+
|
| 321 |
+
<div class="form-group">
|
| 322 |
+
<label>Justification Statement <span class="required">*</span></label>
|
| 323 |
+
<textarea name="justification" id="justification" placeholder="Explain why this expense is necessary (at least 20 characters)"></textarea>
|
| 324 |
+
<div class="help-text">Minimum 20 characters. Explain the business necessity of this expense.</div>
|
| 325 |
+
<div class="error-msg" id="err-justification">Justification must be at least 20 characters.</div>
|
| 326 |
+
</div>
|
| 327 |
+
|
| 328 |
+
<div class="form-group">
|
| 329 |
+
<label>Approval Report <span class="required">*</span></label>
|
| 330 |
+
<input type="file" name="approval_report" id="approval_report" accept=".pdf">
|
| 331 |
+
<div class="help-text">Upload the manager-signed approval document (PDF only).</div>
|
| 332 |
+
<div class="error-msg" id="err-approval">Please upload the approval report.</div>
|
| 333 |
+
</div>
|
| 334 |
+
</div>
|
| 335 |
+
|
| 336 |
+
<button type="submit" class="submit-btn" onclick="return validateForm()">Submit Reimbursement</button>
|
| 337 |
+
</form>
|
| 338 |
+
</div>
|
| 339 |
+
</div>
|
| 340 |
+
|
| 341 |
+
<script>
|
| 342 |
+
function checkAmount() {
|
| 343 |
+
var amount = parseFloat(document.getElementById('amount').value);
|
| 344 |
+
var section = document.getElementById('highValueSection');
|
| 345 |
+
if (amount > 1000) {
|
| 346 |
+
section.classList.add('visible');
|
| 347 |
+
} else {
|
| 348 |
+
section.classList.remove('visible');
|
| 349 |
+
}
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
function validateForm() {
|
| 353 |
+
var valid = true;
|
| 354 |
+
var errors = [];
|
| 355 |
+
|
| 356 |
+
// Reset all error messages
|
| 357 |
+
document.querySelectorAll('.error-msg').forEach(function(el) { el.classList.remove('visible'); });
|
| 358 |
+
document.getElementById('errorBanner').classList.remove('visible');
|
| 359 |
+
|
| 360 |
+
// Check invoices
|
| 361 |
+
var invoices = document.getElementById('invoices');
|
| 362 |
+
if (!invoices.files || invoices.files.length === 0) {
|
| 363 |
+
document.getElementById('err-invoices').classList.add('visible');
|
| 364 |
+
valid = false;
|
| 365 |
+
errors.push('Invoice files are required');
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
// Check amount
|
| 369 |
+
var amount = parseFloat(document.getElementById('amount').value);
|
| 370 |
+
if (isNaN(amount) || amount <= 0) {
|
| 371 |
+
document.getElementById('err-amount').classList.add('visible');
|
| 372 |
+
valid = false;
|
| 373 |
+
errors.push('Valid amount is required');
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
// Check category
|
| 377 |
+
if (!document.getElementById('category').value) {
|
| 378 |
+
document.getElementById('err-category').classList.add('visible');
|
| 379 |
+
valid = false;
|
| 380 |
+
errors.push('Category is required');
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
// Check description
|
| 384 |
+
if (!document.getElementById('description').value.trim()) {
|
| 385 |
+
document.getElementById('err-description').classList.add('visible');
|
| 386 |
+
valid = false;
|
| 387 |
+
errors.push('Description is required');
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
// Check intern fields if present
|
| 391 |
+
var mentorField = document.getElementById('mentor_id');
|
| 392 |
+
if (mentorField) {
|
| 393 |
+
if (!mentorField.value.trim()) {
|
| 394 |
+
document.getElementById('err-mentor').classList.add('visible');
|
| 395 |
+
valid = false;
|
| 396 |
+
errors.push('Mentor ID is required');
|
| 397 |
+
}
|
| 398 |
+
var deptCode = document.getElementById('dept_approval_code');
|
| 399 |
+
if (!deptCode.value.trim()) {
|
| 400 |
+
document.getElementById('err-deptcode').classList.add('visible');
|
| 401 |
+
valid = false;
|
| 402 |
+
errors.push('Department approval code is required');
|
| 403 |
+
}
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
// Check high-value fields if amount > 1000
|
| 407 |
+
if (amount > 1000) {
|
| 408 |
+
var justification = document.getElementById('justification').value.trim();
|
| 409 |
+
if (justification.length < 20) {
|
| 410 |
+
document.getElementById('err-justification').classList.add('visible');
|
| 411 |
+
valid = false;
|
| 412 |
+
errors.push('Justification must be at least 20 characters');
|
| 413 |
+
}
|
| 414 |
+
var approvalReport = document.getElementById('approval_report');
|
| 415 |
+
if (!approvalReport.files || approvalReport.files.length === 0) {
|
| 416 |
+
document.getElementById('err-approval').classList.add('visible');
|
| 417 |
+
valid = false;
|
| 418 |
+
errors.push('Approval report is required for amounts over 1000');
|
| 419 |
+
}
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
if (!valid) {
|
| 423 |
+
var banner = document.getElementById('errorBanner');
|
| 424 |
+
document.getElementById('errorBannerMsg').textContent = '\\u26a0\\ufe0f ' + errors.join('; ') + '. Please fix before submitting.';
|
| 425 |
+
banner.classList.add('visible');
|
| 426 |
+
banner.scrollIntoView({ behavior: 'smooth' });
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
return valid;
|
| 430 |
+
}
|
| 431 |
+
</script>
|
| 432 |
+
</body>
|
| 433 |
+
</html>"""
|
| 434 |
+
|
| 435 |
+
INTERN_SECTION_HTML = """
|
| 436 |
+
<hr class="section-divider">
|
| 437 |
+
<div class="intern-section">
|
| 438 |
+
<h3>📚 Intern Additional Information</h3>
|
| 439 |
+
<p style="margin-bottom: 16px; font-size: 14px; color: #555;">As an intern, you need to provide the following additional details.</p>
|
| 440 |
+
|
| 441 |
+
<div class="form-group">
|
| 442 |
+
<label>Mentor ID <span class="required">*</span></label>
|
| 443 |
+
<input type="text" name="mentor_id" id="mentor_id" placeholder="e.g. EMP-20180042">
|
| 444 |
+
<div class="help-text">Enter your mentor's employee ID as shown in your internship agreement.</div>
|
| 445 |
+
<div class="error-msg" id="err-mentor">Please enter your mentor's ID.</div>
|
| 446 |
+
</div>
|
| 447 |
+
|
| 448 |
+
<div class="form-group">
|
| 449 |
+
<label>Department Approval Code <span class="required">*</span></label>
|
| 450 |
+
<input type="text" name="dept_approval_code" id="dept_approval_code" placeholder="e.g. DEPT-2026-0517">
|
| 451 |
+
<div class="help-text">Your department approval code (format: DEPT-XXXX). Check your approval documents.</div>
|
| 452 |
+
<div class="error-msg" id="err-deptcode">Please enter the department approval code.</div>
|
| 453 |
+
</div>
|
| 454 |
+
</div>
|
| 455 |
+
"""
|
| 456 |
+
|
| 457 |
+
SUCCESS_HTML = """<!DOCTYPE html>
|
| 458 |
+
<html lang="en">
|
| 459 |
+
<head>
|
| 460 |
+
<meta charset="UTF-8">
|
| 461 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 462 |
+
<title>Submission Successful - TechCorp</title>
|
| 463 |
+
<style>
|
| 464 |
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 465 |
+
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #f0f2f5; color: #333; }
|
| 466 |
+
.header { background: linear-gradient(135deg, #1a237e, #283593); color: white; padding: 20px 40px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
|
| 467 |
+
.header h1 { font-size: 24px; font-weight: 600; }
|
| 468 |
+
.container { max-width: 720px; margin: 30px auto; padding: 0 20px; }
|
| 469 |
+
.success-card { background: white; border-radius: 8px; padding: 40px 32px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); text-align: center; }
|
| 470 |
+
.success-icon { font-size: 64px; margin-bottom: 16px; }
|
| 471 |
+
.success-card h2 { color: #2e7d32; margin-bottom: 12px; }
|
| 472 |
+
.success-card .ref-number { background: #e8f5e9; display: inline-block; padding: 8px 20px; border-radius: 20px; font-family: monospace; font-size: 16px; color: #1b5e20; margin: 12px 0; }
|
| 473 |
+
.details-table { margin: 24px auto; text-align: left; border-collapse: collapse; width: 80%; }
|
| 474 |
+
.details-table td { padding: 8px 12px; border-bottom: 1px solid #eee; font-size: 14px; }
|
| 475 |
+
.details-table td:first-child { font-weight: 600; color: #555; width: 40%; }
|
| 476 |
+
.back-link { display: inline-block; margin-top: 24px; color: #1a237e; text-decoration: none; font-weight: 500; }
|
| 477 |
+
.back-link:hover { text-decoration: underline; }
|
| 478 |
+
</style>
|
| 479 |
+
</head>
|
| 480 |
+
<body>
|
| 481 |
+
<div class="header">
|
| 482 |
+
<h1>🏢 TechCorp Expense Reimbursement System</h1>
|
| 483 |
+
</div>
|
| 484 |
+
<div class="container">
|
| 485 |
+
<div class="success-card">
|
| 486 |
+
<div class="success-icon">✅</div>
|
| 487 |
+
<h2>Reimbursement Submitted Successfully!</h2>
|
| 488 |
+
<div class="ref-number">{reference_number}</div>
|
| 489 |
+
<table class="details-table">
|
| 490 |
+
<tr><td>Amount:</td><td>¥{amount}</td></tr>
|
| 491 |
+
<tr><td>Category:</td><td>{category}</td></tr>
|
| 492 |
+
<tr><td>Description:</td><td>{description}</td></tr>
|
| 493 |
+
<tr><td>Invoice Files:</td><td>{invoice_count} file(s) uploaded</td></tr>
|
| 494 |
+
<tr><td>Status:</td><td><span style="color: #2e7d32; font-weight: 600;">Pending Review</span></td></tr>
|
| 495 |
+
</table>
|
| 496 |
+
<p style="margin-top: 20px; color: #555; font-size: 14px;">Your submission has been recorded and is awaiting review.</p>
|
| 497 |
+
<a href="/" class="back-link">← Back to Home</a>
|
| 498 |
+
</div>
|
| 499 |
+
</div>
|
| 500 |
+
</body>
|
| 501 |
+
</html>"""
|
| 502 |
+
|
| 503 |
+
|
| 504 |
+
class OARequestHandler(BaseHTTPRequestHandler):
|
| 505 |
+
"""HTTP request handler for the OA reimbursement system."""
|
| 506 |
+
|
| 507 |
+
def log_message(self, format, *args):
|
| 508 |
+
"""Override to log to stderr with timestamp."""
|
| 509 |
+
sys.stderr.write("[%s] %s\n" % (
|
| 510 |
+
time.strftime("%Y-%m-%d %H:%M:%S"), format % args))
|
| 511 |
+
|
| 512 |
+
def do_GET(self):
|
| 513 |
+
parsed = urlparse(self.path)
|
| 514 |
+
path = parsed.path
|
| 515 |
+
|
| 516 |
+
if path == "/" or path == "":
|
| 517 |
+
self._serve_homepage()
|
| 518 |
+
elif path == "/form":
|
| 519 |
+
params = parse_qs(parsed.query)
|
| 520 |
+
portal = params.get("portal", [""])[0]
|
| 521 |
+
self._serve_form(portal)
|
| 522 |
+
else:
|
| 523 |
+
self._send_404()
|
| 524 |
+
|
| 525 |
+
def do_POST(self):
|
| 526 |
+
parsed = urlparse(self.path)
|
| 527 |
+
if parsed.path == "/submit":
|
| 528 |
+
self._handle_submit()
|
| 529 |
+
else:
|
| 530 |
+
self._send_404()
|
| 531 |
+
|
| 532 |
+
def _serve_homepage(self):
|
| 533 |
+
"""Serve the homepage with guide and portal buttons."""
|
| 534 |
+
user_config = self.server.user_config
|
| 535 |
+
role = user_config["role"]
|
| 536 |
+
display_name = user_config["display_name"]
|
| 537 |
+
|
| 538 |
+
if role == "employee":
|
| 539 |
+
role_label = "Full-time Employee"
|
| 540 |
+
else:
|
| 541 |
+
role_label = "Intern"
|
| 542 |
+
|
| 543 |
+
html = HOMEPAGE_HTML.replace(
|
| 544 |
+
"{display_name}", display_name
|
| 545 |
+
).replace(
|
| 546 |
+
"{role_label}", role_label
|
| 547 |
+
).replace(
|
| 548 |
+
"{role}", role
|
| 549 |
+
)
|
| 550 |
+
self._send_html(html)
|
| 551 |
+
|
| 552 |
+
def _serve_form(self, portal):
|
| 553 |
+
"""Serve the reimbursement form."""
|
| 554 |
+
user_config = self.server.user_config
|
| 555 |
+
role = user_config["role"]
|
| 556 |
+
display_name = user_config["display_name"]
|
| 557 |
+
|
| 558 |
+
if role == "employee":
|
| 559 |
+
role_label = "Full-time Employee"
|
| 560 |
+
else:
|
| 561 |
+
role_label = "Intern"
|
| 562 |
+
|
| 563 |
+
if portal == "employee":
|
| 564 |
+
portal_label = "Employee Portal"
|
| 565 |
+
else:
|
| 566 |
+
portal_label = "Intern Portal"
|
| 567 |
+
|
| 568 |
+
# Determine if intern section should be shown
|
| 569 |
+
intern_section = ""
|
| 570 |
+
if portal == "intern":
|
| 571 |
+
intern_section = INTERN_SECTION_HTML
|
| 572 |
+
|
| 573 |
+
html = FORM_HTML.replace(
|
| 574 |
+
"{display_name}", display_name
|
| 575 |
+
).replace(
|
| 576 |
+
"{role_label}", role_label
|
| 577 |
+
).replace(
|
| 578 |
+
"{portal_label}", portal_label
|
| 579 |
+
).replace(
|
| 580 |
+
"{portal}", portal
|
| 581 |
+
).replace(
|
| 582 |
+
"{intern_section}", intern_section
|
| 583 |
+
)
|
| 584 |
+
self._send_html(html)
|
| 585 |
+
|
| 586 |
+
def _handle_submit(self):
|
| 587 |
+
"""Handle form submission: save data + files to DATA_DIR."""
|
| 588 |
+
content_type = self.headers.get("Content-Type", "")
|
| 589 |
+
if "multipart/form-data" not in content_type:
|
| 590 |
+
self._send_error(400, "Invalid content type")
|
| 591 |
+
return
|
| 592 |
+
|
| 593 |
+
# Extract boundary from content-type header
|
| 594 |
+
boundary = None
|
| 595 |
+
for part in content_type.split(";"):
|
| 596 |
+
part = part.strip()
|
| 597 |
+
if part.startswith("boundary="):
|
| 598 |
+
boundary = part[len("boundary="):].strip('"')
|
| 599 |
+
break
|
| 600 |
+
|
| 601 |
+
if not boundary:
|
| 602 |
+
self._send_error(400, "Missing boundary in content type")
|
| 603 |
+
return
|
| 604 |
+
|
| 605 |
+
# Read request body
|
| 606 |
+
content_length = int(self.headers.get("Content-Length", 0))
|
| 607 |
+
body = self.rfile.read(content_length)
|
| 608 |
+
|
| 609 |
+
# Parse multipart form data
|
| 610 |
+
form = parse_multipart(body, boundary)
|
| 611 |
+
|
| 612 |
+
# Ensure data directory exists
|
| 613 |
+
os.makedirs(DATA_DIR, exist_ok=True)
|
| 614 |
+
|
| 615 |
+
# Extract form fields
|
| 616 |
+
portal_used = self._get_field(form, "portal_used", "")
|
| 617 |
+
amount_str = self._get_field(form, "amount", "0")
|
| 618 |
+
category = self._get_field(form, "category", "")
|
| 619 |
+
description = self._get_field(form, "description", "")
|
| 620 |
+
justification = self._get_field(form, "justification", "")
|
| 621 |
+
mentor_id = self._get_field(form, "mentor_id", "")
|
| 622 |
+
dept_approval_code = self._get_field(form, "dept_approval_code", "")
|
| 623 |
+
|
| 624 |
+
try:
|
| 625 |
+
amount = float(amount_str)
|
| 626 |
+
except (ValueError, TypeError):
|
| 627 |
+
amount = 0.0
|
| 628 |
+
|
| 629 |
+
# Save uploaded invoice files
|
| 630 |
+
invoice_files = []
|
| 631 |
+
if "invoices" in form:
|
| 632 |
+
invoices_field = form["invoices"]
|
| 633 |
+
if not isinstance(invoices_field, list):
|
| 634 |
+
invoices_field = [invoices_field]
|
| 635 |
+
for item in invoices_field:
|
| 636 |
+
if isinstance(item, UploadedFile) and item.filename:
|
| 637 |
+
filename = os.path.basename(item.filename)
|
| 638 |
+
filepath = os.path.join(DATA_DIR, filename)
|
| 639 |
+
with open(filepath, "wb") as f:
|
| 640 |
+
f.write(item.read())
|
| 641 |
+
invoice_files.append(filename)
|
| 642 |
+
|
| 643 |
+
# Save approval report if present
|
| 644 |
+
approval_report_filename = None
|
| 645 |
+
if "approval_report" in form:
|
| 646 |
+
ar_field = form["approval_report"]
|
| 647 |
+
if isinstance(ar_field, list):
|
| 648 |
+
ar_field = ar_field[0]
|
| 649 |
+
if isinstance(ar_field, UploadedFile) and ar_field.filename:
|
| 650 |
+
filename = os.path.basename(ar_field.filename)
|
| 651 |
+
filepath = os.path.join(DATA_DIR, filename)
|
| 652 |
+
with open(filepath, "wb") as f:
|
| 653 |
+
f.write(ar_field.read())
|
| 654 |
+
approval_report_filename = filename
|
| 655 |
+
|
| 656 |
+
# Build submission record
|
| 657 |
+
user_config = self.server.user_config
|
| 658 |
+
ref_number = "EXP-%s-%03d" % (
|
| 659 |
+
time.strftime("%Y%m%d"), int(time.time()) % 1000)
|
| 660 |
+
|
| 661 |
+
submission = {
|
| 662 |
+
"timestamp": time.strftime("%Y-%m-%dT%H:%M:%S"),
|
| 663 |
+
"user": user_config["user"],
|
| 664 |
+
"role": user_config["role"],
|
| 665 |
+
"portal_used": portal_used,
|
| 666 |
+
"amount": amount,
|
| 667 |
+
"category": category,
|
| 668 |
+
"description": description,
|
| 669 |
+
"justification": justification if justification else None,
|
| 670 |
+
"mentor_id": mentor_id if mentor_id else None,
|
| 671 |
+
"dept_approval_code": dept_approval_code if dept_approval_code else None,
|
| 672 |
+
"invoice_files": invoice_files,
|
| 673 |
+
"approval_report_filename": approval_report_filename,
|
| 674 |
+
"reference_number": ref_number,
|
| 675 |
+
"status": "submitted"
|
| 676 |
+
}
|
| 677 |
+
|
| 678 |
+
# Write submission.json
|
| 679 |
+
submission_path = os.path.join(DATA_DIR, "submission.json")
|
| 680 |
+
with open(submission_path, "w", encoding="utf-8") as f:
|
| 681 |
+
json.dump(submission, f, indent=2, ensure_ascii=False)
|
| 682 |
+
|
| 683 |
+
# Serve success page
|
| 684 |
+
html = SUCCESS_HTML.replace(
|
| 685 |
+
"{reference_number}", ref_number
|
| 686 |
+
).replace(
|
| 687 |
+
"{amount}", "%.2f" % amount
|
| 688 |
+
).replace(
|
| 689 |
+
"{category}", category
|
| 690 |
+
).replace(
|
| 691 |
+
"{description}", description
|
| 692 |
+
).replace(
|
| 693 |
+
"{invoice_count}", str(len(invoice_files))
|
| 694 |
+
)
|
| 695 |
+
self._send_html(html)
|
| 696 |
+
|
| 697 |
+
self.log_message("Submission saved: %s (amount=%.2f, invoices=%d)",
|
| 698 |
+
ref_number, amount, len(invoice_files))
|
| 699 |
+
|
| 700 |
+
def _get_field(self, form, name, default=""):
|
| 701 |
+
"""Safely get a form field value from parsed multipart data."""
|
| 702 |
+
if name in form:
|
| 703 |
+
field = form[name]
|
| 704 |
+
if isinstance(field, list):
|
| 705 |
+
field = field[0]
|
| 706 |
+
if isinstance(field, UploadedFile):
|
| 707 |
+
return field.filename # For file fields, return filename
|
| 708 |
+
return str(field)
|
| 709 |
+
return default
|
| 710 |
+
|
| 711 |
+
def _send_html(self, html, status=200):
|
| 712 |
+
"""Send an HTML response."""
|
| 713 |
+
encoded = html.encode("utf-8")
|
| 714 |
+
self.send_response(status)
|
| 715 |
+
self.send_header("Content-Type", "text/html; charset=utf-8")
|
| 716 |
+
self.send_header("Content-Length", str(len(encoded)))
|
| 717 |
+
self.end_headers()
|
| 718 |
+
self.wfile.write(encoded)
|
| 719 |
+
|
| 720 |
+
def _send_error(self, code, message):
|
| 721 |
+
"""Send a simple error response."""
|
| 722 |
+
self._send_html("<h1>Error %d</h1><p>%s</p>" % (code, message), code)
|
| 723 |
+
|
| 724 |
+
def _send_404(self):
|
| 725 |
+
"""Send 404 response."""
|
| 726 |
+
self._send_html("<h1>404 Not Found</h1><p>The requested page does not exist.</p>", 404)
|
| 727 |
+
|
| 728 |
+
|
| 729 |
+
def format_display_name(user_id):
|
| 730 |
+
"""Convert user_id like 'zhang_wei' to 'Zhang Wei'."""
|
| 731 |
+
return " ".join(part.capitalize() for part in user_id.split("_"))
|
| 732 |
+
|
| 733 |
+
|
| 734 |
+
def main():
|
| 735 |
+
global DATA_DIR
|
| 736 |
+
|
| 737 |
+
parser = argparse.ArgumentParser(
|
| 738 |
+
description="TechCorp Expense Reimbursement System (Fake OA Server)")
|
| 739 |
+
parser.add_argument("--user", required=True,
|
| 740 |
+
help="User ID (e.g. zhang_wei)")
|
| 741 |
+
parser.add_argument("--role", required=True, choices=["employee", "intern"],
|
| 742 |
+
help="User role: employee or intern")
|
| 743 |
+
parser.add_argument("--port", type=int, default=DEFAULT_PORT,
|
| 744 |
+
help="Port to listen on (default: %d)" % DEFAULT_PORT)
|
| 745 |
+
parser.add_argument("--data-dir", default=DATA_DIR,
|
| 746 |
+
help="Directory to save submission data (default: %s)" % DATA_DIR)
|
| 747 |
+
args = parser.parse_args()
|
| 748 |
+
|
| 749 |
+
DATA_DIR = args.data_dir
|
| 750 |
+
os.makedirs(DATA_DIR, exist_ok=True)
|
| 751 |
+
|
| 752 |
+
# Configure server
|
| 753 |
+
server = HTTPServer(("0.0.0.0", args.port), OARequestHandler)
|
| 754 |
+
server.user_config = {
|
| 755 |
+
"user": args.user,
|
| 756 |
+
"role": args.role,
|
| 757 |
+
"display_name": format_display_name(args.user),
|
| 758 |
+
}
|
| 759 |
+
|
| 760 |
+
url = "http://localhost:%d/" % args.port
|
| 761 |
+
|
| 762 |
+
print("=" * 60)
|
| 763 |
+
print(" TechCorp Expense Reimbursement System")
|
| 764 |
+
print(" " + "-" * 56)
|
| 765 |
+
print(" User: %s (%s)" % (server.user_config["display_name"], args.role))
|
| 766 |
+
print(" Port: %d" % args.port)
|
| 767 |
+
print(" Data: %s" % DATA_DIR)
|
| 768 |
+
print(" URL: %s" % url)
|
| 769 |
+
print("=" * 60)
|
| 770 |
+
print("\nServer is running. Press Ctrl+C to stop.\n")
|
| 771 |
+
try:
|
| 772 |
+
server.serve_forever()
|
| 773 |
+
except KeyboardInterrupt:
|
| 774 |
+
print("\nShutting down server...")
|
| 775 |
+
server.shutdown()
|
| 776 |
+
|
| 777 |
+
|
| 778 |
+
if __name__ == "__main__":
|
| 779 |
+
main()
|
fin_expense_claim_002__long__cond/5cb11caa-90fb-53cc-9f6b-1489523366db_manager_approval.pdf
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%PDF-1.3
|
| 2 |
+
%���� ReportLab Generated PDF document (opensource)
|
| 3 |
+
1 0 obj
|
| 4 |
+
<<
|
| 5 |
+
/F1 2 0 R /F2 3 0 R
|
| 6 |
+
>>
|
| 7 |
+
endobj
|
| 8 |
+
2 0 obj
|
| 9 |
+
<<
|
| 10 |
+
/BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font
|
| 11 |
+
>>
|
| 12 |
+
endobj
|
| 13 |
+
3 0 obj
|
| 14 |
+
<<
|
| 15 |
+
/BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding /Name /F2 /Subtype /Type1 /Type /Font
|
| 16 |
+
>>
|
| 17 |
+
endobj
|
| 18 |
+
4 0 obj
|
| 19 |
+
<<
|
| 20 |
+
/Contents 8 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 7 0 R /Resources <<
|
| 21 |
+
/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
|
| 22 |
+
>> /Rotate 0 /Trans <<
|
| 23 |
+
|
| 24 |
+
>>
|
| 25 |
+
/Type /Page
|
| 26 |
+
>>
|
| 27 |
+
endobj
|
| 28 |
+
5 0 obj
|
| 29 |
+
<<
|
| 30 |
+
/PageMode /UseNone /Pages 7 0 R /Type /Catalog
|
| 31 |
+
>>
|
| 32 |
+
endobj
|
| 33 |
+
6 0 obj
|
| 34 |
+
<<
|
| 35 |
+
/Author (anonymous) /CreationDate (D:20260517182107+08'00') /Creator (anonymous) /Keywords () /ModDate (D:20260517182107+08'00') /Producer (ReportLab PDF Library - \(opensource\))
|
| 36 |
+
/Subject (unspecified) /Title (untitled) /Trapped /False
|
| 37 |
+
>>
|
| 38 |
+
endobj
|
| 39 |
+
7 0 obj
|
| 40 |
+
<<
|
| 41 |
+
/Count 1 /Kids [ 4 0 R ] /Type /Pages
|
| 42 |
+
>>
|
| 43 |
+
endobj
|
| 44 |
+
8 0 obj
|
| 45 |
+
<<
|
| 46 |
+
/Filter [ /ASCII85Decode /FlateDecode ] /Length 816
|
| 47 |
+
>>
|
| 48 |
+
stream
|
| 49 |
+
GatUr;/ao;&BE]*.IN=lc1megG'IM6i<@0L7=``1'X_6dPWHWU43FJaP-eLM%>9ZY[FWn-kBHXqmLV@+YkqaE!Nn5'obIQ3AG:U/M]mEXo5)k."e]c#!a5)-a.icP`=bHmPY@I1S<e'O`J<72CZF>I?+XjDQ`r/djdHRu^-hV"Q!a[iBCTkkn1_+4l]Y;D#V$T@;+eV>A>GXC69X$p\=K./Z,;PlA;pDErIh42dn,-G%6-_SA;<7IQFj9(%:k7J]H0oKj\7*kJV)!C5>dsNXGuo8]E(ecs,f(aS42('0$M"K`\)lELLTj.2ckThjGM,2c7p"di@J$(5P&%7KVK!1:0bk-Yp.I-f;eRe>F3mVKVK!q^2@u'L<l`I],/69n[Aa%gg,SR@R'.ecd]L@g*d@V*Qh[VHsr$/0Je&S<coo4Lac85>XZ[nYd`.8*-ENP-Xqq!a<fl?-S?,he;,?f.0\eDEee&DTkNS/le<DF2aq:F0dX+Rd_4Bo4',KI3%d^)e$<Z9f=p`Cj.WG[;=';6`JSi4Z?uG/TOCI-`eC]srg,+ch>@&UAm@%f:i*]t[_5V+n9>2r=@#8^3AM>+BE1[ok`u]skC]0mRQ!0`O.YR@5e^>FdlQ#h^Al<J,K4:O-jM)5%Fn\1e_;lRU_MWIPld,*.nXsI;XDW,glc/eLI"r>LiF,NlVTl3'<!"7&>b#.i(r*]d'XYR\[*Etrct4VCR/Z!18kYDQmQNs-T?a7eZ!`@fT^"$\B5T1]IXSt2V'kAdhUqe72(Xc>;bKkO'P&Cj\Tk*^7>YG=BgXlB@q_G-GKRL(aTL~>endstream
|
| 50 |
+
endobj
|
| 51 |
+
xref
|
| 52 |
+
0 9
|
| 53 |
+
0000000000 65535 f
|
| 54 |
+
0000000061 00000 n
|
| 55 |
+
0000000102 00000 n
|
| 56 |
+
0000000209 00000 n
|
| 57 |
+
0000000321 00000 n
|
| 58 |
+
0000000524 00000 n
|
| 59 |
+
0000000592 00000 n
|
| 60 |
+
0000000853 00000 n
|
| 61 |
+
0000000912 00000 n
|
| 62 |
+
trailer
|
| 63 |
+
<<
|
| 64 |
+
/ID
|
| 65 |
+
[<0612e7b4c5688218dcc1822c23642fe4><0612e7b4c5688218dcc1822c23642fe4>]
|
| 66 |
+
% ReportLab generated PDF document -- digest (opensource)
|
| 67 |
+
|
| 68 |
+
/Info 6 0 R
|
| 69 |
+
/Root 5 0 R
|
| 70 |
+
/Size 9
|
| 71 |
+
>>
|
| 72 |
+
startxref
|
| 73 |
+
1818
|
| 74 |
+
%%EOF
|
fin_expense_claim_002__long__cond/999fca2d-ceec-581b-9623-500d62780607_invoice_1.pdf
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%PDF-1.3
|
| 2 |
+
%���� ReportLab Generated PDF document (opensource)
|
| 3 |
+
1 0 obj
|
| 4 |
+
<<
|
| 5 |
+
/F1 2 0 R /F2 3 0 R /F3 4 0 R
|
| 6 |
+
>>
|
| 7 |
+
endobj
|
| 8 |
+
2 0 obj
|
| 9 |
+
<<
|
| 10 |
+
/BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font
|
| 11 |
+
>>
|
| 12 |
+
endobj
|
| 13 |
+
3 0 obj
|
| 14 |
+
<<
|
| 15 |
+
/BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding /Name /F2 /Subtype /Type1 /Type /Font
|
| 16 |
+
>>
|
| 17 |
+
endobj
|
| 18 |
+
4 0 obj
|
| 19 |
+
<<
|
| 20 |
+
/BaseFont /Symbol /Name /F3 /Subtype /Type1 /Type /Font
|
| 21 |
+
>>
|
| 22 |
+
endobj
|
| 23 |
+
5 0 obj
|
| 24 |
+
<<
|
| 25 |
+
/Contents 9 0 R /MediaBox [ 0 0 419.5276 595.2756 ] /Parent 8 0 R /Resources <<
|
| 26 |
+
/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
|
| 27 |
+
>> /Rotate 0 /Trans <<
|
| 28 |
+
|
| 29 |
+
>>
|
| 30 |
+
/Type /Page
|
| 31 |
+
>>
|
| 32 |
+
endobj
|
| 33 |
+
6 0 obj
|
| 34 |
+
<<
|
| 35 |
+
/PageMode /UseNone /Pages 8 0 R /Type /Catalog
|
| 36 |
+
>>
|
| 37 |
+
endobj
|
| 38 |
+
7 0 obj
|
| 39 |
+
<<
|
| 40 |
+
/Author (anonymous) /CreationDate (D:20260517182107+08'00') /Creator (anonymous) /Keywords () /ModDate (D:20260517182107+08'00') /Producer (ReportLab PDF Library - \(opensource\))
|
| 41 |
+
/Subject (unspecified) /Title (untitled) /Trapped /False
|
| 42 |
+
>>
|
| 43 |
+
endobj
|
| 44 |
+
8 0 obj
|
| 45 |
+
<<
|
| 46 |
+
/Count 1 /Kids [ 5 0 R ] /Type /Pages
|
| 47 |
+
>>
|
| 48 |
+
endobj
|
| 49 |
+
9 0 obj
|
| 50 |
+
<<
|
| 51 |
+
/Filter [ /ASCII85Decode /FlateDecode ] /Length 611
|
| 52 |
+
>>
|
| 53 |
+
stream
|
| 54 |
+
Gat=h9lJc/(kD)S(%3lJ'Zu3IVRJ*^GM,KOqQN=?Q;&!h(cl-(lb=O]DMO^)ROf\9?AjU%"nNABrZU6+2#n^+\@`tM-kol..8$</!hY>q`$l60iY'YREAA^DV2.[6"/gShQ@<QNMo(bApg@B3[b;YPW(Q<0p&^,D:jhI5Lr%FrT+f0%0enbf`/,0@35LD+6(n=FAI.<IMB1V-H.Kr#MnY?;Ma"1^JV9h^5ai!I.HWp=FG"KI>t'A6Y47["L(V`%Ce?4,/1IH*M)k,)CYo*Eq%:g@J@dF<2:F%LN(-Gq;htau)';WI::ZRk'\k`rd^=*Om:,.aXu3<Th/@.Ro*!/h)U?fTZhH$5I,Ai=4:D%b*3:7_05oKrZaco<N*iG4/7>5KarUEr_:k?A1>sFYIBVG-,af>pkBPXbg[_?6./9gr]rgI/3ruLdo@MOmD6U#igR7aEa#C$9\YYrIB;l0`<R[/WloZa,.)5brr*n/=9fZkc$\#"07.l0en!N:%qXG2Vl:9](80gY0?\X<tG-R*%&^1'@`(9#&Qjre;YE.UGBg<\<eN.Jf<?;WGYZ"$a)d.e4.LYgD"cdnAb-lB67t5[8W>\3^5k50;_b3;~>endstream
|
| 55 |
+
endobj
|
| 56 |
+
xref
|
| 57 |
+
0 10
|
| 58 |
+
0000000000 65535 f
|
| 59 |
+
0000000061 00000 n
|
| 60 |
+
0000000112 00000 n
|
| 61 |
+
0000000219 00000 n
|
| 62 |
+
0000000331 00000 n
|
| 63 |
+
0000000408 00000 n
|
| 64 |
+
0000000611 00000 n
|
| 65 |
+
0000000679 00000 n
|
| 66 |
+
0000000940 00000 n
|
| 67 |
+
0000000999 00000 n
|
| 68 |
+
trailer
|
| 69 |
+
<<
|
| 70 |
+
/ID
|
| 71 |
+
[<0863e61a1dac3fff929198004d0745a8><0863e61a1dac3fff929198004d0745a8>]
|
| 72 |
+
% ReportLab generated PDF document -- digest (opensource)
|
| 73 |
+
|
| 74 |
+
/Info 7 0 R
|
| 75 |
+
/Root 6 0 R
|
| 76 |
+
/Size 10
|
| 77 |
+
>>
|
| 78 |
+
startxref
|
| 79 |
+
1700
|
| 80 |
+
%%EOF
|
fin_expense_claim_002__long__cond/c97f91fe-8f04-5f0f-a397-971c012d254d_invoice_2.pdf
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%PDF-1.3
|
| 2 |
+
%���� ReportLab Generated PDF document (opensource)
|
| 3 |
+
1 0 obj
|
| 4 |
+
<<
|
| 5 |
+
/F1 2 0 R /F2 3 0 R /F3 4 0 R
|
| 6 |
+
>>
|
| 7 |
+
endobj
|
| 8 |
+
2 0 obj
|
| 9 |
+
<<
|
| 10 |
+
/BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font
|
| 11 |
+
>>
|
| 12 |
+
endobj
|
| 13 |
+
3 0 obj
|
| 14 |
+
<<
|
| 15 |
+
/BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding /Name /F2 /Subtype /Type1 /Type /Font
|
| 16 |
+
>>
|
| 17 |
+
endobj
|
| 18 |
+
4 0 obj
|
| 19 |
+
<<
|
| 20 |
+
/BaseFont /Symbol /Name /F3 /Subtype /Type1 /Type /Font
|
| 21 |
+
>>
|
| 22 |
+
endobj
|
| 23 |
+
5 0 obj
|
| 24 |
+
<<
|
| 25 |
+
/Contents 9 0 R /MediaBox [ 0 0 419.5276 595.2756 ] /Parent 8 0 R /Resources <<
|
| 26 |
+
/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
|
| 27 |
+
>> /Rotate 0 /Trans <<
|
| 28 |
+
|
| 29 |
+
>>
|
| 30 |
+
/Type /Page
|
| 31 |
+
>>
|
| 32 |
+
endobj
|
| 33 |
+
6 0 obj
|
| 34 |
+
<<
|
| 35 |
+
/PageMode /UseNone /Pages 8 0 R /Type /Catalog
|
| 36 |
+
>>
|
| 37 |
+
endobj
|
| 38 |
+
7 0 obj
|
| 39 |
+
<<
|
| 40 |
+
/Author (anonymous) /CreationDate (D:20260517182107+08'00') /Creator (anonymous) /Keywords () /ModDate (D:20260517182107+08'00') /Producer (ReportLab PDF Library - \(opensource\))
|
| 41 |
+
/Subject (unspecified) /Title (untitled) /Trapped /False
|
| 42 |
+
>>
|
| 43 |
+
endobj
|
| 44 |
+
8 0 obj
|
| 45 |
+
<<
|
| 46 |
+
/Count 1 /Kids [ 5 0 R ] /Type /Pages
|
| 47 |
+
>>
|
| 48 |
+
endobj
|
| 49 |
+
9 0 obj
|
| 50 |
+
<<
|
| 51 |
+
/Filter [ /ASCII85Decode /FlateDecode ] /Length 612
|
| 52 |
+
>>
|
| 53 |
+
stream
|
| 54 |
+
Gat=h:N)^V(l.R-MYEK4MX*LZ`k,gH\kCdX/Vb?m6/X#[K&&GK[blPRcjlLfRLg6#DresbC[dAb%MsurZ3L)m_q>1o66Y4d8Poij-%*n"=JnDPX=H^=f#`FbPTliH#+UEn=G<_3/95+M_h7PTd26NT<gVN&1nPoj"o7>AJ/Iq=p3VBN4=1hAME"I"!@J^]-7IBZUdQ'C;/Hhfabqd3>4dg@8bGN;$R?Ed"B$Z[V3jd'_%!OfqD&]]E/iJh,t;!KE_=N)/h*Z,M)f"3^?,<c?$Kg6Mn&AQd5.moPeh$)fK:<(&8/Y*ZZk+F9r[*k];)@4T4p5RSt!m<HIk=u]:C<?qPX=@\p!e=9fV:6r?8NRCM/^^`Xd>8I^Or%5J(;:ki/1S1&Nh5D?2s[Rr6\qpD@MGAi7\p5T.W@QJE8$F\mW>h<\B(YM0A&m<gmriG4'G=h<0Bml8%F%]>VEU5Yom6<A;"3jB'k1nqk`s7.,(mV0hSj<4pq#a%u50GYY7Cm#mD[8DB`SV0==E!S2J&&0.^W"cM<4%YCPJAA6Nk<!a80FA26YKOpICW^,$Itk)6]%b:5I%Mr<6jk!YeeV!GFf>:WNRnm`2$1lAMNgb.~>endstream
|
| 55 |
+
endobj
|
| 56 |
+
xref
|
| 57 |
+
0 10
|
| 58 |
+
0000000000 65535 f
|
| 59 |
+
0000000061 00000 n
|
| 60 |
+
0000000112 00000 n
|
| 61 |
+
0000000219 00000 n
|
| 62 |
+
0000000331 00000 n
|
| 63 |
+
0000000408 00000 n
|
| 64 |
+
0000000611 00000 n
|
| 65 |
+
0000000679 00000 n
|
| 66 |
+
0000000940 00000 n
|
| 67 |
+
0000000999 00000 n
|
| 68 |
+
trailer
|
| 69 |
+
<<
|
| 70 |
+
/ID
|
| 71 |
+
[<430513405f7b86d2996780ca2a987f36><430513405f7b86d2996780ca2a987f36>]
|
| 72 |
+
% ReportLab generated PDF document -- digest (opensource)
|
| 73 |
+
|
| 74 |
+
/Info 7 0 R
|
| 75 |
+
/Root 6 0 R
|
| 76 |
+
/Size 10
|
| 77 |
+
>>
|
| 78 |
+
startxref
|
| 79 |
+
1701
|
| 80 |
+
%%EOF
|
fin_expense_claim_002__long__cond/ce9481c5-7ab8-50e7-a97b-0f4f833ad690_justification.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Justification for high-value expense:
|
| 2 |
+
|
| 3 |
+
This transportation expense of ¥1,105 was incurred for client visits
|
| 4 |
+
to the Riverside Convention Center on May 12-13, 2026. The visits were
|
| 5 |
+
essential for the Q3 project delivery milestone meeting with our key
|
| 6 |
+
client, Greenland Holdings.
|
| 7 |
+
|
| 8 |
+
The higher-than-usual cost is due to the remote location of the
|
| 9 |
+
convention center (45 km from office) and the need for round-trip
|
| 10 |
+
transportation on both days during peak hours.
|
| 11 |
+
|
| 12 |
+
Approved by: Manager Chen Wei, 2026-05-10.
|
hr_onboarding_checklist_004/_cua_gym_vm_bridge.sh
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# CUA-Gym VM-side network fix (direct-IP mock access).
|
| 3 |
+
#
|
| 4 |
+
# Runs INSIDE the QEMU guest. The CUA-Gym mock services are now reached by
|
| 5 |
+
# their real IDC address (http://28.7.184.198:81xx) instead of the old
|
| 6 |
+
# localhost:9000-9097 socat bridge, so the VM only needs two fixes:
|
| 7 |
+
#
|
| 8 |
+
# 1. Working DNS — the qcow2-baked /etc/resolv.conf points at the Pod's
|
| 9 |
+
# cluster DNS, which is unreachable from QEMU SLIRP NAT
|
| 10 |
+
# ("Temporary failure in name resolution").
|
| 11 |
+
# 2. The mock host excluded from the woa http proxy — otherwise the VM's
|
| 12 |
+
# Chrome (gsettings proxy) and initial_setup.py's `requests` get a 403
|
| 13 |
+
# from the proxy when hitting 28.7.184.198:81xx. (The old socat path never
|
| 14 |
+
# hit this because localhost is bypassed by default.)
|
| 15 |
+
#
|
| 16 |
+
# Idempotent. Scoped to the CUA-Gym bridge step; does not touch the generic
|
| 17 |
+
# OSWorld setup pipeline.
|
| 18 |
+
#
|
| 19 |
+
# Argv:
|
| 20 |
+
# $1 optional sudo password (default "password"; SetupController
|
| 21 |
+
# substitutes {CLIENT_PASSWORD} when uploaded as a cache file).
|
| 22 |
+
# $2 unused (kept for backward compat — was socat first port 9000).
|
| 23 |
+
# $3 unused (kept for backward compat — was socat last port 9097).
|
| 24 |
+
# $4 optional mock host IP (default 28.7.184.198).
|
| 25 |
+
|
| 26 |
+
set +e
|
| 27 |
+
|
| 28 |
+
PASS="${1:-password}"
|
| 29 |
+
MOCK_HOST="${4:-28.7.184.198}"
|
| 30 |
+
# Derive the /16 IDC subnet so future port/host tweaks on the same segment
|
| 31 |
+
# stay bypassed too (28.7.184.198 -> 28.7.0.0/16).
|
| 32 |
+
MOCK_NET="$(echo "${MOCK_HOST}" | awk -F. 'NF==4{print $1"."$2".0.0/16"}')"
|
| 33 |
+
|
| 34 |
+
run_root() {
|
| 35 |
+
echo "$PASS" | sudo -S -p "" bash -c "$1"
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
# Detect SLIRP gateway from VM's routing table; fall back to 10.0.2.2.
|
| 39 |
+
GW="$(ip route 2>/dev/null | awk '/default/ {print $3; exit}')"
|
| 40 |
+
GW="${GW:-10.0.2.2}"
|
| 41 |
+
|
| 42 |
+
# ─── CUA-Gym network fix (Taiji-specific) ─────────────────────────────
|
| 43 |
+
fix_vm_network() {
|
| 44 |
+
# 0) Discover VM network state at runtime — gateway, own IP/CIDR, SLIRP
|
| 45 |
+
# DNS forwarder. Nothing hardcoded except the mock host above.
|
| 46 |
+
local GW_NET="${GW%.*}"
|
| 47 |
+
local SLIRP_DNS="${GW_NET}.3" # QEMU SLIRP DNS proxy is always .3
|
| 48 |
+
local OWN_CIDR
|
| 49 |
+
OWN_CIDR="$(ip -4 -o addr show scope global 2>/dev/null \
|
| 50 |
+
| awk '{print $4; exit}')"
|
| 51 |
+
local OWN_IP="${OWN_CIDR%/*}"
|
| 52 |
+
local OWN_NET=""
|
| 53 |
+
[ -n "${OWN_IP}" ] && OWN_NET="${OWN_IP%.*}.0/24"
|
| 54 |
+
|
| 55 |
+
# 1) DNS — point at SLIRP DNS proxy + public fallbacks. chattr +i keeps
|
| 56 |
+
# systemd-resolved/NetworkManager from clobbering it.
|
| 57 |
+
if run_root "printf 'nameserver ${SLIRP_DNS}\\nnameserver 114.114.114.114\\nnameserver 8.8.8.8\\n' > /etc/resolv.conf
|
| 58 |
+
chattr +i /etc/resolv.conf 2>/dev/null || true"; then
|
| 59 |
+
echo "[cua_gym_vm_bridge] DNS set: ${SLIRP_DNS}, 114.114.114.114, 8.8.8.8 (gw=${GW})"
|
| 60 |
+
else
|
| 61 |
+
echo "[cua_gym_vm_bridge] WARN: failed to write /etc/resolv.conf"
|
| 62 |
+
fi
|
| 63 |
+
|
| 64 |
+
# 2) Build the proxy bypass list from detected values + the direct-IP
|
| 65 |
+
# mock host (and its /16 subnet). THIS is what makes 28.7.184.198:81xx
|
| 66 |
+
# reachable from inside the VM — without it the woa proxy 403s it.
|
| 67 |
+
local ignore_list="['localhost', '127.0.0.0/8', '${GW}'"
|
| 68 |
+
[ -n "${OWN_IP}" ] && ignore_list="${ignore_list}, '${OWN_IP}'"
|
| 69 |
+
[ -n "${OWN_NET}" ] && ignore_list="${ignore_list}, '${OWN_NET}'"
|
| 70 |
+
[ -n "${GW_NET}" ] && ignore_list="${ignore_list}, '${GW_NET}.0/24'"
|
| 71 |
+
[ -n "${MOCK_HOST}" ] && ignore_list="${ignore_list}, '${MOCK_HOST}'"
|
| 72 |
+
[ -n "${MOCK_NET}" ] && ignore_list="${ignore_list}, '${MOCK_NET}'"
|
| 73 |
+
ignore_list="${ignore_list}]"
|
| 74 |
+
|
| 75 |
+
# 3) GNOME proxy ignore-hosts — Chrome bypasses the woa proxy for these.
|
| 76 |
+
if gsettings set org.gnome.system.proxy ignore-hosts "${ignore_list}" 2>/tmp/gsettings_err; then
|
| 77 |
+
echo "[cua_gym_vm_bridge] gsettings ignore-hosts = ${ignore_list}"
|
| 78 |
+
else
|
| 79 |
+
echo "[cua_gym_vm_bridge] WARN: gsettings ignore-hosts failed: $(cat /tmp/gsettings_err 2>/dev/null)"
|
| 80 |
+
fi
|
| 81 |
+
|
| 82 |
+
# 4) Shell env — comma-separated form for no_proxy/NO_PROXY (requests/curl).
|
| 83 |
+
local NP="localhost,127.0.0.1,${GW}"
|
| 84 |
+
[ -n "${OWN_IP}" ] && NP="${NP},${OWN_IP}"
|
| 85 |
+
[ -n "${OWN_NET}" ] && NP="${NP},${OWN_NET}"
|
| 86 |
+
[ -n "${GW_NET}" ] && NP="${NP},${GW_NET}.0/24"
|
| 87 |
+
[ -n "${MOCK_HOST}" ] && NP="${NP},${MOCK_HOST}"
|
| 88 |
+
[ -n "${MOCK_NET}" ] && NP="${NP},${MOCK_NET}"
|
| 89 |
+
|
| 90 |
+
for var in no_proxy NO_PROXY; do
|
| 91 |
+
if ! grep -q "export ${var}=${NP}" /home/user/.bashrc 2>/dev/null; then
|
| 92 |
+
echo "export ${var}=${NP}" >> /home/user/.bashrc
|
| 93 |
+
fi
|
| 94 |
+
done
|
| 95 |
+
run_root "grep -q '^no_proxy=' /etc/environment 2>/dev/null \
|
| 96 |
+
&& sed -i 's|^no_proxy=.*|no_proxy=\"${NP}\"|' /etc/environment \
|
| 97 |
+
|| echo 'no_proxy=\"${NP}\"' >> /etc/environment
|
| 98 |
+
grep -q '^NO_PROXY=' /etc/environment 2>/dev/null \
|
| 99 |
+
&& sed -i 's|^NO_PROXY=.*|NO_PROXY=\"${NP}\"|' /etc/environment \
|
| 100 |
+
|| echo 'NO_PROXY=\"${NP}\"' >> /etc/environment" >/dev/null 2>&1
|
| 101 |
+
echo "[cua_gym_vm_bridge] no_proxy=${NP}"
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
fix_vm_network
|
| 105 |
+
|
| 106 |
+
echo "[cua_gym_vm_bridge] direct-IP mode: ${MOCK_HOST} (+${MOCK_NET}) bypassed from woa proxy; no socat forwarding needed"
|
hr_onboarding_checklist_004/initial_setup.py
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Initial Setup: HR onboarding checklist (Workday) + Day-1 orientation event (Google Calendar)
|
| 3 |
+
Task ID: hr_onboarding_checklist_004
|
| 4 |
+
Domain: libreoffice_calc (actual task is a mock_websites task against Workday + Google Calendar)
|
| 5 |
+
Mocks:
|
| 6 |
+
- Workday: http://28.7.184.198:8192
|
| 7 |
+
- Calendar: http://28.7.184.198:8141
|
| 8 |
+
|
| 9 |
+
This script runs on the INITIAL VM only. It establishes the PRE-TASK state:
|
| 10 |
+
- Workday: full default org state + an EMPTY onboardingChecklists array (no Ava Thompson checklist)
|
| 11 |
+
- Calendar: a realistic baseline calendar with a few existing events, but NO
|
| 12 |
+
"Day-1 Orientation — Ava Thompson" event.
|
| 13 |
+
|
| 14 |
+
The sid is deterministic per-environment and written to /tmp/task_web_sid so the
|
| 15 |
+
reward-gen agent can locate this session's state on the (shared) mock server.
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
import json
|
| 19 |
+
import os
|
| 20 |
+
import shlex
|
| 21 |
+
import subprocess
|
| 22 |
+
import time
|
| 23 |
+
|
| 24 |
+
import requests
|
| 25 |
+
|
| 26 |
+
# ---------------------------------------------------------------------------
|
| 27 |
+
# Config
|
| 28 |
+
# ---------------------------------------------------------------------------
|
| 29 |
+
WORKDAY_URL = "http://28.7.184.198:8192"
|
| 30 |
+
CALENDAR_URL = "http://28.7.184.198:8141"
|
| 31 |
+
|
| 32 |
+
# Deterministic, per-environment sid. The initial VM uses the "_init" variant.
|
| 33 |
+
SID = "prof13_onboarding_checklist_001_init"
|
| 34 |
+
|
| 35 |
+
# Persist sid for reward-gen (it reads /tmp/task_web_sid on the VM it tests).
|
| 36 |
+
with open("/tmp/task_web_sid", "w") as f:
|
| 37 |
+
f.write(SID)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
# ---------------------------------------------------------------------------
|
| 41 |
+
# Baseline calendar state (the mock has no default state, so we build one).
|
| 42 |
+
# This is realistic content: a few existing events, no orientation event.
|
| 43 |
+
# ---------------------------------------------------------------------------
|
| 44 |
+
def build_baseline_calendar_state():
|
| 45 |
+
return {
|
| 46 |
+
"user": {
|
| 47 |
+
"id": "u1",
|
| 48 |
+
"username": "HR Generalist",
|
| 49 |
+
"email": "hr@northwindcloud.com",
|
| 50 |
+
"avatar": "https://ui-avatars.com/api/?name=HR+Generalist&background=0875E1&color=fff&size=128",
|
| 51 |
+
},
|
| 52 |
+
"calendars": [
|
| 53 |
+
{"id": "c1", "name": "Personal", "color": "#039BE5", "visible": True, "userId": "u1", "isDefault": True},
|
| 54 |
+
{"id": "c2", "name": "Work", "color": "#33B679", "visible": True, "userId": "u1", "isDefault": False},
|
| 55 |
+
{"id": "c3", "name": "Family", "color": "#8E24AA", "visible": True, "userId": "u1", "isDefault": False},
|
| 56 |
+
],
|
| 57 |
+
"events": [
|
| 58 |
+
{
|
| 59 |
+
"id": "evt_daily_standup",
|
| 60 |
+
"calendarId": "c2",
|
| 61 |
+
"title": "Daily Standup",
|
| 62 |
+
"start": "2026-07-02T09:00:00",
|
| 63 |
+
"end": "2026-07-02T09:15:00",
|
| 64 |
+
"allDay": False,
|
| 65 |
+
"location": "Zoom",
|
| 66 |
+
"description": "Team sync",
|
| 67 |
+
"guests": ["daniel.okafor@northwindcloud.com"],
|
| 68 |
+
"color": "#33B679",
|
| 69 |
+
"recurring": "daily",
|
| 70 |
+
"reminders": [{"type": "popup", "minutes": 5}],
|
| 71 |
+
"meetLink": "",
|
| 72 |
+
"status": "confirmed",
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"id": "evt_benefits_review",
|
| 76 |
+
"calendarId": "c2",
|
| 77 |
+
"title": "Benefits Enrollment Review",
|
| 78 |
+
"start": "2026-07-10T14:00:00",
|
| 79 |
+
"end": "2026-07-10T15:00:00",
|
| 80 |
+
"allDay": False,
|
| 81 |
+
"location": "Conference Room B",
|
| 82 |
+
"description": "Quarterly benefits review with HR.",
|
| 83 |
+
"guests": [],
|
| 84 |
+
"color": "#33B679",
|
| 85 |
+
"recurring": "none",
|
| 86 |
+
"reminders": [{"type": "popup", "minutes": 15}],
|
| 87 |
+
"meetLink": "",
|
| 88 |
+
"status": "confirmed",
|
| 89 |
+
},
|
| 90 |
+
],
|
| 91 |
+
"view": "week",
|
| 92 |
+
"currentDate": "2026-07-02T00:00:00",
|
| 93 |
+
"sidebarOpen": True,
|
| 94 |
+
"settings": {
|
| 95 |
+
"weekStart": 0,
|
| 96 |
+
"defaultDuration": 60,
|
| 97 |
+
"defaultView": "week",
|
| 98 |
+
"defaultReminder": {"type": "popup", "minutes": 10},
|
| 99 |
+
"timeFormat": "12h",
|
| 100 |
+
"showWeekNumbers": False,
|
| 101 |
+
"showDeclinedEvents": False,
|
| 102 |
+
},
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def inject_state(base_url, state, action="set"):
|
| 107 |
+
resp = requests.post(
|
| 108 |
+
f"{base_url}/post?sid={SID}",
|
| 109 |
+
json={"action": action, "state": state},
|
| 110 |
+
timeout=30,
|
| 111 |
+
)
|
| 112 |
+
resp.raise_for_status()
|
| 113 |
+
return resp.json()
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
def launch_gui(command, delay_sec=1.0):
|
| 117 |
+
env = os.environ.copy()
|
| 118 |
+
env["DISPLAY"] = ":0"
|
| 119 |
+
subprocess.Popen(
|
| 120 |
+
shlex.split(command),
|
| 121 |
+
stdout=subprocess.DEVNULL,
|
| 122 |
+
stderr=subprocess.DEVNULL,
|
| 123 |
+
env=env,
|
| 124 |
+
)
|
| 125 |
+
time.sleep(delay_sec)
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def wait_for_mocks_loaded(mocks, timeout=60.0, render_timeout=15.0):
|
| 129 |
+
"""Block until every mock serves the injected state AND the page renders."""
|
| 130 |
+
import time as _t
|
| 131 |
+
|
| 132 |
+
deadline = _t.time() + timeout
|
| 133 |
+
pending = dict(mocks)
|
| 134 |
+
while pending and _t.time() < deadline:
|
| 135 |
+
for name in list(pending):
|
| 136 |
+
try:
|
| 137 |
+
r = requests.get(f"{pending[name]}/go?sid={SID}", timeout=5)
|
| 138 |
+
if r.status_code == 200 and r.json().get("initial_state") is not None:
|
| 139 |
+
del pending[name]
|
| 140 |
+
except Exception:
|
| 141 |
+
pass
|
| 142 |
+
if pending:
|
| 143 |
+
_t.sleep(1.0)
|
| 144 |
+
if pending:
|
| 145 |
+
print(f"WARN: mocks not ready within {timeout}s: {list(pending)}")
|
| 146 |
+
return
|
| 147 |
+
|
| 148 |
+
# Browser-side render check (best effort).
|
| 149 |
+
try:
|
| 150 |
+
from playwright.sync_api import sync_playwright
|
| 151 |
+
except ImportError:
|
| 152 |
+
print("WARN: playwright not installed; skipping render check")
|
| 153 |
+
return
|
| 154 |
+
try:
|
| 155 |
+
with sync_playwright() as p:
|
| 156 |
+
browser = p.chromium.launch(
|
| 157 |
+
channel="chrome",
|
| 158 |
+
headless=True,
|
| 159 |
+
args=["--no-sandbox", "--disable-gpu", "--disable-dev-shm-usage"],
|
| 160 |
+
)
|
| 161 |
+
try:
|
| 162 |
+
for name, url in mocks.items():
|
| 163 |
+
page = browser.new_page()
|
| 164 |
+
try:
|
| 165 |
+
page.goto(f"{url}/?sid={SID}", wait_until="domcontentloaded",
|
| 166 |
+
timeout=int(render_timeout * 1000))
|
| 167 |
+
page.wait_for_function(
|
| 168 |
+
"document.body && document.body.innerText.length > 100",
|
| 169 |
+
timeout=int(render_timeout * 1000))
|
| 170 |
+
print(f"[{name}] rendered OK")
|
| 171 |
+
except Exception as e:
|
| 172 |
+
print(f"WARN: [{name}] render check failed: {e}")
|
| 173 |
+
finally:
|
| 174 |
+
page.close()
|
| 175 |
+
finally:
|
| 176 |
+
browser.close()
|
| 177 |
+
except Exception as e:
|
| 178 |
+
print(f"WARN: render check skipped: {e}")
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
def main():
|
| 182 |
+
# --- Workday: fetch the server's default state and inject it with an
|
| 183 |
+
# EMPTY onboardingChecklists array (pre-task state). ---
|
| 184 |
+
try:
|
| 185 |
+
default_wd = requests.get(f"{WORKDAY_URL}/go?sid=nonexistent", timeout=15).json()["initial_state"]
|
| 186 |
+
except Exception as e:
|
| 187 |
+
print(f"WARN: could not fetch Workday default state: {e}")
|
| 188 |
+
default_wd = {}
|
| 189 |
+
wd_state = dict(default_wd)
|
| 190 |
+
wd_state["onboardingChecklists"] = [] # no checklist yet (pre-task)
|
| 191 |
+
inject_state(WORKDAY_URL, wd_state, action="set")
|
| 192 |
+
print("Workday initial state injected (onboardingChecklists=[]).")
|
| 193 |
+
|
| 194 |
+
# --- Calendar: inject a realistic baseline calendar with NO orientation event. ---
|
| 195 |
+
cal_state = build_baseline_calendar_state()
|
| 196 |
+
inject_state(CALENDAR_URL, cal_state, action="set")
|
| 197 |
+
print("Calendar initial state injected (no orientation event).")
|
| 198 |
+
|
| 199 |
+
# --- Verify ---
|
| 200 |
+
go_wd = requests.get(f"{WORKDAY_URL}/go?sid={SID}", timeout=10).json()
|
| 201 |
+
go_cal = requests.get(f"{CALENDAR_URL}/go?sid={SID}", timeout=10).json()
|
| 202 |
+
assert go_wd["initial_state"] is not None, "Workday initial_state is None"
|
| 203 |
+
assert go_cal["initial_state"] is not None, "Calendar initial_state is None"
|
| 204 |
+
print("Verified: initial_state set for both mocks.")
|
| 205 |
+
|
| 206 |
+
# --- Launch Chrome for BOTH mocks (agent needs both open). ---
|
| 207 |
+
launch_gui(f'google-chrome "{WORKDAY_URL}/?sid={SID}"', delay_sec=1.0)
|
| 208 |
+
launch_gui(f'google-chrome "{CALENDAR_URL}/?sid={SID}"', delay_sec=1.0)
|
| 209 |
+
|
| 210 |
+
# --- Wait until both mocks serve state and render. ---
|
| 211 |
+
wait_for_mocks_loaded({
|
| 212 |
+
"workday": WORKDAY_URL,
|
| 213 |
+
"calendar": CALENDAR_URL,
|
| 214 |
+
})
|
| 215 |
+
|
| 216 |
+
print(f"GUI_READY: launched and verified Chrome for both mocks (sid={SID})")
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
if __name__ == "__main__":
|
| 220 |
+
main()
|
hr_onboarding_checklist_004/reward.py
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Reward Script: Create Workday onboarding checklist for Ava Thompson + Google Calendar Day-1 orientation event
|
| 3 |
+
Task ID: hr_onboarding_checklist_004
|
| 4 |
+
Domain: mock_websites (Workday @ http://28.7.184.198:8192, Google Calendar @ http://28.7.184.198:8141)
|
| 5 |
+
Scoring:
|
| 6 |
+
Component 1 (0.5): Workday onboardingChecklists has exactly one checklist for 'Ava Thompson'
|
| 7 |
+
with assignee 'Ava Thompson', dueDate '2026-07-13', and the 5 checkbox items
|
| 8 |
+
in the exact required order/labels.
|
| 9 |
+
Component 2 (0.5): Google Calendar has exactly one event titled 'Day-1 Orientation — Ava Thompson'
|
| 10 |
+
on 2026-07-13 09:30-11:00 with both required guests and the exact description.
|
| 11 |
+
Each component is verified against the LIVE mock state via /go?sid=<sid>, so it fails on the
|
| 12 |
+
initial VM (empty checklist list, no orientation event) and passes on the golden VM.
|
| 13 |
+
"""
|
| 14 |
+
import json
|
| 15 |
+
import sys
|
| 16 |
+
|
| 17 |
+
import requests
|
| 18 |
+
|
| 19 |
+
# --- Mock URLs (from task_config.json; state lives on the remote mock server) ---
|
| 20 |
+
WORKDAY_URL = 'http://28.7.184.198:8192'
|
| 21 |
+
CALENDAR_URL = 'http://28.7.184.198:8141'
|
| 22 |
+
|
| 23 |
+
# --- Ground-truth values from task_config.json context ---
|
| 24 |
+
EXPECTED_EMPLOYEE = 'Ava Thompson'
|
| 25 |
+
EXPECTED_ASSIGNEE = 'Ava Thompson'
|
| 26 |
+
EXPECTED_DUE_DATE = '2026-07-13'
|
| 27 |
+
EXPECTED_ITEMS = [
|
| 28 |
+
'Submit I-9 and W-4',
|
| 29 |
+
'Order laptop (MacBook Pro 14")',
|
| 30 |
+
'Assign Platform team Slack channel',
|
| 31 |
+
'Schedule Day-1 orientation',
|
| 32 |
+
'Grant GitHub access',
|
| 33 |
+
]
|
| 34 |
+
EXPECTED_EVENT_TITLE = 'Day-1 Orientation — Ava Thompson'
|
| 35 |
+
EXPECTED_EVENT_START = '2026-07-13T09:30:00'
|
| 36 |
+
EXPECTED_EVENT_END = '2026-07-13T11:00:00'
|
| 37 |
+
EXPECTED_GUESTS = ['ava.thompson@northwindcloud.com', 'daniel.okafor@northwindcloud.com']
|
| 38 |
+
EXPECTED_DESC = ('New-hire orientation for Ava Thompson (Backend Engineer, Platform team, '
|
| 39 |
+
'manager Daniel Okafor). Onboarding checklist owner: HR.')
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def _comp(idx, name, weight, passed, score, detail="", description=""):
|
| 43 |
+
"""Emit a structured COMPONENT line for per-module scoring visibility."""
|
| 44 |
+
print("COMPONENT: " + json.dumps({
|
| 45 |
+
"id": idx, "name": name, "weight": float(weight),
|
| 46 |
+
"passed": bool(passed), "score": float(score),
|
| 47 |
+
"detail": detail, "description": description,
|
| 48 |
+
}))
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def _run_component(idx, name, weight, fn, args):
|
| 52 |
+
"""Run one check fn, emit PASS/FAIL + COMPONENT line, return (passed, score, detail)."""
|
| 53 |
+
try:
|
| 54 |
+
passed, score, detail = fn(*args)
|
| 55 |
+
except Exception as e:
|
| 56 |
+
passed, score, detail = False, 0.0, f'error: {e}'
|
| 57 |
+
status = 'PASS' if passed else 'FAIL'
|
| 58 |
+
suffix = f' ({weight} pts)' if passed else f' — {detail}'
|
| 59 |
+
print(f'{status}: Component {idx} — {name}{suffix}')
|
| 60 |
+
_comp(idx, name, weight, passed, score, detail,
|
| 61 |
+
description=(fn.__doc__ or '').strip())
|
| 62 |
+
return passed, score, detail
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
# --- State fetch helper ---
|
| 66 |
+
def _fetch_current(base_url):
|
| 67 |
+
"""Read sid from /tmp/task_web_sid and fetch current_state from the mock server.
|
| 68 |
+
|
| 69 |
+
Returns the current_state dict, or {} on any failure (caller handles scoring).
|
| 70 |
+
"""
|
| 71 |
+
try:
|
| 72 |
+
with open('/tmp/task_web_sid') as f:
|
| 73 |
+
sid = f.read().strip()
|
| 74 |
+
if not sid:
|
| 75 |
+
return {}
|
| 76 |
+
except Exception:
|
| 77 |
+
return {}
|
| 78 |
+
try:
|
| 79 |
+
resp = requests.get(f'{base_url}/go?sid={sid}', timeout=15)
|
| 80 |
+
resp.raise_for_status()
|
| 81 |
+
data = resp.json()
|
| 82 |
+
return data.get('current_state') or {}
|
| 83 |
+
except Exception:
|
| 84 |
+
return {}
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
# --- Per-component checks (one function per sub-objective) ---
|
| 88 |
+
|
| 89 |
+
def check_component_1(workday_state):
|
| 90 |
+
"""Workday has exactly one onboarding checklist for 'Ava Thompson' with assignee
|
| 91 |
+
'Ava Thompson', dueDate '2026-07-13', and the 5 checkbox items in the exact required
|
| 92 |
+
order/labels. Pass condition: onboardingChecklists is a list of length 1, the single
|
| 93 |
+
entry's employeeName == 'Ava Thompson', assignee == 'Ava Thompson', dueDate ==
|
| 94 |
+
'2026-07-13', and items (label sequence) == the 5 expected labels.
|
| 95 |
+
"""
|
| 96 |
+
lists = workday_state.get('onboardingChecklists')
|
| 97 |
+
if not isinstance(lists, list):
|
| 98 |
+
return False, 0.0, 'onboardingChecklists missing or not a list'
|
| 99 |
+
if len(lists) != 1:
|
| 100 |
+
return False, 0.0, f'expected exactly 1 checklist, found {len(lists)}'
|
| 101 |
+
|
| 102 |
+
cl = lists[0]
|
| 103 |
+
if not isinstance(cl, dict):
|
| 104 |
+
return False, 0.0, 'checklist entry is not an object'
|
| 105 |
+
|
| 106 |
+
name = cl.get('employeeName')
|
| 107 |
+
if name != EXPECTED_EMPLOYEE:
|
| 108 |
+
return False, 0.0, f'employeeName={name!r}, expected {EXPECTED_EMPLOYEE!r}'
|
| 109 |
+
|
| 110 |
+
assignee = cl.get('assignee')
|
| 111 |
+
if assignee != EXPECTED_ASSIGNEE:
|
| 112 |
+
return False, 0.0, f'assignee={assignee!r}, expected {EXPECTED_ASSIGNEE!r}'
|
| 113 |
+
|
| 114 |
+
due = cl.get('dueDate')
|
| 115 |
+
if due != EXPECTED_DUE_DATE:
|
| 116 |
+
return False, 0.0, f'dueDate={due!r}, expected {EXPECTED_DUE_DATE!r}'
|
| 117 |
+
|
| 118 |
+
items = cl.get('items')
|
| 119 |
+
if not isinstance(items, list):
|
| 120 |
+
return False, 0.0, 'items missing or not a list'
|
| 121 |
+
labels = [it.get('label') for it in items if isinstance(it, dict)]
|
| 122 |
+
if labels != EXPECTED_ITEMS:
|
| 123 |
+
return False, 0.0, f'item labels={labels!r} != expected {EXPECTED_ITEMS!r}'
|
| 124 |
+
|
| 125 |
+
return True, 0.5, ('one Ava Thompson checklist, assignee=Ava Thompson, '
|
| 126 |
+
f'dueDate={EXPECTED_DUE_DATE}, 5 items in order')
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
def check_component_2(calendar_state):
|
| 130 |
+
"""Calendar has exactly one event titled 'Day-1 Orientation — Ava Thompson' on
|
| 131 |
+
2026-07-13 09:30-11:00 with both required guests and the exact description.
|
| 132 |
+
Pass condition: among current events there is exactly one event whose title matches
|
| 133 |
+
the expected title, start == '2026-07-13T09:30:00', end == '2026-07-13T11:00:00',
|
| 134 |
+
the guest set contains both required emails, and description matches exactly.
|
| 135 |
+
"""
|
| 136 |
+
events = calendar_state.get('events')
|
| 137 |
+
if not isinstance(events, list):
|
| 138 |
+
return False, 0.0, 'events missing or not a list'
|
| 139 |
+
|
| 140 |
+
matches = [e for e in events if isinstance(e, dict)
|
| 141 |
+
and e.get('title') == EXPECTED_EVENT_TITLE]
|
| 142 |
+
if len(matches) != 1:
|
| 143 |
+
return False, 0.0, (f'expected exactly 1 event titled {EXPECTED_EVENT_TITLE!r}, '
|
| 144 |
+
f'found {len(matches)}')
|
| 145 |
+
|
| 146 |
+
ev = matches[0]
|
| 147 |
+
start = ev.get('start')
|
| 148 |
+
if start != EXPECTED_EVENT_START:
|
| 149 |
+
return False, 0.0, f'start={start!r}, expected {EXPECTED_EVENT_START!r}'
|
| 150 |
+
|
| 151 |
+
end = ev.get('end')
|
| 152 |
+
if end != EXPECTED_EVENT_END:
|
| 153 |
+
return False, 0.0, f'end={end!r}, expected {EXPECTED_EVENT_END!r}'
|
| 154 |
+
|
| 155 |
+
guests = ev.get('guests') or []
|
| 156 |
+
if not isinstance(guests, list):
|
| 157 |
+
return False, 0.0, 'guests not a list'
|
| 158 |
+
guest_set = set(guests)
|
| 159 |
+
missing = [g for g in EXPECTED_GUESTS if g not in guest_set]
|
| 160 |
+
if missing:
|
| 161 |
+
return False, 0.0, f'missing guests: {missing} (have {guests!r})'
|
| 162 |
+
|
| 163 |
+
desc = ev.get('description')
|
| 164 |
+
if desc != EXPECTED_DESC:
|
| 165 |
+
return False, 0.0, f'description mismatch: got {desc!r}'
|
| 166 |
+
|
| 167 |
+
return True, 0.5, ('one orientation event 2026-07-13 09:30-11:00, both guests invited, '
|
| 168 |
+
'exact description')
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
def verify_task():
|
| 172 |
+
"""Verify task completion against live mock state. Returns float 0.0-1.0."""
|
| 173 |
+
workday_state = _fetch_current(WORKDAY_URL)
|
| 174 |
+
calendar_state = _fetch_current(CALENDAR_URL)
|
| 175 |
+
|
| 176 |
+
total_score = 0.0
|
| 177 |
+
for idx, name, weight, fn, args in [
|
| 178 |
+
(1, 'Workday Ava Thompson onboarding checklist', 0.5,
|
| 179 |
+
check_component_1, (workday_state,)),
|
| 180 |
+
(2, 'Calendar Day-1 Orientation event', 0.5,
|
| 181 |
+
check_component_2, (calendar_state,)),
|
| 182 |
+
]:
|
| 183 |
+
_, score, _ = _run_component(idx, name, weight, fn, args)
|
| 184 |
+
total_score += score
|
| 185 |
+
|
| 186 |
+
final_score = round(min(total_score, 1.0), 4)
|
| 187 |
+
print(f'\nScore: {total_score}/1.0')
|
| 188 |
+
print(f'REWARD: {final_score}')
|
| 189 |
+
return final_score
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
verify_task()
|
hr_onboarding_checklist_004/reward_label.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"reward_file": "/apdcephfs_sh2/share_300000800/user/jackwkwang/long-horizon-tasks/mini_osworld_xiangwu/cache/prof13_onboarding_checklist_001/reward.py",
|
| 3 |
+
"api_url": "http://28.7.184.184:8000/v1/chat/completions",
|
| 4 |
+
"model": "Kimi-K2.6",
|
| 5 |
+
"max_code_chars": 100000,
|
| 6 |
+
"created_at": "2026-07-14 10:28:34",
|
| 7 |
+
"label": {
|
| 8 |
+
"task_id": "hr_onboarding_checklist_004",
|
| 9 |
+
"domain": "mock_websites",
|
| 10 |
+
"summary": "验证在 Workday 中为 Ava Thompson 创建了包含5项检查内容的入职清单,并在 Google Calendar 中创建了指定时间、嘉宾和描述的 Day-1 Orientation 活动。",
|
| 11 |
+
"is_placeholder": false,
|
| 12 |
+
"data_sources": [
|
| 13 |
+
"/tmp/task_web_sid",
|
| 14 |
+
"http://28.7.186.212:8212",
|
| 15 |
+
"http://28.7.186.212:8161"
|
| 16 |
+
],
|
| 17 |
+
"scoring_components": [
|
| 18 |
+
{
|
| 19 |
+
"name": "Component 1",
|
| 20 |
+
"weight": 0.5,
|
| 21 |
+
"description": "Workday 中存在且仅存在一个针对 Ava Thompson 的入职清单,包含正确的负责人、截止日期和5个检查项。",
|
| 22 |
+
"check_logic": "从 Workday mock 状态获取 onboardingChecklists,验证其为长度为1的列表;检查唯一条目的 employeeName == 'Ava Thompson'、assignee == 'Ava Thompson'、dueDate == '2026-07-13';提取 items 中所有 label 并与 EXPECTED_ITEMS 列表进行精确顺序比较。",
|
| 23 |
+
"pass_condition": "onboardingChecklists 长度为1,且该清单的 employeeName、assignee、dueDate 均与预期值一致,items 的 label 序列与预期5项完全一致。"
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"name": "Component 2",
|
| 27 |
+
"weight": 0.5,
|
| 28 |
+
"description": "Google Calendar 中存在且仅存在一个标题为 'Day-1 Orientation — Ava Thompson' 的事件,时间、嘉宾和描述均正确。",
|
| 29 |
+
"check_logic": "从 Calendar mock 状态获取 events,筛选 title == 'Day-1 Orientation — Ava Thompson' 的事件,验证匹配数量为1;检查该事件的 start == '2026-07-13T09:30:00'、end == '2026-07-13T11:00:00';验证 guests 列表包含两个预期邮箱;验证 description 与预期字符串完全相等。",
|
| 30 |
+
"pass_condition": "events 中恰好有1个匹配标题的事件,start/end 时间正确,guests 包含两个指定邮箱,description 完全匹配。"
|
| 31 |
+
}
|
| 32 |
+
],
|
| 33 |
+
"total_max_score": 1.0,
|
| 34 |
+
"score_aggregation": "各组件分数相加,最终通过 round(min(total_score, 1.0), 4) 计算并钳制到上限 1.0。",
|
| 35 |
+
"failure_modes": [
|
| 36 |
+
"读取 /tmp/task_web_sid 失败或为空,导致获取 mock 状态失败",
|
| 37 |
+
"向 Workday 或 Calendar mock 服务器请求失败,返回空状态",
|
| 38 |
+
"Workday 的 onboardingChecklists 缺失、非列表或长度不为1",
|
| 39 |
+
"Workday 清单的 employeeName、assignee、dueDate 任一字段不匹配",
|
| 40 |
+
"Workday 清单的 items 缺失、非列表或 label 顺序/内容不匹配",
|
| 41 |
+
"Calendar 的 events 缺失或非列表",
|
| 42 |
+
"Calendar 中匹配标题的事件数量不为1",
|
| 43 |
+
"Calendar 事件的起止时间、嘉宾列表(缺少任一预期邮箱)或描述不匹配",
|
| 44 |
+
"组件检查函数抛出异常时该组件得 0.0 分"
|
| 45 |
+
],
|
| 46 |
+
"scoring_logic_explanation": "脚本首先通过 /tmp/task_web_sid 读取会话 ID,然后分别向 Workday (8212) 和 Calendar (8161) 的 mock 服务器请求当前状态。接着依次执行两个组件检查:Component 1 验证 Workday 中是否存在唯一且字段完全正确的 Ava Thompson 入职清单;Component 2 验证 Calendar 中是否存在唯一且字段完全正确的 Day-1 Orientation 事件。每个组件通过返回 (passed, score, detail) 元组,权重分别为 0.5。verify_task 将各组件 score 累加得到 total_score,最终返回 round(min(total_score, 1.0), 4)。任一组件失败仅扣除该组件权重分数,不会导致整体提前退出。",
|
| 47 |
+
"confidence": 1.0
|
| 48 |
+
},
|
| 49 |
+
"raw_response": "用户要求我分析一个 reward.py 评分脚本的评分逻辑,并以 JSON 格式输出分析结果。\n\n让我仔细阅读代码:\n\n1. **任务信息提取**:\n - Task ID: prof13_onboarding_checklist_001\n - Domain: mock_websites (Workday @ http://28.7.186.212:8212, Google Calendar @ http://28.7.186.212:8161)\n\n2. **数据源**:\n - 从 `/tmp/task_web_sid` 读取 sid\n - 通过 HTTP GET 请求获取 mock 服务器状态:\n - Workday: `http://28.7.186.212:8212/go?sid=<sid>`\n - Google Calendar: `http://28.7.186.212:8161/go?sid=<sid>`\n\n3. **评分组件**:\n - Component 1 (0.5): Workday onboarding checklist\n - 检查 onboardingChecklists 是否为长度为1的列表\n - 检查 employeeName == 'Ava Thompson'\n - 检查 assignee == 'Ava Thompson'\n - 检查 dueDate == '2026-07-13'\n - 检查 items 列表中的 label 顺序和内容完全匹配5个预期项目\n - Component 2 (0.5): Google Calendar event\n - 检查 events 列表中是否有且仅有1个标题为 'Day-1 Orientation — Ava Thompson' 的事件\n - 检查 start == '2026-07-13T09:30:00'\n - 检查 end == '2026-07-13T11:00:00'\n - 检查 guests 包含两个指定邮箱(ava.thompson@northwindcloud.com, daniel.okafor@northwindcloud.com)\n - 检查 description 完全匹配预期字符串\n\n4. **分数汇总**:\n - 两个组件分数相加,每个 0.5\n - 最终分数 = round(min(total_score, 1.0), 4)\n - 是相加逻辑\n\n5. **失败模式**:\n - 读取 /tmp/task_web_sid 失败或为空 → _fetch_current 返回 {},后续检查会失败\n - 请求 mock 服务器失败 → 返回 {},后续检查会失败\n - Workday: onboardingChecklists 缺失/非列表/长度不为1/字段不匹配/items不匹配\n - Calendar: events 缺失/非列表/无匹配事件/多个匹配事件/时间不匹配/客人缺失/描述不匹配\n - 任何异常会被捕获,返回 False, 0.0, error message\n\n6. **is_placeholder**:\n - 不是占位脚本,它真正检查 mock 状态。\n\n7. **confidence**:\n - 1.0,因为代码清晰完整。\n\n现在构建 JSON:\n\n```json\n{\n \"task_id\": \"prof13_onboarding_checklist_001\",\n \"domain\": \"mock_websites\",\n \"summary\": \"验证在 Workday 中为 Ava Thompson 创建了正确的入职清单,并在 Google Calendar 中创建了正确的 Day-1 定向活动。\",\n \"is_placeholder\": false,\n \"data_sources\": [\"/tmp/task_web_sid\", \"http://28.7.186.212:8212\", \"http://28.7.186.212:8161\"],\n \"scoring_components\": [\n {\n \"name\": \"Component 1\",\n \"weight\": 0.5,\n \"description\": \"Workday 中存在且仅存在一个针对 Ava Thompson 的入职清单,包含正确的负责人、截止日期和5个检查项。\",\n \"check_logic\": \"从 Workday mock 状态获取 onboardingChecklists,验证其为长度为1的列表;检查唯一条目的 employeeName == 'Ava Thompson'、assignee == 'Ava Thompson'、dueDate == '2026-07-13';提取 items 中所有 label 并与 EXPECTED_ITEMS 列表进行精确顺序比较。\",\n \"pass_condition\": \"onboardingChecklists 长度为1,且该清单的 employeeName、assignee、dueDate 均与预期值一致,items 的 label 序列与预期5项完全一致。\"\n },\n {\n \"name\": \"Component 2\",\n \"weight\": 0.5,\n \"description\": \"Google Calendar 中存在且仅存在一个标题为 'Day-1 Orientation — Ava Thompson' 的事件,时间、嘉宾和描述均正确。\",\n \"check_logic\": \"从 Calendar mock 状态获取 events,筛选 title == 'Day-1 Orientation — Ava Thompson' 的事件,验证匹配数量为1;检查该事件的 start == '2026-07-13T09:30:00'、end == '2026-07-13T11:00:00';验证 guests 列表包含两个预期邮箱;验证 description 与预期字符串完全相等。\",\n \"pass_condition\": \"events 中恰好有1个匹配标题的事件,start/end 时间正确,guests 包含两个指定邮箱,description 完全匹配。\"\n }\n ],\n \"total_max_score\": 1.0,\n \"score_aggregation\": \"各组件分数相加,最终通过 round(min(total_score, 1.0), 4) 计算并钳制到上限 1.0。\",\n \"failure_modes\": [\n \"读取 /tmp/task_web_sid 失败或为空,导致获取 mock 状态失败\",\n \"向 Workday 或 Calendar mock 服务器请求失败,返回空状态\",\n \"Workday 的 onboardingChecklists 缺失、非列表或长度不为1\",\n \"Workday 清单的 employeeName、assignee、dueDate 任一字段不匹配\",\n \"Workday 清单的 items 缺失、非列表或 label 顺序/内容不匹配\",\n \"Calendar 的 events 缺失或非列表\",\n \"Calendar 中匹配标题的事件数量不为1\",\n \"Calendar 事件的起止时间、嘉宾列表(缺少任一预期邮箱)或描述不匹配\",\n \"组件检查函数抛出异常时该组件得 0.0 分\"\n ],\n \"scoring_logic_explanation\": \"脚本首先通过 /tmp/task_web_sid 读取会话 ID,然后分别向 Workday (8212) 和 Calendar (8161) 的 mock 服务器请求当前状态。接着依次执行两个组件检查:Component 1 验证 Workday 中是否存在唯一且字段完全正确的 Ava Thompson 入职清单;Component 2 验证 Calendar 中是否存在唯一且字段完全正确的 Day-1 Orientation 事件。每个组件通过返回 (passed, score, detail) 元组,权重分别为 0.5。verify_task 将各组件 score 累加得到 total_score,最终返回 round(min(total_score, 1.0), 4)。任一组件失败仅扣除该组件权重分数,不会导致整体提前退出。\",\n \"confidence\": 1.0\n}\n```\n\n检查要求:\n- 只输出 JSON,不要 Markdown 代码块\n- 第一个字符是 {,最后一个字符是 }\n- 字符串 value 使用中文,task_id、domain、字段名、代码标识符保留原样\n- weight 显式给出:0.5\n- is_placeholder: false\n\n确认所有字段都已覆盖。 </think> {\n \"task_id\": \"prof13_onboarding_checklist_001\",\n \"domain\": \"mock_websites\",\n \"summary\": \"验证在 Workday 中为 Ava Thompson 创建了包含5项检查内容的入职清单,并在 Google Calendar 中创建了指定时间、嘉宾和描述的 Day-1 Orientation 活动。\",\n \"is_placeholder\": false,\n \"data_sources\": [\"/tmp/task_web_sid\", \"http://28.7.186.212:8212\", \"http://28.7.186.212:8161\"],\n \"scoring_components\": [\n {\n \"name\": \"Component 1\",\n \"weight\": 0.5,\n \"description\": \"Workday 中存在且仅存在一个针对 Ava Thompson 的入职清单,包含正确的负责人、截止日期和5个检查项。\",\n \"check_logic\": \"从 Workday mock 状态获取 onboardingChecklists,验证其为长度为1的列表;检查唯一条目的 employeeName == 'Ava Thompson'、assignee == 'Ava Thompson'、dueDate == '2026-07-13';提取 items 中所有 label 并与 EXPECTED_ITEMS 列表进行精确顺序比较。\",\n \"pass_condition\": \"onboardingChecklists 长度为1,且该清单的 employeeName、assignee、dueDate 均与预期值一致,items 的 label 序列与预期5项完全一致。\"\n },\n {\n \"name\": \"Component 2\",\n \"weight\": 0.5,\n \"description\": \"Google Calendar 中存在且仅存在一个标题为 'Day-1 Orientation — Ava Thompson' 的事件,时间、嘉宾和描述均正确。\",\n \"check_logic\": \"从 Calendar mock 状态获取 events,筛选 title == 'Day-1 Orientation — Ava Thompson' 的事件,验证匹配数量为1;检查该事件的 start == '2026-07-13T09:30:00'、end == '2026-07-13T11:00:00';验证 guests 列表包含两个预期邮箱;验证 description 与预期字符串完全相等。\",\n \"pass_condition\": \"events 中恰好有1个匹配标题的事件,start/end 时间正确,guests 包含两个指定邮箱,description 完全匹配。\"\n }\n ],\n \"total_max_score\": 1.0,\n \"score_aggregation\": \"各组件分数相加,最终通过 round(min(total_score, 1.0), 4) 计算并钳制到上限 1.0。\",\n \"failure_modes\": [\n \"读取 /tmp/task_web_sid 失败或为空,导致获取 mock 状态失败\",\n \"向 Workday 或 Calendar mock 服务器请求失败,返回空状态\",\n \"Workday 的 onboardingChecklists 缺失、非列表或长度不为1\",\n \"Workday 清单的 employeeName、assignee、dueDate 任一字段不匹配\",\n \"Workday 清单的 items 缺失、非列表或 label 顺序/内容不匹配\",\n \"Calendar 的 events 缺失或非列表\",\n \"Calendar 中匹配标题的事件数量不为1\",\n \"Calendar 事件的起止时间、嘉宾列表(缺少任一预期邮箱)或描述不匹配\",\n \"组件检查函数抛出异常时该组件得 0.0 分\"\n ],\n \"scoring_logic_explanation\": \"脚本首先通过 /tmp/task_web_sid 读取会话 ID,然后分别向 Workday (8212) 和 Calendar (8161) 的 mock 服务器请求当前状态。接着依次执行两个组件检查:Component 1 验证 Workday 中是否存在唯一且字段完全正确的 Ava Thompson 入职清单;Component 2 验证 Calendar 中是否存在唯一且字段完全正确的 Day-1 Orientation 事件。每个组件通过返回 (passed, score, detail) 元组,权重分别为 0.5。verify_task 将各组件 score 累加得到 total_score,最终返回 round(min(total_score, 1.0), 4)。任一组件失败仅扣除该组件权重分数,不会导致整体提前退出。\",\n \"confidence\": 1.0\n}"
|
| 50 |
+
}
|
img_contrast_002__long/.PLACEHOLDER
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
This directory is intentionally empty.
|
| 2 |
+
It exists only to satisfy start_our_benchmark_test.sh's uniform
|
| 3 |
+
'cache_dir/<tid>/ must exist' precheck. Non-mock tasks do not use
|
| 4 |
+
cua_gym cache; their evaluators read a vm_file tarball instead.
|
| 5 |
+
See docs/0716_迁移执行日志.md § S15 for details.
|
legacy/23a66d5f-baa6-5303-a1d6-6275229ebfa9/_cua_gym_vm_bridge.sh
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# CUA-Gym VM-side network fix (direct-IP mock access).
|
| 3 |
+
#
|
| 4 |
+
# Runs INSIDE the QEMU guest. The CUA-Gym mock services are now reached by
|
| 5 |
+
# their real IDC address (http://9.91.4.13:81xx) instead of the old
|
| 6 |
+
# localhost:9000-9097 socat bridge, so the VM only needs two fixes:
|
| 7 |
+
#
|
| 8 |
+
# 1. Working DNS — the qcow2-baked /etc/resolv.conf points at the Pod's
|
| 9 |
+
# cluster DNS, which is unreachable from QEMU SLIRP NAT
|
| 10 |
+
# ("Temporary failure in name resolution").
|
| 11 |
+
# 2. The mock host excluded from the woa http proxy — otherwise the VM's
|
| 12 |
+
# Chrome (gsettings proxy) and initial_setup.py's `requests` get a 403
|
| 13 |
+
# from the proxy when hitting 9.91.4.13:81xx. (The old socat path never
|
| 14 |
+
# hit this because localhost is bypassed by default.)
|
| 15 |
+
#
|
| 16 |
+
# Idempotent. Scoped to the CUA-Gym bridge step; does not touch the generic
|
| 17 |
+
# OSWorld setup pipeline.
|
| 18 |
+
#
|
| 19 |
+
# Argv:
|
| 20 |
+
# $1 optional sudo password (default "password"; SetupController
|
| 21 |
+
# substitutes {CLIENT_PASSWORD} when uploaded as a cache file).
|
| 22 |
+
# $2 unused (kept for backward compat — was socat first port 9000).
|
| 23 |
+
# $3 unused (kept for backward compat — was socat last port 9097).
|
| 24 |
+
# $4 optional mock host IP (default 9.91.4.13).
|
| 25 |
+
|
| 26 |
+
set +e
|
| 27 |
+
|
| 28 |
+
PASS="${1:-password}"
|
| 29 |
+
MOCK_HOST="${4:-28.7.186.212}"
|
| 30 |
+
# Derive the /16 IDC subnet so future port/host tweaks on the same segment
|
| 31 |
+
# stay bypassed too (9.91.4.13 -> 9.91.0.0/16).
|
| 32 |
+
MOCK_NET="$(echo "${MOCK_HOST}" | awk -F. 'NF==4{print $1"."$2".0.0/16"}')"
|
| 33 |
+
|
| 34 |
+
run_root() {
|
| 35 |
+
echo "$PASS" | sudo -S -p "" bash -c "$1"
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
# Detect SLIRP gateway from VM's routing table; fall back to 10.0.2.2.
|
| 39 |
+
GW="$(ip route 2>/dev/null | awk '/default/ {print $3; exit}')"
|
| 40 |
+
GW="${GW:-10.0.2.2}"
|
| 41 |
+
|
| 42 |
+
# ─── CUA-Gym network fix (Taiji-specific) ─────────────────────────────
|
| 43 |
+
fix_vm_network() {
|
| 44 |
+
# 0) Discover VM network state at runtime — gateway, own IP/CIDR, SLIRP
|
| 45 |
+
# DNS forwarder. Nothing hardcoded except the mock host above.
|
| 46 |
+
local GW_NET="${GW%.*}"
|
| 47 |
+
local SLIRP_DNS="${GW_NET}.3" # QEMU SLIRP DNS proxy is always .3
|
| 48 |
+
local OWN_CIDR
|
| 49 |
+
OWN_CIDR="$(ip -4 -o addr show scope global 2>/dev/null \
|
| 50 |
+
| awk '{print $4; exit}')"
|
| 51 |
+
local OWN_IP="${OWN_CIDR%/*}"
|
| 52 |
+
local OWN_NET=""
|
| 53 |
+
[ -n "${OWN_IP}" ] && OWN_NET="${OWN_IP%.*}.0/24"
|
| 54 |
+
|
| 55 |
+
# 1) DNS — point at SLIRP DNS proxy + public fallbacks. chattr +i keeps
|
| 56 |
+
# systemd-resolved/NetworkManager from clobbering it.
|
| 57 |
+
if run_root "printf 'nameserver ${SLIRP_DNS}\\nnameserver 114.114.114.114\\nnameserver 8.8.8.8\\n' > /etc/resolv.conf
|
| 58 |
+
chattr +i /etc/resolv.conf 2>/dev/null || true"; then
|
| 59 |
+
echo "[cua_gym_vm_bridge] DNS set: ${SLIRP_DNS}, 114.114.114.114, 8.8.8.8 (gw=${GW})"
|
| 60 |
+
else
|
| 61 |
+
echo "[cua_gym_vm_bridge] WARN: failed to write /etc/resolv.conf"
|
| 62 |
+
fi
|
| 63 |
+
|
| 64 |
+
# 2) Build the proxy bypass list from detected values + the direct-IP
|
| 65 |
+
# mock host (and its /16 subnet). THIS is what makes 9.91.4.13:81xx
|
| 66 |
+
# reachable from inside the VM — without it the woa proxy 403s it.
|
| 67 |
+
local ignore_list="['localhost', '127.0.0.0/8', '${GW}'"
|
| 68 |
+
[ -n "${OWN_IP}" ] && ignore_list="${ignore_list}, '${OWN_IP}'"
|
| 69 |
+
[ -n "${OWN_NET}" ] && ignore_list="${ignore_list}, '${OWN_NET}'"
|
| 70 |
+
[ -n "${GW_NET}" ] && ignore_list="${ignore_list}, '${GW_NET}.0/24'"
|
| 71 |
+
[ -n "${MOCK_HOST}" ] && ignore_list="${ignore_list}, '${MOCK_HOST}'"
|
| 72 |
+
[ -n "${MOCK_NET}" ] && ignore_list="${ignore_list}, '${MOCK_NET}'"
|
| 73 |
+
ignore_list="${ignore_list}]"
|
| 74 |
+
|
| 75 |
+
# 3) GNOME proxy ignore-hosts — Chrome bypasses the woa proxy for these.
|
| 76 |
+
if gsettings set org.gnome.system.proxy ignore-hosts "${ignore_list}" 2>/tmp/gsettings_err; then
|
| 77 |
+
echo "[cua_gym_vm_bridge] gsettings ignore-hosts = ${ignore_list}"
|
| 78 |
+
else
|
| 79 |
+
echo "[cua_gym_vm_bridge] WARN: gsettings ignore-hosts failed: $(cat /tmp/gsettings_err 2>/dev/null)"
|
| 80 |
+
fi
|
| 81 |
+
|
| 82 |
+
# 4) Shell env — comma-separated form for no_proxy/NO_PROXY (requests/curl).
|
| 83 |
+
local NP="localhost,127.0.0.1,${GW}"
|
| 84 |
+
[ -n "${OWN_IP}" ] && NP="${NP},${OWN_IP}"
|
| 85 |
+
[ -n "${OWN_NET}" ] && NP="${NP},${OWN_NET}"
|
| 86 |
+
[ -n "${GW_NET}" ] && NP="${NP},${GW_NET}.0/24"
|
| 87 |
+
[ -n "${MOCK_HOST}" ] && NP="${NP},${MOCK_HOST}"
|
| 88 |
+
[ -n "${MOCK_NET}" ] && NP="${NP},${MOCK_NET}"
|
| 89 |
+
|
| 90 |
+
for var in no_proxy NO_PROXY; do
|
| 91 |
+
if ! grep -q "export ${var}=${NP}" /home/user/.bashrc 2>/dev/null; then
|
| 92 |
+
echo "export ${var}=${NP}" >> /home/user/.bashrc
|
| 93 |
+
fi
|
| 94 |
+
done
|
| 95 |
+
run_root "grep -q '^no_proxy=' /etc/environment 2>/dev/null \
|
| 96 |
+
&& sed -i 's|^no_proxy=.*|no_proxy=\"${NP}\"|' /etc/environment \
|
| 97 |
+
|| echo 'no_proxy=\"${NP}\"' >> /etc/environment
|
| 98 |
+
grep -q '^NO_PROXY=' /etc/environment 2>/dev/null \
|
| 99 |
+
&& sed -i 's|^NO_PROXY=.*|NO_PROXY=\"${NP}\"|' /etc/environment \
|
| 100 |
+
|| echo 'NO_PROXY=\"${NP}\"' >> /etc/environment" >/dev/null 2>&1
|
| 101 |
+
echo "[cua_gym_vm_bridge] no_proxy=${NP}"
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
fix_vm_network
|
| 105 |
+
|
| 106 |
+
echo "[cua_gym_vm_bridge] direct-IP mode: ${MOCK_HOST} (+${MOCK_NET}) bypassed from woa proxy; no socat forwarding needed"
|
legacy/23a66d5f-baa6-5303-a1d6-6275229ebfa9/initial_setup.py
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Initial Setup: cm_publish_sync_b98
|
| 3 |
+
Task ID: 23a66d5f-baa6-5303-a1d6-6275229ebfa9
|
| 4 |
+
Domain: mock_websites
|
| 5 |
+
Mocks: airtable_mock, slack_mock, gmail_mock (single shared sid)
|
| 6 |
+
|
| 7 |
+
Persona: You are an office worker acting as an operations manager. Your tools for this task are: the Airtable base, team communications, the shared email inbox.
|
| 8 |
+
|
| 9 |
+
Environment / context (initial state + ground truth this setup establishes):
|
| 10 |
+
Initial environment (seeded via a single shared session id across all mocks): Airtable 'Project Tracker' base (Tasks + Team tables); Slack workspace with channels #general, #marketing, #random; Gmail inbox with 1 email(s): "Let me know when assets are live" from enablement@company.com. GROUND TRUTH — the agent earns partial credit for each checkpoint: Website Redesign Status = Done (+0.3); Approved checkbox ticked (+0.2); gmail_new_sent (+0.1); emailed enablement lead (+0.2); slack_new_msg (+0.1); heads-up in #marketing (+0.1). Scoring is absolute over each mock's current_state; new objects exclude the seeded IDs, so an untouched environment scores 0.0 and fully completing every checkpoint scores 1.0.
|
| 11 |
+
"""
|
| 12 |
+
import json
|
| 13 |
+
import os
|
| 14 |
+
import shlex
|
| 15 |
+
import subprocess
|
| 16 |
+
import time
|
| 17 |
+
import uuid
|
| 18 |
+
|
| 19 |
+
import requests
|
| 20 |
+
|
| 21 |
+
MOCK_URLS = {
|
| 22 |
+
"airtable_mock": "http://28.7.186.212:8129",
|
| 23 |
+
"slack_mock": "http://28.7.186.212:8198",
|
| 24 |
+
"gmail_mock": "http://28.7.186.212:8158"
|
| 25 |
+
}
|
| 26 |
+
PRIMARY_URL = 'http://28.7.186.212:8129'
|
| 27 |
+
|
| 28 |
+
sid = str(uuid.uuid4())
|
| 29 |
+
with open('/tmp/task_web_sid', 'w') as f:
|
| 30 |
+
f.write(sid)
|
| 31 |
+
print(f'Generated sid: {sid}')
|
| 32 |
+
|
| 33 |
+
# Full initial state for every mock involved (all required top-level keys present).
|
| 34 |
+
STATES = { 'airtable_mock': { 'bases': { 'base_cyqj85ts3': { 'id': 'base_cyqj85ts3',
|
| 35 |
+
'name': 'Project Tracker',
|
| 36 |
+
'color': 'bg-orange-500',
|
| 37 |
+
'tables': [ 'tbl_btxo7yi93',
|
| 38 |
+
'tbl_qcxlmfd9q']}},
|
| 39 |
+
'tables': { 'tbl_btxo7yi93': { 'id': 'tbl_btxo7yi93',
|
| 40 |
+
'name': 'Tasks',
|
| 41 |
+
'baseId': 'base_cyqj85ts3',
|
| 42 |
+
'fields': [ { 'id': 'fld_3z0pn979t',
|
| 43 |
+
'name': 'Name',
|
| 44 |
+
'type': 'text',
|
| 45 |
+
'primary': True},
|
| 46 |
+
{ 'id': 'fld_9bpvpiybo',
|
| 47 |
+
'name': 'Status',
|
| 48 |
+
'type': 'single_select',
|
| 49 |
+
'options': [ { 'id': 'opt1',
|
| 50 |
+
'name': 'Todo',
|
| 51 |
+
'color': 'bg-red-100 '
|
| 52 |
+
'text-red-800'},
|
| 53 |
+
{ 'id': 'opt2',
|
| 54 |
+
'name': 'In '
|
| 55 |
+
'Progress',
|
| 56 |
+
'color': 'bg-yellow-100 '
|
| 57 |
+
'text-yellow-800'},
|
| 58 |
+
{ 'id': 'opt3',
|
| 59 |
+
'name': 'Done',
|
| 60 |
+
'color': 'bg-green-100 '
|
| 61 |
+
'text-green-800'}]},
|
| 62 |
+
{ 'id': 'fld_6mdsjffxl',
|
| 63 |
+
'name': 'Priority',
|
| 64 |
+
'type': 'rating',
|
| 65 |
+
'max': 5},
|
| 66 |
+
{ 'id': 'fld_mpojl6vv7',
|
| 67 |
+
'name': 'Assignee',
|
| 68 |
+
'type': 'user'},
|
| 69 |
+
{ 'id': 'fld_1lzg9gbnm',
|
| 70 |
+
'name': 'Due Date',
|
| 71 |
+
'type': 'date'},
|
| 72 |
+
{ 'id': 'fld_gwn2mrky2',
|
| 73 |
+
'name': 'Budget',
|
| 74 |
+
'type': 'currency'},
|
| 75 |
+
{ 'id': 'fld_lzn5jy370',
|
| 76 |
+
'name': 'Attachments',
|
| 77 |
+
'type': 'attachment'},
|
| 78 |
+
{ 'id': 'fld_vd5052ol2',
|
| 79 |
+
'name': 'Tags',
|
| 80 |
+
'type': 'multiple_select',
|
| 81 |
+
'options': [ { 'id': 'tag1',
|
| 82 |
+
'name': 'Design',
|
| 83 |
+
'color': 'bg-purple-100 '
|
| 84 |
+
'text-purple-800'},
|
| 85 |
+
{ 'id': 'tag2',
|
| 86 |
+
'name': 'Dev',
|
| 87 |
+
'color': 'bg-blue-100 '
|
| 88 |
+
'text-blue-800'},
|
| 89 |
+
{ 'id': 'tag3',
|
| 90 |
+
'name': 'Marketing',
|
| 91 |
+
'color': 'bg-pink-100 '
|
| 92 |
+
'text-pink-800'}]},
|
| 93 |
+
{ 'id': 'fld_jli108tsf',
|
| 94 |
+
'name': 'Notes',
|
| 95 |
+
'type': 'long_text'},
|
| 96 |
+
{ 'id': 'fld_znxiw39md',
|
| 97 |
+
'name': 'Approved',
|
| 98 |
+
'type': 'checkbox'}],
|
| 99 |
+
'records': [ { 'id': 'rec_mbony82h2',
|
| 100 |
+
'createdTime': '2026-06-11T06:40:50.934Z',
|
| 101 |
+
'fields': { 'fld_3z0pn979t': 'Website '
|
| 102 |
+
'Redesign',
|
| 103 |
+
'fld_9bpvpiybo': 'In '
|
| 104 |
+
'Progress',
|
| 105 |
+
'fld_6mdsjffxl': 4,
|
| 106 |
+
'fld_mpojl6vv7': { 'name': 'Alice',
|
| 107 |
+
'avatar': 'https://picsum.photos/100/100?random=1'},
|
| 108 |
+
'fld_1lzg9gbnm': '2023-12-25',
|
| 109 |
+
'fld_gwn2mrky2': 5000,
|
| 110 |
+
'fld_lzn5jy370': [ { 'url': 'https://picsum.photos/300/200?random=10',
|
| 111 |
+
'name': 'mockup.png'}],
|
| 112 |
+
'fld_vd5052ol2': [ 'Design',
|
| 113 |
+
'Dev'],
|
| 114 |
+
'fld_jli108tsf': 'Needs '
|
| 115 |
+
'to '
|
| 116 |
+
'be '
|
| 117 |
+
'responsive.',
|
| 118 |
+
'fld_znxiw39md': False}},
|
| 119 |
+
{ 'id': 'rec_ggerrdipl',
|
| 120 |
+
'createdTime': '2026-06-11T06:40:50.934Z',
|
| 121 |
+
'fields': { 'fld_3z0pn979t': 'Q1 '
|
| 122 |
+
'Marketing '
|
| 123 |
+
'Campaign',
|
| 124 |
+
'fld_9bpvpiybo': 'Todo',
|
| 125 |
+
'fld_6mdsjffxl': 5,
|
| 126 |
+
'fld_mpojl6vv7': { 'name': 'Bob',
|
| 127 |
+
'avatar': 'https://picsum.photos/100/100?random=2'},
|
| 128 |
+
'fld_1lzg9gbnm': '2024-01-15',
|
| 129 |
+
'fld_gwn2mrky2': 12000,
|
| 130 |
+
'fld_lzn5jy370': [ ],
|
| 131 |
+
'fld_vd5052ol2': [ 'Marketing'],
|
| 132 |
+
'fld_jli108tsf': 'Focus '
|
| 133 |
+
'on '
|
| 134 |
+
'social '
|
| 135 |
+
'media.',
|
| 136 |
+
'fld_znxiw39md': False}},
|
| 137 |
+
{ 'id': 'rec_0651cwkw3',
|
| 138 |
+
'createdTime': '2026-06-11T06:40:50.934Z',
|
| 139 |
+
'fields': { 'fld_3z0pn979t': 'Database '
|
| 140 |
+
'Migration',
|
| 141 |
+
'fld_9bpvpiybo': 'Done',
|
| 142 |
+
'fld_6mdsjffxl': 3,
|
| 143 |
+
'fld_mpojl6vv7': { 'name': 'Charlie',
|
| 144 |
+
'avatar': 'https://picsum.photos/100/100?random=3'},
|
| 145 |
+
'fld_1lzg9gbnm': '2023-11-01',
|
| 146 |
+
'fld_gwn2mrky2': 2500,
|
| 147 |
+
'fld_lzn5jy370': [ { 'url': 'https://picsum.photos/300/200?random=11',
|
| 148 |
+
'name': 'schema.pdf'}],
|
| 149 |
+
'fld_vd5052ol2': [ 'Dev'],
|
| 150 |
+
'fld_jli108tsf': 'Completed '
|
| 151 |
+
'ahead '
|
| 152 |
+
'of '
|
| 153 |
+
'schedule.',
|
| 154 |
+
'fld_znxiw39md': True}}],
|
| 155 |
+
'views': [ { 'id': 'view_aa9x38mct',
|
| 156 |
+
'name': 'Grid View',
|
| 157 |
+
'type': 'grid'},
|
| 158 |
+
{ 'id': 'view_rykugfxaw',
|
| 159 |
+
'name': 'Kanban Board',
|
| 160 |
+
'type': 'kanban',
|
| 161 |
+
'groupFieldId': 'fld_9bpvpiybo'},
|
| 162 |
+
{ 'id': 'view_zzdarkhpg',
|
| 163 |
+
'name': 'Gallery',
|
| 164 |
+
'type': 'gallery'},
|
| 165 |
+
{ 'id': 'view_63y3ptw7g',
|
| 166 |
+
'name': 'Input Form',
|
| 167 |
+
'type': 'form'}],
|
| 168 |
+
'activeViewId': 'view_aa9x38mct'},
|
| 169 |
+
'tbl_qcxlmfd9q': { 'id': 'tbl_qcxlmfd9q',
|
| 170 |
+
'name': 'Team',
|
| 171 |
+
'baseId': 'base_cyqj85ts3',
|
| 172 |
+
'fields': [ { 'id': 'fld_i5gvgkxrc',
|
| 173 |
+
'name': 'Name',
|
| 174 |
+
'type': 'text',
|
| 175 |
+
'primary': True},
|
| 176 |
+
{ 'id': 'fld_yuilfoka7',
|
| 177 |
+
'name': 'Role',
|
| 178 |
+
'type': 'single_select',
|
| 179 |
+
'options': [ { 'id': 'r1',
|
| 180 |
+
'name': 'Manager'},
|
| 181 |
+
{ 'id': 'r2',
|
| 182 |
+
'name': 'IC'}]},
|
| 183 |
+
{ 'id': 'fld_0c3we1tep',
|
| 184 |
+
'name': 'Email',
|
| 185 |
+
'type': 'email'}],
|
| 186 |
+
'records': [ { 'id': 'rec_ohudorf8k',
|
| 187 |
+
'createdTime': '2026-06-11T06:40:50.934Z',
|
| 188 |
+
'fields': {}}],
|
| 189 |
+
'views': [ { 'id': 'view_bngoc8vlm',
|
| 190 |
+
'name': 'All Team',
|
| 191 |
+
'type': 'grid'}],
|
| 192 |
+
'activeViewId': None}},
|
| 193 |
+
'activeBaseId': 'base_cyqj85ts3',
|
| 194 |
+
'activeTableId': 'tbl_btxo7yi93',
|
| 195 |
+
'ui': {'searchQuery': ''},
|
| 196 |
+
'activityLog': []},
|
| 197 |
+
'slack_mock': { 'currentUser': { 'userId': 'user_1',
|
| 198 |
+
'fullName': 'John Smith',
|
| 199 |
+
'displayName': 'John',
|
| 200 |
+
'email': 'john.smith@company.com',
|
| 201 |
+
'avatar': 'https://picsum.photos/200/200?random=1',
|
| 202 |
+
'title': '',
|
| 203 |
+
'status': 'online',
|
| 204 |
+
'statusMessage': '',
|
| 205 |
+
'statusEmoji': '',
|
| 206 |
+
'timeZone': 'America/New_York'},
|
| 207 |
+
'workspace': { 'workspaceId': 'ws_1',
|
| 208 |
+
'workspaceName': 'Acme Corp',
|
| 209 |
+
'icon': ''},
|
| 210 |
+
'users': [ { 'userId': 'user_1',
|
| 211 |
+
'fullName': 'John Smith',
|
| 212 |
+
'displayName': 'John',
|
| 213 |
+
'email': 'john.smith@company.com',
|
| 214 |
+
'avatar': 'https://picsum.photos/200/200?random=1',
|
| 215 |
+
'title': '',
|
| 216 |
+
'status': 'online',
|
| 217 |
+
'statusMessage': '',
|
| 218 |
+
'statusEmoji': '',
|
| 219 |
+
'timeZone': 'America/New_York'},
|
| 220 |
+
{ 'userId': 'user_2',
|
| 221 |
+
'fullName': 'Sarah Johnson',
|
| 222 |
+
'displayName': 'Sarah',
|
| 223 |
+
'email': 'sarah.johnson@company.com',
|
| 224 |
+
'avatar': 'https://picsum.photos/200/200?random=2',
|
| 225 |
+
'title': '',
|
| 226 |
+
'status': 'online',
|
| 227 |
+
'statusMessage': '',
|
| 228 |
+
'statusEmoji': '',
|
| 229 |
+
'timeZone': 'America/New_York'},
|
| 230 |
+
{ 'userId': 'user_3',
|
| 231 |
+
'fullName': 'Mike Chen',
|
| 232 |
+
'displayName': 'Mike',
|
| 233 |
+
'email': 'mike.chen@company.com',
|
| 234 |
+
'avatar': 'https://picsum.photos/200/200?random=3',
|
| 235 |
+
'title': '',
|
| 236 |
+
'status': 'online',
|
| 237 |
+
'statusMessage': '',
|
| 238 |
+
'statusEmoji': '',
|
| 239 |
+
'timeZone': 'America/New_York'},
|
| 240 |
+
{ 'userId': 'user_4',
|
| 241 |
+
'fullName': 'Lisa Park',
|
| 242 |
+
'displayName': 'Lisa',
|
| 243 |
+
'email': 'lisa.park@company.com',
|
| 244 |
+
'avatar': 'https://picsum.photos/200/200?random=4',
|
| 245 |
+
'title': '',
|
| 246 |
+
'status': 'online',
|
| 247 |
+
'statusMessage': '',
|
| 248 |
+
'statusEmoji': '',
|
| 249 |
+
'timeZone': 'America/New_York'}],
|
| 250 |
+
'channels': [ { 'channelId': 'general',
|
| 251 |
+
'name': 'general',
|
| 252 |
+
'description': 'general channel',
|
| 253 |
+
'topic': '',
|
| 254 |
+
'isPrivate': False,
|
| 255 |
+
'isStarred': False,
|
| 256 |
+
'members': ['user_1', 'user_2', 'user_3', 'user_4'],
|
| 257 |
+
'createdBy': 'user_1',
|
| 258 |
+
'createdAt': '2026-01-01T10:00:00Z',
|
| 259 |
+
'pinnedMessages': [],
|
| 260 |
+
'unreadCount': 0},
|
| 261 |
+
{ 'channelId': 'marketing',
|
| 262 |
+
'name': 'marketing',
|
| 263 |
+
'description': 'marketing channel',
|
| 264 |
+
'topic': '',
|
| 265 |
+
'isPrivate': False,
|
| 266 |
+
'isStarred': False,
|
| 267 |
+
'members': ['user_1', 'user_2', 'user_3', 'user_4'],
|
| 268 |
+
'createdBy': 'user_1',
|
| 269 |
+
'createdAt': '2026-01-01T10:00:00Z',
|
| 270 |
+
'pinnedMessages': [],
|
| 271 |
+
'unreadCount': 0},
|
| 272 |
+
{ 'channelId': 'random',
|
| 273 |
+
'name': 'random',
|
| 274 |
+
'description': 'random channel',
|
| 275 |
+
'topic': '',
|
| 276 |
+
'isPrivate': False,
|
| 277 |
+
'isStarred': False,
|
| 278 |
+
'members': ['user_1', 'user_2', 'user_3', 'user_4'],
|
| 279 |
+
'createdBy': 'user_1',
|
| 280 |
+
'createdAt': '2026-01-01T10:00:00Z',
|
| 281 |
+
'pinnedMessages': [],
|
| 282 |
+
'unreadCount': 0}],
|
| 283 |
+
'messages': { 'general': [],
|
| 284 |
+
'marketing': [ { 'messageId': 'm1',
|
| 285 |
+
'senderId': 'user_3',
|
| 286 |
+
'content': 'did the website redesign '
|
| 287 |
+
'asset ship?',
|
| 288 |
+
'timestamp': '2026-06-08T08:00:00Z',
|
| 289 |
+
'threadId': None,
|
| 290 |
+
'reactions': [],
|
| 291 |
+
'attachments': [],
|
| 292 |
+
'isEdited': False}],
|
| 293 |
+
'random': []},
|
| 294 |
+
'threads': {},
|
| 295 |
+
'dms': [],
|
| 296 |
+
'bookmarkedMessages': [],
|
| 297 |
+
'callHistory': [],
|
| 298 |
+
'settings': { 'theme': 'light',
|
| 299 |
+
'notifications': 'all',
|
| 300 |
+
'displayDensity': 'comfortable',
|
| 301 |
+
'showAvatars': True,
|
| 302 |
+
'use24Hour': False},
|
| 303 |
+
'invitations': [],
|
| 304 |
+
'notifications': []},
|
| 305 |
+
'gmail_mock': { 'user': { 'userId': 'u1',
|
| 306 |
+
'username': 'John Smith',
|
| 307 |
+
'email': 'john.smith@company.com',
|
| 308 |
+
'avatar': ''},
|
| 309 |
+
'labels': [ {'id': 'l1', 'name': 'Work', 'color': '#ef4444'},
|
| 310 |
+
{'id': 'l2', 'name': 'Personal', 'color': '#3b82f6'},
|
| 311 |
+
{'id': 'l3', 'name': 'Travel', 'color': '#22c55e'},
|
| 312 |
+
{'id': 'l4', 'name': 'Finance', 'color': '#eab308'}],
|
| 313 |
+
'emails': [ { 'id': 'email_1',
|
| 314 |
+
'threadId': 'thread_email_1',
|
| 315 |
+
'from': { 'name': 'Enablement Lead',
|
| 316 |
+
'email': 'enablement@company.com',
|
| 317 |
+
'avatar': ''},
|
| 318 |
+
'to': [ { 'name': 'John Smith',
|
| 319 |
+
'email': 'john.smith@company.com'}],
|
| 320 |
+
'cc': [],
|
| 321 |
+
'bcc': [],
|
| 322 |
+
'subject': 'Let me know when assets are live',
|
| 323 |
+
'body': '<p>Ping me when the redesign content is published '
|
| 324 |
+
'so I can brief the sales team.</p>',
|
| 325 |
+
'snippet': 'Ping when live.',
|
| 326 |
+
'timestamp': '2026-06-08T08:15:00Z',
|
| 327 |
+
'read': False,
|
| 328 |
+
'starred': False,
|
| 329 |
+
'important': False,
|
| 330 |
+
'labels': [],
|
| 331 |
+
'category': 'primary',
|
| 332 |
+
'folder': 'inbox',
|
| 333 |
+
'attachments': []}],
|
| 334 |
+
'drafts': []}}
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
def launch_gui(command, delay_sec=1.0):
|
| 338 |
+
env = os.environ.copy()
|
| 339 |
+
env['DISPLAY'] = ':0'
|
| 340 |
+
subprocess.Popen(shlex.split(command), stdin=subprocess.DEVNULL,
|
| 341 |
+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
| 342 |
+
env=env, start_new_session=True)
|
| 343 |
+
time.sleep(delay_sec)
|
| 344 |
+
|
| 345 |
+
|
| 346 |
+
for name, url in MOCK_URLS.items():
|
| 347 |
+
resp = requests.post(f'{url}/post?sid={sid}',
|
| 348 |
+
json={'action': 'set', 'state': STATES[name]}, timeout=30)
|
| 349 |
+
assert resp.status_code == 200, f'{name} injection failed: {resp.text}'
|
| 350 |
+
go = requests.get(f'{url}/go?sid={sid}', timeout=10).json()
|
| 351 |
+
assert go.get('initial_state') is not None, f'{name} initial_state is None'
|
| 352 |
+
print(f'State injected: {name} sid={sid}')
|
| 353 |
+
|
| 354 |
+
# Open the PRIMARY app as the main window first, then open every other
|
| 355 |
+
# involved mock as an additional browser tab so the agent can see/reach all
|
| 356 |
+
# relevant apps (e.g. read the email in the Gmail tab AND post in Slack).
|
| 357 |
+
# Without this, secondary-app data is injected but has no on-screen entry
|
| 358 |
+
# point, and the agent wastes its budget hunting for a non-existent client.
|
| 359 |
+
launch_gui(f'google-chrome "{PRIMARY_URL}/?sid={sid}"', delay_sec=2.0)
|
| 360 |
+
print(f'GUI_READY: launched browser at {PRIMARY_URL}/?sid={sid}')
|
| 361 |
+
for _name, _url in MOCK_URLS.items():
|
| 362 |
+
if _url == PRIMARY_URL:
|
| 363 |
+
continue
|
| 364 |
+
launch_gui(f'google-chrome --new-tab "{_url}/?sid={sid}"', delay_sec=1.0)
|
| 365 |
+
print(f'Opened tab: {_name} at {_url}/?sid={sid}')
|
legacy/23a66d5f-baa6-5303-a1d6-6275229ebfa9/reward.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Reward Script: cm_publish_sync_b98
|
| 3 |
+
Task ID: 23a66d5f-baa6-5303-a1d6-6275229ebfa9
|
| 4 |
+
Domain: mock_websites
|
| 5 |
+
Mocks: airtable_mock, slack_mock, gmail_mock
|
| 6 |
+
Scoring (all programmatic; evaluated against each mock's current_state; total = 1.0):
|
| 7 |
+
- [0.3] Website Redesign Status = Done
|
| 8 |
+
- [0.2] Approved checkbox ticked
|
| 9 |
+
- [0.1] gmail_new_sent
|
| 10 |
+
- [0.2] emailed enablement lead
|
| 11 |
+
- [0.1] slack_new_msg
|
| 12 |
+
- [0.1] heads-up in #marketing
|
| 13 |
+
"""
|
| 14 |
+
import re
|
| 15 |
+
import sys
|
| 16 |
+
|
| 17 |
+
import requests
|
| 18 |
+
|
| 19 |
+
MOCK_URLS = {
|
| 20 |
+
"airtable_mock": "http://28.7.186.212:8129",
|
| 21 |
+
"slack_mock": "http://28.7.186.212:8198",
|
| 22 |
+
"gmail_mock": "http://28.7.186.212:8158"
|
| 23 |
+
}
|
| 24 |
+
SEED = {
|
| 25 |
+
"slack_mock:general": [],
|
| 26 |
+
"slack_mock:marketing": [
|
| 27 |
+
"m1"
|
| 28 |
+
],
|
| 29 |
+
"slack_mock:random": []
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
try:
|
| 33 |
+
with open('/tmp/task_web_sid') as f:
|
| 34 |
+
sid = f.read().strip()
|
| 35 |
+
if not sid:
|
| 36 |
+
raise ValueError('sid is empty')
|
| 37 |
+
except Exception as e:
|
| 38 |
+
print(f'CRITICAL: cannot read sid: {e}')
|
| 39 |
+
print('REWARD: 0.0')
|
| 40 |
+
sys.exit(0)
|
| 41 |
+
|
| 42 |
+
STATES = {}
|
| 43 |
+
for _name, _url in MOCK_URLS.items():
|
| 44 |
+
try:
|
| 45 |
+
_r = requests.get(f'{_url}/go?sid={sid}', timeout=15)
|
| 46 |
+
_r.raise_for_status()
|
| 47 |
+
STATES[_name] = _r.json()
|
| 48 |
+
except Exception as e:
|
| 49 |
+
print(f'CRITICAL: cannot fetch {_name}: {e}')
|
| 50 |
+
print('REWARD: 0.0')
|
| 51 |
+
sys.exit(0)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def cur(mock):
|
| 55 |
+
return (STATES.get(mock) or {}).get('current_state') or {}
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def _lc(s):
|
| 59 |
+
return (s or '').lower()
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
total = 0.0
|
| 63 |
+
|
| 64 |
+
# c0: airtable record rec_mbony82h2 field fld_9bpvpiybo == 'Done'
|
| 65 |
+
c0_tbl = (cur('airtable_mock').get('tables') or {}).get('tbl_btxo7yi93') or {}
|
| 66 |
+
c0_rec = next((r for r in (c0_tbl.get('records') or []) if r.get('id') == 'rec_mbony82h2'), None)
|
| 67 |
+
if c0_rec and (c0_rec.get('fields') or {}).get('fld_9bpvpiybo') == 'Done':
|
| 68 |
+
print('PASS: Website Redesign Status = Done (0.3)')
|
| 69 |
+
total += 0.3
|
| 70 |
+
else:
|
| 71 |
+
print('FAIL: Website Redesign Status = Done')
|
| 72 |
+
|
| 73 |
+
# c1: airtable record rec_mbony82h2 field fld_znxiw39md == True
|
| 74 |
+
c1_tbl = (cur('airtable_mock').get('tables') or {}).get('tbl_btxo7yi93') or {}
|
| 75 |
+
c1_rec = next((r for r in (c1_tbl.get('records') or []) if r.get('id') == 'rec_mbony82h2'), None)
|
| 76 |
+
if c1_rec and (c1_rec.get('fields') or {}).get('fld_znxiw39md') == True:
|
| 77 |
+
print('PASS: Approved checkbox ticked (0.2)')
|
| 78 |
+
total += 0.2
|
| 79 |
+
else:
|
| 80 |
+
print('FAIL: Approved checkbox ticked')
|
| 81 |
+
|
| 82 |
+
# c2: a new email was sent (folder sent) or saved as draft
|
| 83 |
+
c2_init = (STATES['gmail_mock'].get('initial_state') or {})
|
| 84 |
+
c2_cur = cur('gmail_mock')
|
| 85 |
+
c2_init_ids = {e.get('id') for e in (c2_init.get('emails') or [])}
|
| 86 |
+
c2_sent = [e for e in (c2_cur.get('emails') or []) if e.get('id') not in c2_init_ids and e.get('folder') in ('sent', 'drafts')]
|
| 87 |
+
c2_sent += [d for d in (c2_cur.get('drafts') or []) if d.get('id') not in {x.get('id') for x in (c2_init.get('drafts') or [])}]
|
| 88 |
+
if c2_sent:
|
| 89 |
+
print('PASS: new email sent/drafted (0.1)')
|
| 90 |
+
total += 0.1
|
| 91 |
+
else:
|
| 92 |
+
print('FAIL: no new sent/draft email')
|
| 93 |
+
|
| 94 |
+
# c3: sent/draft email addressed to (emailed enablement lead)
|
| 95 |
+
c3_init = (STATES['gmail_mock'].get('initial_state') or {})
|
| 96 |
+
c3_cur = cur('gmail_mock')
|
| 97 |
+
c3_init_ids = {e.get('id') for e in (c3_init.get('emails') or [])}
|
| 98 |
+
c3_pool = [e for e in (c3_cur.get('emails') or []) if e.get('id') not in c3_init_ids and e.get('folder') in ('sent','drafts')] + (c3_cur.get('drafts') or [])
|
| 99 |
+
c3_tos = _lc(' '.join(t.get('email','') for e in c3_pool for t in (e.get('to') or [])))
|
| 100 |
+
if any(t in c3_tos for t in ['enablement@company.com']):
|
| 101 |
+
print('PASS: emailed enablement lead (0.2)')
|
| 102 |
+
total += 0.2
|
| 103 |
+
else:
|
| 104 |
+
print('FAIL: emailed enablement lead')
|
| 105 |
+
|
| 106 |
+
# c4: new message by user_1 in #marketing
|
| 107 |
+
c4_msgs = (cur('slack_mock').get('messages') or {}).get('marketing', []) or []
|
| 108 |
+
c4_seed = set(SEED.get('slack_mock:marketing', []))
|
| 109 |
+
c4_new = [m for m in c4_msgs if m.get('messageId') not in c4_seed and m.get('senderId') == 'user_1']
|
| 110 |
+
c4_blob = _lc(' '.join((m.get('content') or '') for m in c4_new))
|
| 111 |
+
if c4_new:
|
| 112 |
+
print('PASS: new message by user_1 in #marketing (0.1)')
|
| 113 |
+
total += 0.1
|
| 114 |
+
else:
|
| 115 |
+
print('FAIL: no new user_1 message in #marketing')
|
| 116 |
+
|
| 117 |
+
# c5: slack #marketing contains (heads-up in #marketing)
|
| 118 |
+
c5_msgs = (cur('slack_mock').get('messages') or {}).get('marketing', []) or []
|
| 119 |
+
c5_seed = set(SEED.get('slack_mock:marketing', []))
|
| 120 |
+
c5_blob = _lc(' '.join((m.get('content') or '') for m in c5_msgs if m.get('messageId') not in c5_seed and m.get('senderId') == 'user_1'))
|
| 121 |
+
if any(t in c5_blob for t in ['publish', 'live', 'redesign', 'approved']):
|
| 122 |
+
print('PASS: heads-up in #marketing (0.1)')
|
| 123 |
+
total += 0.1
|
| 124 |
+
else:
|
| 125 |
+
print('FAIL: heads-up in #marketing')
|
| 126 |
+
|
| 127 |
+
final = round(min(total, 1.0), 4)
|
| 128 |
+
print(f'\nScore: {total}/1.0')
|
| 129 |
+
print(f'REWARD: {final}')
|
legacy/23a66d5f-baa6-5303-a1d6-6275229ebfa9/reward_label.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"reward_file": "/apdcephfs_sh2/share_300000800/user/jackwkwang/long-horizon-tasks/mini_osworld_xiangwu/cache/23a66d5f-baa6-5303-a1d6-6275229ebfa9/reward.py",
|
| 3 |
+
"api_url": "http://28.7.184.184:8000/v1/chat/completions",
|
| 4 |
+
"model": "Kimi-K2.6",
|
| 5 |
+
"max_code_chars": 100000,
|
| 6 |
+
"created_at": "2026-07-14 10:18:50",
|
| 7 |
+
"label": {
|
| 8 |
+
"task_id": "23a66d5f-baa6-5303-a1d6-6275229ebfa9",
|
| 9 |
+
"domain": "mock_websites",
|
| 10 |
+
"summary": "验证用户在 Airtable 中将网站重设计状态更新为 Done 并勾选 Approved,通过 Gmail 向 enablement lead 发送邮件,并在 Slack #marketing 频道发送包含指定关键词的提醒消息",
|
| 11 |
+
"is_placeholder": false,
|
| 12 |
+
"data_sources": [
|
| 13 |
+
"/tmp/task_web_sid",
|
| 14 |
+
"airtable_mock",
|
| 15 |
+
"slack_mock",
|
| 16 |
+
"gmail_mock"
|
| 17 |
+
],
|
| 18 |
+
"scoring_components": [
|
| 19 |
+
{
|
| 20 |
+
"name": "Component 0: Website Redesign Status = Done",
|
| 21 |
+
"weight": 0.3,
|
| 22 |
+
"description": "检查 Airtable 中指定记录的网站重设计状态是否标记为 Done",
|
| 23 |
+
"check_logic": "从 airtable_mock 的 current_state 中获取 tables.tbl_btxo7yi93.records,查找 id 为 rec_mbony82h2 的记录,检查其 fields.fld_9bpvpiybo 是否等于 'Done'",
|
| 24 |
+
"pass_condition": "rec_mbony82h2 的 fld_9bpvpiybo 字段值为 'Done'"
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"name": "Component 1: Approved checkbox ticked",
|
| 28 |
+
"weight": 0.2,
|
| 29 |
+
"description": "检查 Airtable 中指定记录的 Approved 复选框是否被勾选",
|
| 30 |
+
"check_logic": "从 airtable_mock 的 current_state 中获取 tables.tbl_btxo7yi93.records,查找 id 为 rec_mbony82h2 的记录,检查其 fields.fld_znxiw39md 是否等于 True",
|
| 31 |
+
"pass_condition": "rec_mbony82h2 的 fld_znxiw39md 字段值为 True"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"name": "Component 2: gmail_new_sent",
|
| 35 |
+
"weight": 0.1,
|
| 36 |
+
"description": "检查是否通过 Gmail 发送了新邮件或保存了新草稿",
|
| 37 |
+
"check_logic": "对比 gmail_mock 的 initial_state 与 current_state,找出 emails 中 id 不在初始集合且 folder 为 sent 或 drafts 的新邮件,以及 drafts 中新增的草稿;若列表非空则通过",
|
| 38 |
+
"pass_condition": "存在至少一封新的 sent 或 draft 邮件"
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"name": "Component 3: emailed enablement lead",
|
| 42 |
+
"weight": 0.2,
|
| 43 |
+
"description": "检查新邮件是否发送给了 enablement lead",
|
| 44 |
+
"check_logic": "在新邮件/草稿池中,提取所有 to 字段中的 email 地址并转为小写拼接,检查是否包含 'enablement@company.com'",
|
| 45 |
+
"pass_condition": "新邮件的收件人包含 enablement@company.com"
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"name": "Component 4: slack_new_msg",
|
| 49 |
+
"weight": 0.1,
|
| 50 |
+
"description": "检查 user_1 是否在 Slack #marketing 频道发送了新消息",
|
| 51 |
+
"check_logic": "从 slack_mock 的 current_state.messages.marketing 中,排除 SEED 中预置的消息(messageId 不在 seed 中),筛选 senderId 为 'user_1' 的消息;若存在则通过",
|
| 52 |
+
"pass_condition": "#marketing 频道存在至少一条 user_1 发送的新消息"
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"name": "Component 5: heads-up in #marketing",
|
| 56 |
+
"weight": 0.1,
|
| 57 |
+
"description": "检查 Slack #marketing 频道的新消息内容是否包含相关提醒关键词",
|
| 58 |
+
"check_logic": "提取 #marketing 频道中 user_1 发送的新消息内容并转为小写,检查是否包含 'publish'、'live'、'redesign'、'approved' 中的任一关键词",
|
| 59 |
+
"pass_condition": "消息内容包含 'publish'、'live'、'redesign' 或 'approved' 至少一个关键词"
|
| 60 |
+
}
|
| 61 |
+
],
|
| 62 |
+
"total_max_score": 1.0,
|
| 63 |
+
"score_aggregation": "各组件分数相加,最后通过 min(total, 1.0) 钳制到上限 1.0,并四舍五入到 4 位小数",
|
| 64 |
+
"failure_modes": [
|
| 65 |
+
"读取 /tmp/task_web_sid 失败或内容为空:打印 CRITICAL 并返回 0.0 退出",
|
| 66 |
+
"请求任何 mock 服务(airtable_mock、slack_mock、gmail_mock)失败:打印 CRITICAL 并返回 0.0 退出",
|
| 67 |
+
"Airtable 记录不存在或字段值不符合预期:对应组件不得分",
|
| 68 |
+
"Gmail 无新邮件/草稿:对应组件不得分",
|
| 69 |
+
"新邮件未发送给 enablement@company.com:对应组件不得分",
|
| 70 |
+
"Slack #marketing 无 user_1 新消息:对应组件不得分",
|
| 71 |
+
"Slack 消息内容不包含所需关键词:对应组件不得分"
|
| 72 |
+
],
|
| 73 |
+
"scoring_logic_explanation": "脚本首先读取 /tmp/task_web_sid 获取会话 ID,然后依次向 airtable_mock、slack_mock、gmail_mock 发送 HTTP GET 请求获取 current_state。若任何步骤失败则直接返回 0.0。随后按顺序执行 6 项检查:1)Airtable 记录 rec_mbony82h2 的 Website Redesign Status 字段是否为 Done(0.3 分);2)同一记录的 Approved 复选框是否为 True(0.2 分);3)Gmail 是否存在新的 sent/drafts 邮件(0.1 分);4)新邮件是否发送给 enablement@company.com(0.2 分);5)Slack #marketing 是否有 user_1 的新��息(0.1 分);6)该消息内容是否包含 publish/live/redesign/approved 任一关键词(0.1 分)。每项通过则累加对应分数,最终总分经 min(total, 1.0) 限制后四舍五入输出。",
|
| 74 |
+
"confidence": 1.0
|
| 75 |
+
},
|
| 76 |
+
"raw_response": "用户要求我分析一个 reward.py 评分脚本,并输出一个严格的 JSON 对象,不要有任何额外文字。\n\n让我仔细阅读代码:\n\n1. 文件路径和 docstring:\n - Task ID: 23a66d5f-baa6-5303-a1d6-6275229ebfa9(从 docstring 中提取)\n - Domain: mock_websites(从 docstring 中提取)\n - Mocks: airtable_mock, slack_mock, gmail_mock\n\n2. 评分组件:\n - c0: [0.3] Website Redesign Status = Done - 检查 airtable_mock 中 tbl_btxo7yi93 表的 rec_mbony82h2 记录的 fld_9bpvpiybo 字段是否等于 'Done'\n - c1: [0.2] Approved checkbox ticked - 检查 airtable_mock 中 tbl_btxo7yi93 表的 rec_mbony82h2 记录的 fld_znxiw39md 字段是否等于 True\n - c2: [0.1] gmail_new_sent - 检查是否有新发送或保存为草稿的邮件(通过比较 initial_state 和 current_state 的 emails/drafts)\n - c3: [0.2] emailed enablement lead - 检查新发送/草稿邮件是否发送给 enablement@company.com\n - c4: [0.1] slack_new_msg - 检查 user_1 是否在 #marketing 频道发送了新消息(排除 seed 中的消息)\n - c5: [0.1] heads-up in #marketing - 检查 #marketing 频道中 user_1 的新消息内容是否包含 'publish', 'live', 'redesign', 'approved' 任一关键词\n\n3. 数据源:\n - /tmp/task_web_sid(读取 session id)\n - airtable_mock (http://28.7.186.212:8129)\n - slack_mock (http://28.7.186.212:8198)\n - gmail_mock (http://28.7.186.212:8158)\n\n4. 失败模式:\n - 读取 sid 失败或为空:打印 CRITICAL,REWARD: 0.0,sys.exit(0)\n - 获取任何 mock 状态失败:打印 CRITICAL,REWARD: 0.0,sys.exit(0)\n - 各组件检查失败只是不加分,不会提前退出\n\n5. 分数汇总:\n - 各组件分数相加(0.3 + 0.2 + 0.1 + 0.2 + 0.1 + 0.1 = 1.0)\n - 最后 round(min(total, 1.0), 4)\n\n6. is_placeholder: false,因为这是一个真正的评分脚本,有具体的检查逻辑。\n\n7. confidence: 1.0,因为代码清晰完整。\n\n现在构建 JSON:\n\ntask_id: \"23a66d5f-baa6-5303-a1d6-6275229ebfa9\"\ndomain: \"mock_websites\"\nsummary: \"验证用户在 Airtable 中更新网站重设计状态为 Done 并勾选 Approved,通过 Gmail 向 enablement lead 发送邮件,并在 Slack #marketing 频道发送提醒消息\"\nis_placeholder: false\ndata_sources: [\"/tmp/task_web_sid\", \"airtable_mock\", \"slack_mock\", \"gmail_mock\"]\n\nscoring_components:\n- name: \"Component 0\" 或 \"Website Redesign Status = Done\"\n weight: 0.3\n description: \"检查 Airtable 中指定记录的网站重设计状态是否标记为 Done\"\n check_logic: \"从 airtable_mock 的 current_state 中获取 tables.tbl_btxo7yi93.records,查找 id 为 rec_mbony82h2 的记录,检查其 fields.fld_9bpvpiybo 是否等于 'Done'\"\n pass_condition: \"rec_mbony82h2 的 fld_9bpvpiybo 字段值为 'Done'\"\n\n- name: \"Component 1\" 或 \"Approved checkbox ticked\"\n weight: 0.2\n description: \"检查 Airtable 中指定记录的 Approved 复选框是否被勾选\"\n check_logic: \"从 airtable_mock 的 current_state 中获取 tables.tbl_btxo7yi93.records,查找 id 为 rec_mbony82h2 的记录,检查其 fields.fld_znxiw39md 是否等于 True\"\n pass_condition: \"rec_mbony82h2 的 fld_znxiw39md 字段值为 True\"\n\n- name: \"Component 2\" 或 \"gmail_new_sent\"\n weight: 0.1\n description: \"检查是否通过 Gmail 发送了新邮件或保存了新草稿\"\n check_logic: \"对比 gmail_mock 的 initial_state 与 current_state,找出 emails 中 id 不在初始集合且 folder 为 sent 或 drafts 的新邮件,以及 drafts 中新增的草稿;若列表非空则通过\"\n pass_condition: \"存在至少一封新的 sent 或 draft 邮件\"\n\n- name: \"Component 3\" 或 \"emailed enablement lead\"\n weight: 0.2\n description: \"检查新邮件是否发送给了 enablement lead\"\n check_logic: \"在新邮件/草稿池中,提取所有 to 字段中的 email 地址并转为小写拼接,检查是否包含 'enablement@company.com'\"\n pass_condition: \"新邮件的收件人包含 enablement@company.com\"\n\n- name: \"Component 4\" 或 \"slack_new_msg\"\n weight: 0.1\n description: \"检查 user_1 是否在 Slack #marketing 频道发送了新消息\"\n check_logic: \"从 slack_mock 的 current_state.messages.marketing 中,排除 SEED 中预置的消息(messageId 不在 seed 中),筛选 senderId 为 'user_1' 的消息;若存在则通过\"\n pass_condition: \"#marketing 频道存在至少一条 user_1 发送的新消息\"\n\n- name: \"Component 5\" 或 \"heads-up in #marketing\"\n weight: 0.1\n description: \"检查 Slack #marketing 频道的新消息内容是否包含相关提醒关键词\"\n check_logic: \"提取 #marketing 频道中 user_1 发送的新消息内容并转为小写,检查是否包含 'publish'、'live'、'redesign'、'approved' 中的任一关键词\"\n pass_condition: \"消息内容包含 'publish'、'live'、'redesign' 或 'approved' 至少一个关键词\"\n\ntotal_max_score: 1.0\nscore_aggregation: \"各组件分数相加,最后通过 min(total, 1.0) 钳制到上限 1.0,并四舍五入到 4 位小数\"\nfailure_modes: [\n \"读取 /tmp/task_web_sid 失败或内容为空:打印 CRITICAL 并返回 0.0 退出\",\n \"请求任何 mock 服务(airtable_mock、slack_mock、gmail_mock)失败:打印 CRITICAL 并返回 0.0 退出\",\n \"Airtable 记录不存在或字段值不符合预期:对应组件不得分\",\n \"Gmail 无新邮件/草稿:对应组件不得分\",\n \"新邮件未发送给 enablement@company.com:对应组件不得分\",\n \"Slack #marketing 无 user_1 新消息:对应组件不得分\",\n \"Slack 消息内容不包含所需关键词:对应组件不得分\"\n]\n\nscoring_logic_explanation: \"脚本首先读取 /tmp/task_web_sid 获取会话 ID,然后依次向 airtable_mock、slack_mock、gmail_mock 发送 HTTP GET 请求获取 current_state。若任何步骤失败则直接返回 0.0。随后按顺序执行 6 项检查:1)Airtable 记录 rec_mbony82h2 的 Website Redesign Status 字段是否为 Done(0.3 分);2)同一记录的 Approved 复选框是否为 True(0.2 分);3)Gmail 是否存在新的 sent/drafts 邮件(0.1 分);4)新邮件是否发送给 enablement@company.com(0.2 分);5)Slack #marketing 是否有 user_1 的新消息(0.1 分);6)该消息内容是否包含 publish/live/redesign/approved 任一关键词(0.1 分)。每项通过则累加对应分数,最终总分经 min(total, 1.0) 限制后四舍五入输出。\"\n\nconfidence: 1.0\n\n确保 JSON 格式正确,没有 markdown 代码块,第一个字符是 {,最后一个字符是 }。 </think> {\"task_id\":\"23a66d5f-baa6-5303-a1d6-6275229ebfa9\",\"domain\":\"mock_websites\",\"summary\":\"验证用户在 Airtable 中将网站重设计状态更新为 Done 并勾选 Approved,通过 Gmail 向 enablement lead 发送邮件,并在 Slack #marketing 频道发送包含指定关键词的提醒消息\",\"is_placeholder\":false,\"data_sources\":[\"/tmp/task_web_sid\",\"airtable_mock\",\"slack_mock\",\"gmail_mock\"],\"scoring_components\":[{\"name\":\"Component 0: Website Redesign Status = Done\",\"weight\":0.3,\"description\":\"检查 Airtable 中指定记录的网站重设计状态是否标记为 Done\",\"check_logic\":\"从 airtable_mock 的 current_state 中获取 tables.tbl_btxo7yi93.records,查找 id 为 rec_mbony82h2 的记录,检查其 fields.fld_9bpvpiybo 是否等于 'Done'\",\"pass_condition\":\"rec_mbony82h2 的 fld_9bpvpiybo 字段值为 'Done'\"},{\"name\":\"Component 1: Approved checkbox ticked\",\"weight\":0.2,\"description\":\"检查 Airtable 中指定记录的 Approved 复选框是否被勾选\",\"check_logic\":\"从 airtable_mock 的 current_state 中获取 tables.tbl_btxo7yi93.records,查找 id 为 rec_mbony82h2 的记录,检查其 fields.fld_znxiw39md 是否等于 True\",\"pass_condition\":\"rec_mbony82h2 的 fld_znxiw39md 字段值为 True\"},{\"name\":\"Component 2: gmail_new_sent\",\"weight\":0.1,\"description\":\"检查是否通过 Gmail 发送了新邮件或保存了新草稿\",\"check_logic\":\"对比 gmail_mock 的 initial_state 与 current_state,找出 emails 中 id 不在初始集合且 folder 为 sent 或 drafts 的新邮件,以及 drafts 中新增的草稿;若列表非空则通过\",\"pass_condition\":\"存在至少一封新的 sent 或 draft 邮件\"},{\"name\":\"Component 3: emailed enablement lead\",\"weight\":0.2,\"description\":\"检查新邮件是否发送给了 enablement lead\",\"check_logic\":\"在新邮件/草稿池中,提取所有 to 字段中的 email 地址并转为小写拼接,检查是否包含 'enablement@company.com'\",\"pass_condition\":\"新邮件的收件人包含 enablement@company.com\"},{\"name\":\"Component 4: slack_new_msg\",\"weight\":0.1,\"description\":\"检查 user_1 是否在 Slack #marketing 频道发送了新消息\",\"check_logic\":\"从 slack_mock 的 current_state.messages.marketing 中,排除 SEED 中预置的消息(messageId 不在 seed 中),筛选 senderId 为 'user_1' 的消息;若存在则通过\",\"pass_condition\":\"#marketing 频道存在至少一条 user_1 发送的新消息\"},{\"name\":\"Component 5: heads-up in #marketing\",\"weight\":0.1,\"description\":\"检查 Slack #marketing 频道的新消息内容是否包含相关提醒关键词\",\"check_logic\":\"提取 #marketing 频道中 user_1 发送的新消息内容并转为小写,检查是否包含 'publish'、'live'、'redesign'、'approved' 中的任一关键词\",\"pass_condition\":\"消息内容包含 'publish'、'live'、'redesign' 或 'approved' 至少一个关键词\"}],\"total_max_score\":1.0,\"score_aggregation\":\"各组件分数相加,最后通过 min(total, 1.0) 钳制到上限 1.0,并四舍五入到 4 位小数\",\"failure_modes\":[\"读取 /tmp/task_web_sid 失败或内容为空:打印 CRITICAL 并返回 0.0 ��出\",\"请求任何 mock 服务(airtable_mock、slack_mock、gmail_mock)失败:打印 CRITICAL 并返回 0.0 退出\",\"Airtable 记录不存在或字段值不符合预期:对应组件不得分\",\"Gmail 无新邮件/草稿:对应组件不得分\",\"新邮件未发送给 enablement@company.com:对应组件不得分\",\"Slack #marketing 无 user_1 新消息:对应组件不得分\",\"Slack 消息内容不包含所需关键词:对应组件不得分\"],\"scoring_logic_explanation\":\"脚本首先读取 /tmp/task_web_sid 获取会话 ID,然后依次向 airtable_mock、slack_mock、gmail_mock 发送 HTTP GET 请求获取 current_state。若任何步骤失败则直接返回 0.0。随后按顺序执行 6 项检查:1)Airtable 记录 rec_mbony82h2 的 Website Redesign Status 字段是否为 Done(0.3 分);2)同一记录的 Approved 复选框是否为 True(0.2 分);3)Gmail 是否存在新的 sent/drafts 邮件(0.1 分);4)新邮件是否发送给 enablement@company.com(0.2 分);5)Slack #marketing 是否有 user_1 的新消息(0.1 分);6)该消息内容是否包含 publish/live/redesign/approved 任一关键词(0.1 分)。每项通过则累加对应分数,最终总分经 min(total, 1.0) 限制后四舍五入输出。\",\"confidence\":1.0}"
|
| 77 |
+
}
|
legacy/4619652a-02e6-5961-83df-6860dfb3ef29/_cua_gym_vm_bridge.sh
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# CUA-Gym VM-side network fix (direct-IP mock access).
|
| 3 |
+
#
|
| 4 |
+
# Runs INSIDE the QEMU guest. The CUA-Gym mock services are now reached by
|
| 5 |
+
# their real IDC address (http://9.91.4.13:81xx) instead of the old
|
| 6 |
+
# localhost:9000-9097 socat bridge, so the VM only needs two fixes:
|
| 7 |
+
#
|
| 8 |
+
# 1. Working DNS — the qcow2-baked /etc/resolv.conf points at the Pod's
|
| 9 |
+
# cluster DNS, which is unreachable from QEMU SLIRP NAT
|
| 10 |
+
# ("Temporary failure in name resolution").
|
| 11 |
+
# 2. The mock host excluded from the woa http proxy — otherwise the VM's
|
| 12 |
+
# Chrome (gsettings proxy) and initial_setup.py's `requests` get a 403
|
| 13 |
+
# from the proxy when hitting 9.91.4.13:81xx. (The old socat path never
|
| 14 |
+
# hit this because localhost is bypassed by default.)
|
| 15 |
+
#
|
| 16 |
+
# Idempotent. Scoped to the CUA-Gym bridge step; does not touch the generic
|
| 17 |
+
# OSWorld setup pipeline.
|
| 18 |
+
#
|
| 19 |
+
# Argv:
|
| 20 |
+
# $1 optional sudo password (default "password"; SetupController
|
| 21 |
+
# substitutes {CLIENT_PASSWORD} when uploaded as a cache file).
|
| 22 |
+
# $2 unused (kept for backward compat — was socat first port 9000).
|
| 23 |
+
# $3 unused (kept for backward compat — was socat last port 9097).
|
| 24 |
+
# $4 optional mock host IP (default 9.91.4.13).
|
| 25 |
+
|
| 26 |
+
set +e
|
| 27 |
+
|
| 28 |
+
PASS="${1:-password}"
|
| 29 |
+
MOCK_HOST="${4:-28.7.186.212}"
|
| 30 |
+
# Derive the /16 IDC subnet so future port/host tweaks on the same segment
|
| 31 |
+
# stay bypassed too (9.91.4.13 -> 9.91.0.0/16).
|
| 32 |
+
MOCK_NET="$(echo "${MOCK_HOST}" | awk -F. 'NF==4{print $1"."$2".0.0/16"}')"
|
| 33 |
+
|
| 34 |
+
run_root() {
|
| 35 |
+
echo "$PASS" | sudo -S -p "" bash -c "$1"
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
# Detect SLIRP gateway from VM's routing table; fall back to 10.0.2.2.
|
| 39 |
+
GW="$(ip route 2>/dev/null | awk '/default/ {print $3; exit}')"
|
| 40 |
+
GW="${GW:-10.0.2.2}"
|
| 41 |
+
|
| 42 |
+
# ─── CUA-Gym network fix (Taiji-specific) ─────────────────────────────
|
| 43 |
+
fix_vm_network() {
|
| 44 |
+
# 0) Discover VM network state at runtime — gateway, own IP/CIDR, SLIRP
|
| 45 |
+
# DNS forwarder. Nothing hardcoded except the mock host above.
|
| 46 |
+
local GW_NET="${GW%.*}"
|
| 47 |
+
local SLIRP_DNS="${GW_NET}.3" # QEMU SLIRP DNS proxy is always .3
|
| 48 |
+
local OWN_CIDR
|
| 49 |
+
OWN_CIDR="$(ip -4 -o addr show scope global 2>/dev/null \
|
| 50 |
+
| awk '{print $4; exit}')"
|
| 51 |
+
local OWN_IP="${OWN_CIDR%/*}"
|
| 52 |
+
local OWN_NET=""
|
| 53 |
+
[ -n "${OWN_IP}" ] && OWN_NET="${OWN_IP%.*}.0/24"
|
| 54 |
+
|
| 55 |
+
# 1) DNS — point at SLIRP DNS proxy + public fallbacks. chattr +i keeps
|
| 56 |
+
# systemd-resolved/NetworkManager from clobbering it.
|
| 57 |
+
if run_root "printf 'nameserver ${SLIRP_DNS}\\nnameserver 114.114.114.114\\nnameserver 8.8.8.8\\n' > /etc/resolv.conf
|
| 58 |
+
chattr +i /etc/resolv.conf 2>/dev/null || true"; then
|
| 59 |
+
echo "[cua_gym_vm_bridge] DNS set: ${SLIRP_DNS}, 114.114.114.114, 8.8.8.8 (gw=${GW})"
|
| 60 |
+
else
|
| 61 |
+
echo "[cua_gym_vm_bridge] WARN: failed to write /etc/resolv.conf"
|
| 62 |
+
fi
|
| 63 |
+
|
| 64 |
+
# 2) Build the proxy bypass list from detected values + the direct-IP
|
| 65 |
+
# mock host (and its /16 subnet). THIS is what makes 9.91.4.13:81xx
|
| 66 |
+
# reachable from inside the VM — without it the woa proxy 403s it.
|
| 67 |
+
local ignore_list="['localhost', '127.0.0.0/8', '${GW}'"
|
| 68 |
+
[ -n "${OWN_IP}" ] && ignore_list="${ignore_list}, '${OWN_IP}'"
|
| 69 |
+
[ -n "${OWN_NET}" ] && ignore_list="${ignore_list}, '${OWN_NET}'"
|
| 70 |
+
[ -n "${GW_NET}" ] && ignore_list="${ignore_list}, '${GW_NET}.0/24'"
|
| 71 |
+
[ -n "${MOCK_HOST}" ] && ignore_list="${ignore_list}, '${MOCK_HOST}'"
|
| 72 |
+
[ -n "${MOCK_NET}" ] && ignore_list="${ignore_list}, '${MOCK_NET}'"
|
| 73 |
+
ignore_list="${ignore_list}]"
|
| 74 |
+
|
| 75 |
+
# 3) GNOME proxy ignore-hosts — Chrome bypasses the woa proxy for these.
|
| 76 |
+
if gsettings set org.gnome.system.proxy ignore-hosts "${ignore_list}" 2>/tmp/gsettings_err; then
|
| 77 |
+
echo "[cua_gym_vm_bridge] gsettings ignore-hosts = ${ignore_list}"
|
| 78 |
+
else
|
| 79 |
+
echo "[cua_gym_vm_bridge] WARN: gsettings ignore-hosts failed: $(cat /tmp/gsettings_err 2>/dev/null)"
|
| 80 |
+
fi
|
| 81 |
+
|
| 82 |
+
# 4) Shell env — comma-separated form for no_proxy/NO_PROXY (requests/curl).
|
| 83 |
+
local NP="localhost,127.0.0.1,${GW}"
|
| 84 |
+
[ -n "${OWN_IP}" ] && NP="${NP},${OWN_IP}"
|
| 85 |
+
[ -n "${OWN_NET}" ] && NP="${NP},${OWN_NET}"
|
| 86 |
+
[ -n "${GW_NET}" ] && NP="${NP},${GW_NET}.0/24"
|
| 87 |
+
[ -n "${MOCK_HOST}" ] && NP="${NP},${MOCK_HOST}"
|
| 88 |
+
[ -n "${MOCK_NET}" ] && NP="${NP},${MOCK_NET}"
|
| 89 |
+
|
| 90 |
+
for var in no_proxy NO_PROXY; do
|
| 91 |
+
if ! grep -q "export ${var}=${NP}" /home/user/.bashrc 2>/dev/null; then
|
| 92 |
+
echo "export ${var}=${NP}" >> /home/user/.bashrc
|
| 93 |
+
fi
|
| 94 |
+
done
|
| 95 |
+
run_root "grep -q '^no_proxy=' /etc/environment 2>/dev/null \
|
| 96 |
+
&& sed -i 's|^no_proxy=.*|no_proxy=\"${NP}\"|' /etc/environment \
|
| 97 |
+
|| echo 'no_proxy=\"${NP}\"' >> /etc/environment
|
| 98 |
+
grep -q '^NO_PROXY=' /etc/environment 2>/dev/null \
|
| 99 |
+
&& sed -i 's|^NO_PROXY=.*|NO_PROXY=\"${NP}\"|' /etc/environment \
|
| 100 |
+
|| echo 'NO_PROXY=\"${NP}\"' >> /etc/environment" >/dev/null 2>&1
|
| 101 |
+
echo "[cua_gym_vm_bridge] no_proxy=${NP}"
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
fix_vm_network
|
| 105 |
+
|
| 106 |
+
echo "[cua_gym_vm_bridge] direct-IP mode: ${MOCK_HOST} (+${MOCK_NET}) bypassed from woa proxy; no socat forwarding needed"
|
legacy/4619652a-02e6-5961-83df-6860dfb3ef29/initial_setup.py
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Initial Setup: cm_brief_to_draft_b97
|
| 3 |
+
Task ID: 4619652a-02e6-5961-83df-6860dfb3ef29
|
| 4 |
+
Domain: mock_websites
|
| 5 |
+
Mocks: notion_mock, google_docs_mock, trello_mock, slack_mock (single shared sid)
|
| 6 |
+
|
| 7 |
+
Persona: You are an office worker acting as a product manager. Your tools for this task are: the Notion workspace, shared documents, the Trello board, team communications.
|
| 8 |
+
|
| 9 |
+
Environment / context (initial state + ground truth this setup establishes):
|
| 10 |
+
Initial environment (seeded via a single shared session id across all mocks): Notion workspace with pages 'Content Brief: Remote Onboarding'; Google Docs with documents 'Brand Style Guide'; Trello 'Project Alpha' board with lists Draft, Review, Published; Slack workspace with channels #general, #marketing, #random. GROUND TRUTH — the agent earns partial credit for each checkpoint: new article draft created (+0.2); draft has both H2s and the demo CTA (+0.3); card moved to Review list (+0.3); slack_new_msg (+0.1); tells team it's in review (+0.1). Scoring is absolute over each mock's current_state; new objects exclude the seeded IDs, so an untouched environment scores 0.0 and fully completing every checkpoint scores 1.0.
|
| 11 |
+
"""
|
| 12 |
+
import json
|
| 13 |
+
import os
|
| 14 |
+
import shlex
|
| 15 |
+
import subprocess
|
| 16 |
+
import time
|
| 17 |
+
import uuid
|
| 18 |
+
|
| 19 |
+
import requests
|
| 20 |
+
|
| 21 |
+
MOCK_URLS = {
|
| 22 |
+
"notion_mock": "http://28.7.186.212:8186",
|
| 23 |
+
"google_docs_mock": "http://28.7.186.212:8162",
|
| 24 |
+
"trello_mock": "http://28.7.186.212:8202",
|
| 25 |
+
"slack_mock": "http://28.7.186.212:8198"
|
| 26 |
+
}
|
| 27 |
+
PRIMARY_URL = 'http://28.7.186.212:8186'
|
| 28 |
+
|
| 29 |
+
sid = str(uuid.uuid4())
|
| 30 |
+
with open('/tmp/task_web_sid', 'w') as f:
|
| 31 |
+
f.write(sid)
|
| 32 |
+
print(f'Generated sid: {sid}')
|
| 33 |
+
|
| 34 |
+
# Full initial state for every mock involved (all required top-level keys present).
|
| 35 |
+
STATES = { 'notion_mock': { 'user': { 'id': 'user-1',
|
| 36 |
+
'name': 'Sarah Chen',
|
| 37 |
+
'email': 'sarah.chen@acme.com',
|
| 38 |
+
'avatar': ''},
|
| 39 |
+
'workspace': { 'id': 'ws-1',
|
| 40 |
+
'name': 'Acme Product',
|
| 41 |
+
'icon': '',
|
| 42 |
+
'members': ['user-1']},
|
| 43 |
+
'pages': { 'page-brief': { 'id': 'page-brief',
|
| 44 |
+
'title': 'Content Brief: Remote Onboarding',
|
| 45 |
+
'icon': '',
|
| 46 |
+
'cover': None,
|
| 47 |
+
'parentId': None,
|
| 48 |
+
'blockIds': ['blk-b1', 'blk-b2'],
|
| 49 |
+
'favorite': False,
|
| 50 |
+
'createdDate': '2026-05-20T00:00:00.000Z',
|
| 51 |
+
'lastEditedDate': '2026-06-05T00:00:00.000Z',
|
| 52 |
+
'properties': {}}},
|
| 53 |
+
'blocks': { 'blk-b1': { 'id': 'blk-b1',
|
| 54 |
+
'type': 'text',
|
| 55 |
+
'content': 'Working title: The Remote '
|
| 56 |
+
'Onboarding Playbook. Audience: new '
|
| 57 |
+
'remote hires.',
|
| 58 |
+
'properties': {},
|
| 59 |
+
'createdDate': '2026-05-20T00:00:00.000Z',
|
| 60 |
+
'lastEditedDate': '2026-05-20T00:00:00.000Z'},
|
| 61 |
+
'blk-b2': { 'id': 'blk-b2',
|
| 62 |
+
'type': 'text',
|
| 63 |
+
'content': 'Required H2s: First Week; Tools & '
|
| 64 |
+
'Access. CTA: book a demo.',
|
| 65 |
+
'properties': {},
|
| 66 |
+
'createdDate': '2026-05-20T00:00:00.000Z',
|
| 67 |
+
'lastEditedDate': '2026-05-20T00:00:00.000Z'}},
|
| 68 |
+
'trash': [],
|
| 69 |
+
'comments': {},
|
| 70 |
+
'settings': { 'appearance': 'light',
|
| 71 |
+
'startWeekMonday': False,
|
| 72 |
+
'fontSize': 'default'},
|
| 73 |
+
'notifications': [],
|
| 74 |
+
'pageOrder': ['page-brief'],
|
| 75 |
+
'focusBlockId': None},
|
| 76 |
+
'google_docs_mock': { 'currentUser': { 'id': 'user-1',
|
| 77 |
+
'name': 'Demo User',
|
| 78 |
+
'email': 'demo@example.com',
|
| 79 |
+
'avatar': ''},
|
| 80 |
+
'users': [ { 'id': 'user-1',
|
| 81 |
+
'name': 'Demo User',
|
| 82 |
+
'email': 'demo@example.com',
|
| 83 |
+
'avatar': ''},
|
| 84 |
+
{ 'id': 'user-2',
|
| 85 |
+
'name': 'Alice Chen',
|
| 86 |
+
'email': 'alice@example.com',
|
| 87 |
+
'avatar': ''},
|
| 88 |
+
{ 'id': 'user-3',
|
| 89 |
+
'name': 'Bob Smith',
|
| 90 |
+
'email': 'bob@example.com',
|
| 91 |
+
'avatar': ''}],
|
| 92 |
+
'documents': { 'd-style': { 'id': 'd-style',
|
| 93 |
+
'title': 'Brand Style Guide',
|
| 94 |
+
'content': '<p>style</p>',
|
| 95 |
+
'ownerId': 'user-1',
|
| 96 |
+
'starred': False,
|
| 97 |
+
'created': '2026-05-01T10:00:00Z',
|
| 98 |
+
'updated': '2026-06-01T10:00:00Z',
|
| 99 |
+
'sharedWith': [],
|
| 100 |
+
'linkSharing': { 'enabled': False,
|
| 101 |
+
'permission': 'viewer'}}},
|
| 102 |
+
'comments': [],
|
| 103 |
+
'ui': { 'currentDocId': None,
|
| 104 |
+
'sidebarOpen': False,
|
| 105 |
+
'sidebarTab': 'comments',
|
| 106 |
+
'shareDialogOpen': False,
|
| 107 |
+
'findReplaceOpen': False,
|
| 108 |
+
'viewMode': 'editing',
|
| 109 |
+
'zoom': 100,
|
| 110 |
+
'documentListView': 'grid',
|
| 111 |
+
'searchQuery': ''}},
|
| 112 |
+
'trello_mock': { 'currentUser': 'u1',
|
| 113 |
+
'users': { 'u1': { 'id': 'u1',
|
| 114 |
+
'name': 'Sarah Chen',
|
| 115 |
+
'username': 'sarah',
|
| 116 |
+
'initials': 'SC',
|
| 117 |
+
'email': 'sarah.chen@acme.com',
|
| 118 |
+
'avatarUrl': ''},
|
| 119 |
+
'u2': { 'id': 'u2',
|
| 120 |
+
'name': 'Bob Lee',
|
| 121 |
+
'username': 'bob',
|
| 122 |
+
'initials': 'BL',
|
| 123 |
+
'email': 'bob@acme.com',
|
| 124 |
+
'avatarUrl': ''}},
|
| 125 |
+
'boards': { 'board-1': { 'id': 'board-1',
|
| 126 |
+
'title': 'Project Alpha',
|
| 127 |
+
'description': '',
|
| 128 |
+
'background': '#0079BF',
|
| 129 |
+
'listIds': ['list-1', 'list-2', 'list-3'],
|
| 130 |
+
'starred': False,
|
| 131 |
+
'visibility': 'workspace',
|
| 132 |
+
'archivedListIds': [],
|
| 133 |
+
'archivedCardIds': [],
|
| 134 |
+
'labels': [],
|
| 135 |
+
'memberIds': ['u1', 'u2'],
|
| 136 |
+
'createdAt': '2026-01-15T10:00:00.000Z'}},
|
| 137 |
+
'lists': { 'list-1': { 'id': 'list-1',
|
| 138 |
+
'title': 'Draft',
|
| 139 |
+
'boardId': 'board-1',
|
| 140 |
+
'cardIds': ['card-ro'],
|
| 141 |
+
'archived': False},
|
| 142 |
+
'list-2': { 'id': 'list-2',
|
| 143 |
+
'title': 'Review',
|
| 144 |
+
'boardId': 'board-1',
|
| 145 |
+
'cardIds': [],
|
| 146 |
+
'archived': False},
|
| 147 |
+
'list-3': { 'id': 'list-3',
|
| 148 |
+
'title': 'Published',
|
| 149 |
+
'boardId': 'board-1',
|
| 150 |
+
'cardIds': [],
|
| 151 |
+
'archived': False}},
|
| 152 |
+
'cards': { 'card-ro': { 'id': 'card-ro',
|
| 153 |
+
'title': 'Remote Onboarding article',
|
| 154 |
+
'description': '',
|
| 155 |
+
'listId': 'list-1',
|
| 156 |
+
'boardId': 'board-1',
|
| 157 |
+
'labelIds': [],
|
| 158 |
+
'memberIds': [],
|
| 159 |
+
'dueDate': None,
|
| 160 |
+
'startDate': None,
|
| 161 |
+
'completed': False,
|
| 162 |
+
'cover': None,
|
| 163 |
+
'checklists': [],
|
| 164 |
+
'comments': [],
|
| 165 |
+
'attachments': [],
|
| 166 |
+
'archived': False,
|
| 167 |
+
'watching': False,
|
| 168 |
+
'position': 0,
|
| 169 |
+
'createdAt': '2026-01-20T10:00:00.000Z'},
|
| 170 |
+
'card-x': { 'id': 'card-x',
|
| 171 |
+
'title': 'Q3 webinar recap',
|
| 172 |
+
'description': '',
|
| 173 |
+
'listId': 'list-1',
|
| 174 |
+
'boardId': 'board-1',
|
| 175 |
+
'labelIds': [],
|
| 176 |
+
'memberIds': [],
|
| 177 |
+
'dueDate': None,
|
| 178 |
+
'startDate': None,
|
| 179 |
+
'completed': False,
|
| 180 |
+
'cover': None,
|
| 181 |
+
'checklists': [],
|
| 182 |
+
'comments': [],
|
| 183 |
+
'attachments': [],
|
| 184 |
+
'archived': False,
|
| 185 |
+
'watching': False,
|
| 186 |
+
'position': 0,
|
| 187 |
+
'createdAt': '2026-01-20T10:00:00.000Z'}},
|
| 188 |
+
'boardOrder': ['board-1']},
|
| 189 |
+
'slack_mock': { 'currentUser': { 'userId': 'user_1',
|
| 190 |
+
'fullName': 'John Smith',
|
| 191 |
+
'displayName': 'John',
|
| 192 |
+
'email': 'john.smith@company.com',
|
| 193 |
+
'avatar': 'https://picsum.photos/200/200?random=1',
|
| 194 |
+
'title': '',
|
| 195 |
+
'status': 'online',
|
| 196 |
+
'statusMessage': '',
|
| 197 |
+
'statusEmoji': '',
|
| 198 |
+
'timeZone': 'America/New_York'},
|
| 199 |
+
'workspace': { 'workspaceId': 'ws_1',
|
| 200 |
+
'workspaceName': 'Acme Corp',
|
| 201 |
+
'icon': ''},
|
| 202 |
+
'users': [ { 'userId': 'user_1',
|
| 203 |
+
'fullName': 'John Smith',
|
| 204 |
+
'displayName': 'John',
|
| 205 |
+
'email': 'john.smith@company.com',
|
| 206 |
+
'avatar': 'https://picsum.photos/200/200?random=1',
|
| 207 |
+
'title': '',
|
| 208 |
+
'status': 'online',
|
| 209 |
+
'statusMessage': '',
|
| 210 |
+
'statusEmoji': '',
|
| 211 |
+
'timeZone': 'America/New_York'},
|
| 212 |
+
{ 'userId': 'user_2',
|
| 213 |
+
'fullName': 'Sarah Johnson',
|
| 214 |
+
'displayName': 'Sarah',
|
| 215 |
+
'email': 'sarah.johnson@company.com',
|
| 216 |
+
'avatar': 'https://picsum.photos/200/200?random=2',
|
| 217 |
+
'title': '',
|
| 218 |
+
'status': 'online',
|
| 219 |
+
'statusMessage': '',
|
| 220 |
+
'statusEmoji': '',
|
| 221 |
+
'timeZone': 'America/New_York'},
|
| 222 |
+
{ 'userId': 'user_3',
|
| 223 |
+
'fullName': 'Mike Chen',
|
| 224 |
+
'displayName': 'Mike',
|
| 225 |
+
'email': 'mike.chen@company.com',
|
| 226 |
+
'avatar': 'https://picsum.photos/200/200?random=3',
|
| 227 |
+
'title': '',
|
| 228 |
+
'status': 'online',
|
| 229 |
+
'statusMessage': '',
|
| 230 |
+
'statusEmoji': '',
|
| 231 |
+
'timeZone': 'America/New_York'},
|
| 232 |
+
{ 'userId': 'user_4',
|
| 233 |
+
'fullName': 'Lisa Park',
|
| 234 |
+
'displayName': 'Lisa',
|
| 235 |
+
'email': 'lisa.park@company.com',
|
| 236 |
+
'avatar': 'https://picsum.photos/200/200?random=4',
|
| 237 |
+
'title': '',
|
| 238 |
+
'status': 'online',
|
| 239 |
+
'statusMessage': '',
|
| 240 |
+
'statusEmoji': '',
|
| 241 |
+
'timeZone': 'America/New_York'}],
|
| 242 |
+
'channels': [ { 'channelId': 'general',
|
| 243 |
+
'name': 'general',
|
| 244 |
+
'description': 'general channel',
|
| 245 |
+
'topic': '',
|
| 246 |
+
'isPrivate': False,
|
| 247 |
+
'isStarred': False,
|
| 248 |
+
'members': ['user_1', 'user_2', 'user_3', 'user_4'],
|
| 249 |
+
'createdBy': 'user_1',
|
| 250 |
+
'createdAt': '2026-01-01T10:00:00Z',
|
| 251 |
+
'pinnedMessages': [],
|
| 252 |
+
'unreadCount': 0},
|
| 253 |
+
{ 'channelId': 'marketing',
|
| 254 |
+
'name': 'marketing',
|
| 255 |
+
'description': 'marketing channel',
|
| 256 |
+
'topic': '',
|
| 257 |
+
'isPrivate': False,
|
| 258 |
+
'isStarred': False,
|
| 259 |
+
'members': ['user_1', 'user_2', 'user_3', 'user_4'],
|
| 260 |
+
'createdBy': 'user_1',
|
| 261 |
+
'createdAt': '2026-01-01T10:00:00Z',
|
| 262 |
+
'pinnedMessages': [],
|
| 263 |
+
'unreadCount': 0},
|
| 264 |
+
{ 'channelId': 'random',
|
| 265 |
+
'name': 'random',
|
| 266 |
+
'description': 'random channel',
|
| 267 |
+
'topic': '',
|
| 268 |
+
'isPrivate': False,
|
| 269 |
+
'isStarred': False,
|
| 270 |
+
'members': ['user_1', 'user_2', 'user_3', 'user_4'],
|
| 271 |
+
'createdBy': 'user_1',
|
| 272 |
+
'createdAt': '2026-01-01T10:00:00Z',
|
| 273 |
+
'pinnedMessages': [],
|
| 274 |
+
'unreadCount': 0}],
|
| 275 |
+
'messages': { 'general': [],
|
| 276 |
+
'marketing': [ { 'messageId': 'm1',
|
| 277 |
+
'senderId': 'user_2',
|
| 278 |
+
'content': 'is the remote onboarding '
|
| 279 |
+
'piece drafted yet?',
|
| 280 |
+
'timestamp': '2026-06-08T08:00:00Z',
|
| 281 |
+
'threadId': None,
|
| 282 |
+
'reactions': [],
|
| 283 |
+
'attachments': [],
|
| 284 |
+
'isEdited': False}],
|
| 285 |
+
'random': []},
|
| 286 |
+
'threads': {},
|
| 287 |
+
'dms': [],
|
| 288 |
+
'bookmarkedMessages': [],
|
| 289 |
+
'callHistory': [],
|
| 290 |
+
'settings': { 'theme': 'light',
|
| 291 |
+
'notifications': 'all',
|
| 292 |
+
'displayDensity': 'comfortable',
|
| 293 |
+
'showAvatars': True,
|
| 294 |
+
'use24Hour': False},
|
| 295 |
+
'invitations': [],
|
| 296 |
+
'notifications': []}}
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
def launch_gui(command, delay_sec=1.0):
|
| 300 |
+
env = os.environ.copy()
|
| 301 |
+
env['DISPLAY'] = ':0'
|
| 302 |
+
subprocess.Popen(shlex.split(command), stdin=subprocess.DEVNULL,
|
| 303 |
+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
| 304 |
+
env=env, start_new_session=True)
|
| 305 |
+
time.sleep(delay_sec)
|
| 306 |
+
|
| 307 |
+
|
| 308 |
+
for name, url in MOCK_URLS.items():
|
| 309 |
+
resp = requests.post(f'{url}/post?sid={sid}',
|
| 310 |
+
json={'action': 'set', 'state': STATES[name]}, timeout=30)
|
| 311 |
+
assert resp.status_code == 200, f'{name} injection failed: {resp.text}'
|
| 312 |
+
go = requests.get(f'{url}/go?sid={sid}', timeout=10).json()
|
| 313 |
+
assert go.get('initial_state') is not None, f'{name} initial_state is None'
|
| 314 |
+
print(f'State injected: {name} sid={sid}')
|
| 315 |
+
|
| 316 |
+
# Open the PRIMARY app as the main window first, then open every other
|
| 317 |
+
# involved mock as an additional browser tab so the agent can see/reach all
|
| 318 |
+
# relevant apps (e.g. read the email in the Gmail tab AND post in Slack).
|
| 319 |
+
# Without this, secondary-app data is injected but has no on-screen entry
|
| 320 |
+
# point, and the agent wastes its budget hunting for a non-existent client.
|
| 321 |
+
launch_gui(f'google-chrome "{PRIMARY_URL}/?sid={sid}"', delay_sec=2.0)
|
| 322 |
+
print(f'GUI_READY: launched browser at {PRIMARY_URL}/?sid={sid}')
|
| 323 |
+
for _name, _url in MOCK_URLS.items():
|
| 324 |
+
if _url == PRIMARY_URL:
|
| 325 |
+
continue
|
| 326 |
+
launch_gui(f'google-chrome --new-tab "{_url}/?sid={sid}"', delay_sec=1.0)
|
| 327 |
+
print(f'Opened tab: {_name} at {_url}/?sid={sid}')
|
legacy/4619652a-02e6-5961-83df-6860dfb3ef29/reward.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Reward Script: cm_brief_to_draft_b97
|
| 3 |
+
Task ID: 4619652a-02e6-5961-83df-6860dfb3ef29
|
| 4 |
+
Domain: mock_websites
|
| 5 |
+
Mocks: notion_mock, google_docs_mock, trello_mock, slack_mock
|
| 6 |
+
Scoring (all programmatic; evaluated against each mock's current_state; total = 1.0):
|
| 7 |
+
- [0.2] new article draft created
|
| 8 |
+
- [0.3] draft has both H2s and the demo CTA
|
| 9 |
+
- [0.3] card moved to Review list
|
| 10 |
+
- [0.1] slack_new_msg
|
| 11 |
+
- [0.1] tells team it's in review
|
| 12 |
+
"""
|
| 13 |
+
import re
|
| 14 |
+
import sys
|
| 15 |
+
|
| 16 |
+
import requests
|
| 17 |
+
|
| 18 |
+
MOCK_URLS = {
|
| 19 |
+
"notion_mock": "http://28.7.186.212:8186",
|
| 20 |
+
"google_docs_mock": "http://28.7.186.212:8162",
|
| 21 |
+
"trello_mock": "http://28.7.186.212:8202",
|
| 22 |
+
"slack_mock": "http://28.7.186.212:8198"
|
| 23 |
+
}
|
| 24 |
+
SEED = {
|
| 25 |
+
"slack_mock:general": [],
|
| 26 |
+
"slack_mock:marketing": [
|
| 27 |
+
"m1"
|
| 28 |
+
],
|
| 29 |
+
"slack_mock:random": []
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
try:
|
| 33 |
+
with open('/tmp/task_web_sid') as f:
|
| 34 |
+
sid = f.read().strip()
|
| 35 |
+
if not sid:
|
| 36 |
+
raise ValueError('sid is empty')
|
| 37 |
+
except Exception as e:
|
| 38 |
+
print(f'CRITICAL: cannot read sid: {e}')
|
| 39 |
+
print('REWARD: 0.0')
|
| 40 |
+
sys.exit(0)
|
| 41 |
+
|
| 42 |
+
STATES = {}
|
| 43 |
+
for _name, _url in MOCK_URLS.items():
|
| 44 |
+
try:
|
| 45 |
+
_r = requests.get(f'{_url}/go?sid={sid}', timeout=15)
|
| 46 |
+
_r.raise_for_status()
|
| 47 |
+
STATES[_name] = _r.json()
|
| 48 |
+
except Exception as e:
|
| 49 |
+
print(f'CRITICAL: cannot fetch {_name}: {e}')
|
| 50 |
+
print('REWARD: 0.0')
|
| 51 |
+
sys.exit(0)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def cur(mock):
|
| 55 |
+
return (STATES.get(mock) or {}).get('current_state') or {}
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def _lc(s):
|
| 59 |
+
return (s or '').lower()
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
total = 0.0
|
| 63 |
+
|
| 64 |
+
# c0: a new google doc titled about (new article draft created)
|
| 65 |
+
c0_init = set((STATES['google_docs_mock'].get('initial_state') or {}).get('documents', {}).keys())
|
| 66 |
+
c0_docs = cur('google_docs_mock').get('documents') or {}
|
| 67 |
+
c0_new = [d for did, d in c0_docs.items() if did not in c0_init and any(t in _lc(d.get('title','')) for t in ['remote onboarding playbook', 'remote onboarding'])]
|
| 68 |
+
if c0_new:
|
| 69 |
+
print('PASS: new article draft created (0.2)')
|
| 70 |
+
total += 0.2
|
| 71 |
+
else:
|
| 72 |
+
print('FAIL: new article draft created')
|
| 73 |
+
|
| 74 |
+
# c1: new google doc body (draft has both H2s and the demo CTA)
|
| 75 |
+
c1_init = set((STATES['google_docs_mock'].get('initial_state') or {}).get('documents', {}).keys())
|
| 76 |
+
c1_docs = cur('google_docs_mock').get('documents') or {}
|
| 77 |
+
c1_new = [d for did, d in c1_docs.items() if did not in c1_init and any(t in _lc(d.get('title','')) for t in ['remote onboarding playbook', 'remote onboarding'])]
|
| 78 |
+
c1_txt = _lc(' '.join(d.get('content','') for d in c1_new))
|
| 79 |
+
if c1_new and all(t in c1_txt for t in ['first week', 'tools & access', 'demo']):
|
| 80 |
+
print('PASS: draft has both H2s and the demo CTA (0.3)')
|
| 81 |
+
total += 0.3
|
| 82 |
+
else:
|
| 83 |
+
print('FAIL: draft has both H2s and the demo CTA')
|
| 84 |
+
|
| 85 |
+
# c2: trello card card-ro listId == 'list-2'
|
| 86 |
+
c2_card = (cur('trello_mock').get('cards') or {}).get('card-ro')
|
| 87 |
+
if c2_card and c2_card.get('listId') == 'list-2':
|
| 88 |
+
print('PASS: card moved to Review list (0.3)')
|
| 89 |
+
total += 0.3
|
| 90 |
+
else:
|
| 91 |
+
print('FAIL: card moved to Review list')
|
| 92 |
+
|
| 93 |
+
# c3: new message by user_1 in #marketing
|
| 94 |
+
c3_msgs = (cur('slack_mock').get('messages') or {}).get('marketing', []) or []
|
| 95 |
+
c3_seed = set(SEED.get('slack_mock:marketing', []))
|
| 96 |
+
c3_new = [m for m in c3_msgs if m.get('messageId') not in c3_seed and m.get('senderId') == 'user_1']
|
| 97 |
+
c3_blob = _lc(' '.join((m.get('content') or '') for m in c3_new))
|
| 98 |
+
if c3_new:
|
| 99 |
+
print('PASS: new message by user_1 in #marketing (0.1)')
|
| 100 |
+
total += 0.1
|
| 101 |
+
else:
|
| 102 |
+
print('FAIL: no new user_1 message in #marketing')
|
| 103 |
+
|
| 104 |
+
# c4: slack #marketing contains (tells team it\'s in review)
|
| 105 |
+
c4_msgs = (cur('slack_mock').get('messages') or {}).get('marketing', []) or []
|
| 106 |
+
c4_seed = set(SEED.get('slack_mock:marketing', []))
|
| 107 |
+
c4_blob = _lc(' '.join((m.get('content') or '') for m in c4_msgs if m.get('messageId') not in c4_seed and m.get('senderId') == 'user_1'))
|
| 108 |
+
if any(t in c4_blob for t in ['review', 'draft']):
|
| 109 |
+
print('PASS: tells team it\'s in review (0.1)')
|
| 110 |
+
total += 0.1
|
| 111 |
+
else:
|
| 112 |
+
print('FAIL: tells team it\'s in review')
|
| 113 |
+
|
| 114 |
+
final = round(min(total, 1.0), 4)
|
| 115 |
+
print(f'\nScore: {total}/1.0')
|
| 116 |
+
print(f'REWARD: {final}')
|
legacy/4619652a-02e6-5961-83df-6860dfb3ef29/reward_label.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"reward_file": "/apdcephfs_sh2/share_300000800/user/jackwkwang/long-horizon-tasks/mini_osworld_xiangwu/cache/4619652a-02e6-5961-83df-6860dfb3ef29/reward.py",
|
| 3 |
+
"api_url": "http://28.7.184.184:8000/v1/chat/completions",
|
| 4 |
+
"model": "Kimi-K2.6",
|
| 5 |
+
"max_code_chars": 100000,
|
| 6 |
+
"created_at": "2026-07-14 10:18:50",
|
| 7 |
+
"label": {
|
| 8 |
+
"task_id": "4619652a-02e6-5961-83df-6860dfb3ef29",
|
| 9 |
+
"domain": "mock_websites",
|
| 10 |
+
"summary": "验证用户是否根据 brief 在 Google Docs 创建包含特定 H2 和 demo CTA 的新文章草稿,将 Trello 卡片移到 Review 列表,并在 Slack #marketing 频道通知团队稿件已进入 review 阶段",
|
| 11 |
+
"is_placeholder": false,
|
| 12 |
+
"data_sources": [
|
| 13 |
+
"/tmp/task_web_sid",
|
| 14 |
+
"notion_mock",
|
| 15 |
+
"google_docs_mock",
|
| 16 |
+
"trello_mock",
|
| 17 |
+
"slack_mock"
|
| 18 |
+
],
|
| 19 |
+
"scoring_components": [
|
| 20 |
+
{
|
| 21 |
+
"name": "Component 0",
|
| 22 |
+
"weight": 0.2,
|
| 23 |
+
"description": "检查是否在 Google Docs 中创建了新的文章草稿",
|
| 24 |
+
"check_logic": "对比 google_docs_mock 的 initial_state 与 current_state 中的 documents,找出 documentId 不在初始集合中的新文档,并检查其 title(转小写后)是否包含 'remote onboarding playbook' 或 'remote onboarding'",
|
| 25 |
+
"pass_condition": "存在至少一个新增文档且标题包含指定关键词"
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"name": "Component 1",
|
| 29 |
+
"weight": 0.3,
|
| 30 |
+
"description": "检查新文章草稿正文是否包含两个指定的 H2 标题和 demo CTA",
|
| 31 |
+
"check_logic": "获取 Component 0 中识别出的新文档,将其 content 拼接并转小写为 c1_txt,检查是否同时包含 'first week'、'tools & access' 和 'demo'",
|
| 32 |
+
"pass_condition": "新文档内容同时包含 'first week'、'tools & access' 和 'demo'"
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"name": "Component 2",
|
| 36 |
+
"weight": 0.3,
|
| 37 |
+
"description": "检查 Trello 卡片是否被移动到 Review 列表",
|
| 38 |
+
"check_logic": "检查 trello_mock current_state 中 cards['card-ro'] 的 listId 字段是否等于 'list-2'",
|
| 39 |
+
"pass_condition": "card-ro 的 listId 为 'list-2'"
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"name": "Component 3",
|
| 43 |
+
"weight": 0.1,
|
| 44 |
+
"description": "检查 user_1 是否在 Slack #marketing 频道发送了新消息",
|
| 45 |
+
"check_logic": "获取 slack_mock current_state 中 marketing 频道的消息列表,排除 SEED 中预置的消息(messageId 不在 seed 中),筛选出发送者为 user_1 的新消息",
|
| 46 |
+
"pass_condition": "存在至少一条由 user_1 发送的、不在 seed 中的新消息"
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"name": "Component 4",
|
| 50 |
+
"weight": 0.1,
|
| 51 |
+
"description": "检查 Slack 新消息是否告知团队稿件已进入 review 阶段",
|
| 52 |
+
"check_logic": "将 user_1 在 #marketing 频道的新消息内容拼接并转小写,检查是否包含 'review' 或 'draft'",
|
| 53 |
+
"pass_condition": "消息内容包含 'review' 或 'draft'"
|
| 54 |
+
}
|
| 55 |
+
],
|
| 56 |
+
"total_max_score": 1.0,
|
| 57 |
+
"score_aggregation": "各组件分数相加,最终通过 min(total, 1.0) 钳制到上限 1.0 并四舍五入到 4 位小数",
|
| 58 |
+
"failure_modes": [
|
| 59 |
+
"读取 /tmp/task_web_sid 失败或 sid 为空时提前退出并返回 0.0",
|
| 60 |
+
"从任一 mock 服务(notion_mock、google_docs_mock、trello_mock、slack_mock)拉取 current_state 失败时提前退出并返回 0.0",
|
| 61 |
+
"Google Docs 未新增标题匹配的文章草稿时 Component 0 不得分",
|
| 62 |
+
"新增草稿内容未同时包含 'first week'、'tools & access' 和 'demo' 时 Component 1 不得分",
|
| 63 |
+
"Trello 卡片 card-ro 的 listId 不是 'list-2' 时 Component 2 不得分",
|
| 64 |
+
"Slack #marketing 频道没有 user_1 发送的新消息时 Component 3 不得分",
|
| 65 |
+
"Slack 新消息内容不包含 'review' 或 'draft' 时 Component 4 不得分"
|
| 66 |
+
],
|
| 67 |
+
"scoring_logic_explanation": "脚本首先读取 /tmp/task_web_sid 获取会话 ID,若失败则直接返回 0.0。随后依次向四个 mock 服务请求当前状态并缓存到 STATES 字典中,任一请求失败也会直接返回 0.0。评分按以下顺序执行:1)Component 0 检查 Google Docs 中是否新增了标题包含 'remote onboarding playbook' 或 'remote onboarding' 的文档,通过则加 0.2;2)Component 1 检查这些新增文档的正文内容(转小写后)是否同时包含 'first week'、'tools & access' 和 'demo',通过则加 0.3;3)Component 2 检查 trello_mock 中 cards['card-ro'] 的 listId 是否等于 'list-2',通过则加 0.3;4)Component 3 检查 slack_mock 的 #marketing 频道中是否存在由 user_1 发送的、不在 SEED 预置消息中的新消息,通过则加 0.1;5)Component 4 检查上述 user_1 的新消息内容(转小写后)是否包含 'review' 或 'draft',通过则加 0.1。各组件独立计分,最终总分通过 min(total, 1.0) 钳制到 1.0 上限并四舍五入到 4 位小数输出。",
|
| 68 |
+
"confidence": 1.0
|
| 69 |
+
},
|
| 70 |
+
"raw_response": "用户要求我分析一个 reward.py 评分脚本的评分逻辑,并输出一个严格的 JSON 对象。\n\n让我仔细阅读源码:\n\n1. **Docstring 信息**:\n - Reward Script: cm_brief_to_draft_b97\n - Task ID: 4619652a-02e6-5961-83df-6860dfb3ef29\n - Domain: mock_websites\n - Mocks: notion_mock, google_docs_mock, trello_mock, slack_mock\n - Scoring: total = 1.0\n - [0.2] new article draft created\n - [0.3] draft has both H2s and the demo CTA\n - [0.3] card moved to Review list\n - [0.1] slack_new_msg\n - [0.1] tells team it's in review\n\n2. **数据源**:\n - `/tmp/task_web_sid` 文件获取 sid\n - 四个 mock 服务: notion_mock, google_docs_mock, trello_mock, slack_mock\n - 通过 HTTP GET 请求获取状态\n\n3. **评分组件**:\n - **Component 0 (0.2)**: 检查 google_docs_mock 中是否有新创建的文档,标题包含 'remote onboarding playbook' 或 'remote onboarding'\n - **Component 1 (0.3)**: 检查新创建的 google doc 内容是否包含 'first week', 'tools & access', 'demo'(不区分大小写)\n - **Component 2 (0.3)**: 检查 trello_mock 中 card-ro 的 listId 是否为 'list-2'\n - **Component 3 (0.1)**: 检查 slack_mock 的 marketing 频道中是否有 user_1 发送的新消息(排除 seed 中的消息)\n - **Component 4 (0.1)**: 检查 slack_mock 的 marketing 频道中 user_1 的新消息内容是否包含 'review' 或 'draft'\n\n4. **分数汇总**:\n - 各组件分数相加\n - 最后 `final = round(min(total, 1.0), 4)`,即相加后钳制到 1.0\n\n5. **失败模式**:\n - 读取 sid 失败 -> 打印 CRITICAL, REWARD: 0.0, sys.exit(0)\n - 获取任何 mock 状态失败 -> 打印 CRITICAL, REWARD: 0.0, sys.exit(0)\n - 各组件检查失败只是不加分,不会提前退出\n\n6. **is_placeholder**: false,因为这是一个真正的评分脚本,有具体的检查逻辑。\n\n7. **confidence**: 1.0,因为源码完整且逻辑清晰。\n\n现在构建 JSON:\n\n- task_id: \"4619652a-02e6-5961-83df-6860dfb3ef29\"\n- domain: \"mock_websites\"\n- summary: \"验证用户是否根据 brief 在 Google Docs 创建包含特定 H2 和 CTA 的新文章草稿,将 Trello 卡片移到 Review 列表,并在 Slack marketing 频道通知团队稿件已进入 review 阶段\"\n- is_placeholder: false\n- data_sources: [\"/tmp/task_web_sid\", \"notion_mock\", \"google_docs_mock\", \"trello_mock\", \"slack_mock\"]\n- scoring_components: 5 个组件\n- total_max_score: 1.0\n- score_aggregation: \"各组件分数相加,最终通过 min(total, 1.0) 钳制到上限 1.0 并四舍五入到 4 位小数\"\n- failure_modes: [\"读取 /tmp/task_web_sid 失败或 sid 为空\", \"从任一 mock 服务拉取当前状态失败\"]\n- scoring_logic_explanation: 详细说明执行顺序...\n- confidence: 1.0\n\n确保所有字符串 value 使用中文,但代码标识符保留原样。\n\n检查每个组件的 check_logic 和 pass_condition:\n\nComponent 1:\n- name: \"Component 0\" 或 \"new article draft created\"\n- weight: 0.2\n- description: \"检查是否在 Google Docs 中创建了新的文章草稿\"\n- check_logic: \"对比 google_docs_mock 的 initial_state 与 current_state 中的 documents,找出不在初始集合中的新文档,并检查其 title(转小写后)是否包含 'remote onboarding playbook' 或 'remote onboarding'\"\n- pass_condition: \"存在至少一个新增文档且标题包含指定关键词\"\n\nComponent 2:\n- name: \"Component 1\" 或 \"draft has both H2s and the demo CTA\"\n- weight: 0.3\n- description: \"检查新文章草稿正文是否包含两个指定的 H2 标题和 demo CTA\"\n- check_logic: \"获取 Component 0 中识别出的新文档,将其 content 拼接并转小写,检查是否同时包含 'first week'、'tools & access' 和 'demo'\"\n- pass_condition: \"新文档内容同时包含 'first week'、'tools & access' 和 'demo'\"\n\nComponent 3:\n- name: \"Component 2\" 或 \"card moved to Review list\"\n- weight: 0.3\n- description: \"检查 Trello 卡片是否被移动到 Review 列表\"\n- check_logic: \"检查 trello_mock current_state 中 cards['card-ro'] 的 listId 字段是否等于 'list-2'\"\n- pass_condition: \"card-ro 的 listId 为 'list-2'\"\n\nComponent 4:\n- name: \"Component 3\" 或 \"slack_new_msg\"\n- weight: 0.1\n- description: \"检查 user_1 是否在 Slack #marketing 频道发送了新消息\"\n- check_logic: \"获取 slack_mock current_state 中 marketing 频道的消息列表,排除 SEED 中预置的消息(messageId 不在 seed 中),筛选出发送者为 user_1 的新消息\"\n- pass_condition: \"存在至少一条由 user_1 发送的、不在 seed 中的新消息\"\n\nComponent 5:\n- name: \"Component 4\" 或 \"tells team it's in review\"\n- weight: 0.1\n- description: \"检查 Slack 新消息是否告知团队稿件已进入 review 阶段\"\n- check_logic: \"将 user_1 在 #marketing 频道的新消息内容拼接并转小写,检查是否包含 'review' 或 'draft'\"\n- pass_condition: \"消息内容包含 'review' 或 'draft'\"\n\nfailure_modes 还需要包括各组件失败只是不得分,���有两个 critical 提前退出。\n\n让我再仔细看看代码中的变量名和逻辑,确保准确。\n\nc0_init: 从 STATES['google_docs_mock'].get('initial_state') 获取 documents 的 keys\nc0_docs: cur('google_docs_mock').get('documents') or {}\nc0_new: [d for did, d in c0_docs.items() if did not in c0_init and any(t in _lc(d.get('title','')) for t in ['remote onboarding playbook', 'remote onboarding'])]\n\nc1 和 c0 类似,但检查 content。\n\nc2_card = (cur('trello_mock').get('cards') or {}).get('card-ro')\nif c2_card and c2_card.get('listId') == 'list-2':\n\nc3: c3_msgs = (cur('slack_mock').get('messages') or {}).get('marketing', []) or []\nc3_seed = set(SEED.get('slack_mock:marketing', []))\nc3_new = [m for m in c3_msgs if m.get('messageId') not in c3_seed and m.get('senderId') == 'user_1']\n\nc4: c4_msgs = ... 同上\nc4_seed = ... 同上\nc4_blob = _lc(' '.join((m.get('content') or '') for m in c4_msgs if m.get('messageId') not in c4_seed and m.get('senderId') == 'user_1'))\nif any(t in c4_blob for t in ['review', 'draft']):\n\n注意 c4 检查的是所有 user_1 的新消息(不一定是 c3_new 中的,但逻辑一样),内容包含 review 或 draft。\n\n最终输出 JSON,不要 markdown 代码块,第一个字符是 {,最后一个是 }。\n\n确保 JSON 格式正确,没有 trailing comma。\n\nsummary 用中文。\n\nscoring_logic_explanation 要详细:\n1. 从 /tmp/task_web_sid 读取会话 ID\n2. 向四个 mock 服务获取 current_state\n3. 组件 0:检查 Google Docs 新增文档标题\n4. 组件 1:检查新增文档内容关键词\n5. 组件 2:检查 Trello 卡片 listId\n6. 组件 3:检查 Slack #marketing 新消息\n7. 组件 4:检查 Slack 消息内容\n8. 累加分数,min(total, 1.0) 并四舍五入\n\nconfidence: 1.0\n\nis_placeholder: false\n\ndomain: mock_websites\n\ntask_id: 4619652a-02e6-5961-83df-6860dfb3ef29\n\ndata_sources: [\"/tmp/task_web_sid\", \"notion_mock\", \"google_docs_mock\", \"trello_mock\", \"slack_mock\"] (notion_mock 虽然在 MOCK_URLS 中,但评分逻辑里没有用到,不过它确实从该数据源获取了状态,所以应该包含)\n\n让我再确认一下 docstring 中的 task_id 和 domain。docstring 明确写了 Task ID: 4619652a-02e6-5961-83df-6860dfb3ef29 和 Domain: mock_websites。\n\n好,构建最终 JSON。 </think> {\"task_id\":\"4619652a-02e6-5961-83df-6860dfb3ef29\",\"domain\":\"mock_websites\",\"summary\":\"验证用户是否根据 brief 在 Google Docs 创建包含特定 H2 和 demo CTA 的新文章草稿,将 Trello 卡片移到 Review 列表,并在 Slack #marketing 频道通知团队稿件已进入 review 阶段\",\"is_placeholder\":false,\"data_sources\":[\"/tmp/task_web_sid\",\"notion_mock\",\"google_docs_mock\",\"trello_mock\",\"slack_mock\"],\"scoring_components\":[{\"name\":\"Component 0\",\"weight\":0.2,\"description\":\"检查是否在 Google Docs 中创建了新的文章草稿\",\"check_logic\":\"对比 google_docs_mock 的 initial_state 与 current_state 中的 documents,找出 documentId 不在初始集合中的新文档,并检查其 title(转小写后)是否包含 'remote onboarding playbook' 或 'remote onboarding'\",\"pass_condition\":\"存在至少一个新增文档且标题包含指定关键词\"},{\"name\":\"Component 1\",\"weight\":0.3,\"description\":\"检查新文章草稿正文是否包含两个指定的 H2 标题和 demo CTA\",\"check_logic\":\"获取 Component 0 中识别出的新文档,将其 content 拼接并转小写为 c1_txt,检查是否同时包含 'first week'、'tools & access' 和 'demo'\",\"pass_condition\":\"新文档内容同时包含 'first week'、'tools & access' 和 'demo'\"},{\"name\":\"Component 2\",\"weight\":0.3,\"description\":\"检查 Trello 卡片是否被移动到 Review 列表\",\"check_logic\":\"检查 trello_mock current_state 中 cards['card-ro'] 的 listId 字段是否等于 'list-2'\",\"pass_condition\":\"card-ro 的 listId 为 'list-2'\"},{\"name\":\"Component 3\",\"weight\":0.1,\"description\":\"检查 user_1 是否在 Slack #marketing 频道发送了新消息\",\"check_logic\":\"获取 slack_mock current_state 中 marketing 频道的消息列表,排除 SEED 中预置的消息(messageId 不在 seed 中),筛选出发送者为 user_1 的新消息\",\"pass_condition\":\"存在至少一条由 user_1 发送的、不在 seed 中的新消息\"},{\"name\":\"Component 4\",\"weight\":0.1,\"description\":\"检查 Slack 新消息是否告知团队稿件已进入 review 阶段\",\"check_logic\":\"将 user_1 在 #marketing 频道的新消息内容拼接并转小写,检查是否包含 'review' 或 'draft'\",\"pass_condition\":\"消息内容包含 'review' 或 'draft'\"}],\"total_max_score\":1.0,\"score_aggregation\":\"各组件分数相加,最终通过 min(total, 1.0) 钳制到上限 1.0 并四舍五入到 4 位小数\",\"failure_modes\":[\"读取 /tmp/task_web_sid 失败或 sid 为空时提前退出并返回 0.0\",\"从任一 mock 服务(notion_mock、google_docs_mock、trello_mock、slack_mock)拉取 current_state 失败时提前退出并���回 0.0\",\"Google Docs 未新增标题匹配的文章草稿时 Component 0 不得分\",\"新增草稿内容未同时包含 'first week'、'tools & access' 和 'demo' 时 Component 1 不得分\",\"Trello 卡片 card-ro 的 listId 不是 'list-2' 时 Component 2 不得分\",\"Slack #marketing 频道没有 user_1 发送的新消息时 Component 3 不得分\",\"Slack 新消息内容不包含 'review' 或 'draft' 时 Component 4 不得分\"],\"scoring_logic_explanation\":\"脚本首先读取 /tmp/task_web_sid 获取会话 ID,若失败则直接返回 0.0。随后依次向四个 mock 服务请求当前状态并缓存到 STATES 字典中,任一请求失败也会直接返回 0.0。评分按以下顺序执行:1)Component 0 检查 Google Docs 中是否新增了标题包含 'remote onboarding playbook' 或 'remote onboarding' 的文档,通过则加 0.2;2)Component 1 检查这些新增文档的正文内容(转小写后)是否同时包含 'first week'、'tools & access' 和 'demo',通过则加 0.3;3)Component 2 检查 trello_mock 中 cards['card-ro'] 的 listId 是否等于 'list-2',通过则加 0.3;4)Component 3 检查 slack_mock 的 #marketing 频道中是否存在由 user_1 发送的、不在 SEED 预置消息中的新消息,通过则加 0.1;5)Component 4 检查上述 user_1 的新消息内容(转小写后)是否包含 'review' 或 'draft',通过则加 0.1。各组件独立计分,最终总分通过 min(total, 1.0) 钳制到 1.0 上限并四舍五入到 4 位小数输出。\",\"confidence\":1.0}"
|
| 71 |
+
}
|
legacy/57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f/_cua_gym_vm_bridge.sh
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# CUA-Gym VM-side network fix (direct-IP mock access).
|
| 3 |
+
#
|
| 4 |
+
# Runs INSIDE the QEMU guest. The CUA-Gym mock services are now reached by
|
| 5 |
+
# their real IDC address (http://9.91.4.13:81xx) instead of the old
|
| 6 |
+
# localhost:9000-9097 socat bridge, so the VM only needs two fixes:
|
| 7 |
+
#
|
| 8 |
+
# 1. Working DNS — the qcow2-baked /etc/resolv.conf points at the Pod's
|
| 9 |
+
# cluster DNS, which is unreachable from QEMU SLIRP NAT
|
| 10 |
+
# ("Temporary failure in name resolution").
|
| 11 |
+
# 2. The mock host excluded from the woa http proxy — otherwise the VM's
|
| 12 |
+
# Chrome (gsettings proxy) and initial_setup.py's `requests` get a 403
|
| 13 |
+
# from the proxy when hitting 9.91.4.13:81xx. (The old socat path never
|
| 14 |
+
# hit this because localhost is bypassed by default.)
|
| 15 |
+
#
|
| 16 |
+
# Idempotent. Scoped to the CUA-Gym bridge step; does not touch the generic
|
| 17 |
+
# OSWorld setup pipeline.
|
| 18 |
+
#
|
| 19 |
+
# Argv:
|
| 20 |
+
# $1 optional sudo password (default "password"; SetupController
|
| 21 |
+
# substitutes {CLIENT_PASSWORD} when uploaded as a cache file).
|
| 22 |
+
# $2 unused (kept for backward compat — was socat first port 9000).
|
| 23 |
+
# $3 unused (kept for backward compat — was socat last port 9097).
|
| 24 |
+
# $4 optional mock host IP (default 9.91.4.13).
|
| 25 |
+
|
| 26 |
+
set +e
|
| 27 |
+
|
| 28 |
+
PASS="${1:-password}"
|
| 29 |
+
MOCK_HOST="${4:-28.7.186.212}"
|
| 30 |
+
# Derive the /16 IDC subnet so future port/host tweaks on the same segment
|
| 31 |
+
# stay bypassed too (9.91.4.13 -> 9.91.0.0/16).
|
| 32 |
+
MOCK_NET="$(echo "${MOCK_HOST}" | awk -F. 'NF==4{print $1"."$2".0.0/16"}')"
|
| 33 |
+
|
| 34 |
+
run_root() {
|
| 35 |
+
echo "$PASS" | sudo -S -p "" bash -c "$1"
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
# Detect SLIRP gateway from VM's routing table; fall back to 10.0.2.2.
|
| 39 |
+
GW="$(ip route 2>/dev/null | awk '/default/ {print $3; exit}')"
|
| 40 |
+
GW="${GW:-10.0.2.2}"
|
| 41 |
+
|
| 42 |
+
# ─── CUA-Gym network fix (Taiji-specific) ─────────────────────────────
|
| 43 |
+
fix_vm_network() {
|
| 44 |
+
# 0) Discover VM network state at runtime — gateway, own IP/CIDR, SLIRP
|
| 45 |
+
# DNS forwarder. Nothing hardcoded except the mock host above.
|
| 46 |
+
local GW_NET="${GW%.*}"
|
| 47 |
+
local SLIRP_DNS="${GW_NET}.3" # QEMU SLIRP DNS proxy is always .3
|
| 48 |
+
local OWN_CIDR
|
| 49 |
+
OWN_CIDR="$(ip -4 -o addr show scope global 2>/dev/null \
|
| 50 |
+
| awk '{print $4; exit}')"
|
| 51 |
+
local OWN_IP="${OWN_CIDR%/*}"
|
| 52 |
+
local OWN_NET=""
|
| 53 |
+
[ -n "${OWN_IP}" ] && OWN_NET="${OWN_IP%.*}.0/24"
|
| 54 |
+
|
| 55 |
+
# 1) DNS — point at SLIRP DNS proxy + public fallbacks. chattr +i keeps
|
| 56 |
+
# systemd-resolved/NetworkManager from clobbering it.
|
| 57 |
+
if run_root "printf 'nameserver ${SLIRP_DNS}\\nnameserver 114.114.114.114\\nnameserver 8.8.8.8\\n' > /etc/resolv.conf
|
| 58 |
+
chattr +i /etc/resolv.conf 2>/dev/null || true"; then
|
| 59 |
+
echo "[cua_gym_vm_bridge] DNS set: ${SLIRP_DNS}, 114.114.114.114, 8.8.8.8 (gw=${GW})"
|
| 60 |
+
else
|
| 61 |
+
echo "[cua_gym_vm_bridge] WARN: failed to write /etc/resolv.conf"
|
| 62 |
+
fi
|
| 63 |
+
|
| 64 |
+
# 2) Build the proxy bypass list from detected values + the direct-IP
|
| 65 |
+
# mock host (and its /16 subnet). THIS is what makes 9.91.4.13:81xx
|
| 66 |
+
# reachable from inside the VM — without it the woa proxy 403s it.
|
| 67 |
+
local ignore_list="['localhost', '127.0.0.0/8', '${GW}'"
|
| 68 |
+
[ -n "${OWN_IP}" ] && ignore_list="${ignore_list}, '${OWN_IP}'"
|
| 69 |
+
[ -n "${OWN_NET}" ] && ignore_list="${ignore_list}, '${OWN_NET}'"
|
| 70 |
+
[ -n "${GW_NET}" ] && ignore_list="${ignore_list}, '${GW_NET}.0/24'"
|
| 71 |
+
[ -n "${MOCK_HOST}" ] && ignore_list="${ignore_list}, '${MOCK_HOST}'"
|
| 72 |
+
[ -n "${MOCK_NET}" ] && ignore_list="${ignore_list}, '${MOCK_NET}'"
|
| 73 |
+
ignore_list="${ignore_list}]"
|
| 74 |
+
|
| 75 |
+
# 3) GNOME proxy ignore-hosts — Chrome bypasses the woa proxy for these.
|
| 76 |
+
if gsettings set org.gnome.system.proxy ignore-hosts "${ignore_list}" 2>/tmp/gsettings_err; then
|
| 77 |
+
echo "[cua_gym_vm_bridge] gsettings ignore-hosts = ${ignore_list}"
|
| 78 |
+
else
|
| 79 |
+
echo "[cua_gym_vm_bridge] WARN: gsettings ignore-hosts failed: $(cat /tmp/gsettings_err 2>/dev/null)"
|
| 80 |
+
fi
|
| 81 |
+
|
| 82 |
+
# 4) Shell env — comma-separated form for no_proxy/NO_PROXY (requests/curl).
|
| 83 |
+
local NP="localhost,127.0.0.1,${GW}"
|
| 84 |
+
[ -n "${OWN_IP}" ] && NP="${NP},${OWN_IP}"
|
| 85 |
+
[ -n "${OWN_NET}" ] && NP="${NP},${OWN_NET}"
|
| 86 |
+
[ -n "${GW_NET}" ] && NP="${NP},${GW_NET}.0/24"
|
| 87 |
+
[ -n "${MOCK_HOST}" ] && NP="${NP},${MOCK_HOST}"
|
| 88 |
+
[ -n "${MOCK_NET}" ] && NP="${NP},${MOCK_NET}"
|
| 89 |
+
|
| 90 |
+
for var in no_proxy NO_PROXY; do
|
| 91 |
+
if ! grep -q "export ${var}=${NP}" /home/user/.bashrc 2>/dev/null; then
|
| 92 |
+
echo "export ${var}=${NP}" >> /home/user/.bashrc
|
| 93 |
+
fi
|
| 94 |
+
done
|
| 95 |
+
run_root "grep -q '^no_proxy=' /etc/environment 2>/dev/null \
|
| 96 |
+
&& sed -i 's|^no_proxy=.*|no_proxy=\"${NP}\"|' /etc/environment \
|
| 97 |
+
|| echo 'no_proxy=\"${NP}\"' >> /etc/environment
|
| 98 |
+
grep -q '^NO_PROXY=' /etc/environment 2>/dev/null \
|
| 99 |
+
&& sed -i 's|^NO_PROXY=.*|NO_PROXY=\"${NP}\"|' /etc/environment \
|
| 100 |
+
|| echo 'NO_PROXY=\"${NP}\"' >> /etc/environment" >/dev/null 2>&1
|
| 101 |
+
echo "[cua_gym_vm_bridge] no_proxy=${NP}"
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
fix_vm_network
|
| 105 |
+
|
| 106 |
+
echo "[cua_gym_vm_bridge] direct-IP mode: ${MOCK_HOST} (+${MOCK_NET}) bypassed from woa proxy; no socat forwarding needed"
|
legacy/57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f/initial_setup.py
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Initial Setup: cm_editorial_plan_b99
|
| 3 |
+
Task ID: 57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f
|
| 4 |
+
Domain: mock_websites
|
| 5 |
+
Mocks: asana_mock, google_calendar_mock, google_docs_mock, slack_mock (single shared sid)
|
| 6 |
+
|
| 7 |
+
Persona: You are an office worker acting as a marketing program manager. Your tools for this task are: the Asana project, the team calendar, shared documents, team communications.
|
| 8 |
+
|
| 9 |
+
Environment / context (initial state + ground truth this setup establishes):
|
| 10 |
+
Initial environment (seeded via a single shared session id across all mocks): Asana 'Q1 Product Launch' project with 1 task(s); an empty Google Calendar; Google Docs with documents 'Editorial Calendar'; Slack workspace with channels #general, #marketing, #random. GROUND TRUTH — the agent earns partial credit for each checkpoint: new July feature task in Asana (+0.25); cal_new_event (+0.1); publish event titled (+0.1); publish date July 2 (+0.15); outline doc created (+0.1); outline has Problem/Approach/Results (+0.1); slack_new_msg (+0.1); names the July 2 publish date (+0.1). Scoring is absolute over each mock's current_state; new objects exclude the seeded IDs, so an untouched environment scores 0.0 and fully completing every checkpoint scores 1.0.
|
| 11 |
+
"""
|
| 12 |
+
import json
|
| 13 |
+
import os
|
| 14 |
+
import shlex
|
| 15 |
+
import subprocess
|
| 16 |
+
import time
|
| 17 |
+
import uuid
|
| 18 |
+
|
| 19 |
+
import requests
|
| 20 |
+
|
| 21 |
+
MOCK_URLS = {
|
| 22 |
+
"asana_mock": "http://28.7.186.212:8134",
|
| 23 |
+
"google_calendar_mock": "http://28.7.186.212:8161",
|
| 24 |
+
"google_docs_mock": "http://28.7.186.212:8162",
|
| 25 |
+
"slack_mock": "http://28.7.186.212:8198"
|
| 26 |
+
}
|
| 27 |
+
PRIMARY_URL = 'http://28.7.186.212:8134'
|
| 28 |
+
|
| 29 |
+
sid = str(uuid.uuid4())
|
| 30 |
+
with open('/tmp/task_web_sid', 'w') as f:
|
| 31 |
+
f.write(sid)
|
| 32 |
+
print(f'Generated sid: {sid}')
|
| 33 |
+
|
| 34 |
+
# Full initial state for every mock involved (all required top-level keys present).
|
| 35 |
+
STATES = { 'asana_mock': { 'currentUser': { 'userId': 'user-0',
|
| 36 |
+
'name': 'Alex Johnson',
|
| 37 |
+
'email': 'alex.johnson@company.com',
|
| 38 |
+
'avatar': 'https://picsum.photos/100/100?random=user0',
|
| 39 |
+
'title': 'Product Manager',
|
| 40 |
+
'department': 'Product',
|
| 41 |
+
'location': 'SF',
|
| 42 |
+
'timezone': 'PST',
|
| 43 |
+
'theme': 'light'},
|
| 44 |
+
'users': [ { 'userId': 'user-0',
|
| 45 |
+
'name': 'Alex Johnson',
|
| 46 |
+
'email': 'alex.johnson@company.com'},
|
| 47 |
+
{ 'userId': 'user-1',
|
| 48 |
+
'name': 'Sarah Chen',
|
| 49 |
+
'email': 'sarah.chen@company.com'},
|
| 50 |
+
{ 'userId': 'user-2',
|
| 51 |
+
'name': 'Mike Rodriguez',
|
| 52 |
+
'email': 'mike.r@company.com'}],
|
| 53 |
+
'teams': [ { 'teamId': 'team-1',
|
| 54 |
+
'name': 'Product',
|
| 55 |
+
'description': '',
|
| 56 |
+
'memberIds': ['user-0', 'user-1', 'user-2'],
|
| 57 |
+
'ownerId': 'user-0',
|
| 58 |
+
'privacy': 'public',
|
| 59 |
+
'createdDate': '2026-01-01T00:00:00Z'}],
|
| 60 |
+
'projects': [ { 'projectId': 'project-1',
|
| 61 |
+
'name': 'Q1 Product Launch',
|
| 62 |
+
'teamId': 'team-1',
|
| 63 |
+
'description': '',
|
| 64 |
+
'color': 'blue',
|
| 65 |
+
'icon': 'rocket',
|
| 66 |
+
'ownerId': 'user-0',
|
| 67 |
+
'memberIds': ['user-0', 'user-1', 'user-2'],
|
| 68 |
+
'sections': [ { 'sectionId': 'section-1-1',
|
| 69 |
+
'name': 'To Do',
|
| 70 |
+
'collapsed': False},
|
| 71 |
+
{ 'sectionId': 'section-1-2',
|
| 72 |
+
'name': 'In Progress',
|
| 73 |
+
'collapsed': False}],
|
| 74 |
+
'customFields': [],
|
| 75 |
+
'privacy': 'public',
|
| 76 |
+
'startDate': None,
|
| 77 |
+
'dueDate': None,
|
| 78 |
+
'archived': False,
|
| 79 |
+
'starred': False,
|
| 80 |
+
'createdDate': '2026-01-01T00:00:00Z',
|
| 81 |
+
'modifiedDate': '2026-01-01T00:00:00Z'}],
|
| 82 |
+
'tasks': [ { 'taskId': 't-seed',
|
| 83 |
+
'name': 'Update media kit',
|
| 84 |
+
'projectId': 'project-1',
|
| 85 |
+
'sectionId': 'section-1-1',
|
| 86 |
+
'description': '',
|
| 87 |
+
'assigneeId': None,
|
| 88 |
+
'creatorId': 'user-0',
|
| 89 |
+
'dueDate': None,
|
| 90 |
+
'startDate': None,
|
| 91 |
+
'completed': False,
|
| 92 |
+
'completedDate': None,
|
| 93 |
+
'parentTaskId': None,
|
| 94 |
+
'dependencies': [],
|
| 95 |
+
'tags': [],
|
| 96 |
+
'attachmentIds': [],
|
| 97 |
+
'customFieldValues': {},
|
| 98 |
+
'likeCount': 0,
|
| 99 |
+
'createdDate': '2026-06-01T00:00:00Z',
|
| 100 |
+
'modifiedDate': '2026-06-01T00:00:00Z'}],
|
| 101 |
+
'comments': [],
|
| 102 |
+
'portfolios': [],
|
| 103 |
+
'goals': [],
|
| 104 |
+
'notifications': [],
|
| 105 |
+
'attachments': []},
|
| 106 |
+
'google_calendar_mock': { 'user': { 'id': 'u1',
|
| 107 |
+
'username': 'Demo User',
|
| 108 |
+
'email': 'demo@example.com',
|
| 109 |
+
'avatar': ''},
|
| 110 |
+
'calendars': [ { 'id': 'c1',
|
| 111 |
+
'name': 'Personal',
|
| 112 |
+
'color': '#039BE5',
|
| 113 |
+
'visible': True,
|
| 114 |
+
'userId': 'u1',
|
| 115 |
+
'isDefault': True},
|
| 116 |
+
{ 'id': 'c2',
|
| 117 |
+
'name': 'Work',
|
| 118 |
+
'color': '#33B679',
|
| 119 |
+
'visible': True,
|
| 120 |
+
'userId': 'u1',
|
| 121 |
+
'isDefault': False}],
|
| 122 |
+
'events': [],
|
| 123 |
+
'view': 'week',
|
| 124 |
+
'currentDate': '2026-06-08T00:00:00.000Z',
|
| 125 |
+
'sidebarOpen': True,
|
| 126 |
+
'settings': { 'weekStart': 0,
|
| 127 |
+
'defaultDuration': 60,
|
| 128 |
+
'defaultView': 'week',
|
| 129 |
+
'defaultReminder': {'type': 'popup', 'minutes': 10},
|
| 130 |
+
'timeFormat': '12h',
|
| 131 |
+
'showWeekNumbers': False,
|
| 132 |
+
'showDeclinedEvents': False}},
|
| 133 |
+
'google_docs_mock': { 'currentUser': { 'id': 'user-1',
|
| 134 |
+
'name': 'Demo User',
|
| 135 |
+
'email': 'demo@example.com',
|
| 136 |
+
'avatar': ''},
|
| 137 |
+
'users': [ { 'id': 'user-1',
|
| 138 |
+
'name': 'Demo User',
|
| 139 |
+
'email': 'demo@example.com',
|
| 140 |
+
'avatar': ''},
|
| 141 |
+
{ 'id': 'user-2',
|
| 142 |
+
'name': 'Alice Chen',
|
| 143 |
+
'email': 'alice@example.com',
|
| 144 |
+
'avatar': ''},
|
| 145 |
+
{ 'id': 'user-3',
|
| 146 |
+
'name': 'Bob Smith',
|
| 147 |
+
'email': 'bob@example.com',
|
| 148 |
+
'avatar': ''}],
|
| 149 |
+
'documents': { 'd-cal': { 'id': 'd-cal',
|
| 150 |
+
'title': 'Editorial Calendar',
|
| 151 |
+
'content': '<p>cal</p>',
|
| 152 |
+
'ownerId': 'user-1',
|
| 153 |
+
'starred': False,
|
| 154 |
+
'created': '2026-05-01T10:00:00Z',
|
| 155 |
+
'updated': '2026-06-01T10:00:00Z',
|
| 156 |
+
'sharedWith': [],
|
| 157 |
+
'linkSharing': { 'enabled': False,
|
| 158 |
+
'permission': 'viewer'}}},
|
| 159 |
+
'comments': [],
|
| 160 |
+
'ui': { 'currentDocId': None,
|
| 161 |
+
'sidebarOpen': False,
|
| 162 |
+
'sidebarTab': 'comments',
|
| 163 |
+
'shareDialogOpen': False,
|
| 164 |
+
'findReplaceOpen': False,
|
| 165 |
+
'viewMode': 'editing',
|
| 166 |
+
'zoom': 100,
|
| 167 |
+
'documentListView': 'grid',
|
| 168 |
+
'searchQuery': ''}},
|
| 169 |
+
'slack_mock': { 'currentUser': { 'userId': 'user_1',
|
| 170 |
+
'fullName': 'John Smith',
|
| 171 |
+
'displayName': 'John',
|
| 172 |
+
'email': 'john.smith@company.com',
|
| 173 |
+
'avatar': 'https://picsum.photos/200/200?random=1',
|
| 174 |
+
'title': '',
|
| 175 |
+
'status': 'online',
|
| 176 |
+
'statusMessage': '',
|
| 177 |
+
'statusEmoji': '',
|
| 178 |
+
'timeZone': 'America/New_York'},
|
| 179 |
+
'workspace': { 'workspaceId': 'ws_1',
|
| 180 |
+
'workspaceName': 'Acme Corp',
|
| 181 |
+
'icon': ''},
|
| 182 |
+
'users': [ { 'userId': 'user_1',
|
| 183 |
+
'fullName': 'John Smith',
|
| 184 |
+
'displayName': 'John',
|
| 185 |
+
'email': 'john.smith@company.com',
|
| 186 |
+
'avatar': 'https://picsum.photos/200/200?random=1',
|
| 187 |
+
'title': '',
|
| 188 |
+
'status': 'online',
|
| 189 |
+
'statusMessage': '',
|
| 190 |
+
'statusEmoji': '',
|
| 191 |
+
'timeZone': 'America/New_York'},
|
| 192 |
+
{ 'userId': 'user_2',
|
| 193 |
+
'fullName': 'Sarah Johnson',
|
| 194 |
+
'displayName': 'Sarah',
|
| 195 |
+
'email': 'sarah.johnson@company.com',
|
| 196 |
+
'avatar': 'https://picsum.photos/200/200?random=2',
|
| 197 |
+
'title': '',
|
| 198 |
+
'status': 'online',
|
| 199 |
+
'statusMessage': '',
|
| 200 |
+
'statusEmoji': '',
|
| 201 |
+
'timeZone': 'America/New_York'},
|
| 202 |
+
{ 'userId': 'user_3',
|
| 203 |
+
'fullName': 'Mike Chen',
|
| 204 |
+
'displayName': 'Mike',
|
| 205 |
+
'email': 'mike.chen@company.com',
|
| 206 |
+
'avatar': 'https://picsum.photos/200/200?random=3',
|
| 207 |
+
'title': '',
|
| 208 |
+
'status': 'online',
|
| 209 |
+
'statusMessage': '',
|
| 210 |
+
'statusEmoji': '',
|
| 211 |
+
'timeZone': 'America/New_York'},
|
| 212 |
+
{ 'userId': 'user_4',
|
| 213 |
+
'fullName': 'Lisa Park',
|
| 214 |
+
'displayName': 'Lisa',
|
| 215 |
+
'email': 'lisa.park@company.com',
|
| 216 |
+
'avatar': 'https://picsum.photos/200/200?random=4',
|
| 217 |
+
'title': '',
|
| 218 |
+
'status': 'online',
|
| 219 |
+
'statusMessage': '',
|
| 220 |
+
'statusEmoji': '',
|
| 221 |
+
'timeZone': 'America/New_York'}],
|
| 222 |
+
'channels': [ { 'channelId': 'general',
|
| 223 |
+
'name': 'general',
|
| 224 |
+
'description': 'general channel',
|
| 225 |
+
'topic': '',
|
| 226 |
+
'isPrivate': False,
|
| 227 |
+
'isStarred': False,
|
| 228 |
+
'members': ['user_1', 'user_2', 'user_3', 'user_4'],
|
| 229 |
+
'createdBy': 'user_1',
|
| 230 |
+
'createdAt': '2026-01-01T10:00:00Z',
|
| 231 |
+
'pinnedMessages': [],
|
| 232 |
+
'unreadCount': 0},
|
| 233 |
+
{ 'channelId': 'marketing',
|
| 234 |
+
'name': 'marketing',
|
| 235 |
+
'description': 'marketing channel',
|
| 236 |
+
'topic': '',
|
| 237 |
+
'isPrivate': False,
|
| 238 |
+
'isStarred': False,
|
| 239 |
+
'members': ['user_1', 'user_2', 'user_3', 'user_4'],
|
| 240 |
+
'createdBy': 'user_1',
|
| 241 |
+
'createdAt': '2026-01-01T10:00:00Z',
|
| 242 |
+
'pinnedMessages': [],
|
| 243 |
+
'unreadCount': 0},
|
| 244 |
+
{ 'channelId': 'random',
|
| 245 |
+
'name': 'random',
|
| 246 |
+
'description': 'random channel',
|
| 247 |
+
'topic': '',
|
| 248 |
+
'isPrivate': False,
|
| 249 |
+
'isStarred': False,
|
| 250 |
+
'members': ['user_1', 'user_2', 'user_3', 'user_4'],
|
| 251 |
+
'createdBy': 'user_1',
|
| 252 |
+
'createdAt': '2026-01-01T10:00:00Z',
|
| 253 |
+
'pinnedMessages': [],
|
| 254 |
+
'unreadCount': 0}],
|
| 255 |
+
'messages': { 'general': [],
|
| 256 |
+
'marketing': [ { 'messageId': 'm1',
|
| 257 |
+
'senderId': 'user_2',
|
| 258 |
+
'content': "what's the July feature "
|
| 259 |
+
'plan?',
|
| 260 |
+
'timestamp': '2026-06-08T08:00:00Z',
|
| 261 |
+
'threadId': None,
|
| 262 |
+
'reactions': [],
|
| 263 |
+
'attachments': [],
|
| 264 |
+
'isEdited': False}],
|
| 265 |
+
'random': []},
|
| 266 |
+
'threads': {},
|
| 267 |
+
'dms': [],
|
| 268 |
+
'bookmarkedMessages': [],
|
| 269 |
+
'callHistory': [],
|
| 270 |
+
'settings': { 'theme': 'light',
|
| 271 |
+
'notifications': 'all',
|
| 272 |
+
'displayDensity': 'comfortable',
|
| 273 |
+
'showAvatars': True,
|
| 274 |
+
'use24Hour': False},
|
| 275 |
+
'invitations': [],
|
| 276 |
+
'notifications': []}}
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
def launch_gui(command, delay_sec=1.0):
|
| 280 |
+
env = os.environ.copy()
|
| 281 |
+
env['DISPLAY'] = ':0'
|
| 282 |
+
subprocess.Popen(shlex.split(command), stdin=subprocess.DEVNULL,
|
| 283 |
+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
| 284 |
+
env=env, start_new_session=True)
|
| 285 |
+
time.sleep(delay_sec)
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
for name, url in MOCK_URLS.items():
|
| 289 |
+
resp = requests.post(f'{url}/post?sid={sid}',
|
| 290 |
+
json={'action': 'set', 'state': STATES[name]}, timeout=30)
|
| 291 |
+
assert resp.status_code == 200, f'{name} injection failed: {resp.text}'
|
| 292 |
+
go = requests.get(f'{url}/go?sid={sid}', timeout=10).json()
|
| 293 |
+
assert go.get('initial_state') is not None, f'{name} initial_state is None'
|
| 294 |
+
print(f'State injected: {name} sid={sid}')
|
| 295 |
+
|
| 296 |
+
# Open the PRIMARY app as the main window first, then open every other
|
| 297 |
+
# involved mock as an additional browser tab so the agent can see/reach all
|
| 298 |
+
# relevant apps (e.g. read the email in the Gmail tab AND post in Slack).
|
| 299 |
+
# Without this, secondary-app data is injected but has no on-screen entry
|
| 300 |
+
# point, and the agent wastes its budget hunting for a non-existent client.
|
| 301 |
+
launch_gui(f'google-chrome "{PRIMARY_URL}/?sid={sid}"', delay_sec=2.0)
|
| 302 |
+
print(f'GUI_READY: launched browser at {PRIMARY_URL}/?sid={sid}')
|
| 303 |
+
for _name, _url in MOCK_URLS.items():
|
| 304 |
+
if _url == PRIMARY_URL:
|
| 305 |
+
continue
|
| 306 |
+
launch_gui(f'google-chrome --new-tab "{_url}/?sid={sid}"', delay_sec=1.0)
|
| 307 |
+
print(f'Opened tab: {_name} at {_url}/?sid={sid}')
|
legacy/57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f/reward.py
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Reward Script: cm_editorial_plan_b99
|
| 3 |
+
Task ID: 57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f
|
| 4 |
+
Domain: mock_websites
|
| 5 |
+
Mocks: asana_mock, google_calendar_mock, google_docs_mock, slack_mock
|
| 6 |
+
Scoring (all programmatic; evaluated against each mock's current_state; total = 1.0):
|
| 7 |
+
- [0.25] new July feature task in Asana
|
| 8 |
+
- [0.1] cal_new_event
|
| 9 |
+
- [0.1] publish event titled
|
| 10 |
+
- [0.15] publish date July 2
|
| 11 |
+
- [0.1] outline doc created
|
| 12 |
+
- [0.1] outline has Problem/Approach/Results
|
| 13 |
+
- [0.1] slack_new_msg
|
| 14 |
+
- [0.1] names the July 2 publish date
|
| 15 |
+
"""
|
| 16 |
+
import re
|
| 17 |
+
import sys
|
| 18 |
+
|
| 19 |
+
import requests
|
| 20 |
+
|
| 21 |
+
MOCK_URLS = {
|
| 22 |
+
"asana_mock": "http://28.7.186.212:8134",
|
| 23 |
+
"google_calendar_mock": "http://28.7.186.212:8161",
|
| 24 |
+
"google_docs_mock": "http://28.7.186.212:8162",
|
| 25 |
+
"slack_mock": "http://28.7.186.212:8198"
|
| 26 |
+
}
|
| 27 |
+
SEED = {
|
| 28 |
+
"slack_mock:general": [],
|
| 29 |
+
"slack_mock:marketing": [
|
| 30 |
+
"m1"
|
| 31 |
+
],
|
| 32 |
+
"slack_mock:random": []
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
try:
|
| 36 |
+
with open('/tmp/task_web_sid') as f:
|
| 37 |
+
sid = f.read().strip()
|
| 38 |
+
if not sid:
|
| 39 |
+
raise ValueError('sid is empty')
|
| 40 |
+
except Exception as e:
|
| 41 |
+
print(f'CRITICAL: cannot read sid: {e}')
|
| 42 |
+
print('REWARD: 0.0')
|
| 43 |
+
sys.exit(0)
|
| 44 |
+
|
| 45 |
+
STATES = {}
|
| 46 |
+
for _name, _url in MOCK_URLS.items():
|
| 47 |
+
try:
|
| 48 |
+
_r = requests.get(f'{_url}/go?sid={sid}', timeout=15)
|
| 49 |
+
_r.raise_for_status()
|
| 50 |
+
STATES[_name] = _r.json()
|
| 51 |
+
except Exception as e:
|
| 52 |
+
print(f'CRITICAL: cannot fetch {_name}: {e}')
|
| 53 |
+
print('REWARD: 0.0')
|
| 54 |
+
sys.exit(0)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def cur(mock):
|
| 58 |
+
return (STATES.get(mock) or {}).get('current_state') or {}
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def _lc(s):
|
| 62 |
+
return (s or '').lower()
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
total = 0.0
|
| 66 |
+
|
| 67 |
+
# c0: a new asana task about (new July feature task in Asana)
|
| 68 |
+
c0_init = {t.get('taskId') for t in ((STATES['asana_mock'].get('initial_state') or {}).get('tasks') or [])}
|
| 69 |
+
c0_new = [t for t in (cur('asana_mock').get('tasks') or []) if t.get('taskId') not in c0_init and any(x in _lc(t.get('name','')) for x in ['july feature', 'ai in support'])]
|
| 70 |
+
if c0_new:
|
| 71 |
+
print('PASS: new July feature task in Asana (0.25)')
|
| 72 |
+
total += 0.25
|
| 73 |
+
else:
|
| 74 |
+
print('FAIL: new July feature task in Asana')
|
| 75 |
+
|
| 76 |
+
# c1: a new calendar event was created
|
| 77 |
+
c1_init_ids = {e.get('id') for e in ((STATES['google_calendar_mock'].get('initial_state') or {}).get('events') or [])}
|
| 78 |
+
c1_new = [e for e in (cur('google_calendar_mock').get('events') or []) if e.get('id') not in c1_init_ids]
|
| 79 |
+
globals()['cal_new_events'] = c1_new
|
| 80 |
+
if c1_new:
|
| 81 |
+
print('PASS: new calendar event (0.1)')
|
| 82 |
+
total += 0.1
|
| 83 |
+
else:
|
| 84 |
+
print('FAIL: no new calendar event')
|
| 85 |
+
|
| 86 |
+
# c2: new event title (publish event titled)
|
| 87 |
+
c2_new = globals().get('cal_new_events', [])
|
| 88 |
+
if any(any(t in _lc(e.get('title','')) for t in ['publish: ai in support', 'ai in support', 'publish']) for e in c2_new):
|
| 89 |
+
print('PASS: publish event titled (0.1)')
|
| 90 |
+
total += 0.1
|
| 91 |
+
else:
|
| 92 |
+
print('FAIL: publish event titled')
|
| 93 |
+
|
| 94 |
+
# c3: new event date contains '2026-07-02'
|
| 95 |
+
c3_new = globals().get('cal_new_events', [])
|
| 96 |
+
if any('2026-07-02' in (e.get('start','') or '') for e in c3_new):
|
| 97 |
+
print('PASS: publish date July 2 (0.15)')
|
| 98 |
+
total += 0.15
|
| 99 |
+
else:
|
| 100 |
+
print('FAIL: publish date July 2')
|
| 101 |
+
|
| 102 |
+
# c4: a new google doc titled about (outline doc created)
|
| 103 |
+
c4_init = set((STATES['google_docs_mock'].get('initial_state') or {}).get('documents', {}).keys())
|
| 104 |
+
c4_docs = cur('google_docs_mock').get('documents') or {}
|
| 105 |
+
c4_new = [d for did, d in c4_docs.items() if did not in c4_init and any(t in _lc(d.get('title','')) for t in ['ai in support - outline', 'ai in support'])]
|
| 106 |
+
if c4_new:
|
| 107 |
+
print('PASS: outline doc created (0.1)')
|
| 108 |
+
total += 0.1
|
| 109 |
+
else:
|
| 110 |
+
print('FAIL: outline doc created')
|
| 111 |
+
|
| 112 |
+
# c5: new google doc body (outline has Problem/Approach/Results)
|
| 113 |
+
c5_init = set((STATES['google_docs_mock'].get('initial_state') or {}).get('documents', {}).keys())
|
| 114 |
+
c5_docs = cur('google_docs_mock').get('documents') or {}
|
| 115 |
+
c5_new = [d for did, d in c5_docs.items() if did not in c5_init and any(t in _lc(d.get('title','')) for t in ['ai in support'])]
|
| 116 |
+
c5_txt = _lc(' '.join(d.get('content','') for d in c5_new))
|
| 117 |
+
if c5_new and all(t in c5_txt for t in ['problem', 'approach', 'results']):
|
| 118 |
+
print('PASS: outline has Problem/Approach/Results (0.1)')
|
| 119 |
+
total += 0.1
|
| 120 |
+
else:
|
| 121 |
+
print('FAIL: outline has Problem/Approach/Results')
|
| 122 |
+
|
| 123 |
+
# c6: new message by user_1 in #marketing
|
| 124 |
+
c6_msgs = (cur('slack_mock').get('messages') or {}).get('marketing', []) or []
|
| 125 |
+
c6_seed = set(SEED.get('slack_mock:marketing', []))
|
| 126 |
+
c6_new = [m for m in c6_msgs if m.get('messageId') not in c6_seed and m.get('senderId') == 'user_1']
|
| 127 |
+
c6_blob = _lc(' '.join((m.get('content') or '') for m in c6_new))
|
| 128 |
+
if c6_new:
|
| 129 |
+
print('PASS: new message by user_1 in #marketing (0.1)')
|
| 130 |
+
total += 0.1
|
| 131 |
+
else:
|
| 132 |
+
print('FAIL: no new user_1 message in #marketing')
|
| 133 |
+
|
| 134 |
+
# c7: slack #marketing contains (names the July 2 publish date)
|
| 135 |
+
c7_msgs = (cur('slack_mock').get('messages') or {}).get('marketing', []) or []
|
| 136 |
+
c7_seed = set(SEED.get('slack_mock:marketing', []))
|
| 137 |
+
c7_blob = _lc(' '.join((m.get('content') or '') for m in c7_msgs if m.get('messageId') not in c7_seed and m.get('senderId') == 'user_1'))
|
| 138 |
+
if any(t in c7_blob for t in ['july 2', 'july 2nd', '2026-07-02', 'july feature']):
|
| 139 |
+
print('PASS: names the July 2 publish date (0.1)')
|
| 140 |
+
total += 0.1
|
| 141 |
+
else:
|
| 142 |
+
print('FAIL: names the July 2 publish date')
|
| 143 |
+
|
| 144 |
+
final = round(min(total, 1.0), 4)
|
| 145 |
+
print(f'\nScore: {total}/1.0')
|
| 146 |
+
print(f'REWARD: {final}')
|
legacy/57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f/reward_label.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"reward_file": "/apdcephfs_sh2/share_300000800/user/jackwkwang/long-horizon-tasks/mini_osworld_xiangwu/cache/57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f/reward.py",
|
| 3 |
+
"api_url": "http://28.7.184.184:8000/v1/chat/completions",
|
| 4 |
+
"model": "Kimi-K2.6",
|
| 5 |
+
"max_code_chars": 100000,
|
| 6 |
+
"created_at": "2026-07-14 10:19:40",
|
| 7 |
+
"label": {
|
| 8 |
+
"task_id": "57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f",
|
| 9 |
+
"domain": "mock_websites",
|
| 10 |
+
"summary": "验证在 Asana、Google Calendar、Google Docs 和 Slack 中是否完成了关于 AI in Support 的编辑计划任务,包括创建任务、日历事件、文档大纲和营销频道消息",
|
| 11 |
+
"is_placeholder": false,
|
| 12 |
+
"data_sources": [
|
| 13 |
+
"/tmp/task_web_sid",
|
| 14 |
+
"asana_mock",
|
| 15 |
+
"google_calendar_mock",
|
| 16 |
+
"google_docs_mock",
|
| 17 |
+
"slack_mock"
|
| 18 |
+
],
|
| 19 |
+
"scoring_components": [
|
| 20 |
+
{
|
| 21 |
+
"name": "Component 1",
|
| 22 |
+
"weight": 0.25,
|
| 23 |
+
"description": "在 Asana 中创建关于 July feature 的新任务",
|
| 24 |
+
"check_logic": "对比 asana_mock 的 initial_state 与 current_state 中的 tasks,找出 taskId 不在初始集合中的新任务,检查其 name 字段(转小写后)是否包含 'july feature' 或 'ai in support'",
|
| 25 |
+
"pass_condition": "存在新任务且任务名称包含 'july feature' 或 'ai in support'"
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"name": "Component 2",
|
| 29 |
+
"weight": 0.1,
|
| 30 |
+
"description": "在 Google Calendar 中创建新事件",
|
| 31 |
+
"check_logic": "对比 google_calendar_mock 的 initial_state 与 current_state 中的 events,找出 id 不在初始集合中的新事件",
|
| 32 |
+
"pass_condition": "存在至少一个新创建的事件"
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"name": "Component 3",
|
| 36 |
+
"weight": 0.1,
|
| 37 |
+
"description": "新日历事件的标题包含发布相关字样",
|
| 38 |
+
"check_logic": "在 Component 2 筛选出的新事件中,检查 title 字段(转小写后)是否包含 'publish: ai in support'、'ai in support' 或 'publish'",
|
| 39 |
+
"pass_condition": "新事件标题包含 'publish: ai in support'、'ai in support' 或 'publish'"
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"name": "Component 4",
|
| 43 |
+
"weight": 0.15,
|
| 44 |
+
"description": "新日历事件的日期为 2026-07-02",
|
| 45 |
+
"check_logic": "在 Component 2 筛选出的新事件中,检查 start 字段是否包含字符串 '2026-07-02'",
|
| 46 |
+
"pass_condition": "新事件的开始日期包含 '2026-07-02'"
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"name": "Component 5",
|
| 50 |
+
"weight": 0.1,
|
| 51 |
+
"description": "在 Google Docs 中创建 AI in Support 大纲文档",
|
| 52 |
+
"check_logic": "对比 google_docs_mock 的 initial_state 与 current_state 中的 documents,找出 document id 不在初始集合中的新文档,检查 title 字段(转小写后)是否包含 'ai in support - outline' 或 'ai in support'",
|
| 53 |
+
"pass_condition": "存在新文档且标题包含 'ai in support - outline' 或 'ai in support'"
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"name": "Component 6",
|
| 57 |
+
"weight": 0.1,
|
| 58 |
+
"description": "新文档内容包含 Problem、Approach、Results 三部分",
|
| 59 |
+
"check_logic": "在标题包含 'ai in support' 的新文档中,提取 content 字段拼接并转小写,检查是否同时包含 'problem'、'approach'、'results'",
|
| 60 |
+
"pass_condition": "存在标题包含 'ai in support' 的新文档,且其内容同时包含 'problem'、'approach'、'results'"
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"name": "Component 7",
|
| 64 |
+
"weight": 0.1,
|
| 65 |
+
"description": "在 Slack #marketing 频道中 user_1 发送了新消息",
|
| 66 |
+
"check_logic": "检查 slack_mock current_state 中 messages.marketing 列表,筛选出 messageId 不在 SEED['slack_mock:marketing'] 中且 senderId 为 'user_1' 的消息",
|
| 67 |
+
"pass_condition": "存在至少一条 user_1 在 #marketing 频道发送的新消息"
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"name": "Component 8",
|
| 71 |
+
"weight": 0.1,
|
| 72 |
+
"description": "Slack 消息中提及 July 2 发布日期",
|
| 73 |
+
"check_logic": "提取 #marketing 频道中 user_1 的新消息内容,拼接转小写后,检查是否包含 'july 2'、'july 2nd'、'2026-07-02' 或 'july feature'",
|
| 74 |
+
"pass_condition": "user_1 在 #marketing 的新消息内容包含 'july 2'、'july 2nd'、'2026-07-02' 或 'july feature'"
|
| 75 |
+
}
|
| 76 |
+
],
|
| 77 |
+
"total_max_score": 1.0,
|
| 78 |
+
"score_aggregation": "各组件分数相加,最后用 min(total, 1.0) 钳制到上限 1.0,并四舍五入到 4 位小数",
|
| 79 |
+
"failure_modes": [
|
| 80 |
+
"读取 /tmp/task_web_sid 失败或为空时,打印 CRITICAL 并返回 0.0 后退出",
|
| 81 |
+
"请求任意 mock 服务(asana_mock、google_calendar_mock、google_docs_mock、slack_mock)状态失败时,打印 CRITICAL 并返回 0.0 后退出",
|
| 82 |
+
"各组件检查不通过时仅不加分,不会导致提前退出"
|
| 83 |
+
],
|
| 84 |
+
"scoring_logic_explanation": "脚本首先读取 /tmp/task_web_sid 获取会话 ID,然后依次向 asana_mock、google_calendar_mock、google_docs_mock 和 slack_mock 发送 HTTP GET 请求获取���前状态与初始状态。接着按顺序执行 8 项独立检查:1)Asana 中是否有名称包含 'july feature' 或 'ai in support' 的新任务;2)Google Calendar 中是否有新事件;3)新事件标题是否包含发布相关字样;4)新事件日期是否为 2026-07-02;5)Google Docs 中是否创建了 AI in Support 大纲文档;6)新文档内容是否同时包含 Problem、Approach、Results;7)Slack #marketing 中 user_1 是否发送了新消息;8)该消息是否提及 July 2 发布日期。每项通过即累加对应分值,最终总分通过 min(total, 1.0) 限制在 1.0 以内,四舍五入后输出 REWARD。",
|
| 85 |
+
"confidence": 1.0
|
| 86 |
+
},
|
| 87 |
+
"raw_response": "用户要求我分析一个 reward.py 评分脚本的评分逻辑,并输出一个严格的 JSON 对象。\n\n让我仔细阅读代码:\n\n1. **Task ID**: 从 docstring 看,Task ID 是 `57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f`,但 docstring 开头也写了 `Reward Script: cm_editorial_plan_b99`。根据要求\"从文件 docstring 中提取的任务 ID\",这里明确写了 Task ID: 57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f,所以 task_id 应该是这个 UUID。\n\n2. **Domain**: docstring 中写了 `Domain: mock_websites`\n\n3. **Summary**: 一句话概括。这个脚本验证在多个 mock 服务(Asana、Google Calendar、Google Docs、Slack)中是否完成了关于\"AI in Support\"的编辑计划任务,包括创建任务、日历事件、文档大纲和 Slack 消息。\n\n4. **is_placeholder**: false,因为脚本有详细的检查逻辑。\n\n5. **data_sources**: 脚本从 `/tmp/task_web_sid` 读取 sid,然后从 `asana_mock`, `google_calendar_mock`, `google_docs_mock`, `slack_mock` 获取状态。\n\n6. **scoring_components**: 有 8 个组件,分值在 docstring 中明确给出:\n - c0: 0.25 - new July feature task in Asana\n - c1: 0.1 - cal_new_event\n - c2: 0.1 - publish event titled\n - c3: 0.15 - publish date July 2\n - c4: 0.1 - outline doc created\n - c5: 0.1 - outline has Problem/Approach/Results\n - c6: 0.1 - slack_new_msg\n - c7: 0.1 - names the July 2 publish date\n\n让我详细分析每个组件的检查逻辑:\n\n**Component 1 (c0)**: \n- 检查 Asana 中是否有新任务(taskId 不在 initial_state 中)\n- 任务名称包含 'july feature' 或 'ai in support'\n- 通过则 +0.25\n\n**Component 2 (c1)**:\n- 检查 Google Calendar 中是否有新事件(id 不在 initial_state 中)\n- 通过则 +0.1\n\n**Component 3 (c2)**:\n- 检查新事件的标题(在 c1_new 中)是否包含 'publish: ai in support'、'ai in support' 或 'publish'\n- 通过则 +0.1\n\n**Component 4 (c3)**:\n- 检查新事件的开始日期是否包含 '2026-07-02'\n- 通过则 +0.15\n\n**Component 5 (c4)**:\n- 检查 Google Docs 中是否有新文档(document id 不在 initial_state 中)\n- 标题包含 'ai in support - outline' 或 'ai in support'\n- 通过则 +0.1\n\n**Component 6 (c5)**:\n- 检查 Google Docs 新文档(标题包含 'ai in support')的内容\n- 内容(转小写后)必须同时包含 'problem'、'approach'、'results'\n- 通过则 +0.1\n\n**Component 7 (c6)**:\n- 检查 Slack #marketing 频道中是否有 user_1 发送的新消息(messageId 不在 SEED 中,senderId == 'user_1')\n- 通过则 +0.1\n\n**Component 8 (c7)**:\n- 检查 Slack #marketing 中 user_1 的新消息内容是否包含 'july 2'、'july 2nd'、'2026-07-02' 或 'july feature'\n- 通过则 +0.1\n\n7. **total_max_score**: 1.0\n\n8. **score_aggregation**: 各组件分数相加,最后用 `min(total, 1.0)` 钳制到上限 1.0,再四舍五入到 4 位小数。\n\n9. **failure_modes**:\n - 读取 `/tmp/task_web_sid` 失败或为空:打印 CRITICAL,REWARD: 0.0,sys.exit(0)\n - 获取任何 mock 服务状态失败:打印 CRITICAL,REWARD: 0.0,sys.exit(0)\n - 各组件检查失败只是不加分,不会提前退出\n\n10. **scoring_logic_explanation**: 详细中文解释,按执行顺序:\n - 从 /tmp/task_web_sid 读取会话 ID\n - 向四个 mock 服务获取当前状态(current_state)和初始状态(initial_state)\n - 逐项检查 8 个条件,每个条件独立评分,通过则累加对应分值\n - 总分用 min(total, 1.0) 限制在 1.0 以内,四舍五入后输出\n\n11. **confidence**: 1.0,因为代码逻辑非常清晰。\n\n让我再仔细检查一下 task_id。docstring 中明确写了 \"Task ID: 57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f\",虽然文件名路径中也有这个 UUID,但 docstring 是明确标注的。\n\n检查各组件的 pass_condition:\n- c0: Asana 中有新任务,且任务名称(小写)包含 'july feature' 或 'ai in support'\n- c1: Google Calendar 中有新创建的事件(id 不在 initial_state 中)\n- c2: 新事件的标题(小写)包含 'publish: ai in support' 或 'ai in support' 或 'publish'\n- c3: 新事件的开始日期字符串包含 '2026-07-02'\n- c4: Google Docs 中有新文档,且标题(小写)包含 'ai in support - outline' 或 'ai in support'\n- c5: 新文档标题包含 'ai in support'��且文档内容(小写)同时包含 'problem'、'approach'、'results'\n- c6: Slack #marketing 频道中有 senderId 为 'user_1' 且 messageId 不在 SEED 中的新消息\n- c7: Slack #marketing 中 user_1 的新消息内容(小写)包含 'july 2'、'july 2nd'、'2026-07-02' 或 'july feature'\n\n注意 c5 和 c4 的区别:c4 检查标题包含 'ai in support - outline' 或 'ai in support',c5 检查标题包含 'ai in support'(更宽),然后检查内容。\n\n注意 c7 和 c6 的区别:c6 只看是否有新消息,c7 看内容是否包含日期。\n\nJSON 格式要求:\n- 不要输出 Markdown 代码块标记\n- 不要输出额外解释\n- 不要输出思考过程\n- 不要输出 <thinking> 标签\n- 第一个字符必须是 {,最后一个字符必须是 }\n- 所有字符串 value 使用中文;task_id、domain、字段名、代码标识符保留原样\n\n让我构建 JSON:\n\n```json\n{\n \"task_id\": \"57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f\",\n \"domain\": \"mock_websites\",\n \"summary\": \"验证在 Asana、Google Calendar、Google Docs 和 Slack 中是否完成了关于 AI in Support 的编辑计划任务,包括创建任务、日历事件、文档大纲和营销频道消息\",\n \"is_placeholder\": false,\n \"data_sources\": [\"/tmp/task_web_sid\", \"asana_mock\", \"google_calendar_mock\", \"google_docs_mock\", \"slack_mock\"],\n \"scoring_components\": [\n {\n \"name\": \"Component 1\",\n \"weight\": 0.25,\n \"description\": \"在 Asana 中创建关于 July feature 的新任务\",\n \"check_logic\": \"对比 asana_mock 的 initial_state 与 current_state 中的 tasks,找出 taskId 不在初始集合中的新任务,检查其 name 字段(转小写后)是否包含 'july feature' 或 'ai in support'\",\n \"pass_condition\": \"存在新任务且任务名称包含 'july feature' 或 'ai in support'\"\n },\n {\n \"name\": \"Component 2\",\n \"weight\": 0.1,\n \"description\": \"在 Google Calendar 中创建新事件\",\n \"check_logic\": \"对比 google_calendar_mock 的 initial_state 与 current_state 中的 events,找出 id 不在初始集合中的新事件\",\n \"pass_condition\": \"存在至少一个新创建的事件\"\n },\n {\n \"name\": \"Component 3\",\n \"weight\": 0.1,\n \"description\": \"新日历事件的标题包含发布相关字样\",\n \"check_logic\": \"在 Component 2 筛选出的新事件中,检查 title 字段(转小写后)是否包含 'publish: ai in support'、'ai in support' 或 'publish'\",\n \"pass_condition\": \"新事件标题包含 'publish: ai in support'、'ai in support' 或 'publish'\"\n },\n {\n \"name\": \"Component 4\",\n \"weight\": 0.15,\n \"description\": \"新日历事件的日期为 2026-07-02\",\n \"check_logic\": \"在 Component 2 筛选出的新事件中,检查 start 字段是否包含字符串 '2026-07-02'\",\n \"pass_condition\": \"新事件的开始日期包含 '2026-07-02'\"\n },\n {\n \"name\": \"Component 5\",\n \"weight\": 0.1,\n \"description\": \"在 Google Docs 中创建 AI in Support 大纲文档\",\n \"check_logic\": \"对比 google_docs_mock 的 initial_state 与 current_state 中的 documents,找出 document id 不在初始集合中的新文档,检查 title 字段(转小写后)是否包含 'ai in support - outline' 或 'ai in support'\",\n \"pass_condition\": \"存在新文档且标题包含 'ai in support - outline' 或 'ai in support'\"\n },\n {\n \"name\": \"Component 6\",\n \"weight\": 0.1,\n \"description\": \"新文档内容包含 Problem、Approach、Results 三部分\",\n \"check_logic\": \"在标题包含 'ai in support' 的新文档中,提取 content 字段拼接并转小写,检查是否同时包含 'problem'、'approach'、'results'\",\n \"pass_condition\": \"存在标题包含 'ai in support' 的新文档,且其内容同时包含 'problem'、'approach'、'results'\"\n },\n {\n \"name\": \"Component 7\",\n \"weight\": 0.1,\n \"description\": \"在 Slack #marketing 频道中 user_1 发送了新消息\",\n \"check_logic\": \"检查 slack_mock current_state 中 messages.marketing 列表,筛选出 messageId 不在 SEED['slack_mock:marketing'] 中且 senderId 为 'user_1' 的消息\",\n \"pass_condition\": \"存在至少一条 user_1 在 #marketing 频道发送的新消息\"\n },\n {\n \"name\": \"Component 8\",\n \"weight\": 0.1,\n \"description\": \"Slack 消息中提及 July 2 发布日期\",\n \"check_logic\": \"提取 #marketing 频道中 user_1 的新消息内容,拼接转小写后,检查是否包含 'july 2'、'july 2nd'、'2026-07-02' 或 'july feature'\",\n \"pass_condition\": \"user_1 在 #marketing 的新消息内容包含 'july 2'、'july 2nd'、'2026-07-02' 或 'july feature'\"\n }\n ],\n \"total_max_score\": 1.0,\n \"score_aggregation\": \"各组件分数相加,最后用 min(total, 1.0) 钳制到上限 1.0,并四舍五入到 4 位小数\",\n \"failure_modes\": [\n \"读取 /tmp/task_web_sid 失败或为空时,打印 CRITICAL 并返回 0.0 后退出\",\n \"请求任意 mock 服务(asana_mock、google_calendar_mock、google_docs_mock、slack_mock)状态失败时,打印 CRITICAL 并返回 0.0 后退出\",\n \"各组件检查不通过时仅不加分,不会导致提前退出\"\n ],\n \"scoring_logic_explanation\": \"脚本首先读取 /tmp/task_web_sid 获取会话 ID,然后依次向 asana_mock、google_calendar_mock、google_docs_mock 和 slack_mock 发送 HTTP GET 请求获取当前状态与初始状态。接着按顺序执行 8 项独立检查:1)Asana 中是否有名称包含 'july feature' 或 'ai in support' 的新任务;2)Google Calendar 中是否有新事件;3)新事件标题是否包含发布相关字样;4)新事件日期是否为 2026-07-02;5)Google Docs 中是否创建了 AI in Support 大纲文档;6)新文档内容是否同时包含 Problem、Approach、Results;7)Slack #marketing 中 user_1 是否发送了新消息;8)该消息是否提及 July 2 发布日期。每项通过即累加对应分值,最终总分通过 min(total, 1.0) 限制在 1.0 以内,四舍五入后输出 REWARD。\",\n \"confidence\": 1.0\n}\n```\n\n检查是否符合所有要求:\n- 只输出 JSON 对象:是\n- 没有 Markdown 代码块:是\n- 没有额外解释:是\n- 没有 thinking 标签:是\n- 第一个字符是 {,最后一个是 }:是\n- task_id、domain 正确:是\n- is_placeholder: false:是\n- data_sources 完整:是\n- scoring_components 有 8 个,weight 正确:是\n- total_max_score: 1.0:是\n- score_aggregation 正确:是\n- failure_modes 包含提前退出路径:是\n- scoring_logic_explanation 详细且按执行顺序:是\n- confidence: 1.0:是\n\n看起来都正确。 </think> {\n \"task_id\": \"57f76e1c-93b4-5bc1-aa92-9ff6bab42d2f\",\n \"domain\": \"mock_websites\",\n \"summary\": \"验证在 Asana、Google Calendar、Google Docs 和 Slack 中是否完成了关于 AI in Support 的编辑计划任务,包括创建任务、日历事件、文档大纲和营销频道消息\",\n \"is_placeholder\": false,\n \"data_sources\": [\"/tmp/task_web_sid\", \"asana_mock\", \"google_calendar_mock\", \"google_docs_mock\", \"slack_mock\"],\n \"scoring_components\": [\n {\n \"name\": \"Component 1\",\n \"weight\": 0.25,\n \"description\": \"在 Asana 中创建关于 July feature 的新任务\",\n \"check_logic\": \"对比 asana_mock 的 initial_state 与 current_state 中的 tasks,找出 taskId 不在初始集合中的新任务,检查其 name 字段(转小写后)是否包含 'july feature' 或 'ai in support'\",\n \"pass_condition\": \"存在新任务且任务名称包含 'july feature' 或 'ai in support'\"\n },\n {\n \"name\": \"Component 2\",\n \"weight\": 0.1,\n \"description\": \"在 Google Calendar 中创建新事件\",\n \"check_logic\": \"对比 google_calendar_mock 的 initial_state 与 current_state 中的 events,找出 id 不在初始集合中的新事件\",\n \"pass_condition\": \"存在至少一个新创建的事件\"\n },\n {\n \"name\": \"Component 3\",\n \"weight\": 0.1,\n \"description\": \"新日历事件的标题包含发布相关字样\",\n \"check_logic\": \"在 Component 2 筛选出的新事件中,检查 title 字段(转小写后)是否包含 'publish: ai in support'、'ai in support' 或 'publish'\",\n \"pass_condition\": \"新事件标题包含 'publish: ai in support'、'ai in support' 或 'publish'\"\n },\n {\n \"name\": \"Component 4\",\n \"weight\": 0.15,\n \"description\": \"新日历事件的日期为 2026-07-02\",\n \"check_logic\": \"在 Component 2 筛选出的新事件中,检查 start 字段是否包含字符串 '2026-07-02'\",\n \"pass_condition\": \"新事件的开始日期包含 '2026-07-02'\"\n },\n {\n \"name\": \"Component 5\",\n \"weight\": 0.1,\n \"description\": \"在 Google Docs 中创建 AI in Support 大纲文档\",\n \"check_logic\": \"对比 google_docs_mock 的 initial_state 与 current_state 中的 documents,找出 document id 不在初始集合中的新文档,检查 title 字段(转小写后)是否包含 'ai in support - outline' 或 'ai in support'\",\n \"pass_condition\": \"存在新文档且标题包含 'ai in support - outline' 或 'ai in support'\"\n },\n {\n \"name\": \"Component 6\",\n \"weight\": 0.1,\n \"description\": \"新文档内容包含 Problem、Approach、Results 三部分\",\n \"check_logic\": \"在标题包含 'ai in support' 的新文档中,提取 content 字段拼接并转小写,检查是否同时包含 'problem'、'approach'、'results'\",\n \"pass_condition\": \"存在标题包含 'ai in support' 的新文档,且其内容同时包含 'problem'、'approach'、'results'\"\n },\n {\n \"name\": \"Component 7\",\n \"weight\": 0.1,\n \"description\": \"在 Slack #marketing ��道中 user_1 发送了新消息\",\n \"check_logic\": \"检查 slack_mock current_state 中 messages.marketing 列表,筛选出 messageId 不在 SEED['slack_mock:marketing'] 中且 senderId 为 'user_1' 的消息\",\n \"pass_condition\": \"存在至少一条 user_1 在 #marketing 频道发送的新消息\"\n },\n {\n \"name\": \"Component 8\",\n \"weight\": 0.1,\n \"description\": \"Slack 消息中提及 July 2 发布日期\",\n \"check_logic\": \"提取 #marketing 频道中 user_1 的新消息内容,拼接转小写后,检查是否包含 'july 2'、'july 2nd'、'2026-07-02' 或 'july feature'\",\n \"pass_condition\": \"user_1 在 #marketing 的新消息内容包含 'july 2'、'july 2nd'、'2026-07-02' 或 'july feature'\"\n }\n ],\n \"total_max_score\": 1.0,\n \"score_aggregation\": \"各组件分数相加,最后用 min(total, 1.0) 钳制到上限 1.0,并四舍五入到 4 位小数\",\n \"failure_modes\": [\n \"读取 /tmp/task_web_sid 失败或为空时,打印 CRITICAL 并返回 0.0 后退出\",\n \"请求任意 mock 服务(asana_mock、google_calendar_mock、google_docs_mock、slack_mock)状态失败时,打印 CRITICAL 并返回 0.0 后退出\",\n \"各组件检查不通过时仅不加分,不会导致提前退出\"\n ],\n \"scoring_logic_explanation\": \"脚本首先读取 /tmp/task_web_sid 获取会话 ID,然后依次向 asana_mock、google_calendar_mock、google_docs_mock 和 slack_mock 发送 HTTP GET 请求获取当前状态与初始状态。接着按顺序执行 8 项独立检查:1)Asana 中是否有名称包含 'july feature' 或 'ai in support' 的新任务;2)Google Calendar 中是否有新事件;3)新事件标题是否包含发布相关字样;4)新事件日期是否为 2026-07-02;5)Google Docs 中是否创建了 AI in Support 大纲文档;6)新文档内容是否同时包含 Problem、Approach、Results;7)Slack #marketing 中 user_1 是否发送了新消息;8)该消息是否提及 July 2 发布日期。每项通过即累加对应分值,最终总分通过 min(total, 1.0) 限制在 1.0 以内,四舍五入后输出 REWARD。\",\n \"confidence\": 1.0\n}"
|
| 88 |
+
}
|
legacy/a91f29df-e380-5d54-b965-27aecef4d2b3/reward.py
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Reward Script: se_linear_github_triage_b91
|
| 3 |
+
Task ID: a91f29df-e380-5d54-b965-27aecef4d2b3
|
| 4 |
+
Domain: mock_websites
|
| 5 |
+
Mocks: linear_mock, github_mock, slack_mock
|
| 6 |
+
Scoring (all programmatic; evaluated against each mock's current_state; total = 1.0):
|
| 7 |
+
- [0.3] ENG-15 (memory leak) moved to In Progress
|
| 8 |
+
- [0.2] ENG-15 assigned to Sam Patel
|
| 9 |
+
- [0.2] GitHub issue opened for the leak
|
| 10 |
+
- [0.1] slack_new_msg
|
| 11 |
+
- [0.2] Slack names ENG-15 exactly
|
| 12 |
+
"""
|
| 13 |
+
import re
|
| 14 |
+
import sys
|
| 15 |
+
|
| 16 |
+
import requests
|
| 17 |
+
|
| 18 |
+
MOCK_URLS = {
|
| 19 |
+
"linear_mock": "http://28.7.186.212:8176",
|
| 20 |
+
"github_mock": "http://28.7.186.212:8156",
|
| 21 |
+
"slack_mock": "http://28.7.186.212:8198"
|
| 22 |
+
}
|
| 23 |
+
SEED = {
|
| 24 |
+
"slack_mock:general": [],
|
| 25 |
+
"slack_mock:engineering": [
|
| 26 |
+
"e1",
|
| 27 |
+
"e2"
|
| 28 |
+
],
|
| 29 |
+
"slack_mock:random": []
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
try:
|
| 33 |
+
with open('/tmp/task_web_sid') as f:
|
| 34 |
+
sid = f.read().strip()
|
| 35 |
+
if not sid:
|
| 36 |
+
raise ValueError('sid is empty')
|
| 37 |
+
except Exception as e:
|
| 38 |
+
print(f'CRITICAL: cannot read sid: {e}')
|
| 39 |
+
print('REWARD: 0.0')
|
| 40 |
+
sys.exit(0)
|
| 41 |
+
|
| 42 |
+
STATES = {}
|
| 43 |
+
for _name, _url in MOCK_URLS.items():
|
| 44 |
+
try:
|
| 45 |
+
_r = requests.get(f'{_url}/go?sid={sid}', timeout=15)
|
| 46 |
+
_r.raise_for_status()
|
| 47 |
+
STATES[_name] = _r.json()
|
| 48 |
+
except Exception as e:
|
| 49 |
+
print(f'CRITICAL: cannot fetch {_name}: {e}')
|
| 50 |
+
print('REWARD: 0.0')
|
| 51 |
+
sys.exit(0)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def cur(mock):
|
| 55 |
+
return (STATES.get(mock) or {}).get('current_state') or {}
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def _lc(s):
|
| 59 |
+
return (s or '').lower()
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
total = 0.0
|
| 63 |
+
|
| 64 |
+
# c0: linear issue i15 stateId == 'ws_eng_in_progress'
|
| 65 |
+
c0_i = next((i for i in (cur('linear_mock').get('issues') or []) if i.get('id') == 'i15'), None)
|
| 66 |
+
if c0_i and c0_i.get('stateId') == 'ws_eng_in_progress':
|
| 67 |
+
print('PASS: ENG-15 (memory leak) moved to In Progress (0.3)')
|
| 68 |
+
total += 0.3
|
| 69 |
+
else:
|
| 70 |
+
print('FAIL: ENG-15 (memory leak) moved to In Progress (got ' + str(c0_i.get('stateId') if c0_i else 'missing') + ')')
|
| 71 |
+
|
| 72 |
+
# c1: linear issue i15 assigneeId == 'u3'
|
| 73 |
+
c1_i = next((i for i in (cur('linear_mock').get('issues') or []) if i.get('id') == 'i15'), None)
|
| 74 |
+
if c1_i and c1_i.get('assigneeId') == 'u3':
|
| 75 |
+
print('PASS: ENG-15 assigned to Sam Patel (0.2)')
|
| 76 |
+
total += 0.2
|
| 77 |
+
else:
|
| 78 |
+
print('FAIL: ENG-15 assigned to Sam Patel (got ' + str(c1_i.get('assigneeId') if c1_i else 'missing') + ')')
|
| 79 |
+
|
| 80 |
+
# c2: a new github issue about (GitHub issue opened for the leak)
|
| 81 |
+
c2_init = {i.get('id') for i in ((STATES['github_mock'].get('initial_state') or {}).get('issues') or [])}
|
| 82 |
+
c2_new = [i for i in (cur('github_mock').get('issues') or []) if i.get('id') not in c2_init and any(t in _lc(i.get('title','')) for t in ['memory leak in real-time notifications', 'memory leak'])]
|
| 83 |
+
if c2_new:
|
| 84 |
+
print('PASS: GitHub issue opened for the leak (0.2)')
|
| 85 |
+
total += 0.2
|
| 86 |
+
else:
|
| 87 |
+
print('FAIL: GitHub issue opened for the leak')
|
| 88 |
+
|
| 89 |
+
# c3: new message by user_1 in #engineering
|
| 90 |
+
c3_msgs = (cur('slack_mock').get('messages') or {}).get('engineering', []) or []
|
| 91 |
+
c3_seed = set(SEED.get('slack_mock:engineering', []))
|
| 92 |
+
c3_new = [m for m in c3_msgs if m.get('messageId') not in c3_seed and m.get('senderId') == 'user_1']
|
| 93 |
+
c3_blob = _lc(' '.join((m.get('content') or '') for m in c3_new))
|
| 94 |
+
if c3_new:
|
| 95 |
+
print('PASS: new message by user_1 in #engineering (0.1)')
|
| 96 |
+
total += 0.1
|
| 97 |
+
else:
|
| 98 |
+
print('FAIL: no new user_1 message in #engineering')
|
| 99 |
+
|
| 100 |
+
# c4: slack #engineering contains (Slack names ENG-15 exactly)
|
| 101 |
+
c4_msgs = (cur('slack_mock').get('messages') or {}).get('engineering', []) or []
|
| 102 |
+
c4_seed = set(SEED.get('slack_mock:engineering', []))
|
| 103 |
+
c4_blob = _lc(' '.join((m.get('content') or '') for m in c4_msgs if m.get('messageId') not in c4_seed and m.get('senderId') == 'user_1'))
|
| 104 |
+
if all(t in c4_blob for t in ['eng-15']):
|
| 105 |
+
print('PASS: Slack names ENG-15 exactly (0.2)')
|
| 106 |
+
total += 0.2
|
| 107 |
+
else:
|
| 108 |
+
print('FAIL: Slack names ENG-15 exactly')
|
| 109 |
+
|
| 110 |
+
final = round(min(total, 1.0), 4)
|
| 111 |
+
print(f'\nScore: {total}/1.0')
|
| 112 |
+
print(f'REWARD: {final}')
|
legacy/ae_forecast_001/_cua_gym_vm_bridge.sh
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# CUA-Gym VM-side network fix (direct-IP mock access).
|
| 3 |
+
#
|
| 4 |
+
# Runs INSIDE the QEMU guest. The CUA-Gym mock services are now reached by
|
| 5 |
+
# their real IDC address (http://28.7.186.212:81xx) instead of the old
|
| 6 |
+
# localhost:9000-9097 socat bridge, so the VM only needs two fixes:
|
| 7 |
+
#
|
| 8 |
+
# 1. Working DNS — the qcow2-baked /etc/resolv.conf points at the Pod's
|
| 9 |
+
# cluster DNS, which is unreachable from QEMU SLIRP NAT
|
| 10 |
+
# ("Temporary failure in name resolution").
|
| 11 |
+
# 2. The mock host excluded from the woa http proxy — otherwise the VM's
|
| 12 |
+
# Chrome (gsettings proxy) and initial_setup.py's `requests` get a 403
|
| 13 |
+
# from the proxy when hitting 28.7.186.212:81xx. (The old socat path never
|
| 14 |
+
# hit this because localhost is bypassed by default.)
|
| 15 |
+
#
|
| 16 |
+
# Idempotent. Scoped to the CUA-Gym bridge step; does not touch the generic
|
| 17 |
+
# OSWorld setup pipeline.
|
| 18 |
+
#
|
| 19 |
+
# Argv:
|
| 20 |
+
# $1 optional sudo password (default "password"; SetupController
|
| 21 |
+
# substitutes {CLIENT_PASSWORD} when uploaded as a cache file).
|
| 22 |
+
# $2 unused (kept for backward compat — was socat first port 9000).
|
| 23 |
+
# $3 unused (kept for backward compat — was socat last port 9097).
|
| 24 |
+
# $4 optional mock host IP (default 28.7.186.212).
|
| 25 |
+
|
| 26 |
+
set +e
|
| 27 |
+
|
| 28 |
+
PASS="${1:-password}"
|
| 29 |
+
MOCK_HOST="${4:-28.7.186.212}"
|
| 30 |
+
# Derive the /16 IDC subnet so future port/host tweaks on the same segment
|
| 31 |
+
# stay bypassed too (28.7.186.212 -> 28.133.0.0/16).
|
| 32 |
+
MOCK_NET="$(echo "${MOCK_HOST}" | awk -F. 'NF==4{print $1"."$2".0.0/16"}')"
|
| 33 |
+
|
| 34 |
+
run_root() {
|
| 35 |
+
echo "$PASS" | sudo -S -p "" bash -c "$1"
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
# Detect SLIRP gateway from VM's routing table; fall back to 10.0.2.2.
|
| 39 |
+
GW="$(ip route 2>/dev/null | awk '/default/ {print $3; exit}')"
|
| 40 |
+
GW="${GW:-10.0.2.2}"
|
| 41 |
+
|
| 42 |
+
# ─── CUA-Gym network fix (Taiji-specific) ─────────────────────────────
|
| 43 |
+
fix_vm_network() {
|
| 44 |
+
# 0) Discover VM network state at runtime — gateway, own IP/CIDR, SLIRP
|
| 45 |
+
# DNS forwarder. Nothing hardcoded except the mock host above.
|
| 46 |
+
local GW_NET="${GW%.*}"
|
| 47 |
+
local SLIRP_DNS="${GW_NET}.3" # QEMU SLIRP DNS proxy is always .3
|
| 48 |
+
local OWN_CIDR
|
| 49 |
+
OWN_CIDR="$(ip -4 -o addr show scope global 2>/dev/null \
|
| 50 |
+
| awk '{print $4; exit}')"
|
| 51 |
+
local OWN_IP="${OWN_CIDR%/*}"
|
| 52 |
+
local OWN_NET=""
|
| 53 |
+
[ -n "${OWN_IP}" ] && OWN_NET="${OWN_IP%.*}.0/24"
|
| 54 |
+
|
| 55 |
+
# 1) DNS — point at SLIRP DNS proxy + public fallbacks. chattr +i keeps
|
| 56 |
+
# systemd-resolved/NetworkManager from clobbering it.
|
| 57 |
+
if run_root "printf 'nameserver ${SLIRP_DNS}\\nnameserver 114.114.114.114\\nnameserver 8.8.8.8\\n' > /etc/resolv.conf
|
| 58 |
+
chattr +i /etc/resolv.conf 2>/dev/null || true"; then
|
| 59 |
+
echo "[cua_gym_vm_bridge] DNS set: ${SLIRP_DNS}, 114.114.114.114, 8.8.8.8 (gw=${GW})"
|
| 60 |
+
else
|
| 61 |
+
echo "[cua_gym_vm_bridge] WARN: failed to write /etc/resolv.conf"
|
| 62 |
+
fi
|
| 63 |
+
|
| 64 |
+
# 2) Build the proxy bypass list from detected values + the direct-IP
|
| 65 |
+
# mock host (and its /16 subnet). THIS is what makes 28.7.186.212:81xx
|
| 66 |
+
# reachable from inside the VM — without it the woa proxy 403s it.
|
| 67 |
+
local ignore_list="['localhost', '127.0.0.0/8', '${GW}'"
|
| 68 |
+
[ -n "${OWN_IP}" ] && ignore_list="${ignore_list}, '${OWN_IP}'"
|
| 69 |
+
[ -n "${OWN_NET}" ] && ignore_list="${ignore_list}, '${OWN_NET}'"
|
| 70 |
+
[ -n "${GW_NET}" ] && ignore_list="${ignore_list}, '${GW_NET}.0/24'"
|
| 71 |
+
[ -n "${MOCK_HOST}" ] && ignore_list="${ignore_list}, '${MOCK_HOST}'"
|
| 72 |
+
[ -n "${MOCK_NET}" ] && ignore_list="${ignore_list}, '${MOCK_NET}'"
|
| 73 |
+
ignore_list="${ignore_list}]"
|
| 74 |
+
|
| 75 |
+
# 3) GNOME proxy ignore-hosts — Chrome bypasses the woa proxy for these.
|
| 76 |
+
if gsettings set org.gnome.system.proxy ignore-hosts "${ignore_list}" 2>/tmp/gsettings_err; then
|
| 77 |
+
echo "[cua_gym_vm_bridge] gsettings ignore-hosts = ${ignore_list}"
|
| 78 |
+
else
|
| 79 |
+
echo "[cua_gym_vm_bridge] WARN: gsettings ignore-hosts failed: $(cat /tmp/gsettings_err 2>/dev/null)"
|
| 80 |
+
fi
|
| 81 |
+
|
| 82 |
+
# 4) Shell env — comma-separated form for no_proxy/NO_PROXY (requests/curl).
|
| 83 |
+
local NP="localhost,127.0.0.1,${GW}"
|
| 84 |
+
[ -n "${OWN_IP}" ] && NP="${NP},${OWN_IP}"
|
| 85 |
+
[ -n "${OWN_NET}" ] && NP="${NP},${OWN_NET}"
|
| 86 |
+
[ -n "${GW_NET}" ] && NP="${NP},${GW_NET}.0/24"
|
| 87 |
+
[ -n "${MOCK_HOST}" ] && NP="${NP},${MOCK_HOST}"
|
| 88 |
+
[ -n "${MOCK_NET}" ] && NP="${NP},${MOCK_NET}"
|
| 89 |
+
|
| 90 |
+
for var in no_proxy NO_PROXY; do
|
| 91 |
+
if ! grep -q "export ${var}=${NP}" /home/user/.bashrc 2>/dev/null; then
|
| 92 |
+
echo "export ${var}=${NP}" >> /home/user/.bashrc
|
| 93 |
+
fi
|
| 94 |
+
done
|
| 95 |
+
run_root "grep -q '^no_proxy=' /etc/environment 2>/dev/null \
|
| 96 |
+
&& sed -i 's|^no_proxy=.*|no_proxy=\"${NP}\"|' /etc/environment \
|
| 97 |
+
|| echo 'no_proxy=\"${NP}\"' >> /etc/environment
|
| 98 |
+
grep -q '^NO_PROXY=' /etc/environment 2>/dev/null \
|
| 99 |
+
&& sed -i 's|^NO_PROXY=.*|NO_PROXY=\"${NP}\"|' /etc/environment \
|
| 100 |
+
|| echo 'NO_PROXY=\"${NP}\"' >> /etc/environment" >/dev/null 2>&1
|
| 101 |
+
echo "[cua_gym_vm_bridge] no_proxy=${NP}"
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
fix_vm_network
|
| 105 |
+
|
| 106 |
+
echo "[cua_gym_vm_bridge] direct-IP mode: ${MOCK_HOST} (+${MOCK_NET}) bypassed from woa proxy; no socat forwarding needed"
|
legacy/ae_forecast_001/initial_setup.py
ADDED
|
@@ -0,0 +1,553 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# --- MOCK_HOST_NO_PROXY_OVERRIDE: bypass woa proxy for locally-deployed mocks ---
|
| 2 |
+
import os as _os
|
| 3 |
+
_np = _os.environ.get("no_proxy", _os.environ.get("NO_PROXY", ""))
|
| 4 |
+
for _h in ("127.0.0.1", "localhost", "28.7.186.212"):
|
| 5 |
+
if _h not in _np:
|
| 6 |
+
_np = (_np + "," + _h).lstrip(",")
|
| 7 |
+
_os.environ["no_proxy"] = _np
|
| 8 |
+
_os.environ["NO_PROXY"] = _np
|
| 9 |
+
# --- end override ---
|
| 10 |
+
|
| 11 |
+
# --- wait_mocks_loaded: wait for mock backends ready AND browser tabs rendered ---
|
| 12 |
+
def wait_mocks_loaded(timeout=60, render_buffer=12):
|
| 13 |
+
"""Wait for mock backends ready AND browser tabs rendered (via CDP).
|
| 14 |
+
|
| 15 |
+
Phase 1 — backend readiness: poll each mock's /state?sid= until it
|
| 16 |
+
returns 200 with 'stored_state' in the body.
|
| 17 |
+
|
| 18 |
+
Phase 2 — browser render verification: connect to Chrome's CDP
|
| 19 |
+
endpoint and wait for every open tab to reach 'networkidle' load
|
| 20 |
+
state with a non-trivial DOM element count. This confirms the SPA
|
| 21 |
+
has fetched its /go?sid= data and actually painted, not just that
|
| 22 |
+
the backend is up.
|
| 23 |
+
|
| 24 |
+
CDP port auto-detection: checks globals for _chrome_debug_port /
|
| 25 |
+
cdp_port / debug_port (set by tasks that use a dynamic port, e.g.
|
| 26 |
+
se_hard_008's launch_chrome_with_urls); defaults to 1337 for tasks
|
| 27 |
+
that use launch_gui's --remote-debugging-port injection.
|
| 28 |
+
|
| 29 |
+
Falls back to the old render_buffer sleep if Playwright or the CDP
|
| 30 |
+
endpoint is unavailable.
|
| 31 |
+
"""
|
| 32 |
+
import urllib.request as _u, time as _t
|
| 33 |
+
g = globals()
|
| 34 |
+
_urls = {}
|
| 35 |
+
for _k, _v in list(g.items()):
|
| 36 |
+
if isinstance(_v, dict) and _v and all(isinstance(x, str) and x.startswith("http://") for x in _v.values()):
|
| 37 |
+
_urls.update(_v)
|
| 38 |
+
elif isinstance(_v, str) and _v.startswith("http://") and (_k.endswith("_URL") or _k.endswith("_url")):
|
| 39 |
+
_urls[_k] = _v
|
| 40 |
+
_sid = ""
|
| 41 |
+
for _k in ("sid", "SID", "task_sid", "session_id"):
|
| 42 |
+
if isinstance(g.get(_k), str) and g[_k]:
|
| 43 |
+
_sid = g[_k]; break
|
| 44 |
+
if not _sid:
|
| 45 |
+
for _k, _v in g.items():
|
| 46 |
+
if "sid" in _k.lower() and isinstance(_v, str) and _v:
|
| 47 |
+
_sid = _v; break
|
| 48 |
+
if not _urls or not _sid:
|
| 49 |
+
print(" wait_mocks_loaded: no mocks/sid found (%d urls, sid=%r), skipping" % (len(_urls), bool(_sid)))
|
| 50 |
+
return
|
| 51 |
+
|
| 52 |
+
# ---- Phase 1: backend readiness ----
|
| 53 |
+
_op = _u.build_opener(_u.ProxyHandler({}))
|
| 54 |
+
_dl = _t.time() + timeout
|
| 55 |
+
_todo = list(_urls.items())
|
| 56 |
+
while _todo and _t.time() < _dl:
|
| 57 |
+
_rest = []
|
| 58 |
+
for _n2, _uu in _todo:
|
| 59 |
+
try:
|
| 60 |
+
_r = _op.open("%s/state?sid=%s" % (_uu, _sid), timeout=5)
|
| 61 |
+
if _r.status == 200 and b"stored_state" in _r.read():
|
| 62 |
+
print(" %s: backend ready" % _n2); continue
|
| 63 |
+
except Exception:
|
| 64 |
+
pass
|
| 65 |
+
_rest.append((_n2, _uu))
|
| 66 |
+
_todo = _rest
|
| 67 |
+
if _todo:
|
| 68 |
+
_t.sleep(2)
|
| 69 |
+
_done = len(_urls) - len(_todo)
|
| 70 |
+
_pend = (" (pending: %s)" % [n for n, _ in _todo]) if _todo else ""
|
| 71 |
+
print(" mocks backend ready: %d/%d%s" % (_done, len(_urls), _pend))
|
| 72 |
+
|
| 73 |
+
# ---- Phase 2: browser render verification via CDP ----
|
| 74 |
+
# Auto-detect CDP port from globals (set by launch_chrome_with_urls
|
| 75 |
+
# in tasks that use a dynamic port); default to 1337.
|
| 76 |
+
_cdp_port = 1337
|
| 77 |
+
for _pk in ("_chrome_debug_port", "chrome_debug_port", "cdp_port", "debug_port"):
|
| 78 |
+
_pv = g.get(_pk)
|
| 79 |
+
if isinstance(_pv, int) and 0 < _pv < 65536:
|
| 80 |
+
_cdp_port = _pv; break
|
| 81 |
+
_cdp_ok = False
|
| 82 |
+
try:
|
| 83 |
+
from playwright.sync_api import sync_playwright
|
| 84 |
+
_cdp_dl = _t.time() + max(10.0, _dl - _t.time()) # leftover budget, floor 10s
|
| 85 |
+
with sync_playwright() as _p:
|
| 86 |
+
_br = None
|
| 87 |
+
# Retry-connect: Chrome may still be starting up.
|
| 88 |
+
while _t.time() < _cdp_dl:
|
| 89 |
+
try:
|
| 90 |
+
_br = _p.chromium.connect_over_cdp("http://localhost:%d" % _cdp_port)
|
| 91 |
+
break
|
| 92 |
+
except Exception:
|
| 93 |
+
_t.sleep(0.5)
|
| 94 |
+
if _br is None:
|
| 95 |
+
print(" wait_mocks_loaded: CDP connect to localhost:%d failed; "
|
| 96 |
+
"is Chrome launched with --remote-debugging-port?" % _cdp_port)
|
| 97 |
+
else:
|
| 98 |
+
# Wait for ALL expected tabs to appear, then verify each renders.
|
| 99 |
+
_n_expected = len(_urls)
|
| 100 |
+
_pages = []
|
| 101 |
+
_pg_dl = _t.time() + 15
|
| 102 |
+
_last_count = -1
|
| 103 |
+
_stable_since = None
|
| 104 |
+
while _t.time() < _pg_dl:
|
| 105 |
+
_pages = []
|
| 106 |
+
for _c in _br.contexts:
|
| 107 |
+
_pages.extend(_c.pages)
|
| 108 |
+
_cnt = len(_pages)
|
| 109 |
+
if _n_expected > 0 and _cnt >= _n_expected:
|
| 110 |
+
break # all expected tabs are open
|
| 111 |
+
if _cnt > 0 and _cnt == _last_count:
|
| 112 |
+
if _stable_since is None:
|
| 113 |
+
_stable_since = _t.time()
|
| 114 |
+
elif _t.time() - _stable_since >= 1.5:
|
| 115 |
+
break # tab count stable -> no more tabs opening
|
| 116 |
+
else:
|
| 117 |
+
_stable_since = None
|
| 118 |
+
_last_count = _cnt
|
| 119 |
+
_t.sleep(0.5)
|
| 120 |
+
# Re-fetch final snapshot so late-opening tabs are included.
|
| 121 |
+
_pages = []
|
| 122 |
+
for _c in _br.contexts:
|
| 123 |
+
_pages.extend(_c.pages)
|
| 124 |
+
if not _pages:
|
| 125 |
+
print(" wait_mocks_loaded: CDP connected but no open tabs found")
|
| 126 |
+
else:
|
| 127 |
+
print(" wait_mocks_loaded: %d tab(s) open (expected %d); "
|
| 128 |
+
"verifying render" % (len(_pages), _n_expected))
|
| 129 |
+
_ok_cnt = 0
|
| 130 |
+
for _pg in _pages:
|
| 131 |
+
_ttl = ""
|
| 132 |
+
try:
|
| 133 |
+
_ttl = _pg.title()
|
| 134 |
+
except Exception:
|
| 135 |
+
pass
|
| 136 |
+
try:
|
| 137 |
+
_pg.wait_for_load_state(
|
| 138 |
+
"networkidle",
|
| 139 |
+
timeout=int(max(5000, (_cdp_dl - _t.time()) * 1000)))
|
| 140 |
+
_n = _pg.evaluate("document.querySelectorAll('*').length")
|
| 141 |
+
if _n < 20:
|
| 142 |
+
print(" wait_mocks_loaded: WARNING tab %r has only %d "
|
| 143 |
+
"elements (render stall?)" % (_ttl, _n))
|
| 144 |
+
else:
|
| 145 |
+
print(" wait_mocks_loaded: tab %r rendered (%d elements)"
|
| 146 |
+
% (_ttl, _n))
|
| 147 |
+
_ok_cnt += 1
|
| 148 |
+
except Exception as _e:
|
| 149 |
+
print(" wait_mocks_loaded: tab %r render wait failed: %r"
|
| 150 |
+
% (_ttl, _e))
|
| 151 |
+
# Require ALL open tabs to render before skipping the
|
| 152 |
+
# render_buffer fallback, so no tab is left half-loaded.
|
| 153 |
+
if _ok_cnt > 0 and _ok_cnt == len(_pages):
|
| 154 |
+
_cdp_ok = True
|
| 155 |
+
else:
|
| 156 |
+
print(" wait_mocks_loaded: %d/%d tabs rendered, will fall back"
|
| 157 |
+
% (_ok_cnt, len(_pages)))
|
| 158 |
+
except ImportError:
|
| 159 |
+
print(" wait_mocks_loaded: playwright not installed; cannot verify browser render")
|
| 160 |
+
except Exception as _e:
|
| 161 |
+
print(" wait_mocks_loaded: CDP phase error (%r)" % _e)
|
| 162 |
+
|
| 163 |
+
if not _cdp_ok:
|
| 164 |
+
print(" wait_mocks_loaded: falling back to render_buffer=%ds sleep" % render_buffer)
|
| 165 |
+
_t.sleep(render_buffer)
|
| 166 |
+
else:
|
| 167 |
+
print(" wait_mocks_loaded: browser render verified, skipping render_buffer")
|
| 168 |
+
# --- end wait_mocks_loaded ---
|
| 169 |
+
|
| 170 |
+
# --- _open_remaining_mock_tabs: open all auto-detected mock URLs in new Chrome tabs ---
|
| 171 |
+
def _open_remaining_mock_tabs(primary_url=""):
|
| 172 |
+
"""Open all auto-detected mock URLs in Chrome --new-tab, except primary_url."""
|
| 173 |
+
g = globals()
|
| 174 |
+
_urls = set()
|
| 175 |
+
for _k, _v in list(g.items()):
|
| 176 |
+
if "PROBE" in _k.upper() or _k.startswith("_"):
|
| 177 |
+
continue
|
| 178 |
+
if isinstance(_v, str) and _v.startswith("http://") and (_k.endswith("_URL") or _k.endswith("_url")):
|
| 179 |
+
_urls.add(_v)
|
| 180 |
+
elif isinstance(_v, dict) and _v and all(isinstance(x, str) and x.startswith("http://") for x in _v.values()):
|
| 181 |
+
_urls.update(_v.values())
|
| 182 |
+
_sid = ""
|
| 183 |
+
for _k in ("sid", "SID", "task_sid", "session_id"):
|
| 184 |
+
if isinstance(g.get(_k), str) and g[_k]:
|
| 185 |
+
_sid = g[_k]; break
|
| 186 |
+
for _u in sorted(_urls):
|
| 187 |
+
if _u != primary_url:
|
| 188 |
+
launch_gui(f'google-chrome --new-tab "{_u}/?sid={_sid}"', delay_sec=1.0)
|
| 189 |
+
# --- end _open_remaining_mock_tabs ---
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
"""
|
| 193 |
+
Initial Setup: Q3 forecast prep across Salesforce, Notion, and Slack.
|
| 194 |
+
Task ID: ae_forecast_001
|
| 195 |
+
Domain: mock_websites (multi-mock)
|
| 196 |
+
Mocks: salesforce, notion, slack
|
| 197 |
+
|
| 198 |
+
Persona: Alex Rivera (user-1 / user_1), AE at Northwind Cloud. Today = 2026-06-24.
|
| 199 |
+
|
| 200 |
+
Pre-task state ONLY. MUST NOT contain task-completed elements:
|
| 201 |
+
- Notion 'Q3 Forecast' database has exactly 3 rows whose Opportunity titles
|
| 202 |
+
are 'Globex - Platform Expansion', 'Initech - Annual Renewal',
|
| 203 |
+
'Soylent - New Logo'. Amount / Stage / Close Date / Next Step are EMPTY
|
| 204 |
+
in every one of those rows (the agent fills them).
|
| 205 |
+
- Slack channel 'sales' exists but has NO message from today (and no forecast
|
| 206 |
+
summary message at all).
|
| 207 |
+
Distractor that MUST exist and be left untouched by the golden state:
|
| 208 |
+
- Salesforce opp-6 'Globex - SMB Add-on' (Closed Lost) — must NOT be
|
| 209 |
+
forecast and must remain unchanged.
|
| 210 |
+
"""
|
| 211 |
+
import os
|
| 212 |
+
import shlex
|
| 213 |
+
import subprocess
|
| 214 |
+
import time
|
| 215 |
+
import uuid
|
| 216 |
+
|
| 217 |
+
import requests
|
| 218 |
+
|
| 219 |
+
# --- Networking ---
|
| 220 |
+
# Mock servers are reachable directly on the fixed internal host.
|
| 221 |
+
|
| 222 |
+
# --- Mock registry ---
|
| 223 |
+
MOCKS = {
|
| 224 |
+
'salesforce': 'http://28.7.186.212:8195',
|
| 225 |
+
'notion': 'http://28.7.186.212:8186',
|
| 226 |
+
'slack': 'http://28.7.186.212:8198',
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
# --- Shared session id ---
|
| 230 |
+
sid = str(uuid.uuid4())
|
| 231 |
+
with open('/tmp/task_web_sid', 'w') as f:
|
| 232 |
+
f.write(sid)
|
| 233 |
+
print(f'sid = {sid}')
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
# ----------------------------------------------------------------------------
|
| 237 |
+
# Salesforce state
|
| 238 |
+
# user-1 Alex Rivera; 3 accounts + 3 contacts; 4 opportunities
|
| 239 |
+
# (opp-1/2/3 OPEN + opp-6 Closed Lost distractor). Read-only in this task.
|
| 240 |
+
# ----------------------------------------------------------------------------
|
| 241 |
+
def salesforce_state():
|
| 242 |
+
user_1 = {
|
| 243 |
+
"userId": "user-1", "firstName": "Alex", "lastName": "Rivera",
|
| 244 |
+
"email": "alex.rivera@northwindcloud.com", "phone": "(555) 240-1188",
|
| 245 |
+
"title": "Account Executive", "department": "Sales", "role": "Rep",
|
| 246 |
+
"avatar": "https://i.pravatar.cc/150?u=user-1",
|
| 247 |
+
"timezone": "America/Los_Angeles", "locale": "en-US", "theme": "lightning",
|
| 248 |
+
}
|
| 249 |
+
user_2 = {
|
| 250 |
+
"userId": "user-2", "firstName": "Sam", "lastName": "Lee",
|
| 251 |
+
"email": "sam.lee@northwindcloud.com", "phone": "(555) 240-1190",
|
| 252 |
+
"title": "Sales Manager", "department": "Sales", "role": "Manager",
|
| 253 |
+
"avatar": "https://i.pravatar.cc/150?u=user-2",
|
| 254 |
+
"timezone": "America/Los_Angeles", "locale": "en-US", "theme": "lightning",
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
accounts = [
|
| 258 |
+
{"accountId": "account-1", "name": "Globex Corporation",
|
| 259 |
+
"type": "Customer", "industry": "Manufacturing", "revenue": 48000000,
|
| 260 |
+
"employees": 1200, "ownerId": "user-1", "billingStreet": "500 Globex Pkwy",
|
| 261 |
+
"billingCity": "San Jose", "billingState": "CA", "billingZip": "95110",
|
| 262 |
+
"billingCountry": "USA"},
|
| 263 |
+
{"accountId": "account-2", "name": "Initech LLC", "type": "Customer",
|
| 264 |
+
"industry": "Software", "revenue": 22000000, "employees": 320,
|
| 265 |
+
"ownerId": "user-1", "billingStreet": "78 Office Park Dr",
|
| 266 |
+
"billingCity": "Austin", "billingState": "TX", "billingZip": "73301",
|
| 267 |
+
"billingCountry": "USA"},
|
| 268 |
+
{"accountId": "account-3", "name": "Soylent Industries",
|
| 269 |
+
"type": "Prospect", "industry": "Food & Beverage", "revenue": 9000000,
|
| 270 |
+
"employees": 140, "ownerId": "user-1", "billingStreet": "12 Greenway Blvd",
|
| 271 |
+
"billingCity": "Portland", "billingState": "OR", "billingZip": "97201",
|
| 272 |
+
"billingCountry": "USA"},
|
| 273 |
+
]
|
| 274 |
+
|
| 275 |
+
contacts = [
|
| 276 |
+
{"contactId": "contact-1", "accountId": "account-1",
|
| 277 |
+
"firstName": "Maria", "lastName": "Gomez", "title": "VP Operations",
|
| 278 |
+
"department": "Operations", "email": "maria.gomez@globex.com",
|
| 279 |
+
"phone": "(555) 401-3321", "ownerId": "user-1"},
|
| 280 |
+
{"contactId": "contact-2", "accountId": "account-2",
|
| 281 |
+
"firstName": "Daniel", "lastName": "Park", "title": "CTO",
|
| 282 |
+
"department": "Engineering", "email": "daniel.park@initech.com",
|
| 283 |
+
"phone": "(555) 330-2201", "ownerId": "user-1"},
|
| 284 |
+
{"contactId": "contact-3", "accountId": "account-3",
|
| 285 |
+
"firstName": "Priya", "lastName": "Nair", "title": "Head of Procurement",
|
| 286 |
+
"department": "Procurement", "email": "priya.nair@soylent.com",
|
| 287 |
+
"phone": "(555) 661-7788", "ownerId": "user-1"},
|
| 288 |
+
]
|
| 289 |
+
|
| 290 |
+
opportunities = [
|
| 291 |
+
{"opportunityId": "opp-1", "name": "Globex - Platform Expansion",
|
| 292 |
+
"accountId": "account-1", "contactId": "contact-1", "amount": 120000,
|
| 293 |
+
"closeDate": "2026-07-15", "stage": "Negotiation", "probability": 75,
|
| 294 |
+
"ownerId": "user-1"},
|
| 295 |
+
{"opportunityId": "opp-2", "name": "Initech - Annual Renewal",
|
| 296 |
+
"accountId": "account-2", "contactId": "contact-2", "amount": 60000,
|
| 297 |
+
"closeDate": "2026-06-30", "stage": "Proposal", "probability": 60,
|
| 298 |
+
"ownerId": "user-1"},
|
| 299 |
+
{"opportunityId": "opp-3", "name": "Soylent - New Logo",
|
| 300 |
+
"accountId": "account-3", "contactId": "contact-3", "amount": 45000,
|
| 301 |
+
"closeDate": "2026-08-20", "stage": "Value Proposition",
|
| 302 |
+
"probability": 40, "ownerId": "user-1"},
|
| 303 |
+
# DISTRACTOR — closed, must NOT be forecast and must remain unchanged.
|
| 304 |
+
{"opportunityId": "opp-6", "name": "Globex - SMB Add-on",
|
| 305 |
+
"accountId": "account-1", "contactId": "contact-1", "amount": 9000,
|
| 306 |
+
"closeDate": "2026-04-01", "stage": "Closed Lost", "probability": 0,
|
| 307 |
+
"ownerId": "user-1"},
|
| 308 |
+
]
|
| 309 |
+
|
| 310 |
+
return {
|
| 311 |
+
"user": user_1,
|
| 312 |
+
"users": [user_1, user_2],
|
| 313 |
+
"leads": [],
|
| 314 |
+
"accounts": accounts,
|
| 315 |
+
"contacts": contacts,
|
| 316 |
+
"opportunities": opportunities,
|
| 317 |
+
"cases": [],
|
| 318 |
+
"activities": [],
|
| 319 |
+
"chatterPosts": [],
|
| 320 |
+
"files": [],
|
| 321 |
+
"following": [],
|
| 322 |
+
"recentlyViewed": [],
|
| 323 |
+
"dismissedNotifications": [],
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
|
| 327 |
+
# ----------------------------------------------------------------------------
|
| 328 |
+
# Notion state
|
| 329 |
+
# 'Q3 Forecast' database (table view). Three rows with Opportunity titles
|
| 330 |
+
# filled; Amount / Stage / Close Date / Next Step all EMPTY.
|
| 331 |
+
# ----------------------------------------------------------------------------
|
| 332 |
+
def notion_state():
|
| 333 |
+
db_id = "db-q3-forecast"
|
| 334 |
+
# NOTE: notion_mock stores database-row property values as a FLAT map
|
| 335 |
+
# ({propId: primitiveValue}) and select options as a string array. The
|
| 336 |
+
# built-in "Name" column renders page.title, so there is no "title"-typed
|
| 337 |
+
# property (that type is unsupported and crashes DatabaseView -> blank page).
|
| 338 |
+
properties = [
|
| 339 |
+
{"id": "prop_amt", "name": "Amount", "type": "number"},
|
| 340 |
+
{"id": "prop_stage", "name": "Stage", "type": "select",
|
| 341 |
+
"options": ["Prospecting", "Qualification", "Needs Analysis",
|
| 342 |
+
"Value Proposition", "Proposal", "Negotiation",
|
| 343 |
+
"Closed Won", "Closed Lost"]},
|
| 344 |
+
{"id": "prop_date", "name": "Close Date", "type": "date"},
|
| 345 |
+
{"id": "prop_next", "name": "Next Step", "type": "text"},
|
| 346 |
+
]
|
| 347 |
+
|
| 348 |
+
def make_empty_row(page_id, opp_title):
|
| 349 |
+
# Title filled (via page.title / Name column); all other cells EMPTY.
|
| 350 |
+
return {
|
| 351 |
+
"id": page_id,
|
| 352 |
+
"title": opp_title,
|
| 353 |
+
"icon": "", "cover": None, "parentId": db_id,
|
| 354 |
+
"blockIds": [], "favorite": False,
|
| 355 |
+
"createdDate": "2026-06-20T09:00:00.000Z",
|
| 356 |
+
"lastEditedDate": "2026-06-20T09:00:00.000Z",
|
| 357 |
+
"properties": {
|
| 358 |
+
"prop_amt": "",
|
| 359 |
+
"prop_stage": "",
|
| 360 |
+
"prop_date": "",
|
| 361 |
+
"prop_next": "",
|
| 362 |
+
},
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
row_globex = make_empty_row("row-globex", "Globex - Platform Expansion")
|
| 366 |
+
row_initech = make_empty_row("row-initech", "Initech - Annual Renewal")
|
| 367 |
+
row_soylent = make_empty_row("row-soylent", "Soylent - New Logo")
|
| 368 |
+
|
| 369 |
+
db_page = {
|
| 370 |
+
"id": db_id,
|
| 371 |
+
"title": "Q3 Forecast",
|
| 372 |
+
"icon": "📊", "cover": None, "parentId": None,
|
| 373 |
+
"type": "database", "viewType": "table",
|
| 374 |
+
"properties": properties,
|
| 375 |
+
"views": [{
|
| 376 |
+
"id": "view-q3", "name": "Table", "type": "table",
|
| 377 |
+
"filters": [], "sorts": [], "groupBy": None,
|
| 378 |
+
"visibleProperties": ["prop_amt", "prop_stage",
|
| 379 |
+
"prop_date", "prop_next"],
|
| 380 |
+
}],
|
| 381 |
+
"items": ["row-globex", "row-initech", "row-soylent"],
|
| 382 |
+
"blockIds": [], "favorite": False,
|
| 383 |
+
"createdDate": "2026-06-20T09:00:00.000Z",
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
return {
|
| 387 |
+
"user": {"id": "user-1", "name": "Alex Rivera",
|
| 388 |
+
"email": "alex.rivera@northwindcloud.com", "avatar": ""},
|
| 389 |
+
"workspace": {"id": "ws-1", "name": "Northwind Sales", "icon": "🏢",
|
| 390 |
+
"members": ["user-1"]},
|
| 391 |
+
"pages": {
|
| 392 |
+
db_id: db_page,
|
| 393 |
+
"row-globex": row_globex,
|
| 394 |
+
"row-initech": row_initech,
|
| 395 |
+
"row-soylent": row_soylent,
|
| 396 |
+
},
|
| 397 |
+
"blocks": {},
|
| 398 |
+
"trash": [],
|
| 399 |
+
"comments": {},
|
| 400 |
+
"settings": {"appearance": "light", "startWeekMonday": False,
|
| 401 |
+
"fontSize": "default"},
|
| 402 |
+
"notifications": [],
|
| 403 |
+
"pageOrder": [db_id],
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
|
| 407 |
+
# ----------------------------------------------------------------------------
|
| 408 |
+
# Slack state
|
| 409 |
+
# workspace 'Northwind Cloud'; currentUser user_1 Alex Rivera.
|
| 410 |
+
# Public channel 'sales' (alongside defaults). No forecast message yet.
|
| 411 |
+
# ----------------------------------------------------------------------------
|
| 412 |
+
def slack_state():
|
| 413 |
+
user_1 = {
|
| 414 |
+
"userId": "user_1", "fullName": "Alex Rivera", "displayName": "Alex",
|
| 415 |
+
"email": "alex.rivera@northwindcloud.com",
|
| 416 |
+
"avatar": "https://picsum.photos/200/200?random=1", "title": "Account Executive",
|
| 417 |
+
"status": "online", "statusMessage": "", "statusEmoji": "",
|
| 418 |
+
"timeZone": "America/Los_Angeles",
|
| 419 |
+
}
|
| 420 |
+
user_2 = {
|
| 421 |
+
"userId": "user_2", "fullName": "Sam Lee", "displayName": "Sam",
|
| 422 |
+
"email": "sam.lee@northwindcloud.com",
|
| 423 |
+
"avatar": "https://picsum.photos/200/200?random=2", "title": "Sales Manager",
|
| 424 |
+
"status": "online", "statusMessage": "", "statusEmoji": "",
|
| 425 |
+
"timeZone": "America/Los_Angeles",
|
| 426 |
+
}
|
| 427 |
+
user_3 = {
|
| 428 |
+
"userId": "user_3", "fullName": "Nina Torres", "displayName": "Nina",
|
| 429 |
+
"email": "nina.torres@northwindcloud.com",
|
| 430 |
+
"avatar": "https://picsum.photos/200/200?random=3", "title": "Sales Engineer",
|
| 431 |
+
"status": "away", "statusMessage": "", "statusEmoji": "",
|
| 432 |
+
"timeZone": "America/New_York",
|
| 433 |
+
}
|
| 434 |
+
users = [user_1, user_2, user_3]
|
| 435 |
+
all_members = ["user_1", "user_2", "user_3"]
|
| 436 |
+
|
| 437 |
+
def channel(cid, name, desc, topic):
|
| 438 |
+
return {
|
| 439 |
+
"channelId": cid, "name": name, "description": desc, "topic": topic,
|
| 440 |
+
"isPrivate": False, "isStarred": False, "members": all_members,
|
| 441 |
+
"createdBy": "user_2", "createdAt": "2026-01-05T09:00:00Z",
|
| 442 |
+
"pinnedMessages": [], "unreadCount": 0,
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
channels = [
|
| 446 |
+
channel("general", "general", "Company-wide announcements", "Welcome to Northwind Cloud"),
|
| 447 |
+
channel("random", "random", "Non-work chatter", ""),
|
| 448 |
+
channel("engineering", "engineering", "Engineering team", ""),
|
| 449 |
+
channel("design", "design", "Design team", ""),
|
| 450 |
+
channel("marketing", "marketing", "Marketing team", ""),
|
| 451 |
+
channel("project-alpha", "project-alpha", "Project Alpha working group", ""),
|
| 452 |
+
channel("sales", "sales", "Sales team — pipeline, forecasts, wins", "Q3 forecast prep"),
|
| 453 |
+
]
|
| 454 |
+
|
| 455 |
+
# Channels have some realistic prior chatter, but NO forecast summary today.
|
| 456 |
+
messages = {
|
| 457 |
+
"general": [
|
| 458 |
+
{"messageId": "msg_gen_1", "senderId": "user_2",
|
| 459 |
+
"content": "Morning team — reminder we have the Q3 sales sync this afternoon.",
|
| 460 |
+
"timestamp": "2026-06-24T15:00:00Z", "threadId": None,
|
| 461 |
+
"reactions": [], "attachments": [], "isEdited": False},
|
| 462 |
+
],
|
| 463 |
+
"random": [],
|
| 464 |
+
"engineering": [],
|
| 465 |
+
"design": [],
|
| 466 |
+
"marketing": [],
|
| 467 |
+
"project-alpha": [],
|
| 468 |
+
"sales": [
|
| 469 |
+
{"messageId": "msg_sales_1", "senderId": "user_2",
|
| 470 |
+
"content": "Let's get the Q3 forecast numbers locked before the sync.",
|
| 471 |
+
"timestamp": "2026-06-22T16:30:00Z", "threadId": None,
|
| 472 |
+
"reactions": [], "attachments": [], "isEdited": False},
|
| 473 |
+
],
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
return {
|
| 477 |
+
"currentUser": user_1,
|
| 478 |
+
"workspace": {"workspaceId": "ws_1", "workspaceName": "Northwind Cloud",
|
| 479 |
+
"icon": ""},
|
| 480 |
+
"users": users,
|
| 481 |
+
"channels": channels,
|
| 482 |
+
"messages": messages,
|
| 483 |
+
"threads": {},
|
| 484 |
+
"dms": [],
|
| 485 |
+
"bookmarkedMessages": [],
|
| 486 |
+
"callHistory": [],
|
| 487 |
+
"settings": {"theme": "light", "notifications": "all",
|
| 488 |
+
"displayDensity": "comfortable", "showAvatars": True,
|
| 489 |
+
"use24Hour": False},
|
| 490 |
+
"invitations": [],
|
| 491 |
+
"notifications": [],
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
|
| 495 |
+
# ----------------------------------------------------------------------------
|
| 496 |
+
# Inject all states
|
| 497 |
+
# ----------------------------------------------------------------------------
|
| 498 |
+
STATE_BUILDERS = {
|
| 499 |
+
'salesforce': salesforce_state,
|
| 500 |
+
'notion': notion_state,
|
| 501 |
+
'slack': slack_state,
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
for name, build in STATE_BUILDERS.items():
|
| 505 |
+
url = MOCKS[name]
|
| 506 |
+
state = build()
|
| 507 |
+
resp = requests.post(f'{url}/post?sid={sid}',
|
| 508 |
+
json={'action': 'set', 'state': state}, timeout=30)
|
| 509 |
+
assert resp.status_code == 200, \
|
| 510 |
+
f'{name} injection failed: {resp.status_code} {resp.text}'
|
| 511 |
+
go = requests.get(f'{url}/go?sid={sid}', timeout=10).json()
|
| 512 |
+
assert go.get('initial_state') is not None, f'{name} initial_state is None'
|
| 513 |
+
print(f' injected {name}: initial_state OK')
|
| 514 |
+
|
| 515 |
+
print(f'All 3 mocks injected with sid={sid}')
|
| 516 |
+
|
| 517 |
+
|
| 518 |
+
# ----------------------------------------------------------------------------
|
| 519 |
+
# GUI-ready: launch Chrome on Salesforce (primary app — where the source data is)
|
| 520 |
+
# ----------------------------------------------------------------------------
|
| 521 |
+
def launch_gui(command, delay_sec=1.0):
|
| 522 |
+
env = os.environ.copy()
|
| 523 |
+
env['DISPLAY'] = ':0'
|
| 524 |
+
# Accept both a command string and a pre-split arg list (some tasks
|
| 525 |
+
# build arg lists themselves, e.g. se_hard_008).
|
| 526 |
+
if isinstance(command, str):
|
| 527 |
+
_parts = shlex.split(command)
|
| 528 |
+
else:
|
| 529 |
+
_parts = list(command)
|
| 530 |
+
# Inject CDP debug port so wait_mocks_loaded can verify browser render
|
| 531 |
+
# via Playwright connect_over_cdp. Idempotent: skip if any arg already
|
| 532 |
+
# starts with --remote-debugging-port (some tasks inject their own
|
| 533 |
+
# dynamic port, e.g. se_hard_008).
|
| 534 |
+
if _parts and 'google-chrome' in _parts[0] \
|
| 535 |
+
and not any(p.startswith('--remote-debugging-port') for p in _parts):
|
| 536 |
+
_parts[1:1] = ['--no-first-run', '--no-default-browser-check',
|
| 537 |
+
'--remote-debugging-port=1337']
|
| 538 |
+
_proc = subprocess.Popen(_parts, stdin=subprocess.DEVNULL,
|
| 539 |
+
stdout=subprocess.DEVNULL,
|
| 540 |
+
stderr=subprocess.DEVNULL, env=env,
|
| 541 |
+
start_new_session=True)
|
| 542 |
+
time.sleep(delay_sec)
|
| 543 |
+
if _proc.poll() is not None:
|
| 544 |
+
print(' WARNING: launch_gui process exited early (code=%s)'
|
| 545 |
+
% _proc.returncode)
|
| 546 |
+
return _proc
|
| 547 |
+
launch_gui(
|
| 548 |
+
f'google-chrome "{MOCKS["salesforce"]}/?sid={sid}"',
|
| 549 |
+
delay_sec=2.0,
|
| 550 |
+
)
|
| 551 |
+
_open_remaining_mock_tabs(MOCKS["salesforce"])
|
| 552 |
+
wait_mocks_loaded()
|
| 553 |
+
print(f'GUI_READY: launched browser tabs with sid={sid}')
|
legacy/ae_forecast_001/reward.py
ADDED
|
@@ -0,0 +1,524 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# --- MOCK_HOST_NO_PROXY_OVERRIDE: bypass woa proxy for locally-deployed mocks ---
|
| 2 |
+
import os as _os
|
| 3 |
+
_np = _os.environ.get("no_proxy", _os.environ.get("NO_PROXY", ""))
|
| 4 |
+
for _h in ("127.0.0.1", "localhost", "28.7.186.212"):
|
| 5 |
+
if _h not in _np:
|
| 6 |
+
_np = (_np + "," + _h).lstrip(",")
|
| 7 |
+
_os.environ["no_proxy"] = _np
|
| 8 |
+
_os.environ["NO_PROXY"] = _np
|
| 9 |
+
# --- end override ---
|
| 10 |
+
|
| 11 |
+
"""
|
| 12 |
+
Reward Script: Q3 forecast — copy 3 open Salesforce opps into Notion 'Q3 Forecast'
|
| 13 |
+
table and post a Slack #sales summary with the combined total.
|
| 14 |
+
Task ID: ae_forecast_001
|
| 15 |
+
Domain: mock_websites (multi-mock: notion_mock, slack_mock; salesforce read-only)
|
| 16 |
+
|
| 17 |
+
Scoring (all components verify task-introduced changes; each FAILS on initial_env):
|
| 18 |
+
- Component 1: Notion 'Globex - Platform Expansion' row filled (0.20)
|
| 19 |
+
amount, stage, closeDate match the Salesforce source opportunity
|
| 20 |
+
- Component 2: Notion 'Initech - Annual Renewal' row filled (0.20)
|
| 21 |
+
amount, stage, closeDate match the Salesforce source opportunity
|
| 22 |
+
- Component 3: Notion 'Soylent - New Logo' row filled (0.20)
|
| 23 |
+
amount, stage, closeDate match the Salesforce source opportunity
|
| 24 |
+
- Component 4: exactly 3 forecast rows; Closed Lost distractor (0.15)
|
| 25 |
+
'Globex - SMB Add-on' NOT added to the table
|
| 26 |
+
- Component 5: Slack #sales message by current user with combined (0.25)
|
| 27 |
+
runtime Salesforce total AND naming Globex, Initech, Soylent
|
| 28 |
+
Total = 1.0
|
| 29 |
+
|
| 30 |
+
NOTE: Salesforce opportunity data is a read-only precondition (must stay
|
| 31 |
+
unchanged); it is NOT scored. All scored items are empty/absent in initial_env.
|
| 32 |
+
"""
|
| 33 |
+
import datetime as dt
|
| 34 |
+
import json
|
| 35 |
+
import os
|
| 36 |
+
import re
|
| 37 |
+
import sys
|
| 38 |
+
|
| 39 |
+
import requests
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def _comp(idx, name, weight, passed, score, detail=""):
|
| 43 |
+
"""Emit a structured COMPONENT line for per-module scoring visibility.
|
| 44 |
+
|
| 45 |
+
Parsed by the cua_gym_reward metric to build a
|
| 46 |
+
_cua_reward_components.json sidecar alongside the captured stdout, so the
|
| 47 |
+
evaluator can report which modules were done correctly instead of only a
|
| 48 |
+
single aggregate float. Output format: ``COMPONENT: <json>``.
|
| 49 |
+
"""
|
| 50 |
+
print("COMPONENT: " + json.dumps({
|
| 51 |
+
"id": idx,
|
| 52 |
+
"name": name,
|
| 53 |
+
"weight": float(weight),
|
| 54 |
+
"passed": bool(passed),
|
| 55 |
+
"score": float(score),
|
| 56 |
+
"detail": detail,
|
| 57 |
+
}))
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
# --- Read sid (written by initial_setup.py) ---
|
| 61 |
+
try:
|
| 62 |
+
with open('/tmp/task_web_sid') as f:
|
| 63 |
+
sid = f.read().strip()
|
| 64 |
+
if not sid:
|
| 65 |
+
raise ValueError('sid is empty')
|
| 66 |
+
except Exception as e:
|
| 67 |
+
print(f'CRITICAL: Cannot read sid from /tmp/task_web_sid: {e}')
|
| 68 |
+
print('REWARD: 0.0')
|
| 69 |
+
sys.exit(0)
|
| 70 |
+
|
| 71 |
+
SALESFORCE_URL = 'http://28.7.186.212:8195'
|
| 72 |
+
NOTION_URL = 'http://28.7.186.212:8186'
|
| 73 |
+
SLACK_URL = 'http://28.7.186.212:8198'
|
| 74 |
+
|
| 75 |
+
TARGET_OPPORTUNITIES = [
|
| 76 |
+
'Globex - Platform Expansion',
|
| 77 |
+
'Initech - Annual Renewal',
|
| 78 |
+
'Soylent - New Logo',
|
| 79 |
+
]
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def fetch_state(base_url):
|
| 83 |
+
"""Fetch /go for a mock; returns (initial_state, current_state) dicts."""
|
| 84 |
+
data = requests.get(f'{base_url}/go?sid={sid}', timeout=15).json()
|
| 85 |
+
return data.get('initial_state') or {}, data.get('current_state') or {}
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
# ---------- helpers for robust property extraction ----------
|
| 89 |
+
def normalize_text(value):
|
| 90 |
+
"""Case/punctuation/spacing-insensitive text normalization."""
|
| 91 |
+
text = '' if value is None else str(value)
|
| 92 |
+
text = text.replace('&', ' and ')
|
| 93 |
+
text = re.sub(r'[\u2010-\u2015]', '-', text)
|
| 94 |
+
text = re.sub(r'[^a-zA-Z0-9]+', ' ', text.lower())
|
| 95 |
+
return re.sub(r'\s+', ' ', text).strip()
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def normalized_contains(text, needle):
|
| 99 |
+
norm_text = normalize_text(text)
|
| 100 |
+
norm_needle = normalize_text(needle)
|
| 101 |
+
return bool(norm_needle and norm_needle in norm_text)
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
def get_prop(props, *keys):
|
| 105 |
+
"""Fetch a Notion property by stable id or display name."""
|
| 106 |
+
if not isinstance(props, dict):
|
| 107 |
+
return None
|
| 108 |
+
for key in keys:
|
| 109 |
+
if key in props:
|
| 110 |
+
return props[key]
|
| 111 |
+
wanted = {normalize_text(key) for key in keys}
|
| 112 |
+
for key, value in props.items():
|
| 113 |
+
if normalize_text(key) in wanted:
|
| 114 |
+
return value
|
| 115 |
+
return None
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
def get_number(prop):
|
| 119 |
+
"""prop expected shape: {'number': <val>}; tolerate raw value too."""
|
| 120 |
+
if isinstance(prop, dict):
|
| 121 |
+
return prop.get('number')
|
| 122 |
+
return prop
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def get_select(prop):
|
| 126 |
+
"""prop expected shape: {'select': 'Stage'} or {'select': {'name': ...}}."""
|
| 127 |
+
if isinstance(prop, dict):
|
| 128 |
+
val = prop.get('select', prop)
|
| 129 |
+
else:
|
| 130 |
+
val = prop
|
| 131 |
+
if isinstance(val, dict):
|
| 132 |
+
return val.get('name')
|
| 133 |
+
return val
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def get_date_start(prop):
|
| 137 |
+
"""prop expected shape: {'date': {'start': 'YYYY-MM-DD'}} or {'date': 'YYYY-MM-DD'}."""
|
| 138 |
+
if isinstance(prop, dict):
|
| 139 |
+
val = prop.get('date', prop)
|
| 140 |
+
else:
|
| 141 |
+
val = prop
|
| 142 |
+
if isinstance(val, dict):
|
| 143 |
+
return val.get('start')
|
| 144 |
+
return val
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def parse_amount(value):
|
| 148 |
+
"""Parse common money/number formats such as $225,000, 225k, or 225000."""
|
| 149 |
+
if value is None:
|
| 150 |
+
return None
|
| 151 |
+
if isinstance(value, (int, float)):
|
| 152 |
+
return float(value)
|
| 153 |
+
text = str(value).strip().lower()
|
| 154 |
+
if not text:
|
| 155 |
+
return None
|
| 156 |
+
mult = 1
|
| 157 |
+
if re.search(r'\b(k|thousand)\b', text):
|
| 158 |
+
mult = 1000
|
| 159 |
+
text = re.sub(r'[$,\s]', '', text)
|
| 160 |
+
text = re.sub(r'(usd|dollars?|k|thousand)', '', text)
|
| 161 |
+
match = re.search(r'-?\d+(?:\.\d+)?', text)
|
| 162 |
+
if not match:
|
| 163 |
+
return None
|
| 164 |
+
return float(match.group(0)) * mult
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
def amounts_equal(actual, expected):
|
| 168 |
+
actual_num = parse_amount(actual)
|
| 169 |
+
expected_num = parse_amount(expected)
|
| 170 |
+
return actual_num is not None and expected_num is not None and abs(actual_num - expected_num) < 0.01
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
def normalize_stage(value):
|
| 174 |
+
norm = normalize_text(value)
|
| 175 |
+
aliases = {
|
| 176 |
+
'value prop': 'value proposition',
|
| 177 |
+
'value proposition': 'value proposition',
|
| 178 |
+
'proposal quote': 'proposal',
|
| 179 |
+
'proposal': 'proposal',
|
| 180 |
+
'negotiating': 'negotiation',
|
| 181 |
+
'negotiation review': 'negotiation',
|
| 182 |
+
'negotiation': 'negotiation',
|
| 183 |
+
}
|
| 184 |
+
return aliases.get(norm, norm)
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def parse_date(value):
|
| 188 |
+
"""Return a date object from common UI/API date strings."""
|
| 189 |
+
if value is None:
|
| 190 |
+
return None
|
| 191 |
+
if isinstance(value, dt.datetime):
|
| 192 |
+
return value.date()
|
| 193 |
+
if isinstance(value, dt.date):
|
| 194 |
+
return value
|
| 195 |
+
if isinstance(value, dict):
|
| 196 |
+
for key in ('start', 'date', 'value'):
|
| 197 |
+
parsed = parse_date(value.get(key))
|
| 198 |
+
if parsed:
|
| 199 |
+
return parsed
|
| 200 |
+
return None
|
| 201 |
+
|
| 202 |
+
text = str(value).strip()
|
| 203 |
+
if not text:
|
| 204 |
+
return None
|
| 205 |
+
text = re.sub(r'(\d)(st|nd|rd|th)\b', r'\1', text, flags=re.I)
|
| 206 |
+
iso_text = text.replace('Z', '+00:00')
|
| 207 |
+
try:
|
| 208 |
+
return dt.datetime.fromisoformat(iso_text).date()
|
| 209 |
+
except ValueError:
|
| 210 |
+
pass
|
| 211 |
+
if 'T' in text:
|
| 212 |
+
text = text.split('T', 1)[0]
|
| 213 |
+
for fmt in (
|
| 214 |
+
'%Y-%m-%d',
|
| 215 |
+
'%Y/%m/%d',
|
| 216 |
+
'%m/%d/%Y',
|
| 217 |
+
'%m/%d/%y',
|
| 218 |
+
'%b %d, %Y',
|
| 219 |
+
'%B %d, %Y',
|
| 220 |
+
'%d %b %Y',
|
| 221 |
+
'%d %B %Y',
|
| 222 |
+
):
|
| 223 |
+
try:
|
| 224 |
+
return dt.datetime.strptime(text, fmt).date()
|
| 225 |
+
except ValueError:
|
| 226 |
+
continue
|
| 227 |
+
return None
|
| 228 |
+
|
| 229 |
+
|
| 230 |
+
def dates_equal(actual, expected):
|
| 231 |
+
actual_date = parse_date(actual)
|
| 232 |
+
expected_date = parse_date(expected)
|
| 233 |
+
return (
|
| 234 |
+
actual_date is not None
|
| 235 |
+
and expected_date is not None
|
| 236 |
+
and (actual_date.year, actual_date.month, actual_date.day)
|
| 237 |
+
== (expected_date.year, expected_date.month, expected_date.day)
|
| 238 |
+
)
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
def row_matches(props, expected):
|
| 242 |
+
"""Return True only if amount, stage AND close date all match the source opp."""
|
| 243 |
+
exp_amount = expected.get('amount')
|
| 244 |
+
exp_stage = expected.get('stage')
|
| 245 |
+
exp_date = expected.get('closeDate')
|
| 246 |
+
amt = get_number(get_prop(props, 'prop_amt', 'Amount'))
|
| 247 |
+
stage = get_select(get_prop(props, 'prop_stage', 'Stage'))
|
| 248 |
+
date = get_date_start(get_prop(props, 'prop_date', 'Close Date'))
|
| 249 |
+
amt_ok = amounts_equal(amt, exp_amount)
|
| 250 |
+
stage_ok = normalize_stage(stage) == normalize_stage(exp_stage)
|
| 251 |
+
date_ok = dates_equal(date, exp_date)
|
| 252 |
+
print(f' amount={amt} (exp {exp_amount}, {"ok" if amt_ok else "BAD"}), '
|
| 253 |
+
f'stage={stage!r} (exp {exp_stage!r}, {"ok" if stage_ok else "BAD"}), '
|
| 254 |
+
f'date={date!r} (exp {exp_date!r}, {"ok" if date_ok else "BAD"})')
|
| 255 |
+
return amt_ok and stage_ok and date_ok
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
def find_row(pages, title):
|
| 259 |
+
"""Find a database row page whose title matches despite case/punctuation."""
|
| 260 |
+
for pid, page in pages.items():
|
| 261 |
+
if not isinstance(page, dict):
|
| 262 |
+
continue
|
| 263 |
+
if page.get('parentId') != 'db-q3-forecast':
|
| 264 |
+
continue
|
| 265 |
+
props = page.get('properties', {})
|
| 266 |
+
t = page.get('title') or get_prop(props, 'prop_opp', 'Opportunity')
|
| 267 |
+
if isinstance(t, dict):
|
| 268 |
+
t = t.get('title') or t.get('name') or t.get('plain_text')
|
| 269 |
+
if t and normalize_text(t) == normalize_text(title):
|
| 270 |
+
return page
|
| 271 |
+
return None
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
def is_open_stage(stage):
|
| 275 |
+
return normalize_stage(stage) not in {'closed won', 'closed lost'}
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
def get_expected_opportunities(salesforce_state):
|
| 279 |
+
opportunities = salesforce_state.get('opportunities', [])
|
| 280 |
+
accounts = {
|
| 281 |
+
account.get('accountId'): account.get('name')
|
| 282 |
+
for account in salesforce_state.get('accounts', [])
|
| 283 |
+
if isinstance(account, dict)
|
| 284 |
+
}
|
| 285 |
+
expected = {}
|
| 286 |
+
for target_name in TARGET_OPPORTUNITIES:
|
| 287 |
+
target_norm = normalize_text(target_name)
|
| 288 |
+
for opp in opportunities:
|
| 289 |
+
if not isinstance(opp, dict):
|
| 290 |
+
continue
|
| 291 |
+
if normalize_text(opp.get('name')) != target_norm:
|
| 292 |
+
continue
|
| 293 |
+
if not is_open_stage(opp.get('stage')):
|
| 294 |
+
continue
|
| 295 |
+
opp_copy = dict(opp)
|
| 296 |
+
opp_copy['accountName'] = accounts.get(opp.get('accountId'), '')
|
| 297 |
+
expected[target_name] = opp_copy
|
| 298 |
+
break
|
| 299 |
+
return expected
|
| 300 |
+
|
| 301 |
+
|
| 302 |
+
def channel_id_for(slack_state, name):
|
| 303 |
+
for channel in slack_state.get('channels', []) or []:
|
| 304 |
+
if isinstance(channel, dict) and normalize_text(channel.get('name')) == normalize_text(name):
|
| 305 |
+
return channel.get('channelId') or channel.get('name')
|
| 306 |
+
return name
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
def content_has_amount(content, expected_amount):
|
| 310 |
+
expected_num = parse_amount(expected_amount)
|
| 311 |
+
if expected_num is None:
|
| 312 |
+
return False
|
| 313 |
+
compact = re.sub(r'[,$\s]', '', str(content).lower())
|
| 314 |
+
if str(int(expected_num)) in compact:
|
| 315 |
+
return True
|
| 316 |
+
for match in re.finditer(
|
| 317 |
+
r'\$?\s*(-?\d+(?:[,\s]\d{3})*(?:\.\d+)?|-?\d+(?:\.\d+)?)\s*(k|thousand|usd|dollars?)?',
|
| 318 |
+
str(content),
|
| 319 |
+
flags=re.I,
|
| 320 |
+
):
|
| 321 |
+
num = parse_amount(''.join(part or '' for part in match.groups()))
|
| 322 |
+
if num is not None and abs(num - expected_num) < 0.01:
|
| 323 |
+
return True
|
| 324 |
+
return False
|
| 325 |
+
|
| 326 |
+
|
| 327 |
+
def account_aliases(opp):
|
| 328 |
+
aliases = []
|
| 329 |
+
account_name = opp.get('accountName')
|
| 330 |
+
if account_name:
|
| 331 |
+
aliases.append(account_name)
|
| 332 |
+
aliases.append(re.sub(r'\b(corporation|corp|llc|inc|industries|ltd)\b', '', account_name, flags=re.I))
|
| 333 |
+
opp_name = opp.get('name')
|
| 334 |
+
if opp_name:
|
| 335 |
+
aliases.append(str(opp_name).split('-', 1)[0])
|
| 336 |
+
return [alias for alias in aliases if normalize_text(alias)]
|
| 337 |
+
|
| 338 |
+
|
| 339 |
+
def content_mentions_all_accounts(content, expected_opps):
|
| 340 |
+
for opp in expected_opps.values():
|
| 341 |
+
aliases = account_aliases(opp)
|
| 342 |
+
if not any(normalized_contains(content, alias) for alias in aliases):
|
| 343 |
+
return False
|
| 344 |
+
return True
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
def verify_task():
|
| 348 |
+
total_score = 0.0
|
| 349 |
+
|
| 350 |
+
# --- Fetch Salesforce + Notion + Slack state ---
|
| 351 |
+
try:
|
| 352 |
+
salesforce_init, _ = fetch_state(SALESFORCE_URL)
|
| 353 |
+
expected_opps = get_expected_opportunities(salesforce_init)
|
| 354 |
+
missing = [name for name in TARGET_OPPORTUNITIES if name not in expected_opps]
|
| 355 |
+
if missing:
|
| 356 |
+
raise ValueError(f'missing open source opportunities: {missing}')
|
| 357 |
+
except Exception as e:
|
| 358 |
+
print(f'CRITICAL: cannot build expected values from Salesforce state: {e}')
|
| 359 |
+
print('REWARD: 0.0')
|
| 360 |
+
return 0.0
|
| 361 |
+
try:
|
| 362 |
+
_, notion_cur = fetch_state(NOTION_URL)
|
| 363 |
+
except Exception as e:
|
| 364 |
+
print(f'CRITICAL: cannot fetch Notion state: {e}')
|
| 365 |
+
print('REWARD: 0.0')
|
| 366 |
+
return 0.0
|
| 367 |
+
try:
|
| 368 |
+
slack_init, slack_cur = fetch_state(SLACK_URL)
|
| 369 |
+
except Exception as e:
|
| 370 |
+
print(f'CRITICAL: cannot fetch Slack state: {e}')
|
| 371 |
+
print('REWARD: 0.0')
|
| 372 |
+
return 0.0
|
| 373 |
+
|
| 374 |
+
notion_pages = notion_cur.get('pages', {}) if isinstance(notion_cur, dict) else {}
|
| 375 |
+
|
| 376 |
+
# Component 1: Globex row filled (0.20)
|
| 377 |
+
try:
|
| 378 |
+
row = find_row(notion_pages, 'Globex - Platform Expansion')
|
| 379 |
+
if row is None:
|
| 380 |
+
print('FAIL: Component 1 — Globex row not found')
|
| 381 |
+
_comp(1, 'Globex row filled', 0.20, False, 0.0, 'row not found')
|
| 382 |
+
else:
|
| 383 |
+
print('CHECK Component 1 — Globex - Platform Expansion:')
|
| 384 |
+
if row_matches(row.get('properties', {}),
|
| 385 |
+
expected_opps['Globex - Platform Expansion']):
|
| 386 |
+
print('PASS: Component 1 — Globex row fully correct (0.20 pts)')
|
| 387 |
+
total_score += 0.20
|
| 388 |
+
_comp(1, 'Globex row filled', 0.20, True, 0.20,
|
| 389 |
+
'amount/stage/date ok')
|
| 390 |
+
else:
|
| 391 |
+
print('FAIL: Component 1 — Globex row values incorrect')
|
| 392 |
+
_comp(1, 'Globex row filled', 0.20, False, 0.0,
|
| 393 |
+
'values incorrect')
|
| 394 |
+
except Exception as e:
|
| 395 |
+
print(f'ERROR: Component 1 — {e}')
|
| 396 |
+
_comp(1, 'Globex row filled', 0.20, False, 0.0, f'error: {e}')
|
| 397 |
+
|
| 398 |
+
# Component 2: Initech row filled (0.20)
|
| 399 |
+
try:
|
| 400 |
+
row = find_row(notion_pages, 'Initech - Annual Renewal')
|
| 401 |
+
if row is None:
|
| 402 |
+
print('FAIL: Component 2 — Initech row not found')
|
| 403 |
+
_comp(2, 'Initech row filled', 0.20, False, 0.0, 'row not found')
|
| 404 |
+
else:
|
| 405 |
+
print('CHECK Component 2 — Initech - Annual Renewal:')
|
| 406 |
+
if row_matches(row.get('properties', {}),
|
| 407 |
+
expected_opps['Initech - Annual Renewal']):
|
| 408 |
+
print('PASS: Component 2 — Initech row fully correct (0.20 pts)')
|
| 409 |
+
total_score += 0.20
|
| 410 |
+
_comp(2, 'Initech row filled', 0.20, True, 0.20,
|
| 411 |
+
'amount/stage/date ok')
|
| 412 |
+
else:
|
| 413 |
+
print('FAIL: Component 2 — Initech row values incorrect')
|
| 414 |
+
_comp(2, 'Initech row filled', 0.20, False, 0.0,
|
| 415 |
+
'values incorrect')
|
| 416 |
+
except Exception as e:
|
| 417 |
+
print(f'ERROR: Component 2 — {e}')
|
| 418 |
+
_comp(2, 'Initech row filled', 0.20, False, 0.0, f'error: {e}')
|
| 419 |
+
|
| 420 |
+
# Component 3: Soylent row filled (0.20)
|
| 421 |
+
try:
|
| 422 |
+
row = find_row(notion_pages, 'Soylent - New Logo')
|
| 423 |
+
if row is None:
|
| 424 |
+
print('FAIL: Component 3 — Soylent row not found')
|
| 425 |
+
_comp(3, 'Soylent row filled', 0.20, False, 0.0, 'row not found')
|
| 426 |
+
else:
|
| 427 |
+
print('CHECK Component 3 — Soylent - New Logo:')
|
| 428 |
+
if row_matches(row.get('properties', {}),
|
| 429 |
+
expected_opps['Soylent - New Logo']):
|
| 430 |
+
print('PASS: Component 3 — Soylent row fully correct (0.20 pts)')
|
| 431 |
+
total_score += 0.20
|
| 432 |
+
_comp(3, 'Soylent row filled', 0.20, True, 0.20,
|
| 433 |
+
'amount/stage/date ok')
|
| 434 |
+
else:
|
| 435 |
+
print('FAIL: Component 3 — Soylent row values incorrect')
|
| 436 |
+
_comp(3, 'Soylent row filled', 0.20, False, 0.0,
|
| 437 |
+
'values incorrect')
|
| 438 |
+
except Exception as e:
|
| 439 |
+
print(f'ERROR: Component 3 — {e}')
|
| 440 |
+
_comp(3, 'Soylent row filled', 0.20, False, 0.0, f'error: {e}')
|
| 441 |
+
|
| 442 |
+
# Component 4: exactly 3 forecast rows; Closed Lost distractor NOT added (0.15)
|
| 443 |
+
# This anchors to the task change: rows are only "complete" (filled) in golden,
|
| 444 |
+
# and we additionally guard that the agent did not add a 4th row for the
|
| 445 |
+
# Closed Lost 'Globex - SMB Add-on' distractor.
|
| 446 |
+
try:
|
| 447 |
+
db = notion_pages.get('db-q3-forecast', {})
|
| 448 |
+
items = db.get('items', []) if isinstance(db, dict) else []
|
| 449 |
+
# rows actually parented to the forecast DB
|
| 450 |
+
child_rows = [p for p in notion_pages.values()
|
| 451 |
+
if isinstance(p, dict) and p.get('parentId') == 'db-q3-forecast']
|
| 452 |
+
titles = [normalize_text(p.get('title', '')) for p in child_rows]
|
| 453 |
+
distractor_present = any(normalized_contains(t, 'smb add on') for t in titles)
|
| 454 |
+
# Require: at least one row already correctly filled (a real task change),
|
| 455 |
+
# exactly 3 rows, and no distractor row.
|
| 456 |
+
any_filled = total_score > 0
|
| 457 |
+
comp4_ok = (any_filled and len(items) == 3
|
| 458 |
+
and len(child_rows) == 3 and not distractor_present)
|
| 459 |
+
if comp4_ok:
|
| 460 |
+
total_score += 0.15
|
| 461 |
+
print('PASS: Component 4 — exactly 3 rows, no Closed Lost distractor '
|
| 462 |
+
'(0.15 pts)')
|
| 463 |
+
_comp(4, 'exactly 3 rows, no distractor', 0.15, True, 0.15,
|
| 464 |
+
'items=3, child_rows=3, no distractor')
|
| 465 |
+
else:
|
| 466 |
+
print(f'FAIL: Component 4 — items={len(items)}, child_rows='
|
| 467 |
+
f'{len(child_rows)}, distractor_present={distractor_present}, '
|
| 468 |
+
f'any_filled={any_filled}')
|
| 469 |
+
_comp(4, 'exactly 3 rows, no distractor', 0.15, False, 0.0,
|
| 470 |
+
f'items={len(items)}, child_rows={len(child_rows)}, '
|
| 471 |
+
f'distractor={distractor_present}, any_filled={any_filled}')
|
| 472 |
+
except Exception as e:
|
| 473 |
+
print(f'ERROR: Component 4 — {e}')
|
| 474 |
+
_comp(4, 'exactly 3 rows, no distractor', 0.15, False, 0.0,
|
| 475 |
+
f'error: {e}')
|
| 476 |
+
|
| 477 |
+
# Component 5: Slack #sales message with runtime total + 3 accounts (0.25)
|
| 478 |
+
try:
|
| 479 |
+
sales_channel_id = channel_id_for(slack_cur, 'sales')
|
| 480 |
+
init_messages = slack_init.get('messages', {}) or {}
|
| 481 |
+
cur_messages = slack_cur.get('messages', {}) or {}
|
| 482 |
+
init_msgs = init_messages.get(sales_channel_id, init_messages.get('sales', []))
|
| 483 |
+
cur_msgs = cur_messages.get(sales_channel_id, cur_messages.get('sales', []))
|
| 484 |
+
init_ids = {m.get('messageId') for m in init_msgs}
|
| 485 |
+
new_msgs = [m for m in cur_msgs
|
| 486 |
+
if m.get('messageId') not in init_ids
|
| 487 |
+
or not m.get('messageId')]
|
| 488 |
+
expected_sender = (slack_cur.get('currentUser', {}) or {}).get('userId', 'user_1')
|
| 489 |
+
total_amount = sum(parse_amount(opp.get('amount')) or 0 for opp in expected_opps.values())
|
| 490 |
+
match = None
|
| 491 |
+
for m in new_msgs:
|
| 492 |
+
content = str(m.get('content', ''))
|
| 493 |
+
sender = m.get('senderId')
|
| 494 |
+
has_total = content_has_amount(content, total_amount)
|
| 495 |
+
has_accounts = content_mentions_all_accounts(content, expected_opps)
|
| 496 |
+
mentions_distractor = normalized_contains(content, 'Globex SMB Add-on')
|
| 497 |
+
if (sender == expected_sender and has_total and has_accounts
|
| 498 |
+
and not mentions_distractor):
|
| 499 |
+
match = m
|
| 500 |
+
break
|
| 501 |
+
if match:
|
| 502 |
+
print(f'PASS: Component 5 — Slack #sales update by current user with '
|
| 503 |
+
f'${total_amount:,.0f} and all three accounts (0.25 pts)')
|
| 504 |
+
total_score += 0.25
|
| 505 |
+
_comp(5, 'Slack #sales message with total + 3 accounts', 0.25,
|
| 506 |
+
True, 0.25, 'sender + total + three accounts')
|
| 507 |
+
else:
|
| 508 |
+
print(f'FAIL: Component 5 — no qualifying new #sales message '
|
| 509 |
+
f'(new msgs: {len(new_msgs)}; need sender + total '
|
| 510 |
+
f'{total_amount:g} + three accounts)')
|
| 511 |
+
_comp(5, 'Slack #sales message with total + 3 accounts', 0.25,
|
| 512 |
+
False, 0.0, f'new msgs={len(new_msgs)}, no qualifying message')
|
| 513 |
+
except Exception as e:
|
| 514 |
+
print(f'ERROR: Component 5 �� {e}')
|
| 515 |
+
_comp(5, 'Slack #sales message with total + 3 accounts', 0.25,
|
| 516 |
+
False, 0.0, f'error: {e}')
|
| 517 |
+
|
| 518 |
+
final_score = round(min(total_score, 1.0), 4)
|
| 519 |
+
print(f'\nScore: {total_score}/1.0')
|
| 520 |
+
print(f'REWARD: {final_score}')
|
| 521 |
+
return final_score
|
| 522 |
+
|
| 523 |
+
|
| 524 |
+
verify_task()
|
legacy/ae_forecast_001/reward_label.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"reward_file": "/apdcephfs_sh2/share_300000800/user/jackwkwang/long-horizon-tasks/mini_osworld_xiangwu/cache/ae_forecast_001/reward.py",
|
| 3 |
+
"api_url": "http://28.7.184.184:8000/v1/chat/completions",
|
| 4 |
+
"model": "Kimi-K2.6",
|
| 5 |
+
"max_code_chars": 100000,
|
| 6 |
+
"created_at": "2026-07-03 18:50:07",
|
| 7 |
+
"label": {
|
| 8 |
+
"task_id": "ae_forecast_001",
|
| 9 |
+
"domain": "mock_websites",
|
| 10 |
+
"summary": "验证将3个开放的Salesforce机会复制到Notion的Q3 Forecast表格,并在Slack #sales频道发布包含实时合计金额与三个客户名称的摘要消息",
|
| 11 |
+
"is_placeholder": false,
|
| 12 |
+
"data_sources": [
|
| 13 |
+
"/tmp/task_web_sid",
|
| 14 |
+
"salesforce_mock (http://28.7.186.212:8195)",
|
| 15 |
+
"notion_mock (http://28.7.186.212:8186)",
|
| 16 |
+
"slack_mock (http://28.7.186.212:8198)"
|
| 17 |
+
],
|
| 18 |
+
"scoring_components": [
|
| 19 |
+
{
|
| 20 |
+
"name": "Component 1",
|
| 21 |
+
"weight": 0.2,
|
| 22 |
+
"description": "Notion中'Globex - Platform Expansion'行已正确填充",
|
| 23 |
+
"check_logic": "调用find_row在notion_pages中查找parentId为'db-q3-forecast'且标题归一化后匹配'Globex - Platform Expansion'的页面;若找到,使用row_matches对比其properties中的Amount(prop_amt/Amount)、Stage(prop_stage/Stage)、Close Date(prop_date/Close Date)是否与Salesforce源机会一致(amounts_equal、normalize_stage、dates_equal)",
|
| 24 |
+
"pass_condition": "存在匹配行且amount、stage、closeDate三项均与Salesforce源数据匹配"
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"name": "Component 2",
|
| 28 |
+
"weight": 0.2,
|
| 29 |
+
"description": "Notion中'Initech - Annual Renewal'行已正确填充",
|
| 30 |
+
"check_logic": "与Component 1相同,查找标题匹配'Initech - Annual Renewal'的行并校验amount、stage、closeDate",
|
| 31 |
+
"pass_condition": "存在匹配行且三项属性均与Salesforce源数据匹配"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"name": "Component 3",
|
| 35 |
+
"weight": 0.2,
|
| 36 |
+
"description": "Notion中'Soylent - New Logo'行已正确填充",
|
| 37 |
+
"check_logic": "与Component 1相同,查找标题匹配'Soylent - New Logo'的行并校验amount、stage、closeDate",
|
| 38 |
+
"pass_condition": "存在匹配行且三项属性均与Salesforce源数据匹配"
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"name": "Component 4",
|
| 42 |
+
"weight": 0.15,
|
| 43 |
+
"description": "Notion Q3 Forecast表格恰好有3行且未添加Closed Lost干扰项",
|
| 44 |
+
"check_logic": "检查notion_pages中'db-q3-forecast'的items长度为3;统计parentId为'db-q3-forecast'的child_rows数量为3;检查所有子行标题归一化后不含'smb add on';且要求前面至少有一个组件已通过(any_filled = total_score > 0)",
|
| 45 |
+
"pass_condition": "items==3、child_rows==3、无distractor且any_filled为真"
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"name": "Component 5",
|
| 49 |
+
"weight": 0.25,
|
| 50 |
+
"description": "Slack #sales频道由当前用户发送包含合计金额与三个账户名称的新消息",
|
| 51 |
+
"check_logic": "获取#sales频道初始与当前消息,筛选出messageId不在初始集合中的new_msgs;计算三个预期机会的amount总和total_amount;遍历新消息,检查senderId等于当前用户、content_has_amount匹配total_amount、content_mentions_all_accounts提及Globex/Initech/Soylent三个账户、且不包含'Globex SMB Add-on'干扰项",
|
| 52 |
+
"pass_condition": "存在一条由当前用户发送的新消息,内容包含实时总金额、提及全部三个账户且不提及干扰项"
|
| 53 |
+
}
|
| 54 |
+
],
|
| 55 |
+
"total_max_score": 1.0,
|
| 56 |
+
"score_aggregation": "各组件分数累加,最终用 min(total_score, 1.0) 钳制到上限 1.0,并四舍五入保留4位小数",
|
| 57 |
+
"failure_modes": [
|
| 58 |
+
"读取 /tmp/task_web_sid 失败或为空:打印 CRITICAL,返回 0.0",
|
| 59 |
+
"从 Salesforce 拉取状态失败或缺少目标开放机会:打印 CRITICAL,返回 0.0",
|
| 60 |
+
"从 Notion 拉取状态失败:打印 CRITICAL,返回 0.0",
|
| 61 |
+
"从 Slack 拉取状态失败:打印 CRITICAL,返回 0.0",
|
| 62 |
+
"各组件单独失败时仅该组件得 0 分,不会导致整体提前退出(Critical 路径除外)"
|
| 63 |
+
],
|
| 64 |
+
"scoring_logic_explanation": "脚本首先读取 /tmp/task_web_sid 获取会话ID,失败则直接返回0.0。随后并行(按代码顺序)从Salesforce、Notion、Slack三个mock服务拉取状态:Salesforce取初始状态以构建3个目标开放机会的预期值(amount/stage/closeDate),若缺失则直接返回0.0;Notion取当前状态用于检查表格行;Slack取初始和当前状态用于检测新消息。接着逐项评分:组件1-3分别在Notion的Q3 Forecast数据库(parentId='db-q3-forecast')中查找指定标题行,使用容错逻辑(金额解析、阶段别名归一化、多格式日期解析)对比Amount、Stage、Close Date是否与Salesforce源数据一致,每项正确加0.20分。组件4检查该数据库的items数量和实际子行数量均恰好为3,且不存在标题含'smb add on'的Closed Lost干扰项,同时要求前面至少有一行已正确填充(any_filled),满���加0.15分。组件5在Slack #sales频道中筛选当前用户发送的新消息,验证消息内容包含三个机会的实时计算总金额、提及全部三个账户名称(Globex、Initech、Soylent),且不包含干扰项'Globex SMB Add-on',满足加0.25分。最终汇总得分,经min(score, 1.0)钳制并四舍五入到4位小数后返回。",
|
| 65 |
+
"confidence": 1.0
|
| 66 |
+
},
|
| 67 |
+
"raw_response": "用户要求我分析一个 reward.py 评分脚本的评分逻辑,并输出一个严格的 JSON 对象。\n\n让我仔细阅读代码并提取所需信息:\n\n1. **task_id**: 从 docstring 中可以看到 \"Task ID: ae_forecast_001\"\n2. **domain**: 从 docstring 中可以看到 \"Domain: mock_websites (multi-mock: notion_mock, slack_mock; salesforce read-only)\"\n3. **summary**: 一句话概括:验证将3个开放的Salesforce机会复制到Notion的Q3 Forecast表格,并在Slack #sales频道发布包含合计金额和三个客户名称的摘要消息。\n4. **is_placeholder**: false,因为脚本有详细的验证逻辑,不是占位脚本。\n5. **data_sources**: \n - /tmp/task_web_sid (读取sid)\n - salesforce_mock (通过 http://28.7.186.212:8195)\n - notion_mock (通过 http://28.7.186.212:8186)\n - slack_mock (通过 http://28.7.186.212:8198)\n\n6. **scoring_components**:\n - Component 1: Notion 'Globex - Platform Expansion' row filled (0.20)\n - Component 2: Notion 'Initech - Annual Renewal' row filled (0.20)\n - Component 3: Notion 'Soylent - New Logo' row filled (0.20)\n - Component 4: exactly 3 forecast rows; Closed Lost distractor NOT added (0.15)\n - Component 5: Slack #sales message by current user with combined runtime Salesforce total AND naming Globex, Initech, Soylent (0.25)\n\n每个组件的详细逻辑:\n- Component 1: 查找 Notion 中 parentId 为 'db-q3-forecast' 且标题匹配 'Globex - Platform Expansion' 的行,检查 amount、stage、closeDate 是否与 Salesforce 源机会匹配。\n- Component 2: 同上,检查 'Initech - Annual Renewal'。\n- Component 3: 同上,检查 'Soylent - New Logo'。\n- Component 4: 检查 notion_pages 中 db-q3-forecast 的 items 数量为 3,child_rows(parentId 为 db-q3-forecast 的页面)数量为 3,且不存在标题包含 'smb add on' 的 distractor 行。同时要求至少有一个前面的组件已填充(any_filled = total_score > 0)。\n- Component 5: 检查 Slack #sales 频道中由当前用户发送的新消息,消息内容需包含三个机会的总金额(运行时计算),并提及所有三个账户(Globex, Initech, Soylent),且不能提及 distractor 'Globex SMB Add-on'。\n\n7. **total_max_score**: 1.0\n8. **score_aggregation**: 各组件分数相加,最终用 min(total_score, 1.0) 钳制到上限 1.0,并四舍五入到4位小数。\n9. **failure_modes**:\n - 读取 /tmp/task_web_sid 失败或为空:打印 CRITICAL 并返回 0.0\n - 从 Salesforce 获取状态失败或缺少目标机会:打印 CRITICAL 并返回 0.0\n - 从 Notion 获取状态失败:打印 CRITICAL 并返回 0.0\n - 从 Slack 获取状态失败:打印 CRITICAL 并返回 0.0\n - 各组件单独失败时只扣该组件分数,不会导致整体 0.0(除非前面 critical 退出)\n\n10. **scoring_logic_explanation**: 详细中文解释,按执行顺序:\n - 首先读取 /tmp/task_web_sid 获取会话 ID,失败则直接返回 0.0。\n - 然后依次从三个 mock 服务获取状态:Salesforce(只读,获取初始状态以确定预期值)、Notion(获取当前状态)、Slack(获取初始和当前状态以检测新消息)。\n - 如果无法从 Salesforce 构建预期机会列表(缺少3个目标开放机会),直接返回 0.0。\n - 组件1-3:在 Notion 的 Q3 Forecast 数据库(parentId='db-q3-forecast')中分别查找三个指定标题的行,对比 Amount、Stage、Close Date 是否与 Salesforce 源数据一致(使用金额解析、阶段别名归一化、日期解析等容错逻辑)。一致则加 0.20 分。\n - 组件4:检查 Notion 中该数据库的 items 数量和实际子行数量都恰好为 3,且不存在标题包含 \"smb add on\" 的干扰项(Closed Lost distractor),同时要求前面至少有一个行已正确填充(any_filled)。满足则加 0.15 分。\n - 组件5:在 Slack #sales 频道中找出当前用户发送的新消息,检查消息内容是否包含三个机会的实时计算总金额,是否提及全部三个账户名称(Globex、Initech、Soylent),且不包含干扰项 \"Globex SMB Add-on\"。满足则加 0.25 分。\n - 最终汇总各组件得分,用 min(score, 1.0) 钳制上限,四舍五入到4位小数后返回。\n\n11. **confidence**: 1.0(代码逻辑清晰完整)\n\n让我再仔细检查一下 Component 4 的 any_filled 条件。代码中是 `any_filled = total_score > 0`,这里的 total_score 是前面三个组件累加后的值。所以 Component 4 要求至少前面有一个行是正确的。\n\nComponent 5 的 total_amount 是运行时计算的:`sum(parse_amount(opp.get('amount')) or 0 for opp in expected_opps.values())`\n\nSlack 消息检测:比较 init_msgs 和 cur_msgs,找出 messageId 不在 init_ids 中的新消息。\n\n所有字符串 value 使用中文,但 task_id、domain、字段名、代码标识符保留原样。\n\nJSON 格式要求:不要 Markdown 代码块,第一个字符是 {,最后一个字符是 }。\n\n让我构建 JSON。 </think> {\"task_id\":\"ae_forecast_001\",\"domain\":\"mock_websites\",\"summary\":\"验证将3个开放的Salesforce机会复制到Notion的Q3 Forecast表格,并在Slack #sales频道发布包含实时合计金额与三个客户名称的摘要消息\",\"is_placeholder\":false,\"data_sources\":[\"/tmp/task_web_sid\",\"salesforce_mock (http://28.7.186.212:8195)\",\"notion_mock (http://28.7.186.212:8186)\",\"slack_mock (http://28.7.186.212:8198)\"],\"scoring_components\":[{\"name\":\"Component 1\",\"weight\":0.2,\"description\":\"Notion中'Globex - Platform Expansion'行已正确填充\",\"check_logic\":\"调用find_row在notion_pages中查找parentId为'db-q3-forecast'且标题归一化后匹配'Globex - Platform Expansion'的页面;若找到,使用row_matches对比其properties中的Amount(prop_amt/Amount)、Stage(prop_stage/Stage)、Close Date(prop_date/Close Date)是否与Salesforce源机会一致(amounts_equal、normalize_stage、dates_equal)\",\"pass_condition\":\"存在匹配行且amount、stage、closeDate三项均与Salesforce源数据匹配\"},{\"name\":\"Component 2\",\"weight\":0.2,\"description\":\"Notion中'Initech - Annual Renewal'行已正确填充\",\"check_logic\":\"与Component 1相同,查找标题匹配'Initech - Annual Renewal'的行并校验amount、stage、closeDate\",\"pass_condition\":\"存在匹配行且三项属性均与Salesforce源数据匹配\"},{\"name\":\"Component 3\",\"weight\":0.2,\"description\":\"Notion中'Soylent - New Logo'行已正确填充\",\"check_logic\":\"与Component 1相同,查找标题匹配'Soylent - New Logo'的行并校验amount、stage、closeDate\",\"pass_condition\":\"存在匹配行且三项属性均与Salesforce源数据匹配\"},{\"name\":\"Component 4\",\"weight\":0.15,\"description\":\"Notion Q3 Forecast表格恰好有3行且未添加Closed Lost干扰项\",\"check_logic\":\"检查notion_pages中'db-q3-forecast'的items长度为3;统计parentId为'db-q3-forecast'的child_rows数量为3;检查所有子行标题归一化后不含'smb add on';且要求前面至少有一个组件已通过(any_filled = total_score > 0)\",\"pass_condition\":\"items==3、child_rows==3、无distractor且any_filled为真\"},{\"name\":\"Component 5\",\"weight\":0.25,\"description\":\"Slack #sales频道由当前用户发送包含合计金额与三个账户名称的新消息\",\"check_logic\":\"获取#sales频道初始与当前消息,筛选出messageId不在初始集合中的new_msgs;计算三个预期机会的amount总和total_amount;遍历新消息,检查senderId等于当前用户、content_has_amount匹配total_amount、content_mentions_all_accounts提及Globex/Initech/Soylent三个账户、且不包含'Globex SMB Add-on'干扰项\",\"pass_condition\":\"存在一条由当前用户发送的新消息,内容包含实时总金额、提及全部三个账户且不提及干扰项\"}],\"total_max_score\":1.0,\"score_aggregation\":\"各组件分数累加,最终用 min(total_score, 1.0) 钳制到上限 1.0,并四舍五入保留4位小数\",\"failure_modes\":[\"读取 /tmp/task_web_sid 失败或为空:打印 CRITICAL,返回 0.0\",\"从 Salesforce 拉取状态失败或缺少目标开放机会:打印 CRITICAL,返回 0.0\",\"从 Notion 拉取状态失败:打印 CRITICAL,返回 0.0\",\"从 Slack 拉取状态失败:打印 CRITICAL,返回 0.0\",\"各组件单独失败时仅该组件得 0 分,不会导致整体提前退出(Critical 路径除外)\"],\"scoring_logic_explanation\":\"脚本首先读取 /tmp/task_web_sid 获取会话ID,失败则直接返回0.0。随后并行(按代码顺序)从Salesforce、Notion、Slack三个mock服务拉取状态:Salesforce取初始状态以构建3个目标开放机会的预期值(amount/stage/closeDate),若缺失则直接返回0.0;Notion取当前状态用于检查表格行;Slack取初始和当前状态用于检测新消息。接着逐项评分:组件1-3分别在Notion的Q3 Forecast数据库(parentId='db-q3-forecast')中查找指定标题行,使用容错逻辑(金额解析、阶段别名归一化、多格式日期解析)对比Amount、Stage、Close Date是否与Salesforce源数据一致,每项正确加0.20分。组件4检查该数据库的items数量和实际子行数量均恰好为3,且不存在标题含'smb add on'的Closed Lost干扰项,同时要求前面至少有一行已正确填充(any_filled),满足加0.15分。组件5在Slack #sales频道中筛选当前用户发送的新消息,验证消息内容包含三个机会的实时计算总金额、提及全部三个账户名称(Globex、Initech、Soylent),且不包含干扰项'Globex SMB Add-on',满足加0.25分。最终汇总得分,经min(score, 1.0)钳制并四舍五入到4位小数后返回。\",\"confidence\":1.0}"
|
| 68 |
+
}
|
legacy/ae_meeting_followup_002/_cua_gym_vm_bridge.sh
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# CUA-Gym VM-side network fix (direct-IP mock access).
|
| 3 |
+
#
|
| 4 |
+
# Runs INSIDE the QEMU guest. The CUA-Gym mock services are now reached by
|
| 5 |
+
# their real IDC address (http://28.7.186.212:81xx) instead of the old
|
| 6 |
+
# localhost:9000-9097 socat bridge, so the VM only needs two fixes:
|
| 7 |
+
#
|
| 8 |
+
# 1. Working DNS — the qcow2-baked /etc/resolv.conf points at the Pod's
|
| 9 |
+
# cluster DNS, which is unreachable from QEMU SLIRP NAT
|
| 10 |
+
# ("Temporary failure in name resolution").
|
| 11 |
+
# 2. The mock host excluded from the woa http proxy — otherwise the VM's
|
| 12 |
+
# Chrome (gsettings proxy) and initial_setup.py's `requests` get a 403
|
| 13 |
+
# from the proxy when hitting 28.7.186.212:81xx. (The old socat path never
|
| 14 |
+
# hit this because localhost is bypassed by default.)
|
| 15 |
+
#
|
| 16 |
+
# Idempotent. Scoped to the CUA-Gym bridge step; does not touch the generic
|
| 17 |
+
# OSWorld setup pipeline.
|
| 18 |
+
#
|
| 19 |
+
# Argv:
|
| 20 |
+
# $1 optional sudo password (default "password"; SetupController
|
| 21 |
+
# substitutes {CLIENT_PASSWORD} when uploaded as a cache file).
|
| 22 |
+
# $2 unused (kept for backward compat — was socat first port 9000).
|
| 23 |
+
# $3 unused (kept for backward compat — was socat last port 9097).
|
| 24 |
+
# $4 optional mock host IP (default 28.7.186.212).
|
| 25 |
+
|
| 26 |
+
set +e
|
| 27 |
+
|
| 28 |
+
PASS="${1:-password}"
|
| 29 |
+
MOCK_HOST="${4:-28.7.186.212}"
|
| 30 |
+
# Derive the /16 IDC subnet so future port/host tweaks on the same segment
|
| 31 |
+
# stay bypassed too (28.7.186.212 -> 28.133.0.0/16).
|
| 32 |
+
MOCK_NET="$(echo "${MOCK_HOST}" | awk -F. 'NF==4{print $1"."$2".0.0/16"}')"
|
| 33 |
+
|
| 34 |
+
run_root() {
|
| 35 |
+
echo "$PASS" | sudo -S -p "" bash -c "$1"
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
# Detect SLIRP gateway from VM's routing table; fall back to 10.0.2.2.
|
| 39 |
+
GW="$(ip route 2>/dev/null | awk '/default/ {print $3; exit}')"
|
| 40 |
+
GW="${GW:-10.0.2.2}"
|
| 41 |
+
|
| 42 |
+
# ─── CUA-Gym network fix (Taiji-specific) ─────────────────────────────
|
| 43 |
+
fix_vm_network() {
|
| 44 |
+
# 0) Discover VM network state at runtime — gateway, own IP/CIDR, SLIRP
|
| 45 |
+
# DNS forwarder. Nothing hardcoded except the mock host above.
|
| 46 |
+
local GW_NET="${GW%.*}"
|
| 47 |
+
local SLIRP_DNS="${GW_NET}.3" # QEMU SLIRP DNS proxy is always .3
|
| 48 |
+
local OWN_CIDR
|
| 49 |
+
OWN_CIDR="$(ip -4 -o addr show scope global 2>/dev/null \
|
| 50 |
+
| awk '{print $4; exit}')"
|
| 51 |
+
local OWN_IP="${OWN_CIDR%/*}"
|
| 52 |
+
local OWN_NET=""
|
| 53 |
+
[ -n "${OWN_IP}" ] && OWN_NET="${OWN_IP%.*}.0/24"
|
| 54 |
+
|
| 55 |
+
# 1) DNS — point at SLIRP DNS proxy + public fallbacks. chattr +i keeps
|
| 56 |
+
# systemd-resolved/NetworkManager from clobbering it.
|
| 57 |
+
if run_root "printf 'nameserver ${SLIRP_DNS}\\nnameserver 114.114.114.114\\nnameserver 8.8.8.8\\n' > /etc/resolv.conf
|
| 58 |
+
chattr +i /etc/resolv.conf 2>/dev/null || true"; then
|
| 59 |
+
echo "[cua_gym_vm_bridge] DNS set: ${SLIRP_DNS}, 114.114.114.114, 8.8.8.8 (gw=${GW})"
|
| 60 |
+
else
|
| 61 |
+
echo "[cua_gym_vm_bridge] WARN: failed to write /etc/resolv.conf"
|
| 62 |
+
fi
|
| 63 |
+
|
| 64 |
+
# 2) Build the proxy bypass list from detected values + the direct-IP
|
| 65 |
+
# mock host (and its /16 subnet). THIS is what makes 28.7.186.212:81xx
|
| 66 |
+
# reachable from inside the VM — without it the woa proxy 403s it.
|
| 67 |
+
local ignore_list="['localhost', '127.0.0.0/8', '${GW}'"
|
| 68 |
+
[ -n "${OWN_IP}" ] && ignore_list="${ignore_list}, '${OWN_IP}'"
|
| 69 |
+
[ -n "${OWN_NET}" ] && ignore_list="${ignore_list}, '${OWN_NET}'"
|
| 70 |
+
[ -n "${GW_NET}" ] && ignore_list="${ignore_list}, '${GW_NET}.0/24'"
|
| 71 |
+
[ -n "${MOCK_HOST}" ] && ignore_list="${ignore_list}, '${MOCK_HOST}'"
|
| 72 |
+
[ -n "${MOCK_NET}" ] && ignore_list="${ignore_list}, '${MOCK_NET}'"
|
| 73 |
+
ignore_list="${ignore_list}]"
|
| 74 |
+
|
| 75 |
+
# 3) GNOME proxy ignore-hosts — Chrome bypasses the woa proxy for these.
|
| 76 |
+
if gsettings set org.gnome.system.proxy ignore-hosts "${ignore_list}" 2>/tmp/gsettings_err; then
|
| 77 |
+
echo "[cua_gym_vm_bridge] gsettings ignore-hosts = ${ignore_list}"
|
| 78 |
+
else
|
| 79 |
+
echo "[cua_gym_vm_bridge] WARN: gsettings ignore-hosts failed: $(cat /tmp/gsettings_err 2>/dev/null)"
|
| 80 |
+
fi
|
| 81 |
+
|
| 82 |
+
# 4) Shell env — comma-separated form for no_proxy/NO_PROXY (requests/curl).
|
| 83 |
+
local NP="localhost,127.0.0.1,${GW}"
|
| 84 |
+
[ -n "${OWN_IP}" ] && NP="${NP},${OWN_IP}"
|
| 85 |
+
[ -n "${OWN_NET}" ] && NP="${NP},${OWN_NET}"
|
| 86 |
+
[ -n "${GW_NET}" ] && NP="${NP},${GW_NET}.0/24"
|
| 87 |
+
[ -n "${MOCK_HOST}" ] && NP="${NP},${MOCK_HOST}"
|
| 88 |
+
[ -n "${MOCK_NET}" ] && NP="${NP},${MOCK_NET}"
|
| 89 |
+
|
| 90 |
+
for var in no_proxy NO_PROXY; do
|
| 91 |
+
if ! grep -q "export ${var}=${NP}" /home/user/.bashrc 2>/dev/null; then
|
| 92 |
+
echo "export ${var}=${NP}" >> /home/user/.bashrc
|
| 93 |
+
fi
|
| 94 |
+
done
|
| 95 |
+
run_root "grep -q '^no_proxy=' /etc/environment 2>/dev/null \
|
| 96 |
+
&& sed -i 's|^no_proxy=.*|no_proxy=\"${NP}\"|' /etc/environment \
|
| 97 |
+
|| echo 'no_proxy=\"${NP}\"' >> /etc/environment
|
| 98 |
+
grep -q '^NO_PROXY=' /etc/environment 2>/dev/null \
|
| 99 |
+
&& sed -i 's|^NO_PROXY=.*|NO_PROXY=\"${NP}\"|' /etc/environment \
|
| 100 |
+
|| echo 'NO_PROXY=\"${NP}\"' >> /etc/environment" >/dev/null 2>&1
|
| 101 |
+
echo "[cua_gym_vm_bridge] no_proxy=${NP}"
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
fix_vm_network
|
| 105 |
+
|
| 106 |
+
echo "[cua_gym_vm_bridge] direct-IP mode: ${MOCK_HOST} (+${MOCK_NET}) bypassed from woa proxy; no socat forwarding needed"
|
legacy/ae_meeting_followup_002/initial_setup.py
ADDED
|
@@ -0,0 +1,576 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# --- MOCK_HOST_NO_PROXY_OVERRIDE: bypass woa proxy for locally-deployed mocks ---
|
| 2 |
+
import os as _os
|
| 3 |
+
_np = _os.environ.get("no_proxy", _os.environ.get("NO_PROXY", ""))
|
| 4 |
+
for _h in ("127.0.0.1", "localhost", "28.7.186.212"):
|
| 5 |
+
if _h not in _np:
|
| 6 |
+
_np = (_np + "," + _h).lstrip(",")
|
| 7 |
+
_os.environ["no_proxy"] = _np
|
| 8 |
+
_os.environ["NO_PROXY"] = _np
|
| 9 |
+
# --- end override ---
|
| 10 |
+
|
| 11 |
+
# --- wait_mocks_loaded: wait for mock backends ready AND browser tabs rendered ---
|
| 12 |
+
def wait_mocks_loaded(timeout=60, render_buffer=12):
|
| 13 |
+
"""Wait for mock backends ready AND browser tabs rendered (via CDP).
|
| 14 |
+
|
| 15 |
+
Phase 1 — backend readiness: poll each mock's /state?sid= until it
|
| 16 |
+
returns 200 with 'stored_state' in the body.
|
| 17 |
+
|
| 18 |
+
Phase 2 — browser render verification: connect to Chrome's CDP
|
| 19 |
+
endpoint and wait for every open tab to reach 'networkidle' load
|
| 20 |
+
state with a non-trivial DOM element count. This confirms the SPA
|
| 21 |
+
has fetched its /go?sid= data and actually painted, not just that
|
| 22 |
+
the backend is up.
|
| 23 |
+
|
| 24 |
+
CDP port auto-detection: checks globals for _chrome_debug_port /
|
| 25 |
+
cdp_port / debug_port (set by tasks that use a dynamic port, e.g.
|
| 26 |
+
se_hard_008's launch_chrome_with_urls); defaults to 1337 for tasks
|
| 27 |
+
that use launch_gui's --remote-debugging-port injection.
|
| 28 |
+
|
| 29 |
+
Falls back to the old render_buffer sleep if Playwright or the CDP
|
| 30 |
+
endpoint is unavailable.
|
| 31 |
+
"""
|
| 32 |
+
import urllib.request as _u, time as _t
|
| 33 |
+
g = globals()
|
| 34 |
+
_urls = {}
|
| 35 |
+
for _k, _v in list(g.items()):
|
| 36 |
+
if isinstance(_v, dict) and _v and all(isinstance(x, str) and x.startswith("http://") for x in _v.values()):
|
| 37 |
+
_urls.update(_v)
|
| 38 |
+
elif isinstance(_v, str) and _v.startswith("http://") and (_k.endswith("_URL") or _k.endswith("_url")):
|
| 39 |
+
_urls[_k] = _v
|
| 40 |
+
_sid = ""
|
| 41 |
+
for _k in ("sid", "SID", "task_sid", "session_id"):
|
| 42 |
+
if isinstance(g.get(_k), str) and g[_k]:
|
| 43 |
+
_sid = g[_k]; break
|
| 44 |
+
if not _sid:
|
| 45 |
+
for _k, _v in g.items():
|
| 46 |
+
if "sid" in _k.lower() and isinstance(_v, str) and _v:
|
| 47 |
+
_sid = _v; break
|
| 48 |
+
if not _urls or not _sid:
|
| 49 |
+
print(" wait_mocks_loaded: no mocks/sid found (%d urls, sid=%r), skipping" % (len(_urls), bool(_sid)))
|
| 50 |
+
return
|
| 51 |
+
|
| 52 |
+
# ---- Phase 1: backend readiness ----
|
| 53 |
+
_op = _u.build_opener(_u.ProxyHandler({}))
|
| 54 |
+
_dl = _t.time() + timeout
|
| 55 |
+
_todo = list(_urls.items())
|
| 56 |
+
while _todo and _t.time() < _dl:
|
| 57 |
+
_rest = []
|
| 58 |
+
for _n2, _uu in _todo:
|
| 59 |
+
try:
|
| 60 |
+
_r = _op.open("%s/state?sid=%s" % (_uu, _sid), timeout=5)
|
| 61 |
+
if _r.status == 200 and b"stored_state" in _r.read():
|
| 62 |
+
print(" %s: backend ready" % _n2); continue
|
| 63 |
+
except Exception:
|
| 64 |
+
pass
|
| 65 |
+
_rest.append((_n2, _uu))
|
| 66 |
+
_todo = _rest
|
| 67 |
+
if _todo:
|
| 68 |
+
_t.sleep(2)
|
| 69 |
+
_done = len(_urls) - len(_todo)
|
| 70 |
+
_pend = (" (pending: %s)" % [n for n, _ in _todo]) if _todo else ""
|
| 71 |
+
print(" mocks backend ready: %d/%d%s" % (_done, len(_urls), _pend))
|
| 72 |
+
|
| 73 |
+
# ---- Phase 2: browser render verification via CDP ----
|
| 74 |
+
# Auto-detect CDP port from globals (set by launch_chrome_with_urls
|
| 75 |
+
# in tasks that use a dynamic port); default to 1337.
|
| 76 |
+
_cdp_port = 1337
|
| 77 |
+
for _pk in ("_chrome_debug_port", "chrome_debug_port", "cdp_port", "debug_port"):
|
| 78 |
+
_pv = g.get(_pk)
|
| 79 |
+
if isinstance(_pv, int) and 0 < _pv < 65536:
|
| 80 |
+
_cdp_port = _pv; break
|
| 81 |
+
_cdp_ok = False
|
| 82 |
+
try:
|
| 83 |
+
from playwright.sync_api import sync_playwright
|
| 84 |
+
_cdp_dl = _t.time() + max(10.0, _dl - _t.time()) # leftover budget, floor 10s
|
| 85 |
+
with sync_playwright() as _p:
|
| 86 |
+
_br = None
|
| 87 |
+
# Retry-connect: Chrome may still be starting up.
|
| 88 |
+
while _t.time() < _cdp_dl:
|
| 89 |
+
try:
|
| 90 |
+
_br = _p.chromium.connect_over_cdp("http://localhost:%d" % _cdp_port)
|
| 91 |
+
break
|
| 92 |
+
except Exception:
|
| 93 |
+
_t.sleep(0.5)
|
| 94 |
+
if _br is None:
|
| 95 |
+
print(" wait_mocks_loaded: CDP connect to localhost:%d failed; "
|
| 96 |
+
"is Chrome launched with --remote-debugging-port?" % _cdp_port)
|
| 97 |
+
else:
|
| 98 |
+
# Wait for ALL expected tabs to appear, then verify each renders.
|
| 99 |
+
_n_expected = len(_urls)
|
| 100 |
+
_pages = []
|
| 101 |
+
_pg_dl = _t.time() + 15
|
| 102 |
+
_last_count = -1
|
| 103 |
+
_stable_since = None
|
| 104 |
+
while _t.time() < _pg_dl:
|
| 105 |
+
_pages = []
|
| 106 |
+
for _c in _br.contexts:
|
| 107 |
+
_pages.extend(_c.pages)
|
| 108 |
+
_cnt = len(_pages)
|
| 109 |
+
if _n_expected > 0 and _cnt >= _n_expected:
|
| 110 |
+
break # all expected tabs are open
|
| 111 |
+
if _cnt > 0 and _cnt == _last_count:
|
| 112 |
+
if _stable_since is None:
|
| 113 |
+
_stable_since = _t.time()
|
| 114 |
+
elif _t.time() - _stable_since >= 1.5:
|
| 115 |
+
break # tab count stable -> no more tabs opening
|
| 116 |
+
else:
|
| 117 |
+
_stable_since = None
|
| 118 |
+
_last_count = _cnt
|
| 119 |
+
_t.sleep(0.5)
|
| 120 |
+
# Re-fetch final snapshot so late-opening tabs are included.
|
| 121 |
+
_pages = []
|
| 122 |
+
for _c in _br.contexts:
|
| 123 |
+
_pages.extend(_c.pages)
|
| 124 |
+
if not _pages:
|
| 125 |
+
print(" wait_mocks_loaded: CDP connected but no open tabs found")
|
| 126 |
+
else:
|
| 127 |
+
print(" wait_mocks_loaded: %d tab(s) open (expected %d); "
|
| 128 |
+
"verifying render" % (len(_pages), _n_expected))
|
| 129 |
+
_ok_cnt = 0
|
| 130 |
+
for _pg in _pages:
|
| 131 |
+
_ttl = ""
|
| 132 |
+
try:
|
| 133 |
+
_ttl = _pg.title()
|
| 134 |
+
except Exception:
|
| 135 |
+
pass
|
| 136 |
+
try:
|
| 137 |
+
_pg.wait_for_load_state(
|
| 138 |
+
"networkidle",
|
| 139 |
+
timeout=int(max(5000, (_cdp_dl - _t.time()) * 1000)))
|
| 140 |
+
_n = _pg.evaluate("document.querySelectorAll('*').length")
|
| 141 |
+
if _n < 20:
|
| 142 |
+
print(" wait_mocks_loaded: WARNING tab %r has only %d "
|
| 143 |
+
"elements (render stall?)" % (_ttl, _n))
|
| 144 |
+
else:
|
| 145 |
+
print(" wait_mocks_loaded: tab %r rendered (%d elements)"
|
| 146 |
+
% (_ttl, _n))
|
| 147 |
+
_ok_cnt += 1
|
| 148 |
+
except Exception as _e:
|
| 149 |
+
print(" wait_mocks_loaded: tab %r render wait failed: %r"
|
| 150 |
+
% (_ttl, _e))
|
| 151 |
+
# Require ALL open tabs to render before skipping the
|
| 152 |
+
# render_buffer fallback, so no tab is left half-loaded.
|
| 153 |
+
if _ok_cnt > 0 and _ok_cnt == len(_pages):
|
| 154 |
+
_cdp_ok = True
|
| 155 |
+
else:
|
| 156 |
+
print(" wait_mocks_loaded: %d/%d tabs rendered, will fall back"
|
| 157 |
+
% (_ok_cnt, len(_pages)))
|
| 158 |
+
except ImportError:
|
| 159 |
+
print(" wait_mocks_loaded: playwright not installed; cannot verify browser render")
|
| 160 |
+
except Exception as _e:
|
| 161 |
+
print(" wait_mocks_loaded: CDP phase error (%r)" % _e)
|
| 162 |
+
|
| 163 |
+
if not _cdp_ok:
|
| 164 |
+
print(" wait_mocks_loaded: falling back to render_buffer=%ds sleep" % render_buffer)
|
| 165 |
+
_t.sleep(render_buffer)
|
| 166 |
+
else:
|
| 167 |
+
print(" wait_mocks_loaded: browser render verified, skipping render_buffer")
|
| 168 |
+
# --- end wait_mocks_loaded ---
|
| 169 |
+
|
| 170 |
+
# --- _open_remaining_mock_tabs: open all auto-detected mock URLs in new Chrome tabs ---
|
| 171 |
+
def _open_remaining_mock_tabs(primary_url=""):
|
| 172 |
+
"""Open all auto-detected mock URLs in Chrome --new-tab, except primary_url."""
|
| 173 |
+
g = globals()
|
| 174 |
+
_urls = set()
|
| 175 |
+
for _k, _v in list(g.items()):
|
| 176 |
+
if "PROBE" in _k.upper() or _k.startswith("_"):
|
| 177 |
+
continue
|
| 178 |
+
if isinstance(_v, str) and _v.startswith("http://") and (_k.endswith("_URL") or _k.endswith("_url")):
|
| 179 |
+
_urls.add(_v)
|
| 180 |
+
elif isinstance(_v, dict) and _v and all(isinstance(x, str) and x.startswith("http://") for x in _v.values()):
|
| 181 |
+
_urls.update(_v.values())
|
| 182 |
+
_sid = ""
|
| 183 |
+
for _k in ("sid", "SID", "task_sid", "session_id"):
|
| 184 |
+
if isinstance(g.get(_k), str) and g[_k]:
|
| 185 |
+
_sid = g[_k]; break
|
| 186 |
+
for _u in sorted(_urls):
|
| 187 |
+
if _u != primary_url:
|
| 188 |
+
launch_gui(f'google-chrome --new-tab "{_u}/?sid={_sid}"', delay_sec=1.0)
|
| 189 |
+
# --- end _open_remaining_mock_tabs ---
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
"""
|
| 193 |
+
Initial Setup: Post-meeting follow-up across Notion, Gmail, and Salesforce.
|
| 194 |
+
Task ID: ae_meeting_followup_002
|
| 195 |
+
Domain: mock_websites (multi-mock)
|
| 196 |
+
Mocks: notion, gmail, salesforce
|
| 197 |
+
|
| 198 |
+
Persona: Alex Rivera (user-1), AE at Northwind Cloud
|
| 199 |
+
(alex.rivera@northwindcloud.com). Today = 2026-06-24.
|
| 200 |
+
|
| 201 |
+
Pre-task state ONLY. MUST NOT contain task-completed elements:
|
| 202 |
+
- Notion 'Meetings' database holds ONLY unrelated past events
|
| 203 |
+
(no Initech technical deep-dive row).
|
| 204 |
+
- Gmail: NO follow-up sent to Daniel Park (sent folder has no such mail).
|
| 205 |
+
- Salesforce: opp-2 'Initech - Annual Renewal' has NO open activities
|
| 206 |
+
(no pricing-proposal task).
|
| 207 |
+
Distractors that MUST exist and be left untouched by the golden state:
|
| 208 |
+
- Notion page 'Meeting Notes - Globex Expansion'.
|
| 209 |
+
- Salesforce contact-7 'Daniela Park' at account 'Initrode'.
|
| 210 |
+
"""
|
| 211 |
+
import os
|
| 212 |
+
import shlex
|
| 213 |
+
import subprocess
|
| 214 |
+
import time
|
| 215 |
+
import uuid
|
| 216 |
+
|
| 217 |
+
import requests
|
| 218 |
+
|
| 219 |
+
# --- Mock registry ---
|
| 220 |
+
MOCKS = {
|
| 221 |
+
'notion': 'http://28.7.186.212:8186',
|
| 222 |
+
'gmail': 'http://28.7.186.212:8158',
|
| 223 |
+
'salesforce': 'http://28.7.186.212:8195',
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
# --- Shared session id ---
|
| 227 |
+
sid = str(uuid.uuid4())
|
| 228 |
+
with open('/tmp/task_web_sid', 'w') as f:
|
| 229 |
+
f.write(sid)
|
| 230 |
+
print(f'sid = {sid}')
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
# ----------------------------------------------------------------------------
|
| 234 |
+
# Notion state
|
| 235 |
+
# - Meeting notes page (Initech renewal) with attendee + action items
|
| 236 |
+
# - 'Meetings' database with only unrelated past events
|
| 237 |
+
# - Distractor 'Meeting Notes - Globex Expansion' page
|
| 238 |
+
# ----------------------------------------------------------------------------
|
| 239 |
+
def notion_state():
|
| 240 |
+
user = {"id": "user-1", "name": "Alex Rivera",
|
| 241 |
+
"email": "alex.rivera@northwindcloud.com", "avatar": ""}
|
| 242 |
+
workspace = {"id": "ws-1", "name": "Northwind Sales", "icon": "🏢",
|
| 243 |
+
"members": ["user-1"]}
|
| 244 |
+
|
| 245 |
+
# --- Meeting notes page (Initech) ---
|
| 246 |
+
notes_page_id = "page-initech-notes"
|
| 247 |
+
blocks = {
|
| 248 |
+
"blk-attendee": {
|
| 249 |
+
"id": "blk-attendee", "type": "text",
|
| 250 |
+
"content": "Attendee: Daniel Park, CTO, Initech LLC "
|
| 251 |
+
"(daniel.park@initech.com)",
|
| 252 |
+
"properties": {},
|
| 253 |
+
"createdDate": "2026-06-18T15:00:00.000Z",
|
| 254 |
+
"lastEditedDate": "2026-06-18T15:00:00.000Z",
|
| 255 |
+
},
|
| 256 |
+
"blk-disc-head": {
|
| 257 |
+
"id": "blk-disc-head", "type": "heading-2",
|
| 258 |
+
"content": "Discussion", "properties": {},
|
| 259 |
+
"createdDate": "2026-06-18T15:01:00.000Z",
|
| 260 |
+
"lastEditedDate": "2026-06-18T15:01:00.000Z",
|
| 261 |
+
},
|
| 262 |
+
"blk-disc-body": {
|
| 263 |
+
"id": "blk-disc-body", "type": "text",
|
| 264 |
+
"content": "Reviewed the annual renewal. Daniel wants an updated "
|
| 265 |
+
"pricing proposal and a technical deep-dive with his "
|
| 266 |
+
"engineering team before signing.",
|
| 267 |
+
"properties": {},
|
| 268 |
+
"createdDate": "2026-06-18T15:02:00.000Z",
|
| 269 |
+
"lastEditedDate": "2026-06-18T15:02:00.000Z",
|
| 270 |
+
},
|
| 271 |
+
"blk-action-head": {
|
| 272 |
+
"id": "blk-action-head", "type": "heading-2",
|
| 273 |
+
"content": "Action Items", "properties": {},
|
| 274 |
+
"createdDate": "2026-06-18T15:03:00.000Z",
|
| 275 |
+
"lastEditedDate": "2026-06-18T15:03:00.000Z",
|
| 276 |
+
},
|
| 277 |
+
"blk-action-1": {
|
| 278 |
+
"id": "blk-action-1", "type": "todo",
|
| 279 |
+
"content": "Send the updated pricing proposal to Daniel by "
|
| 280 |
+
"Friday 2026-06-26",
|
| 281 |
+
"properties": {"checked": False},
|
| 282 |
+
"createdDate": "2026-06-18T15:04:00.000Z",
|
| 283 |
+
"lastEditedDate": "2026-06-18T15:04:00.000Z",
|
| 284 |
+
},
|
| 285 |
+
"blk-action-2": {
|
| 286 |
+
"id": "blk-action-2", "type": "todo",
|
| 287 |
+
"content": "Schedule a technical deep-dive call for 2026-06-24 "
|
| 288 |
+
"at 10:00 AM",
|
| 289 |
+
"properties": {"checked": False},
|
| 290 |
+
"createdDate": "2026-06-18T15:05:00.000Z",
|
| 291 |
+
"lastEditedDate": "2026-06-18T15:05:00.000Z",
|
| 292 |
+
},
|
| 293 |
+
# Distractor page content
|
| 294 |
+
"blk-globex": {
|
| 295 |
+
"id": "blk-globex", "type": "text",
|
| 296 |
+
"content": "Globex expansion kickoff — discussed adding 200 seats "
|
| 297 |
+
"in Q3. Unrelated to the Initech renewal.",
|
| 298 |
+
"properties": {},
|
| 299 |
+
"createdDate": "2026-06-19T09:00:00.000Z",
|
| 300 |
+
"lastEditedDate": "2026-06-19T09:00:00.000Z",
|
| 301 |
+
},
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
notes_page = {
|
| 305 |
+
"id": notes_page_id,
|
| 306 |
+
"title": "Meeting Notes - Initech Renewal (2026-06-18)",
|
| 307 |
+
"icon": "📝", "cover": None, "parentId": None,
|
| 308 |
+
"blockIds": ["blk-attendee", "blk-disc-head", "blk-disc-body",
|
| 309 |
+
"blk-action-head", "blk-action-1", "blk-action-2"],
|
| 310 |
+
"favorite": False,
|
| 311 |
+
"createdDate": "2026-06-18T15:00:00.000Z",
|
| 312 |
+
"lastEditedDate": "2026-06-18T15:05:00.000Z",
|
| 313 |
+
"properties": {},
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
# --- Distractor: Globex meeting notes page ---
|
| 317 |
+
globex_page_id = "page-globex-notes"
|
| 318 |
+
globex_page = {
|
| 319 |
+
"id": globex_page_id,
|
| 320 |
+
"title": "Meeting Notes - Globex Expansion",
|
| 321 |
+
"icon": "📝", "cover": None, "parentId": None,
|
| 322 |
+
"blockIds": ["blk-globex"],
|
| 323 |
+
"favorite": False,
|
| 324 |
+
"createdDate": "2026-06-19T09:00:00.000Z",
|
| 325 |
+
"lastEditedDate": "2026-06-19T09:00:00.000Z",
|
| 326 |
+
"properties": {},
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
# --- 'Meetings' database (table view) ---
|
| 330 |
+
meetings_db_id = "db-meetings"
|
| 331 |
+
# notion_mock stores row property values as a FLAT map and has no "title"
|
| 332 |
+
# property type (title comes from page.title / the built-in Name column).
|
| 333 |
+
meetings_props = [
|
| 334 |
+
{"id": "prop_date", "name": "Date", "type": "date"},
|
| 335 |
+
{"id": "prop_attendee", "name": "Attendee", "type": "text"},
|
| 336 |
+
]
|
| 337 |
+
|
| 338 |
+
def make_event_row(page_id, event, date, attendee, created):
|
| 339 |
+
return {
|
| 340 |
+
"id": page_id,
|
| 341 |
+
"title": event,
|
| 342 |
+
"icon": "", "cover": None, "parentId": meetings_db_id,
|
| 343 |
+
"blockIds": [], "favorite": False,
|
| 344 |
+
"createdDate": created, "lastEditedDate": created,
|
| 345 |
+
"properties": {
|
| 346 |
+
"prop_date": date,
|
| 347 |
+
"prop_attendee": attendee,
|
| 348 |
+
},
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
# Unrelated PAST events only (no Initech technical deep-dive).
|
| 352 |
+
row_past_1 = make_event_row(
|
| 353 |
+
"evt-globex-sync", "Globex Quarterly Sync", "2026-06-10",
|
| 354 |
+
"Maria Lopez", "2026-06-01T12:00:00.000Z")
|
| 355 |
+
row_past_2 = make_event_row(
|
| 356 |
+
"evt-internal-fcst", "Northwind Sales Forecast Review", "2026-06-12",
|
| 357 |
+
"Sam Lee", "2026-06-02T12:00:00.000Z")
|
| 358 |
+
|
| 359 |
+
meetings_db = {
|
| 360 |
+
"id": meetings_db_id,
|
| 361 |
+
"title": "Meetings",
|
| 362 |
+
"icon": "📅", "cover": None, "parentId": None,
|
| 363 |
+
"type": "database", "viewType": "table",
|
| 364 |
+
"properties": meetings_props,
|
| 365 |
+
"views": [{
|
| 366 |
+
"id": "view-meetings", "name": "Table", "type": "table",
|
| 367 |
+
"filters": [], "sorts": [], "groupBy": None,
|
| 368 |
+
"visibleProperties": ["prop_date", "prop_attendee"],
|
| 369 |
+
}],
|
| 370 |
+
"items": ["evt-globex-sync", "evt-internal-fcst"],
|
| 371 |
+
"blockIds": [], "favorite": False,
|
| 372 |
+
"createdDate": "2026-05-01T09:00:00.000Z",
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
pages = {
|
| 376 |
+
notes_page_id: notes_page,
|
| 377 |
+
globex_page_id: globex_page,
|
| 378 |
+
meetings_db_id: meetings_db,
|
| 379 |
+
"evt-globex-sync": row_past_1,
|
| 380 |
+
"evt-internal-fcst": row_past_2,
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
return {
|
| 384 |
+
"user": user,
|
| 385 |
+
"workspace": workspace,
|
| 386 |
+
"pages": pages,
|
| 387 |
+
"blocks": blocks,
|
| 388 |
+
"trash": [],
|
| 389 |
+
"comments": {},
|
| 390 |
+
"settings": {"appearance": "light", "startWeekMonday": False,
|
| 391 |
+
"fontSize": "default"},
|
| 392 |
+
"notifications": [],
|
| 393 |
+
"pageOrder": [notes_page_id, globex_page_id, meetings_db_id],
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
# ----------------------------------------------------------------------------
|
| 398 |
+
# Gmail state — Alex Rivera; inbound thread from Daniel Park, NO follow-up sent
|
| 399 |
+
# ----------------------------------------------------------------------------
|
| 400 |
+
def gmail_state():
|
| 401 |
+
return {
|
| 402 |
+
"user": {"userId": "user-1", "username": "Alex Rivera",
|
| 403 |
+
"email": "alex.rivera@northwindcloud.com", "avatar": ""},
|
| 404 |
+
"emails": [
|
| 405 |
+
{
|
| 406 |
+
"id": "email_1", "threadId": "thread_initech",
|
| 407 |
+
"from": {"name": "Daniel Park", "email": "daniel.park@initech.com"},
|
| 408 |
+
"to": [{"name": "Alex Rivera",
|
| 409 |
+
"email": "alex.rivera@northwindcloud.com"}],
|
| 410 |
+
"cc": [], "bcc": [],
|
| 411 |
+
"subject": "Initech renewal - thanks for today",
|
| 412 |
+
"body": ("Hi Alex,<br><br>Thanks for the call today on the annual "
|
| 413 |
+
"renewal. To recap, we agreed you'll send the updated "
|
| 414 |
+
"pricing proposal by Friday, and we'll do the technical "
|
| 415 |
+
"deep-dive with my team. Looking forward to it.<br><br>"
|
| 416 |
+
"Best,<br>Daniel Park<br>CTO, Initech LLC"),
|
| 417 |
+
"timestamp": "2026-06-18T16:30:00Z",
|
| 418 |
+
"read": True, "starred": False, "important": True,
|
| 419 |
+
"labels": ["l1"], "category": "primary", "folder": "inbox",
|
| 420 |
+
"attachments": [],
|
| 421 |
+
},
|
| 422 |
+
{
|
| 423 |
+
"id": "email_2", "threadId": "thread_2",
|
| 424 |
+
"from": {"name": "Sam Lee", "email": "sam.lee@northwindcloud.com"},
|
| 425 |
+
"to": [{"name": "Alex Rivera",
|
| 426 |
+
"email": "alex.rivera@northwindcloud.com"}],
|
| 427 |
+
"cc": [], "bcc": [],
|
| 428 |
+
"subject": "Great work on the Initech call",
|
| 429 |
+
"body": "Nice job, Alex. Let me know how the follow-ups go.",
|
| 430 |
+
"timestamp": "2026-06-18T17:00:00Z",
|
| 431 |
+
"read": False, "starred": False, "important": False,
|
| 432 |
+
"labels": ["l1"], "category": "primary", "folder": "inbox",
|
| 433 |
+
"attachments": [],
|
| 434 |
+
},
|
| 435 |
+
],
|
| 436 |
+
"labels": [
|
| 437 |
+
{"id": "l1", "name": "Work", "color": "#ef4444"},
|
| 438 |
+
{"id": "l2", "name": "Personal", "color": "#3b82f6"},
|
| 439 |
+
{"id": "l3", "name": "Travel", "color": "#22c55e"},
|
| 440 |
+
{"id": "l4", "name": "Finance", "color": "#eab308"},
|
| 441 |
+
],
|
| 442 |
+
"drafts": [],
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
|
| 446 |
+
# ----------------------------------------------------------------------------
|
| 447 |
+
# Salesforce state
|
| 448 |
+
# - opp-2 'Initech - Annual Renewal' (account-2, contact-2 Daniel Park)
|
| 449 |
+
# - distractor contact-7 'Daniela Park' at account 'Initrode'
|
| 450 |
+
# - NO open activities
|
| 451 |
+
# ----------------------------------------------------------------------------
|
| 452 |
+
def salesforce_state():
|
| 453 |
+
user_1 = {
|
| 454 |
+
"userId": "user-1", "firstName": "Alex", "lastName": "Rivera",
|
| 455 |
+
"email": "alex.rivera@northwindcloud.com", "phone": "(555) 240-1188",
|
| 456 |
+
"title": "Account Executive", "department": "Sales", "role": "Rep",
|
| 457 |
+
"avatar": "https://i.pravatar.cc/150?u=user-1",
|
| 458 |
+
"timezone": "America/Los_Angeles", "locale": "en-US", "theme": "lightning",
|
| 459 |
+
}
|
| 460 |
+
user_2 = {
|
| 461 |
+
"userId": "user-2", "firstName": "Sam", "lastName": "Lee",
|
| 462 |
+
"email": "sam.lee@northwindcloud.com", "phone": "(555) 240-1190",
|
| 463 |
+
"title": "Sales Manager", "department": "Sales", "role": "Manager",
|
| 464 |
+
"avatar": "https://i.pravatar.cc/150?u=user-2",
|
| 465 |
+
"timezone": "America/Los_Angeles", "locale": "en-US", "theme": "lightning",
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
accounts = [
|
| 469 |
+
{"accountId": "account-2", "name": "Initech LLC", "type": "Customer",
|
| 470 |
+
"industry": "Software", "revenue": 22000000, "employees": 320,
|
| 471 |
+
"ownerId": "user-1", "billingStreet": "78 Office Park Dr",
|
| 472 |
+
"billingCity": "Austin", "billingState": "TX",
|
| 473 |
+
"billingZip": "73301", "billingCountry": "USA"},
|
| 474 |
+
# Distractor account
|
| 475 |
+
{"accountId": "account-7", "name": "Initrode", "type": "Prospect",
|
| 476 |
+
"industry": "Consulting", "revenue": 5000000, "employees": 60,
|
| 477 |
+
"ownerId": "user-1", "billingStreet": "9 Rodeo Ln",
|
| 478 |
+
"billingCity": "Dallas", "billingState": "TX",
|
| 479 |
+
"billingZip": "75201", "billingCountry": "USA"},
|
| 480 |
+
]
|
| 481 |
+
|
| 482 |
+
contacts = [
|
| 483 |
+
{"contactId": "contact-2", "accountId": "account-2",
|
| 484 |
+
"firstName": "Daniel", "lastName": "Park", "title": "CTO",
|
| 485 |
+
"department": "Engineering", "email": "daniel.park@initech.com",
|
| 486 |
+
"phone": "(555) 330-2201", "ownerId": "user-1"},
|
| 487 |
+
# Distractor contact — different person, different account
|
| 488 |
+
{"contactId": "contact-7", "accountId": "account-7",
|
| 489 |
+
"firstName": "Daniela", "lastName": "Park", "title": "Operations Lead",
|
| 490 |
+
"department": "Operations", "email": "daniela.park@initrode.com",
|
| 491 |
+
"phone": "(555) 770-9912", "ownerId": "user-1"},
|
| 492 |
+
]
|
| 493 |
+
|
| 494 |
+
opportunities = [
|
| 495 |
+
{"opportunityId": "opp-2", "name": "Initech - Annual Renewal",
|
| 496 |
+
"accountId": "account-2", "contactId": "contact-2", "amount": 60000,
|
| 497 |
+
"closeDate": "2026-06-30", "stage": "Proposal", "probability": 60,
|
| 498 |
+
"ownerId": "user-1"},
|
| 499 |
+
]
|
| 500 |
+
|
| 501 |
+
return {
|
| 502 |
+
"user": user_1,
|
| 503 |
+
"users": [user_1, user_2],
|
| 504 |
+
"leads": [],
|
| 505 |
+
"accounts": accounts,
|
| 506 |
+
"contacts": contacts,
|
| 507 |
+
"opportunities": opportunities,
|
| 508 |
+
"cases": [],
|
| 509 |
+
"activities": [], # NO open activities yet
|
| 510 |
+
"chatterPosts": [],
|
| 511 |
+
"files": [],
|
| 512 |
+
"following": [],
|
| 513 |
+
"recentlyViewed": [],
|
| 514 |
+
"dismissedNotifications": [],
|
| 515 |
+
}
|
| 516 |
+
|
| 517 |
+
|
| 518 |
+
# ----------------------------------------------------------------------------
|
| 519 |
+
# Inject all states
|
| 520 |
+
# ----------------------------------------------------------------------------
|
| 521 |
+
STATE_BUILDERS = {
|
| 522 |
+
'notion': notion_state,
|
| 523 |
+
'gmail': gmail_state,
|
| 524 |
+
'salesforce': salesforce_state,
|
| 525 |
+
}
|
| 526 |
+
|
| 527 |
+
for name, build in STATE_BUILDERS.items():
|
| 528 |
+
url = MOCKS[name]
|
| 529 |
+
state = build()
|
| 530 |
+
resp = requests.post(f'{url}/post?sid={sid}',
|
| 531 |
+
json={'action': 'set', 'state': state}, timeout=30)
|
| 532 |
+
assert resp.status_code == 200, \
|
| 533 |
+
f'{name} injection failed: {resp.status_code} {resp.text}'
|
| 534 |
+
go = requests.get(f'{url}/go?sid={sid}', timeout=10).json()
|
| 535 |
+
assert go.get('initial_state') is not None, f'{name} initial_state is None'
|
| 536 |
+
print(f' injected {name}: initial_state OK')
|
| 537 |
+
|
| 538 |
+
print(f'All 3 mocks injected with sid={sid}')
|
| 539 |
+
|
| 540 |
+
|
| 541 |
+
# ----------------------------------------------------------------------------
|
| 542 |
+
# GUI-ready: launch Chrome on Notion (primary app — where the notes live)
|
| 543 |
+
# ----------------------------------------------------------------------------
|
| 544 |
+
def launch_gui(command, delay_sec=1.0):
|
| 545 |
+
env = os.environ.copy()
|
| 546 |
+
env['DISPLAY'] = ':0'
|
| 547 |
+
# Accept both a command string and a pre-split arg list (some tasks
|
| 548 |
+
# build arg lists themselves, e.g. se_hard_008).
|
| 549 |
+
if isinstance(command, str):
|
| 550 |
+
_parts = shlex.split(command)
|
| 551 |
+
else:
|
| 552 |
+
_parts = list(command)
|
| 553 |
+
# Inject CDP debug port so wait_mocks_loaded can verify browser render
|
| 554 |
+
# via Playwright connect_over_cdp. Idempotent: skip if any arg already
|
| 555 |
+
# starts with --remote-debugging-port (some tasks inject their own
|
| 556 |
+
# dynamic port, e.g. se_hard_008).
|
| 557 |
+
if _parts and 'google-chrome' in _parts[0] \
|
| 558 |
+
and not any(p.startswith('--remote-debugging-port') for p in _parts):
|
| 559 |
+
_parts[1:1] = ['--no-first-run', '--no-default-browser-check',
|
| 560 |
+
'--remote-debugging-port=1337']
|
| 561 |
+
_proc = subprocess.Popen(_parts, stdin=subprocess.DEVNULL,
|
| 562 |
+
stdout=subprocess.DEVNULL,
|
| 563 |
+
stderr=subprocess.DEVNULL, env=env,
|
| 564 |
+
start_new_session=True)
|
| 565 |
+
time.sleep(delay_sec)
|
| 566 |
+
if _proc.poll() is not None:
|
| 567 |
+
print(' WARNING: launch_gui process exited early (code=%s)'
|
| 568 |
+
% _proc.returncode)
|
| 569 |
+
return _proc
|
| 570 |
+
launch_gui(
|
| 571 |
+
f'google-chrome "{MOCKS["notion"]}/?sid={sid}"',
|
| 572 |
+
delay_sec=2.0,
|
| 573 |
+
)
|
| 574 |
+
_open_remaining_mock_tabs(MOCKS["notion"])
|
| 575 |
+
wait_mocks_loaded()
|
| 576 |
+
print(f'GUI_READY: launched browser at {MOCKS["notion"]}/?sid={sid}')
|
legacy/ae_meeting_followup_002/reward.py
ADDED
|
@@ -0,0 +1,560 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# --- MOCK_HOST_NO_PROXY_OVERRIDE: bypass woa proxy for locally-deployed mocks ---
|
| 2 |
+
import os as _os
|
| 3 |
+
_np = _os.environ.get("no_proxy", _os.environ.get("NO_PROXY", ""))
|
| 4 |
+
for _h in ("127.0.0.1", "localhost", "28.7.186.212"):
|
| 5 |
+
if _h not in _np:
|
| 6 |
+
_np = (_np + "," + _h).lstrip(",")
|
| 7 |
+
_os.environ["no_proxy"] = _np
|
| 8 |
+
_os.environ["NO_PROXY"] = _np
|
| 9 |
+
# --- end override ---
|
| 10 |
+
|
| 11 |
+
"""
|
| 12 |
+
Reward Script: AE meeting follow-up across Gmail, Salesforce, and Notion
|
| 13 |
+
Task ID: ae_meeting_followup_002
|
| 14 |
+
Domain: mock_websites (multi-mock: gmail, salesforce, notion)
|
| 15 |
+
|
| 16 |
+
Task: After the Initech renewal call, the agent must
|
| 17 |
+
(1) send Daniel a follow-up email from Gmail recapping the two agreed items
|
| 18 |
+
(pricing proposal due 2026-06-26, technical deep-dive call 2026-06-24),
|
| 19 |
+
(2) log the pricing-proposal action as a task on the Initech opportunity (opp-2)
|
| 20 |
+
in Salesforce with due date 2026-06-26, assigned to user-1,
|
| 21 |
+
(3) add the technical deep-dive call to the Notion 'Meetings' calendar
|
| 22 |
+
(Date 2026-06-24, Attendee Daniel Park).
|
| 23 |
+
Distractors (Daniela Park / Initrode, Globex notes) must remain untouched.
|
| 24 |
+
|
| 25 |
+
Scoring (programmatic only — task is fully deterministic):
|
| 26 |
+
Gmail 0.35 : sent follow-up to daniel.park@initech.com (0.20) recapping both agreed items and dates (0.15)
|
| 27 |
+
Salesforce 0.35 : task on opp-2 referencing pricing proposal, assigned user-1 (0.20) + dueDate 2026-06-26 (0.15)
|
| 28 |
+
Notion 0.30 : new Meetings row for the deep-dive (0.15) + Date 2026-06-24 & Attendee Daniel Park (0.15)
|
| 29 |
+
Distractor gate : if a distractor was clearly acted on, zero out the relevant mock's credit.
|
| 30 |
+
"""
|
| 31 |
+
import re
|
| 32 |
+
import sys
|
| 33 |
+
from datetime import date, timedelta
|
| 34 |
+
from html import unescape
|
| 35 |
+
|
| 36 |
+
import requests
|
| 37 |
+
|
| 38 |
+
# --- Read sid ---
|
| 39 |
+
try:
|
| 40 |
+
with open('/tmp/task_web_sid') as f:
|
| 41 |
+
sid = f.read().strip()
|
| 42 |
+
if not sid:
|
| 43 |
+
raise ValueError('sid is empty')
|
| 44 |
+
except Exception as e:
|
| 45 |
+
print(f'CRITICAL: Cannot read sid from /tmp/task_web_sid: {e}')
|
| 46 |
+
print('REWARD: 0.0')
|
| 47 |
+
sys.exit(0)
|
| 48 |
+
|
| 49 |
+
MOCKS = {
|
| 50 |
+
'gmail': 'http://28.7.186.212:8158',
|
| 51 |
+
'salesforce': 'http://28.7.186.212:8195',
|
| 52 |
+
'notion': 'http://28.7.186.212:8186',
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
# --- Fetch state from all three mocks ---
|
| 56 |
+
states = {}
|
| 57 |
+
for name, url in MOCKS.items():
|
| 58 |
+
try:
|
| 59 |
+
resp = requests.get(f'{url}/go?sid={sid}', timeout=15)
|
| 60 |
+
resp.raise_for_status()
|
| 61 |
+
states[name] = resp.json()
|
| 62 |
+
except Exception as e:
|
| 63 |
+
print(f'CRITICAL: Cannot fetch state from {name} ({url}): {e}')
|
| 64 |
+
print('REWARD: 0.0')
|
| 65 |
+
sys.exit(0)
|
| 66 |
+
|
| 67 |
+
gmail_initial = states['gmail'].get('initial_state') or {}
|
| 68 |
+
gmail_cur = states['gmail'].get('current_state') or {}
|
| 69 |
+
sf_initial = states['salesforce'].get('initial_state') or {}
|
| 70 |
+
sf_cur = states['salesforce'].get('current_state') or {}
|
| 71 |
+
notion_initial = states['notion'].get('initial_state') or {}
|
| 72 |
+
notion_cur = states['notion'].get('current_state') or {}
|
| 73 |
+
|
| 74 |
+
DANIEL_EMAIL = 'daniel.park@initech.com'
|
| 75 |
+
DANIELA_EMAIL = 'daniela.park@initrode.com'
|
| 76 |
+
DANIEL_NAME = 'daniel park'
|
| 77 |
+
DANIELA_NAME = 'daniela park'
|
| 78 |
+
TASK_TODAY = date(2026, 6, 24)
|
| 79 |
+
DEFAULT_YEAR = TASK_TODAY.year
|
| 80 |
+
FALLBACK_PROPOSAL_DATE = date(2026, 6, 26)
|
| 81 |
+
FALLBACK_DEEPDIVE_DATE = date(2026, 6, 24)
|
| 82 |
+
FALLBACK_DEEPDIVE_TIME = (10, 0)
|
| 83 |
+
|
| 84 |
+
MONTHS = {
|
| 85 |
+
'jan': 1, 'january': 1,
|
| 86 |
+
'feb': 2, 'february': 2,
|
| 87 |
+
'mar': 3, 'march': 3,
|
| 88 |
+
'apr': 4, 'april': 4,
|
| 89 |
+
'may': 5,
|
| 90 |
+
'jun': 6, 'june': 6,
|
| 91 |
+
'jul': 7, 'july': 7,
|
| 92 |
+
'aug': 8, 'august': 8,
|
| 93 |
+
'sep': 9, 'sept': 9, 'september': 9,
|
| 94 |
+
'oct': 10, 'october': 10,
|
| 95 |
+
'nov': 11, 'november': 11,
|
| 96 |
+
'dec': 12, 'december': 12,
|
| 97 |
+
}
|
| 98 |
+
WEEKDAYS = {
|
| 99 |
+
'monday': 0, 'mon': 0,
|
| 100 |
+
'tuesday': 1, 'tue': 1, 'tues': 1,
|
| 101 |
+
'wednesday': 2, 'wed': 2,
|
| 102 |
+
'thursday': 3, 'thu': 3, 'thur': 3, 'thurs': 3,
|
| 103 |
+
'friday': 4, 'fri': 4,
|
| 104 |
+
'saturday': 5, 'sat': 5,
|
| 105 |
+
'sunday': 6, 'sun': 6,
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
PRICING_TERMS = (
|
| 109 |
+
'pricing proposal', 'price proposal', 'updated proposal',
|
| 110 |
+
'proposal', 'pricing', 'quote', 'commercial proposal',
|
| 111 |
+
'renewal proposal',
|
| 112 |
+
)
|
| 113 |
+
DEEPDIVE_TERMS = (
|
| 114 |
+
'technical deep dive', 'technical deep-dive', 'deep dive',
|
| 115 |
+
'deep-dive', 'deepdive', 'technical review', 'technical session',
|
| 116 |
+
'technical call', 'technical meeting', 'engineering call',
|
| 117 |
+
'engineering session', 'architecture review',
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
def _plain_text(value):
|
| 122 |
+
text = unescape(str(value or ''))
|
| 123 |
+
text = re.sub(r'<[^>]+>', ' ', text)
|
| 124 |
+
text = text.replace('\u2010', '-').replace('\u2011', '-')
|
| 125 |
+
text = text.replace('\u2012', '-').replace('\u2013', '-')
|
| 126 |
+
text = text.replace('\u2014', '-').replace('\u00a0', ' ')
|
| 127 |
+
return re.sub(r'\s+', ' ', text).strip().lower()
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def _token_text(value):
|
| 131 |
+
text = _plain_text(value)
|
| 132 |
+
text = re.sub(r'[^a-z0-9@._:+/-]+', ' ', text)
|
| 133 |
+
text = text.replace('-', ' ')
|
| 134 |
+
return re.sub(r'\s+', ' ', text).strip()
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
def _has_any(value, terms):
|
| 138 |
+
text = _token_text(value)
|
| 139 |
+
return any(_token_text(term) in text for term in terms)
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
def _safe_date(year, month, day):
|
| 143 |
+
try:
|
| 144 |
+
return date(int(year), int(month), int(day))
|
| 145 |
+
except Exception:
|
| 146 |
+
return None
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def _normalize_year(year):
|
| 150 |
+
if year is None or year == '':
|
| 151 |
+
return DEFAULT_YEAR
|
| 152 |
+
year = int(year)
|
| 153 |
+
if year < 100:
|
| 154 |
+
return 2000 + year
|
| 155 |
+
return year
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
def _next_or_same_weekday(base, weekday):
|
| 159 |
+
delta = (weekday - base.weekday()) % 7
|
| 160 |
+
return base + timedelta(days=delta)
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
def _extract_dates(value, base_date=TASK_TODAY):
|
| 164 |
+
text = _plain_text(value)
|
| 165 |
+
found = set()
|
| 166 |
+
|
| 167 |
+
for y, m, d in re.findall(r'\b(\d{4})[-/.](\d{1,2})[-/.](\d{1,2})\b', text):
|
| 168 |
+
dt = _safe_date(y, m, d)
|
| 169 |
+
if dt:
|
| 170 |
+
found.add(dt)
|
| 171 |
+
|
| 172 |
+
month_re = r'jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|jun(?:e)?|jul(?:y)?|aug(?:ust)?|sep(?:t|tember)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?'
|
| 173 |
+
for mon, d, y in re.findall(
|
| 174 |
+
rf'\b({month_re})\.?\s+(\d{{1,2}})(?:st|nd|rd|th)?(?:,?\s+(\d{{2,4}}))?\b',
|
| 175 |
+
text):
|
| 176 |
+
dt = _safe_date(_normalize_year(y), MONTHS[mon[:3]], d)
|
| 177 |
+
if dt:
|
| 178 |
+
found.add(dt)
|
| 179 |
+
|
| 180 |
+
for d, mon, y in re.findall(
|
| 181 |
+
rf'\b(\d{{1,2}})(?:st|nd|rd|th)?\s+({month_re})\.?(?:,?\s+(\d{{2,4}}))?\b',
|
| 182 |
+
text):
|
| 183 |
+
dt = _safe_date(_normalize_year(y), MONTHS[mon[:3]], d)
|
| 184 |
+
if dt:
|
| 185 |
+
found.add(dt)
|
| 186 |
+
|
| 187 |
+
for m, d, y in re.findall(r'\b(\d{1,2})[/-](\d{1,2})(?:[/-](\d{2,4}))?\b', text):
|
| 188 |
+
dt = _safe_date(_normalize_year(y), m, d)
|
| 189 |
+
if dt:
|
| 190 |
+
found.add(dt)
|
| 191 |
+
|
| 192 |
+
if re.search(r'\btoday\b', text):
|
| 193 |
+
found.add(base_date)
|
| 194 |
+
if re.search(r'\bday after tomorrow\b', text):
|
| 195 |
+
found.add(base_date + timedelta(days=2))
|
| 196 |
+
if re.search(r'(?<!after )\btomorrow\b', text):
|
| 197 |
+
found.add(base_date + timedelta(days=1))
|
| 198 |
+
|
| 199 |
+
for word, weekday in WEEKDAYS.items():
|
| 200 |
+
if re.search(rf'\b{re.escape(word)}\.?\b', text):
|
| 201 |
+
found.add(_next_or_same_weekday(base_date, weekday))
|
| 202 |
+
|
| 203 |
+
return found
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
def _date_matches(value, expected):
|
| 207 |
+
return expected in _extract_dates(value)
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
def _to_24h(hour, minute, meridiem):
|
| 211 |
+
hour = int(hour)
|
| 212 |
+
minute = int(minute or 0)
|
| 213 |
+
meridiem = (meridiem or '').replace('.', '').lower()
|
| 214 |
+
if meridiem == 'pm' and hour < 12:
|
| 215 |
+
hour += 12
|
| 216 |
+
elif meridiem == 'am' and hour == 12:
|
| 217 |
+
hour = 0
|
| 218 |
+
if 0 <= hour <= 23 and 0 <= minute <= 59:
|
| 219 |
+
return hour, minute
|
| 220 |
+
return None
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
def _extract_times(value):
|
| 224 |
+
text = _plain_text(value)
|
| 225 |
+
found = set()
|
| 226 |
+
for h, m, mer in re.findall(r'\b(\d{1,2})[:.](\d{2})\s*(a\.?m\.?|p\.?m\.?|am|pm)?\b', text):
|
| 227 |
+
parsed = _to_24h(h, m, mer)
|
| 228 |
+
if parsed:
|
| 229 |
+
found.add(parsed)
|
| 230 |
+
for h, mer in re.findall(r'\b(\d{1,2})\s*(a\.?m\.?|p\.?m\.?|am|pm)\b', text):
|
| 231 |
+
parsed = _to_24h(h, 0, mer)
|
| 232 |
+
if parsed:
|
| 233 |
+
found.add(parsed)
|
| 234 |
+
if re.search(r"\b10\s*o['’]?clock\b", text) or re.search(r'\bten\s*(a\.?m\.?|am|in the morning)\b', text):
|
| 235 |
+
found.add((10, 0))
|
| 236 |
+
return found
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
def _time_matches(value, expected):
|
| 240 |
+
return expected in _extract_times(value)
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
def _all_strings(value):
|
| 244 |
+
if isinstance(value, str):
|
| 245 |
+
return [value]
|
| 246 |
+
if isinstance(value, dict):
|
| 247 |
+
out = []
|
| 248 |
+
for v in value.values():
|
| 249 |
+
out.extend(_all_strings(v))
|
| 250 |
+
return out
|
| 251 |
+
if isinstance(value, list):
|
| 252 |
+
out = []
|
| 253 |
+
for v in value:
|
| 254 |
+
out.extend(_all_strings(v))
|
| 255 |
+
return out
|
| 256 |
+
return []
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
def _initial_blocks_matching(terms):
|
| 260 |
+
blocks = notion_initial.get('blocks', {}) or {}
|
| 261 |
+
matches = []
|
| 262 |
+
for block in blocks.values():
|
| 263 |
+
content = block.get('content', '') if isinstance(block, dict) else ''
|
| 264 |
+
if _has_any(content, terms):
|
| 265 |
+
matches.append(content)
|
| 266 |
+
return matches
|
| 267 |
+
|
| 268 |
+
|
| 269 |
+
def _derive_expected_date(terms, fallback):
|
| 270 |
+
for content in _initial_blocks_matching(terms):
|
| 271 |
+
dates = _extract_dates(content)
|
| 272 |
+
if fallback in dates:
|
| 273 |
+
return fallback
|
| 274 |
+
if dates:
|
| 275 |
+
return sorted(dates)[0]
|
| 276 |
+
return fallback
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
def _derive_expected_time(terms, fallback):
|
| 280 |
+
for content in _initial_blocks_matching(terms):
|
| 281 |
+
times = _extract_times(content)
|
| 282 |
+
if fallback in times:
|
| 283 |
+
return fallback
|
| 284 |
+
if times:
|
| 285 |
+
return sorted(times)[0]
|
| 286 |
+
return fallback
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
DATE_PROPOSAL = _derive_expected_date(PRICING_TERMS, FALLBACK_PROPOSAL_DATE)
|
| 290 |
+
DATE_DEEPDIVE = _derive_expected_date(DEEPDIVE_TERMS, FALLBACK_DEEPDIVE_DATE)
|
| 291 |
+
TIME_DEEPDIVE = _derive_expected_time(DEEPDIVE_TERMS, FALLBACK_DEEPDIVE_TIME)
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
def _recipients(email, fields):
|
| 295 |
+
emails = []
|
| 296 |
+
for field in fields:
|
| 297 |
+
for recipient in email.get(field, []) or []:
|
| 298 |
+
if isinstance(recipient, dict):
|
| 299 |
+
addr = recipient.get('email', '')
|
| 300 |
+
else:
|
| 301 |
+
addr = recipient
|
| 302 |
+
emails.append(str(addr).strip().lower())
|
| 303 |
+
return emails
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
def _is_pricing_action(text):
|
| 307 |
+
return _has_any(text, PRICING_TERMS)
|
| 308 |
+
|
| 309 |
+
|
| 310 |
+
def _is_deepdive_action(text):
|
| 311 |
+
return _has_any(text, DEEPDIVE_TERMS)
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
def _is_daniel(text):
|
| 315 |
+
text_l = _plain_text(text)
|
| 316 |
+
return (
|
| 317 |
+
DANIEL_EMAIL in text_l or
|
| 318 |
+
(DANIEL_NAME in text_l and DANIELA_NAME not in text_l) or
|
| 319 |
+
('daniel' in text_l and 'daniela' not in text_l)
|
| 320 |
+
)
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
def verify_task():
|
| 324 |
+
total = 0.0
|
| 325 |
+
print(
|
| 326 |
+
f"Expected: pricing proposal due {DATE_PROPOSAL.isoformat()}, "
|
| 327 |
+
f"technical deep-dive {DATE_DEEPDIVE.isoformat()} "
|
| 328 |
+
f"at {TIME_DEEPDIVE[0]:02d}:{TIME_DEEPDIVE[1]:02d}"
|
| 329 |
+
)
|
| 330 |
+
|
| 331 |
+
# ============================================================
|
| 332 |
+
# GMAIL — 0.35
|
| 333 |
+
# ============================================================
|
| 334 |
+
sent_to_daniel = None
|
| 335 |
+
gmail_content = {'proposal_ok': False, 'deepdive_ok': False, 'time_ok': False}
|
| 336 |
+
# Distractor gate: did the agent wrongly email Daniela?
|
| 337 |
+
sent_to_daniela = False
|
| 338 |
+
try:
|
| 339 |
+
initial_email_ids = {
|
| 340 |
+
e.get('id') for e in gmail_initial.get('emails', []) if e.get('id')
|
| 341 |
+
}
|
| 342 |
+
candidates = []
|
| 343 |
+
for e in gmail_cur.get('emails', []):
|
| 344 |
+
if e.get('folder') != 'sent':
|
| 345 |
+
continue
|
| 346 |
+
if e.get('id') in initial_email_ids:
|
| 347 |
+
continue
|
| 348 |
+
all_recips = _recipients(e, ('to', 'cc', 'bcc'))
|
| 349 |
+
if DANIELA_EMAIL in all_recips:
|
| 350 |
+
sent_to_daniela = True
|
| 351 |
+
if DANIEL_EMAIL in _recipients(e, ('to',)):
|
| 352 |
+
body = ' '.join([
|
| 353 |
+
str(e.get('subject', '')),
|
| 354 |
+
str(e.get('body', '')),
|
| 355 |
+
str(e.get('snippet', '')),
|
| 356 |
+
])
|
| 357 |
+
flags = {
|
| 358 |
+
'proposal_ok': (
|
| 359 |
+
_is_pricing_action(body) and
|
| 360 |
+
_date_matches(body, DATE_PROPOSAL)
|
| 361 |
+
),
|
| 362 |
+
'deepdive_date_ok': (
|
| 363 |
+
_is_deepdive_action(body) and
|
| 364 |
+
_date_matches(body, DATE_DEEPDIVE)
|
| 365 |
+
),
|
| 366 |
+
'time_ok': _time_matches(body, TIME_DEEPDIVE),
|
| 367 |
+
}
|
| 368 |
+
flags['deepdive_ok'] = (
|
| 369 |
+
flags['deepdive_date_ok'] and flags['time_ok']
|
| 370 |
+
)
|
| 371 |
+
score = int(flags['proposal_ok']) + int(flags['deepdive_ok'])
|
| 372 |
+
candidates.append((score, e, flags))
|
| 373 |
+
if candidates:
|
| 374 |
+
_, sent_to_daniel, gmail_content = max(
|
| 375 |
+
candidates, key=lambda item: item[0]
|
| 376 |
+
)
|
| 377 |
+
except Exception as ex:
|
| 378 |
+
print(f'ERROR: Gmail scan — {ex}')
|
| 379 |
+
|
| 380 |
+
# Component 1a: a sent follow-up addressed to Daniel (0.20)
|
| 381 |
+
try:
|
| 382 |
+
if sent_to_daniel and not sent_to_daniela:
|
| 383 |
+
print('PASS: Gmail — sent email to daniel.park@initech.com found (0.20)')
|
| 384 |
+
total += 0.20
|
| 385 |
+
elif sent_to_daniel and sent_to_daniela:
|
| 386 |
+
print('FAIL: Gmail — distractor Daniela was also emailed; credit withheld')
|
| 387 |
+
else:
|
| 388 |
+
print('FAIL: Gmail — no sent email addressed to daniel.park@initech.com')
|
| 389 |
+
except Exception as ex:
|
| 390 |
+
print(f'ERROR: Component Gmail-1a — {ex}')
|
| 391 |
+
|
| 392 |
+
# Component 1b: that email recaps BOTH agreed items and dates (0.15)
|
| 393 |
+
try:
|
| 394 |
+
if sent_to_daniel and not sent_to_daniela:
|
| 395 |
+
proposal_ok = gmail_content.get('proposal_ok', False)
|
| 396 |
+
deepdive_ok = gmail_content.get('deepdive_ok', False)
|
| 397 |
+
time_ok = gmail_content.get('time_ok', False)
|
| 398 |
+
if proposal_ok and deepdive_ok:
|
| 399 |
+
print(
|
| 400 |
+
'PASS: Gmail — body recaps pricing proposal due '
|
| 401 |
+
f'{DATE_PROPOSAL.isoformat()} and technical deep-dive on '
|
| 402 |
+
f'{DATE_DEEPDIVE.isoformat()} at '
|
| 403 |
+
f'{TIME_DEEPDIVE[0]:02d}:{TIME_DEEPDIVE[1]:02d} (0.15)'
|
| 404 |
+
)
|
| 405 |
+
total += 0.15
|
| 406 |
+
else:
|
| 407 |
+
print(
|
| 408 |
+
'FAIL: Gmail — '
|
| 409 |
+
f'proposal_ok={proposal_ok}, deepdive_ok={deepdive_ok}, '
|
| 410 |
+
f'time_ok={time_ok}'
|
| 411 |
+
)
|
| 412 |
+
else:
|
| 413 |
+
print('FAIL: Gmail — no valid sent email to evaluate body')
|
| 414 |
+
except Exception as ex:
|
| 415 |
+
print(f'ERROR: Component Gmail-1b — {ex}')
|
| 416 |
+
|
| 417 |
+
# ============================================================
|
| 418 |
+
# SALESFORCE — 0.35
|
| 419 |
+
# ============================================================
|
| 420 |
+
sf_task = None
|
| 421 |
+
try:
|
| 422 |
+
initial_activity_ids = {
|
| 423 |
+
a.get('activityId')
|
| 424 |
+
for a in sf_initial.get('activities', [])
|
| 425 |
+
if a.get('activityId')
|
| 426 |
+
}
|
| 427 |
+
candidates = []
|
| 428 |
+
for a in sf_cur.get('activities', []):
|
| 429 |
+
if a.get('activityId') in initial_activity_ids:
|
| 430 |
+
continue
|
| 431 |
+
if str(a.get('type', '')).lower() != 'task':
|
| 432 |
+
continue
|
| 433 |
+
if a.get('relatedToId') != 'opp-2':
|
| 434 |
+
continue
|
| 435 |
+
activity_text = ' '.join(_all_strings(a))
|
| 436 |
+
if _is_pricing_action(activity_text):
|
| 437 |
+
score = int(a.get('assignedToId') == 'user-1')
|
| 438 |
+
score += int(_date_matches(a.get('dueDate', ''), DATE_PROPOSAL))
|
| 439 |
+
candidates.append((score, a))
|
| 440 |
+
if candidates:
|
| 441 |
+
_, sf_task = max(candidates, key=lambda item: item[0])
|
| 442 |
+
except Exception as ex:
|
| 443 |
+
print(f'ERROR: Salesforce scan — {ex}')
|
| 444 |
+
|
| 445 |
+
# Component 2a: task on opp-2 referencing pricing proposal, assigned to user-1 (0.20)
|
| 446 |
+
try:
|
| 447 |
+
if sf_task and sf_task.get('assignedToId') == 'user-1':
|
| 448 |
+
print(f"PASS: Salesforce — pricing-proposal task on opp-2 assigned to user-1 "
|
| 449 |
+
f"(subject='{sf_task.get('subject')}') (0.20)")
|
| 450 |
+
total += 0.20
|
| 451 |
+
elif sf_task:
|
| 452 |
+
print(f"FAIL: Salesforce — task found on opp-2 but assignedToId={sf_task.get('assignedToId')} (expected user-1)")
|
| 453 |
+
else:
|
| 454 |
+
print('FAIL: Salesforce — no pricing-proposal task linked to opp-2')
|
| 455 |
+
except Exception as ex:
|
| 456 |
+
print(f'ERROR: Component SF-2a — {ex}')
|
| 457 |
+
|
| 458 |
+
# Component 2b: due date is 2026-06-26 (0.15)
|
| 459 |
+
try:
|
| 460 |
+
if sf_task and _date_matches(sf_task.get('dueDate', ''), DATE_PROPOSAL):
|
| 461 |
+
print(f'PASS: Salesforce — task dueDate is {DATE_PROPOSAL.isoformat()} (0.15)')
|
| 462 |
+
total += 0.15
|
| 463 |
+
elif sf_task:
|
| 464 |
+
print(
|
| 465 |
+
f"FAIL: Salesforce — dueDate={sf_task.get('dueDate')} "
|
| 466 |
+
f"(expected {DATE_PROPOSAL.isoformat()})"
|
| 467 |
+
)
|
| 468 |
+
else:
|
| 469 |
+
print('FAIL: Salesforce — no task to check dueDate')
|
| 470 |
+
except Exception as ex:
|
| 471 |
+
print(f'ERROR: Component SF-2b — {ex}')
|
| 472 |
+
|
| 473 |
+
# ============================================================
|
| 474 |
+
# NOTION — 0.30
|
| 475 |
+
# ============================================================
|
| 476 |
+
deepdive_row = None
|
| 477 |
+
notion_match = {'event_ok': False, 'date_ok': False, 'att_ok': False}
|
| 478 |
+
try:
|
| 479 |
+
initial_pages = notion_initial.get('pages', {}) or {}
|
| 480 |
+
initial_db = initial_pages.get('db-meetings') or {}
|
| 481 |
+
initial_items = set(initial_db.get('items', []) or [])
|
| 482 |
+
pages = notion_cur.get('pages', {}) or {}
|
| 483 |
+
db = pages.get('db-meetings') or {}
|
| 484 |
+
items = db.get('items', []) or []
|
| 485 |
+
candidates = []
|
| 486 |
+
for item_id in items:
|
| 487 |
+
if item_id in initial_items:
|
| 488 |
+
continue
|
| 489 |
+
row = pages.get(item_id) or {}
|
| 490 |
+
if row.get('parentId') != 'db-meetings':
|
| 491 |
+
continue
|
| 492 |
+
props = row.get('properties', {}) or {}
|
| 493 |
+
event_text = ' '.join([
|
| 494 |
+
str(row.get('title', '')),
|
| 495 |
+
' '.join(_all_strings(props.get('prop_event') or {})),
|
| 496 |
+
])
|
| 497 |
+
date_text = ' '.join(_all_strings(props.get('prop_date') or {}))
|
| 498 |
+
attendee_text = ' '.join(_all_strings(props.get('prop_attendee') or {}))
|
| 499 |
+
row_text = ' '.join([event_text, date_text, attendee_text])
|
| 500 |
+
has_distractor = (
|
| 501 |
+
DANIELA_EMAIL in _plain_text(row_text) or
|
| 502 |
+
DANIELA_NAME in _plain_text(row_text) or
|
| 503 |
+
'initrode' in _plain_text(row_text)
|
| 504 |
+
)
|
| 505 |
+
flags = {
|
| 506 |
+
'event_ok': _is_deepdive_action(event_text) and not has_distractor,
|
| 507 |
+
'date_ok': _date_matches(date_text, DATE_DEEPDIVE),
|
| 508 |
+
'att_ok': _is_daniel(attendee_text),
|
| 509 |
+
'date_text': date_text,
|
| 510 |
+
'attendee_text': attendee_text,
|
| 511 |
+
}
|
| 512 |
+
score = int(flags['event_ok']) + int(flags['date_ok']) + int(flags['att_ok'])
|
| 513 |
+
candidates.append((score, row, flags))
|
| 514 |
+
if candidates:
|
| 515 |
+
_, deepdive_row, notion_match = max(
|
| 516 |
+
candidates, key=lambda item: item[0]
|
| 517 |
+
)
|
| 518 |
+
except Exception as ex:
|
| 519 |
+
print(f'ERROR: Notion scan — {ex}')
|
| 520 |
+
|
| 521 |
+
# Component 3a: new Meetings row referencing the technical deep-dive (0.15)
|
| 522 |
+
try:
|
| 523 |
+
if deepdive_row and notion_match.get('event_ok'):
|
| 524 |
+
print(f"PASS: Notion — Meetings row for deep-dive found (title='{deepdive_row.get('title')}') (0.15)")
|
| 525 |
+
total += 0.15
|
| 526 |
+
elif deepdive_row:
|
| 527 |
+
print(
|
| 528 |
+
"FAIL: Notion — new Meetings row found but it does not clearly "
|
| 529 |
+
f"reference the technical deep-dive (title='{deepdive_row.get('title')}')"
|
| 530 |
+
)
|
| 531 |
+
else:
|
| 532 |
+
print('FAIL: Notion — no Meetings row referencing the technical deep-dive')
|
| 533 |
+
except Exception as ex:
|
| 534 |
+
print(f'ERROR: Component Notion-3a — {ex}')
|
| 535 |
+
|
| 536 |
+
# Component 3b: that row has Date 2026-06-24 and Attendee Daniel Park (0.15)
|
| 537 |
+
try:
|
| 538 |
+
if deepdive_row:
|
| 539 |
+
date_val = notion_match.get('date_text', '')
|
| 540 |
+
att_val = notion_match.get('attendee_text', '')
|
| 541 |
+
date_ok = notion_match.get('date_ok', False)
|
| 542 |
+
att_ok = notion_match.get('att_ok', False)
|
| 543 |
+
if date_ok and att_ok:
|
| 544 |
+
print(f"PASS: Notion — row Date {DATE_DEEPDIVE.isoformat()} and Attendee Daniel Park "
|
| 545 |
+
f"(date='{date_val}', attendee='{att_val}') (0.15)")
|
| 546 |
+
total += 0.15
|
| 547 |
+
else:
|
| 548 |
+
print(f"FAIL: Notion — date_ok={date_ok} (got '{date_val}'), att_ok={att_ok} (got '{att_val}')")
|
| 549 |
+
else:
|
| 550 |
+
print('FAIL: Notion — no deep-dive row to check Date/Attendee')
|
| 551 |
+
except Exception as ex:
|
| 552 |
+
print(f'ERROR: Component Notion-3b — {ex}')
|
| 553 |
+
|
| 554 |
+
final = round(min(total, 1.0), 4)
|
| 555 |
+
print(f'\nScore: {total}/1.0')
|
| 556 |
+
print(f'REWARD: {final}')
|
| 557 |
+
return final
|
| 558 |
+
|
| 559 |
+
|
| 560 |
+
verify_task()
|
legacy/ae_meeting_followup_002/reward_label.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"reward_file": "/apdcephfs_sh2/share_300000800/user/jackwkwang/long-horizon-tasks/mini_osworld_xiangwu/cache/ae_meeting_followup_002/reward.py",
|
| 3 |
+
"api_url": "http://28.7.184.184:8000/v1/chat/completions",
|
| 4 |
+
"model": "Kimi-K2.6",
|
| 5 |
+
"max_code_chars": 100000,
|
| 6 |
+
"created_at": "2026-07-03 18:58:53",
|
| 7 |
+
"label": {
|
| 8 |
+
"task_id": "ae_meeting_followup_002",
|
| 9 |
+
"domain": "mock_websites",
|
| 10 |
+
"summary": "验证代理在Initech续约电话后,是否通过Gmail向Daniel发送跟进邮件、在Salesforce的opp-2上记录定价提案任务,并在Notion的Meetings日历中添加技术深入交流会议。",
|
| 11 |
+
"is_placeholder": false,
|
| 12 |
+
"data_sources": [
|
| 13 |
+
"/tmp/task_web_sid",
|
| 14 |
+
"gmail_mock (http://28.7.186.212:8158)",
|
| 15 |
+
"salesforce_mock (http://28.7.186.212:8195)",
|
| 16 |
+
"notion_mock (http://28.7.186.212:8186)"
|
| 17 |
+
],
|
| 18 |
+
"scoring_components": [
|
| 19 |
+
{
|
| 20 |
+
"name": "Gmail Component 1a",
|
| 21 |
+
"weight": 0.2,
|
| 22 |
+
"description": "检查是否向Daniel Park发送了跟进邮件",
|
| 23 |
+
"check_logic": "遍历gmail_current_state中folder为'sent'且id不在initial_email_ids中的邮件,检查to字段是否包含daniel.park@initech.com;同时检查是否错误发送给daniela.park@initrode.com。若发送给Daniel且未发送给Daniela,则通过。",
|
| 24 |
+
"pass_condition": "存在一封发送给daniel.park@initech.com的新邮件,且未发送给daniela.park@initrode.com"
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"name": "Gmail Component 1b",
|
| 28 |
+
"weight": 0.15,
|
| 29 |
+
"description": "检查邮件内容是否回顾了两个约定事项及其日期",
|
| 30 |
+
"check_logic": "对发送给Daniel的邮件,合并subject、body、snippet进行文本分析。检查是否同时包含pricing proposal相关术语且日期匹配DATE_PROPOSAL,以及deep-dive相关术语且日期匹配DATE_DEEPDIVE、时间匹配TIME_DEEPDIVE。",
|
| 31 |
+
"pass_condition": "邮件正文同时包含pricing proposal(含日期2026-06-26)和technical deep-dive(含日期2026-06-24及对应时间)的回顾"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"name": "Salesforce Component 2a",
|
| 35 |
+
"weight": 0.2,
|
| 36 |
+
"description": "检查是否在opp-2上创建了引用定价提案的任务并分配给user-1",
|
| 37 |
+
"check_logic": "遍历salesforce_current_state中activityId不在initial_activity_ids、type为'task'、relatedToId为'opp-2'的活动,检查文本是否包含pricing相关术语,且assignedToId为'user-1'。",
|
| 38 |
+
"pass_condition": "存在新任务关联到opp-2,内容引用pricing proposal,且assignedToId等于'user-1'"
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"name": "Salesforce Component 2b",
|
| 42 |
+
"weight": 0.15,
|
| 43 |
+
"description": "检查Salesforce任务的截止日期是否为2026-06-26",
|
| 44 |
+
"check_logic": "对找到的pricing-proposal任务,使用_date_matches检查dueDate字段是否匹配DATE_PROPOSAL(2026-06-26)。",
|
| 45 |
+
"pass_condition": "任务的dueDate匹配2026-06-26"
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"name": "Notion Component 3a",
|
| 49 |
+
"weight": 0.15,
|
| 50 |
+
"description": "检查是否在Notion的Meetings数据库中新增了引用技术深入交流的行",
|
| 51 |
+
"check_logic": "遍历notion_current_state中pages下db-meetings的items,排除initial_items,检查parentId为'db-meetings'的行。合并title和prop_event文本,检查是否包含deep-dive相关术语,且不含干扰项(Daniela/Initrode)。",
|
| 52 |
+
"pass_condition": "存在新的Meetings行,内容引用technical deep-dive,且不包含Daniela Park或Initrode等干扰信息"
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"name": "Notion Component 3b",
|
| 56 |
+
"weight": 0.15,
|
| 57 |
+
"description": "检查Notion行的日期是否为2026-06-24且参与者为Daniel Park",
|
| 58 |
+
"check_logic": "对找到的deep-dive行,检查prop_date是否匹配DATE_DEEPDIVE(2026-06-24),且prop_attendee是否包含Daniel Park(不含Daniela)。",
|
| 59 |
+
"pass_condition": "行的Date属性匹配2026-06-24,且Attendee属性包含Daniel Park"
|
| 60 |
+
}
|
| 61 |
+
],
|
| 62 |
+
"total_max_score": 1.0,
|
| 63 |
+
"score_aggregation": "各组件分数相加,最终通过round(min(total, 1.0), 4)钳制到1.0并保留4位小数",
|
| 64 |
+
"failure_modes": [
|
| 65 |
+
"无法从/tmp/task_web_sid读取sid时打印CRITICAL并返回0.0",
|
| 66 |
+
"无法从任一mock服务获取状态时打印CRITICAL并返回0.0",
|
| 67 |
+
"Gmail邮件同时发送给Daniela Park(干扰项)时,Gmail相关credit被扣减(不加分)",
|
| 68 |
+
"Notion行包含Daniela/Initrode等干扰项时,event_ok为False导致该组件不得分",
|
| 69 |
+
"各mock中未找到符合条件的新增项目时对应组件不得分"
|
| 70 |
+
],
|
| 71 |
+
"scoring_logic_explanation": "脚本首先读取/tmp/task_web_sid获取会话ID,然后分别向gmail、salesforce、notion三个mock服务拉取initial_state和current_state。对于Gmail,扫描Sent文件夹中新增邮件,优先匹配发送给daniel.park@initech.com的邮件,若同时发送给daniela.park@initrode.com则触发干扰项门控;对有效邮件检查正文是否同时包含pricing proposal��含日期2026-06-26)和technical deep-dive(含日期2026-06-24及时间)。对于Salesforce,扫描activities中新增且type为task、relatedToId为opp-2的记录,检查是否引用pricing proposal、assignedToId为user-1、dueDate为2026-06-26。对于Notion,扫描db-meetings中新增行,检查是否引用deep-dive(无干扰项)、Date为2026-06-24、Attendee为Daniel Park。各子项通过则累加对应权重(0.20/0.15/0.20/0.15/0.15/0.15),最终总分经min(total, 1.0)钳制后四舍五入到4位小数输出。",
|
| 72 |
+
"confidence": 1.0
|
| 73 |
+
},
|
| 74 |
+
"raw_response": "用户要求我分析一个 reward.py 评分脚本的评分逻辑,并以 JSON 格式输出结果。\n\n让我仔细阅读代码:\n\n1. **任务信息**:\n - Task ID: ae_meeting_followup_002\n - Domain: mock_websites (multi-mock: gmail, salesforce, notion)\n - 这是一个跨 Gmail、Salesforce 和 Notion 的 AE 会议后续任务\n\n2. **数据源**:\n - `/tmp/task_web_sid` - 读取 sid\n - `http://28.7.186.212:8158` - gmail mock\n - `http://28.7.186.212:8195` - salesforce mock\n - `http://28.7.186.212:8186` - notion mock\n\n3. **评分组件**:\n - Gmail: 0.35\n - Component 1a: 发送给 daniel.park@initech.com (0.20)\n - Component 1b: 邮件内容回顾两个约定事项和日期 (0.15)\n - Salesforce: 0.35\n - Component 2a: opp-2 上的任务引用 pricing proposal,分配给 user-1 (0.20)\n - Component 2b: dueDate 为 2026-06-26 (0.15)\n - Notion: 0.30\n - Component 3a: 新的 Meetings 行引用 technical deep-dive (0.15)\n - Component 3b: 日期为 2026-06-24,参与者为 Daniel Park (0.15)\n\n4. **干扰项检查**:\n - 如果代理错误地给 Daniela Park 发送邮件,Gmail 分数会被扣减(sent_to_daniela 为 True 时,Gmail 的 credit 被扣减)\n - Notion 中如果行包含 Daniela/Initrode 等干扰项,has_distractor 为 True\n\n5. **失败模式**:\n - 无法读取 sid -> 0.0\n - 无法从 mock 获取状态 -> 0.0\n - 发送给 Daniela(干扰项)-> Gmail 分数被扣减\n - 没有找到对应的项目 -> 该组件失败\n\n6. **分数汇总**:\n - 各组件分数相加\n - 最终 `round(min(total, 1.0), 4)`\n\n7. **is_placeholder**:\n - false,因为脚本确实进行了详细的状态检查和评分\n\n8. **confidence**:\n - 1.0,因为代码逻辑非常清晰\n\n现在构建 JSON:\n\n```json\n{\n \"task_id\": \"ae_meeting_followup_002\",\n \"domain\": \"mock_websites\",\n \"summary\": \"验证代理在Initech续约电话后,是否通过Gmail向Daniel发送跟进邮件、在Salesforce的opp-2上记录定价提案任务,并在Notion的Meetings日历中添加技术深入交流会议。\",\n \"is_placeholder\": false,\n \"data_sources\": [\"/tmp/task_web_sid\", \"gmail_mock (http://28.7.186.212:8158)\", \"salesforce_mock (http://28.7.186.212:8195)\", \"notion_mock (http://28.7.186.212:8186)\"],\n \"scoring_components\": [\n {\n \"name\": \"Gmail Component 1a\",\n \"weight\": 0.2,\n \"description\": \"检查是否向Daniel Park发送了跟进邮件\",\n \"check_logic\": \"遍历gmail_current_state中folder为'sent'且id不在initial_email_ids中的邮件,检查to字段是否包含daniel.park@initech.com;同时检查是否错误发送给daniela.park@initrode.com。若发送给Daniel且未发送给Daniela,则通过。\",\n \"pass_condition\": \"存在一封发送给daniel.park@initech.com的新邮件,且未发送给daniela.park@initrode.com\"\n },\n {\n \"name\": \"Gmail Component 1b\",\n \"weight\": 0.15,\n \"description\": \"检查邮件内容是否回顾了两个约定事项及其日期\",\n \"check_logic\": \"对发送给Daniel的邮件,合并subject、body、snippet进行文本分析。检查是否同时包含pricing proposal相关术语且日期匹配DATE_PROPOSAL,以及deep-dive相关术语且日期匹配DATE_DEEPDIVE、时间匹配TIME_DEEPDIVE。\",\n \"pass_condition\": \"邮件正文同时包含pricing proposal(含日期2026-06-26)和technical deep-dive(含日期2026-06-24及对应时间)的回顾\"\n },\n {\n \"name\": \"Salesforce Component 2a\",\n \"weight\": 0.2,\n \"description\": \"检查是否在opp-2上创建了引用定价提案的任务并分配给user-1\",\n \"check_logic\": \"遍历salesforce_current_state中activityId不在initial_activity_ids、type为'task'、relatedToId为'opp-2'的活动,检查文本是否包含pricing相关术语,且assignedToId为'user-1'。\",\n \"pass_condition\": \"存在新任务关联到opp-2,内容引用pricing proposal,且assignedToId等于'user-1'\"\n },\n {\n \"name\": \"Salesforce Component 2b\",\n \"weight\": 0.15,\n \"description\": \"检查Salesforce任务的截止日期是否为2026-06-26\",\n \"check_logic\": \"对找到的pricing-proposal任务,使用_date_matches检查dueDate字段是否匹配DATE_PROPOSAL(2026-06-26)。\",\n \"pass_condition\": \"任务的dueDate匹配2026-06-26\"\n },\n {\n \"name\": \"Notion Component 3a\",\n \"weight\": 0.15,\n \"description\": \"检查是否在Notion的Meetings数据库中新增了引用技术深入交流的行\",\n \"check_logic\": \"遍历notion_current_state中pages下db-meetings的items,排除initial_items,检查parentId为'db-meetings'的行。合并title和prop_event文本,检查是否包含deep-dive相关术语,且不含干扰项(Daniela/Initrode)。\",\n \"pass_condition\": \"存在新的Meetings行,内容引用technical deep-dive,且不包含Daniela Park或Initrode等干扰信息\"\n },\n {\n \"name\": \"Notion Component 3b\",\n \"weight\": 0.15,\n \"description\": \"检查Notion行的日期是否为2026-06-24且参与者为Daniel Park\",\n \"check_logic\": \"对找到的deep-dive行,检查prop_date是否匹配DATE_DEEPDIVE(2026-06-24),且prop_attendee是否包含Daniel Park(不含Daniela)。\",\n \"pass_condition\": \"行的Date属性匹配2026-06-24,且Attendee属性包含Daniel Park\"\n }\n ],\n \"total_max_score\": 1.0,\n \"score_aggregation\": \"各组件分数相加,最终通过round(min(total, 1.0), 4)钳制到1.0并保留4位小数\",\n \"failure_modes\": [\n \"无法从/tmp/task_web_sid读取sid时打印CRITICAL并返回0.0\",\n \"无法从任一mock服务获取状态时打印CRITICAL并返回0.0\",\n \"Gmail邮件同时发送给Daniela Park(干扰项)时,Gmail相关credit被扣减(不加分)\",\n \"Notion行包含Daniela/Initrode等干扰项时,event_ok为False导致该组件不得分\",\n \"各mock中未找到符合条件的新增项目时对应组件不得分\"\n ],\n \"scoring_logic_explanation\": \"脚本首先读取/tmp/task_web_sid获取会话ID,然后分别向gmail、salesforce、notion三个mock服务拉取initial_state和current_state。对于Gmail,扫描Sent文件夹中新增邮件,优先匹配发送给daniel.park@initech.com的邮件,若同时发送给daniela.park@initrode.com则触发干扰项门控;对有效邮件检查正文是否同时包含pricing proposal(含日期2026-06-26)和technical deep-dive(含日期2026-06-24及时间)。对于Salesforce,扫描activities中新增且type为task、relatedToId为opp-2的记录,检查是否引用pricing proposal、assignedToId为user-1、dueDate为2026-06-26。对于Notion,扫描db-meetings中新增行,检查是否引用deep-dive(无干扰项)、Date为2026-06-24、Attendee为Daniel Park。各子项通过则累加对应权重(0.20/0.15/0.20/0.15/0.15/0.15),最终总分经min(total, 1.0)钳制后四舍五入到4位小数输出。\",\n \"confidence\": 1.0\n}\n```\n\n检查字段:\n- task_id: ae_meeting_followup_002 ✓\n- domain: mock_websites ✓\n- summary: 一句话概括 ✓\n- is_placeholder: false ✓\n- data_sources: 包含三个mock和sid文件 ✓\n- scoring_components: 6个组件,权重正确 ✓\n- total_max_score: 1.0 ✓\n- score_aggregation: 相加并钳制 ✓\n- failure_modes: 列出了关键失败路径 ✓\n- scoring_logic_explanation: 详细中文解释 ✓\n- confidence: 1.0 ✓\n\n确保没有Markdown代码块,第一个字符是{,最后一个字符是}。 </think> {\n \"task_id\": \"ae_meeting_followup_002\",\n \"domain\": \"mock_websites\",\n \"summary\": \"验证代理在Initech续约电话后,是否通过Gmail向Daniel发送跟进邮件、在Salesforce的opp-2上记录定价提案任务,并在Notion的Meetings日历中添加技术深入交流会议。\",\n \"is_placeholder\": false,\n \"data_sources\": [\"/tmp/task_web_sid\", \"gmail_mock (http://28.7.186.212:8158)\", \"salesforce_mock (http://28.7.186.212:8195)\", \"notion_mock (http://28.7.186.212:8186)\"],\n \"scoring_components\": [\n {\n \"name\": \"Gmail Component 1a\",\n \"weight\": 0.2,\n \"description\": \"检查是否向Daniel Park发送了跟进邮件\",\n \"check_logic\": \"遍历gmail_current_state中folder为'sent'且id不在initial_email_ids中的邮件,检查to字段是否包含daniel.park@initech.com;同时检查是否错误发送给daniela.park@initrode.com。若发送给Daniel且未发送给Daniela,则通过。\",\n \"pass_condition\": \"存在一封发送给daniel.park@initech.com的新邮件,且未发送给daniela.park@initrode.com\"\n },\n {\n \"name\": \"Gmail Component 1b\",\n \"weight\": 0.15,\n \"description\": \"检查邮件内容是否回顾了两个约定事项及其日期\",\n \"check_logic\": \"对发送给Daniel的邮件,合并subject、body、snippet进行文本分析。检查是否同时包含pricing proposal相关术语且日期匹配DATE_PROPOSAL,以及deep-dive相关术语且日期匹配DATE_DEEPDIVE、时间匹配TIME_DEEPDIVE。\",\n \"pass_condition\": \"邮件正文同时包含pricing proposal(含日期2026-06-26)和technical deep-dive(含日期2026-06-24及对应时间)的回顾\"\n },\n {\n \"name\": \"Salesforce Component 2a\",\n \"weight\": 0.2,\n \"description\": \"检查是否在opp-2上创建了引用定价提案���任务并分配给user-1\",\n \"check_logic\": \"遍历salesforce_current_state中activityId不在initial_activity_ids、type为'task'、relatedToId为'opp-2'的活动,检查文本是否包含pricing相关术语,且assignedToId为'user-1'。\",\n \"pass_condition\": \"存在新任务关联到opp-2,内容引用pricing proposal,且assignedToId等于'user-1'\"\n },\n {\n \"name\": \"Salesforce Component 2b\",\n \"weight\": 0.15,\n \"description\": \"检查Salesforce任务的截止日期是否为2026-06-26\",\n \"check_logic\": \"对找到的pricing-proposal任务,使用_date_matches检查dueDate字段是否匹配DATE_PROPOSAL(2026-06-26)。\",\n \"pass_condition\": \"任务的dueDate匹配2026-06-26\"\n },\n {\n \"name\": \"Notion Component 3a\",\n \"weight\": 0.15,\n \"description\": \"检查是否在Notion的Meetings数据库中新增了引用技术深入交流的行\",\n \"check_logic\": \"遍历notion_current_state中pages下db-meetings的items,排除initial_items,检查parentId为'db-meetings'的行。合并title和prop_event文本,检查是否包含deep-dive相关术语,且不含干扰项(Daniela/Initrode)。\",\n \"pass_condition\": \"存在新的Meetings行,内容引用technical deep-dive,且不包含Daniela Park或Initrode等干扰信息\"\n },\n {\n \"name\": \"Notion Component 3b\",\n \"weight\": 0.15,\n \"description\": \"检查Notion行的日期是否为2026-06-24且参与者为Daniel Park\",\n \"check_logic\": \"对找到的deep-dive行,检查prop_date是否匹配DATE_DEEPDIVE(2026-06-24),且prop_attendee是否包含Daniel Park(不含Daniela)。\",\n \"pass_condition\": \"行的Date属性匹配2026-06-24,且Attendee属性包含Daniel Park\"\n }\n ],\n \"total_max_score\": 1.0,\n \"score_aggregation\": \"各组件分数相加,最终通过round(min(total, 1.0), 4)钳制到1.0并保留4位小数\",\n \"failure_modes\": [\n \"无法从/tmp/task_web_sid读取sid时打印CRITICAL并返回0.0\",\n \"无法从任一mock服务获取状态时打印CRITICAL并返回0.0\",\n \"Gmail邮件同时发送给Daniela Park(干扰项)时,Gmail相关credit被扣减(不加分)\",\n \"Notion行包含Daniela/Initrode等干扰项时,event_ok为False导致该组件不得分\",\n \"各mock中未找到符合条件的新增项目时对应组件不得分\"\n ],\n \"scoring_logic_explanation\": \"脚本首先读取/tmp/task_web_sid获取会话ID,然后分别向gmail、salesforce、notion三个mock服务拉取initial_state和current_state。对于Gmail,扫描Sent文件夹中新增邮件,优先匹配发送给daniel.park@initech.com的邮件,若同时发送给daniela.park@initrode.com则触发干扰项门控;对有效邮件检查正文是否同时包含pricing proposal(含日期2026-06-26)和technical deep-dive(含日期2026-06-24及时间)。对于Salesforce,扫描activities中新增且type为task、relatedToId为opp-2的记录,检查是否引用pricing proposal、assignedToId为user-1、dueDate为2026-06-26。对于Notion,扫描db-meetings中新增行,检查是否引用deep-dive(无干扰项)、Date为2026-06-24、Attendee为Daniel Park。各子项通过则累加对应权重(0.20/0.15/0.20/0.15/0.15/0.15),最终总分经min(total, 1.0)钳制后四舍五入到4位小数输出。\",\n \"confidence\": 1.0\n}"
|
| 75 |
+
}
|
legacy/am_renewal_cycle_004/_cua_gym_vm_bridge.sh
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# CUA-Gym VM-side network fix (direct-IP mock access).
|
| 3 |
+
#
|
| 4 |
+
# Runs INSIDE the QEMU guest. The CUA-Gym mock services are now reached by
|
| 5 |
+
# their real IDC address (http://28.7.186.212:81xx) instead of the old
|
| 6 |
+
# localhost:9000-9097 socat bridge, so the VM only needs two fixes:
|
| 7 |
+
#
|
| 8 |
+
# 1. Working DNS — the qcow2-baked /etc/resolv.conf points at the Pod's
|
| 9 |
+
# cluster DNS, which is unreachable from QEMU SLIRP NAT
|
| 10 |
+
# ("Temporary failure in name resolution").
|
| 11 |
+
# 2. The mock host excluded from the woa http proxy — otherwise the VM's
|
| 12 |
+
# Chrome (gsettings proxy) and initial_setup.py's `requests` get a 403
|
| 13 |
+
# from the proxy when hitting 28.7.186.212:81xx. (The old socat path never
|
| 14 |
+
# hit this because localhost is bypassed by default.)
|
| 15 |
+
#
|
| 16 |
+
# Idempotent. Scoped to the CUA-Gym bridge step; does not touch the generic
|
| 17 |
+
# OSWorld setup pipeline.
|
| 18 |
+
#
|
| 19 |
+
# Argv:
|
| 20 |
+
# $1 optional sudo password (default "password"; SetupController
|
| 21 |
+
# substitutes {CLIENT_PASSWORD} when uploaded as a cache file).
|
| 22 |
+
# $2 unused (kept for backward compat — was socat first port 9000).
|
| 23 |
+
# $3 unused (kept for backward compat — was socat last port 9097).
|
| 24 |
+
# $4 optional mock host IP (default 28.7.186.212).
|
| 25 |
+
|
| 26 |
+
set +e
|
| 27 |
+
|
| 28 |
+
PASS="${1:-password}"
|
| 29 |
+
MOCK_HOST="${4:-28.7.186.212}"
|
| 30 |
+
# Derive the /16 IDC subnet so future port/host tweaks on the same segment
|
| 31 |
+
# stay bypassed too (28.7.186.212 -> 28.133.0.0/16).
|
| 32 |
+
MOCK_NET="$(echo "${MOCK_HOST}" | awk -F. 'NF==4{print $1"."$2".0.0/16"}')"
|
| 33 |
+
|
| 34 |
+
run_root() {
|
| 35 |
+
echo "$PASS" | sudo -S -p "" bash -c "$1"
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
# Detect SLIRP gateway from VM's routing table; fall back to 10.0.2.2.
|
| 39 |
+
GW="$(ip route 2>/dev/null | awk '/default/ {print $3; exit}')"
|
| 40 |
+
GW="${GW:-10.0.2.2}"
|
| 41 |
+
|
| 42 |
+
# ─── CUA-Gym network fix (Taiji-specific) ─────────────────────────────
|
| 43 |
+
fix_vm_network() {
|
| 44 |
+
# 0) Discover VM network state at runtime — gateway, own IP/CIDR, SLIRP
|
| 45 |
+
# DNS forwarder. Nothing hardcoded except the mock host above.
|
| 46 |
+
local GW_NET="${GW%.*}"
|
| 47 |
+
local SLIRP_DNS="${GW_NET}.3" # QEMU SLIRP DNS proxy is always .3
|
| 48 |
+
local OWN_CIDR
|
| 49 |
+
OWN_CIDR="$(ip -4 -o addr show scope global 2>/dev/null \
|
| 50 |
+
| awk '{print $4; exit}')"
|
| 51 |
+
local OWN_IP="${OWN_CIDR%/*}"
|
| 52 |
+
local OWN_NET=""
|
| 53 |
+
[ -n "${OWN_IP}" ] && OWN_NET="${OWN_IP%.*}.0/24"
|
| 54 |
+
|
| 55 |
+
# 1) DNS — point at SLIRP DNS proxy + public fallbacks. chattr +i keeps
|
| 56 |
+
# systemd-resolved/NetworkManager from clobbering it.
|
| 57 |
+
if run_root "printf 'nameserver ${SLIRP_DNS}\\nnameserver 114.114.114.114\\nnameserver 8.8.8.8\\n' > /etc/resolv.conf
|
| 58 |
+
chattr +i /etc/resolv.conf 2>/dev/null || true"; then
|
| 59 |
+
echo "[cua_gym_vm_bridge] DNS set: ${SLIRP_DNS}, 114.114.114.114, 8.8.8.8 (gw=${GW})"
|
| 60 |
+
else
|
| 61 |
+
echo "[cua_gym_vm_bridge] WARN: failed to write /etc/resolv.conf"
|
| 62 |
+
fi
|
| 63 |
+
|
| 64 |
+
# 2) Build the proxy bypass list from detected values + the direct-IP
|
| 65 |
+
# mock host (and its /16 subnet). THIS is what makes 28.7.186.212:81xx
|
| 66 |
+
# reachable from inside the VM — without it the woa proxy 403s it.
|
| 67 |
+
local ignore_list="['localhost', '127.0.0.0/8', '${GW}'"
|
| 68 |
+
[ -n "${OWN_IP}" ] && ignore_list="${ignore_list}, '${OWN_IP}'"
|
| 69 |
+
[ -n "${OWN_NET}" ] && ignore_list="${ignore_list}, '${OWN_NET}'"
|
| 70 |
+
[ -n "${GW_NET}" ] && ignore_list="${ignore_list}, '${GW_NET}.0/24'"
|
| 71 |
+
[ -n "${MOCK_HOST}" ] && ignore_list="${ignore_list}, '${MOCK_HOST}'"
|
| 72 |
+
[ -n "${MOCK_NET}" ] && ignore_list="${ignore_list}, '${MOCK_NET}'"
|
| 73 |
+
ignore_list="${ignore_list}]"
|
| 74 |
+
|
| 75 |
+
# 3) GNOME proxy ignore-hosts — Chrome bypasses the woa proxy for these.
|
| 76 |
+
if gsettings set org.gnome.system.proxy ignore-hosts "${ignore_list}" 2>/tmp/gsettings_err; then
|
| 77 |
+
echo "[cua_gym_vm_bridge] gsettings ignore-hosts = ${ignore_list}"
|
| 78 |
+
else
|
| 79 |
+
echo "[cua_gym_vm_bridge] WARN: gsettings ignore-hosts failed: $(cat /tmp/gsettings_err 2>/dev/null)"
|
| 80 |
+
fi
|
| 81 |
+
|
| 82 |
+
# 4) Shell env — comma-separated form for no_proxy/NO_PROXY (requests/curl).
|
| 83 |
+
local NP="localhost,127.0.0.1,${GW}"
|
| 84 |
+
[ -n "${OWN_IP}" ] && NP="${NP},${OWN_IP}"
|
| 85 |
+
[ -n "${OWN_NET}" ] && NP="${NP},${OWN_NET}"
|
| 86 |
+
[ -n "${GW_NET}" ] && NP="${NP},${GW_NET}.0/24"
|
| 87 |
+
[ -n "${MOCK_HOST}" ] && NP="${NP},${MOCK_HOST}"
|
| 88 |
+
[ -n "${MOCK_NET}" ] && NP="${NP},${MOCK_NET}"
|
| 89 |
+
|
| 90 |
+
for var in no_proxy NO_PROXY; do
|
| 91 |
+
if ! grep -q "export ${var}=${NP}" /home/user/.bashrc 2>/dev/null; then
|
| 92 |
+
echo "export ${var}=${NP}" >> /home/user/.bashrc
|
| 93 |
+
fi
|
| 94 |
+
done
|
| 95 |
+
run_root "grep -q '^no_proxy=' /etc/environment 2>/dev/null \
|
| 96 |
+
&& sed -i 's|^no_proxy=.*|no_proxy=\"${NP}\"|' /etc/environment \
|
| 97 |
+
|| echo 'no_proxy=\"${NP}\"' >> /etc/environment
|
| 98 |
+
grep -q '^NO_PROXY=' /etc/environment 2>/dev/null \
|
| 99 |
+
&& sed -i 's|^NO_PROXY=.*|NO_PROXY=\"${NP}\"|' /etc/environment \
|
| 100 |
+
|| echo 'NO_PROXY=\"${NP}\"' >> /etc/environment" >/dev/null 2>&1
|
| 101 |
+
echo "[cua_gym_vm_bridge] no_proxy=${NP}"
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
fix_vm_network
|
| 105 |
+
|
| 106 |
+
echo "[cua_gym_vm_bridge] direct-IP mode: ${MOCK_HOST} (+${MOCK_NET}) bypassed from woa proxy; no socat forwarding needed"
|
legacy/am_renewal_cycle_004/initial_setup.py
ADDED
|
@@ -0,0 +1,675 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# --- MOCK_HOST_NO_PROXY_OVERRIDE: bypass woa proxy for locally-deployed mocks ---
|
| 2 |
+
import os as _os
|
| 3 |
+
_np = _os.environ.get("no_proxy", _os.environ.get("NO_PROXY", ""))
|
| 4 |
+
for _h in ("127.0.0.1", "localhost", "28.7.186.212"):
|
| 5 |
+
if _h not in _np:
|
| 6 |
+
_np = (_np + "," + _h).lstrip(",")
|
| 7 |
+
_os.environ["no_proxy"] = _np
|
| 8 |
+
_os.environ["NO_PROXY"] = _np
|
| 9 |
+
# --- end override ---
|
| 10 |
+
|
| 11 |
+
# --- wait_mocks_loaded: wait for mock backends ready AND browser tabs rendered ---
|
| 12 |
+
def wait_mocks_loaded(timeout=60, render_buffer=12):
|
| 13 |
+
"""Wait for mock backends ready AND browser tabs rendered (via CDP).
|
| 14 |
+
|
| 15 |
+
Phase 1 — backend readiness: poll each mock's /state?sid= until it
|
| 16 |
+
returns 200 with 'stored_state' in the body.
|
| 17 |
+
|
| 18 |
+
Phase 2 — browser render verification: connect to Chrome's CDP
|
| 19 |
+
endpoint and wait for every open tab to reach 'networkidle' load
|
| 20 |
+
state with a non-trivial DOM element count. This confirms the SPA
|
| 21 |
+
has fetched its /go?sid= data and actually painted, not just that
|
| 22 |
+
the backend is up.
|
| 23 |
+
|
| 24 |
+
CDP port auto-detection: checks globals for _chrome_debug_port /
|
| 25 |
+
cdp_port / debug_port (set by tasks that use a dynamic port, e.g.
|
| 26 |
+
se_hard_008's launch_chrome_with_urls); defaults to 1337 for tasks
|
| 27 |
+
that use launch_gui's --remote-debugging-port injection.
|
| 28 |
+
|
| 29 |
+
Falls back to the old render_buffer sleep if Playwright or the CDP
|
| 30 |
+
endpoint is unavailable.
|
| 31 |
+
"""
|
| 32 |
+
import urllib.request as _u, time as _t
|
| 33 |
+
g = globals()
|
| 34 |
+
_urls = {}
|
| 35 |
+
for _k, _v in list(g.items()):
|
| 36 |
+
if isinstance(_v, dict) and _v and all(isinstance(x, str) and x.startswith("http://") for x in _v.values()):
|
| 37 |
+
_urls.update(_v)
|
| 38 |
+
elif isinstance(_v, str) and _v.startswith("http://") and (_k.endswith("_URL") or _k.endswith("_url")):
|
| 39 |
+
_urls[_k] = _v
|
| 40 |
+
_sid = ""
|
| 41 |
+
for _k in ("sid", "SID", "task_sid", "session_id"):
|
| 42 |
+
if isinstance(g.get(_k), str) and g[_k]:
|
| 43 |
+
_sid = g[_k]; break
|
| 44 |
+
if not _sid:
|
| 45 |
+
for _k, _v in g.items():
|
| 46 |
+
if "sid" in _k.lower() and isinstance(_v, str) and _v:
|
| 47 |
+
_sid = _v; break
|
| 48 |
+
if not _urls or not _sid:
|
| 49 |
+
print(" wait_mocks_loaded: no mocks/sid found (%d urls, sid=%r), skipping" % (len(_urls), bool(_sid)))
|
| 50 |
+
return
|
| 51 |
+
|
| 52 |
+
# ---- Phase 1: backend readiness ----
|
| 53 |
+
_op = _u.build_opener(_u.ProxyHandler({}))
|
| 54 |
+
_dl = _t.time() + timeout
|
| 55 |
+
_todo = list(_urls.items())
|
| 56 |
+
while _todo and _t.time() < _dl:
|
| 57 |
+
_rest = []
|
| 58 |
+
for _n2, _uu in _todo:
|
| 59 |
+
try:
|
| 60 |
+
_r = _op.open("%s/state?sid=%s" % (_uu, _sid), timeout=5)
|
| 61 |
+
if _r.status == 200 and b"stored_state" in _r.read():
|
| 62 |
+
print(" %s: backend ready" % _n2); continue
|
| 63 |
+
except Exception:
|
| 64 |
+
pass
|
| 65 |
+
_rest.append((_n2, _uu))
|
| 66 |
+
_todo = _rest
|
| 67 |
+
if _todo:
|
| 68 |
+
_t.sleep(2)
|
| 69 |
+
_done = len(_urls) - len(_todo)
|
| 70 |
+
_pend = (" (pending: %s)" % [n for n, _ in _todo]) if _todo else ""
|
| 71 |
+
print(" mocks backend ready: %d/%d%s" % (_done, len(_urls), _pend))
|
| 72 |
+
|
| 73 |
+
# ---- Phase 2: browser render verification via CDP ----
|
| 74 |
+
# Auto-detect CDP port from globals (set by launch_chrome_with_urls
|
| 75 |
+
# in tasks that use a dynamic port); default to 1337.
|
| 76 |
+
_cdp_port = 1337
|
| 77 |
+
for _pk in ("_chrome_debug_port", "chrome_debug_port", "cdp_port", "debug_port"):
|
| 78 |
+
_pv = g.get(_pk)
|
| 79 |
+
if isinstance(_pv, int) and 0 < _pv < 65536:
|
| 80 |
+
_cdp_port = _pv; break
|
| 81 |
+
_cdp_ok = False
|
| 82 |
+
try:
|
| 83 |
+
from playwright.sync_api import sync_playwright
|
| 84 |
+
_cdp_dl = _t.time() + max(10.0, _dl - _t.time()) # leftover budget, floor 10s
|
| 85 |
+
with sync_playwright() as _p:
|
| 86 |
+
_br = None
|
| 87 |
+
# Retry-connect: Chrome may still be starting up.
|
| 88 |
+
while _t.time() < _cdp_dl:
|
| 89 |
+
try:
|
| 90 |
+
_br = _p.chromium.connect_over_cdp("http://localhost:%d" % _cdp_port)
|
| 91 |
+
break
|
| 92 |
+
except Exception:
|
| 93 |
+
_t.sleep(0.5)
|
| 94 |
+
if _br is None:
|
| 95 |
+
print(" wait_mocks_loaded: CDP connect to localhost:%d failed; "
|
| 96 |
+
"is Chrome launched with --remote-debugging-port?" % _cdp_port)
|
| 97 |
+
else:
|
| 98 |
+
# Wait for ALL expected tabs to appear, then verify each renders.
|
| 99 |
+
_n_expected = len(_urls)
|
| 100 |
+
_pages = []
|
| 101 |
+
_pg_dl = _t.time() + 15
|
| 102 |
+
_last_count = -1
|
| 103 |
+
_stable_since = None
|
| 104 |
+
while _t.time() < _pg_dl:
|
| 105 |
+
_pages = []
|
| 106 |
+
for _c in _br.contexts:
|
| 107 |
+
_pages.extend(_c.pages)
|
| 108 |
+
_cnt = len(_pages)
|
| 109 |
+
if _n_expected > 0 and _cnt >= _n_expected:
|
| 110 |
+
break # all expected tabs are open
|
| 111 |
+
if _cnt > 0 and _cnt == _last_count:
|
| 112 |
+
if _stable_since is None:
|
| 113 |
+
_stable_since = _t.time()
|
| 114 |
+
elif _t.time() - _stable_since >= 1.5:
|
| 115 |
+
break # tab count stable -> no more tabs opening
|
| 116 |
+
else:
|
| 117 |
+
_stable_since = None
|
| 118 |
+
_last_count = _cnt
|
| 119 |
+
_t.sleep(0.5)
|
| 120 |
+
# Re-fetch final snapshot so late-opening tabs are included.
|
| 121 |
+
_pages = []
|
| 122 |
+
for _c in _br.contexts:
|
| 123 |
+
_pages.extend(_c.pages)
|
| 124 |
+
if not _pages:
|
| 125 |
+
print(" wait_mocks_loaded: CDP connected but no open tabs found")
|
| 126 |
+
else:
|
| 127 |
+
print(" wait_mocks_loaded: %d tab(s) open (expected %d); "
|
| 128 |
+
"verifying render" % (len(_pages), _n_expected))
|
| 129 |
+
_ok_cnt = 0
|
| 130 |
+
for _pg in _pages:
|
| 131 |
+
_ttl = ""
|
| 132 |
+
try:
|
| 133 |
+
_ttl = _pg.title()
|
| 134 |
+
except Exception:
|
| 135 |
+
pass
|
| 136 |
+
try:
|
| 137 |
+
_pg.wait_for_load_state(
|
| 138 |
+
"networkidle",
|
| 139 |
+
timeout=int(max(5000, (_cdp_dl - _t.time()) * 1000)))
|
| 140 |
+
_n = _pg.evaluate("document.querySelectorAll('*').length")
|
| 141 |
+
if _n < 20:
|
| 142 |
+
print(" wait_mocks_loaded: WARNING tab %r has only %d "
|
| 143 |
+
"elements (render stall?)" % (_ttl, _n))
|
| 144 |
+
else:
|
| 145 |
+
print(" wait_mocks_loaded: tab %r rendered (%d elements)"
|
| 146 |
+
% (_ttl, _n))
|
| 147 |
+
_ok_cnt += 1
|
| 148 |
+
except Exception as _e:
|
| 149 |
+
print(" wait_mocks_loaded: tab %r render wait failed: %r"
|
| 150 |
+
% (_ttl, _e))
|
| 151 |
+
# Require ALL open tabs to render before skipping the
|
| 152 |
+
# render_buffer fallback, so no tab is left half-loaded.
|
| 153 |
+
if _ok_cnt > 0 and _ok_cnt == len(_pages):
|
| 154 |
+
_cdp_ok = True
|
| 155 |
+
else:
|
| 156 |
+
print(" wait_mocks_loaded: %d/%d tabs rendered, will fall back"
|
| 157 |
+
% (_ok_cnt, len(_pages)))
|
| 158 |
+
except ImportError:
|
| 159 |
+
print(" wait_mocks_loaded: playwright not installed; cannot verify browser render")
|
| 160 |
+
except Exception as _e:
|
| 161 |
+
print(" wait_mocks_loaded: CDP phase error (%r)" % _e)
|
| 162 |
+
|
| 163 |
+
if not _cdp_ok:
|
| 164 |
+
print(" wait_mocks_loaded: falling back to render_buffer=%ds sleep" % render_buffer)
|
| 165 |
+
_t.sleep(render_buffer)
|
| 166 |
+
else:
|
| 167 |
+
print(" wait_mocks_loaded: browser render verified, skipping render_buffer")
|
| 168 |
+
# --- end wait_mocks_loaded ---
|
| 169 |
+
|
| 170 |
+
# --- _open_remaining_mock_tabs: open all auto-detected mock URLs in new Chrome tabs ---
|
| 171 |
+
def _open_remaining_mock_tabs(primary_url=""):
|
| 172 |
+
"""Open all auto-detected mock URLs in Chrome --new-tab, except primary_url."""
|
| 173 |
+
g = globals()
|
| 174 |
+
_urls = set()
|
| 175 |
+
for _k, _v in list(g.items()):
|
| 176 |
+
if "PROBE" in _k.upper() or _k.startswith("_"):
|
| 177 |
+
continue
|
| 178 |
+
if isinstance(_v, str) and _v.startswith("http://") and (_k.endswith("_URL") or _k.endswith("_url")):
|
| 179 |
+
_urls.add(_v)
|
| 180 |
+
elif isinstance(_v, dict) and _v and all(isinstance(x, str) and x.startswith("http://") for x in _v.values()):
|
| 181 |
+
_urls.update(_v.values())
|
| 182 |
+
_sid = ""
|
| 183 |
+
for _k in ("sid", "SID", "task_sid", "session_id"):
|
| 184 |
+
if isinstance(g.get(_k), str) and g[_k]:
|
| 185 |
+
_sid = g[_k]; break
|
| 186 |
+
for _u in sorted(_urls):
|
| 187 |
+
if _u != primary_url:
|
| 188 |
+
launch_gui(f'google-chrome --new-tab "{_u}/?sid={_sid}"', delay_sec=1.0)
|
| 189 |
+
# --- end _open_remaining_mock_tabs ---
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
"""
|
| 193 |
+
Initial Setup: High-risk strategic renewal motion for Initech across five apps.
|
| 194 |
+
Task ID: am_renewal_cycle_004
|
| 195 |
+
Domain: mock_websites (multi-mock)
|
| 196 |
+
Mocks: salesforce, notion, gmail, docusign, slack
|
| 197 |
+
|
| 198 |
+
Persona: Jordan Avery (user-1), Account Manager / Renewals Manager at Vertex Cloud.
|
| 199 |
+
jordan.avery@vertexcloud.example.com. Today = 2026-06-24.
|
| 200 |
+
|
| 201 |
+
Pre-task state ONLY. MUST NOT contain task-completed elements:
|
| 202 |
+
- Salesforce: opp-3 stage stays 'Qualification' (NOT Negotiation); NO renewal-planning task activity.
|
| 203 |
+
- Notion: Initech row Status stays 'Not Started'; NO renewal brief page.
|
| 204 |
+
- Gmail: NO sent renewal email to Priya Nair at priya.nair@initech.example.com
|
| 205 |
+
(only unrelated inbound context).
|
| 206 |
+
- DocuSign: NO Initech renewal envelope (address book + template exist).
|
| 207 |
+
- Slack: NO Initech summary message in #deal-desk.
|
| 208 |
+
"""
|
| 209 |
+
import os
|
| 210 |
+
import shlex
|
| 211 |
+
import subprocess
|
| 212 |
+
import time
|
| 213 |
+
import uuid
|
| 214 |
+
|
| 215 |
+
import requests
|
| 216 |
+
|
| 217 |
+
# --- Mock registry ---
|
| 218 |
+
MOCKS = {
|
| 219 |
+
'salesforce': 'http://28.7.186.212:8195',
|
| 220 |
+
'notion': 'http://28.7.186.212:8186',
|
| 221 |
+
'gmail': 'http://28.7.186.212:8158',
|
| 222 |
+
'docusign': 'http://28.7.186.212:8150',
|
| 223 |
+
'slack': 'http://28.7.186.212:8198',
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
# --- Egress proxy ---
|
| 227 |
+
# The mocks are only reachable via the cluster HTTPS proxy on this VM (no direct
|
| 228 |
+
# route to the public xlang.ai hosts). Auto-detect a working proxy: try direct
|
| 229 |
+
# first, then the known cluster proxy. Chrome is launched through the same proxy.
|
| 230 |
+
PROXY_CANDIDATES = [
|
| 231 |
+
os.environ.get('HTTPS_PROXY') or os.environ.get('https_proxy'),
|
| 232 |
+
None,
|
| 233 |
+
]
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
def _resolve_proxy():
|
| 237 |
+
probe = f"{MOCKS['salesforce']}/go?sid=conn-probe"
|
| 238 |
+
# Try direct connection first.
|
| 239 |
+
try:
|
| 240 |
+
requests.get(probe, timeout=8)
|
| 241 |
+
return None
|
| 242 |
+
except Exception:
|
| 243 |
+
pass
|
| 244 |
+
for cand in PROXY_CANDIDATES:
|
| 245 |
+
if not cand:
|
| 246 |
+
continue
|
| 247 |
+
try:
|
| 248 |
+
requests.get(probe, timeout=12, proxies={'http': cand, 'https': cand})
|
| 249 |
+
return cand
|
| 250 |
+
except Exception:
|
| 251 |
+
continue
|
| 252 |
+
raise RuntimeError('No working route to mock servers (direct and proxies all failed)')
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
PROXY = _resolve_proxy()
|
| 256 |
+
PROXIES = None
|
| 257 |
+
print(f'Egress proxy: {PROXY or "direct"}')
|
| 258 |
+
|
| 259 |
+
# --- Shared session id ---
|
| 260 |
+
sid = str(uuid.uuid4())
|
| 261 |
+
with open('/tmp/task_web_sid', 'w') as f:
|
| 262 |
+
f.write(sid)
|
| 263 |
+
print(f'sid = {sid}')
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
# ----------------------------------------------------------------------------
|
| 267 |
+
# Salesforce state
|
| 268 |
+
# ----------------------------------------------------------------------------
|
| 269 |
+
def salesforce_state():
|
| 270 |
+
user_1 = {
|
| 271 |
+
"userId": "user-1", "firstName": "Jordan", "lastName": "Avery",
|
| 272 |
+
"email": "jordan.avery@vertexcloud.example.com", "phone": "(555) 310-7742",
|
| 273 |
+
"title": "Account Manager", "department": "Renewals", "role": "Manager",
|
| 274 |
+
"avatar": "https://i.pravatar.cc/150?u=user-1",
|
| 275 |
+
"timezone": "America/New_York", "locale": "en-US", "theme": "lightning",
|
| 276 |
+
}
|
| 277 |
+
user_2 = {
|
| 278 |
+
"userId": "user-2", "firstName": "Dana", "lastName": "Whitfield",
|
| 279 |
+
"email": "dana.whitfield@vertexcloud.example.com", "phone": "(555) 310-7750",
|
| 280 |
+
"title": "VP Sales", "department": "Sales", "role": "Executive",
|
| 281 |
+
"avatar": "https://i.pravatar.cc/150?u=user-2",
|
| 282 |
+
"timezone": "America/New_York", "locale": "en-US", "theme": "lightning",
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
accounts = [
|
| 286 |
+
{"accountId": "account-1", "name": "Northwind Traders", "type": "Customer",
|
| 287 |
+
"industry": "Retail", "revenue": 58000000, "employees": 640, "ownerId": "user-1",
|
| 288 |
+
"billingStreet": "210 Commerce Blvd", "billingCity": "Columbus", "billingState": "OH",
|
| 289 |
+
"billingZip": "43004", "billingCountry": "USA"},
|
| 290 |
+
{"accountId": "account-2", "name": "Globex Corp", "type": "Customer",
|
| 291 |
+
"industry": "Technology", "revenue": 142000000, "employees": 2100, "ownerId": "user-1",
|
| 292 |
+
"billingStreet": "1 Globex Center", "billingCity": "San Jose", "billingState": "CA",
|
| 293 |
+
"billingZip": "95110", "billingCountry": "USA"},
|
| 294 |
+
{"accountId": "account-3", "name": "Initech", "type": "Customer",
|
| 295 |
+
"industry": "Fintech", "revenue": 96000000, "employees": 880, "ownerId": "user-1",
|
| 296 |
+
"billingStreet": "4120 Office Park Dr", "billingCity": "Austin", "billingState": "TX",
|
| 297 |
+
"billingZip": "73301", "billingCountry": "USA"},
|
| 298 |
+
]
|
| 299 |
+
|
| 300 |
+
contacts = [
|
| 301 |
+
{"contactId": "contact-3", "accountId": "account-3", "firstName": "Priya",
|
| 302 |
+
"lastName": "Nair", "title": "VP Finance", "department": "Finance",
|
| 303 |
+
"email": "priya.nair@initech.example.com", "phone": "(555) 884-2201",
|
| 304 |
+
"ownerId": "user-1"},
|
| 305 |
+
]
|
| 306 |
+
|
| 307 |
+
opportunities = [
|
| 308 |
+
# DISTRACTOR — Northwind annual renewal
|
| 309 |
+
{"opportunityId": "opp-1", "name": "Northwind Traders – Annual Renewal",
|
| 310 |
+
"accountId": "account-1", "contactId": None, "amount": 85000,
|
| 311 |
+
"closeDate": "2026-08-01", "stage": "Proposal", "probability": 70,
|
| 312 |
+
"ownerId": "user-1"},
|
| 313 |
+
# DISTRACTOR — Globex platform renewal
|
| 314 |
+
{"opportunityId": "opp-2", "name": "Globex Corp – Platform Renewal",
|
| 315 |
+
"accountId": "account-2", "contactId": None, "amount": 130000,
|
| 316 |
+
"closeDate": "2026-10-15", "stage": "Needs Analysis", "probability": 55,
|
| 317 |
+
"ownerId": "user-1"},
|
| 318 |
+
# TARGET — Initech renewal & upsell (high ARR, low win prob -> escalation)
|
| 319 |
+
{"opportunityId": "opp-3", "name": "Initech – Renewal & Upsell",
|
| 320 |
+
"accountId": "account-3", "contactId": "contact-3", "amount": 240000,
|
| 321 |
+
"closeDate": "2026-09-10", "stage": "Qualification", "probability": 35,
|
| 322 |
+
"ownerId": "user-1"},
|
| 323 |
+
# DISTRACTOR — same-customer small add-on (must NOT be acted on)
|
| 324 |
+
{"opportunityId": "opp-4", "name": "Initech – Sandbox Add-on",
|
| 325 |
+
"accountId": "account-3", "contactId": "contact-3", "amount": 8000,
|
| 326 |
+
"closeDate": "2026-07-20", "stage": "Qualification", "probability": 60,
|
| 327 |
+
"ownerId": "user-1"},
|
| 328 |
+
]
|
| 329 |
+
|
| 330 |
+
return {
|
| 331 |
+
"user": user_1,
|
| 332 |
+
"users": [user_1, user_2],
|
| 333 |
+
"leads": [],
|
| 334 |
+
"accounts": accounts,
|
| 335 |
+
"contacts": contacts,
|
| 336 |
+
"opportunities": opportunities,
|
| 337 |
+
"cases": [],
|
| 338 |
+
"activities": [],
|
| 339 |
+
"chatterPosts": [],
|
| 340 |
+
"files": [],
|
| 341 |
+
"following": [],
|
| 342 |
+
"recentlyViewed": [],
|
| 343 |
+
"dismissedNotifications": [],
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
# ----------------------------------------------------------------------------
|
| 348 |
+
# Notion state — 'Renewal Tracker 2026' database with Initech row + distractors
|
| 349 |
+
# ----------------------------------------------------------------------------
|
| 350 |
+
def notion_state():
|
| 351 |
+
db_id = "db-renewal-tracker-2026"
|
| 352 |
+
properties = [
|
| 353 |
+
{"id": "prop_account", "name": "Account", "type": "title"},
|
| 354 |
+
{"id": "prop_arr", "name": "ARR", "type": "number"},
|
| 355 |
+
{"id": "prop_date", "name": "Renewal Date", "type": "date"},
|
| 356 |
+
{"id": "prop_risk", "name": "Risk", "type": "select",
|
| 357 |
+
"options": [{"id": "opt_low", "name": "Low"},
|
| 358 |
+
{"id": "opt_med", "name": "Medium"},
|
| 359 |
+
{"id": "opt_high", "name": "High"}]},
|
| 360 |
+
{"id": "prop_status", "name": "Status", "type": "select",
|
| 361 |
+
"options": [{"id": "opt_ns", "name": "Not Started"},
|
| 362 |
+
{"id": "opt_ip", "name": "In Progress"},
|
| 363 |
+
{"id": "opt_sfs", "name": "Sent for Signature"}]},
|
| 364 |
+
]
|
| 365 |
+
|
| 366 |
+
def make_row(page_id, account, arr, date, risk, status):
|
| 367 |
+
return {
|
| 368 |
+
"id": page_id,
|
| 369 |
+
"title": account,
|
| 370 |
+
"icon": "",
|
| 371 |
+
"cover": None,
|
| 372 |
+
"parentId": db_id,
|
| 373 |
+
"blockIds": [],
|
| 374 |
+
"favorite": False,
|
| 375 |
+
"createdDate": "2026-06-01T09:00:00.000Z",
|
| 376 |
+
"lastEditedDate": "2026-06-01T09:00:00.000Z",
|
| 377 |
+
"properties": {
|
| 378 |
+
"prop_account": {"title": account},
|
| 379 |
+
"prop_arr": {"number": arr},
|
| 380 |
+
"prop_date": {"date": {"start": date, "end": None}},
|
| 381 |
+
"prop_risk": {"select": risk},
|
| 382 |
+
"prop_status": {"select": status},
|
| 383 |
+
},
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
row_initech = make_row("row-initech", "Initech", 240000, "2026-09-10", "High", "Not Started")
|
| 387 |
+
row_northwind = make_row("row-northwind", "Northwind Traders", 85000, "2026-08-01", "Low", "In Progress")
|
| 388 |
+
row_globex = make_row("row-globex", "Globex Corp", 130000, "2026-10-15", "Medium", "Not Started")
|
| 389 |
+
|
| 390 |
+
db_page = {
|
| 391 |
+
"id": db_id,
|
| 392 |
+
"title": "Renewal Tracker 2026",
|
| 393 |
+
"icon": "📊",
|
| 394 |
+
"cover": None,
|
| 395 |
+
"parentId": None,
|
| 396 |
+
"type": "database",
|
| 397 |
+
"viewType": "table",
|
| 398 |
+
"properties": properties,
|
| 399 |
+
"views": [{
|
| 400 |
+
"id": "view-1", "name": "Table", "type": "table",
|
| 401 |
+
"filters": [], "sorts": [], "groupBy": None,
|
| 402 |
+
"visibleProperties": ["prop_account", "prop_arr", "prop_date", "prop_risk", "prop_status"],
|
| 403 |
+
}],
|
| 404 |
+
"items": ["row-initech", "row-northwind", "row-globex"],
|
| 405 |
+
"blockIds": [],
|
| 406 |
+
"favorite": False,
|
| 407 |
+
"createdDate": "2026-06-01T09:00:00.000Z",
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
return {
|
| 411 |
+
"user": {"id": "user-1", "name": "Jordan Avery",
|
| 412 |
+
"email": "jordan.avery@vertexcloud.example.com", "avatar": ""},
|
| 413 |
+
"workspace": {"id": "ws-1", "name": "Vertex Cloud Renewals", "icon": "🏢",
|
| 414 |
+
"members": ["user-1"]},
|
| 415 |
+
"pages": {
|
| 416 |
+
db_id: db_page,
|
| 417 |
+
"row-initech": row_initech,
|
| 418 |
+
"row-northwind": row_northwind,
|
| 419 |
+
"row-globex": row_globex,
|
| 420 |
+
},
|
| 421 |
+
"blocks": {},
|
| 422 |
+
"trash": [],
|
| 423 |
+
"comments": {},
|
| 424 |
+
"settings": {"appearance": "light", "startWeekMonday": False, "fontSize": "default"},
|
| 425 |
+
"notifications": [],
|
| 426 |
+
"pageOrder": [db_id],
|
| 427 |
+
"focusBlockId": None,
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
|
| 431 |
+
# ----------------------------------------------------------------------------
|
| 432 |
+
# Gmail state — Jordan Avery, only an unrelated old Initech support thread
|
| 433 |
+
# ----------------------------------------------------------------------------
|
| 434 |
+
def gmail_state():
|
| 435 |
+
return {
|
| 436 |
+
"user": {"userId": "user-1", "username": "Jordan Avery",
|
| 437 |
+
"email": "jordan.avery@vertexcloud.example.com", "avatar": ""},
|
| 438 |
+
"emails": [
|
| 439 |
+
{
|
| 440 |
+
"id": "email_1", "threadId": "thread_1",
|
| 441 |
+
"from": {"name": "Initech Support", "email": "support@initech.example.com"},
|
| 442 |
+
"to": [{"name": "Jordan Avery", "email": "jordan.avery@vertexcloud.example.com"}],
|
| 443 |
+
"cc": [], "bcc": [],
|
| 444 |
+
"subject": "Re: Initech sandbox login issue (resolved)",
|
| 445 |
+
"body": "Hi Jordan, thanks for your help last month — the sandbox login "
|
| 446 |
+
"issue is fully resolved on our end. Best, Initech Support",
|
| 447 |
+
"timestamp": "2026-05-12T15:42:00Z",
|
| 448 |
+
"read": True, "starred": False, "important": False,
|
| 449 |
+
"labels": ["l1"], "category": "primary", "folder": "inbox",
|
| 450 |
+
"attachments": [],
|
| 451 |
+
},
|
| 452 |
+
{
|
| 453 |
+
"id": "email_2", "threadId": "thread_2",
|
| 454 |
+
"from": {"name": "Dana Whitfield", "email": "dana.whitfield@vertexcloud.example.com"},
|
| 455 |
+
"to": [{"name": "Jordan Avery", "email": "jordan.avery@vertexcloud.example.com"}],
|
| 456 |
+
"cc": [], "bcc": [],
|
| 457 |
+
"subject": "Initech renewal — let's run the high-risk playbook",
|
| 458 |
+
"body": "Jordan, Initech ($240K ARR, 35% win prob) qualifies for the "
|
| 459 |
+
"strategic-renewal playbook. Their VP Finance is Priya Nair "
|
| 460 |
+
"(priya.nair@initech.example.com). Please drive the full motion this week. — Dana",
|
| 461 |
+
"timestamp": "2026-06-24T08:05:00Z",
|
| 462 |
+
"read": False, "starred": True, "important": True,
|
| 463 |
+
"labels": ["l1"], "category": "primary", "folder": "inbox",
|
| 464 |
+
"attachments": [],
|
| 465 |
+
},
|
| 466 |
+
],
|
| 467 |
+
"labels": [
|
| 468 |
+
{"id": "l1", "name": "Work", "color": "#ef4444"},
|
| 469 |
+
{"id": "l2", "name": "Personal", "color": "#3b82f6"},
|
| 470 |
+
{"id": "l3", "name": "Travel", "color": "#22c55e"},
|
| 471 |
+
{"id": "l4", "name": "Finance", "color": "#eab308"},
|
| 472 |
+
],
|
| 473 |
+
"drafts": [],
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
|
| 477 |
+
# ----------------------------------------------------------------------------
|
| 478 |
+
# DocuSign state — address book + template, NO Initech renewal envelope
|
| 479 |
+
# ----------------------------------------------------------------------------
|
| 480 |
+
def docusign_state():
|
| 481 |
+
return {
|
| 482 |
+
"user": {
|
| 483 |
+
"id": "user-1", "name": "Jordan Avery",
|
| 484 |
+
"email": "jordan.avery@vertexcloud.example.com",
|
| 485 |
+
"title": "Account Manager", "company": "Vertex Cloud",
|
| 486 |
+
"memberSince": "2024-02-01",
|
| 487 |
+
"settings": {"defaultReminderDays": 3, "defaultExpirationDays": 120,
|
| 488 |
+
"timezone": "America/New_York"},
|
| 489 |
+
},
|
| 490 |
+
"envelopes": [
|
| 491 |
+
# Distractor: an unrelated completed envelope, nothing to do with Initech renewal
|
| 492 |
+
{
|
| 493 |
+
"id": "env_globex_1",
|
| 494 |
+
"subject": "Globex Corp - Platform Renewal Agreement",
|
| 495 |
+
"message": "Please review and sign.",
|
| 496 |
+
"status": "completed",
|
| 497 |
+
"createdAt": "2026-04-02T10:00:00Z",
|
| 498 |
+
"sentAt": "2026-04-02T10:05:00Z",
|
| 499 |
+
"completedAt": "2026-04-05T16:20:00Z",
|
| 500 |
+
"voidedAt": None, "declinedAt": None,
|
| 501 |
+
"lastActivityAt": "2026-04-05T16:20:00Z",
|
| 502 |
+
"expiresAt": "2026-08-01T10:05:00Z",
|
| 503 |
+
"senderId": "user-1", "folderId": None, "templateId": None,
|
| 504 |
+
"reminderEnabled": True, "reminderDays": 3, "reminderFrequency": 2,
|
| 505 |
+
"documents": [{"id": "doc_globex_1", "name": "Globex_Platform_Renewal.pdf",
|
| 506 |
+
"pageCount": 8, "order": 1,
|
| 507 |
+
"fileUrl": "https://picsum.photos/seed/globex/800/1100",
|
| 508 |
+
"fileType": "pdf"}],
|
| 509 |
+
"recipients": [{"id": "rec_globex_1", "name": "Hank Scorpio",
|
| 510 |
+
"email": "hank@globex.example.com", "role": "signer",
|
| 511 |
+
"routingOrder": 1, "status": "signed",
|
| 512 |
+
"signedAt": "2026-04-05T16:20:00Z",
|
| 513 |
+
"viewedAt": "2026-04-03T09:00:00Z",
|
| 514 |
+
"deliveredAt": "2026-04-02T10:06:00Z",
|
| 515 |
+
"declinedAt": None, "declineReason": None}],
|
| 516 |
+
"fields": [],
|
| 517 |
+
"history": [
|
| 518 |
+
{"id": "evt_globex_1", "timestamp": "2026-04-02T10:00:00Z",
|
| 519 |
+
"action": "created", "actorName": "Jordan Avery",
|
| 520 |
+
"actorEmail": "jordan.avery@vertexcloud.example.com",
|
| 521 |
+
"details": "Envelope created"},
|
| 522 |
+
{"id": "evt_globex_2", "timestamp": "2026-04-05T16:20:00Z",
|
| 523 |
+
"action": "completed", "actorName": "Hank Scorpio",
|
| 524 |
+
"actorEmail": "hank@globex.example.com",
|
| 525 |
+
"details": "All recipients signed"},
|
| 526 |
+
],
|
| 527 |
+
},
|
| 528 |
+
],
|
| 529 |
+
"templates": [
|
| 530 |
+
{"id": "tmpl_renewal", "name": "Annual Renewal Agreement",
|
| 531 |
+
"description": "Standard Vertex Cloud annual renewal agreement template.",
|
| 532 |
+
"createdAt": "2025-01-10T09:00:00Z", "lastUsedAt": "2026-04-02T10:00:00Z",
|
| 533 |
+
"usageCount": 14, "ownerId": "user-1", "shared": True,
|
| 534 |
+
"documents": [{"id": "tdoc_renewal_1", "name": "Annual_Renewal_Agreement.pdf",
|
| 535 |
+
"pageCount": 6, "order": 1,
|
| 536 |
+
"fileUrl": "https://picsum.photos/seed/renewaltmpl/800/1100",
|
| 537 |
+
"fileType": "pdf"}],
|
| 538 |
+
"roles": [{"id": "trole_signer", "name": "Customer Signer", "role": "signer",
|
| 539 |
+
"routingOrder": 1},
|
| 540 |
+
{"id": "trole_cc", "name": "Vertex Finance", "role": "cc",
|
| 541 |
+
"routingOrder": 2}],
|
| 542 |
+
"fields": []},
|
| 543 |
+
],
|
| 544 |
+
"folders": [],
|
| 545 |
+
"contacts": [
|
| 546 |
+
{"id": "con_priya", "name": "Priya Nair", "email": "priya.nair@initech.example.com",
|
| 547 |
+
"company": "Initech", "title": "VP Finance"},
|
| 548 |
+
{"id": "con_finance", "name": "Vertex Finance", "email": "finance@vertexcloud.example.com",
|
| 549 |
+
"company": "Vertex Cloud", "title": "Finance Mailbox"},
|
| 550 |
+
{"id": "con_hank", "name": "Hank Scorpio", "email": "hank@globex.example.com",
|
| 551 |
+
"company": "Globex Corp", "title": "CEO"},
|
| 552 |
+
],
|
| 553 |
+
"auditLog": [
|
| 554 |
+
{"id": "audit_1", "timestamp": "2026-04-05T16:20:00Z", "action": "COMPLETE_ENVELOPE",
|
| 555 |
+
"details": "Globex Corp - Platform Renewal Agreement completed",
|
| 556 |
+
"envelopeId": "env_globex_1"},
|
| 557 |
+
],
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
|
| 561 |
+
# ----------------------------------------------------------------------------
|
| 562 |
+
# Slack state — Vertex Cloud, #deal-desk with Jordan, finance, legal
|
| 563 |
+
# ----------------------------------------------------------------------------
|
| 564 |
+
def slack_state():
|
| 565 |
+
user_1 = {"userId": "user_1", "fullName": "Jordan Avery", "displayName": "Jordan",
|
| 566 |
+
"email": "jordan.avery@vertexcloud.example.com",
|
| 567 |
+
"avatar": "https://picsum.photos/200/200?random=1",
|
| 568 |
+
"status": "online", "statusMessage": "", "statusEmoji": "",
|
| 569 |
+
"title": "Account Manager", "timeZone": "America/New_York"}
|
| 570 |
+
user_fin = {"userId": "user_2", "fullName": "Finance Team", "displayName": "finance",
|
| 571 |
+
"email": "finance@vertexcloud.example.com",
|
| 572 |
+
"avatar": "https://picsum.photos/200/200?random=2",
|
| 573 |
+
"status": "online", "statusMessage": "", "statusEmoji": "",
|
| 574 |
+
"title": "Finance", "timeZone": "America/New_York"}
|
| 575 |
+
user_legal = {"userId": "user_3", "fullName": "Legal Team", "displayName": "legal",
|
| 576 |
+
"email": "legal@vertexcloud.example.com",
|
| 577 |
+
"avatar": "https://picsum.photos/200/200?random=3",
|
| 578 |
+
"status": "online", "statusMessage": "", "statusEmoji": "",
|
| 579 |
+
"title": "Legal", "timeZone": "America/New_York"}
|
| 580 |
+
return {
|
| 581 |
+
"currentUser": user_1,
|
| 582 |
+
"workspace": {"workspaceId": "ws_1", "workspaceName": "Vertex Cloud", "icon": ""},
|
| 583 |
+
"users": [user_1, user_fin, user_legal],
|
| 584 |
+
"channels": [
|
| 585 |
+
{"channelId": "deal-desk", "name": "deal-desk",
|
| 586 |
+
"description": "Deal desk: finance + legal review of strategic deals",
|
| 587 |
+
"topic": "Strategic renewals & approvals", "isPrivate": False, "isStarred": False,
|
| 588 |
+
"members": ["user_1", "user_2", "user_3"], "createdBy": "user_2",
|
| 589 |
+
"createdAt": "2026-01-01T10:00:00Z", "pinnedMessages": [], "unreadCount": 0},
|
| 590 |
+
{"channelId": "general", "name": "general", "description": "Company-wide chat",
|
| 591 |
+
"topic": "", "isPrivate": False, "isStarred": False,
|
| 592 |
+
"members": ["user_1", "user_2", "user_3"], "createdBy": "user_2",
|
| 593 |
+
"createdAt": "2026-01-01T10:00:00Z", "pinnedMessages": [], "unreadCount": 0},
|
| 594 |
+
],
|
| 595 |
+
"messages": {
|
| 596 |
+
"deal-desk": [
|
| 597 |
+
{"messageId": "msg_1", "senderId": "user_2",
|
| 598 |
+
"content": "Reminder: anything ARR >= $200K with win prob < 50% needs the "
|
| 599 |
+
"high-risk strategic-renewal playbook and a closure summary here.",
|
| 600 |
+
"timestamp": "2026-06-22T09:00:00Z", "threadId": None,
|
| 601 |
+
"reactions": [], "attachments": [], "isEdited": False},
|
| 602 |
+
],
|
| 603 |
+
"general": [],
|
| 604 |
+
},
|
| 605 |
+
"threads": {},
|
| 606 |
+
"dms": [],
|
| 607 |
+
"bookmarkedMessages": [],
|
| 608 |
+
"callHistory": [],
|
| 609 |
+
"settings": {"theme": "light", "notifications": "all",
|
| 610 |
+
"displayDensity": "comfortable", "showAvatars": True, "use24Hour": False},
|
| 611 |
+
"invitations": [],
|
| 612 |
+
"notifications": [],
|
| 613 |
+
}
|
| 614 |
+
|
| 615 |
+
|
| 616 |
+
# ----------------------------------------------------------------------------
|
| 617 |
+
# Inject all states
|
| 618 |
+
# ----------------------------------------------------------------------------
|
| 619 |
+
STATE_BUILDERS = {
|
| 620 |
+
'salesforce': salesforce_state,
|
| 621 |
+
'notion': notion_state,
|
| 622 |
+
'gmail': gmail_state,
|
| 623 |
+
'docusign': docusign_state,
|
| 624 |
+
'slack': slack_state,
|
| 625 |
+
}
|
| 626 |
+
|
| 627 |
+
for name, build in STATE_BUILDERS.items():
|
| 628 |
+
url = MOCKS[name]
|
| 629 |
+
state = build()
|
| 630 |
+
resp = requests.post(f'{url}/post?sid={sid}',
|
| 631 |
+
json={'action': 'set', 'state': state}, timeout=30,
|
| 632 |
+
proxies=PROXIES)
|
| 633 |
+
assert resp.status_code == 200, f'{name} injection failed: {resp.status_code} {resp.text}'
|
| 634 |
+
go = requests.get(f'{url}/go?sid={sid}', timeout=10, proxies=PROXIES).json()
|
| 635 |
+
assert go.get('initial_state') is not None, f'{name} initial_state is None'
|
| 636 |
+
print(f' injected {name}: initial_state OK')
|
| 637 |
+
|
| 638 |
+
print(f'All 5 mocks injected with sid={sid}')
|
| 639 |
+
|
| 640 |
+
|
| 641 |
+
# ----------------------------------------------------------------------------
|
| 642 |
+
# GUI-ready: launch Chrome on Salesforce (primary app)
|
| 643 |
+
# ----------------------------------------------------------------------------
|
| 644 |
+
def launch_gui(command, delay_sec=1.0):
|
| 645 |
+
env = os.environ.copy()
|
| 646 |
+
env['DISPLAY'] = ':0'
|
| 647 |
+
# Accept both a command string and a pre-split arg list (some tasks
|
| 648 |
+
# build arg lists themselves, e.g. se_hard_008).
|
| 649 |
+
if isinstance(command, str):
|
| 650 |
+
_parts = shlex.split(command)
|
| 651 |
+
else:
|
| 652 |
+
_parts = list(command)
|
| 653 |
+
# Inject CDP debug port so wait_mocks_loaded can verify browser render
|
| 654 |
+
# via Playwright connect_over_cdp. Idempotent: skip if any arg already
|
| 655 |
+
# starts with --remote-debugging-port (some tasks inject their own
|
| 656 |
+
# dynamic port, e.g. se_hard_008).
|
| 657 |
+
if _parts and 'google-chrome' in _parts[0] \
|
| 658 |
+
and not any(p.startswith('--remote-debugging-port') for p in _parts):
|
| 659 |
+
_parts[1:1] = ['--no-first-run', '--no-default-browser-check',
|
| 660 |
+
'--remote-debugging-port=1337']
|
| 661 |
+
_proc = subprocess.Popen(_parts, stdin=subprocess.DEVNULL,
|
| 662 |
+
stdout=subprocess.DEVNULL,
|
| 663 |
+
stderr=subprocess.DEVNULL, env=env,
|
| 664 |
+
start_new_session=True)
|
| 665 |
+
time.sleep(delay_sec)
|
| 666 |
+
if _proc.poll() is not None:
|
| 667 |
+
print(' WARNING: launch_gui process exited early (code=%s)'
|
| 668 |
+
% _proc.returncode)
|
| 669 |
+
return _proc
|
| 670 |
+
_chrome_proxy = f'--proxy-server={PROXY}' if PROXY else ''
|
| 671 |
+
_primary_mock_url = MOCKS["salesforce"]
|
| 672 |
+
launch_gui(f'google-chrome "{MOCKS["salesforce"]}/?sid={sid}"', delay_sec=2.0)
|
| 673 |
+
_open_remaining_mock_tabs(_primary_mock_url)
|
| 674 |
+
wait_mocks_loaded()
|
| 675 |
+
print(f'GUI_READY: launched browser at {MOCKS["salesforce"]}/?sid={sid} (proxy={PROXY or "direct"})')
|
legacy/am_renewal_cycle_004/reward.py
ADDED
|
File without changes
|
legacy/am_renewal_cycle_004/reward_label.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"reward_file": "/apdcephfs_sh2/share_300000800/user/jackwkwang/long-horizon-tasks/mini_osworld_xiangwu/cache/am_renewal_cycle_004/reward.py",
|
| 3 |
+
"api_url": "http://28.7.184.184:8000/v1/chat/completions",
|
| 4 |
+
"model": "Kimi-K2.6",
|
| 5 |
+
"max_code_chars": 100000,
|
| 6 |
+
"created_at": "2026-07-14 10:21:32",
|
| 7 |
+
"label": {
|
| 8 |
+
"task_id": null,
|
| 9 |
+
"domain": null,
|
| 10 |
+
"summary": "未提供 reward.py 源码,无法分析评分逻辑",
|
| 11 |
+
"is_placeholder": true,
|
| 12 |
+
"data_sources": [],
|
| 13 |
+
"scoring_components": [],
|
| 14 |
+
"total_max_score": 1.0,
|
| 15 |
+
"score_aggregation": "无法确定",
|
| 16 |
+
"failure_modes": [
|
| 17 |
+
"未提供源码,无法识别任何失败路径"
|
| 18 |
+
],
|
| 19 |
+
"scoring_logic_explanation": "输入中未包含 reward.py 的源码内容,因此无法依据源码分析其评分逻辑、状态读取方式、检查组件及分数汇总方式。",
|
| 20 |
+
"confidence": 0.0
|
| 21 |
+
},
|
| 22 |
+
"raw_response": "用户要求我分析一个 reward.py 评分脚本的评分逻辑,并输出一个严格的 JSON 对象。但是,用户提供的源码部分是空的——在【reward.py 源码】后面没有实际代码内容。\n\n我需要根据分析原则如实依据源码填写。由于没有提供源码,我无法确定 task_id、domain、评分逻辑等。在这种情况下,我应该:\n\n1. 检查是否有任何代码内容——看起来没有。\n2. 由于无法读取文件,且用户没有提供源码,我只能基于\"无源码\"这一事实进行分析。\n3. 但是,用户明确说\"请分析下面这个 reward.py\",可能是在某个上下文中遗漏了代码。作为AI,我只能基于实际提供的输入进行判断。\n\n等等,让我仔细看用户消息。用户说:\n【reward.py 源码】\n\n后面确实没有内容。\n\n在这种情况下,我应该:\n- task_id: 从文件路径看,文件名似乎是 am_renewal_cycle_004,所以 task_id 可能是 am_renewal_cycle_004\n- domain: 从路径看,可能是 mini_osworld_xiangwu,但这不是标准领域。从 task_id 前缀 am_ 看,可能是 account_management 或类似?但无法从源码确定,因为没给源码。\n- 由于没有源码,我无法确定评分逻辑。\n\n但是,用户可能期望我基于路径中的 task_id 给出某种回应。然而,分析原则说\"如实依据源码填写,不要臆测未在代码中出现的信息\"。由于没有源码,几乎所有字段都无法确定。\n\n不过,文件路径中包含 \"am_renewal_cycle_004\",这可能就是 task_id。但 domain 无法确定。\n\n等等,也许用户忘记粘贴代码了?但我必须基于给定输入回答。\n\n如果完全没有源码,我应该:\n- task_id: \"am_renewal_cycle_004\"(从路径提取,但这不算 docstring)\n- 实际上,task_id 要求\"从文件 docstring 中提取\",如果没有 docstring 且无法确定,填 null。\n- domain: null\n- summary: \"未提供源码,无法分析评分逻辑\"\n- is_placeholder: 无法确定,但由于没有源码,实际上无法判断。不过也许应该设为 true?不,不能臆测。\n\n实际上,如果源码完全缺失,我无法进行任何有意义的分析。但用户明确要求输出 JSON。我应该诚实地说明没有提供源码。\n\n但是,等等,我再看一遍。用户消息以\"【reward.py 源码】\"结束,后面确实没有代码。这可能是用户的错误。\n\n在这种情况下,最严谨的做法是输出一个 JSON,表明无法分析,因为源码未提供。但格式必须符合要求。\n\n让我重新阅读指令:\"请只输出一个 JSON 对象... 不要输出额外解释\"。\n\n如果源码未提供,我无法填写 scoring_components 等。但也许我可以基于文件路径做一些最小程度的填充:\n\n- task_id: null(因为 docstring 未提供,路径中的不是 docstring)\n- domain: null\n- summary: \"未提供 reward.py 源码,无法分析评分逻辑\"\n- is_placeholder: true(因为没有实际可检查的代码内容)\n- data_sources: []\n- scoring_components: []\n- total_max_score: 1.0\n- score_aggregation: \"无法确定\"\n- failure_modes: [\"未提供源码\"]\n- scoring_logic_explanation: \"用户未提供 reward.py 的源码内容,因此无法分析其评分逻辑、数据源、检查组件及分数汇总方式。\"\n- confidence: 0.0\n\n这看起来是最诚实和严谨的。我不能编造代码逻辑。\n\n但是,等等,用户可能在之前的消息中提供了代码,或者这是一个多轮对话?不,这是第一轮。\n\n另一个想法:也许用户期望我分析路径中的 task_id。文件路径是 .../am_renewal_cycle_004/reward.py。在某些系统中,task_id 就是目录名。但指令明确说\"从文件 docstring 中提取的任务 ID\",所以如果没有 docstring,应该填 null。\n\n我决定输出一个表明\"未提供源码\"的 JSON。这符合\"如实依据源码填写\"的原则——源码确实为空。\n\n让我构造 JSON:\n\n{\n \"task_id\": null,\n \"domain\": null,\n \"summary\": \"未提供 reward.py 源码,无法分析��分逻辑\",\n \"is_placeholder\": true,\n \"data_sources\": [],\n \"scoring_components\": [],\n \"total_max_score\": 1.0,\n \"score_aggregation\": \"无法确定\",\n \"failure_modes\": [\"未提供源码,无法识别任何失败路径\"],\n \"scoring_logic_explanation\": \"用户未提供 reward.py 的源码内容,因此无法分析其评分逻辑、数据源、检查组件及分数汇总方式。\",\n \"confidence\": 0.0\n}\n\n等等,is_placeholder 设为 true 是否合适?占位脚本通常指脚本存在但只是 return 0.0。这里连脚本内容都没有。不过设为 true 表示\"这不是一个有效的可分析脚本\"也勉强可以。或者我可以写 null?但字段要求是 true 或 false。\n\n实际上,如果没有源码,说 is_placeholder: true 有点不准确,因为不知道它是不是占位脚本。但既然没有内容,也许可以认为是\"事实上的占位\"。不过严格来说,我不应该臆测。\n\n让我再想想。用户明确说\"请分析下面这个 reward.py 评分脚本的评分逻辑\",然后没有给源码。这可能是系统错误。作为AI,我只能基于已有信息。\n\n也许我应该直接输出 JSON,说明源码缺失。\n\n但等等,我注意到路径中有 \"am_renewal_cycle_004\"。\"am\" 可能代表 \"account management\"?但 domain 要求从 docstring 提取,所以仍是 null。\n\n我坚持输出\"无源码\"的 JSON。这是最诚实的。\n\n再检查一下 JSON 格式要求:\n- 不要输出 Markdown 代码块标记\n- 不要输出额外解释\n- 不要输出思考过程\n- 不要输出 <thinking> 标签\n- 第一个字符必须是 {,最后一个字符必须是 }\n\n好的,我直接输出 JSON。\n\n等等,我突然想到,也许用户是在测试我是否会 hallucinate 代码逻辑。如果是这样,编造内容是大错。所以坚决不能编。\n\n最终 JSON:\n\n{\n \"task_id\": null,\n \"domain\": null,\n \"summary\": \"未提供 reward.py 源码,无法分析评分逻辑\",\n \"is_placeholder\": true,\n \"data_sources\": [],\n \"scoring_components\": [],\n \"total_max_score\": 1.0,\n \"score_aggregation\": \"无法确定\",\n \"failure_modes\": [\"未提供源码,无法识别任何失败路径\"],\n \"scoring_logic_explanation\": \"输入中未包含 reward.py 的源码内容,因此无法依据源码分析其评分逻辑、状态读取方式、检查组件及分数汇总方式。\",\n \"confidence\": 0.0\n}\n\n这个 JSON 是合法的。 </think> {\"task_id\":null,\"domain\":null,\"summary\":\"未提供 reward.py 源码,无法分析评分逻辑\",\"is_placeholder\":true,\"data_sources\":[],\"scoring_components\":[],\"total_max_score\":1.0,\"score_aggregation\":\"无法确定\",\"failure_modes\":[\"未提供源码,无法识别任何失败路径\"],\"scoring_logic_explanation\":\"输入中未包含 reward.py 的源码内容,因此无法依据源码分析其评分逻辑、状态读取方式、检查组件及分数汇总方式。\",\"confidence\":0.0}"
|
| 23 |
+
}
|
legacy/ar_collections_001/_cua_gym_vm_bridge.sh
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# CUA-Gym VM-side network fix (direct-IP mock access).
|
| 3 |
+
#
|
| 4 |
+
# Runs INSIDE the QEMU guest. The CUA-Gym mock services are now reached by
|
| 5 |
+
# their real IDC address (http://9.91.4.13:81xx) instead of the old
|
| 6 |
+
# localhost:9000-9097 socat bridge, so the VM only needs two fixes:
|
| 7 |
+
#
|
| 8 |
+
# 1. Working DNS — the qcow2-baked /etc/resolv.conf points at the Pod's
|
| 9 |
+
# cluster DNS, which is unreachable from QEMU SLIRP NAT
|
| 10 |
+
# ("Temporary failure in name resolution").
|
| 11 |
+
# 2. The mock host excluded from the woa http proxy — otherwise the VM's
|
| 12 |
+
# Chrome (gsettings proxy) and initial_setup.py's `requests` get a 403
|
| 13 |
+
# from the proxy when hitting 9.91.4.13:81xx. (The old socat path never
|
| 14 |
+
# hit this because localhost is bypassed by default.)
|
| 15 |
+
#
|
| 16 |
+
# Idempotent. Scoped to the CUA-Gym bridge step; does not touch the generic
|
| 17 |
+
# OSWorld setup pipeline.
|
| 18 |
+
#
|
| 19 |
+
# Argv:
|
| 20 |
+
# $1 optional sudo password (default "password"; SetupController
|
| 21 |
+
# substitutes {CLIENT_PASSWORD} when uploaded as a cache file).
|
| 22 |
+
# $2 unused (kept for backward compat — was socat first port 9000).
|
| 23 |
+
# $3 unused (kept for backward compat — was socat last port 9097).
|
| 24 |
+
# $4 optional mock host IP (default 9.91.4.13).
|
| 25 |
+
|
| 26 |
+
set +e
|
| 27 |
+
|
| 28 |
+
PASS="${1:-password}"
|
| 29 |
+
MOCK_HOST="${4:-28.7.186.212}"
|
| 30 |
+
# Derive the /16 IDC subnet so future port/host tweaks on the same segment
|
| 31 |
+
# stay bypassed too (9.91.4.13 -> 9.91.0.0/16).
|
| 32 |
+
MOCK_NET="$(echo "${MOCK_HOST}" | awk -F. 'NF==4{print $1"."$2".0.0/16"}')"
|
| 33 |
+
|
| 34 |
+
run_root() {
|
| 35 |
+
echo "$PASS" | sudo -S -p "" bash -c "$1"
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
# Detect SLIRP gateway from VM's routing table; fall back to 10.0.2.2.
|
| 39 |
+
GW="$(ip route 2>/dev/null | awk '/default/ {print $3; exit}')"
|
| 40 |
+
GW="${GW:-10.0.2.2}"
|
| 41 |
+
|
| 42 |
+
# ─── CUA-Gym network fix (Taiji-specific) ─────────────────────────────
|
| 43 |
+
fix_vm_network() {
|
| 44 |
+
# 0) Discover VM network state at runtime — gateway, own IP/CIDR, SLIRP
|
| 45 |
+
# DNS forwarder. Nothing hardcoded except the mock host above.
|
| 46 |
+
local GW_NET="${GW%.*}"
|
| 47 |
+
local SLIRP_DNS="${GW_NET}.3" # QEMU SLIRP DNS proxy is always .3
|
| 48 |
+
local OWN_CIDR
|
| 49 |
+
OWN_CIDR="$(ip -4 -o addr show scope global 2>/dev/null \
|
| 50 |
+
| awk '{print $4; exit}')"
|
| 51 |
+
local OWN_IP="${OWN_CIDR%/*}"
|
| 52 |
+
local OWN_NET=""
|
| 53 |
+
[ -n "${OWN_IP}" ] && OWN_NET="${OWN_IP%.*}.0/24"
|
| 54 |
+
|
| 55 |
+
# 1) DNS — point at SLIRP DNS proxy + public fallbacks. chattr +i keeps
|
| 56 |
+
# systemd-resolved/NetworkManager from clobbering it.
|
| 57 |
+
if run_root "printf 'nameserver ${SLIRP_DNS}\\nnameserver 114.114.114.114\\nnameserver 8.8.8.8\\n' > /etc/resolv.conf
|
| 58 |
+
chattr +i /etc/resolv.conf 2>/dev/null || true"; then
|
| 59 |
+
echo "[cua_gym_vm_bridge] DNS set: ${SLIRP_DNS}, 114.114.114.114, 8.8.8.8 (gw=${GW})"
|
| 60 |
+
else
|
| 61 |
+
echo "[cua_gym_vm_bridge] WARN: failed to write /etc/resolv.conf"
|
| 62 |
+
fi
|
| 63 |
+
|
| 64 |
+
# 2) Build the proxy bypass list from detected values + the direct-IP
|
| 65 |
+
# mock host (and its /16 subnet). THIS is what makes 9.91.4.13:81xx
|
| 66 |
+
# reachable from inside the VM — without it the woa proxy 403s it.
|
| 67 |
+
local ignore_list="['localhost', '127.0.0.0/8', '${GW}'"
|
| 68 |
+
[ -n "${OWN_IP}" ] && ignore_list="${ignore_list}, '${OWN_IP}'"
|
| 69 |
+
[ -n "${OWN_NET}" ] && ignore_list="${ignore_list}, '${OWN_NET}'"
|
| 70 |
+
[ -n "${GW_NET}" ] && ignore_list="${ignore_list}, '${GW_NET}.0/24'"
|
| 71 |
+
[ -n "${MOCK_HOST}" ] && ignore_list="${ignore_list}, '${MOCK_HOST}'"
|
| 72 |
+
[ -n "${MOCK_NET}" ] && ignore_list="${ignore_list}, '${MOCK_NET}'"
|
| 73 |
+
ignore_list="${ignore_list}]"
|
| 74 |
+
|
| 75 |
+
# 3) GNOME proxy ignore-hosts — Chrome bypasses the woa proxy for these.
|
| 76 |
+
if gsettings set org.gnome.system.proxy ignore-hosts "${ignore_list}" 2>/tmp/gsettings_err; then
|
| 77 |
+
echo "[cua_gym_vm_bridge] gsettings ignore-hosts = ${ignore_list}"
|
| 78 |
+
else
|
| 79 |
+
echo "[cua_gym_vm_bridge] WARN: gsettings ignore-hosts failed: $(cat /tmp/gsettings_err 2>/dev/null)"
|
| 80 |
+
fi
|
| 81 |
+
|
| 82 |
+
# 4) Shell env — comma-separated form for no_proxy/NO_PROXY (requests/curl).
|
| 83 |
+
local NP="localhost,127.0.0.1,${GW}"
|
| 84 |
+
[ -n "${OWN_IP}" ] && NP="${NP},${OWN_IP}"
|
| 85 |
+
[ -n "${OWN_NET}" ] && NP="${NP},${OWN_NET}"
|
| 86 |
+
[ -n "${GW_NET}" ] && NP="${NP},${GW_NET}.0/24"
|
| 87 |
+
[ -n "${MOCK_HOST}" ] && NP="${NP},${MOCK_HOST}"
|
| 88 |
+
[ -n "${MOCK_NET}" ] && NP="${NP},${MOCK_NET}"
|
| 89 |
+
|
| 90 |
+
for var in no_proxy NO_PROXY; do
|
| 91 |
+
if ! grep -q "export ${var}=${NP}" /home/user/.bashrc 2>/dev/null; then
|
| 92 |
+
echo "export ${var}=${NP}" >> /home/user/.bashrc
|
| 93 |
+
fi
|
| 94 |
+
done
|
| 95 |
+
run_root "grep -q '^no_proxy=' /etc/environment 2>/dev/null \
|
| 96 |
+
&& sed -i 's|^no_proxy=.*|no_proxy=\"${NP}\"|' /etc/environment \
|
| 97 |
+
|| echo 'no_proxy=\"${NP}\"' >> /etc/environment
|
| 98 |
+
grep -q '^NO_PROXY=' /etc/environment 2>/dev/null \
|
| 99 |
+
&& sed -i 's|^NO_PROXY=.*|NO_PROXY=\"${NP}\"|' /etc/environment \
|
| 100 |
+
|| echo 'NO_PROXY=\"${NP}\"' >> /etc/environment" >/dev/null 2>&1
|
| 101 |
+
echo "[cua_gym_vm_bridge] no_proxy=${NP}"
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
fix_vm_network
|
| 105 |
+
|
| 106 |
+
echo "[cua_gym_vm_bridge] direct-IP mode: ${MOCK_HOST} (+${MOCK_NET}) bypassed from woa proxy; no socat forwarding needed"
|
legacy/ar_collections_001/initial_setup.py
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Initial Setup: AR collections check (PRE-task state)
|
| 3 |
+
Task ID: ar_collections_001
|
| 4 |
+
Domain: libreoffice_calc (HYBRID: local ledger + gmail_mock + slack_mock)
|
| 5 |
+
|
| 6 |
+
Pre-task state:
|
| 7 |
+
- Ledger /home/user/ar_collections_001.xlsx with INV-1031 & INV-1037 status='Sent'
|
| 8 |
+
- Gmail: realistic inbox, NO dunning emails to the two AP contacts
|
| 9 |
+
- Slack #collections: prior chatter only, NO overdue roundup
|
| 10 |
+
Launches LibreOffice Calc + Chrome (gmail, slack).
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import os
|
| 14 |
+
import shlex
|
| 15 |
+
import subprocess
|
| 16 |
+
import time
|
| 17 |
+
import uuid
|
| 18 |
+
|
| 19 |
+
import openpyxl
|
| 20 |
+
import requests
|
| 21 |
+
|
| 22 |
+
WORKDIR = '/home/user'
|
| 23 |
+
TASK_ID = 'ar_collections_001'
|
| 24 |
+
OUTPUT = f'{WORKDIR}/{TASK_ID}.xlsx'
|
| 25 |
+
|
| 26 |
+
GMAIL_URL = 'http://28.7.186.212:8158'
|
| 27 |
+
SLACK_URL = 'http://28.7.186.212:8198'
|
| 28 |
+
|
| 29 |
+
HEADERS = ['Invoice #', 'Customer', 'Deal/Contract', 'Amount',
|
| 30 |
+
'Issue Date', 'Due Date', 'Status', 'AE/Owner']
|
| 31 |
+
|
| 32 |
+
# Today = 2026-06-24. Overdue = Due Date < today AND Status != 'Paid'.
|
| 33 |
+
# INV-1031 and INV-1037 are 'Sent' here (NOT yet flipped to Overdue).
|
| 34 |
+
LEDGER_ROWS = [
|
| 35 |
+
['INV-1029', 'Initech', 'Enterprise License Renewal', 9800, '2026-04-15', '2026-05-15', 'Paid', 'Sarah Chen'],
|
| 36 |
+
['INV-1030', 'Hooli', 'Cloud Platform Q2', 31200, '2026-04-20', '2026-05-20', 'Paid', 'Marcus Johnson'],
|
| 37 |
+
['INV-1031', 'Vandelay Industries', 'Latex Supply Contract', 15000, '2026-04-30', '2026-05-30', 'Sent', 'Priya Patel'],
|
| 38 |
+
['INV-1032', 'Pied Piper', 'Compression SDK', 8400, '2026-05-05', '2026-06-30', 'Sent', 'Sarah Chen'],
|
| 39 |
+
['INV-1033', 'Stark Industries', 'Arc Reactor Maintenance', 47500, '2026-05-10', '2026-07-10', 'Sent', 'David Kim'],
|
| 40 |
+
['INV-1034', 'Wayne Enterprises', 'Security Audit', 12750, '2026-05-12', '2026-06-12', 'Paid', 'Marcus Johnson'],
|
| 41 |
+
['INV-1035', 'Soylent Corp', 'Nutrition Analytics', 6300, '2026-05-18', '2026-07-01', 'Sent', 'Priya Patel'],
|
| 42 |
+
['INV-1036', 'Globex Corporation', 'ERP Integration', 28900, '2026-05-22', '2026-06-22', 'Paid', 'David Kim'],
|
| 43 |
+
['INV-1037', 'Wernham Hogg', 'Paper Supply Agreement', 22400, '2026-05-06', '2026-06-05', 'Sent', 'Sarah Chen'],
|
| 44 |
+
['INV-1038', 'Cyberdyne Systems', 'AI Platform License', 54000, '2026-06-01', '2026-07-15', 'Sent', 'David Kim'],
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def build_ledger(path, overdue_status='Sent'):
|
| 49 |
+
"""Build the AR Invoice Ledger. overdue_status applied to INV-1031 & INV-1037."""
|
| 50 |
+
wb = openpyxl.Workbook()
|
| 51 |
+
ws = wb.active
|
| 52 |
+
ws.title = 'AR Invoice Ledger'
|
| 53 |
+
for col, h in enumerate(HEADERS, 1):
|
| 54 |
+
ws.cell(row=1, column=col, value=h)
|
| 55 |
+
for r, row in enumerate(LEDGER_ROWS, 2):
|
| 56 |
+
out = list(row)
|
| 57 |
+
if out[0] in ('INV-1031', 'INV-1037'):
|
| 58 |
+
out[6] = overdue_status # column G = Status
|
| 59 |
+
for c, val in enumerate(out, 1):
|
| 60 |
+
ws.cell(row=r, column=c, value=val)
|
| 61 |
+
wb.save(path)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def gmail_state():
|
| 65 |
+
return {
|
| 66 |
+
'user': {'userId': 'u1', 'username': 'Dana Reyes', 'email': 'collections@northwind-saas.com'},
|
| 67 |
+
'emails': [
|
| 68 |
+
{
|
| 69 |
+
'id': 'email_1', 'threadId': 'thread_1',
|
| 70 |
+
'from': {'name': 'Accounts Payable', 'email': 'ap@globex.com'},
|
| 71 |
+
'to': [{'name': 'Dana Reyes', 'email': 'collections@northwind-saas.com'}],
|
| 72 |
+
'cc': [], 'bcc': [],
|
| 73 |
+
'subject': 'Remittance advice — INV-1036 paid',
|
| 74 |
+
'body': '<p>Hi Dana, payment for INV-1036 ($28,900) has been processed. Reference GX-55812.</p>',
|
| 75 |
+
'timestamp': '2026-06-21T09:14:00Z',
|
| 76 |
+
'read': True, 'starred': False, 'important': False,
|
| 77 |
+
'labels': ['l4'], 'category': 'primary', 'folder': 'inbox', 'attachments': []
|
| 78 |
+
},
|
| 79 |
+
{
|
| 80 |
+
'id': 'email_2', 'threadId': 'thread_2',
|
| 81 |
+
'from': {'name': 'Marcus Johnson', 'email': 'marcus.johnson@northwind-saas.com'},
|
| 82 |
+
'to': [{'name': 'Dana Reyes', 'email': 'collections@northwind-saas.com'}],
|
| 83 |
+
'cc': [], 'bcc': [],
|
| 84 |
+
'subject': 'AR aging — please run the weekly check',
|
| 85 |
+
'body': '<p>Dana, can you run the collections pass on the AR Invoice Ledger today? Thanks.</p>',
|
| 86 |
+
'timestamp': '2026-06-24T07:40:00Z',
|
| 87 |
+
'read': False, 'starred': True, 'important': True,
|
| 88 |
+
'labels': ['l1'], 'category': 'primary', 'folder': 'inbox', 'attachments': []
|
| 89 |
+
},
|
| 90 |
+
{
|
| 91 |
+
'id': 'email_3', 'threadId': 'thread_3',
|
| 92 |
+
'from': {'name': 'Initech AP', 'email': 'ap@initech.com'},
|
| 93 |
+
'to': [{'name': 'Dana Reyes', 'email': 'collections@northwind-saas.com'}],
|
| 94 |
+
'cc': [], 'bcc': [],
|
| 95 |
+
'subject': 'Payment confirmation INV-1029',
|
| 96 |
+
'body': '<p>Confirming wire transfer for INV-1029 ($9,800). Thank you.</p>',
|
| 97 |
+
'timestamp': '2026-06-18T15:02:00Z',
|
| 98 |
+
'read': True, 'starred': False, 'important': False,
|
| 99 |
+
'labels': ['l4'], 'category': 'primary', 'folder': 'inbox', 'attachments': []
|
| 100 |
+
},
|
| 101 |
+
],
|
| 102 |
+
'labels': [
|
| 103 |
+
{'id': 'l1', 'name': 'Work', 'color': '#ef4444'},
|
| 104 |
+
{'id': 'l2', 'name': 'Personal', 'color': '#3b82f6'},
|
| 105 |
+
{'id': 'l3', 'name': 'Travel', 'color': '#22c55e'},
|
| 106 |
+
{'id': 'l4', 'name': 'Finance', 'color': '#eab308'},
|
| 107 |
+
],
|
| 108 |
+
'drafts': [],
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
def slack_state():
|
| 113 |
+
users = [
|
| 114 |
+
{'userId': 'user_1', 'fullName': 'Dana Reyes', 'displayName': 'Dana', 'email': 'dana.reyes@northwind-saas.com', 'avatar': 'https://picsum.photos/200/200?random=1', 'title': 'Collections Lead', 'status': 'online', 'statusMessage': '', 'statusEmoji': '', 'timeZone': 'America/New_York'},
|
| 115 |
+
{'userId': 'user_2', 'fullName': 'Marcus Johnson', 'displayName': 'Marcus', 'email': 'marcus.johnson@northwind-saas.com', 'avatar': 'https://picsum.photos/200/200?random=2', 'title': 'AR Manager', 'status': 'online', 'statusMessage': '', 'statusEmoji': '', 'timeZone': 'America/New_York'},
|
| 116 |
+
{'userId': 'user_3', 'fullName': 'Sarah Chen', 'displayName': 'Sarah', 'email': 'sarah.chen@northwind-saas.com', 'avatar': 'https://picsum.photos/200/200?random=3', 'title': 'Account Executive', 'status': 'away', 'statusMessage': '', 'statusEmoji': '', 'timeZone': 'America/Los_Angeles'},
|
| 117 |
+
]
|
| 118 |
+
channels = [
|
| 119 |
+
{'channelId': 'general', 'name': 'general', 'description': 'Company-wide announcements', 'topic': '', 'isPrivate': False, 'isStarred': False, 'members': ['user_1', 'user_2', 'user_3'], 'createdBy': 'user_2', 'createdAt': '2026-01-05T10:00:00Z', 'pinnedMessages': [], 'unreadCount': 0},
|
| 120 |
+
{'channelId': 'random', 'name': 'random', 'description': 'Non-work banter', 'topic': '', 'isPrivate': False, 'isStarred': False, 'members': ['user_1', 'user_2', 'user_3'], 'createdBy': 'user_2', 'createdAt': '2026-01-05T10:00:00Z', 'pinnedMessages': [], 'unreadCount': 0},
|
| 121 |
+
{'channelId': 'collections', 'name': 'collections', 'description': 'AR collections coordination', 'topic': 'Overdue invoices & dunning', 'isPrivate': False, 'isStarred': True, 'members': ['user_1', 'user_2', 'user_3'], 'createdBy': 'user_2', 'createdAt': '2026-02-01T09:00:00Z', 'pinnedMessages': [], 'unreadCount': 0},
|
| 122 |
+
]
|
| 123 |
+
messages = {
|
| 124 |
+
'general': [
|
| 125 |
+
{'messageId': 'msg_g1', 'senderId': 'user_2', 'content': 'Morning all — month-end AR review is this week.', 'timestamp': '2026-06-23T13:30:00Z', 'threadId': None, 'reactions': [], 'attachments': [], 'isEdited': False},
|
| 126 |
+
],
|
| 127 |
+
'random': [
|
| 128 |
+
{'messageId': 'msg_r1', 'senderId': 'user_3', 'content': 'Coffee machine on 4 is fixed 🎉', 'timestamp': '2026-06-22T16:05:00Z', 'threadId': None, 'reactions': [], 'attachments': [], 'isEdited': False},
|
| 129 |
+
],
|
| 130 |
+
'collections': [
|
| 131 |
+
{'messageId': 'msg_c1', 'senderId': 'user_2', 'content': 'Reminder: run the weekly collections pass on the AR Invoice Ledger and post the roundup here.', 'timestamp': '2026-06-24T07:45:00Z', 'threadId': None, 'reactions': [], 'attachments': [], 'isEdited': False},
|
| 132 |
+
{'messageId': 'msg_c2', 'senderId': 'user_1', 'content': 'On it — pulling the ledger now.', 'timestamp': '2026-06-24T08:02:00Z', 'threadId': None, 'reactions': [], 'attachments': [], 'isEdited': False},
|
| 133 |
+
],
|
| 134 |
+
}
|
| 135 |
+
return {
|
| 136 |
+
'currentUser': users[0],
|
| 137 |
+
'workspace': {'workspaceId': 'ws_1', 'workspaceName': 'Northwind SaaS', 'icon': ''},
|
| 138 |
+
'users': users,
|
| 139 |
+
'channels': channels,
|
| 140 |
+
'messages': messages,
|
| 141 |
+
'threads': {},
|
| 142 |
+
'dms': [],
|
| 143 |
+
'bookmarkedMessages': [],
|
| 144 |
+
'callHistory': [],
|
| 145 |
+
'settings': {'theme': 'light', 'notifications': 'all', 'displayDensity': 'comfortable', 'showAvatars': True, 'use24Hour': False},
|
| 146 |
+
'invitations': [],
|
| 147 |
+
'notifications': [],
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def launch_gui(command, delay_sec=1.0):
|
| 152 |
+
env = os.environ.copy()
|
| 153 |
+
env['DISPLAY'] = ':0'
|
| 154 |
+
subprocess.Popen(shlex.split(command), stdout=subprocess.DEVNULL,
|
| 155 |
+
stderr=subprocess.DEVNULL, env=env)
|
| 156 |
+
time.sleep(delay_sec)
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
def main():
|
| 160 |
+
# --- sid (shared between gmail + slack on THIS vm) ---
|
| 161 |
+
sid = str(uuid.uuid4())
|
| 162 |
+
with open('/tmp/task_web_sid', 'w') as f:
|
| 163 |
+
f.write(sid)
|
| 164 |
+
|
| 165 |
+
# --- Ledger (INV-1031 & INV-1037 = 'Sent') ---
|
| 166 |
+
build_ledger(OUTPUT, overdue_status='Sent')
|
| 167 |
+
print(f'Initial ledger created: {OUTPUT}')
|
| 168 |
+
|
| 169 |
+
# --- Inject mock state (action: set => initial_state == current_state) ---
|
| 170 |
+
for name, url, state in [('gmail', GMAIL_URL, gmail_state()),
|
| 171 |
+
('slack', SLACK_URL, slack_state())]:
|
| 172 |
+
r = requests.post(f'{url}/post?sid={sid}',
|
| 173 |
+
json={'action': 'set', 'state': state}, timeout=30)
|
| 174 |
+
assert r.status_code == 200, f'{name} set failed: {r.text}'
|
| 175 |
+
go = requests.get(f'{url}/go?sid={sid}', timeout=15).json()
|
| 176 |
+
assert go['initial_state'] is not None, f'{name} initial_state None'
|
| 177 |
+
print(f'{name} state injected: sid={sid}')
|
| 178 |
+
|
| 179 |
+
# --- GUI-ready startup ---
|
| 180 |
+
launch_gui(f'libreoffice --calc "{OUTPUT}"', delay_sec=3.0)
|
| 181 |
+
launch_gui(f'google-chrome "{GMAIL_URL}/?sid={sid}"', delay_sec=2.0)
|
| 182 |
+
launch_gui(f'google-chrome "{SLACK_URL}/?sid={sid}"', delay_sec=2.0)
|
| 183 |
+
print('GUI_READY: launched LibreOffice Calc + Chrome (gmail, slack) with DISPLAY=:0')
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
main()
|
legacy/ar_collections_001/reward.py
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Reward Script: AR collections check — flip overdue invoices, send dunning emails, post Slack roundup
|
| 3 |
+
Task ID: ar_collections_001
|
| 4 |
+
Domain: libreoffice_calc + mock_websites (HYBRID: local xlsx ledger -> Gmail -> Slack)
|
| 5 |
+
|
| 6 |
+
Scoring (all deterministic; each component scores a task-introduced change so initial_env == 0.0):
|
| 7 |
+
LOCAL LEDGER (0.40):
|
| 8 |
+
C1 (0.15): INV-1031 Status == 'Overdue'
|
| 9 |
+
C2 (0.15): INV-1037 Status == 'Overdue'
|
| 10 |
+
C3 (0.10): C1 & C2 hold AND exactly those two rows are 'Overdue' (no other row flipped)
|
| 11 |
+
GMAIL (0.30):
|
| 12 |
+
C4 (0.15): NEW sent email to ap@vandelay.com referencing INV-1031 and $15,000
|
| 13 |
+
C5 (0.15): NEW sent email to billing@wernham-hogg.com referencing INV-1037 and $22,400
|
| 14 |
+
SLACK (0.30):
|
| 15 |
+
C6 (0.15): NEW #collections message (delta) mentioning 'overdue' and total 37400
|
| 16 |
+
C7 (0.15): that NEW roundup states a count of 2 overdue invoices
|
| 17 |
+
"""
|
| 18 |
+
import os
|
| 19 |
+
import re
|
| 20 |
+
import sys
|
| 21 |
+
|
| 22 |
+
import requests
|
| 23 |
+
|
| 24 |
+
LEDGER_PATH = '/home/user/ar_collections_001.xlsx'
|
| 25 |
+
SHEET_NAME = 'AR Invoice Ledger'
|
| 26 |
+
GMAIL_URL = 'http://28.7.186.212:8158'
|
| 27 |
+
SLACK_URL = 'http://28.7.186.212:8198'
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def _norm_amount(text):
|
| 31 |
+
"""Strip $ and thousands separators so '15,000' / '$15,000.00' / '15000' all match '15000'."""
|
| 32 |
+
return re.sub(r'[,$\s]', '', text or '')
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def fetch_mock(base_url, sid):
|
| 36 |
+
"""Return (initial_state, current_state) dicts, or (None, None) on failure."""
|
| 37 |
+
try:
|
| 38 |
+
d = requests.get(f'{base_url}/go?sid={sid}', timeout=20).json()
|
| 39 |
+
return d.get('initial_state') or {}, d.get('current_state') or {}
|
| 40 |
+
except Exception as e:
|
| 41 |
+
print(f'ERROR: cannot fetch {base_url}: {e}')
|
| 42 |
+
return None, None
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def verify_task():
|
| 46 |
+
total = 0.0
|
| 47 |
+
|
| 48 |
+
# ---- read sid (shared across mocks on this VM) ----
|
| 49 |
+
try:
|
| 50 |
+
with open('/tmp/task_web_sid') as f:
|
| 51 |
+
sid = f.read().strip()
|
| 52 |
+
if not sid:
|
| 53 |
+
raise ValueError('empty sid')
|
| 54 |
+
except Exception as e:
|
| 55 |
+
print(f'CRITICAL: cannot read /tmp/task_web_sid: {e}')
|
| 56 |
+
print('REWARD: 0.0')
|
| 57 |
+
return 0.0
|
| 58 |
+
|
| 59 |
+
# =========================================================
|
| 60 |
+
# LOCAL LEDGER (0.40)
|
| 61 |
+
# =========================================================
|
| 62 |
+
rows = {} # invoice# -> status
|
| 63 |
+
try:
|
| 64 |
+
import openpyxl
|
| 65 |
+
wb = openpyxl.load_workbook(LEDGER_PATH, data_only=True)
|
| 66 |
+
ws = wb[SHEET_NAME]
|
| 67 |
+
for r in ws.iter_rows(min_row=2, values_only=True):
|
| 68 |
+
if r and r[0]:
|
| 69 |
+
rows[str(r[0]).strip()] = (str(r[6]).strip() if r[6] is not None else '')
|
| 70 |
+
print(f'Ledger rows loaded: {len(rows)}')
|
| 71 |
+
except Exception as e:
|
| 72 |
+
print(f'ERROR: cannot load ledger {LEDGER_PATH}: {e}')
|
| 73 |
+
|
| 74 |
+
# C1 (0.15): INV-1031 -> Overdue
|
| 75 |
+
try:
|
| 76 |
+
if rows.get('INV-1031', '').lower() == 'overdue':
|
| 77 |
+
print('PASS C1: INV-1031 Status == Overdue (0.15)')
|
| 78 |
+
total += 0.15
|
| 79 |
+
else:
|
| 80 |
+
print(f"FAIL C1: INV-1031 Status == {rows.get('INV-1031')!r}, expected 'Overdue'")
|
| 81 |
+
except Exception as e:
|
| 82 |
+
print(f'ERROR C1: {e}')
|
| 83 |
+
|
| 84 |
+
# C2 (0.15): INV-1037 -> Overdue
|
| 85 |
+
try:
|
| 86 |
+
if rows.get('INV-1037', '').lower() == 'overdue':
|
| 87 |
+
print('PASS C2: INV-1037 Status == Overdue (0.15)')
|
| 88 |
+
total += 0.15
|
| 89 |
+
else:
|
| 90 |
+
print(f"FAIL C2: INV-1037 Status == {rows.get('INV-1037')!r}, expected 'Overdue'")
|
| 91 |
+
except Exception as e:
|
| 92 |
+
print(f'ERROR C2: {e}')
|
| 93 |
+
|
| 94 |
+
# C3 (0.10): exactly INV-1031 & INV-1037 are Overdue, no other row flipped.
|
| 95 |
+
# Compound-anchored to the change so it FAILS on initial_env (0 overdue rows).
|
| 96 |
+
try:
|
| 97 |
+
overdue = {inv for inv, st in rows.items() if st.lower() == 'overdue'}
|
| 98 |
+
if overdue == {'INV-1031', 'INV-1037'}:
|
| 99 |
+
print('PASS C3: exactly INV-1031 & INV-1037 are Overdue, no other row changed (0.10)')
|
| 100 |
+
total += 0.10
|
| 101 |
+
else:
|
| 102 |
+
print(f'FAIL C3: Overdue set == {sorted(overdue)}, expected exactly INV-1031 & INV-1037')
|
| 103 |
+
except Exception as e:
|
| 104 |
+
print(f'ERROR C3: {e}')
|
| 105 |
+
|
| 106 |
+
# =========================================================
|
| 107 |
+
# GMAIL (0.30) — score only NEW sent emails (delta vs initial)
|
| 108 |
+
# =========================================================
|
| 109 |
+
g_ini, g_cur = fetch_mock(GMAIL_URL, sid)
|
| 110 |
+
new_sent = []
|
| 111 |
+
if g_cur is not None:
|
| 112 |
+
try:
|
| 113 |
+
ini_ids = {e.get('id') for e in g_ini.get('emails', [])}
|
| 114 |
+
for e in g_cur.get('emails', []):
|
| 115 |
+
if e.get('folder') == 'sent' and e.get('id') not in ini_ids:
|
| 116 |
+
new_sent.append(e)
|
| 117 |
+
print(f'New sent emails (delta): {len(new_sent)}')
|
| 118 |
+
except Exception as e:
|
| 119 |
+
print(f'ERROR gmail delta: {e}')
|
| 120 |
+
|
| 121 |
+
def sent_matches(recipient, inv, amount):
|
| 122 |
+
for e in new_sent:
|
| 123 |
+
tos = [r.get('email', '').lower() for r in (e.get('to') or [])]
|
| 124 |
+
if recipient.lower() not in tos:
|
| 125 |
+
continue
|
| 126 |
+
blob = (e.get('subject', '') or '') + ' ' + (e.get('body', '') or '')
|
| 127 |
+
if inv.lower() in blob.lower() and amount in _norm_amount(blob):
|
| 128 |
+
return True
|
| 129 |
+
return False
|
| 130 |
+
|
| 131 |
+
# C4 (0.15): dunning email to Vandelay (INV-1031, $15,000)
|
| 132 |
+
try:
|
| 133 |
+
if sent_matches('ap@vandelay.com', 'INV-1031', '15000'):
|
| 134 |
+
print('PASS C4: dunning email sent to ap@vandelay.com (INV-1031, $15,000) (0.15)')
|
| 135 |
+
total += 0.15
|
| 136 |
+
else:
|
| 137 |
+
print('FAIL C4: no NEW sent email to ap@vandelay.com referencing INV-1031 + $15,000')
|
| 138 |
+
except Exception as e:
|
| 139 |
+
print(f'ERROR C4: {e}')
|
| 140 |
+
|
| 141 |
+
# C5 (0.15): dunning email to Wernham Hogg (INV-1037, $22,400)
|
| 142 |
+
try:
|
| 143 |
+
if sent_matches('billing@wernham-hogg.com', 'INV-1037', '22400'):
|
| 144 |
+
print('PASS C5: dunning email sent to billing@wernham-hogg.com (INV-1037, $22,400) (0.15)')
|
| 145 |
+
total += 0.15
|
| 146 |
+
else:
|
| 147 |
+
print('FAIL C5: no NEW sent email to billing@wernham-hogg.com referencing INV-1037 + $22,400')
|
| 148 |
+
except Exception as e:
|
| 149 |
+
print(f'ERROR C5: {e}')
|
| 150 |
+
|
| 151 |
+
# =========================================================
|
| 152 |
+
# SLACK (0.30) — score only NEW #collections messages (delta vs initial)
|
| 153 |
+
# =========================================================
|
| 154 |
+
s_ini, s_cur = fetch_mock(SLACK_URL, sid)
|
| 155 |
+
new_msgs = []
|
| 156 |
+
if s_cur is not None:
|
| 157 |
+
try:
|
| 158 |
+
ini_msgs = (s_ini.get('messages', {}) or {}).get('collections', []) or []
|
| 159 |
+
cur_msgs = (s_cur.get('messages', {}) or {}).get('collections', []) or []
|
| 160 |
+
ini_mids = {m.get('messageId') for m in ini_msgs}
|
| 161 |
+
for m in cur_msgs:
|
| 162 |
+
if m.get('messageId') not in ini_mids:
|
| 163 |
+
new_msgs.append(m)
|
| 164 |
+
print(f'New #collections messages (delta): {len(new_msgs)}')
|
| 165 |
+
except Exception as e:
|
| 166 |
+
print(f'ERROR slack delta: {e}')
|
| 167 |
+
|
| 168 |
+
# C6 (0.15): a NEW roundup message mentions overdue + total outstanding 37400
|
| 169 |
+
roundup = None
|
| 170 |
+
try:
|
| 171 |
+
for m in new_msgs:
|
| 172 |
+
c = m.get('content', '') or ''
|
| 173 |
+
if 'overdue' in c.lower() and '37400' in _norm_amount(c):
|
| 174 |
+
roundup = m
|
| 175 |
+
break
|
| 176 |
+
if roundup is not None:
|
| 177 |
+
print('PASS C6: NEW #collections roundup mentions overdue + total $37,400 (0.15)')
|
| 178 |
+
total += 0.15
|
| 179 |
+
else:
|
| 180 |
+
print('FAIL C6: no NEW #collections message mentioning overdue + total 37400')
|
| 181 |
+
except Exception as e:
|
| 182 |
+
print(f'ERROR C6: {e}')
|
| 183 |
+
|
| 184 |
+
# C7 (0.15): the roundup states a count of 2 overdue invoices
|
| 185 |
+
try:
|
| 186 |
+
ok = False
|
| 187 |
+
if roundup is not None:
|
| 188 |
+
c = roundup.get('content', '') or ''
|
| 189 |
+
cl = c.lower()
|
| 190 |
+
# count of 2 stated explicitly, or both invoice numbers enumerated
|
| 191 |
+
ok = bool(re.search(r'\b2\b', c)) or ('inv-1031' in cl and 'inv-1037' in cl)
|
| 192 |
+
if ok:
|
| 193 |
+
print('PASS C7: roundup states 2 invoices overdue (0.15)')
|
| 194 |
+
total += 0.15
|
| 195 |
+
else:
|
| 196 |
+
print('FAIL C7: roundup does not state a count of 2 overdue invoices')
|
| 197 |
+
except Exception as e:
|
| 198 |
+
print(f'ERROR C7: {e}')
|
| 199 |
+
|
| 200 |
+
final = round(min(total, 1.0), 4)
|
| 201 |
+
print(f'\nScore: {total}/1.0')
|
| 202 |
+
print(f'REWARD: {final}')
|
| 203 |
+
return final
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
verify_task()
|
legacy/ar_collections_001/reward_label.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"reward_file": "/apdcephfs_sh2/share_300000800/user/jackwkwang/long-horizon-tasks/mini_osworld_xiangwu/cache/ar_collections_001/reward.py",
|
| 3 |
+
"api_url": "http://28.7.184.184:8000/v1/chat/completions",
|
| 4 |
+
"model": "Kimi-K2.6",
|
| 5 |
+
"max_code_chars": 100000,
|
| 6 |
+
"created_at": "2026-07-14 10:22:19",
|
| 7 |
+
"label": {
|
| 8 |
+
"task_id": "ar_collections_001",
|
| 9 |
+
"domain": "libreoffice_calc + mock_websites",
|
| 10 |
+
"summary": "验证用户是否将本地账本中指定发票状态改为Overdue,并通过Gmail发送两封催款邮件,同时在Slack #collections频道发布包含逾期总额和数量的汇总消息",
|
| 11 |
+
"is_placeholder": false,
|
| 12 |
+
"data_sources": [
|
| 13 |
+
"/tmp/task_web_sid",
|
| 14 |
+
"/home/user/ar_collections_001.xlsx",
|
| 15 |
+
"Gmail mock服务 (http://28.7.186.212:8158)",
|
| 16 |
+
"Slack mock服务 (http://28.7.186.212:8198)"
|
| 17 |
+
],
|
| 18 |
+
"scoring_components": [
|
| 19 |
+
{
|
| 20 |
+
"name": "C1",
|
| 21 |
+
"weight": 0.15,
|
| 22 |
+
"description": "检查本地Excel账本中INV-1031的状态是否被标记为Overdue",
|
| 23 |
+
"check_logic": "使用openpyxl加载LEDGER_PATH指定的工作表'SAR Invoice Ledger',遍历所有行构建字典rows(invoice# -> status),检查rows.get('INV-1031', '').lower() == 'overdue'",
|
| 24 |
+
"pass_condition": "INV-1031对应的状态字符串去除首尾空格并转小写后等于'overdue'"
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"name": "C2",
|
| 28 |
+
"weight": 0.15,
|
| 29 |
+
"description": "检查本地Excel账本中INV-1037的状态是否被标记为Overdue",
|
| 30 |
+
"check_logic": "检查rows.get('INV-1037', '').lower() == 'overdue'",
|
| 31 |
+
"pass_condition": "INV-1037对应的状态字符串去除首尾空格并转小写后等于'overdue'"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"name": "C3",
|
| 35 |
+
"weight": 0.1,
|
| 36 |
+
"description": "检查账本中是否仅有INV-1031和INV-1037两行被标记为Overdue,没有其他行被意外修改",
|
| 37 |
+
"check_logic": "遍历rows中所有状态转小写等于'overdue'的发票号构成集合overdue,检查overdue == {'INV-1031', 'INV-1037'}",
|
| 38 |
+
"pass_condition": "逾期发票集合恰好等于{'INV-1031', 'INV-1037'},不多不少"
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"name": "C4",
|
| 42 |
+
"weight": 0.15,
|
| 43 |
+
"description": "检查是否通过Gmail向ap@vandelay.com发送了关于INV-1031和$15,000的新催款邮件",
|
| 44 |
+
"check_logic": "调用fetch_mock获取Gmail的initial_state与current_state,筛选folder为'sent'且id不在初始邮件集合中的new_sent邮件;在new_sent中查找收件人包含'ap@vandelay.com',且subject与body拼接后的文本同时包含'INV-1031'和经_norm_amount处理后的金额'15000'的邮件",
|
| 45 |
+
"pass_condition": "存在至少一封新的sent邮件,收件人包含ap@vandelay.com,且主题或正文同时引用INV-1031和金额15000"
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"name": "C5",
|
| 49 |
+
"weight": 0.15,
|
| 50 |
+
"description": "检查是否通过Gmail向billing@wernham-hogg.com发送了关于INV-1037和$22,400的新催款邮件",
|
| 51 |
+
"check_logic": "与C4类似,在new_sent中查找收件人包含'billing@wernham-hogg.com',且主题或正文同时包含'INV-1037'和经_norm_amount处理后的金额'22400'的邮件",
|
| 52 |
+
"pass_condition": "存在至少一封新的sent邮件,收件人包含billing@wernham-hogg.com,且主题或正文同时引用INV-1037和金额22400"
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"name": "C6",
|
| 56 |
+
"weight": 0.15,
|
| 57 |
+
"description": "检查Slack #collections频道是否有新消息提到overdue和总逾期金额37400",
|
| 58 |
+
"check_logic": "调用fetch_mock获取Slack的initial_state与current_state,提取#collections频道中messageId不在初始消息集合中的new_msgs;遍历new_msgs,检查消息内容转小写后包含'overdue'且经_norm_amount处理后包含'37400'",
|
| 59 |
+
"pass_condition": "存在至少一条新的#collections消息,其内容同时包含'overdue'和金额37400"
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"name": "C7",
|
| 63 |
+
"weight": 0.15,
|
| 64 |
+
"description": "检查C6中找到的汇总消息是否明确说明有2张逾期发票",
|
| 65 |
+
"check_logic": "在C6命中的roundup消息内容中,使用正则\\b2\\b查找显式数字2,或检查内容转小写后同时包含'inv-1031'和'inv-1037'",
|
| 66 |
+
"pass_condition": "roundup消息内容中显式出现数字2,或同时提及inv-1031与inv-1037"
|
| 67 |
+
}
|
| 68 |
+
],
|
| 69 |
+
"total_max_score": 1.0,
|
| 70 |
+
"score_aggregation": "各组件分数累加求和,最终通过round(min(total, 1.0), 4)将总分钳制在1.0以内并四舍五入保留4位小数",
|
| 71 |
+
"failure_modes": [
|
| 72 |
+
"读取/tmp/task_web_sid失败或内容为空:打印CRITICAL并直接返回0.0",
|
| 73 |
+
"加载本地Excel账本失败:打印ERROR,对应行状态为空导致C1-C3失败",
|
| 74 |
+
"fetch_mock请求Gmail或Slack失败:返回(None, None),对应模块无法计算delta而失败",
|
| 75 |
+
"Gmail中无新的sent邮件:C4、C5失败",
|
| 76 |
+
"Slack #collections中无新消息:C6、C7失败",
|
| 77 |
+
"C6未找到roundup消息:C7因roundup为None而失败",
|
| 78 |
+
"任一���件检查过程中抛出异常:捕获后打印ERROR,该组件不得分但不中断后续检查"
|
| 79 |
+
],
|
| 80 |
+
"scoring_logic_explanation": "脚本首先读取/tmp/task_web_sid获取会话ID,失败则直接返回0.0。接着加载本地Excel账本/home/user/ar_collections_001.xlsx,提取所有发票号与状态,依次检查C1(INV-1031为Overdue)、C2(INV-1037为Overdue)和C3(仅有这两行是Overdue)。随后通过sid请求mock Gmail服务,对比初始状态与当前状态,筛选出新的sent邮件,检查C4(发给ap@vandelay.com并引用INV-1031和15000)和C5(发给billing@wernham-hogg.com并引用INV-1037和22400)。再请求mock Slack服务,对比#collections频道消息,筛选出新消息,检查C6(内容包含overdue和37400)和C7(该消息中明确说明数量为2,或同时提及两张发票号)。所有通过的组件分值累加到total,最后以min(total, 1.0)钳制上限并四舍五入到4位小数输出。",
|
| 81 |
+
"confidence": 1.0
|
| 82 |
+
},
|
| 83 |
+
"raw_response": "用户要求我分析一个 reward.py 评分脚本的评分逻辑,并输出一个严格的 JSON 对象。\n\n让我仔细阅读代码:\n\n1. **Task ID**: 从 docstring 中提取:`ar_collections_001`\n2. **Domain**: 从 docstring 中提取:`libreoffice_calc + mock_websites (HYBRID: local xlsx ledger -> Gmail -> Slack)`,简化可以是 `libreoffice_calc` 或 `mock_websites`。根据要求\"如 libreoffice_calc\",我填 `libreoffice_calc + mock_websites` 或按格式要求。看示例有 `libreoffice_calc`,这里 docstring 明确写了 HYBRID,我可以写 `libreoffice_calc + mock_websites` 或者就按 docstring 的 `libreoffice_calc + mock_websites (HYBRID)`。但示例格式是单个值。我填 `libreoffice_calc + mock_websites` 应该可以,或者更准确地提取。再看要求:\"从 docstring 中提取的领域,如 mock_websites / software_engineer / libreoffice_calc\"。这里 docstring 写的是 `libreoffice_calc + mock_websites (HYBRID: local xlsx ledger -> Gmail -> Slack)`。我填 `libreoffice_calc + mock_websites` 比较准确。\n\n3. **Summary**: 一句话概括。这个脚本验证:将本地 Excel 账本中特定发票状态改为逾期,通过 Gmail 发送催款邮件,并在 Slack #collections 频道发布汇总消息。\n\n4. **is_placeholder**: false。这个脚本有详细的检查逻辑,不是占位脚本。\n\n5. **data_sources**: \n - `/tmp/task_web_sid` (读取 sid)\n - `GMAIL_URL` (http://28.7.186.212:8158) - mock Gmail 服务\n - `SLACK_URL` (http://28.7.186.212:8198) - mock Slack 服务\n - `LEDGER_PATH` (`/home/user/ar_collections_001.xlsx`) - 本地 Excel 文件\n\n6. **scoring_components**: 有 7 个组件,分值在 docstring 和代码中都有。\n\n - C1: 0.15, 检查 INV-1031 状态是否为 Overdue\n - C2: 0.15, 检查 INV-1037 状态是否为 Overdue\n - C3: 0.10, 检查是否只有 INV-1031 和 INV-1037 是 Overdue,没有其他行被修改\n - C4: 0.15, 检查是否有新的发送给 ap@vandelay.com 的邮件,引用 INV-1031 和 $15,000\n - C5: 0.15, 检查是否有新的发送给 billing@wernham-hogg.com 的邮件,引用 INV-1037 和 $22,400\n - C6: 0.15, 检查 Slack #collections 是否有新消息提到 overdue 和总额 37400\n - C7: 0.15, 检查该汇总消息是否说明有 2 张逾期发票\n\n 每个组件的 check_logic 和 pass_condition 需要详细描述。\n\n7. **total_max_score**: 1.0\n\n8. **score_aggregation**: 各组件分数相加,最后用 `min(total, 1.0)` 钳制到上限 1.0。\n\n9. **failure_modes**:\n - 读取 `/tmp/task_web_sid` 失败或为空:打印 CRITICAL 并返回 0.0\n - 加载本地账本失败:打印 ERROR,但该部分继续检查(只是 rows 为空会导致失败)\n - fetch_mock 失败(Gmail 或 Slack):返回 (None, None),对应部分无法得分\n - 没有新的 sent email 或新的 Slack 消息:对应组件失败\n - 任何异常被捕获:打印 ERROR Cx,该组件不得分\n\n10. **scoring_logic_explanation**: 按执行顺序:\n - 首先读取 `/tmp/task_web_sid` 获取会话 ID,失败则直接返回 0.0。\n - 然后加载本地 Excel 账本 `/home/user/ar_collections_001.xlsx`,读取所有行并提取发票号和状态。\n - 检查 C1 和 C2:确认 INV-1031 和 INV-1037 的状态是否为 \"Overdue\"。\n - 检查 C3:确认整个账本中只有这两行是 Overdue,没有其他行被意外修改。\n - 接着通过 sid 请求 mock Gmail 服务,获取初始状态和当前状态,计算 delta(新发送的邮件)。\n - 检查 C4 和 C5:在新发送的邮件中查找是否包含发给特定收件人、引用特定发票号和金额的催款邮件。\n - 然后请求 mock Slack 服务,获取 #collections 频道的初始和当前消息,计算 delta(新消息)。\n - 检查 C6:在新消息中查找是否提到 \"overdue\" 和总金额 \"37400\"。\n - 检查 C7:在 C6 找到的消息中,进一步确认是否明确说明了 2 张逾期发票(通过数字 2 或同时提到两张发票号���。\n - 所有通过检查的组件分值累加到 total,最后 `min(total, 1.0)` 并四舍五入到 4 位小数返回。\n\n11. **confidence**: 1.0。代码逻辑非常清晰。\n\n现在构建 JSON。注意:\n- 不要输出 Markdown 代码块\n- 第一个字符是 `{`,最后一个字符是 `}`\n- 所有字符串 value 使用中文(task_id、domain、字段名、代码标识符保留原样)\n- weight 填代码中显式给出的分值\n\n让我确认每个组件的描述:\n\nC1:\n- name: \"C1\"\n- weight: 0.15\n- description: \"检查本地账本中 INV-1031 的状态是否被标记为 Overdue\"\n- check_logic: \"读取 /home/user/ar_collections_001.xlsx 的 'AR Invoice Ledger' 工作表,构建 rows 字典(invoice# -> status),检查 rows.get('INV-1031', '').lower() == 'overdue'\"\n- pass_condition: \"INV-1031 对应的状态字符串(去除首尾空格后转小写)等于 'overdue'\"\n\nC2:\n- name: \"C2\"\n- weight: 0.15\n- description: \"检查本地账本中 INV-1037 的状态是否被标记为 Overdue\"\n- check_logic: \"检查 rows.get('INV-1037', '').lower() == 'overdue'\"\n- pass_condition: \"INV-1037 对应的状态字符串(去除首尾空格后转小写)等于 'overdue'\"\n\nC3:\n- name: \"C3\"\n- weight: 0.10\n- description: \"检查账本中是否仅有 INV-1031 和 INV-1037 两行被标记为 Overdue,无其他行被修改\"\n- check_logic: \"遍历 rows 中所有状态为 'overdue'(不区分大小写)的发票号,构成集合 overdue,检查 overdue == {'INV-1031', 'INV-1037'}\"\n- pass_condition: \"逾期发票集合恰好等于 {'INV-1031', 'INV-1037'},不多不少\"\n\nC4:\n- name: \"C4\"\n- weight: 0.15\n- description: \"检查是否通过 Gmail 向 ap@vandelay.com 发送了关于 INV-1031 和 $15,000 的新催款邮件\"\n- check_logic: \"调用 fetch_mock 获取 Gmail 的 initial_state 和 current_state,筛选 folder 为 'sent' 且 id 不在初始邮件集合中的 new_sent 邮件;在 new_sent 中查找收件人包含 'ap@vandelay.com'、且主题或正文中同时包含 'INV-1031' 和金额 '15000'(经 _norm_amount 去除 $ 和逗号后匹配)的邮件\"\n- pass_condition: \"存在至少一封新的 sent 邮件,收件人包含 ap@vandelay.com,且主题或正文同时引用 INV-1031 和金额 15000\"\n\nC5:\n- name: \"C5\"\n- weight: 0.15\n- description: \"检查是否通过 Gmail 向 billing@wernham-hogg.com 发送了关于 INV-1037 和 $22,400 的新催款邮件\"\n- check_logic: \"与 C4 类似,在 new_sent 中查找收件人包含 'billing@wernham-hogg.com'、且主题或正文同时包含 'INV-1037' 和金额 '22400' 的邮件\"\n- pass_condition: \"存在至少一封新的 sent 邮件,收件人包含 billing@wernham-hogg.com,且主题或正文同时引用 INV-1037 和金额 22400\"\n\nC6:\n- name: \"C6\"\n- weight: 0.15\n- description: \"检查 Slack #collections 频道是否有新消息提到 overdue 和总逾期金额 37400\"\n- check_logic: \"调用 fetch_mock 获取 Slack 的 initial_state 和 current_state,提取 #collections 频道中 messageId 不在初始消息集合中的 new_msgs;遍历 new_msgs,检查消息内容(转小写后)包含 'overdue' 且经 _norm_amount 处理后包含 '37400'\"\n- pass_condition: \"存在至少一条新的 #collections 消息,其内容同时包含 'overdue' 和金额 37400\"\n\nC7:\n- name: \"C7\"\n- weight: 0.15\n- description: \"检查 C6 中找到的汇总消息是否明确说明有 2 张逾期发票\"\n- check_logic: \"在 C6 命中的 roundup 消息内容中,检查是否包含数字 2(正则 \\b2\\b)或同时包含 'inv-1031' 和 'inv-1037'(均转小写)\"\n- pass_condition: \"roundup 消息内容中显式出现数字 2,或同时提及 inv-1031 与 inv-1037\"\n\nscore_aggregation: \"各组件分数累加求和,最终通过 round(min(total, 1.0), 4) 钳制到上限 1.0 并四舍五入保留 4 位小数\"\n\nfailure_modes:\n- \"读取 /tmp/task_web_sid 失败或内容为空:打印 CRITICAL 并直接返回 0.0\"\n- \"加载本地 Excel 账本失败:打印 ERROR,对应行状态为空导致 C1-C3 失败\"\n- \"fetch_mock 请求 Gmail 或 Slack 失败:返回 (None, None),对应模块无法计算 delta 而失败\"\n- \"Gmail 中无新的 sent 邮件:C4、C5 失败\"\n- \"Slack #collections 中无新消息:C6、C7 失败\"\n- \"C6 未找到 roundup 消息:C7 因 roundup 为 None 而失败\"\n- \"任一组件检查过程中抛出异常:捕获后打印 ERROR,该组件不得分但不中断后续检查\"\n\ndomain 的提取:docstring 中明确写了 `Domain: libreoffice_calc + mock_websites (HYBRID: local xlsx ledger -> Gmail -> Slack)`。我应该保留主要部分。可以写 `libreoffice_calc + mock_websites`。如果必须选一个,但这里明确是混合。我就按原文提取。\n\ndata_sources:\n- \"/tmp/task_web_sid\"\n- \"/home/user/ar_collections_001.xlsx\"\n- \"Gmail mock 服务 (http://28.7.186.212:8158)\"\n- \"Slack mock 服务 (http://28.7.186.212:8198)\"\n\n现在组织 JSON。确保没有多余文字,纯 JSON。\n\n检查 JSON 格式:所��字符串用双引号,中文内容,无 trailing comma。\n\n让我再仔细检查一下代码中的细节:\n\n- `_norm_amount` 用于金额标准化,移除 `$`, `,`, 空格。\n- `fetch_mock` 使用 `/go?sid={sid}` 端点。\n- Gmail delta: `e.get('folder') == 'sent'` 且 id 不在 `ini_ids`。\n- Slack delta: 比较 `messages.collections` 列表中的 `messageId`。\n- C7 依赖 C6 找到的 `roundup` 变量。如果 C6 失败,C7 也会失败。\n\n这些细节都要在 explanation 中体现。\n\n最终确认 JSON 结构正确。 </think> {\"task_id\":\"ar_collections_001\",\"domain\":\"libreoffice_calc + mock_websites\",\"summary\":\"验证用户是否将本地账本中指定发票状态改为Overdue,并通过Gmail发送两封催款邮件,同时在Slack #collections频道发布包含逾期总额和数量的汇总消息\",\"is_placeholder\":false,\"data_sources\":[\"/tmp/task_web_sid\",\"/home/user/ar_collections_001.xlsx\",\"Gmail mock服务 (http://28.7.186.212:8158)\",\"Slack mock服务 (http://28.7.186.212:8198)\"],\"scoring_components\":[{\"name\":\"C1\",\"weight\":0.15,\"description\":\"检查本地Excel账本中INV-1031的状态是否被标记为Overdue\",\"check_logic\":\"使用openpyxl加载LEDGER_PATH指定的工作表'SAR Invoice Ledger',遍历所有行构建字典rows(invoice# -> status),检查rows.get('INV-1031', '').lower() == 'overdue'\",\"pass_condition\":\"INV-1031对应的状态字符串去除首尾空格并转小写后等于'overdue'\"},{\"name\":\"C2\",\"weight\":0.15,\"description\":\"检查本地Excel账本中INV-1037的状态是否被标记为Overdue\",\"check_logic\":\"检查rows.get('INV-1037', '').lower() == 'overdue'\",\"pass_condition\":\"INV-1037对应的状态字符串去除首尾空格并转小写后等于'overdue'\"},{\"name\":\"C3\",\"weight\":0.10,\"description\":\"检查账本中是否仅有INV-1031和INV-1037两行被标记为Overdue,没有其他行被意外修改\",\"check_logic\":\"遍历rows中所有状态转小写等于'overdue'的发票号构成集合overdue,检查overdue == {'INV-1031', 'INV-1037'}\",\"pass_condition\":\"逾期发票集合恰好等于{'INV-1031', 'INV-1037'},不多不少\"},{\"name\":\"C4\",\"weight\":0.15,\"description\":\"检查是否通过Gmail向ap@vandelay.com发送了关于INV-1031和$15,000的新催款邮件\",\"check_logic\":\"调用fetch_mock获取Gmail的initial_state与current_state,筛选folder为'sent'且id不在初始邮件集合中的new_sent邮件;在new_sent中查找收件人包含'ap@vandelay.com',且subject与body拼接后的文本同时包含'INV-1031'和经_norm_amount处理后的金额'15000'的邮件\",\"pass_condition\":\"存在至少一封新的sent邮件,收件人包含ap@vandelay.com,且主题或正文同时引用INV-1031和金额15000\"},{\"name\":\"C5\",\"weight\":0.15,\"description\":\"检查是否通过Gmail向billing@wernham-hogg.com发送了关于INV-1037和$22,400的新催款邮件\",\"check_logic\":\"与C4类似,在new_sent中查找收件人包含'billing@wernham-hogg.com',且主题或正文同时包含'INV-1037'和经_norm_amount处理后的金额'22400'的邮件\",\"pass_condition\":\"存在至少一封新的sent邮件,收件人包含billing@wernham-hogg.com,且主题或正文同时引用INV-1037和金额22400\"},{\"name\":\"C6\",\"weight\":0.15,\"description\":\"检查Slack #collections频道是否有新消息提到overdue和总逾期金额37400\",\"check_logic\":\"调用fetch_mock获取Slack的initial_state与current_state,提取#collections频道中messageId不在初始消息集合中的new_msgs;遍历new_msgs,检查消息内容转小写后包含'overdue'且经_norm_amount处理后包含'37400'\",\"pass_condition\":\"存在至少一条新的#collections消息,其内容同时包含'overdue'和金额37400\"},{\"name\":\"C7\",\"weight\":0.15,\"description\":\"检查C6中找到的汇总消息是否明确说明有2张逾期发票\",\"check_logic\":\"在C6命中的roundup消息内容中,使用正则\\\\b2\\\\b查找显式数字2,或检查内容转小写后同时包含'inv-1031'和'inv-1037'\",\"pass_condition\":\"roundup消息内容中显式出现数字2,或同时提及inv-1031与inv-1037\"}],\"total_max_score\":1.0,\"score_aggregation\":\"各组件分数累加求和,最终通过round(min(total, 1.0), 4)将总分钳制在1.0以内并四舍五入保留4位小数\",\"failure_modes\":[\"读取/tmp/task_web_sid失败或内容为空:打印CRITICAL并直接返回0.0\",\"加载本地Excel账本失败:打印ERROR,对应行状态为空导致C1-C3失败\",\"fetch_mock请求Gmail或Slack失败:返回(None, None),对应模块无法计算delta而失败\",\"Gmail中无新的sent邮件:C4、C5失败\",\"Slack #collections中无新消息:C6、C7失败\",\"C6未找到roundup消息:C7因roundup为None而失败\",\"任一组件检查过程中抛出异常:捕获后打印ERROR,该组件不得分但不中断后续检查\"],\"scoring_logic_explanation\":\"脚本首先读取/tmp/task_web_sid获取会话ID,失败则直接返回0.0。接着加载本地Excel账本/home/user/ar_collections_001.xlsx,提取所有发票号与状态,依次检查C1(INV-1031为Overdue)、C2(INV-1037为Overdue)和C3(仅有这两行是Overdue)。随后通过sid请求mock Gmail服务,对比初始状态与当前状态,筛选出新的sent邮件,检查C4(发给ap@vandelay.com并引用INV-1031和15000)和C5(发给billing@wernham-hogg.com并引用INV-1037和22400)。再请求mock Slack服务,对比#collections频道消息,筛选出新消息,检查C6(内容包含overdue和37400)和C7(该消息中明确说明数量为2,或同时提及两张发票号)。所有通过的组件分值累加到total,最后以min(total, 1.0)钳制上限并四舍五入到4位小数输出。\",\"confidence\":1.0}"
|
| 84 |
+
}
|
legacy/beacea76-e300-578d-8dc9-5bf0f1a16d13/_cua_gym_vm_bridge.sh
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# CUA-Gym VM-side network fix (direct-IP mock access).
|
| 3 |
+
#
|
| 4 |
+
# Runs INSIDE the QEMU guest. The CUA-Gym mock services are now reached by
|
| 5 |
+
# their real IDC address (http://9.91.4.13:81xx) instead of the old
|
| 6 |
+
# localhost:9000-9097 socat bridge, so the VM only needs two fixes:
|
| 7 |
+
#
|
| 8 |
+
# 1. Working DNS — the qcow2-baked /etc/resolv.conf points at the Pod's
|
| 9 |
+
# cluster DNS, which is unreachable from QEMU SLIRP NAT
|
| 10 |
+
# ("Temporary failure in name resolution").
|
| 11 |
+
# 2. The mock host excluded from the woa http proxy — otherwise the VM's
|
| 12 |
+
# Chrome (gsettings proxy) and initial_setup.py's `requests` get a 403
|
| 13 |
+
# from the proxy when hitting 9.91.4.13:81xx. (The old socat path never
|
| 14 |
+
# hit this because localhost is bypassed by default.)
|
| 15 |
+
#
|
| 16 |
+
# Idempotent. Scoped to the CUA-Gym bridge step; does not touch the generic
|
| 17 |
+
# OSWorld setup pipeline.
|
| 18 |
+
#
|
| 19 |
+
# Argv:
|
| 20 |
+
# $1 optional sudo password (default "password"; SetupController
|
| 21 |
+
# substitutes {CLIENT_PASSWORD} when uploaded as a cache file).
|
| 22 |
+
# $2 unused (kept for backward compat — was socat first port 9000).
|
| 23 |
+
# $3 unused (kept for backward compat — was socat last port 9097).
|
| 24 |
+
# $4 optional mock host IP (default 9.91.4.13).
|
| 25 |
+
|
| 26 |
+
set +e
|
| 27 |
+
|
| 28 |
+
PASS="${1:-password}"
|
| 29 |
+
MOCK_HOST="${4:-28.7.186.212}"
|
| 30 |
+
# Derive the /16 IDC subnet so future port/host tweaks on the same segment
|
| 31 |
+
# stay bypassed too (9.91.4.13 -> 9.91.0.0/16).
|
| 32 |
+
MOCK_NET="$(echo "${MOCK_HOST}" | awk -F. 'NF==4{print $1"."$2".0.0/16"}')"
|
| 33 |
+
|
| 34 |
+
run_root() {
|
| 35 |
+
echo "$PASS" | sudo -S -p "" bash -c "$1"
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
# Detect SLIRP gateway from VM's routing table; fall back to 10.0.2.2.
|
| 39 |
+
GW="$(ip route 2>/dev/null | awk '/default/ {print $3; exit}')"
|
| 40 |
+
GW="${GW:-10.0.2.2}"
|
| 41 |
+
|
| 42 |
+
# ─── CUA-Gym network fix (Taiji-specific) ─────────────────────────────
|
| 43 |
+
fix_vm_network() {
|
| 44 |
+
# 0) Discover VM network state at runtime — gateway, own IP/CIDR, SLIRP
|
| 45 |
+
# DNS forwarder. Nothing hardcoded except the mock host above.
|
| 46 |
+
local GW_NET="${GW%.*}"
|
| 47 |
+
local SLIRP_DNS="${GW_NET}.3" # QEMU SLIRP DNS proxy is always .3
|
| 48 |
+
local OWN_CIDR
|
| 49 |
+
OWN_CIDR="$(ip -4 -o addr show scope global 2>/dev/null \
|
| 50 |
+
| awk '{print $4; exit}')"
|
| 51 |
+
local OWN_IP="${OWN_CIDR%/*}"
|
| 52 |
+
local OWN_NET=""
|
| 53 |
+
[ -n "${OWN_IP}" ] && OWN_NET="${OWN_IP%.*}.0/24"
|
| 54 |
+
|
| 55 |
+
# 1) DNS — point at SLIRP DNS proxy + public fallbacks. chattr +i keeps
|
| 56 |
+
# systemd-resolved/NetworkManager from clobbering it.
|
| 57 |
+
if run_root "printf 'nameserver ${SLIRP_DNS}\\nnameserver 114.114.114.114\\nnameserver 8.8.8.8\\n' > /etc/resolv.conf
|
| 58 |
+
chattr +i /etc/resolv.conf 2>/dev/null || true"; then
|
| 59 |
+
echo "[cua_gym_vm_bridge] DNS set: ${SLIRP_DNS}, 114.114.114.114, 8.8.8.8 (gw=${GW})"
|
| 60 |
+
else
|
| 61 |
+
echo "[cua_gym_vm_bridge] WARN: failed to write /etc/resolv.conf"
|
| 62 |
+
fi
|
| 63 |
+
|
| 64 |
+
# 2) Build the proxy bypass list from detected values + the direct-IP
|
| 65 |
+
# mock host (and its /16 subnet). THIS is what makes 9.91.4.13:81xx
|
| 66 |
+
# reachable from inside the VM — without it the woa proxy 403s it.
|
| 67 |
+
local ignore_list="['localhost', '127.0.0.0/8', '${GW}'"
|
| 68 |
+
[ -n "${OWN_IP}" ] && ignore_list="${ignore_list}, '${OWN_IP}'"
|
| 69 |
+
[ -n "${OWN_NET}" ] && ignore_list="${ignore_list}, '${OWN_NET}'"
|
| 70 |
+
[ -n "${GW_NET}" ] && ignore_list="${ignore_list}, '${GW_NET}.0/24'"
|
| 71 |
+
[ -n "${MOCK_HOST}" ] && ignore_list="${ignore_list}, '${MOCK_HOST}'"
|
| 72 |
+
[ -n "${MOCK_NET}" ] && ignore_list="${ignore_list}, '${MOCK_NET}'"
|
| 73 |
+
ignore_list="${ignore_list}]"
|
| 74 |
+
|
| 75 |
+
# 3) GNOME proxy ignore-hosts — Chrome bypasses the woa proxy for these.
|
| 76 |
+
if gsettings set org.gnome.system.proxy ignore-hosts "${ignore_list}" 2>/tmp/gsettings_err; then
|
| 77 |
+
echo "[cua_gym_vm_bridge] gsettings ignore-hosts = ${ignore_list}"
|
| 78 |
+
else
|
| 79 |
+
echo "[cua_gym_vm_bridge] WARN: gsettings ignore-hosts failed: $(cat /tmp/gsettings_err 2>/dev/null)"
|
| 80 |
+
fi
|
| 81 |
+
|
| 82 |
+
# 4) Shell env — comma-separated form for no_proxy/NO_PROXY (requests/curl).
|
| 83 |
+
local NP="localhost,127.0.0.1,${GW}"
|
| 84 |
+
[ -n "${OWN_IP}" ] && NP="${NP},${OWN_IP}"
|
| 85 |
+
[ -n "${OWN_NET}" ] && NP="${NP},${OWN_NET}"
|
| 86 |
+
[ -n "${GW_NET}" ] && NP="${NP},${GW_NET}.0/24"
|
| 87 |
+
[ -n "${MOCK_HOST}" ] && NP="${NP},${MOCK_HOST}"
|
| 88 |
+
[ -n "${MOCK_NET}" ] && NP="${NP},${MOCK_NET}"
|
| 89 |
+
|
| 90 |
+
for var in no_proxy NO_PROXY; do
|
| 91 |
+
if ! grep -q "export ${var}=${NP}" /home/user/.bashrc 2>/dev/null; then
|
| 92 |
+
echo "export ${var}=${NP}" >> /home/user/.bashrc
|
| 93 |
+
fi
|
| 94 |
+
done
|
| 95 |
+
run_root "grep -q '^no_proxy=' /etc/environment 2>/dev/null \
|
| 96 |
+
&& sed -i 's|^no_proxy=.*|no_proxy=\"${NP}\"|' /etc/environment \
|
| 97 |
+
|| echo 'no_proxy=\"${NP}\"' >> /etc/environment
|
| 98 |
+
grep -q '^NO_PROXY=' /etc/environment 2>/dev/null \
|
| 99 |
+
&& sed -i 's|^NO_PROXY=.*|NO_PROXY=\"${NP}\"|' /etc/environment \
|
| 100 |
+
|| echo 'NO_PROXY=\"${NP}\"' >> /etc/environment" >/dev/null 2>&1
|
| 101 |
+
echo "[cua_gym_vm_bridge] no_proxy=${NP}"
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
fix_vm_network
|
| 105 |
+
|
| 106 |
+
echo "[cua_gym_vm_bridge] direct-IP mode: ${MOCK_HOST} (+${MOCK_NET}) bypassed from woa proxy; no socat forwarding needed"
|
legacy/beacea76-e300-578d-8dc9-5bf0f1a16d13/initial_setup.py
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Initial Setup: pmo_status_report_b104
|
| 3 |
+
Task ID: beacea76-e300-578d-8dc9-5bf0f1a16d13
|
| 4 |
+
Domain: mock_websites
|
| 5 |
+
Mocks: google_docs_mock, monday_mock, slack_mock, microsoft_teams_mock (single shared sid)
|
| 6 |
+
|
| 7 |
+
Persona: You are an office worker acting as a project lead. Your tools for this task are: shared documents, the monday.com board, team communications, Microsoft Teams.
|
| 8 |
+
|
| 9 |
+
Environment / context (initial state + ground truth this setup establishes):
|
| 10 |
+
Initial environment (seeded via a single shared session id across all mocks): Google Docs with documents 'Weekly Status - June W3'; monday.com 'Product Roadmap' board with 3 items; Slack workspace with channels #general, #random; Microsoft Teams with Engineering/Design teams, channels, and 1:1 chats. GROUND TRUTH — the agent earns partial credit for each checkpoint: new weekly status doc (+0.2); report has Progress/Risks/Decisions (+0.25); Risks names the stuck item (User Research) (+0.2); slack_new_msg (+0.1); Teams post points to the report (+0.25). Scoring is absolute over each mock's current_state; new objects exclude the seeded IDs, so an untouched environment scores 0.0 and fully completing every checkpoint scores 1.0.
|
| 11 |
+
"""
|
| 12 |
+
import json
|
| 13 |
+
import os
|
| 14 |
+
import shlex
|
| 15 |
+
import subprocess
|
| 16 |
+
import time
|
| 17 |
+
import uuid
|
| 18 |
+
|
| 19 |
+
import requests
|
| 20 |
+
|
| 21 |
+
MOCK_URLS = {
|
| 22 |
+
"google_docs_mock": "http://28.7.186.212:8162",
|
| 23 |
+
"monday_mock": "http://28.7.186.212:8185",
|
| 24 |
+
"slack_mock": "http://28.7.186.212:8198",
|
| 25 |
+
"microsoft_teams_mock": "http://28.7.186.212:8182"
|
| 26 |
+
}
|
| 27 |
+
PRIMARY_URL = 'http://28.7.186.212:8162'
|
| 28 |
+
|
| 29 |
+
sid = str(uuid.uuid4())
|
| 30 |
+
with open('/tmp/task_web_sid', 'w') as f:
|
| 31 |
+
f.write(sid)
|
| 32 |
+
print(f'Generated sid: {sid}')
|
| 33 |
+
|
| 34 |
+
# Full initial state for every mock involved (all required top-level keys present).
|
| 35 |
+
STATES = { 'google_docs_mock': { 'currentUser': { 'id': 'user-1',
|
| 36 |
+
'name': 'Demo User',
|
| 37 |
+
'email': 'demo@example.com',
|
| 38 |
+
'avatar': ''},
|
| 39 |
+
'users': [ { 'id': 'user-1',
|
| 40 |
+
'name': 'Demo User',
|
| 41 |
+
'email': 'demo@example.com',
|
| 42 |
+
'avatar': ''},
|
| 43 |
+
{ 'id': 'user-2',
|
| 44 |
+
'name': 'Alice Chen',
|
| 45 |
+
'email': 'alice@example.com',
|
| 46 |
+
'avatar': ''},
|
| 47 |
+
{ 'id': 'user-3',
|
| 48 |
+
'name': 'Bob Smith',
|
| 49 |
+
'email': 'bob@example.com',
|
| 50 |
+
'avatar': ''}],
|
| 51 |
+
'documents': { 'd-old': { 'id': 'd-old',
|
| 52 |
+
'title': 'Weekly Status - June W3',
|
| 53 |
+
'content': '<p>last week</p>',
|
| 54 |
+
'ownerId': 'user-1',
|
| 55 |
+
'starred': False,
|
| 56 |
+
'created': '2026-05-01T10:00:00Z',
|
| 57 |
+
'updated': '2026-06-01T10:00:00Z',
|
| 58 |
+
'sharedWith': [],
|
| 59 |
+
'linkSharing': { 'enabled': False,
|
| 60 |
+
'permission': 'viewer'}}},
|
| 61 |
+
'comments': [],
|
| 62 |
+
'ui': { 'currentDocId': None,
|
| 63 |
+
'sidebarOpen': False,
|
| 64 |
+
'sidebarTab': 'comments',
|
| 65 |
+
'shareDialogOpen': False,
|
| 66 |
+
'findReplaceOpen': False,
|
| 67 |
+
'viewMode': 'editing',
|
| 68 |
+
'zoom': 100,
|
| 69 |
+
'documentListView': 'grid',
|
| 70 |
+
'searchQuery': ''}},
|
| 71 |
+
'monday_mock': { 'workspaces': [{'id': 'ws1', 'name': 'Main Workspace'}],
|
| 72 |
+
'boards': [ { 'id': 'b1',
|
| 73 |
+
'workspaceId': 'ws1',
|
| 74 |
+
'name': 'Product Roadmap',
|
| 75 |
+
'description': 'Q1 2024 Goals and Tasks',
|
| 76 |
+
'columns': [ { 'id': 'c1',
|
| 77 |
+
'title': 'Owner',
|
| 78 |
+
'type': 'person',
|
| 79 |
+
'width': 100},
|
| 80 |
+
{ 'id': 'c2',
|
| 81 |
+
'title': 'Status',
|
| 82 |
+
'type': 'status',
|
| 83 |
+
'width': 140,
|
| 84 |
+
'settings': { 'labels': [ { 'id': 's1',
|
| 85 |
+
'label': 'Done',
|
| 86 |
+
'color': '#00c875'},
|
| 87 |
+
{ 'id': 's2',
|
| 88 |
+
'label': 'Working '
|
| 89 |
+
'on '
|
| 90 |
+
'it',
|
| 91 |
+
'color': '#fdab3d'},
|
| 92 |
+
{ 'id': 's3',
|
| 93 |
+
'label': 'Stuck',
|
| 94 |
+
'color': '#e2445c'},
|
| 95 |
+
{ 'id': 's4',
|
| 96 |
+
'label': 'Not '
|
| 97 |
+
'Started',
|
| 98 |
+
'color': '#c4c4c4'}]}},
|
| 99 |
+
{ 'id': 'c3',
|
| 100 |
+
'title': 'Due Date',
|
| 101 |
+
'type': 'date',
|
| 102 |
+
'width': 120},
|
| 103 |
+
{ 'id': 'c4',
|
| 104 |
+
'title': 'Priority',
|
| 105 |
+
'type': 'status',
|
| 106 |
+
'width': 140,
|
| 107 |
+
'settings': { 'labels': [ { 'id': 'p1',
|
| 108 |
+
'label': 'High',
|
| 109 |
+
'color': '#401694'},
|
| 110 |
+
{ 'id': 'p2',
|
| 111 |
+
'label': 'Medium',
|
| 112 |
+
'color': '#579bfc'},
|
| 113 |
+
{ 'id': 'p3',
|
| 114 |
+
'label': 'Low',
|
| 115 |
+
'color': '#79d5ea'}]}},
|
| 116 |
+
{ 'id': 'c5',
|
| 117 |
+
'title': 'Timeline',
|
| 118 |
+
'type': 'timeline',
|
| 119 |
+
'width': 180},
|
| 120 |
+
{ 'id': 'c6',
|
| 121 |
+
'title': 'Budget',
|
| 122 |
+
'type': 'numbers',
|
| 123 |
+
'width': 100,
|
| 124 |
+
'settings': {'prefix': '$'}}],
|
| 125 |
+
'groups': [ { 'id': 'g1',
|
| 126 |
+
'title': 'Q1 Goals',
|
| 127 |
+
'color': '#579bfc'},
|
| 128 |
+
{ 'id': 'g2',
|
| 129 |
+
'title': 'Backlog',
|
| 130 |
+
'color': '#a25ddc'}],
|
| 131 |
+
'items': [ { 'id': 'i1',
|
| 132 |
+
'groupId': 'g1',
|
| 133 |
+
'name': 'Launch New Website',
|
| 134 |
+
'columnValues': { 'c1': ['u1', 'u2'],
|
| 135 |
+
'c2': 's2',
|
| 136 |
+
'c3': '2024-03-15',
|
| 137 |
+
'c4': 'p1',
|
| 138 |
+
'c5': { 'start': '2024-03-01',
|
| 139 |
+
'end': '2024-03-15'},
|
| 140 |
+
'c6': 5000}},
|
| 141 |
+
{ 'id': 'i2',
|
| 142 |
+
'groupId': 'g1',
|
| 143 |
+
'name': 'Mobile App Design',
|
| 144 |
+
'columnValues': { 'c1': ['u3'],
|
| 145 |
+
'c2': 's1',
|
| 146 |
+
'c3': '2024-02-28',
|
| 147 |
+
'c4': 'p2',
|
| 148 |
+
'c5': { 'start': '2024-02-01',
|
| 149 |
+
'end': '2024-02-28'},
|
| 150 |
+
'c6': 12000}},
|
| 151 |
+
{ 'id': 'i3',
|
| 152 |
+
'groupId': 'g2',
|
| 153 |
+
'name': 'User Research',
|
| 154 |
+
'columnValues': { 'c1': ['u4'],
|
| 155 |
+
'c2': 's3',
|
| 156 |
+
'c3': '2024-04-10',
|
| 157 |
+
'c4': 'p3',
|
| 158 |
+
'c5': { 'start': '2024-04-01',
|
| 159 |
+
'end': '2024-04-10'},
|
| 160 |
+
'c6': 2000}}],
|
| 161 |
+
'updates': [],
|
| 162 |
+
'activities': []}],
|
| 163 |
+
'currentUser': { 'id': 'u1',
|
| 164 |
+
'name': 'Admin User',
|
| 165 |
+
'avatar': 'https://picsum.photos/100/100?random=u1'}},
|
| 166 |
+
'slack_mock': { 'currentUser': { 'userId': 'user_1',
|
| 167 |
+
'fullName': 'John Smith',
|
| 168 |
+
'displayName': 'John',
|
| 169 |
+
'email': 'john.smith@company.com',
|
| 170 |
+
'avatar': 'https://picsum.photos/200/200?random=1',
|
| 171 |
+
'title': '',
|
| 172 |
+
'status': 'online',
|
| 173 |
+
'statusMessage': '',
|
| 174 |
+
'statusEmoji': '',
|
| 175 |
+
'timeZone': 'America/New_York'},
|
| 176 |
+
'workspace': { 'workspaceId': 'ws_1',
|
| 177 |
+
'workspaceName': 'Acme Corp',
|
| 178 |
+
'icon': ''},
|
| 179 |
+
'users': [ { 'userId': 'user_1',
|
| 180 |
+
'fullName': 'John Smith',
|
| 181 |
+
'displayName': 'John',
|
| 182 |
+
'email': 'john.smith@company.com',
|
| 183 |
+
'avatar': 'https://picsum.photos/200/200?random=1',
|
| 184 |
+
'title': '',
|
| 185 |
+
'status': 'online',
|
| 186 |
+
'statusMessage': '',
|
| 187 |
+
'statusEmoji': '',
|
| 188 |
+
'timeZone': 'America/New_York'},
|
| 189 |
+
{ 'userId': 'user_2',
|
| 190 |
+
'fullName': 'Sarah Johnson',
|
| 191 |
+
'displayName': 'Sarah',
|
| 192 |
+
'email': 'sarah.johnson@company.com',
|
| 193 |
+
'avatar': 'https://picsum.photos/200/200?random=2',
|
| 194 |
+
'title': '',
|
| 195 |
+
'status': 'online',
|
| 196 |
+
'statusMessage': '',
|
| 197 |
+
'statusEmoji': '',
|
| 198 |
+
'timeZone': 'America/New_York'},
|
| 199 |
+
{ 'userId': 'user_3',
|
| 200 |
+
'fullName': 'Mike Chen',
|
| 201 |
+
'displayName': 'Mike',
|
| 202 |
+
'email': 'mike.chen@company.com',
|
| 203 |
+
'avatar': 'https://picsum.photos/200/200?random=3',
|
| 204 |
+
'title': '',
|
| 205 |
+
'status': 'online',
|
| 206 |
+
'statusMessage': '',
|
| 207 |
+
'statusEmoji': '',
|
| 208 |
+
'timeZone': 'America/New_York'},
|
| 209 |
+
{ 'userId': 'user_4',
|
| 210 |
+
'fullName': 'Lisa Park',
|
| 211 |
+
'displayName': 'Lisa',
|
| 212 |
+
'email': 'lisa.park@company.com',
|
| 213 |
+
'avatar': 'https://picsum.photos/200/200?random=4',
|
| 214 |
+
'title': '',
|
| 215 |
+
'status': 'online',
|
| 216 |
+
'statusMessage': '',
|
| 217 |
+
'statusEmoji': '',
|
| 218 |
+
'timeZone': 'America/New_York'}],
|
| 219 |
+
'channels': [ { 'channelId': 'general',
|
| 220 |
+
'name': 'general',
|
| 221 |
+
'description': 'general channel',
|
| 222 |
+
'topic': '',
|
| 223 |
+
'isPrivate': False,
|
| 224 |
+
'isStarred': False,
|
| 225 |
+
'members': ['user_1', 'user_2', 'user_3', 'user_4'],
|
| 226 |
+
'createdBy': 'user_1',
|
| 227 |
+
'createdAt': '2026-01-01T10:00:00Z',
|
| 228 |
+
'pinnedMessages': [],
|
| 229 |
+
'unreadCount': 0},
|
| 230 |
+
{ 'channelId': 'random',
|
| 231 |
+
'name': 'random',
|
| 232 |
+
'description': 'random channel',
|
| 233 |
+
'topic': '',
|
| 234 |
+
'isPrivate': False,
|
| 235 |
+
'isStarred': False,
|
| 236 |
+
'members': ['user_1', 'user_2', 'user_3', 'user_4'],
|
| 237 |
+
'createdBy': 'user_1',
|
| 238 |
+
'createdAt': '2026-01-01T10:00:00Z',
|
| 239 |
+
'pinnedMessages': [],
|
| 240 |
+
'unreadCount': 0}],
|
| 241 |
+
'messages': { 'general': [ { 'messageId': 'g1',
|
| 242 |
+
'senderId': 'user_2',
|
| 243 |
+
'content': 'is the weekly status out?',
|
| 244 |
+
'timestamp': '2026-06-08T08:00:00Z',
|
| 245 |
+
'threadId': None,
|
| 246 |
+
'reactions': [],
|
| 247 |
+
'attachments': [],
|
| 248 |
+
'isEdited': False}],
|
| 249 |
+
'random': []},
|
| 250 |
+
'threads': {},
|
| 251 |
+
'dms': [],
|
| 252 |
+
'bookmarkedMessages': [],
|
| 253 |
+
'callHistory': [],
|
| 254 |
+
'settings': { 'theme': 'light',
|
| 255 |
+
'notifications': 'all',
|
| 256 |
+
'displayDensity': 'comfortable',
|
| 257 |
+
'showAvatars': True,
|
| 258 |
+
'use24Hour': False},
|
| 259 |
+
'invitations': [],
|
| 260 |
+
'notifications': []},
|
| 261 |
+
'microsoft_teams_mock': { 'currentUser': { 'id': 'user-me',
|
| 262 |
+
'name': 'Admin User',
|
| 263 |
+
'email': 'admin@example.com',
|
| 264 |
+
'avatar': 'https://placehold.co/64x64/7c3aed/ffffff/png?text=M',
|
| 265 |
+
'status': 'available',
|
| 266 |
+
'statusMessage': ''},
|
| 267 |
+
'users': [ { 'id': 'user-me',
|
| 268 |
+
'name': 'Admin User',
|
| 269 |
+
'email': 'admin@example.com',
|
| 270 |
+
'avatar': 'https://placehold.co/64x64/7c3aed/ffffff/png?text=M',
|
| 271 |
+
'status': 'available',
|
| 272 |
+
'statusMessage': ''},
|
| 273 |
+
{ 'id': 'u1',
|
| 274 |
+
'name': 'Alice Smith',
|
| 275 |
+
'status': 'busy',
|
| 276 |
+
'avatar': 'https://placehold.co/64x64/d97706/ffffff/png?text=U'},
|
| 277 |
+
{ 'id': 'u2',
|
| 278 |
+
'name': 'Bob Jones',
|
| 279 |
+
'status': 'away',
|
| 280 |
+
'avatar': 'https://placehold.co/64x64/dc2626/ffffff/png?text=U'},
|
| 281 |
+
{ 'id': 'u3',
|
| 282 |
+
'name': 'Charlie Day',
|
| 283 |
+
'status': 'offline',
|
| 284 |
+
'avatar': 'https://placehold.co/64x64/db2777/ffffff/png?text=U'},
|
| 285 |
+
{ 'id': 'u4',
|
| 286 |
+
'name': 'Diana Prince',
|
| 287 |
+
'status': 'available',
|
| 288 |
+
'avatar': 'https://placehold.co/64x64/4338ca/ffffff/png?text=U'}],
|
| 289 |
+
'teams': [ { 'id': 't1',
|
| 290 |
+
'name': 'Engineering',
|
| 291 |
+
'description': 'Engineering team collaboration',
|
| 292 |
+
'channels': [ { 'id': 'c1',
|
| 293 |
+
'name': 'General',
|
| 294 |
+
'posts': [ { 'id': 'p1',
|
| 295 |
+
'userId': 'u1',
|
| 296 |
+
'subject': 'Welcome '
|
| 297 |
+
'to '
|
| 298 |
+
'the '
|
| 299 |
+
'team',
|
| 300 |
+
'content': 'Hi '
|
| 301 |
+
'everyone! '
|
| 302 |
+
'Excited '
|
| 303 |
+
'to '
|
| 304 |
+
'be '
|
| 305 |
+
'here.',
|
| 306 |
+
'timestamp': '2026-06-07T09:54:18.071Z',
|
| 307 |
+
'replies': [ { 'id': 'r1',
|
| 308 |
+
'userId': 'user-me',
|
| 309 |
+
'content': 'Welcome '
|
| 310 |
+
'Alice!',
|
| 311 |
+
'timestamp': '2026-06-07T11:40:58.071Z'}],
|
| 312 |
+
'reactions': { '👍': 2}}]},
|
| 313 |
+
{ 'id': 'c2',
|
| 314 |
+
'name': 'Frontend',
|
| 315 |
+
'posts': []},
|
| 316 |
+
{ 'id': 'c3',
|
| 317 |
+
'name': 'Deployments',
|
| 318 |
+
'posts': []}]},
|
| 319 |
+
{ 'id': 't2',
|
| 320 |
+
'name': 'Product Design',
|
| 321 |
+
'description': 'Design team sync',
|
| 322 |
+
'channels': [ { 'id': 'c4',
|
| 323 |
+
'name': 'General',
|
| 324 |
+
'posts': []},
|
| 325 |
+
{ 'id': 'c5',
|
| 326 |
+
'name': 'Inspiration',
|
| 327 |
+
'posts': []}]}],
|
| 328 |
+
'chats': [ { 'id': 'chat1',
|
| 329 |
+
'type': 'direct',
|
| 330 |
+
'participants': ['user-me', 'u1'],
|
| 331 |
+
'messages': [ { 'id': 'm1',
|
| 332 |
+
'userId': 'u1',
|
| 333 |
+
'content': 'Hey, do you have '
|
| 334 |
+
'a minute?',
|
| 335 |
+
'timestamp': '2026-06-08T08:54:18.071Z'},
|
| 336 |
+
{ 'id': 'm2',
|
| 337 |
+
'userId': 'user-me',
|
| 338 |
+
'content': 'Sure, what is up?',
|
| 339 |
+
'timestamp': '2026-06-08T08:55:58.071Z'}]},
|
| 340 |
+
{ 'id': 'chat2',
|
| 341 |
+
'type': 'group',
|
| 342 |
+
'name': 'Lunch Crew',
|
| 343 |
+
'participants': ['user-me', 'u2', 'u3'],
|
| 344 |
+
'messages': [ { 'id': 'm3',
|
| 345 |
+
'userId': 'u2',
|
| 346 |
+
'content': 'Tacos today?',
|
| 347 |
+
'timestamp': '2026-06-08T07:54:18.071Z'}]}],
|
| 348 |
+
'activity': [ { 'id': 'a1',
|
| 349 |
+
'type': 'mention',
|
| 350 |
+
'text': 'Alice mentioned you in Engineering > '
|
| 351 |
+
'General',
|
| 352 |
+
'read': False,
|
| 353 |
+
'timestamp': '2026-06-08T09:54:18.071Z',
|
| 354 |
+
'link': '/teams/t1/c1'},
|
| 355 |
+
{ 'id': 'a2',
|
| 356 |
+
'type': 'reaction',
|
| 357 |
+
'text': 'Bob liked your message',
|
| 358 |
+
'read': True,
|
| 359 |
+
'timestamp': '2026-06-08T09:52:38.071Z',
|
| 360 |
+
'link': '/chat/chat1'}],
|
| 361 |
+
'calendar': [ { 'id': 'evt1',
|
| 362 |
+
'title': 'Daily Standup',
|
| 363 |
+
'start': 1780912800000,
|
| 364 |
+
'end': 1780914600000,
|
| 365 |
+
'attendees': ['u1', 'u2', 'u3']}],
|
| 366 |
+
'files': [ { 'id': 'f1',
|
| 367 |
+
'name': 'Q3_Roadmap.pdf',
|
| 368 |
+
'type': 'pdf',
|
| 369 |
+
'size': '2.4 MB',
|
| 370 |
+
'date': '2023-10-24',
|
| 371 |
+
'url': '/files/_default/Q3_Roadmap.pdf'},
|
| 372 |
+
{ 'id': 'f2',
|
| 373 |
+
'name': 'Design_System_v2.fig',
|
| 374 |
+
'type': 'fig',
|
| 375 |
+
'size': '14 MB',
|
| 376 |
+
'date': '2023-10-25',
|
| 377 |
+
'url': '/files/_default/Design_System_v2.fig'},
|
| 378 |
+
{ 'id': 'f3',
|
| 379 |
+
'name': 'Screenshot_Error.png',
|
| 380 |
+
'type': 'png',
|
| 381 |
+
'size': '1.1 MB',
|
| 382 |
+
'date': '2023-10-26',
|
| 383 |
+
'url': '/files/_default/Screenshot_Error.png'}],
|
| 384 |
+
'calls': [],
|
| 385 |
+
'activeCall': None}}
|
| 386 |
+
|
| 387 |
+
|
| 388 |
+
def launch_gui(command, delay_sec=1.0):
|
| 389 |
+
env = os.environ.copy()
|
| 390 |
+
env['DISPLAY'] = ':0'
|
| 391 |
+
subprocess.Popen(shlex.split(command), stdin=subprocess.DEVNULL,
|
| 392 |
+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
| 393 |
+
env=env, start_new_session=True)
|
| 394 |
+
time.sleep(delay_sec)
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
for name, url in MOCK_URLS.items():
|
| 398 |
+
resp = requests.post(f'{url}/post?sid={sid}',
|
| 399 |
+
json={'action': 'set', 'state': STATES[name]}, timeout=30)
|
| 400 |
+
assert resp.status_code == 200, f'{name} injection failed: {resp.text}'
|
| 401 |
+
go = requests.get(f'{url}/go?sid={sid}', timeout=10).json()
|
| 402 |
+
assert go.get('initial_state') is not None, f'{name} initial_state is None'
|
| 403 |
+
print(f'State injected: {name} sid={sid}')
|
| 404 |
+
|
| 405 |
+
# Open the PRIMARY app as the main window first, then open every other
|
| 406 |
+
# involved mock as an additional browser tab so the agent can see/reach all
|
| 407 |
+
# relevant apps (e.g. read the email in the Gmail tab AND post in Slack).
|
| 408 |
+
# Without this, secondary-app data is injected but has no on-screen entry
|
| 409 |
+
# point, and the agent wastes its budget hunting for a non-existent client.
|
| 410 |
+
launch_gui(f'google-chrome "{PRIMARY_URL}/?sid={sid}"', delay_sec=2.0)
|
| 411 |
+
print(f'GUI_READY: launched browser at {PRIMARY_URL}/?sid={sid}')
|
| 412 |
+
for _name, _url in MOCK_URLS.items():
|
| 413 |
+
if _url == PRIMARY_URL:
|
| 414 |
+
continue
|
| 415 |
+
launch_gui(f'google-chrome --new-tab "{_url}/?sid={sid}"', delay_sec=1.0)
|
| 416 |
+
print(f'Opened tab: {_name} at {_url}/?sid={sid}')
|
legacy/beacea76-e300-578d-8dc9-5bf0f1a16d13/reward.py
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Reward Script: pmo_status_report_b104
|
| 3 |
+
Task ID: beacea76-e300-578d-8dc9-5bf0f1a16d13
|
| 4 |
+
Domain: mock_websites
|
| 5 |
+
Mocks: google_docs_mock, monday_mock, slack_mock, microsoft_teams_mock
|
| 6 |
+
Scoring (all programmatic; evaluated against each mock's current_state; total = 1.0):
|
| 7 |
+
- [0.2] new weekly status doc
|
| 8 |
+
- [0.25] report has Progress/Risks/Decisions
|
| 9 |
+
- [0.2] Risks names the stuck item (User Research)
|
| 10 |
+
- [0.1] slack_new_msg
|
| 11 |
+
- [0.25] Teams post points to the report
|
| 12 |
+
"""
|
| 13 |
+
import re
|
| 14 |
+
import sys
|
| 15 |
+
|
| 16 |
+
import requests
|
| 17 |
+
|
| 18 |
+
MOCK_URLS = {
|
| 19 |
+
"google_docs_mock": "http://28.7.186.212:8162",
|
| 20 |
+
"monday_mock": "http://28.7.186.212:8185",
|
| 21 |
+
"slack_mock": "http://28.7.186.212:8198",
|
| 22 |
+
"microsoft_teams_mock": "http://28.7.186.212:8182"
|
| 23 |
+
}
|
| 24 |
+
SEED = {
|
| 25 |
+
"slack_mock:general": [
|
| 26 |
+
"g1"
|
| 27 |
+
],
|
| 28 |
+
"slack_mock:random": []
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
try:
|
| 32 |
+
with open('/tmp/task_web_sid') as f:
|
| 33 |
+
sid = f.read().strip()
|
| 34 |
+
if not sid:
|
| 35 |
+
raise ValueError('sid is empty')
|
| 36 |
+
except Exception as e:
|
| 37 |
+
print(f'CRITICAL: cannot read sid: {e}')
|
| 38 |
+
print('REWARD: 0.0')
|
| 39 |
+
sys.exit(0)
|
| 40 |
+
|
| 41 |
+
STATES = {}
|
| 42 |
+
for _name, _url in MOCK_URLS.items():
|
| 43 |
+
try:
|
| 44 |
+
_r = requests.get(f'{_url}/go?sid={sid}', timeout=15)
|
| 45 |
+
_r.raise_for_status()
|
| 46 |
+
STATES[_name] = _r.json()
|
| 47 |
+
except Exception as e:
|
| 48 |
+
print(f'CRITICAL: cannot fetch {_name}: {e}')
|
| 49 |
+
print('REWARD: 0.0')
|
| 50 |
+
sys.exit(0)
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def cur(mock):
|
| 54 |
+
return (STATES.get(mock) or {}).get('current_state') or {}
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def _lc(s):
|
| 58 |
+
return (s or '').lower()
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
total = 0.0
|
| 62 |
+
|
| 63 |
+
# c0: a new google doc titled about (new weekly status doc)
|
| 64 |
+
c0_init = set((STATES['google_docs_mock'].get('initial_state') or {}).get('documents', {}).keys())
|
| 65 |
+
c0_docs = cur('google_docs_mock').get('documents') or {}
|
| 66 |
+
c0_new = [d for did, d in c0_docs.items() if did not in c0_init and any(t in _lc(d.get('title','')) for t in ['weekly status - june w4', 'weekly status'])]
|
| 67 |
+
if c0_new:
|
| 68 |
+
print('PASS: new weekly status doc (0.2)')
|
| 69 |
+
total += 0.2
|
| 70 |
+
else:
|
| 71 |
+
print('FAIL: new weekly status doc')
|
| 72 |
+
|
| 73 |
+
# c1: new google doc body (report has Progress/Risks/Decisions)
|
| 74 |
+
c1_init = set((STATES['google_docs_mock'].get('initial_state') or {}).get('documents', {}).keys())
|
| 75 |
+
c1_docs = cur('google_docs_mock').get('documents') or {}
|
| 76 |
+
c1_new = [d for did, d in c1_docs.items() if did not in c1_init and any(t in _lc(d.get('title','')) for t in ['weekly status'])]
|
| 77 |
+
c1_txt = _lc(' '.join(d.get('content','') for d in c1_new))
|
| 78 |
+
if c1_new and all(t in c1_txt for t in ['progress', 'risks', 'decisions']):
|
| 79 |
+
print('PASS: report has Progress/Risks/Decisions (0.25)')
|
| 80 |
+
total += 0.25
|
| 81 |
+
else:
|
| 82 |
+
print('FAIL: report has Progress/Risks/Decisions')
|
| 83 |
+
|
| 84 |
+
# c2: new google doc body (Risks names the stuck item (User Research))
|
| 85 |
+
c2_init = set((STATES['google_docs_mock'].get('initial_state') or {}).get('documents', {}).keys())
|
| 86 |
+
c2_docs = cur('google_docs_mock').get('documents') or {}
|
| 87 |
+
c2_new = [d for did, d in c2_docs.items() if did not in c2_init and any(t in _lc(d.get('title','')) for t in ['weekly status'])]
|
| 88 |
+
c2_txt = _lc(' '.join(d.get('content','') for d in c2_new))
|
| 89 |
+
if c2_new and any(t in c2_txt for t in ['user research']):
|
| 90 |
+
print('PASS: Risks names the stuck item (User Research) (0.2)')
|
| 91 |
+
total += 0.2
|
| 92 |
+
else:
|
| 93 |
+
print('FAIL: Risks names the stuck item (User Research)')
|
| 94 |
+
|
| 95 |
+
# c3: new message by user_1 in #general
|
| 96 |
+
c3_msgs = (cur('slack_mock').get('messages') or {}).get('general', []) or []
|
| 97 |
+
c3_seed = set(SEED.get('slack_mock:general', []))
|
| 98 |
+
c3_new = [m for m in c3_msgs if m.get('messageId') not in c3_seed and m.get('senderId') == 'user_1']
|
| 99 |
+
c3_blob = _lc(' '.join((m.get('content') or '') for m in c3_new))
|
| 100 |
+
if c3_new:
|
| 101 |
+
print('PASS: new message by user_1 in #general (0.1)')
|
| 102 |
+
total += 0.1
|
| 103 |
+
else:
|
| 104 |
+
print('FAIL: no new user_1 message in #general')
|
| 105 |
+
|
| 106 |
+
# c4: new Teams post in channel 'c1' (Teams post points to the report)
|
| 107 |
+
c4_team = next((t for t in (cur('microsoft_teams_mock').get('teams') or []) if t.get('id') == 't1'), None)
|
| 108 |
+
c4_chan = next((ch for ch in ((c4_team or {}).get('channels') or []) if ch.get('id') == 'c1'), None)
|
| 109 |
+
c4_init_team = next((t for t in ((STATES['microsoft_teams_mock'].get('initial_state') or {}).get('teams') or []) if t.get('id') == 't1'), None)
|
| 110 |
+
c4_init_chan = next((ch for ch in ((c4_init_team or {}).get('channels') or []) if ch.get('id') == 'c1'), None)
|
| 111 |
+
c4_seed = {p.get('id') for p in ((c4_init_chan or {}).get('posts') or [])}
|
| 112 |
+
c4_new = [p for p in ((c4_chan or {}).get('posts') or []) if p.get('id') not in c4_seed and p.get('userId') == 'user-me']
|
| 113 |
+
c4_txt = _lc(' '.join((p.get('subject','') + ' ' + p.get('content','')) for p in c4_new))
|
| 114 |
+
if c4_new and any(t in c4_txt for t in ['status', 'weekly', 'report']):
|
| 115 |
+
print('PASS: Teams post points to the report (0.25)')
|
| 116 |
+
total += 0.25
|
| 117 |
+
else:
|
| 118 |
+
print('FAIL: Teams post points to the report')
|
| 119 |
+
|
| 120 |
+
final = round(min(total, 1.0), 4)
|
| 121 |
+
print(f'\nScore: {total}/1.0')
|
| 122 |
+
print(f'REWARD: {final}')
|
legacy/beacea76-e300-578d-8dc9-5bf0f1a16d13/reward_label.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"reward_file": "/apdcephfs_sh2/share_300000800/user/jackwkwang/long-horizon-tasks/mini_osworld_xiangwu/cache/beacea76-e300-578d-8dc9-5bf0f1a16d13/reward.py",
|
| 3 |
+
"api_url": "http://28.7.184.184:8000/v1/chat/completions",
|
| 4 |
+
"model": "Kimi-K2.6",
|
| 5 |
+
"max_code_chars": 100000,
|
| 6 |
+
"created_at": "2026-07-14 10:23:44",
|
| 7 |
+
"label": {
|
| 8 |
+
"task_id": "beacea76-e300-578d-8dc9-5bf0f1a16d13",
|
| 9 |
+
"domain": "mock_websites",
|
| 10 |
+
"summary": "验证用户是否新建了每周状态报告文档并包含指定章节,同时在Slack和Teams中完成相关通知",
|
| 11 |
+
"is_placeholder": false,
|
| 12 |
+
"data_sources": [
|
| 13 |
+
"/tmp/task_web_sid",
|
| 14 |
+
"google_docs_mock",
|
| 15 |
+
"monday_mock",
|
| 16 |
+
"slack_mock",
|
| 17 |
+
"microsoft_teams_mock"
|
| 18 |
+
],
|
| 19 |
+
"scoring_components": [
|
| 20 |
+
{
|
| 21 |
+
"name": "Component 0",
|
| 22 |
+
"weight": 0.2,
|
| 23 |
+
"description": "新建每周状态文档",
|
| 24 |
+
"check_logic": "比较 google_docs_mock 的 initial_state 与 current_state 中的 documents,找出 ID 不在初始集合中且标题(转小写)包含 'weekly status - june w4' 或 'weekly status' 的新文档",
|
| 25 |
+
"pass_condition": "存在至少一个符合条件的新建 Google Doc"
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"name": "Component 1",
|
| 29 |
+
"weight": 0.25,
|
| 30 |
+
"description": "报告包含 Progress/Risks/Decisions 部分",
|
| 31 |
+
"check_logic": "在新建的标题包含 'weekly status' 的文档中,提取所有 content 拼接并转小写,检查是否同时包含 'progress'、'risks'、'decisions' 三个子串",
|
| 32 |
+
"pass_condition": "新建 weekly status 文档存在且内容同时包含 progress、risks、decisions"
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"name": "Component 2",
|
| 36 |
+
"weight": 0.2,
|
| 37 |
+
"description": "Risks 部分指明受阻项目 User Research",
|
| 38 |
+
"check_logic": "在新建的标题包含 'weekly status' 的文档中,提取所有 content 拼接并转小写,检查是否包含 'user research'",
|
| 39 |
+
"pass_condition": "新建 weekly status 文档存在且内容包含 user research"
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"name": "Component 3",
|
| 43 |
+
"weight": 0.1,
|
| 44 |
+
"description": "Slack #general 频道有新消息",
|
| 45 |
+
"check_logic": "检查 slack_mock current_state 中 messages.general 列表,排除 SEED 中标记的初始消息 'g1',筛选 senderId 为 'user_1' 的新消息",
|
| 46 |
+
"pass_condition": "存在至少一条 user_1 发送的、不在初始种子中的新消息"
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"name": "Component 4",
|
| 50 |
+
"weight": 0.25,
|
| 51 |
+
"description": "Teams 帖子指向该报告",
|
| 52 |
+
"check_logic": "在 microsoft_teams_mock 的 team 't1' 的 channel 'c1' 中,比较 initial_state 和 current_state 的 posts,找出 userId 为 'user-me' 且不在初始帖子中的新 post,检查其 subject 和 content(转小写拼接)是否包含 'status'、'weekly' 或 'report'",
|
| 53 |
+
"pass_condition": "存在至少一条 user-me 发送的新帖子,且帖子标题或内容包含 status、weekly 或 report"
|
| 54 |
+
}
|
| 55 |
+
],
|
| 56 |
+
"total_max_score": 1.0,
|
| 57 |
+
"score_aggregation": "各组件分数相加,最后通过 min(total, 1.0) 钳制到上限 1.0,并四舍五入到 4 位小数",
|
| 58 |
+
"failure_modes": [
|
| 59 |
+
"读取 /tmp/task_web_sid 失败或内容为空:打印 CRITICAL 并返回 0.0 退出",
|
| 60 |
+
"从任一 mock 服务拉取当前状态失败:打印 CRITICAL 并返回 0.0 退出",
|
| 61 |
+
"各组件条件不满足时仅不加分,不会导致提前退出"
|
| 62 |
+
],
|
| 63 |
+
"scoring_logic_explanation": "脚本首先读取 /tmp/task_web_sid 获取会话 ID,然后依次向 google_docs_mock、monday_mock、slack_mock、microsoft_teams_mock 四个 mock 服务请求当前状态。若任何一步失败则直接返回 0.0。接着按顺序检查 5 个评分组件:1) 检查 Google Docs 中是否新建了标题含 'weekly status' 的文档;2) 检查该文档内容是否同时包含 'progress'、'risks'、'decisions';3) 检查内容是否包含 'user research';4) 检查 Slack #general 中 user_1 是否发送了非种子新消息;5) 检查 Teams 频道 c1 中 user-me 是否发布了指向报告的新帖子。每个组件通过则累加对应权重,最终总分经 min(total, 1.0) 钳制并四舍五入后输出。",
|
| 64 |
+
"confidence": 1.0
|
| 65 |
+
},
|
| 66 |
+
"raw_response": "用户要求我分析一个 reward.py 评分脚本的评分逻辑,并输出一个严格的 JSON 对象。\n\n让我仔细阅读代码:\n\n1. 文件路径和 docstring:\n - Task ID: beacea76-e300-578d-8dc9-5bf0f1a16d13(从 docstring 和文件路径中提取)\n - Domain: mock_websites(从 docstring 中提取)\n - Mocks: google_docs_mock, monday_mock, slack_mock, microsoft_teams_mock\n\n2. 数据源:\n - 从 /tmp/task_web_sid 读取 sid\n - 从 MOCK_URLS 获取各个 mock 的 current_state:google_docs_mock, monday_mock, slack_mock, microsoft_teams_mock\n\n3. 评分组件:\n - c0: 0.2 - new weekly status doc(Google Docs 中新建了标题包含 'weekly status - june w4' 或 'weekly status' 的文档)\n - c1: 0.25 - report has Progress/Risks/Decisions(新建 weekly status 文档内容中包含 progress, risks, decisions)\n - c2: 0.2 - Risks names the stuck item (User Research)(新建 weekly status 文档内容中包含 'user research')\n - c3: 0.1 - slack_new_msg(Slack #general 频道中 user_1 发送了新消息)\n - c4: 0.25 - Teams post points to the report(Microsoft Teams 频道 c1 中 user-me 发布了新帖子,标题或内容包含 'status', 'weekly', 'report' 之一)\n\n4. 失败模式:\n - 读取 sid 失败或为空:打印 CRITICAL,REWARD: 0.0,退出\n - 获取任何 mock 状态失败:打印 CRITICAL,REWARD: 0.0,退出\n - 各组件检查失败时只是不加分,不会提前退出\n\n5. 分数汇总:\n - total 累加各组件分数\n - final = round(min(total, 1.0), 4)\n - 是相加汇总,然后钳制到 1.0\n\n6. is_placeholder:\n - false,因为脚本有详细的检查逻辑\n\n7. confidence:\n - 1.0,因为代码逻辑清晰完整\n\n现在构建 JSON:\n\ntask_id: \"beacea76-e300-578d-8dc9-5bf0f1a16d13\"\ndomain: \"mock_websites\"\nsummary: \"验证用户是否创建了新的每周状态报告文档,包含进度、风险和决策部分,并在Slack和Teams中进行了相应的通知和分享\"\nis_placeholder: false\ndata_sources: [\"/tmp/task_web_sid\", \"google_docs_mock\", \"monday_mock\", \"slack_mock\", \"microsoft_teams_mock\"]\n\nscoring_components:\n- name: \"Component 0\"\n weight: 0.2\n description: \"新建每周状态文档\"\n check_logic: \"比较 google_docs_mock 的 initial_state 和 current_state 中的 documents,找出 ID 不在初始集合中且标题(转小写)包含 'weekly status - june w4' 或 'weekly status' 的新文档\"\n pass_condition: \"存在至少一个符合条件的新建 Google Doc\"\n\n- name: \"Component 1\"\n weight: 0.25\n description: \"报告包含 Progress/Risks/Decisions 部分\"\n check_logic: \"在新建的标题包含 'weekly status' 的文档中,提取所有 content 拼接并转小写,检查是否同时包含 'progress'、'risks'、'decisions' 三个子串\"\n pass_condition: \"新建 weekly status 文档存在且内容同时包含 progress、risks、decisions\"\n\n- name: \"Component 2\"\n weight: 0.2\n description: \"Risks 部分指明受阻项目 User Research\"\n check_logic: \"在新建的标题包含 'weekly status' 的文档中,提取所有 content 拼接并转小写,检查是否包含 'user research'\"\n pass_condition: \"新建 weekly status 文档存在且内容包含 user research\"\n\n- name: \"Component 3\"\n weight: 0.1\n description: \"Slack #general 频道有新消息\"\n check_logic: \"检查 slack_mock current_state 中 messages.general 列表,排除 SEED 中标记的初始消息 'g1',筛选 senderId 为 'user_1' 的新消息\"\n pass_condition: \"存在至少一条 user_1 发送的、不在初始种子中的新消息\"\n\n- name: \"Component 4\"\n weight: 0.25\n description: \"Teams 帖子指向该报告\"\n check_logic: \"在 microsoft_teams_mock 的 team 't1' 的 channel 'c1' 中,比较 initial_state 和 current_state 的 posts,找出 userId 为 'user-me' 且不在初始帖子中的新 post,检查其 subject 和 content(转小写拼接)是否包含 'status'、'weekly' 或 'report'\"\n pass_condition: \"存在至少一条 user-me 发送的新帖子,且帖子标题或内容包含 status、weekly 或 report\"\n\ntotal_max_score: 1.0\nscore_aggregation: \"各组件分数相加,最后通过 min(total, 1.0) 钳制到上限 1.0,并四舍五入到 4 位小数\"\nfailure_modes: [\n \"读取 /tmp/task_web_sid 失败或内容为空:打印 CRITICAL 并返回 0.0 退出\",\n \"从任一 mock 服务拉取当前状态失败:打印 CRITICAL 并返回 0.0 退出\",\n \"各组件条件不满足时仅不加分,不会导致提前退出\"\n]\n\nscoring_logic_explanation: \"脚本首先读取 /tmp/task_web_sid 获取会话 ID,然后依次向 google_docs_mock、monday_mock、slack_mock、microsoft_teams_mock 四个 mock 服务请求当前状态。若任何一步失败则直接返回 0.0。接着按顺序检查 5 个评分组件:1) 检查 Google Docs 中是否新建了标题含 'weekly status' 的文档;2) 检查该文档内容是否同时包含 'progress'、'risks'、'decisions';3) 检查内容是否包含 'user research';4) 检查 Slack #general 中 user_1 是否发送了非种子新消息;5) 检查 Teams 频道 c1 中 user-me 是否发布了指向报告的新帖子。每个组件通过则累加对应权重,最终总分经 min(total, 1.0) 钳制并四舍五入后输出。\"\n\nconfidence: 1.0\n\n确保 JSON 格式正确,没有 markdown 代码块,第一个字符是 {,最后一个字符是 }。 </think> {\"task_id\":\"beacea76-e300-578d-8dc9-5bf0f1a16d13\",\"domain\":\"mock_websites\",\"summary\":\"验证用户是否新建了每周状态报告文档并包含指定章节,同时在Slack和Teams中完成相关通知\",\"is_placeholder\":false,\"data_sources\":[\"/tmp/task_web_sid\",\"google_docs_mock\",\"monday_mock\",\"slack_mock\",\"microsoft_teams_mock\"],\"scoring_components\":[{\"name\":\"Component 0\",\"weight\":0.2,\"description\":\"新建每周状态文档\",\"check_logic\":\"比较 google_docs_mock 的 initial_state 与 current_state 中的 documents,找出 ID 不在初始集合中且标题(转小写)包含 'weekly status - june w4' 或 'weekly status' 的新文档\",\"pass_condition\":\"存在至少一个符合条件的新建 Google Doc\"},{\"name\":\"Component 1\",\"weight\":0.25,\"description\":\"报告包含 Progress/Risks/Decisions 部分\",\"check_logic\":\"在新建的标题包含 'weekly status' 的文档中,提取所有 content 拼接并转小写,检查是否同时包含 'progress'、'risks'、'decisions' 三个子串\",\"pass_condition\":\"新建 weekly status 文档存在且内容同时包含 progress、risks、decisions\"},{\"name\":\"Component 2\",\"weight\":0.2,\"description\":\"Risks 部分指明受阻项目 User Research\",\"check_logic\":\"在新建的标题包含 'weekly status' 的文档中,提取所有 content 拼接并转小写,检查是否包含 'user research'\",\"pass_condition\":\"新建 weekly status 文档存在且内容包含 user research\"},{\"name\":\"Component 3\",\"weight\":0.1,\"description\":\"Slack #general 频道有新消息\",\"check_logic\":\"检查 slack_mock current_state 中 messages.general 列表,排除 SEED 中标记的初始消息 'g1',筛选 senderId 为 'user_1' 的新消息\",\"pass_condition\":\"存在至少一条 user_1 发送的、不在初始种子中的新消息\"},{\"name\":\"Component 4\",\"weight\":0.25,\"description\":\"Teams 帖子指向该报告\",\"check_logic\":\"在 microsoft_teams_mock 的 team 't1' 的 channel 'c1' 中,比较 initial_state 和 current_state 的 posts,找出 userId 为 'user-me' 且不在初始帖子中的新 post,检查其 subject 和 content(转小写拼接)是否包含 'status'、'weekly' 或 'report'\",\"pass_condition\":\"存在至少一条 user-me 发送的新帖子,且帖子标题或内容包含 status、weekly 或 report\"}],\"total_max_score\":1.0,\"score_aggregation\":\"各组件分数相加,最后通过 min(total, 1.0) 钳制到上限 1.0,并四舍五入到 4 位小数\",\"failure_modes\":[\"读取 /tmp/task_web_sid 失败或内容为空:打印 CRITICAL 并返回 0.0 退出\",\"从任一 mock 服务拉取当前状态失败:打印 CRITICAL 并返回 0.0 退出\",\"各组件条件不满足时仅不加分,不会导致提前退出\"],\"scoring_logic_explanation\":\"脚本首先读取 /tmp/task_web_sid 获取会话 ID,然后依次向 google_docs_mock、monday_mock、slack_mock、microsoft_teams_mock 四个 mock 服务请求当前状态。若任何一步失败则直接返回 0.0。接着按顺序检查 5 个评分组件:1) 检查 Google Docs 中是否新建了标题含 'weekly status' 的文档;2) 检查该文档内容是否同时包含 'progress'、'risks'、'decisions';3) 检查内容是否包含 'user research';4) 检查 Slack #general 中 user_1 是否发送了非种子新消息;5) 检查 Teams 频道 c1 中 user-me 是否发布了指向报告的新帖子。每个组件通过则累加对应权重,最终总分经 min(total, 1.0) 钳制并四舍五入后输出。\",\"confidence\":1.0}"
|
| 67 |
+
}
|