Download ar_payment_004/initial_setup.py from tencent/OSWorkerBench: direct link, hf CLI and curl.
- Browser
- Download file 14 kB
-
https://huggingface.co/datasets/tencent/OSWorkerBench/resolve/main/ar_payment_004/initial_setup.py
- Command line
-
hf download hf://datasets/tencent/OSWorkerBench/ar_payment_004/initial_setup.py
-
curl -L -o initial_setup.py https://huggingface.co/datasets/tencent/OSWorkerBench/resolve/main/ar_payment_004/initial_setup.py
14 kB
| """ | |
| Initial Setup: AR payment INV-1045 (Initech) — PRE-task state. | |
| Task ID: ar_payment_004 | |
| Domain: libreoffice_calc (HYBRID: local Calc ledger + salesforce_mock + slack_mock) | |
| Pre-task state: | |
| - Ledger /home/user/ar_payment_002.xlsx, sheet 'AR Invoice Ledger', INV-1045 Status='Sent'. | |
| - Salesforce: Closed-Won opp 'Initech CRM Rollout' owned by Priya Nair, NO payment-received activity. | |
| - Slack #finance: prior chatter only, no settlement notification to Priya Nair. | |
| GUI: libreoffice --calc ledger + google-chrome for salesforce & slack mocks (DISPLAY=:0). | |
| """ | |
| import os | |
| import shlex | |
| import subprocess | |
| import time | |
| import uuid | |
| import openpyxl | |
| import requests | |
| WORKDIR = '/home/user' | |
| TASK_ID = 'ar_payment_002' | |
| OUTPUT = f'{WORKDIR}/{TASK_ID}.xlsx' | |
| SF_URL = 'http://28.7.184.198:8175' | |
| SLACK_URL = 'http://28.7.184.198:8178' | |
| # --------------------------------------------------------------------------- | |
| # Shared baseline builders (identical in initial_setup.py and golden_patch.py) | |
| # --------------------------------------------------------------------------- | |
| def ledger_rows(): | |
| """Fixed columns A=Invoice #,B=Customer,C=Deal/Contract,D=Amount, | |
| E=Issue Date,F=Due Date,G=Status,H=AE/Owner. 10 data rows.""" | |
| return [ | |
| ['INV-1042', 'Acme Corp', 'Acme Enterprise License', 25000, '2026-05-10', '2026-06-09', 'Paid', 'John Smith'], | |
| ['INV-1043', 'Globex', 'Globex Analytics Suite', 48000, '2026-05-15', '2026-06-14', 'Paid', 'Sarah Johnson'], | |
| ['INV-1044', 'Soylent', 'Soylent Data Platform', 31500, '2026-05-20', '2026-06-19', 'Sent', 'Mike Chen'], | |
| ['INV-1045', 'Initech', 'Initech CRM Rollout', 72000, '2026-05-25', '2026-06-24', 'Sent', 'Priya Nair'], | |
| ['INV-1046', 'Umbrella', 'Umbrella Security Audit', 15800, '2026-06-01', '2026-07-01', 'Sent', 'Emily Davis'], | |
| ['INV-1047', 'Hooli', 'Hooli Cloud Migration', 96000, '2026-06-03', '2026-07-03', 'Paid', 'Priya Nair'], | |
| ['INV-1048', 'Stark Industries', 'Stark IoT Integration', 54000, '2026-06-05', '2026-07-05', 'Sent', 'Alex Kim'], | |
| ['INV-1049', 'Wayne Enterprises', 'Wayne Security Platform', 120000, '2026-06-08', '2026-07-08', 'Paid', 'Sarah Johnson'], | |
| ['INV-1050', 'Pied Piper', 'Pied Piper Compression API', 22500, '2026-06-12', '2026-07-12', 'Sent', 'Mike Chen'], | |
| ['INV-1051', 'Wonka', 'Wonka Supply Chain', 38000, '2026-06-15', '2026-07-15', 'Overdue', 'Emily Davis'], | |
| ] | |
| def build_ledger(paid_inv1045: bool): | |
| wb = openpyxl.Workbook() | |
| ws = wb.active | |
| ws.title = 'AR Invoice Ledger' | |
| headers = ['Invoice #', 'Customer', 'Deal/Contract', 'Amount', | |
| 'Issue Date', 'Due Date', 'Status', 'AE/Owner'] | |
| for col, h in enumerate(headers, 1): | |
| ws.cell(row=1, column=col, value=h) | |
| for r, row in enumerate(ledger_rows(), 2): | |
| vals = list(row) | |
| if paid_inv1045 and vals[0] == 'INV-1045': | |
| vals[6] = 'Paid' # column G = Status | |
| for c, val in enumerate(vals, 1): | |
| ws.cell(row=r, column=c, value=val) | |
| wb.save(OUTPUT) | |
| def salesforce_state(): | |
| """Full baseline Salesforce org with Initech Closed-Won opp owned by Priya Nair, | |
| NO payment-received activity on it.""" | |
| user = { | |
| "userId": "user-1", "firstName": "John", "lastName": "Smith", | |
| "email": "john.smith@company.com", "phone": "(555) 123-4567", | |
| "title": "AR Specialist", "department": "Finance", "role": "Manager", | |
| "avatar": "https://i.pravatar.cc/150?u=user-1", | |
| "timezone": "America/New_York", "locale": "en-US", "theme": "lightning", | |
| } | |
| users = [ | |
| user, | |
| {"userId": "user-2", "firstName": "Sarah", "lastName": "Johnson", | |
| "email": "sarah.johnson@company.com", "phone": "(555) 222-3333", | |
| "title": "Account Executive", "department": "Sales", "role": "Rep", | |
| "avatar": "https://i.pravatar.cc/150?u=user-2", "timezone": "America/New_York", | |
| "locale": "en-US", "theme": "lightning"}, | |
| {"userId": "user-3", "firstName": "Mike", "lastName": "Chen", | |
| "email": "mike.chen@company.com", "phone": "(555) 333-4444", | |
| "title": "Account Executive", "department": "Sales", "role": "Rep", | |
| "avatar": "https://i.pravatar.cc/150?u=user-3", "timezone": "America/Los_Angeles", | |
| "locale": "en-US", "theme": "lightning"}, | |
| {"userId": "user-6", "firstName": "Priya", "lastName": "Nair", | |
| "email": "priya.nair@company.com", "phone": "(555) 666-7788", | |
| "title": "Senior Account Executive", "department": "Sales", "role": "Rep", | |
| "avatar": "https://i.pravatar.cc/150?u=user-6", "timezone": "America/New_York", | |
| "locale": "en-US", "theme": "lightning"}, | |
| ] | |
| accounts = [ | |
| {"accountId": "account-10", "name": "Initech", "type": "Customer", | |
| "industry": "Technology", "revenue": 48000000, "employees": 320, | |
| "ownerId": "user-6", "phone": "(555) 010-2030", "website": "www.initech.com", | |
| "billingStreet": "4120 Freidrich Lane", "billingCity": "Austin", | |
| "billingState": "TX", "billingZip": "78744", "billingCountry": "USA", | |
| "createdDate": "2025-11-02T10:00:00.000Z", "modifiedDate": "2026-06-01T10:00:00.000Z"}, | |
| {"accountId": "account-11", "name": "Globex", "type": "Customer", | |
| "industry": "Manufacturing", "revenue": 92000000, "employees": 540, | |
| "ownerId": "user-2", "phone": "(555) 040-5060", "website": "www.globex.com", | |
| "billingStreet": "200 Market St", "billingCity": "San Francisco", | |
| "billingState": "CA", "billingZip": "94105", "billingCountry": "USA", | |
| "createdDate": "2025-09-15T10:00:00.000Z", "modifiedDate": "2026-05-20T10:00:00.000Z"}, | |
| ] | |
| contacts = [ | |
| {"contactId": "contact-10", "accountId": "account-10", "firstName": "Bill", | |
| "lastName": "Lumbergh", "title": "VP of Operations", "department": "Operations", | |
| "email": "bill.lumbergh@initech.com", "phone": "(555) 010-2031", "ownerId": "user-6"}, | |
| {"contactId": "contact-11", "accountId": "account-11", "firstName": "Hank", | |
| "lastName": "Scorpio", "title": "CEO", "department": "Executive", | |
| "email": "hank.scorpio@globex.com", "phone": "(555) 040-5061", "ownerId": "user-2"}, | |
| ] | |
| opportunities = [ | |
| {"opportunityId": "opp-10", "name": "Initech CRM Rollout", "accountId": "account-10", | |
| "contactId": "contact-10", "amount": 72000, "closeDate": "2026-06-20T00:00:00.000Z", | |
| "stage": "Closed Won", "probability": 100, "type": "New Business", | |
| "leadSource": "Referral", "nextStep": "Kickoff implementation", | |
| "description": "Company-wide CRM rollout for Initech, 320 seats.", | |
| "ownerId": "user-6", "createdDate": "2026-02-10T10:00:00.000Z", | |
| "modifiedDate": "2026-06-20T10:00:00.000Z"}, | |
| {"opportunityId": "opp-11", "name": "Globex Analytics Suite", "accountId": "account-11", | |
| "contactId": "contact-11", "amount": 48000, "closeDate": "2026-07-30T00:00:00.000Z", | |
| "stage": "Negotiation", "probability": 70, "type": "New Business", | |
| "leadSource": "Website", "nextStep": "Send revised proposal", | |
| "description": "Analytics suite expansion for Globex.", | |
| "ownerId": "user-2", "createdDate": "2026-04-01T10:00:00.000Z", | |
| "modifiedDate": "2026-06-18T10:00:00.000Z"}, | |
| ] | |
| activities = [ | |
| {"activityId": "activity-10", "type": "task", "subject": "Send kickoff agenda to Initech", | |
| "status": "Not Started", "priority": "Normal", "dueDate": "2026-06-26T00:00:00.000Z", | |
| "relatedToType": "Opportunity", "relatedToId": "opp-10", "assignedToId": "user-6", | |
| "description": "Prepare and send implementation kickoff agenda to Bill Lumbergh.", | |
| "createdDate": "2026-06-21T10:00:00.000Z"}, | |
| {"activityId": "activity-11", "type": "event", "subject": "Globex proposal review call", | |
| "status": "Scheduled", "priority": "High", | |
| "startDateTime": "2026-07-02T15:00:00.000Z", "endDateTime": "2026-07-02T15:30:00.000Z", | |
| "relatedToType": "Opportunity", "relatedToId": "opp-11", "assignedToId": "user-2", | |
| "description": "Walk through revised analytics suite proposal.", | |
| "createdDate": "2026-06-19T10:00:00.000Z"}, | |
| ] | |
| return { | |
| "user": user, "users": users, "leads": [], "accounts": accounts, | |
| "contacts": contacts, "opportunities": opportunities, "cases": [], | |
| "activities": activities, "chatterPosts": [], "files": [], "following": [], | |
| "recentlyViewed": [], "dismissedNotifications": [], | |
| } | |
| def slack_state(): | |
| """Slack workspace with a #finance channel pre-seeded with prior chatter, | |
| NO settlement notification to Priya Nair. Priya Nair present as a user.""" | |
| current_user = { | |
| "userId": "user_1", "fullName": "John Smith", "displayName": "John", | |
| "email": "john.smith@company.com", "avatar": "https://picsum.photos/200/200?random=1", | |
| "title": "AR Specialist", "status": "online", "statusMessage": "", "statusEmoji": "", | |
| "timeZone": "America/New_York", | |
| } | |
| users = [ | |
| current_user, | |
| {"userId": "user_2", "fullName": "Sarah Johnson", "displayName": "Sarah", | |
| "email": "sarah.johnson@company.com", "avatar": "https://picsum.photos/200/200?random=2", | |
| "title": "Account Executive", "status": "online", "statusMessage": "", "statusEmoji": "", | |
| "timeZone": "America/New_York"}, | |
| {"userId": "user_3", "fullName": "Mike Chen", "displayName": "Mike", | |
| "email": "mike.chen@company.com", "avatar": "https://picsum.photos/200/200?random=3", | |
| "title": "Account Executive", "status": "away", "statusMessage": "", "statusEmoji": "", | |
| "timeZone": "America/Los_Angeles"}, | |
| {"userId": "user_9", "fullName": "Priya Nair", "displayName": "Priya", | |
| "email": "priya.nair@company.com", "avatar": "https://picsum.photos/200/200?random=9", | |
| "title": "Senior Account Executive", "status": "online", "statusMessage": "", "statusEmoji": "", | |
| "timeZone": "America/New_York"}, | |
| ] | |
| channels = [ | |
| {"channelId": "general", "name": "general", "description": "Company-wide announcements", | |
| "topic": "Welcome!", "isPrivate": False, "isStarred": False, | |
| "members": ["user_1", "user_2", "user_3", "user_9"], "createdBy": "user_1", | |
| "createdAt": "2026-01-01T10:00:00Z", "pinnedMessages": [], "unreadCount": 0}, | |
| {"channelId": "finance", "name": "finance", "description": "Accounts receivable, billing, and collections", | |
| "topic": "AR / billing coordination", "isPrivate": False, "isStarred": True, | |
| "members": ["user_1", "user_2", "user_3", "user_9"], "createdBy": "user_1", | |
| "createdAt": "2026-01-05T10:00:00Z", "pinnedMessages": [], "unreadCount": 0}, | |
| ] | |
| messages = { | |
| "general": [ | |
| {"messageId": "msg_g1", "senderId": "user_3", "content": "Morning all, quarterly close is next week.", | |
| "timestamp": "2026-06-29T09:00:00Z", "threadId": None, "reactions": [], | |
| "attachments": [], "isEdited": False}, | |
| ], | |
| "finance": [ | |
| {"messageId": "msg_f1", "senderId": "user_2", "content": "Reminder: please log payments in Salesforce as they land so AR stays clean.", | |
| "timestamp": "2026-06-26T13:10:00Z", "threadId": None, "reactions": [], | |
| "attachments": [], "isEdited": False}, | |
| {"messageId": "msg_f2", "senderId": "user_9", "content": "Still waiting on Initech's wire for the CRM Rollout, will confirm once it clears.", | |
| "timestamp": "2026-06-27T16:45:00Z", "threadId": None, "reactions": [], | |
| "attachments": [], "isEdited": False}, | |
| {"messageId": "msg_f3", "senderId": "user_1", "content": "Thanks Priya — I'll mark the invoice paid the moment treasury confirms receipt.", | |
| "timestamp": "2026-06-27T17:02:00Z", "threadId": None, "reactions": [], | |
| "attachments": [], "isEdited": False}, | |
| ], | |
| } | |
| return { | |
| "currentUser": current_user, | |
| "workspace": {"workspaceId": "ws_1", "workspaceName": "Acme Corp", "icon": ""}, | |
| "users": users, "channels": channels, "messages": messages, "threads": {}, | |
| "dms": [], "bookmarkedMessages": [], "callHistory": [], | |
| "settings": {"theme": "light", "notifications": "all", "displayDensity": "comfortable", | |
| "showAvatars": True, "use24Hour": False}, | |
| "invitations": [], "notifications": [], | |
| } | |
| def launch_gui(command, delay_sec=1.0): | |
| env = os.environ.copy() | |
| env['DISPLAY'] = ':0' | |
| subprocess.Popen(shlex.split(command), stdout=subprocess.DEVNULL, | |
| stderr=subprocess.DEVNULL, env=env) | |
| time.sleep(delay_sec) | |
| def main(): | |
| # --- 1. Local ledger (INV-1045 Status='Sent') --- | |
| build_ledger(paid_inv1045=False) | |
| print(f'Initial ledger created: {OUTPUT}') | |
| # --- 2. Shared sid for both mocks --- | |
| sid = str(uuid.uuid4()) | |
| with open('/tmp/task_web_sid', 'w') as f: | |
| f.write(sid) | |
| # --- 3. Inject Salesforce + Slack initial state (action 'set') --- | |
| for name, url, state in [ | |
| ('salesforce', SF_URL, salesforce_state()), | |
| ('slack', SLACK_URL, slack_state()), | |
| ]: | |
| r = requests.post(f'{url}/post?sid={sid}', json={'action': 'set', 'state': state}, timeout=30) | |
| assert r.status_code == 200, f'{name} set failed: {r.text}' | |
| go = requests.get(f'{url}/go?sid={sid}', timeout=15).json() | |
| assert go['initial_state'] is not None, f'{name} initial_state is None' | |
| print(f'{name} initial state injected: sid={sid}') | |
| # --- 4. GUI-ready startup --- | |
| launch_gui(f'libreoffice --calc "{OUTPUT}"', delay_sec=3.0) | |
| launch_gui(f'google-chrome "{SF_URL}/?sid={sid}"', delay_sec=2.0) | |
| launch_gui(f'google-chrome "{SLACK_URL}/?sid={sid}"', delay_sec=2.0) | |
| print('GUI_READY: launched libreoffice calc + chrome (salesforce, slack) with DISPLAY=:0') | |
| main() | |