Index of every page on this site: llms.txt
All skills
oahc09 avatar

/cocosair-agent-session

@ed38648
by oahc09oahc09/cocosairjs3 stars
2
Run it yourself

Inspect live scenes and frames with devtools; read runtime diagnostics. Use for scoped session writes, pixel probes or duplicate requestId INVALID_ARGUMENT errors.

  • 9 files
  • 34.7 KB
  • MIT
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/oahc09/cocosairjs/cocosair-agent-session

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencescontracts.md

≈1.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Derived from the cocosair-agent-session skill and its canonical docs/source pointers; reorganized on 2026-10-11. Source annotations below identify repository inputs, not files guaranteed to ship to npm consumers.

Contracts

Runtime face (shipped on the cocosair entry):

  • AirDiagnostics is an opt-in bounded view of the native diagnostic stream, declared on the main entry (src/air/diagnostics.ts:14; in the SDK declarations it appears on AirApp as an optional diagnostics field, build/cocosair.module.d.ts, currently :55725). It exposes snapshot(), onMessage(), clear() and destroy() (src/air/diagnostics.ts:16-20).
  • Each message is truncated to 600 characters (src/air/diagnostics.ts:33) and the channel evicts to 80 distinct entries FIFO-style (src/air/diagnostics.ts:42); identical repeats bump occurrences on one bounded record (src/air/diagnostics.ts:37-39).
  • The factory createAirDiagnostics is marked @engineInternal (src/air/diagnostics.ts:23-24) and is NOT exported in the SDK declarations, so app code consumes app.diagnostics but never constructs the channel itself.

Devtools face (tools/debug/**, NOT on the runtime export; validated against source, not the .d.ts):

  • Request contract: AgentRequest is { requestId, action, targetId?, params? } (tools/debug/agent-session.ts:48-53) and every dispatch resolves to { requestId, ok: true, result } or { requestId, ok: false, error: { code, message, cause? } } (tools/debug/agent-session.ts:60-68). Error codes are INVALID_ARGUMENT / STALE_TARGET / OUT_OF_SCOPE / UNSUPPORTED_ACTION / LOAD_FAILED / SESSION_CLOSED, plus CAPTURE_FAILED for capture (tools/debug/agent-session.ts:31-38).
  • Duplicate requestId is REJECTED as INVALID_ARGUMENT, not idempotently replayed: a repeat that is still running OR settled within the 60s retention window fails (tools/debug/agent-session.ts:673-678; REQUEST_RETENTION_MS = 60_000 at :168). The window count default is DEFAULT_REQUEST_WINDOW = 256 (tools/debug/agent-session.ts:164, overridable via requestIdWindow); records past the retention time are cleared FIFO and the log is hard-capped at requestIdWindow * 2 entries (tools/debug/agent-session.ts:680-686). So 256 is the retention window SIZE, the 60000ms value is the retention TIME, and a blind write-retry never returns the original result.
  • inspectScene() returns a SceneSummary distinguishing nodeCount, componentCount, componentsByType, camera/light/renderer counts, uniqueAssetCount and a flat nodes list truncated at INSPECT_ROWS_LIMIT = 500 with a truncated flag (tools/debug/agent-session.ts:451, interface :71-84, limit :167). inspectNode(targetId) returns a NodeSummary with stable session-local id, parent/children ids, active/layer, component list, local/world transforms and optional visual observations (tools/debug/agent-session.ts:505, interface :86-108).
  • IDs are stable within a session and keyed by object identity, so two same-named nodes get different ids; a destroyed node or a replaced scene yields STALE_TARGET (tools/debug/agent-session.ts:399-440). A read-only session must inspectScene first to get its OWN ids before it can address a write (examples/automation/main.ts:170-178).
  • captureFrame() samples on the AFTER_DRAW hook: it subscribes to cc.director's EVENT_AFTER_DRAW (tools/debug/agent-session.ts:598, :641), which is the DirectorEvent.AFTER_DRAW alias (src/cocos/game/director.ts:109, aliased :240). It snapshots the scene at request time and fails with CAPTURE_FAILED if the scene was replaced before the draw, times out (default 5000ms), or the canvas yields no PNG (tools/debug/agent-session.ts:606-638).
  • getRuntimeErrors({ since, limit }) reads a capacity-bounded ring Collector keyed on the app canvas; default limit DEFAULT_ERROR_LIMIT = 200 (tools/debug/agent-session.ts:647, :163, :194), returning { errors, dropped } where dropped counts evictions (tools/debug/agent-session.ts:293-313). Categories include window-error, unhandled-rejection, shader, link, session-load, engine-warning, engine-error (tools/debug/agent-session.ts:130-137). The collector prefers the shared window.__airErrorHub dispatch channel and only installs its own window/WebGL hooks when the hub is absent (tools/debug/agent-session.ts:231-278).
  • Wiring is dev-only: createAgentSession(options) is the explicit attach factory (tools/debug/agent-session.ts:935); the dev server bundles tools/debug/** entries on demand and serves them under /__debug/, leaving cocosair external so the session shares the page's single engine instance (tools/dev/dev-server.cjs:193, :207, :337-341). The automation example demonstrates the full loop, attaching with await import('/__debug/agent-session.js') (examples/automation/main.ts:50, :89).

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at ed38648. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month
layer
subsystem
All 1 allowed tools
Read Bash
Other metadata
compatibility
Cocos AIR source checkout or installed cocosair.js package. Browser rendering requires WebGL 2; source tooling requires Node.js >=18. Use the host-provided tools and user-authorized workspace.
when_to_use
[
  "inspect the running scene or node",
  "apply a scoped change through an agent session",
  "capture a frame after drawing",
  "read runtime errors and diagnostics",
  "duplicate requestId is rejected"
]
owns
[
  "agent-session",
  "scene-inspection",
  "scoped-writes",
  "frame-capture",
  "pixel-probes",
  "runtime-diagnostics"
]
not_for
[
  "app startup or shutdown -> cocosair-application",
  "verification gates and release evidence -> cocosair-verification",
  "scene-tree implementation -> cocosair-scene-graph"
]
metadata
{
  "author": "oahc09@gmail.com",
  "version": "1.0.0",
  "last-updated": "2026-10-13",
  "description_zh": "使用开发工具观察运行时、按明确范围写入、捕获画面和读取诊断。用于实时应用检查或受控自动化,工具不属于默认运行时包。"
}

README badge

README badge for oahc09/cocosairjs/cocosair-agent-session