react-native-mcp-kit 3.0.1 → 4.1.0
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 +25 -13
- package/dist/babel/testIdPlugin.d.ts.map +1 -1
- package/dist/babel/testIdPlugin.js +22 -13
- package/dist/babel/testIdPlugin.js.map +1 -1
- package/dist/bin/ios-hid +0 -0
- package/dist/client/contexts/McpContext/McpProvider.d.ts.map +1 -1
- package/dist/client/contexts/McpContext/McpProvider.js +5 -5
- package/dist/client/contexts/McpContext/McpProvider.js.map +1 -1
- package/dist/client/core/McpClient.d.ts.map +1 -1
- package/dist/client/core/McpClient.js +42 -34
- package/dist/client/core/McpClient.js.map +1 -1
- package/dist/modules/alert/alert.d.ts.map +1 -1
- package/dist/modules/alert/alert.js +2 -5
- package/dist/modules/alert/alert.js.map +1 -1
- package/dist/modules/console/console.d.ts.map +1 -1
- package/dist/modules/console/console.js +32 -107
- package/dist/modules/console/console.js.map +1 -1
- package/dist/modules/console/types.d.ts +1 -0
- package/dist/modules/console/types.d.ts.map +1 -1
- package/dist/modules/device/device.d.ts.map +1 -1
- package/dist/modules/device/device.js +224 -133
- package/dist/modules/device/device.js.map +1 -1
- package/dist/modules/errors/errors.d.ts.map +1 -1
- package/dist/modules/errors/errors.js +19 -36
- package/dist/modules/errors/errors.js.map +1 -1
- package/dist/modules/fiberTree/children.d.ts +49 -0
- package/dist/modules/fiberTree/children.d.ts.map +1 -0
- package/dist/modules/fiberTree/children.js +182 -0
- package/dist/modules/fiberTree/children.js.map +1 -0
- package/dist/modules/fiberTree/constants.d.ts +13 -0
- package/dist/modules/fiberTree/constants.d.ts.map +1 -0
- package/dist/modules/fiberTree/constants.js +24 -0
- package/dist/modules/fiberTree/constants.js.map +1 -0
- package/dist/modules/fiberTree/fiberTree.d.ts +3 -6
- package/dist/modules/fiberTree/fiberTree.d.ts.map +1 -1
- package/dist/modules/fiberTree/fiberTree.js +219 -1080
- package/dist/modules/fiberTree/fiberTree.js.map +1 -1
- package/dist/modules/fiberTree/finder.d.ts +60 -0
- package/dist/modules/fiberTree/finder.d.ts.map +1 -0
- package/dist/modules/fiberTree/finder.js +107 -0
- package/dist/modules/fiberTree/finder.js.map +1 -0
- package/dist/modules/fiberTree/hooks.d.ts +103 -0
- package/dist/modules/fiberTree/hooks.d.ts.map +1 -0
- package/dist/modules/fiberTree/hooks.js +532 -0
- package/dist/modules/fiberTree/hooks.js.map +1 -0
- package/dist/modules/fiberTree/projection.d.ts +49 -0
- package/dist/modules/fiberTree/projection.d.ts.map +1 -0
- package/dist/modules/fiberTree/projection.js +82 -0
- package/dist/modules/fiberTree/projection.js.map +1 -0
- package/dist/modules/fiberTree/query.d.ts +56 -0
- package/dist/modules/fiberTree/query.d.ts.map +1 -0
- package/dist/modules/fiberTree/query.js +151 -0
- package/dist/modules/fiberTree/query.js.map +1 -0
- package/dist/modules/fiberTree/redact.d.ts +24 -0
- package/dist/modules/fiberTree/redact.d.ts.map +1 -0
- package/dist/modules/fiberTree/redact.js +51 -0
- package/dist/modules/fiberTree/redact.js.map +1 -0
- package/dist/modules/fiberTree/types.d.ts +7 -0
- package/dist/modules/fiberTree/types.d.ts.map +1 -1
- package/dist/modules/fiberTree/utils.d.ts +8 -2
- package/dist/modules/fiberTree/utils.d.ts.map +1 -1
- package/dist/modules/fiberTree/utils.js +79 -78
- package/dist/modules/fiberTree/utils.js.map +1 -1
- package/dist/modules/fiberTree/viewport.d.ts +28 -0
- package/dist/modules/fiberTree/viewport.d.ts.map +1 -0
- package/dist/modules/fiberTree/viewport.js +50 -0
- package/dist/modules/fiberTree/viewport.js.map +1 -0
- package/dist/modules/fiberTree/waitFor.d.ts +52 -0
- package/dist/modules/fiberTree/waitFor.d.ts.map +1 -0
- package/dist/modules/fiberTree/waitFor.js +98 -0
- package/dist/modules/fiberTree/waitFor.js.map +1 -0
- package/dist/modules/logBox/logBox.d.ts.map +1 -1
- package/dist/modules/logBox/logBox.js +59 -66
- package/dist/modules/logBox/logBox.js.map +1 -1
- package/dist/modules/navigation/navigation.d.ts.map +1 -1
- package/dist/modules/navigation/navigation.js +115 -114
- package/dist/modules/navigation/navigation.js.map +1 -1
- package/dist/modules/network/network.d.ts.map +1 -1
- package/dist/modules/network/network.js +78 -197
- package/dist/modules/network/network.js.map +1 -1
- package/dist/modules/network/types.d.ts +23 -27
- package/dist/modules/network/types.d.ts.map +1 -1
- package/dist/modules/reactQuery/reactQuery.d.ts.map +1 -1
- package/dist/modules/reactQuery/reactQuery.js +46 -52
- package/dist/modules/reactQuery/reactQuery.js.map +1 -1
- package/dist/modules/storage/storage.d.ts.map +1 -1
- package/dist/modules/storage/storage.js +20 -3
- package/dist/modules/storage/storage.js.map +1 -1
- package/dist/server/bridge.d.ts +1 -0
- package/dist/server/bridge.d.ts.map +1 -1
- package/dist/server/bridge.js +1 -0
- package/dist/server/bridge.js.map +1 -1
- package/dist/server/host/coredevice/dtx.d.ts +79 -0
- package/dist/server/host/coredevice/dtx.d.ts.map +1 -0
- package/dist/server/host/coredevice/dtx.js +453 -0
- package/dist/server/host/coredevice/dtx.js.map +1 -0
- package/dist/server/host/coredevice/nska.d.ts +6 -0
- package/dist/server/host/coredevice/nska.d.ts.map +1 -0
- package/dist/server/host/coredevice/nska.js +277 -0
- package/dist/server/host/coredevice/nska.js.map +1 -0
- package/dist/server/host/coredevice/rsd.d.ts +20 -0
- package/dist/server/host/coredevice/rsd.d.ts.map +1 -0
- package/dist/server/host/coredevice/rsd.js +244 -0
- package/dist/server/host/coredevice/rsd.js.map +1 -0
- package/dist/server/host/coredevice/screenshot.d.ts +11 -0
- package/dist/server/host/coredevice/screenshot.d.ts.map +1 -0
- package/dist/server/host/coredevice/screenshot.js +84 -0
- package/dist/server/host/coredevice/screenshot.js.map +1 -0
- package/dist/server/host/coredevice/tunnel.d.ts +29 -0
- package/dist/server/host/coredevice/tunnel.d.ts.map +1 -0
- package/dist/server/host/coredevice/tunnel.js +222 -0
- package/dist/server/host/coredevice/tunnel.js.map +1 -0
- package/dist/server/host/coredevice/xpc.d.ts +21 -0
- package/dist/server/host/coredevice/xpc.d.ts.map +1 -0
- package/dist/server/host/coredevice/xpc.js +318 -0
- package/dist/server/host/coredevice/xpc.js.map +1 -0
- package/dist/server/host/deviceResolver.d.ts +8 -0
- package/dist/server/host/deviceResolver.d.ts.map +1 -1
- package/dist/server/host/deviceResolver.js +128 -62
- package/dist/server/host/deviceResolver.js.map +1 -1
- package/dist/server/host/tools/capture.d.ts.map +1 -1
- package/dist/server/host/tools/capture.js +26 -0
- package/dist/server/host/tools/capture.js.map +1 -1
- package/dist/server/host/tools/input.js +2 -2
- package/dist/server/host/tools/input.js.map +1 -1
- package/dist/server/mcpServer.d.ts.map +1 -1
- package/dist/server/mcpServer.js +44 -3
- package/dist/server/mcpServer.js.map +1 -1
- package/dist/server/metro/eventCapture.d.ts +0 -2
- package/dist/server/metro/eventCapture.d.ts.map +1 -1
- package/dist/server/metro/eventCapture.js +1 -2
- package/dist/server/metro/eventCapture.js.map +1 -1
- package/dist/server/metro/tools/events.d.ts.map +1 -1
- package/dist/server/metro/tools/events.js +11 -11
- package/dist/server/metro/tools/events.js.map +1 -1
- package/dist/shared/projection/projectValue.d.ts +90 -0
- package/dist/shared/projection/projectValue.d.ts.map +1 -0
- package/dist/shared/projection/projectValue.js +322 -0
- package/dist/shared/projection/projectValue.js.map +1 -0
- package/dist/shared/projection/redact.d.ts +31 -0
- package/dist/shared/projection/redact.d.ts.map +1 -0
- package/dist/shared/projection/redact.js +78 -0
- package/dist/shared/projection/redact.js.map +1 -0
- package/dist/shared/projection/resolvePath.d.ts +45 -0
- package/dist/shared/projection/resolvePath.d.ts.map +1 -0
- package/dist/shared/projection/resolvePath.js +211 -0
- package/dist/shared/projection/resolvePath.js.map +1 -0
- package/dist/shared/protocol.d.ts +2 -1
- package/dist/shared/protocol.d.ts.map +1 -1
- package/dist/shared/protocol.js +1 -1
- package/dist/shared/rn/core.d.ts +48 -0
- package/dist/shared/rn/core.d.ts.map +1 -0
- package/dist/shared/rn/core.js +100 -0
- package/dist/shared/rn/core.js.map +1 -0
- package/dist/shared/rn/deviceInfo.d.ts +40 -0
- package/dist/shared/rn/deviceInfo.d.ts.map +1 -0
- package/dist/shared/rn/deviceInfo.js +78 -0
- package/dist/shared/rn/deviceInfo.js.map +1 -0
- package/package.json +4 -2
- package/dist/client/hooks/useMcpState.d.ts +0 -3
- package/dist/client/hooks/useMcpState.d.ts.map +0 -1
- package/dist/client/hooks/useMcpState.js +0 -20
- package/dist/client/hooks/useMcpState.js.map +0 -1
- package/dist/server/canonicalize.d.ts +0 -8
- package/dist/server/canonicalize.d.ts.map +0 -1
- package/dist/server/canonicalize.js +0 -23
- package/dist/server/canonicalize.js.map +0 -1
- package/dist/server/host/modules/screenshot.d.ts +0 -4
- package/dist/server/host/modules/screenshot.d.ts.map +0 -1
- package/dist/server/host/modules/screenshot.js +0 -615
- package/dist/server/host/modules/screenshot.js.map +0 -1
- package/dist/server/host/tools/connectionStatus.d.ts +0 -9
- package/dist/server/host/tools/connectionStatus.d.ts.map +0 -1
- package/dist/server/host/tools/connectionStatus.js +0 -39
- package/dist/server/host/tools/connectionStatus.js.map +0 -1
- package/dist/server/host/tools/symbolicate.d.ts +0 -3
- package/dist/server/host/tools/symbolicate.d.ts.map +0 -1
- package/dist/server/host/tools/symbolicate.js +0 -209
- package/dist/server/host/tools/symbolicate.js.map +0 -1
- package/dist/server/host/wda.d.ts +0 -15
- package/dist/server/host/wda.d.ts.map +0 -1
- package/dist/server/host/wda.js +0 -100
- package/dist/server/host/wda.js.map +0 -1
- package/dist/server/inputSchemaToZod.d.ts +0 -19
- package/dist/server/inputSchemaToZod.d.ts.map +0 -1
- package/dist/server/inputSchemaToZod.js +0 -89
- package/dist/server/inputSchemaToZod.js.map +0 -1
- package/dist/server/metro/tools/openUrl.d.ts +0 -3
- package/dist/server/metro/tools/openUrl.d.ts.map +0 -1
- package/dist/server/metro/tools/openUrl.js +0 -71
- package/dist/server/metro/tools/openUrl.js.map +0 -1
- package/dist/shared/slice.d.ts +0 -16
- package/dist/shared/slice.d.ts.map +0 -1
- package/dist/shared/slice.js +0 -29
- package/dist/shared/slice.js.map +0 -1
|
@@ -3,26 +3,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getEventsTool = void 0;
|
|
4
4
|
const eventCapture_1 = require("../../../server/metro/eventCapture");
|
|
5
5
|
const resolveMetroUrl_1 = require("../../../server/metro/resolveMetroUrl");
|
|
6
|
-
const
|
|
6
|
+
const projectValue_1 = require("../../../shared/projection/projectValue");
|
|
7
|
+
// Default depth 4 — top-level outer ({metroUrl,connected,events,lastError,total})
|
|
8
|
+
// (1) → events array (2) → event (3) → data (4). Heavy event payloads collapse
|
|
9
|
+
// past depth 4 to markers; drill via path.
|
|
10
|
+
const EVENTS_DEFAULT_DEPTH = 4;
|
|
11
|
+
const PROJECTION_SCHEMA = (0, projectValue_1.makeProjectionSchema)(EVENTS_DEFAULT_DEPTH);
|
|
7
12
|
const getEventsTool = () => {
|
|
8
13
|
return {
|
|
9
14
|
description: `Read recent Metro reporter events from a server-side ring buffer fed by Metro's WebSocket \`/events\` stream.
|
|
10
15
|
|
|
11
16
|
Metro emits events for the whole bundler lifecycle — \`bundle_build_started\` / \`bundle_build_done\` / \`bundle_build_failed\`, \`bundling_error\`, \`hmr_update\`, \`hmr_client_error\`, \`initial_update_done\`, \`transform_cache_reset\`, \`dep_graph_loading\` / \`dep_graph_loaded\`, \`client_log\`, \`worker_stdout_chunk\` / \`worker_stderr_chunk\`. When an agent edits a file and HMR silently fails (syntax error, broken import), the red box may not appear — but the \`bundling_error\` / \`hmr_client_error\` event already explains why.
|
|
12
17
|
|
|
13
|
-
The capture is lazy (connects on first call) and auto-reconnects. Buffer holds the last 200 events. Pass \`since: <msEpoch>\` to get only what arrived after a known checkpoint
|
|
18
|
+
The capture is lazy (connects on first call) and auto-reconnects. Buffer holds the last 200 events. Pass \`since: <msEpoch>\` to get only what arrived after a known checkpoint. \`type\` filters to one or several event types.
|
|
14
19
|
|
|
15
|
-
Each event
|
|
20
|
+
Each event: \`{ id, receivedAt, type, data }\`; \`data\` is the raw Metro payload minus the \`type\` field. Response accepts path / depth / maxBytes (default depth ${EVENTS_DEFAULT_DEPTH}).`,
|
|
16
21
|
handler: async (args, ctx) => {
|
|
17
22
|
const metroUrl = (0, resolveMetroUrl_1.resolveMetroUrl)(args, ctx);
|
|
18
23
|
const capture = (0, eventCapture_1.getEventCapture)(metroUrl);
|
|
19
24
|
const type = args.type;
|
|
20
25
|
const since = typeof args.since === 'number' ? args.since : undefined;
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
return { metroUrl, ...result };
|
|
26
|
+
const result = capture.getEvents({ since, type });
|
|
27
|
+
return (0, projectValue_1.applyProjection)({ metroUrl, ...result }, args, projectValue_1.projectAsValue, EVENTS_DEFAULT_DEPTH);
|
|
24
28
|
},
|
|
25
29
|
inputSchema: {
|
|
30
|
+
...PROJECTION_SCHEMA,
|
|
26
31
|
clientId: {
|
|
27
32
|
description: 'Target client ID — used to pick up the Metro URL the app was loaded from (falls back to `metroUrl` or the hardcoded default).',
|
|
28
33
|
type: 'string',
|
|
@@ -35,11 +40,6 @@ Each event has \`{ id, receivedAt, type, data }\`; \`data\` is the raw Metro pay
|
|
|
35
40
|
description: 'Only return events with `receivedAt >= since` (ms since epoch).',
|
|
36
41
|
type: 'number',
|
|
37
42
|
},
|
|
38
|
-
slice: {
|
|
39
|
-
description: (0, slice_1.sliceSchemaDescription)('Default [-50] = the newest 50.'),
|
|
40
|
-
examples: [[-10], [-20, -10], [0]],
|
|
41
|
-
type: 'array',
|
|
42
|
-
},
|
|
43
43
|
type: {
|
|
44
44
|
description: 'Filter by event type. Accepts a single string or an array of types (OR semantics).',
|
|
45
45
|
examples: ['bundling_error', ['bundling_error', 'hmr_client_error', 'bundle_build_failed']],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../../src/server/metro/tools/events.ts"],"names":[],"mappings":";;;AACA,8DAA8D;AAC9D,oEAAiE;AACjE,
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../../src/server/metro/tools/events.ts"],"names":[],"mappings":";;;AACA,8DAA8D;AAC9D,oEAAiE;AACjE,mEAK0C;AAE1C,kFAAkF;AAClF,+EAA+E;AAC/E,2CAA2C;AAC3C,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAE/B,MAAM,iBAAiB,GAAG,IAAA,mCAAoB,EAAC,oBAAoB,CAAC,CAAC;AAE9D,MAAM,aAAa,GAAG,GAAoB,EAAE;IACjD,OAAO;QACL,WAAW,EAAE;;;;;;sKAMqJ,oBAAoB,IAAI;QAC1L,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;YAC3B,MAAM,QAAQ,GAAG,IAAA,iCAAe,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAC5C,MAAM,OAAO,GAAG,IAAA,8BAAe,EAAC,QAAQ,CAAC,CAAC;YAE1C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAqC,CAAC;YACxD,MAAM,KAAK,GAAG,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;YAEtE,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAClD,OAAO,IAAA,8BAAe,EACpB,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,EACvB,IAAsB,EACtB,6BAAc,EACd,oBAAoB,CACrB,CAAC;QACJ,CAAC;QACD,WAAW,EAAE;YACX,GAAG,iBAAiB;YACpB,QAAQ,EAAE;gBACR,WAAW,EACT,+HAA+H;gBACjI,IAAI,EAAE,QAAQ;aACf;YACD,QAAQ,EAAE;gBACR,WAAW,EAAE,wHAAwH;gBACrI,IAAI,EAAE,QAAQ;aACf;YACD,KAAK,EAAE;gBACL,WAAW,EAAE,iEAAiE;gBAC9E,IAAI,EAAE,QAAQ;aACf;YACD,IAAI,EAAE;gBACJ,WAAW,EACT,oFAAoF;gBACtF,QAAQ,EAAE,CAAC,gBAAgB,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,qBAAqB,CAAC,CAAC;aAC5F;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AA9CW,QAAA,aAAa,iBA8CxB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { type RedactPatterns } from './redact';
|
|
2
|
+
/**
|
|
3
|
+
* Single canonical "render this value into a compact, agent-friendly JSON"
|
|
4
|
+
* primitive. Replaces the per-module serializers (`fiberTree:serializeValue`,
|
|
5
|
+
* `console:serializeArg`, `network:captureBody`).
|
|
6
|
+
*
|
|
7
|
+
* Behaviour:
|
|
8
|
+
* - Walks the value to depth `depth` (default 1, max 8).
|
|
9
|
+
* - Containers expanded inside the depth budget → raw JSON.
|
|
10
|
+
* - Containers beyond depth, or specials (Date/Error/etc.) → string-keyed
|
|
11
|
+
* sentinel marker `{ "${kind}": meta }` (see plan §2 for full table).
|
|
12
|
+
* - Wide containers are width-capped: 30 keys for objects, 50 items for
|
|
13
|
+
* arrays; the cut adds a `${truncated}` sentinel as the FIRST entry of
|
|
14
|
+
* the container.
|
|
15
|
+
* - Long strings (> previewCap) become `{ "${str}": { "len": N, "preview": "..." } }`.
|
|
16
|
+
* - Cycles → `{ "${cyc}": true }`.
|
|
17
|
+
* - Pluggable `collapse` rules let modules detect domain-specific shapes
|
|
18
|
+
* (fiberTree component refs) and replace them with their own marker.
|
|
19
|
+
* - Optional `path` — resolves the path inside `input` first; then projects
|
|
20
|
+
* the resolved subtree under the same rules. Path slice (`[N:M]`) overrides
|
|
21
|
+
* the default container width-cap for that specific level.
|
|
22
|
+
*/
|
|
23
|
+
export declare const DEFAULT_DEPTH = 1;
|
|
24
|
+
export declare const MAX_DEPTH = 8;
|
|
25
|
+
export declare const DEFAULT_OBJECT_CAP = 30;
|
|
26
|
+
export declare const DEFAULT_ARRAY_CAP = 50;
|
|
27
|
+
export declare const DEFAULT_PREVIEW_CAP = 100;
|
|
28
|
+
export declare const DEFAULT_MAX_BYTES = 50000;
|
|
29
|
+
export type CollapseRule = (value: unknown) => Record<string, unknown> | undefined;
|
|
30
|
+
export interface ProjectOptions {
|
|
31
|
+
collapse?: ReadonlyArray<CollapseRule>;
|
|
32
|
+
depth?: number;
|
|
33
|
+
maxBytes?: number;
|
|
34
|
+
path?: string;
|
|
35
|
+
previewCap?: number;
|
|
36
|
+
redact?: RedactPatterns;
|
|
37
|
+
skipKeys?: ReadonlyArray<string | RegExp>;
|
|
38
|
+
}
|
|
39
|
+
export interface ProjectResult {
|
|
40
|
+
bytes: number;
|
|
41
|
+
truncated: boolean;
|
|
42
|
+
value: unknown;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Standard `path` / `depth` / `maxBytes` arg shape for any tool that returns
|
|
46
|
+
* heavy JSON. Modules call `makeProjectionSchema(defaultDepth)` to get a
|
|
47
|
+
* description string that reflects their per-tool default, and spread the
|
|
48
|
+
* result into their inputSchema. Args are then funnelled through
|
|
49
|
+
* `applyProjection` at the handler exit.
|
|
50
|
+
*/
|
|
51
|
+
export declare const makeProjectionSchema: (defaultDepth?: number) => Record<string, {
|
|
52
|
+
description: string;
|
|
53
|
+
type: string;
|
|
54
|
+
examples?: unknown[];
|
|
55
|
+
}>;
|
|
56
|
+
/** Default-depth projection schema — for modules that don't override depth. */
|
|
57
|
+
export declare const PROJECTION_SCHEMA: Record<string, {
|
|
58
|
+
description: string;
|
|
59
|
+
type: string;
|
|
60
|
+
examples?: unknown[];
|
|
61
|
+
}>;
|
|
62
|
+
export interface ProjectionArgs {
|
|
63
|
+
depth?: number;
|
|
64
|
+
maxBytes?: number;
|
|
65
|
+
path?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A projector function — takes a raw value + options, returns an
|
|
69
|
+
* agent-friendly projected value. Modules can plug in `projectFiberValue`
|
|
70
|
+
* (with fiber-aware collapse rules) or call `projectValue` directly.
|
|
71
|
+
*/
|
|
72
|
+
export type Projector = (value: unknown, options: ProjectOptions) => unknown;
|
|
73
|
+
/**
|
|
74
|
+
* Convenience wrapper around `projectValue` that returns just the projected
|
|
75
|
+
* value (drops the `{ bytes, truncated }` envelope). Most module handlers
|
|
76
|
+
* want this form when they don't need byte-cap telemetry.
|
|
77
|
+
*/
|
|
78
|
+
export declare const projectAsValue: Projector;
|
|
79
|
+
/**
|
|
80
|
+
* Standard handler-exit hook. Call this on the final raw response with the
|
|
81
|
+
* tool's args; it pulls `path`/`depth`/`maxBytes` and forwards to the given
|
|
82
|
+
* projector. Modules may override `defaultDepth` per-tool (e.g. fiberTree
|
|
83
|
+
* uses 2 because its top-level shape is an array of matches and depth 1
|
|
84
|
+
* would collapse the array itself into a marker).
|
|
85
|
+
*/
|
|
86
|
+
export declare const applyProjection: (result: unknown, args: ProjectionArgs, projector: Projector, defaultDepth?: number) => unknown;
|
|
87
|
+
declare const isMarker: (v: unknown) => boolean;
|
|
88
|
+
export declare const projectValue: (input: unknown, options?: ProjectOptions) => ProjectResult;
|
|
89
|
+
export { isMarker };
|
|
90
|
+
//# sourceMappingURL=projectValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectValue.d.ts","sourceRoot":"","sources":["../../../src/shared/projection/projectValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAG7E;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,SAAS,IAAI,CAAC;AAC3B,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,mBAAmB,MAAM,CAAC;A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;;;;GAMG;AACH,eAAO,MAAM,eAAe,WAClB,OAAO,QACT,cAAc,aACT,SAAS,iBACN,MAAM,KACnB,OAMF,CAAC;AAQF,QAAA,MAAM,QAAQ,MAAO,OAAO,KAAG,OAI9B,CAAC;AA8IF,eAAO,MAAM,YAAY,UAAW,OAAO,YAAY,cAAc,KAAG,aA8EvE,CAAC;AAiBF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isMarker = exports.projectValue = exports.applyProjection = exports.projectAsValue = exports.PROJECTION_SCHEMA = exports.makeProjectionSchema = exports.DEFAULT_MAX_BYTES = exports.DEFAULT_PREVIEW_CAP = exports.DEFAULT_ARRAY_CAP = exports.DEFAULT_OBJECT_CAP = exports.MAX_DEPTH = exports.DEFAULT_DEPTH = void 0;
|
|
4
|
+
const redact_1 = require("./redact");
|
|
5
|
+
const resolvePath_1 = require("./resolvePath");
|
|
6
|
+
/**
|
|
7
|
+
* Single canonical "render this value into a compact, agent-friendly JSON"
|
|
8
|
+
* primitive. Replaces the per-module serializers (`fiberTree:serializeValue`,
|
|
9
|
+
* `console:serializeArg`, `network:captureBody`).
|
|
10
|
+
*
|
|
11
|
+
* Behaviour:
|
|
12
|
+
* - Walks the value to depth `depth` (default 1, max 8).
|
|
13
|
+
* - Containers expanded inside the depth budget → raw JSON.
|
|
14
|
+
* - Containers beyond depth, or specials (Date/Error/etc.) → string-keyed
|
|
15
|
+
* sentinel marker `{ "${kind}": meta }` (see plan §2 for full table).
|
|
16
|
+
* - Wide containers are width-capped: 30 keys for objects, 50 items for
|
|
17
|
+
* arrays; the cut adds a `${truncated}` sentinel as the FIRST entry of
|
|
18
|
+
* the container.
|
|
19
|
+
* - Long strings (> previewCap) become `{ "${str}": { "len": N, "preview": "..." } }`.
|
|
20
|
+
* - Cycles → `{ "${cyc}": true }`.
|
|
21
|
+
* - Pluggable `collapse` rules let modules detect domain-specific shapes
|
|
22
|
+
* (fiberTree component refs) and replace them with their own marker.
|
|
23
|
+
* - Optional `path` — resolves the path inside `input` first; then projects
|
|
24
|
+
* the resolved subtree under the same rules. Path slice (`[N:M]`) overrides
|
|
25
|
+
* the default container width-cap for that specific level.
|
|
26
|
+
*/
|
|
27
|
+
exports.DEFAULT_DEPTH = 1;
|
|
28
|
+
exports.MAX_DEPTH = 8;
|
|
29
|
+
exports.DEFAULT_OBJECT_CAP = 30;
|
|
30
|
+
exports.DEFAULT_ARRAY_CAP = 50;
|
|
31
|
+
exports.DEFAULT_PREVIEW_CAP = 100;
|
|
32
|
+
exports.DEFAULT_MAX_BYTES = 50_000;
|
|
33
|
+
/**
|
|
34
|
+
* Standard `path` / `depth` / `maxBytes` arg shape for any tool that returns
|
|
35
|
+
* heavy JSON. Modules call `makeProjectionSchema(defaultDepth)` to get a
|
|
36
|
+
* description string that reflects their per-tool default, and spread the
|
|
37
|
+
* result into their inputSchema. Args are then funnelled through
|
|
38
|
+
* `applyProjection` at the handler exit.
|
|
39
|
+
*/
|
|
40
|
+
// Reusable description shared across all tools: full path/depth/maxBytes
|
|
41
|
+
// semantics live in the server BASE_INSTRUCTIONS — schemas just reference it
|
|
42
|
+
// to keep `describe_tool` payloads small.
|
|
43
|
+
const makeProjectionSchema = (defaultDepth = exports.DEFAULT_DEPTH) => {
|
|
44
|
+
return {
|
|
45
|
+
depth: {
|
|
46
|
+
description: `Expansion depth (default ${defaultDepth}, max ${exports.MAX_DEPTH}). See server instructions § Path-based drill.`,
|
|
47
|
+
examples: [1, 3, 8],
|
|
48
|
+
type: 'number',
|
|
49
|
+
},
|
|
50
|
+
maxBytes: {
|
|
51
|
+
description: `Soft byte cap (default ${exports.DEFAULT_MAX_BYTES}). See server instructions § Path-based drill.`,
|
|
52
|
+
type: 'number',
|
|
53
|
+
},
|
|
54
|
+
path: {
|
|
55
|
+
description: 'Path drill into response (`.key`, `[N]`, `[a:b]`). See server instructions § Path-based drill for full syntax.',
|
|
56
|
+
examples: ['items[0].body', 'items[0:3].id', 'data.user.email'],
|
|
57
|
+
type: 'string',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
exports.makeProjectionSchema = makeProjectionSchema;
|
|
62
|
+
/** Default-depth projection schema — for modules that don't override depth. */
|
|
63
|
+
exports.PROJECTION_SCHEMA = (0, exports.makeProjectionSchema)();
|
|
64
|
+
/**
|
|
65
|
+
* Convenience wrapper around `projectValue` that returns just the projected
|
|
66
|
+
* value (drops the `{ bytes, truncated }` envelope). Most module handlers
|
|
67
|
+
* want this form when they don't need byte-cap telemetry.
|
|
68
|
+
*/
|
|
69
|
+
const projectAsValue = (value, options) => {
|
|
70
|
+
return (0, exports.projectValue)(value, options).value;
|
|
71
|
+
};
|
|
72
|
+
exports.projectAsValue = projectAsValue;
|
|
73
|
+
/**
|
|
74
|
+
* Standard handler-exit hook. Call this on the final raw response with the
|
|
75
|
+
* tool's args; it pulls `path`/`depth`/`maxBytes` and forwards to the given
|
|
76
|
+
* projector. Modules may override `defaultDepth` per-tool (e.g. fiberTree
|
|
77
|
+
* uses 2 because its top-level shape is an array of matches and depth 1
|
|
78
|
+
* would collapse the array itself into a marker).
|
|
79
|
+
*/
|
|
80
|
+
const applyProjection = (result, args, projector, defaultDepth = exports.DEFAULT_DEPTH) => {
|
|
81
|
+
return projector(result, {
|
|
82
|
+
depth: args.depth ?? defaultDepth,
|
|
83
|
+
maxBytes: args.maxBytes,
|
|
84
|
+
path: args.path,
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
exports.applyProjection = applyProjection;
|
|
88
|
+
const isPlainObject = (v) => {
|
|
89
|
+
if (v === null || typeof v !== 'object')
|
|
90
|
+
return false;
|
|
91
|
+
const proto = Object.getPrototypeOf(v);
|
|
92
|
+
return proto === Object.prototype || proto === null;
|
|
93
|
+
};
|
|
94
|
+
const isMarker = (v) => {
|
|
95
|
+
if (!v || typeof v !== 'object' || Array.isArray(v))
|
|
96
|
+
return false;
|
|
97
|
+
const keys = Object.keys(v);
|
|
98
|
+
return keys.length === 1 && keys[0].startsWith('${') && keys[0].endsWith('}');
|
|
99
|
+
};
|
|
100
|
+
exports.isMarker = isMarker;
|
|
101
|
+
const constructorName = (v) => {
|
|
102
|
+
const proto = Object.getPrototypeOf(v);
|
|
103
|
+
if (!proto || proto === Object.prototype)
|
|
104
|
+
return null;
|
|
105
|
+
const ctor = proto.constructor;
|
|
106
|
+
return ctor?.name ?? null;
|
|
107
|
+
};
|
|
108
|
+
const projectString = (s, previewCap) => {
|
|
109
|
+
if (s.length <= previewCap)
|
|
110
|
+
return s;
|
|
111
|
+
return { ['${str}']: { len: s.length, preview: s.slice(0, previewCap) } };
|
|
112
|
+
};
|
|
113
|
+
const projectSpecial = (v, collapse) => {
|
|
114
|
+
// built-ins first
|
|
115
|
+
if (v instanceof Date)
|
|
116
|
+
return { ['${Date}']: v.toISOString() };
|
|
117
|
+
if (v instanceof RegExp)
|
|
118
|
+
return { ['${RegExp}']: v.toString() };
|
|
119
|
+
if (v instanceof Error) {
|
|
120
|
+
return { ['${Err}']: { msg: v.message, name: v.name } };
|
|
121
|
+
}
|
|
122
|
+
if (v instanceof Map)
|
|
123
|
+
return { ['${map}']: v.size };
|
|
124
|
+
if (v instanceof Set)
|
|
125
|
+
return { ['${set}']: v.size };
|
|
126
|
+
if (typeof v === 'function') {
|
|
127
|
+
const name = v.name;
|
|
128
|
+
return { ['${fun}']: name && name.length > 0 ? name : '<anon>' };
|
|
129
|
+
}
|
|
130
|
+
if (typeof v === 'symbol') {
|
|
131
|
+
return { ['${sym}']: v.toString() };
|
|
132
|
+
}
|
|
133
|
+
// pluggable collapse rules (fiberTree component refs etc.)
|
|
134
|
+
for (const rule of collapse) {
|
|
135
|
+
const out = rule(v);
|
|
136
|
+
if (out !== undefined)
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
return undefined;
|
|
140
|
+
};
|
|
141
|
+
const collapsedContainer = (v) => {
|
|
142
|
+
if (Array.isArray(v))
|
|
143
|
+
return { ['${arr}']: v.length };
|
|
144
|
+
if (isPlainObject(v))
|
|
145
|
+
return { ['${obj}']: Object.keys(v).length };
|
|
146
|
+
if (v && typeof v === 'object') {
|
|
147
|
+
const cls = constructorName(v);
|
|
148
|
+
if (cls)
|
|
149
|
+
return { ['${cls}']: { len: Object.keys(v).length, name: cls } };
|
|
150
|
+
return { ['${obj}']: Object.keys(v).length };
|
|
151
|
+
}
|
|
152
|
+
return undefined;
|
|
153
|
+
};
|
|
154
|
+
const walkContainer = (v, depth, ctx, seen) => {
|
|
155
|
+
// strings, primitives — handled before this fn is called
|
|
156
|
+
// specials (Date, Error, ...) — handled before via projectSpecial
|
|
157
|
+
if (Array.isArray(v)) {
|
|
158
|
+
return walkArray(v, depth, ctx, seen);
|
|
159
|
+
}
|
|
160
|
+
return walkObject(v, depth, ctx, seen);
|
|
161
|
+
};
|
|
162
|
+
const walkArray = (arr, depth, ctx, seen) => {
|
|
163
|
+
const total = arr.length;
|
|
164
|
+
const cap = ctx.arrayCap;
|
|
165
|
+
const sliced = arr.slice(0, cap);
|
|
166
|
+
const out = [];
|
|
167
|
+
if (total > cap) {
|
|
168
|
+
out.push({ ['${truncated}']: { slice: [0, cap], total } });
|
|
169
|
+
}
|
|
170
|
+
for (const item of sliced) {
|
|
171
|
+
out.push(walk(item, depth - 1, ctx, seen));
|
|
172
|
+
}
|
|
173
|
+
return out;
|
|
174
|
+
};
|
|
175
|
+
const walkObject = (obj, depth, ctx, seen) => {
|
|
176
|
+
const allKeys = Object.keys(obj).filter((k) => {
|
|
177
|
+
return !matchesSkip(k, ctx);
|
|
178
|
+
});
|
|
179
|
+
const total = allKeys.length;
|
|
180
|
+
const cap = ctx.objectCap;
|
|
181
|
+
const keys = allKeys.slice(0, cap);
|
|
182
|
+
const out = {};
|
|
183
|
+
if (total > cap) {
|
|
184
|
+
out['${truncated}'] = { slice: [0, cap], total };
|
|
185
|
+
}
|
|
186
|
+
for (const k of keys) {
|
|
187
|
+
if ((0, redact_1.matchesRedact)(k, ctx.compiledRedact)) {
|
|
188
|
+
out[k] = '[redacted]';
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
out[k] = walk(obj[k], depth - 1, ctx, seen);
|
|
192
|
+
}
|
|
193
|
+
return out;
|
|
194
|
+
};
|
|
195
|
+
const matchesSkip = (key, ctx) => {
|
|
196
|
+
if (ctx.skipExact.has(key))
|
|
197
|
+
return true;
|
|
198
|
+
for (const rx of ctx.skipRegex)
|
|
199
|
+
if (rx.test(key))
|
|
200
|
+
return true;
|
|
201
|
+
return false;
|
|
202
|
+
};
|
|
203
|
+
const walk = (v, remainingDepth, ctx, seen) => {
|
|
204
|
+
// primitives
|
|
205
|
+
if (v === null || v === undefined)
|
|
206
|
+
return v;
|
|
207
|
+
const t = typeof v;
|
|
208
|
+
if (t === 'number' || t === 'boolean')
|
|
209
|
+
return v;
|
|
210
|
+
if (t === 'bigint')
|
|
211
|
+
return { ['${bigint}']: v.toString() };
|
|
212
|
+
if (t === 'string')
|
|
213
|
+
return projectString(v, ctx.previewCap);
|
|
214
|
+
// specials before container check (Map/Set/Date/etc. typeof === 'object')
|
|
215
|
+
const special = projectSpecial(v, ctx.collapse);
|
|
216
|
+
if (special !== undefined)
|
|
217
|
+
return special;
|
|
218
|
+
// cycle
|
|
219
|
+
if (typeof v === 'object' && v !== null) {
|
|
220
|
+
if (seen.has(v))
|
|
221
|
+
return { ['${cyc}']: true };
|
|
222
|
+
seen.add(v);
|
|
223
|
+
}
|
|
224
|
+
// depth exhausted — collapse to marker
|
|
225
|
+
if (remainingDepth <= 0) {
|
|
226
|
+
const collapsed = collapsedContainer(v);
|
|
227
|
+
return collapsed ?? v;
|
|
228
|
+
}
|
|
229
|
+
// expand container
|
|
230
|
+
return walkContainer(v, remainingDepth, ctx, seen);
|
|
231
|
+
};
|
|
232
|
+
const projectValue = (input, options) => {
|
|
233
|
+
const opts = options ?? {};
|
|
234
|
+
const depth = clampDepth(opts.depth ?? exports.DEFAULT_DEPTH);
|
|
235
|
+
const objectCap = exports.DEFAULT_OBJECT_CAP;
|
|
236
|
+
const arrayCap = exports.DEFAULT_ARRAY_CAP;
|
|
237
|
+
const previewCap = opts.previewCap ?? exports.DEFAULT_PREVIEW_CAP;
|
|
238
|
+
const maxBytes = opts.maxBytes ?? exports.DEFAULT_MAX_BYTES;
|
|
239
|
+
const collapse = opts.collapse ?? [];
|
|
240
|
+
const skipExact = new Set();
|
|
241
|
+
const skipRegex = [];
|
|
242
|
+
for (const k of opts.skipKeys ?? []) {
|
|
243
|
+
if (typeof k === 'string')
|
|
244
|
+
skipExact.add(k);
|
|
245
|
+
else
|
|
246
|
+
skipRegex.push(k);
|
|
247
|
+
}
|
|
248
|
+
const compiledRedact = (0, redact_1.compileRedact)(opts.redact);
|
|
249
|
+
// resolve path first (if any) — applies to the input tree, not the projection
|
|
250
|
+
let target = input;
|
|
251
|
+
let pathResolved = false;
|
|
252
|
+
if (opts.path) {
|
|
253
|
+
const res = (0, resolvePath_1.resolvePath)(input, opts.path);
|
|
254
|
+
if (!res.ok) {
|
|
255
|
+
return {
|
|
256
|
+
bytes: 0,
|
|
257
|
+
truncated: false,
|
|
258
|
+
value: { error: res.error, validUpTo: res.validUpTo },
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
target = res.value;
|
|
262
|
+
pathResolved = true;
|
|
263
|
+
}
|
|
264
|
+
// When path explicitly resolves to a string scalar, return the raw string
|
|
265
|
+
// (truncated only if it would blow the maxBytes cap). The user navigated
|
|
266
|
+
// to a leaf — they asked for the content, not a preview marker.
|
|
267
|
+
if (pathResolved && typeof target === 'string') {
|
|
268
|
+
if (target.length > maxBytes) {
|
|
269
|
+
return {
|
|
270
|
+
bytes: target.length,
|
|
271
|
+
truncated: true,
|
|
272
|
+
value: { ['${str}']: { len: target.length, preview: target.slice(0, 200) } },
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
return { bytes: target.length, truncated: false, value: target };
|
|
276
|
+
}
|
|
277
|
+
const ctx = {
|
|
278
|
+
arrayCap,
|
|
279
|
+
collapse,
|
|
280
|
+
compiledRedact,
|
|
281
|
+
objectCap,
|
|
282
|
+
previewCap,
|
|
283
|
+
skipExact,
|
|
284
|
+
skipRegex,
|
|
285
|
+
};
|
|
286
|
+
const seen = new WeakSet();
|
|
287
|
+
// walk with depth + 1 because the caller's "depth: N" means N levels of
|
|
288
|
+
// container expansion; our walk decrements before recursing into children.
|
|
289
|
+
const projected = walk(target, depth, ctx, seen);
|
|
290
|
+
// soft byte cap — if exceeded, replace with a string-marker that carries
|
|
291
|
+
// the original size + a short preview
|
|
292
|
+
const serialized = safeStringify(projected);
|
|
293
|
+
if (serialized.length > maxBytes) {
|
|
294
|
+
const preview = serialized.slice(0, Math.min(maxBytes, 200));
|
|
295
|
+
return {
|
|
296
|
+
bytes: serialized.length,
|
|
297
|
+
truncated: true,
|
|
298
|
+
value: {
|
|
299
|
+
['${str}']: {
|
|
300
|
+
len: serialized.length,
|
|
301
|
+
preview,
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
return { bytes: serialized.length, truncated: false, value: projected };
|
|
307
|
+
};
|
|
308
|
+
exports.projectValue = projectValue;
|
|
309
|
+
const clampDepth = (d) => {
|
|
310
|
+
if (!Number.isFinite(d) || d < 0)
|
|
311
|
+
return exports.DEFAULT_DEPTH;
|
|
312
|
+
return Math.min(Math.floor(d), exports.MAX_DEPTH);
|
|
313
|
+
};
|
|
314
|
+
const safeStringify = (v) => {
|
|
315
|
+
try {
|
|
316
|
+
return JSON.stringify(v) ?? '';
|
|
317
|
+
}
|
|
318
|
+
catch {
|
|
319
|
+
return '';
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
//# sourceMappingURL=projectValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectValue.js","sourceRoot":"","sources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;gBACL,CAAC,QAAQ,CAAC,EAAE;oBACV,GAAG,EAAE,UAAU,CAAC,MAAM;oBACtB,OAAO;iBACR;aACF;SACF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAC1E,CAAC,CAAC;AA9EW,QAAA,YAAY,gBA8EvB;AAEF,MAAM,UAAU,GAAG,CAAC,CAAS,EAAU,EAAE;IACvC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,qBAAa,CAAC;IACvD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,iBAAS,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,CAAU,EAAU,EAAE;IAC3C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared redact utility used by `projectValue` and modules that have their
|
|
3
|
+
* own redact lists (network headers/body keys). Extracted from `network.ts`
|
|
4
|
+
* verbatim so behaviour stays identical for existing callers.
|
|
5
|
+
*
|
|
6
|
+
* - Pattern list is `Array<string | RegExp>`. Strings are lowercased and
|
|
7
|
+
* matched as substring on lowercased keys; regexes are matched verbatim.
|
|
8
|
+
* - `false` (instead of array) — disables redaction.
|
|
9
|
+
* - `undefined` — uses provided defaults.
|
|
10
|
+
*/
|
|
11
|
+
export type RedactPatterns = ReadonlyArray<string | RegExp> | false;
|
|
12
|
+
interface CompiledRedact {
|
|
13
|
+
empty: boolean;
|
|
14
|
+
exact: Set<string>;
|
|
15
|
+
regexes: RegExp[];
|
|
16
|
+
}
|
|
17
|
+
export declare const compileRedact: (list: RedactPatterns | undefined, defaults?: ReadonlyArray<string | RegExp>) => CompiledRedact | null;
|
|
18
|
+
export declare const matchesRedact: (key: string, compiled: CompiledRedact | null) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Walk an object/array graph; replace value of any key matching a redact
|
|
21
|
+
* pattern with `[redacted]`. Preserves shape so caller still sees the field
|
|
22
|
+
* exists. Used by network for request/response bodies; also re-exported for
|
|
23
|
+
* `projectValue` which inlines the same matcher in its walk.
|
|
24
|
+
*/
|
|
25
|
+
export declare const redactValue: (value: unknown, compiled: CompiledRedact | null) => unknown;
|
|
26
|
+
/**
|
|
27
|
+
* Redact a flat headers map (case-insensitive on key names).
|
|
28
|
+
*/
|
|
29
|
+
export declare const redactHeaders: (headers: Record<string, string>, compiled: CompiledRedact | null) => Record<string, string>;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=redact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../../src/shared/projection/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,MAAM,cAAc,GAAG,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC;AAEpE,UAAU,cAAc;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,eAAO,MAAM,aAAa,SAClB,cAAc,GAAG,SAAS,aACtB,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,KACvC,cAAc,GAAG,IAUnB,CAAC;AAEF,eAAO,MAAM,aAAa,QAAS,MAAM,YAAY,cAAc,GAAG,IAAI,KAAG,OAQ5E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,UAAW,OAAO,YAAY,cAAc,GAAG,IAAI,KAAG,OAa7E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,YACf,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,YACrB,cAAc,GAAG,IAAI,KAC9B,MAAM,CAAC,MAAM,EAAE,MAAM,CAOvB,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared redact utility used by `projectValue` and modules that have their
|
|
4
|
+
* own redact lists (network headers/body keys). Extracted from `network.ts`
|
|
5
|
+
* verbatim so behaviour stays identical for existing callers.
|
|
6
|
+
*
|
|
7
|
+
* - Pattern list is `Array<string | RegExp>`. Strings are lowercased and
|
|
8
|
+
* matched as substring on lowercased keys; regexes are matched verbatim.
|
|
9
|
+
* - `false` (instead of array) — disables redaction.
|
|
10
|
+
* - `undefined` — uses provided defaults.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.redactHeaders = exports.redactValue = exports.matchesRedact = exports.compileRedact = void 0;
|
|
14
|
+
const compileRedact = (list, defaults = []) => {
|
|
15
|
+
if (list === false)
|
|
16
|
+
return null;
|
|
17
|
+
const src = list === undefined ? defaults : list;
|
|
18
|
+
const exact = new Set();
|
|
19
|
+
const regexes = [];
|
|
20
|
+
for (const item of src) {
|
|
21
|
+
if (typeof item === 'string')
|
|
22
|
+
exact.add(item.toLowerCase());
|
|
23
|
+
else
|
|
24
|
+
regexes.push(item);
|
|
25
|
+
}
|
|
26
|
+
return { empty: exact.size === 0 && regexes.length === 0, exact, regexes };
|
|
27
|
+
};
|
|
28
|
+
exports.compileRedact = compileRedact;
|
|
29
|
+
const matchesRedact = (key, compiled) => {
|
|
30
|
+
if (!compiled || compiled.empty)
|
|
31
|
+
return false;
|
|
32
|
+
const lower = key.toLowerCase();
|
|
33
|
+
if (compiled.exact.has(lower))
|
|
34
|
+
return true;
|
|
35
|
+
for (const rx of compiled.regexes) {
|
|
36
|
+
if (rx.test(key))
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
};
|
|
41
|
+
exports.matchesRedact = matchesRedact;
|
|
42
|
+
/**
|
|
43
|
+
* Walk an object/array graph; replace value of any key matching a redact
|
|
44
|
+
* pattern with `[redacted]`. Preserves shape so caller still sees the field
|
|
45
|
+
* exists. Used by network for request/response bodies; also re-exported for
|
|
46
|
+
* `projectValue` which inlines the same matcher in its walk.
|
|
47
|
+
*/
|
|
48
|
+
const redactValue = (value, compiled) => {
|
|
49
|
+
if (!compiled || compiled.empty)
|
|
50
|
+
return value;
|
|
51
|
+
if (value === null || typeof value !== 'object')
|
|
52
|
+
return value;
|
|
53
|
+
if (Array.isArray(value)) {
|
|
54
|
+
return value.map((item) => {
|
|
55
|
+
return (0, exports.redactValue)(item, compiled);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const out = {};
|
|
59
|
+
for (const [key, v] of Object.entries(value)) {
|
|
60
|
+
out[key] = (0, exports.matchesRedact)(key, compiled) ? '[redacted]' : (0, exports.redactValue)(v, compiled);
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
};
|
|
64
|
+
exports.redactValue = redactValue;
|
|
65
|
+
/**
|
|
66
|
+
* Redact a flat headers map (case-insensitive on key names).
|
|
67
|
+
*/
|
|
68
|
+
const redactHeaders = (headers, compiled) => {
|
|
69
|
+
if (!compiled || compiled.empty)
|
|
70
|
+
return headers;
|
|
71
|
+
const out = {};
|
|
72
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
73
|
+
out[key] = (0, exports.matchesRedact)(key, compiled) ? '[redacted]' : value;
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
};
|
|
77
|
+
exports.redactHeaders = redactHeaders;
|
|
78
|
+
//# sourceMappingURL=redact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../../../src/shared/projection/redact.ts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