(Runtime: Client['Runtime'], callFrame: any, { only }: { only?: string[] } = {})
| 40 | } |
| 41 | |
| 42 | async function dumpLocalScope(Runtime: Client['Runtime'], callFrame: any, { only }: { only?: string[] } = {}) { |
| 43 | try { |
| 44 | const localScope = (callFrame.scopeChain || []).find((s: any) => s.type === 'local'); |
| 45 | if (!localScope || !localScope.object || !localScope.object.objectId) { |
| 46 | debugLog('locals: <no local scope object>'); |
| 47 | return; |
| 48 | } |
| 49 | const { result } = await Runtime.getProperties({ |
| 50 | objectId: localScope.object.objectId, |
| 51 | ownProperties: true, |
| 52 | accessorPropertiesOnly: false, |
| 53 | generatePreview: true |
| 54 | }); |
| 55 | const props = (result || []) |
| 56 | .filter((p: any) => p && p.enumerable && p.name !== 'arguments') |
| 57 | .filter((p: any) => !only || only.includes(p.name)) |
| 58 | .map((p: any) => { |
| 59 | const v: any = p.value || {}; |
| 60 | const val = Object.prototype.hasOwnProperty.call(v, 'value') ? v.value : (v.description || v.type); |
| 61 | return `${p.name}=${JSON.stringify(val)}`; |
| 62 | }); |
| 63 | debugLog('locals:', props.join(', ')); |
| 64 | } catch (e: any) { |
| 65 | debugLog('locals: <error reading locals>', e && e.message ? e.message : e); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | // MCP-style logging helpers (simulated) |
| 70 | function mcpLogCall(tool: string, params: unknown) { |
no test coverage detected