|
| 1 | +--- |
| 2 | +name: runtime |
| 3 | +description: Runtime inspection workflows for agent-cdp. Use after reading the core skill and selecting a target. Covers expression evaluation, preserved remote object handles, property inspection, and explicit release for Chrome, Node.js, and React Native targets. |
| 4 | +allowed-tools: Bash(agent-cdp:*) |
| 5 | +--- |
| 6 | + |
| 7 | +# agent-cdp runtime |
| 8 | + |
| 9 | +Use `runtime` when you need live state inspection against the currently selected target. |
| 10 | + |
| 11 | +This is the fastest path for an LLM agent to answer questions like: |
| 12 | + |
| 13 | +- What is the current value of a global or module-level variable? |
| 14 | +- What properties exist on this object right now? |
| 15 | +- Does the runtime state match what the logs suggest? |
| 16 | + |
| 17 | +## Commands |
| 18 | + |
| 19 | +```bash |
| 20 | +agent-cdp runtime eval --expr EXPR [--await] [--json] |
| 21 | +agent-cdp runtime props --id OBJECT_ID [--own] [--accessor-properties-only] |
| 22 | +agent-cdp runtime release --id OBJECT_ID |
| 23 | +agent-cdp runtime release-group [--group NAME] |
| 24 | +``` |
| 25 | + |
| 26 | +## Safe workflow |
| 27 | + |
| 28 | +```bash |
| 29 | +agent-cdp runtime eval --expr "globalThis.store" |
| 30 | +agent-cdp runtime props --id <OBJECT_ID> --own |
| 31 | +agent-cdp runtime release --id <OBJECT_ID> |
| 32 | +``` |
| 33 | + |
| 34 | +If you evaluate several objects during a session, release the whole group when done: |
| 35 | + |
| 36 | +```bash |
| 37 | +agent-cdp runtime release-group |
| 38 | +``` |
| 39 | + |
| 40 | +## Preserved by default |
| 41 | + |
| 42 | +Runtime object handles are preserved by default. |
| 43 | + |
| 44 | +That means: |
| 45 | + |
| 46 | +- `runtime eval` may return an `objectId` for a live remote object |
| 47 | +- you can pass that `objectId` to `runtime props` |
| 48 | +- the handle stays available until you explicitly release it or release its group |
| 49 | + |
| 50 | +This is intentional because LLM agents often need a follow-up inspection step after evaluation. |
| 51 | + |
| 52 | +Releasing a handle does not delete the real application object. It only drops the inspector-side reference used by the debugging session. |
| 53 | + |
| 54 | +## `objectId` and object groups |
| 55 | + |
| 56 | +- `objectId` is a remote inspector handle, not a serialized value |
| 57 | +- preserved handles are placed in the default group `agent-cdp-runtime` |
| 58 | +- use `runtime release --id ...` for one handle |
| 59 | +- use `runtime release-group` to clean up the default group in bulk |
| 60 | + |
| 61 | +In long-lived daemon sessions, release handles you no longer need. |
| 62 | + |
| 63 | +## Side effects |
| 64 | + |
| 65 | +`runtime eval` runs code in the target runtime. It is not automatically read-only. |
| 66 | + |
| 67 | +Prefer expressions that inspect state without mutating it, for example: |
| 68 | + |
| 69 | +```bash |
| 70 | +agent-cdp runtime eval --expr "process.version" |
| 71 | +agent-cdp runtime eval --expr "globalThis.__APP_STATE__" |
| 72 | +agent-cdp runtime eval --expr "Array.isArray(globalThis.items) ? globalThis.items.length : null" |
| 73 | +``` |
| 74 | + |
| 75 | +Avoid expressions that trigger writes, network calls, or state transitions unless you mean to do that. |
| 76 | + |
| 77 | +## Cross-target notes |
| 78 | + |
| 79 | +The Runtime commands are intended to work with: |
| 80 | + |
| 81 | +- Chrome / Chromium pages with CDP enabled |
| 82 | +- Node.js processes started with `--inspect` or `--inspect-brk` |
| 83 | +- React Native targets exposed through Metro / the RN debugger endpoint |
| 84 | + |
| 85 | +Examples: |
| 86 | + |
| 87 | +```bash |
| 88 | +agent-cdp target list --url http://localhost:9222 |
| 89 | +agent-cdp target list --url http://localhost:9229 |
| 90 | +agent-cdp target list --url http://localhost:8081 |
| 91 | +``` |
| 92 | + |
| 93 | +Then select the target and inspect runtime state. |
| 94 | + |
| 95 | +## React Native / Hermes promises |
| 96 | + |
| 97 | +On React Native targets backed by Hermes, do not assume `runtime eval --await` will unwrap a promise into its fulfillment value. |
| 98 | + |
| 99 | +Some Hermes targets also reject `async`/`await` syntax at parse time, so avoid using async functions as a probe unless you have already confirmed the target accepts them. |
| 100 | + |
| 101 | +If `--await` returns a promise handle instead of the resolved value: |
| 102 | + |
| 103 | +1. Re-run `runtime eval` without `--await` to get the remote object handle. |
| 104 | +2. Inspect the handle with `runtime props --id <OBJECT_ID> --own`. |
| 105 | +3. Look for Hermes promise internals such as `_h`, `_i`, `_j`, and `_k`. |
| 106 | +4. In practice, `_j` often holds the fulfilled value once the promise settles, while `_k` may be `null`. |
| 107 | +5. If you only need to confirm settlement, treat a non-null `_j` as the most useful clue and avoid assuming the inspector will serialize the resolved value for you. |
| 108 | + |
| 109 | +Use this workflow for debugging RN promise state instead of relying on native async syntax or promise unwrapping in the inspector path. |
0 commit comments