@saptools/cf-inspector 0.4.7 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -86
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Built so an AI agent (or a CI job) can drive a debugger from a single shell comm
|
|
|
10
10
|
[](./LICENSE)
|
|
11
11
|
[](https://nodejs.org)
|
|
12
12
|
|
|
13
|
-
[Install](#-install) • [Quick Start](#-quick-start) • [CLI](#-cli) • [
|
|
13
|
+
[Install](#-install) • [Quick Start](#-quick-start) • [CLI](#-cli) • [How it works](#-how-it-works)
|
|
14
14
|
|
|
15
15
|
</div>
|
|
16
16
|
|
|
@@ -282,91 +282,6 @@ cf-inspector attach --port 9229
|
|
|
282
282
|
|
|
283
283
|
---
|
|
284
284
|
|
|
285
|
-
## 🧑💻 Programmatic Usage
|
|
286
|
-
|
|
287
|
-
```ts
|
|
288
|
-
import {
|
|
289
|
-
connectInspector,
|
|
290
|
-
setBreakpoint,
|
|
291
|
-
waitForPause,
|
|
292
|
-
captureSnapshot,
|
|
293
|
-
evaluateOnFrame,
|
|
294
|
-
resume,
|
|
295
|
-
} from "@saptools/cf-inspector";
|
|
296
|
-
|
|
297
|
-
const session = await connectInspector({ port: 9229 });
|
|
298
|
-
const bp = await setBreakpoint(session, {
|
|
299
|
-
file: "src/handler.ts",
|
|
300
|
-
line: 42,
|
|
301
|
-
});
|
|
302
|
-
const pause = await waitForPause(session, { timeoutMs: 30_000 });
|
|
303
|
-
const snapshot = await captureSnapshot(session, pause, {
|
|
304
|
-
captures: ["this.user"],
|
|
305
|
-
maxValueLength: 4096,
|
|
306
|
-
});
|
|
307
|
-
const topFrame = pause.callFrames[0];
|
|
308
|
-
if (topFrame === undefined) {
|
|
309
|
-
throw new Error("Breakpoint paused without a call frame");
|
|
310
|
-
}
|
|
311
|
-
const customValue = await evaluateOnFrame(session, topFrame.callFrameId, "this.user");
|
|
312
|
-
await resume(session);
|
|
313
|
-
await session.dispose();
|
|
314
|
-
|
|
315
|
-
console.log({ bp, snapshot, customValue });
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
<details>
|
|
319
|
-
<summary><b>📚 Full export list</b></summary>
|
|
320
|
-
|
|
321
|
-
| Export | Description |
|
|
322
|
-
| --- | --- |
|
|
323
|
-
| `connectInspector(options)` | Open a CDP WebSocket session against a port |
|
|
324
|
-
| `setBreakpoint(session, location)` | Set a breakpoint by file/line + optional remote root and `hitCount` |
|
|
325
|
-
| `removeBreakpoint(session, id)` | Remove a breakpoint by id |
|
|
326
|
-
| `setPauseOnExceptions(session, state)` | Configure exception pause state: `none / uncaught / caught / all` |
|
|
327
|
-
| `waitForPause(session, options)` | Resolve when the next `Debugger.paused` event fires; supports `pauseReasons` allow-list |
|
|
328
|
-
| `captureSnapshot(session, pause, options)` | Build a structured snapshot of the paused frame. Pass `includeScopes: true` to expand scopes, `stackDepth` + `stackCaptures` for multi-frame walks, or `maxValueLength` to override the default captured value limit |
|
|
329
|
-
| `captureException(session, pause, maxValueLength)` | Materialize the exception attached to a `Debugger.paused` event |
|
|
330
|
-
| `walkStack(session, frames, options)` | Walk a call stack and evaluate per-frame expressions |
|
|
331
|
-
| `evaluateOnFrame(session, frameId, expression)` | Evaluate in a paused frame |
|
|
332
|
-
| `evaluateGlobal(session, expression)` | Evaluate against the global Runtime |
|
|
333
|
-
| `listScripts(session)` | Return the scripts the V8 instance knows about |
|
|
334
|
-
| `resume(session)` | Resume execution |
|
|
335
|
-
| `streamLogpoint(session, options)` | Stream a non-pausing logpoint until duration / signal / max-events / transport-close |
|
|
336
|
-
| `buildLogpointCondition(sentinel, expression, options?)` | Build the CDP `condition` string for a logpoint with optional predicate / hit-count gates |
|
|
337
|
-
| `buildHitCountedCondition(hitCount, key, userCondition?)` | Build the hit-count gate used by `setBreakpoint({ hitCount })` |
|
|
338
|
-
| `parseRemoteRoot(value)` | Parse a literal/regex remote-root setting |
|
|
339
|
-
| `buildBreakpointUrlRegex(input)` | Build a CDP `urlRegex` for a file path |
|
|
340
|
-
| `CfInspectorError` | Rich error class with typed `code` |
|
|
341
|
-
|
|
342
|
-
</details>
|
|
343
|
-
|
|
344
|
-
<details>
|
|
345
|
-
<summary><b>🧪 Error codes</b></summary>
|
|
346
|
-
|
|
347
|
-
| Code | When |
|
|
348
|
-
| --- | --- |
|
|
349
|
-
| `INVALID_ARGUMENT` | A numeric flag (`--port`, `--timeout`, `--duration`, …) is not a positive integer |
|
|
350
|
-
| `INVALID_BREAKPOINT` | `--bp` / `--at` is not in `file:line` form, or line is not a positive integer |
|
|
351
|
-
| `INVALID_REMOTE_ROOT` | `--remote-root` regex did not compile |
|
|
352
|
-
| `INVALID_EXPRESSION` | `--condition` or `--expr` failed to parse on V8 (`Runtime.compileScript` reported a SyntaxError) — fast-fail before the breakpoint is set |
|
|
353
|
-
| `INVALID_HIT_COUNT` | `--hit-count` is not a positive integer |
|
|
354
|
-
| `INVALID_PAUSE_TYPE` | `cf-inspector exception --type` is not one of `uncaught / caught / all` |
|
|
355
|
-
| `BREAKPOINT_DID_NOT_BIND` | Reserved: a breakpoint resolved to no scripts. Currently surfaced as a stderr warning only — see `BreakpointHandle.resolvedLocations` for programmatic detection |
|
|
356
|
-
| `INSPECTOR_DISCOVERY_FAILED` | `/json/list` did not return a usable WebSocket URL |
|
|
357
|
-
| `INSPECTOR_CONNECTION_FAILED` | WebSocket handshake failed, or the connection closed mid-request |
|
|
358
|
-
| `CDP_REQUEST_FAILED` | A CDP method returned an error result, timed out, or failed to send |
|
|
359
|
-
| `BREAKPOINT_NOT_HIT` | The breakpoint did not hit before the timeout elapsed |
|
|
360
|
-
| `UNRELATED_PAUSE` | The target paused somewhere else and `--fail-on-unmatched-pause` was enabled |
|
|
361
|
-
| `UNRELATED_PAUSE_TIMEOUT` | The target stayed paused somewhere else until the snapshot timeout elapsed |
|
|
362
|
-
| `EVALUATION_FAILED` | Reserved for future use — current evaluation paths surface remote exceptions inline via `CapturedExpression.error` instead of throwing |
|
|
363
|
-
| `MISSING_TARGET` | Neither `--port` nor a complete CF target (`--region/--org/--space/--app`) was provided |
|
|
364
|
-
| `ABORTED` | Reserved for future use by long-running streams when an `AbortSignal` fires |
|
|
365
|
-
|
|
366
|
-
</details>
|
|
367
|
-
|
|
368
|
-
---
|
|
369
|
-
|
|
370
285
|
## 🔭 How it works
|
|
371
286
|
|
|
372
287
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saptools/cf-inspector",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"description": "Set breakpoints, capture variable snapshots, and evaluate expressions on a SAP BTP Cloud Foundry Node.js app via the Chrome DevTools Protocol — agent-friendly, no IDE required.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"url": "https://github.com/dongitran/saptools/issues"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@saptools/cf-debugger": "^0.1.
|
|
53
|
+
"@saptools/cf-debugger": "^0.1.13",
|
|
54
54
|
"commander": "^13.0.0",
|
|
55
55
|
"ws": "^8.21.0"
|
|
56
56
|
},
|