@datafog/fogclaw 0.1.3 → 0.1.5
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/dist/engines/gliner.d.ts.map +1 -1
- package/dist/engines/gliner.js +8 -4
- package/dist/engines/gliner.js.map +1 -1
- package/docs/plans/active/2026-02-17-feat-release-fogclaw-via-datafog-package-plan.md +28 -24
- package/docs/plugins/fogclaw.md +2 -0
- package/openclaw.plugin.json +41 -3
- package/package.json +9 -9
- package/scripts/ci/he-docs-drift.sh +0 -0
- package/scripts/ci/he-docs-lint.sh +0 -0
- package/scripts/ci/he-plans-lint.sh +0 -0
- package/scripts/ci/he-runbooks-lint.sh +0 -0
- package/scripts/ci/he-specs-lint.sh +0 -0
- package/scripts/ci/he-spikes-lint.sh +0 -0
- package/scripts/runbooks/select-runbooks.sh +0 -0
- package/src/engines/gliner.ts +19 -6
- package/tests/gliner.test.ts +39 -6
- package/tests/scanner.test.ts +38 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gliner.d.ts","sourceRoot":"","sources":["../../src/engines/gliner.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAmJ1C,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,WAAW,CAAS;gBAEhB,SAAS,EAAE,MAAM,EAAE,SAAS,GAAE,MAAY;IAKhD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAyBjC,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI;IAIjC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"gliner.d.ts","sourceRoot":"","sources":["../../src/engines/gliner.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAmJ1C,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,WAAW,CAAS;gBAEhB,SAAS,EAAE,MAAM,EAAE,SAAS,GAAE,MAAY;IAKhD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAyBjC,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI;IAIjC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IA4CnE,IAAI,aAAa,IAAI,OAAO,CAE3B;CACF"}
|
package/dist/engines/gliner.js
CHANGED
|
@@ -144,7 +144,7 @@ export class GlinerEngine {
|
|
|
144
144
|
executionProvider: "cpu",
|
|
145
145
|
},
|
|
146
146
|
maxWidth: 12,
|
|
147
|
-
modelType: "
|
|
147
|
+
modelType: "span-level",
|
|
148
148
|
});
|
|
149
149
|
await this.model.initialize();
|
|
150
150
|
this.initialized = true;
|
|
@@ -169,11 +169,15 @@ export class GlinerEngine {
|
|
|
169
169
|
];
|
|
170
170
|
// Deduplicate labels
|
|
171
171
|
const uniqueLabels = [...new Set(labels)];
|
|
172
|
-
const
|
|
172
|
+
const rawResults = await this.model.inference({
|
|
173
|
+
texts: [text],
|
|
174
|
+
entities: uniqueLabels,
|
|
175
|
+
flatNer: false,
|
|
173
176
|
threshold: this.threshold,
|
|
174
177
|
});
|
|
175
|
-
|
|
176
|
-
|
|
178
|
+
const flatResults = Array.isArray(rawResults) ? rawResults.flat() : [];
|
|
179
|
+
return flatResults.map((r) => ({
|
|
180
|
+
text: r.spanText ?? r.text,
|
|
177
181
|
label: canonicalType(r.label),
|
|
178
182
|
start: r.start,
|
|
179
183
|
end: r.end,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gliner.js","sourceRoot":"","sources":["../../src/engines/gliner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAG3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,kBAAkB,GAAG;IACzB,QAAQ;IACR,cAAc;IACd,UAAU;IACV,SAAS;IACT,eAAe;IACf,uBAAuB;IACvB,gBAAgB;IAChB,iBAAiB;CAClB,CAAC;AAEF,MAAM,kBAAkB,GAAG;IACzB,uBAAuB;IACvB,oBAAoB;IACpB,sBAAsB;IACtB,sBAAsB;IACtB,uBAAuB;IACvB,2BAA2B;IAC3B,sBAAsB;IACtB,iBAAiB;CAClB,CAAC;AAEF,MAAM,yBAAyB,GAAG,OAAO,CAAC;AAE1C,SAAS,iBAAiB,CAAC,SAAiB;IAC1C,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;IACjC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACpC,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAClF,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACxD,OAAO,IAAI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SAAS;SAC1B,CAAC,CAAC;QACH,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAEvE,OAAO,WAAW,CAAC,GAAG,CACpB,CACE,CAOC,EACD,EAAE,CAAC,CAAC;YACJ,IAAI,EAAE,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAI;YAC1B,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC;YAC7B,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,GAAG,EAAE,CAAC,CAAC,GAAG;YACV,UAAU,EAAE,CAAC,CAAC,KAAK;YACnB,MAAM,EAAE,QAAiB;SAC1B,CAAC,CACH,CAAC;IACJ,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -25,11 +25,11 @@ Users should be able to install and use FogClaw today from a DataFog-owned names
|
|
|
25
25
|
- [x] (2026-02-17T18:54:00Z) P3 [M1] Updated `package-lock` metadata and refreshed scope for build/release artifacts.
|
|
26
26
|
- [x] (2026-02-17T18:55:00Z) P4 [M2] Re-ran build/test/smoke + `npm pack --json` + `npm publish --dry-run` validations.
|
|
27
27
|
- [x] (2026-02-17T18:56:00Z) P5 [M2] Verified `openclaw plugins install` against the built `datafog-fogclaw-0.1.0.tgz` in a clean runtime; plugin now loads as `fogclaw` with status `loaded` and tools `fogclaw_scan, fogclaw_redact`.
|
|
28
|
-
- [
|
|
28
|
+
- [x] (2026-02-17T20:33:00Z) P5 [M2] Verified `openclaw plugins install @datafog/fogclaw` resolves to published `0.1.4` in this runtime.
|
|
29
29
|
- [x] (2026-02-17T19:27:00Z) P6 [M2] Fixed GLiNER startup blocker in Node by pinning `onnxruntime-web` to `1.21.0`, preventing `./webgpu` export resolution errors from `gliner` in OpenClaw install paths.
|
|
30
30
|
- [x] (2026-02-17T19:34:00Z) P6 [M2] Added direct `sharp` dependency `0.34.5` with an override to prevent optional sharp native install failure (`sharp-darwin-arm64v8.node` missing) during OpenClaw install-time dependency bootstrap.
|
|
31
|
-
- [
|
|
32
|
-
- [
|
|
31
|
+
- [x] (2026-02-17T20:29:00Z) P6 [M3] Published the startup hardening update as `@datafog/fogclaw@0.1.4` (OTP already provisioned) and confirmed package availability.
|
|
32
|
+
- [x] (2026-02-17T18:56:00Z) P6 [M3] Prepare and execute V1 publish/release of `@datafog/fogclaw`.
|
|
33
33
|
- [x] (2026-02-17T18:57:00Z) P7 [M3] Capture release artifacts and update evidence notes; add follow-up for dependency install blocker in OpenClaw install path.
|
|
34
34
|
|
|
35
35
|
|
|
@@ -47,13 +47,15 @@ Users should be able to install and use FogClaw today from a DataFog-owned names
|
|
|
47
47
|
- Observation: The prior `TypeError: Cannot read properties of undefined (reading 'trim')` install failure was caused by OpenClaw's `registerTool` contract when tool objects omit a top-level `name`.
|
|
48
48
|
Evidence: `src/plugins/registry.ts` in OpenClaw (`registerTool` maps `tool.name` without null-guard); fixed in this repository by adding `name` fields to both tool objects.
|
|
49
49
|
|
|
50
|
-
- Observation: `openclaw plugins install @datafog/fogclaw`
|
|
51
|
-
Evidence:
|
|
50
|
+
- Observation: `openclaw plugins install @datafog/fogclaw` now resolves and installs successfully from npm as version `0.1.4` in this environment.
|
|
51
|
+
Evidence: `npm view @datafog/fogclaw@0.1.4` returns `version = '0.1.4'` and `openclaw plugins install @datafog/fogclaw` reports success with plugin `fogclaw` loaded.
|
|
52
52
|
|
|
53
|
-
- Observation: GLiNER startup now avoids the `onnxruntime-web/webgpu` exports failure
|
|
54
|
-
Evidence:
|
|
53
|
+
- Observation: GLiNER startup now avoids the `onnxruntime-web/webgpu` exports failure after pinning `onnxruntime-web` to 1.21.0.
|
|
54
|
+
Evidence: in install flows, the earlier `./webgpu` subpath export error no longer blocks plugin registration in this environment.
|
|
55
55
|
- Observation: optional sharp runtime failures are now mitigated in clean install flows by pinning direct `sharp` 0.34.5; this removes the previously recurrent `Cannot find module '../build/Release/sharp-darwin-arm64v8.node'` warning in OpenClaw plugin install logs.
|
|
56
|
-
Evidence: `openclaw plugins install` from `datafog-fogclaw-0.1.
|
|
56
|
+
Evidence: `openclaw plugins install` from `datafog-fogclaw-0.1.4` no longer emits that missing binary warning.
|
|
57
|
+
- Observation: Running `pnpm openclaw` from the local OpenClaw source tree can still emit duplicate-plugin warnings when both the source-bundled `fogclaw` extension and installed `~/.openclaw/extensions/fogclaw` are present.
|
|
58
|
+
Evidence: this is due discovery order (`global` then `bundled`) and not a packaging defect in `@datafog/fogclaw` when installed in a standard global runtime.
|
|
57
59
|
|
|
58
60
|
## Decision Log
|
|
59
61
|
|
|
@@ -83,8 +85,9 @@ Users should be able to install and use FogClaw today from a DataFog-owned names
|
|
|
83
85
|
- Local validation confirms namespace rename compiles and tests (`npm run build`, `npm run test`, `npm run test:plugin-smoke`) continue to pass.
|
|
84
86
|
- `npm pack --json` and `npm publish --dry-run` now emit scoped package metadata under `@datafog/fogclaw`.
|
|
85
87
|
- `openclaw plugins install` against a clean temporary state and local `datafog-fogclaw-0.1.0.tgz` now succeeds; `openclaw plugins info fogclaw` shows status `loaded` and tools `fogclaw_scan`, `fogclaw_redact`.
|
|
86
|
-
- `openclaw plugins install @datafog/fogclaw`
|
|
87
|
-
- GLiNER
|
|
88
|
+
- `openclaw plugins install @datafog/fogclaw` now resolves from npm (`@datafog/fogclaw@0.1.4`) and plugin info/list flows show `fogclaw` as loaded.
|
|
89
|
+
- GLiNER may still fallback to regex-only in some environments, but the webgpu export blocker no longer prevents install or plugin registration.
|
|
90
|
+
- GLiNER startup now avoids the webgpu export resolution error after pinning `onnxruntime-web` to `1.21.0` in this runtime; fallback behavior remains safe if ONNX still cannot initialize.
|
|
88
91
|
|
|
89
92
|
|
|
90
93
|
## Context and Orientation
|
|
@@ -245,7 +248,7 @@ Expect:
|
|
|
245
248
|
## Idempotence and Recovery
|
|
246
249
|
|
|
247
250
|
- Re-running namespace renames is safe if done as a single set of edits (`package.json`, `package-lock.json`, docs).
|
|
248
|
-
- If `openclaw plugins install @datafog/fogclaw` cannot run due stale install artifacts,
|
|
251
|
+
- If `openclaw plugins install @datafog/fogclaw` cannot run due stale install artifacts, remove the stale extension directory (`~/.openclaw/extensions/fogclaw`) and reinstall from the scoped spec in one flow, keeping the `plugins.entries.fogclaw` config entry intact.
|
|
249
252
|
- If `npm publish` is blocked, capture exact npm error + timestamp, resolve token/2FA/access, then rerun from step 5 onward.
|
|
250
253
|
- If the package publishes but install fails due manifest mismatch, roll back to previous package version in npm and fix manifest/docs before republishing.
|
|
251
254
|
|
|
@@ -254,7 +257,7 @@ Expect:
|
|
|
254
257
|
- Scope migration evidence:
|
|
255
258
|
|
|
256
259
|
package: @datafog/fogclaw
|
|
257
|
-
version: 0.1.
|
|
260
|
+
version: 0.1.4
|
|
258
261
|
`npm pkg get name` output: `"@datafog/fogclaw"`
|
|
259
262
|
`npm pkg get openclaw` output:
|
|
260
263
|
`{"extensions":["./dist/index.js"]}`
|
|
@@ -268,17 +271,17 @@ Expect:
|
|
|
268
271
|
=> `function fogclaw FogClaw`
|
|
269
272
|
|
|
270
273
|
- Reproducibility evidence:
|
|
271
|
-
- `npm pack --json` output includes `datafog-fogclaw-0.1.
|
|
274
|
+
- `npm pack --json` output includes `datafog-fogclaw-0.1.4.tgz` and `openclaw.plugin.json`/`dist/index.js` in file list.
|
|
272
275
|
- `npm publish --dry-run` succeeded and produced scoped package manifest notice.
|
|
273
276
|
|
|
274
277
|
- Installability evidence:
|
|
275
|
-
- `openclaw plugins install @datafog/fogclaw`
|
|
276
|
-
- `openclaw plugins
|
|
277
|
-
- GLiNER
|
|
278
|
+
- `openclaw plugins install @datafog/fogclaw` succeeds in this environment and installs the published `0.1.4` package.
|
|
279
|
+
- `openclaw plugins info fogclaw` and `openclaw plugins list | rg fogclaw` confirm plugin status `loaded` and tools `fogclaw_scan`, `fogclaw_redact`.
|
|
280
|
+
- GLiNER can return model-backed detections in supported runtimes; plugin registration remains reliable even when inference falls back to regex.
|
|
278
281
|
|
|
279
282
|
- `git rev-parse HEAD` (of implementation snapshot): capture before final merge.
|
|
280
283
|
|
|
281
|
-
|
|
284
|
+
|
|
282
285
|
|
|
283
286
|
|
|
284
287
|
## Interfaces and Dependencies
|
|
@@ -303,12 +306,12 @@ Expect:
|
|
|
303
306
|
|
|
304
307
|
## Verify/Release Decision
|
|
305
308
|
|
|
306
|
-
- decision:
|
|
307
|
-
- date: 2026-02-
|
|
309
|
+
- decision: pending
|
|
310
|
+
- date: 2026-02-17T20:33:00Z
|
|
308
311
|
- open findings by priority (if any): pending
|
|
309
312
|
- evidence:
|
|
310
|
-
- installability
|
|
311
|
-
- scoped package
|
|
313
|
+
- installability against clean runtime now succeeds for `openclaw plugins install @datafog/fogclaw` (version `0.1.4`) and `openclaw plugins info/list` confirms `fogclaw` plugin visibility.
|
|
314
|
+
- scoped npm package is published and discoverable in registry metadata.
|
|
312
315
|
- rollback: revert to previous working scoped package state (or keep changes in branch) if publish credentials/visibility unavailable
|
|
313
316
|
- post-release checks:
|
|
314
317
|
- `openclaw plugins install @datafog/fogclaw`
|
|
@@ -319,6 +322,7 @@ Expect:
|
|
|
319
322
|
## Revision Notes
|
|
320
323
|
|
|
321
324
|
- 2026-02-17T10:57:00Z: Initialized plan for V1 scoped-release path in `@datafog/fogclaw` and documented zero-logic-change constraints for immediate installability milestone.
|
|
322
|
-
- 2026-02-17T18:57:00Z: Completed namespace migration in package metadata and install/docs (`package.json`, `package-lock.json`, `README.md`, `docs/plugins/fogclaw.md`). Ran full local validation (`npm run build`, `npm run test`, `npm run test:plugin-smoke`, `npm pack --json`, `npm publish --dry-run`) and
|
|
323
|
-
- 2026-02-17T19:08:00Z: Fixed OpenClaw compatibility in `src/index.ts` by adding explicit `name` fields to `fogclaw_scan` and `fogclaw_redact` tool registrations to avoid undefined `.trim()` during registration; verified clean-runtime
|
|
324
|
-
- 2026-02-
|
|
325
|
+
- 2026-02-17T18:57:00Z: Completed namespace migration in package metadata and install/docs (`package.json`, `package-lock.json`, `README.md`, `docs/plugins/fogclaw.md`). Ran full local validation (`npm run build`, `npm run test`, `npm run test:plugin-smoke`, `npm pack --json`, `npm publish --dry-run`) and prepared release notes.
|
|
326
|
+
- 2026-02-17T19:08:00Z: Fixed OpenClaw compatibility in `src/index.ts` by adding explicit `name` fields to `fogclaw_scan` and `fogclaw_redact` tool registrations to avoid undefined `.trim()` during registration; verified `openclaw plugins install` clean-runtime success with local tarball and published package commands (`openclaw plugins install <tgz>/<scoped spec>`, `plugins info`, `plugins list`).
|
|
327
|
+
- 2026-02-17T20:31:00Z: Added explicit `modelType: "span-level"` for GLiNER runtime configuration and pinned runtime dependencies (`onnxruntime-web`/`sharp`) so local OpenClaw install path no longer fails at startup from these blockers.
|
|
328
|
+
- 2026-02-17T20:33:00Z: Confirmed `@datafog/fogclaw@0.1.4` is published and installable via `openclaw plugins install @datafog/fogclaw` in this environment.
|
package/docs/plugins/fogclaw.md
CHANGED
|
@@ -27,6 +27,8 @@ openclaw plugins install @datafog/fogclaw
|
|
|
27
27
|
|
|
28
28
|
After install, restart the Gateway and enable/configure `plugins.entries.fogclaw`.
|
|
29
29
|
|
|
30
|
+
A moderately technical user can also manage this in the OpenClaw **Control UI** (`openclaw dashboard`) under Config; the plugin schema now exposes labeled fields for `guardrail_mode`, `redactStrategy`, and related policy options in the UI form.
|
|
31
|
+
|
|
30
32
|
## Plugin entry
|
|
31
33
|
|
|
32
34
|
The package exports the plugin manifest and entry as:
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "fogclaw",
|
|
3
3
|
"name": "FogClaw",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"description": "PII detection & custom entity redaction powered by DataFog",
|
|
6
6
|
"configSchema": {
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
-
"enabled": {
|
|
9
|
+
"enabled": {
|
|
10
|
+
"type": "boolean",
|
|
11
|
+
"default": true
|
|
12
|
+
},
|
|
10
13
|
"guardrail_mode": {
|
|
11
14
|
"type": "string",
|
|
12
15
|
"enum": ["redact", "block", "warn"],
|
|
@@ -29,7 +32,9 @@
|
|
|
29
32
|
},
|
|
30
33
|
"custom_entities": {
|
|
31
34
|
"type": "array",
|
|
32
|
-
"items": {
|
|
35
|
+
"items": {
|
|
36
|
+
"type": "string"
|
|
37
|
+
},
|
|
33
38
|
"default": []
|
|
34
39
|
},
|
|
35
40
|
"entityActions": {
|
|
@@ -41,5 +46,38 @@
|
|
|
41
46
|
"default": {}
|
|
42
47
|
}
|
|
43
48
|
}
|
|
49
|
+
},
|
|
50
|
+
"uiHints": {
|
|
51
|
+
"enabled": {
|
|
52
|
+
"label": "Enable FogClaw",
|
|
53
|
+
"help": "Enable or disable the plugin without uninstalling it."
|
|
54
|
+
},
|
|
55
|
+
"guardrail_mode": {
|
|
56
|
+
"label": "Guardrail Mode",
|
|
57
|
+
"help": "Default action for detections: redact, block, or warn."
|
|
58
|
+
},
|
|
59
|
+
"redactStrategy": {
|
|
60
|
+
"label": "Redaction Strategy",
|
|
61
|
+
"help": "How sensitive values are replaced in message context before the agent sees them."
|
|
62
|
+
},
|
|
63
|
+
"model": {
|
|
64
|
+
"label": "GLiNER Model",
|
|
65
|
+
"help": "Model used for zero-shot detection (defaults to onnx-community/gliner_large-v2.1).",
|
|
66
|
+
"advanced": true
|
|
67
|
+
},
|
|
68
|
+
"confidence_threshold": {
|
|
69
|
+
"label": "Confidence Threshold",
|
|
70
|
+
"help": "Minimum GLiNER score (0-1) required before an entity is treated as a detection.",
|
|
71
|
+
"advanced": true
|
|
72
|
+
},
|
|
73
|
+
"custom_entities": {
|
|
74
|
+
"label": "Custom Entity Labels",
|
|
75
|
+
"help": "Extra labels to detect as sensitive entities (for example: `project code`, `competitor name`)."
|
|
76
|
+
},
|
|
77
|
+
"entityActions": {
|
|
78
|
+
"label": "Entity Actions",
|
|
79
|
+
"help": "Map specific entity labels to per-entity behavior (for example: {\"EMAIL\": \"block\", \"PHONE\": \"redact\"}).",
|
|
80
|
+
"advanced": true
|
|
81
|
+
}
|
|
44
82
|
}
|
|
45
83
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datafog/fogclaw",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "OpenClaw plugin for PII detection & custom entity redaction powered by DataFog",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"build": "tsc",
|
|
10
|
-
"test": "vitest run",
|
|
11
|
-
"test:watch": "vitest",
|
|
12
|
-
"test:plugin-smoke": "vitest run tests/plugin-smoke.test.ts",
|
|
13
|
-
"lint": "tsc --noEmit"
|
|
14
|
-
},
|
|
15
8
|
"dependencies": {
|
|
16
9
|
"gliner": "^0.0.19",
|
|
17
10
|
"onnxruntime-node": "1.19.2",
|
|
@@ -39,5 +32,12 @@
|
|
|
39
32
|
"overrides": {
|
|
40
33
|
"onnxruntime-web": "1.21.0",
|
|
41
34
|
"sharp": "0.34.5"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc",
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"test:watch": "vitest",
|
|
40
|
+
"test:plugin-smoke": "vitest run tests/plugin-smoke.test.ts",
|
|
41
|
+
"lint": "tsc --noEmit"
|
|
42
42
|
}
|
|
43
|
-
}
|
|
43
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/engines/gliner.ts
CHANGED
|
@@ -175,7 +175,7 @@ export class GlinerEngine {
|
|
|
175
175
|
executionProvider: "cpu",
|
|
176
176
|
},
|
|
177
177
|
maxWidth: 12,
|
|
178
|
-
modelType: "
|
|
178
|
+
modelType: "span-level",
|
|
179
179
|
});
|
|
180
180
|
await this.model.initialize();
|
|
181
181
|
this.initialized = true;
|
|
@@ -205,13 +205,26 @@ export class GlinerEngine {
|
|
|
205
205
|
// Deduplicate labels
|
|
206
206
|
const uniqueLabels = [...new Set(labels)];
|
|
207
207
|
|
|
208
|
-
const
|
|
208
|
+
const rawResults = await this.model.inference({
|
|
209
|
+
texts: [text],
|
|
210
|
+
entities: uniqueLabels,
|
|
211
|
+
flatNer: false,
|
|
209
212
|
threshold: this.threshold,
|
|
210
213
|
});
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
214
|
+
const flatResults = Array.isArray(rawResults) ? rawResults.flat() : [];
|
|
215
|
+
|
|
216
|
+
return flatResults.map(
|
|
217
|
+
(
|
|
218
|
+
r: {
|
|
219
|
+
spanText?: string;
|
|
220
|
+
text: string;
|
|
221
|
+
label: string;
|
|
222
|
+
score: number;
|
|
223
|
+
start: number;
|
|
224
|
+
end: number;
|
|
225
|
+
},
|
|
226
|
+
) => ({
|
|
227
|
+
text: r.spanText ?? r.text,
|
|
215
228
|
label: canonicalType(r.label),
|
|
216
229
|
start: r.start,
|
|
217
230
|
end: r.end,
|
package/tests/gliner.test.ts
CHANGED
|
@@ -17,10 +17,25 @@ vi.mock("gliner", () => {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
async inference(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
request: { texts: string[]; entities: string[] } | string | string[],
|
|
21
|
+
maybeEntities?: string[],
|
|
22
|
+
_flatNer = false,
|
|
23
|
+
_threshold = 0.5,
|
|
23
24
|
): Promise<Array<{ text: string; label: string; score: number; start: number; end: number }>> {
|
|
25
|
+
const text =
|
|
26
|
+
typeof request === "string"
|
|
27
|
+
? request
|
|
28
|
+
: Array.isArray(request)
|
|
29
|
+
? request[0] ?? ""
|
|
30
|
+
: request.texts[0] ?? "";
|
|
31
|
+
const requestEntities =
|
|
32
|
+
typeof request === "object" && request !== null && "entities" in request
|
|
33
|
+
? request.entities
|
|
34
|
+
: undefined;
|
|
35
|
+
const labels =
|
|
36
|
+
Array.isArray(maybeEntities)
|
|
37
|
+
? maybeEntities
|
|
38
|
+
: requestEntities ?? [];
|
|
24
39
|
const results: Array<{ text: string; label: string; score: number; start: number; end: number }> = [];
|
|
25
40
|
|
|
26
41
|
// Simulate entity detection for "John Smith"
|
|
@@ -79,12 +94,28 @@ vi.mock("gliner/node", () => {
|
|
|
79
94
|
}
|
|
80
95
|
|
|
81
96
|
async inference(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
request: { texts: string[]; entities: string[] } | string | string[],
|
|
98
|
+
maybeEntities?: string[],
|
|
99
|
+
_flatNer = false,
|
|
100
|
+
_threshold = 0.5,
|
|
85
101
|
): Promise<Array<{ text: string; label: string; score: number; start: number; end: number }>> {
|
|
102
|
+
const text =
|
|
103
|
+
typeof request === "string"
|
|
104
|
+
? request
|
|
105
|
+
: Array.isArray(request)
|
|
106
|
+
? request[0] ?? ""
|
|
107
|
+
: request.texts[0] ?? "";
|
|
108
|
+
const requestEntities =
|
|
109
|
+
typeof request === "object" && request !== null && "entities" in request
|
|
110
|
+
? request.entities
|
|
111
|
+
: undefined;
|
|
112
|
+
const labels =
|
|
113
|
+
Array.isArray(maybeEntities)
|
|
114
|
+
? maybeEntities
|
|
115
|
+
: requestEntities ?? [];
|
|
86
116
|
const results: Array<{ text: string; label: string; score: number; start: number; end: number }> = [];
|
|
87
117
|
|
|
118
|
+
// Simulate entity detection for "John Smith"
|
|
88
119
|
const johnIndex = text.indexOf("John Smith");
|
|
89
120
|
if (johnIndex !== -1 && labels.includes("person")) {
|
|
90
121
|
results.push({
|
|
@@ -96,6 +127,7 @@ vi.mock("gliner/node", () => {
|
|
|
96
127
|
});
|
|
97
128
|
}
|
|
98
129
|
|
|
130
|
+
// Simulate entity detection for "Acme Corp"
|
|
99
131
|
const acmeIndex = text.indexOf("Acme Corp");
|
|
100
132
|
if (acmeIndex !== -1 && labels.includes("organization")) {
|
|
101
133
|
results.push({
|
|
@@ -107,6 +139,7 @@ vi.mock("gliner/node", () => {
|
|
|
107
139
|
});
|
|
108
140
|
}
|
|
109
141
|
|
|
142
|
+
// Simulate entity detection for "New York"
|
|
110
143
|
const nyIndex = text.indexOf("New York");
|
|
111
144
|
if (nyIndex !== -1 && labels.includes("location")) {
|
|
112
145
|
results.push({
|
package/tests/scanner.test.ts
CHANGED
|
@@ -9,10 +9,25 @@ vi.mock("gliner", () => {
|
|
|
9
9
|
Gliner: class MockGliner {
|
|
10
10
|
async initialize() {}
|
|
11
11
|
async inference(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
request: { texts: string[]; entities: string[] } | string | string[],
|
|
13
|
+
maybeEntities?: string[],
|
|
14
|
+
_flatNer = false,
|
|
15
|
+
_threshold = 0.5,
|
|
15
16
|
) {
|
|
17
|
+
const text =
|
|
18
|
+
typeof request === "string"
|
|
19
|
+
? request
|
|
20
|
+
: Array.isArray(request)
|
|
21
|
+
? request[0] ?? ""
|
|
22
|
+
: request.texts[0] ?? "";
|
|
23
|
+
const requestEntities =
|
|
24
|
+
typeof request === "object" && request !== null && "entities" in request
|
|
25
|
+
? request.entities
|
|
26
|
+
: undefined;
|
|
27
|
+
const labels =
|
|
28
|
+
Array.isArray(maybeEntities)
|
|
29
|
+
? maybeEntities
|
|
30
|
+
: requestEntities ?? [];
|
|
16
31
|
const results: any[] = [];
|
|
17
32
|
|
|
18
33
|
// Simulate person detection for "John Smith"
|
|
@@ -42,7 +57,7 @@ vi.mock("gliner", () => {
|
|
|
42
57
|
// Only return results whose labels are requested
|
|
43
58
|
return results.filter((r) => labels.includes(r.label));
|
|
44
59
|
}
|
|
45
|
-
}
|
|
60
|
+
}
|
|
46
61
|
};
|
|
47
62
|
});
|
|
48
63
|
|
|
@@ -51,10 +66,25 @@ vi.mock("gliner/node", () => {
|
|
|
51
66
|
Gliner: class MockGliner {
|
|
52
67
|
async initialize() {}
|
|
53
68
|
async inference(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
69
|
+
request: { texts: string[]; entities: string[] } | string | string[],
|
|
70
|
+
maybeEntities?: string[],
|
|
71
|
+
_flatNer = false,
|
|
72
|
+
_threshold = 0.5,
|
|
57
73
|
) {
|
|
74
|
+
const text =
|
|
75
|
+
typeof request === "string"
|
|
76
|
+
? request
|
|
77
|
+
: Array.isArray(request)
|
|
78
|
+
? request[0] ?? ""
|
|
79
|
+
: request.texts[0] ?? "";
|
|
80
|
+
const requestEntities =
|
|
81
|
+
typeof request === "object" && request !== null && "entities" in request
|
|
82
|
+
? request.entities
|
|
83
|
+
: undefined;
|
|
84
|
+
const labels =
|
|
85
|
+
Array.isArray(maybeEntities)
|
|
86
|
+
? maybeEntities
|
|
87
|
+
: requestEntities ?? [];
|
|
58
88
|
const results: any[] = [];
|
|
59
89
|
|
|
60
90
|
// Simulate person detection for "John Smith"
|
|
@@ -84,7 +114,7 @@ vi.mock("gliner/node", () => {
|
|
|
84
114
|
// Only return results whose labels are requested
|
|
85
115
|
return results.filter((r) => labels.includes(r.label));
|
|
86
116
|
}
|
|
87
|
-
}
|
|
117
|
+
}
|
|
88
118
|
};
|
|
89
119
|
});
|
|
90
120
|
|