Cosmonyx Admin – Sign in, Fetch Companies, Export as PDF or Excel
This skill lets an admin sign in to Cosmonyx, fetch all company records using the same endpoints as the Cosmonyx gateway API, then choose to export those records as PDF or Excel, or send reminder emails. Email is sent by this skill’s own script (scripts/send-email.py); see TOOLS.md.
You must run all HTTP requests yourself (no external repos). For structured config (endpoints, run order) you can also load SKILL.yaml from this directory if present, but this SKILL.md is the source of truth for behavior.
Step 0 – Prompt for admin credentials
Before calling any API:
- "Please provide your
Cosmonyx admin email."
- "Please provide your
Cosmonyx admin password."
- - Do not echo the password back in any reply. Treat it as sensitive.
- Use the provided email/password as the sign-in payload.
If the user has already given both an email and password in their initial request, reuse those and do not ask again.
Step 1 – Sign in (admin)
- - POST INLINECODE1
- Headers: INLINECODE2
- Body: JSON with the admin credentials you obtained in Step 0, e.g.:
-
{"email":"<ADMIN_EMAIL>","password":"<ADMIN_PASSWORD>"}
- - From the response, take the auth token from whichever field exists first:
-
accessToken,
token,
data.token, or
data.accessToken
- - Keep this token in memory only and never print it in any reply.
If sign-in fails (4xx/5xx or missing token), stop, explain the error briefly, and ask the user to correct the credentials instead of proceeding.
Step 2 – Fetch all company records
- - GET INLINECODE8
- Headers:
Authorization: Bearer <TOKEN> where <TOKEN> is from Step 1. - Fetch the full list of companies. If the API is paginated:
- Detect pagination from response fields like
page,
totalPages,
links.next, etc.
- Request
all pages until there are no more, concatenating results.
-
data,
companies, or the root.
- - Extract the complete list of company objects into an in-memory structure (array of objects).
If there are zero companies, still continue to the export choice but clearly state that the dataset is empty.
Step 3 – Choose action on the records
After fetching all companies, prompt the admin to choose what they want to do:
"What would you like to do with the Cosmonyx company records?
1) List records where complianceStatus is Not Started
2) List records with riskType = Low
3) List records where the primary user’s sumsubVerificationStatus is under_review
4) Send reminder emails to records where complianceStatus is Not Started
5) Send reminder emails to records whose expiryDate is before a given date
6) Work with all records (no filter)"
Step 3A – Filtering logic
Apply filters in memory over the full company list from Step 2:
- - Option 1: compliance not started
- Filter:
company.complianceStatus === "Not Started".
- Filter:
company.riskType === "Low".
- - Option 3: KYC under review
- Filter:
company.primaryUser?.sumsubVerificationStatus === "under_review".
- - Option 4: compliance not started (for email)
- Same filter as option 1.
- - Option 5: expiry date before a given date
- Ask once: "Please provide a cutoff date (YYYY-MM-DD). Records with
expiryDate earlier than this date will be selected."
- Parse the cutoff into a date and filter records where
expiryDate is non-null and
< cutoff.
- No extra filter; use the full dataset.
If the filter results in zero records, report that to the user and stop (no export and no emails).
Step 3B – Branching: export vs email
- - If the admin chose 1, 2, 3, or 6, proceed to Step 4 – Export filtered records (PDF or Excel).
- If the admin chose 4 or 5, proceed to Step 5 – Send reminder emails to the filtered companies.
Step 4 – Export filtered records (PDF or Excel)
Step 4A – Ask export format (PDF vs Excel)
For actions 1, 2, 3, or 6, after filtering:
"I selected N matching companies. How would you like to export these records?
1) PDF file
2) Excel (.xlsx) file"
Interpret the user’s reply:
- - If they answer with "1", "pdf", or similar → choose PDF.
- If they answer with "2", "excel", "xlsx", or similar → choose Excel.
- If unclear, ask once for clarification and then proceed.
Step 4B – Generate PDF file (if user chose PDF)
If the user selected PDF:
- - Create a PDF file summarizing all filtered company records (not the full list).
- At minimum, include a table or clearly formatted list with columns such as:
-
id,
name,
status,
country, and any other key fields returned.
- - Save the file into the current user’s Downloads folder so it appears in your normal download location, e.g.:
-
$HOME/Downloads/comonyx-companies.pdf
- - Ensure the file contains all filtered companies from Step 3 (not truncated).
When done, reply with:
- 1. A short confirmation that admin sign-in succeeded.
- A brief summary of how many companies were selected by the filter.
- The path and name of the generated PDF file (e.g.
$HOME/Downloads/comonyx-companies.pdf) so the user (or tools) can retrieve it.
Then proceed to Step 4D – Optional: Email the exported file.
Do not ask what to do next.
Step 4C – Generate Excel file (if user chose Excel)
If the user selected Excel:
- - Create an Excel
.xlsx file listing all filtered company records in a sheet named Companies. - Include columns for key fields such as:
-
id,
name,
status,
country,
email, and any other important fields present in the API response.
- - Each company should be one row.
- Save the file into the current user’s Downloads folder:
-
$HOME/Downloads/comonyx-companies.xlsx
- - Ensure the file contains all filtered companies from Step 3.
When done, reply with:
- 1. A short confirmation that admin sign-in succeeded.
- A brief summary of how many companies were selected by the filter.
- The path and name of the generated Excel file (e.g.
$HOME/Downloads/comonyx-companies.xlsx).
Then proceed to Step 4D – Optional: Email the exported file.
Do not ask what to do next.
Step 4D – Optional: Email the exported file (PDF or Excel)
After Step 4B or 4C (once the export file path is known):
- 1. Ask once: "Would you like this file emailed to someone? If yes, provide the email address." If the user says no or does not provide an address, skip sending and go to the final reply (Step "Reply format").
- If the user provides an email address:
- Use
TOOLS.md in this skill directory. Set
EMAIL_TO to the address they gave and
ATTACHMENT_PATH to the
exact path of the generated file (e.g.
$HOME/Downloads/comonyx-companies.pdf or
$HOME/Downloads/comonyx-companies.xlsx). Expand
$HOME to the actual home path if needed (e.g.
/home/musawir).
- Write the body file:
echo "Cosmonyx companies export attached." > /tmp/companies_body.txt
- Run the one-line send command from TOOLS.md in a single
exec (with
EMAIL_TO and
ATTACHMENT_PATH set). Use the script in
this skill’s scripts/send-email.py (TOOLS.md uses
<skill-dir> for the path; resolve that to this skill’s directory).
- If send succeeds, confirm in your final reply: "The export was emailed to \
."
- If send fails, report the error and still mention where the file was saved.
Do not ask what to do next after sending (or after declining).
Step 5 – Send reminder emails to filtered companies (options 4 and 5)
If the admin chose option 4 or 5 in Step 3:
- 1. Use the filtered list from Step 3A.
- For each company, determine the email recipient:
- Prefer company.email if non-empty.
- Otherwise use company.primaryUser?.email if present.
- Skip records that have no email at all.
- 3. Ask the admin once for:
- The email subject, e.g. "Compliance onboarding reminder".
- The email body template, which may include placeholders like {companyName}, {status}, {expiryDate} – you can do simple string replacements for these placeholders per company.
- 4. For each selected company with a recipient address:
- Fill in the template with that company’s values.
- Write the final body to a temp file (e.g. /tmp/comonyx-admin-email-body.txt).
- Use the email script in this skill’s scripts/send-email.py and the SMTP/recipient settings in this skill’s TOOLS.md. Set EMAIL_TO to that company’s recipient address (and no attachment for reminder emails) before running the send command.
- 5. Keep track of how many emails were successfully attempted vs skipped (no email address).
If sending fails due to SMTP issues, report the error and remind the user to configure SMTP_* environment variables (host, port, user, password).
Reply format (final response)
After completing the chosen action (export or sending emails), send one final reply that includes:
- 1. Sign-in result – e.g. "Signed in to Cosmonyx as admin successfully."
- Filter summary – what option was chosen and how many companies matched (e.g. "Selected 24 companies where complianceStatus is Not Started.").
- Outcome:
- For exports:
- PDF: "Generated PDF export at $HOME/Downloads/comonyx-companies.pdf."
- Excel: "Generated Excel export at $HOME/Downloads/comonyx-companies.xlsx."
- If the user asked to email the file and you sent it: "The export was emailed to \."
- For reminder emails (options 4/5):
- E.g. "Attempted to send reminder emails to 24 companies; 22 emails sent, 2 skipped due to missing email address."
Do not add follow-up offers like "let me know if you need anything else" or questions about next steps. End after confirming the outcome.
Cosmonyx Admin – 登录、获取公司列表、导出为PDF或Excel
此技能允许管理员登录Cosmonyx,使用与Cosmonyx网关API相同的端点获取所有公司记录,然后选择将这些记录导出为PDF或Excel,或发送提醒邮件。邮件由该技能自身的脚本(scripts/send-email.py)发送;详见TOOLS.md。
您必须自行执行所有HTTP请求(无需外部仓库)。对于结构化配置(端点、运行顺序),如果存在,您也可以加载此目录中的SKILL.yaml,但此SKILL.md是行为的事实依据。
步骤0 – 提示输入管理员凭据
在调用任何API之前:
- 请提供您的
Cosmonyx管理员邮箱。
- 请提供您的
Cosmonyx管理员密码。
- - 不要在任何回复中回显密码。将其视为敏感信息。
- 使用提供的邮箱/密码作为登录请求体。
如果用户已在初始请求中同时提供了邮箱和密码,则直接使用这些信息,不再询问。
步骤1 – 登录(管理员)
- - POST https://gateway-dev.cosmonyx.co/auth/signin
- 请求头: Content-Type: application/json
- 请求体: 包含您在步骤0中获取的管理员凭据的JSON,例如:
- {email:<管理员邮箱>,password:<管理员密码>}
- accessToken、token、data.token 或 data.accessToken
- - 将此令牌仅保存在内存中,并且切勿在任何回复中打印它。
如果登录失败(4xx/5xx或缺少令牌),则停止,简要说明错误,并要求用户更正凭据,而不是继续执行。
步骤2 – 获取所有公司记录
- - GET https://gateway-dev.cosmonyx.co/companies
- 请求头: Authorization: Bearer <令牌>,其中<令牌>来自步骤1。
- 获取公司的完整列表。如果API支持分页:
- 从响应字段(如page、totalPages、links.next等)检测分页。
- 请求
所有页面,直到没有更多页面,并合并结果。
- data、companies或根层级。
- - 将完整的公司对象列表提取到内存结构中(对象数组)。
如果公司数量为零,仍然继续到导出选择,但需明确说明数据集为空。
步骤3 – 选择对记录的操作
获取所有公司后,提示管理员选择他们想要执行的操作:
您想对Cosmonyx公司记录执行什么操作?
1) 列出complianceStatus为Not Started的记录
2) 列出riskType为Low的记录
3) 列出主要用户的sumsubVerificationStatus为under_review的记录
4) 向complianceStatus为Not Started的记录发送提醒邮件
5) 向expiryDate在给定日期之前的记录发送提醒邮件
6) 处理所有记录(无筛选)
步骤3A – 筛选逻辑
在内存中对步骤2中的完整公司列表应用筛选:
- 筛选条件:company.complianceStatus === Not Started。
- 筛选条件:company.riskType === Low。
- 筛选条件:company.primaryUser?.sumsubVerificationStatus === under_review。
- 与选项1相同的筛选条件。
- 询问一次:请提供截止日期(YYYY-MM-DD)。expiryDate早于此日期的记录将被选中。
- 将截止日期解析为日期,并筛选出expiryDate非空且< 截止日期的记录。
- 无额外筛选;使用完整数据集。
如果筛选结果为零条记录,向用户报告并停止(不导出也不发送邮件)。
步骤3B – 分支:导出与邮件
- - 如果管理员选择了1、2、3或6,则继续执行步骤4 – 导出筛选后的记录(PDF或Excel)。
- 如果管理员选择了4或5,则继续执行步骤5 – 向筛选后的公司发送提醒邮件。
步骤4 – 导出筛选后的记录(PDF或Excel)
步骤4A – 询问导出格式(PDF与Excel)
对于操作1、2、3或6,在筛选之后:
我找到了N家匹配的公司。您希望如何导出这些记录?
1) PDF文件
2) Excel(.xlsx)文件
解释用户的回复:
- - 如果用户回答1、pdf或类似内容 → 选择PDF。
- 如果用户回答2、excel、xlsx或类似内容 → 选择Excel。
- 如果不明确,询问一次以澄清,然后继续。
步骤4B – 生成PDF文件(如果用户选择了PDF)
如果用户选择了PDF:
- - 创建一个PDF文件,汇总所有筛选后的公司记录(而非完整列表)。
- 至少包含一个表格或格式清晰的列表,包含以下列:
- id、name、status、country以及返回的任何其他关键字段。
- - 将文件保存到当前用户的下载文件夹中,使其出现在您的常规下载位置,例如:
- $HOME/Downloads/comonyx-companies.pdf
- - 确保文件包含步骤3中所有筛选后的公司(不截断)。
完成后,回复:
- 1. 简短确认管理员登录成功。
- 简要总结筛选选中的公司数量。
- 生成的PDF文件的路径和名称(例如$HOME/Downloads/comonyx-companies.pdf),以便用户(或工具)可以检索它。
然后继续执行步骤4D – 可选:通过邮件发送导出的文件。
不要询问下一步操作。
步骤4C – 生成Excel文件(如果用户选择了Excel)
如果用户选择了Excel:
- - 创建一个Excel .xlsx文件,在名为Companies的工作表中列出所有筛选后的公司记录。
- 包含关键字段的列,例如:
- id、name、status、country、email以及API响应中存在的任何其他重要字段。
- - 每家公司占一行。
- 将文件保存到当前用户的下载文件夹中:
- $HOME/Downloads/comonyx-companies.xlsx
完成后,回复:
- 1. 简短确认管理员登录成功。
- 简要总结筛选选中的公司数量。
- 生成的Excel文件的路径和名称(例如$HOME/Downloads/comonyx-companies.xlsx)。
然后继续执行步骤4D – 可选:通过邮件发送导出的文件。
不要询问下一步操作。
步骤4D – 可选:通过邮件发送导出的文件(PDF或Excel)
在步骤4B或4C之后(一旦知道导出文件路径):
- 1. 询问一次: 您希望将此文件通过邮件发送给某人吗?如果是,请提供电子邮件地址。如果用户说不或未提供地址,则跳过发送并进入最终回复(步骤回复格式)。
- 如果用户提供了电子邮件地址:
- 使用此技能目录中的
TOOLS.md。将EMAIL
TO设置为他们提供的地址,将ATTACHMENTPATH设置为生成文件的
确切路径(例如$HOME/Downloads/comonyx-companies.pdf或$HOME/Downloads/comonyx-companies.xlsx)。如有必要,将$HOME扩展为实际的主目录路径(例如/home/musawir)。
- 编写正文文件:echo Cosmonyx companies export attached. > /tmp/companies_body.txt
- 在单个
exec中运行TOOLS.md中的单行发送命令(设置EMAIL
TO和ATTACHMENTPATH)。使用
此技能的scripts/send-email.py脚本(TOOLS.md使用
作为路径;将其解析为此技能的目录)。
- 如果发送成功,在最终回复中确认:导出文件已通过邮件发送至\<地址\>。
- 如果发送失败,报告错误,并仍然说明文件保存的位置。
发送后(或拒绝发送后),不要询问下一步操作。
步骤5 – 向筛选后的公司发送提醒邮件(选项4