05-frontend-api

05-frontend-api is a cursor rule for coding agents from loonghao/auroraview. It costs 717 tokens per session, scanned A, original, MIT.

A coding rule that defines how JavaScript in AuroraView talks to its Python or Rust backend. It documents calls, responses, errors, events, and a compatibility shortcut for PyWebView applications.

In plain words
What is it for?
Implementing or reviewing frontend-to-backend calls such as exporting a scene, applying a tool, subscribing to events, and handling the ready signal.
Why use it?
It gives frontend code one consistent way to request backend actions and receive results or pushed events. This reduces mismatched method names, parameters, and error handling.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/loonghao/auroraview/05-frontend-api
Clone the repo
git clone --depth 1 https://github.com/loonghao/auroraview

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for 05-frontend-api

README.md
[![agentmods](https://agentmods.dev/badge/rules/loonghao/auroraview/05-frontend-api.svg)](https://agentmods.dev/rules/loonghao/auroraview/05-frontend-api)
Your own site
<a href="https://agentmods.dev/rules/loonghao/auroraview/05-frontend-api"><img src="https://agentmods.dev/badge/rules/loonghao/auroraview/05-frontend-api.svg" alt="Measured on agentmods" height="20"></a>
Per session 717 This file is loaded in full into every session.
When invoked 717 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00717 $0.00717
Opus 5 $0.00358 $0.00358
Sonnet 5 $0.00143 $0.00143
Haiku 4.5 $0.00072 $0.00072

Measured 4d ago against content hash 1a2d24a7093b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

05-frontend-api scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.codebuddy/rules/05-frontend-api.mdc · 48 lines

What it actually says

前端命名空间(window.auroraview)

  • 全局唯一入口:window.auroraview
  • 核心能力:
    • auroraview.call(method: string, params?: any): Promise<any>
      • method 为字符串命名空间,如:"api.export_scene""tool.apply"
      • params 支持:对象(当作 kwargs)、数组(当作位置参数)、单值(单一位置参数)
      • 正常返回:Promise resolve 为 Python 返回的 JSON 兼容值
      • 异常:Promise reject,错误对象包含 name / message / 可选 code / data
    • auroraview.on(event: string, handler: (payload: any) => void): () => void
      • 订阅后端推送事件,返回取消订阅函数
    • auroraview.off(event: string, handler: (payload: any) => void): void
  • pywebview 风格语法糖:auroraview.api
    • 通过 JS Proxy 映射:auroraview.api.foo(...args)auroraview.call("api.foo", args)
    • 主要服务于 PyWebView 用户迁移场景
  • 预留字段:
    • auroraview.platform?: string (如 "standalone""maya2025-pyside6"
    • auroraview.token?: string (CSRF/session token,对齐 pywebview)
  • Ready 事件:
    • 注入完成后触发 window 级事件 "auroraviewready"
    • 前端可在该事件中安全使用 auroraview.call/on/api

auroraview.call 请求/响应协议(目标结构)

  • JS → 后端(Rust/Python)消息:

    • type: "call"
    • id: string 唯一ID(例如自增序号 + 时间戳),用于在回包中对应 Promise
    • method: string 方法名(如 "api.echo""tool.apply"
    • params: any 参数(对象/数组/单值,遵循上文的调用规则)
  • 后端 → JS 回包消息:

    • type: "call_result"
    • id: string 必须与请求中 id 完全一致
    • ok: bool 调用是否成功
    • 成功时:result: any 为返回值(JSON 兼容类型)
    • 失败时:error: { name: string; message: string; code?: string | int; data?: any }
  • JS 侧 Promise 语义:

    • 发起调用时,JS 为 id 建立一个 pending Promise
    • 收到 call_result
      • ok == trueresolve(result)
      • ok == falsereject(error)
    • 如果超时或底层报错,可在 JS 层构造 errorreject
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 48 lines · 717 tokens per session scan A 1a2d24a7093b

Subscribe to this mod's changes

05-frontend-api is a cursor rule published in the GitHub repository loonghao/auroraview (44 stars, last pushed 1mo ago), licensed MIT. It adds 717 tokens to every session, about $0.0036 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.