@framers/agentos 0.1.56 → 0.1.57

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.
Files changed (82) hide show
  1. package/README.md +67 -16
  2. package/dist/api/types/AgentOSResponse.d.ts +7 -0
  3. package/dist/api/types/AgentOSResponse.d.ts.map +1 -1
  4. package/dist/core/guardrails/IGuardrailService.d.ts +39 -0
  5. package/dist/core/guardrails/IGuardrailService.d.ts.map +1 -1
  6. package/dist/core/guardrails/ParallelGuardrailDispatcher.d.ts +92 -0
  7. package/dist/core/guardrails/ParallelGuardrailDispatcher.d.ts.map +1 -0
  8. package/dist/core/guardrails/ParallelGuardrailDispatcher.js +463 -0
  9. package/dist/core/guardrails/ParallelGuardrailDispatcher.js.map +1 -0
  10. package/dist/core/guardrails/guardrailDispatcher.d.ts +59 -1
  11. package/dist/core/guardrails/guardrailDispatcher.d.ts.map +1 -1
  12. package/dist/core/guardrails/guardrailDispatcher.js +49 -154
  13. package/dist/core/guardrails/guardrailDispatcher.js.map +1 -1
  14. package/dist/core/guardrails/index.d.ts +1 -0
  15. package/dist/core/guardrails/index.d.ts.map +1 -1
  16. package/dist/core/guardrails/index.js +2 -0
  17. package/dist/core/guardrails/index.js.map +1 -1
  18. package/dist/core/utils/index.d.ts +13 -0
  19. package/dist/core/utils/index.d.ts.map +1 -0
  20. package/dist/core/utils/index.js +13 -0
  21. package/dist/core/utils/index.js.map +1 -0
  22. package/dist/core/utils/text-utils.d.ts +164 -0
  23. package/dist/core/utils/text-utils.d.ts.map +1 -0
  24. package/dist/core/utils/text-utils.js +254 -0
  25. package/dist/core/utils/text-utils.js.map +1 -0
  26. package/dist/extensions/index.d.ts +0 -1
  27. package/dist/extensions/index.d.ts.map +1 -1
  28. package/dist/extensions/index.js +0 -2
  29. package/dist/extensions/index.js.map +1 -1
  30. package/package.json +1 -6
  31. package/dist/extensions/packs/pii-redaction/EntityMerger.d.ts +0 -127
  32. package/dist/extensions/packs/pii-redaction/EntityMerger.d.ts.map +0 -1
  33. package/dist/extensions/packs/pii-redaction/EntityMerger.js +0 -263
  34. package/dist/extensions/packs/pii-redaction/EntityMerger.js.map +0 -1
  35. package/dist/extensions/packs/pii-redaction/PiiDetectionPipeline.d.ts +0 -199
  36. package/dist/extensions/packs/pii-redaction/PiiDetectionPipeline.d.ts.map +0 -1
  37. package/dist/extensions/packs/pii-redaction/PiiDetectionPipeline.js +0 -456
  38. package/dist/extensions/packs/pii-redaction/PiiDetectionPipeline.js.map +0 -1
  39. package/dist/extensions/packs/pii-redaction/PiiRedactionGuardrail.d.ts +0 -121
  40. package/dist/extensions/packs/pii-redaction/PiiRedactionGuardrail.d.ts.map +0 -1
  41. package/dist/extensions/packs/pii-redaction/PiiRedactionGuardrail.js +0 -271
  42. package/dist/extensions/packs/pii-redaction/PiiRedactionGuardrail.js.map +0 -1
  43. package/dist/extensions/packs/pii-redaction/RedactionEngine.d.ts +0 -61
  44. package/dist/extensions/packs/pii-redaction/RedactionEngine.d.ts.map +0 -1
  45. package/dist/extensions/packs/pii-redaction/RedactionEngine.js +0 -207
  46. package/dist/extensions/packs/pii-redaction/RedactionEngine.js.map +0 -1
  47. package/dist/extensions/packs/pii-redaction/index.d.ts +0 -90
  48. package/dist/extensions/packs/pii-redaction/index.d.ts.map +0 -1
  49. package/dist/extensions/packs/pii-redaction/index.js +0 -195
  50. package/dist/extensions/packs/pii-redaction/index.js.map +0 -1
  51. package/dist/extensions/packs/pii-redaction/recognizers/IEntityRecognizer.d.ts +0 -151
  52. package/dist/extensions/packs/pii-redaction/recognizers/IEntityRecognizer.d.ts.map +0 -1
  53. package/dist/extensions/packs/pii-redaction/recognizers/IEntityRecognizer.js +0 -14
  54. package/dist/extensions/packs/pii-redaction/recognizers/IEntityRecognizer.js.map +0 -1
  55. package/dist/extensions/packs/pii-redaction/recognizers/LlmJudgeRecognizer.d.ts +0 -177
  56. package/dist/extensions/packs/pii-redaction/recognizers/LlmJudgeRecognizer.d.ts.map +0 -1
  57. package/dist/extensions/packs/pii-redaction/recognizers/LlmJudgeRecognizer.js +0 -420
  58. package/dist/extensions/packs/pii-redaction/recognizers/LlmJudgeRecognizer.js.map +0 -1
  59. package/dist/extensions/packs/pii-redaction/recognizers/NerModelRecognizer.d.ts +0 -145
  60. package/dist/extensions/packs/pii-redaction/recognizers/NerModelRecognizer.d.ts.map +0 -1
  61. package/dist/extensions/packs/pii-redaction/recognizers/NerModelRecognizer.js +0 -299
  62. package/dist/extensions/packs/pii-redaction/recognizers/NerModelRecognizer.js.map +0 -1
  63. package/dist/extensions/packs/pii-redaction/recognizers/NlpPrefilterRecognizer.d.ts +0 -102
  64. package/dist/extensions/packs/pii-redaction/recognizers/NlpPrefilterRecognizer.d.ts.map +0 -1
  65. package/dist/extensions/packs/pii-redaction/recognizers/NlpPrefilterRecognizer.js +0 -228
  66. package/dist/extensions/packs/pii-redaction/recognizers/NlpPrefilterRecognizer.js.map +0 -1
  67. package/dist/extensions/packs/pii-redaction/recognizers/RegexRecognizer.d.ts +0 -103
  68. package/dist/extensions/packs/pii-redaction/recognizers/RegexRecognizer.d.ts.map +0 -1
  69. package/dist/extensions/packs/pii-redaction/recognizers/RegexRecognizer.js +0 -275
  70. package/dist/extensions/packs/pii-redaction/recognizers/RegexRecognizer.js.map +0 -1
  71. package/dist/extensions/packs/pii-redaction/tools/PiiRedactTool.d.ts +0 -118
  72. package/dist/extensions/packs/pii-redaction/tools/PiiRedactTool.d.ts.map +0 -1
  73. package/dist/extensions/packs/pii-redaction/tools/PiiRedactTool.js +0 -152
  74. package/dist/extensions/packs/pii-redaction/tools/PiiRedactTool.js.map +0 -1
  75. package/dist/extensions/packs/pii-redaction/tools/PiiScanTool.d.ts +0 -98
  76. package/dist/extensions/packs/pii-redaction/tools/PiiScanTool.d.ts.map +0 -1
  77. package/dist/extensions/packs/pii-redaction/tools/PiiScanTool.js +0 -153
  78. package/dist/extensions/packs/pii-redaction/tools/PiiScanTool.js.map +0 -1
  79. package/dist/extensions/packs/pii-redaction/types.d.ts +0 -332
  80. package/dist/extensions/packs/pii-redaction/types.d.ts.map +0 -1
  81. package/dist/extensions/packs/pii-redaction/types.js +0 -83
  82. package/dist/extensions/packs/pii-redaction/types.js.map +0 -1
@@ -1,98 +0,0 @@
1
- /**
2
- * @file PiiScanTool.ts
3
- * @description AgentOS tool that scans text for PII (Personally Identifiable
4
- * Information) without modifying it.
5
- *
6
- * The tool wraps the {@link PiiDetectionPipeline} and exposes it as an
7
- * {@link ITool} so agents can programmatically inspect text for sensitive
8
- * data before deciding how to handle it (e.g., before logging, forwarding,
9
- * or storing user-provided content).
10
- *
11
- * Unlike the guardrail (which intercepts I/O automatically), this tool is
12
- * invoked explicitly by the agent or orchestrator when scan-only semantics
13
- * are needed.
14
- *
15
- * @module pii-redaction/tools/PiiScanTool
16
- */
17
- import type { ISharedServiceRegistry } from '../../../ISharedServiceRegistry';
18
- import type { ITool, ToolExecutionContext, ToolExecutionResult, JSONSchemaObject } from '../../../../core/tools/ITool';
19
- import type { PiiRedactionPackOptions, PiiDetectionResult, PiiEntityType } from '../types';
20
- /**
21
- * Input arguments accepted by the {@link PiiScanTool}.
22
- *
23
- * Only `text` is required. The optional `entityTypes` array allows the
24
- * caller to narrow detection to a subset of PII categories, overriding the
25
- * pack-level default for this single invocation.
26
- */
27
- export interface PiiScanInput {
28
- /** The text to scan for PII entities. */
29
- text: string;
30
- /**
31
- * Optional subset of PII entity types to scan for.
32
- * When omitted the tool uses the pack-level entity type configuration.
33
- */
34
- entityTypes?: PiiEntityType[];
35
- }
36
- /**
37
- * AgentOS tool that detects PII entities in text and returns structured
38
- * detection results without modifying the original text.
39
- *
40
- * ### Usage by agents
41
- * ```json
42
- * {
43
- * "tool": "pii_scan",
44
- * "arguments": {
45
- * "text": "Contact John Smith at john@example.com"
46
- * }
47
- * }
48
- * ```
49
- *
50
- * ### Return value
51
- * A {@link PiiDetectionResult} containing the list of detected entities,
52
- * processing metadata, and a human-readable summary.
53
- *
54
- * @implements {ITool<PiiScanInput, PiiDetectionResult>}
55
- */
56
- export declare class PiiScanTool implements ITool<PiiScanInput, PiiDetectionResult> {
57
- /** Globally unique identifier for the tool. */
58
- readonly id = "pii_scan";
59
- /** Functional name used by LLMs in tool call requests. */
60
- readonly name = "pii_scan";
61
- /** Human-readable display name for UIs and logs. */
62
- readonly displayName = "PII Scanner";
63
- /** Detailed description for LLM tool selection. */
64
- readonly description: string;
65
- /** Tool category for filtering and grouping. */
66
- readonly category = "security";
67
- /** This tool is read-only and has no side effects. */
68
- readonly hasSideEffects = false;
69
- /** JSON Schema describing the expected input arguments. */
70
- readonly inputSchema: JSONSchemaObject;
71
- /** Detection pipeline instance shared across invocations. */
72
- private readonly pipeline;
73
- /**
74
- * Construct a new PiiScanTool.
75
- *
76
- * @param services - Shared service registry forwarded to the detection
77
- * pipeline for lazy-loading NLP/NER models.
78
- * @param options - Pack-level configuration controlling entity types,
79
- * confidence threshold, and detection tier flags.
80
- */
81
- constructor(services: ISharedServiceRegistry, options: PiiRedactionPackOptions);
82
- /**
83
- * Execute the PII scan on the provided text.
84
- *
85
- * Runs the full detection pipeline (Regex -> NLP pre-filter -> NER -> LLM
86
- * judge, as configured) and returns the detection result wrapped in a
87
- * {@link ToolExecutionResult}.
88
- *
89
- * @param args - Input arguments containing the text to scan and optional
90
- * entity type filter.
91
- * @param context - Tool execution context (unused by this tool but required
92
- * by the ITool interface).
93
- * @returns A promise resolving to the tool execution result containing the
94
- * {@link PiiDetectionResult}.
95
- */
96
- execute(args: PiiScanInput, context: ToolExecutionContext): Promise<ToolExecutionResult<PiiDetectionResult>>;
97
- }
98
- //# sourceMappingURL=PiiScanTool.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PiiScanTool.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/packs/pii-redaction/tools/PiiScanTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,KAAK,EACV,KAAK,EACL,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,uBAAuB,EACvB,kBAAkB,EAClB,aAAa,EACd,MAAM,UAAU,CAAC;AAOlB;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;CAC/B;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,WAAY,YAAW,KAAK,CAAC,YAAY,EAAE,kBAAkB,CAAC;IAKzE,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,cAAc;IAEzB,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,cAAc;IAE3B,oDAAoD;IACpD,QAAQ,CAAC,WAAW,iBAAiB;IAErC,mDAAmD;IACnD,QAAQ,CAAC,WAAW,SAIiE;IAErF,gDAAgD;IAChD,QAAQ,CAAC,QAAQ,cAAc;IAE/B,sDAAsD;IACtD,QAAQ,CAAC,cAAc,SAAS;IAEhC,2DAA2D;IAC3D,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAgBpC;IAMF,6DAA6D;IAC7D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuB;IAMhD;;;;;;;OAOG;gBAED,QAAQ,EAAE,sBAAsB,EAChC,OAAO,EAAE,uBAAuB;IASlC;;;;;;;;;;;;;OAaG;IACG,OAAO,CACX,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;CAmDpD"}
@@ -1,153 +0,0 @@
1
- /**
2
- * @file PiiScanTool.ts
3
- * @description AgentOS tool that scans text for PII (Personally Identifiable
4
- * Information) without modifying it.
5
- *
6
- * The tool wraps the {@link PiiDetectionPipeline} and exposes it as an
7
- * {@link ITool} so agents can programmatically inspect text for sensitive
8
- * data before deciding how to handle it (e.g., before logging, forwarding,
9
- * or storing user-provided content).
10
- *
11
- * Unlike the guardrail (which intercepts I/O automatically), this tool is
12
- * invoked explicitly by the agent or orchestrator when scan-only semantics
13
- * are needed.
14
- *
15
- * @module pii-redaction/tools/PiiScanTool
16
- */
17
- import { PiiDetectionPipeline } from '../PiiDetectionPipeline.js';
18
- // ---------------------------------------------------------------------------
19
- // PiiScanTool
20
- // ---------------------------------------------------------------------------
21
- /**
22
- * AgentOS tool that detects PII entities in text and returns structured
23
- * detection results without modifying the original text.
24
- *
25
- * ### Usage by agents
26
- * ```json
27
- * {
28
- * "tool": "pii_scan",
29
- * "arguments": {
30
- * "text": "Contact John Smith at john@example.com"
31
- * }
32
- * }
33
- * ```
34
- *
35
- * ### Return value
36
- * A {@link PiiDetectionResult} containing the list of detected entities,
37
- * processing metadata, and a human-readable summary.
38
- *
39
- * @implements {ITool<PiiScanInput, PiiDetectionResult>}
40
- */
41
- export class PiiScanTool {
42
- // -----------------------------------------------------------------------
43
- // Constructor
44
- // -----------------------------------------------------------------------
45
- /**
46
- * Construct a new PiiScanTool.
47
- *
48
- * @param services - Shared service registry forwarded to the detection
49
- * pipeline for lazy-loading NLP/NER models.
50
- * @param options - Pack-level configuration controlling entity types,
51
- * confidence threshold, and detection tier flags.
52
- */
53
- constructor(services, options) {
54
- // -----------------------------------------------------------------------
55
- // ITool metadata
56
- // -----------------------------------------------------------------------
57
- /** Globally unique identifier for the tool. */
58
- this.id = 'pii_scan';
59
- /** Functional name used by LLMs in tool call requests. */
60
- this.name = 'pii_scan';
61
- /** Human-readable display name for UIs and logs. */
62
- this.displayName = 'PII Scanner';
63
- /** Detailed description for LLM tool selection. */
64
- this.description = 'Scan text for Personally Identifiable Information (PII) without modifying it. ' +
65
- 'Returns a structured result listing all detected PII entities with their types, ' +
66
- 'positions, confidence scores, and detection sources. Useful for auditing or ' +
67
- 'deciding how to handle sensitive data before logging, forwarding, or storing it.';
68
- /** Tool category for filtering and grouping. */
69
- this.category = 'security';
70
- /** This tool is read-only and has no side effects. */
71
- this.hasSideEffects = false;
72
- /** JSON Schema describing the expected input arguments. */
73
- this.inputSchema = {
74
- type: 'object',
75
- properties: {
76
- text: {
77
- type: 'string',
78
- description: 'The text to scan for PII entities.',
79
- },
80
- entityTypes: {
81
- type: 'array',
82
- items: { type: 'string' },
83
- description: 'Optional subset of PII entity types to scan for (e.g., ["EMAIL", "PHONE"]). ' +
84
- 'When omitted, all configured entity types are scanned.',
85
- },
86
- },
87
- required: ['text'],
88
- };
89
- this.pipeline = new PiiDetectionPipeline(services, options);
90
- }
91
- // -----------------------------------------------------------------------
92
- // ITool — execute
93
- // -----------------------------------------------------------------------
94
- /**
95
- * Execute the PII scan on the provided text.
96
- *
97
- * Runs the full detection pipeline (Regex -> NLP pre-filter -> NER -> LLM
98
- * judge, as configured) and returns the detection result wrapped in a
99
- * {@link ToolExecutionResult}.
100
- *
101
- * @param args - Input arguments containing the text to scan and optional
102
- * entity type filter.
103
- * @param context - Tool execution context (unused by this tool but required
104
- * by the ITool interface).
105
- * @returns A promise resolving to the tool execution result containing the
106
- * {@link PiiDetectionResult}.
107
- */
108
- async execute(args, context) {
109
- try {
110
- // Validate that the required `text` argument is present and non-empty.
111
- if (!args.text || typeof args.text !== 'string') {
112
- return {
113
- success: false,
114
- error: 'The "text" argument is required and must be a non-empty string.',
115
- };
116
- }
117
- // Run the detection pipeline.
118
- const result = await this.pipeline.detect(args.text);
119
- // If the caller provided a subset of entity types, filter the results
120
- // to only include entities matching those types.
121
- if (args.entityTypes && args.entityTypes.length > 0) {
122
- const allowedTypes = new Set(args.entityTypes);
123
- const filteredEntities = result.entities.filter((e) => allowedTypes.has(e.entityType));
124
- return {
125
- success: true,
126
- output: {
127
- ...result,
128
- entities: filteredEntities,
129
- // Update summary to reflect the filtered count.
130
- summary: filteredEntities.length === 0
131
- ? 'No PII detected (after entity type filter)'
132
- : `${filteredEntities.length} ${filteredEntities.length === 1 ? 'entity' : 'entities'} found (filtered by type)`,
133
- },
134
- };
135
- }
136
- return {
137
- success: true,
138
- output: result,
139
- };
140
- }
141
- catch (error) {
142
- // Wrap unexpected errors in a failed ToolExecutionResult rather than
143
- // letting them propagate as unhandled exceptions.
144
- const message = error instanceof Error ? error.message : 'Unknown error during PII scan';
145
- return {
146
- success: false,
147
- error: message,
148
- details: { stack: error instanceof Error ? error.stack : undefined },
149
- };
150
- }
151
- }
152
- }
153
- //# sourceMappingURL=PiiScanTool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PiiScanTool.js","sourceRoot":"","sources":["../../../../../src/extensions/packs/pii-redaction/tools/PiiScanTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAcH,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAwB/D,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,WAAW;IAqDtB,0EAA0E;IAC1E,cAAc;IACd,0EAA0E;IAE1E;;;;;;;OAOG;IACH,YACE,QAAgC,EAChC,OAAgC;QAlElC,0EAA0E;QAC1E,iBAAiB;QACjB,0EAA0E;QAE1E,+CAA+C;QACtC,OAAE,GAAG,UAAU,CAAC;QAEzB,0DAA0D;QACjD,SAAI,GAAG,UAAU,CAAC;QAE3B,oDAAoD;QAC3C,gBAAW,GAAG,aAAa,CAAC;QAErC,mDAAmD;QAC1C,gBAAW,GAClB,gFAAgF;YAChF,kFAAkF;YAClF,8EAA8E;YAC9E,kFAAkF,CAAC;QAErF,gDAAgD;QACvC,aAAQ,GAAG,UAAU,CAAC;QAE/B,sDAAsD;QAC7C,mBAAc,GAAG,KAAK,CAAC;QAEhC,2DAA2D;QAClD,gBAAW,GAAqB;YACvC,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EA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OAAO,EACL,gBAAgB,CAAC,MAAM,KAAK,CAAC;4BAC3B,CAAC,CAAC,4CAA4C;4BAC9C,CAAC,CAAC,GAAG,gBAAgB,CAAC,MAAM,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,2BAA2B;qBACrH;iBACF,CAAC;YACJ,CAAC;YAED,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE,MAAM;aACf,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,qEAAqE;YACrE,kDAAkD;YAClD,MAAM,OAAO,GACX,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,+BAA+B,CAAC;YAC3E,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,OAAO;gBACd,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAAE;aACrE,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -1,332 +0,0 @@
1
- /**
2
- * @file types.ts
3
- * @description Core type definitions for the PII Redaction extension pack.
4
- *
5
- * This module defines all shared types used across the PII detection pipeline:
6
- * entity types, detection results, redaction styles, configuration interfaces,
7
- * and stable service identity constants.
8
- *
9
- * @module pii-redaction/types
10
- */
11
- /**
12
- * Enumeration of all PII (Personally Identifiable Information) entity categories
13
- * that the detection pipeline can recognise.
14
- *
15
- * The union is intentionally a string-literal type rather than a TypeScript
16
- * `enum` so that values can be used directly as JSON without serialisation
17
- * gymnastics and tree-shaken away when not referenced.
18
- *
19
- * @example
20
- * ```ts
21
- * const myType: PiiEntityType = 'EMAIL';
22
- * ```
23
- */
24
- export type PiiEntityType =
25
- /** US Social Security Number (format: NNN-NN-NNNN). */
26
- 'SSN'
27
- /** Payment card numbers (Luhn-validated, 13–19 digits). */
28
- | 'CREDIT_CARD'
29
- /** RFC 5321 email addresses. */
30
- | 'EMAIL'
31
- /** International or domestic telephone numbers (E.164 and local variants). */
32
- | 'PHONE'
33
- /** IPv4 and IPv6 addresses. */
34
- | 'IP_ADDRESS'
35
- /** International Bank Account Number (ISO 13616). */
36
- | 'IBAN'
37
- /** Passport document numbers (multi-country patterns). */
38
- | 'PASSPORT'
39
- /** Driver's licence numbers (US state patterns and common international formats). */
40
- | 'DRIVERS_LICENSE'
41
- /** Generic government-issued ID numbers not covered by the above. */
42
- | 'GOV_ID'
43
- /** Date of birth — detected when contextual signals confirm a birthday. */
44
- | 'DATE_OF_BIRTH'
45
- /** Generic API tokens and secret keys (Bearer, sk-…, gh…, etc.). */
46
- | 'API_KEY'
47
- /** AWS Access Key IDs (AKIA…) and Secret Access Keys. */
48
- | 'AWS_KEY'
49
- /** Blockchain wallet addresses (Bitcoin, Ethereum, etc.). */
50
- | 'CRYPTO_ADDRESS'
51
- /** Full or partial personal names identified by NER. */
52
- | 'PERSON'
53
- /** Company, agency, or institution names identified by NER. */
54
- | 'ORGANIZATION'
55
- /** Geographical locations (city, country, address) identified by NER. */
56
- | 'LOCATION'
57
- /** Clinical terminology, diagnoses, medications, or health conditions. */
58
- | 'MEDICAL_TERM'
59
- /**
60
- * Catch-all bucket for spans flagged by the LLM judge or custom denylist
61
- * rules that do not map to a more specific type.
62
- */
63
- | 'UNKNOWN_PII';
64
- /**
65
- * Immutable array listing every {@link PiiEntityType} value in declaration
66
- * order. Useful for iterating all types, building UI checkboxes, or asserting
67
- * total coverage in tests.
68
- *
69
- * @example
70
- * ```ts
71
- * const allEnabled: PiiEntityType[] = [...ALL_PII_ENTITY_TYPES];
72
- * ```
73
- */
74
- export declare const ALL_PII_ENTITY_TYPES: readonly PiiEntityType[];
75
- /**
76
- * A single detected PII entity span within a text.
77
- *
78
- * Coordinates (`start`, `end`) are UTF-16 code-unit offsets (i.e. the same
79
- * unit used by `String.prototype.slice`) so they can be applied directly to
80
- * the original input string without any conversion.
81
- */
82
- export interface PiiEntity {
83
- /** The semantic category of the detected PII. */
84
- entityType: PiiEntityType;
85
- /**
86
- * The exact matched substring from the input text.
87
- * Preserves original casing and surrounding punctuation that was part of
88
- * the match (e.g. the angle-brackets in `<user@example.com>`).
89
- */
90
- text: string;
91
- /**
92
- * Zero-based start offset (inclusive) of the match in the original string,
93
- * measured in UTF-16 code units.
94
- */
95
- start: number;
96
- /**
97
- * Zero-based end offset (exclusive) of the match in the original string,
98
- * measured in UTF-16 code units.
99
- * Equivalent to `start + text.length` for BMP characters.
100
- */
101
- end: number;
102
- /**
103
- * Confidence score in the range [0, 1].
104
- * - `1.0` — deterministic (e.g. regex + checksum validation)
105
- * - `0.7–0.99` — high-confidence NER or heuristic match
106
- * - `< 0.5` — speculative; may be a false positive
107
- */
108
- score: number;
109
- /**
110
- * The detection tier that produced this entity.
111
- * - `'regex'` — Tier 0 pattern matcher
112
- * - `'ner'` — Tier 1 named-entity recognition model
113
- * - `'llm'` — Tier 2 LLM judge
114
- * - `'denylist'` — explicit denylist rule
115
- */
116
- source: 'regex' | 'nlp-prefilter' | 'ner-model' | 'ner' | 'llm' | 'denylist';
117
- /**
118
- * Arbitrary key-value metadata attached by the recogniser that produced
119
- * this entity. Examples: `{ "pattern": "US_SSN_DASHES" }` or
120
- * `{ "nerLabel": "PER", "nerModel": "en_core_web_sm" }`.
121
- */
122
- metadata?: Record<string, unknown>;
123
- }
124
- /**
125
- * Controls how detected PII spans are replaced in the redacted output.
126
- *
127
- * | Style | Example output |
128
- * |---|---|
129
- * | `'placeholder'` | `[EMAIL]` |
130
- * | `'mask'` | `***` |
131
- * | `'hash'` | `a3f2c1d…` (SHA-256 truncated to 8 hex chars) |
132
- * | `'category-tag'` | `<PII type="EMAIL"/>` |
133
- */
134
- export type RedactionStyle = 'placeholder' | 'mask' | 'hash' | 'category-tag';
135
- /**
136
- * The full output of a PII detection pass over a single input string.
137
- */
138
- export interface PiiDetectionResult {
139
- /**
140
- * All PII entities detected in the input, sorted by `start` offset in
141
- * ascending order. Non-overlapping spans are guaranteed; if two recognisers
142
- * emit overlapping matches the one with the higher `score` is kept.
143
- */
144
- entities: PiiEntity[];
145
- /**
146
- * Length of the original input string in UTF-16 code units.
147
- * Stored for downstream metrics and to avoid re-measuring.
148
- */
149
- inputLength: number;
150
- /**
151
- * Wall-clock time in milliseconds spent running all detection tiers for
152
- * this particular input.
153
- */
154
- processingTimeMs: number;
155
- /**
156
- * Which detection tiers were actually executed, in execution order.
157
- * Possible values: `'regex'`, `'ner'`, `'llm'`.
158
- * A tier is omitted when it is disabled in {@link PiiRedactionPackOptions}
159
- * or when early-exit conditions prevent it from running.
160
- */
161
- tiersExecuted: Array<'regex' | 'ner' | 'llm'>;
162
- /**
163
- * Human-readable summary of detection results, e.g.:
164
- * `"3 entities found: 1×EMAIL, 1×PHONE, 1×PERSON"`.
165
- * Intended for logging and observability dashboards.
166
- */
167
- summary: string;
168
- }
169
- /**
170
- * Configuration for the optional Tier-2 LLM judge that re-examines candidate
171
- * spans flagged by earlier tiers and catches context-dependent PII that
172
- * regex/NER cannot reliably detect.
173
- *
174
- * Using a small, cheap model (e.g. `gpt-4o-mini`) is strongly recommended
175
- * because the judge is called once per input chunk and latency matters.
176
- */
177
- export interface LlmJudgeConfig {
178
- /**
179
- * LLM provider identifier. Must match a key registered in the
180
- * AgentOS `ProviderRegistry` (e.g. `'openai'`, `'anthropic'`,
181
- * `'mistral'`).
182
- */
183
- provider: string;
184
- /**
185
- * Specific model to use for PII judgement.
186
- * @example `'gpt-4o-mini'`, `'claude-haiku-3-5'`
187
- */
188
- model: string;
189
- /**
190
- * API key for the chosen provider. If omitted, the pack will attempt to
191
- * read the key from the environment using the provider's conventional
192
- * variable name (e.g. `OPENAI_API_KEY`).
193
- */
194
- apiKey?: string;
195
- /**
196
- * Custom base URL for self-hosted or proxy deployments
197
- * (e.g. an OpenAI-compatible local server).
198
- */
199
- baseUrl?: string;
200
- /**
201
- * Maximum number of LLM requests that may be in-flight simultaneously.
202
- * Prevents rate-limit exhaustion on high-throughput agents.
203
- * @default 4
204
- */
205
- maxConcurrency?: number;
206
- /**
207
- * Maximum number of (input → judgement) results to keep in the in-memory
208
- * LRU cache. Set to `0` to disable caching.
209
- * @default 256
210
- */
211
- cacheSize?: number;
212
- }
213
- /**
214
- * Top-level configuration object passed to `createPiiRedactionPack()`.
215
- *
216
- * All properties are optional; sensible defaults are applied by the pack
217
- * factory so that a zero-config setup works out of the box.
218
- */
219
- export interface PiiRedactionPackOptions {
220
- /**
221
- * Subset of {@link PiiEntityType} values to detect.
222
- * Defaults to {@link ALL_PII_ENTITY_TYPES} when omitted.
223
- *
224
- * Narrowing this list improves performance by skipping irrelevant regex
225
- * patterns and NER labels.
226
- */
227
- entityTypes?: PiiEntityType[];
228
- /**
229
- * Minimum confidence score (inclusive) required for an entity to be
230
- * included in {@link PiiDetectionResult.entities}.
231
- * Must be in the range [0, 1].
232
- * @default 0.6
233
- */
234
- confidenceThreshold?: number;
235
- /**
236
- * Redaction style applied when replacing detected PII in output text.
237
- * @default 'placeholder'
238
- */
239
- redactionStyle?: RedactionStyle;
240
- /**
241
- * Exact strings or RegExp patterns that should be unconditionally excluded
242
- * from redaction even when they match a PII pattern.
243
- *
244
- * @example `['support@example.com', /\b192\.168\.\d+\.\d+\b/]`
245
- */
246
- allowlist?: Array<string | RegExp>;
247
- /**
248
- * Exact strings or RegExp patterns that should always be redacted as
249
- * {@link PiiEntityType | `UNKNOWN_PII`} regardless of other detection
250
- * results.
251
- *
252
- * @example `['ACME-SECRET', /employee_id:\s*\d{6}/]`
253
- */
254
- denylist?: Array<string | RegExp>;
255
- /**
256
- * Whether to load and run a local NER model (Tier 1) in addition to
257
- * regex patterns (Tier 0). Enabling this improves recall for `PERSON`,
258
- * `ORGANIZATION`, and `LOCATION` at the cost of higher memory usage.
259
- * @default false
260
- */
261
- enableNerModel?: boolean;
262
- /**
263
- * When provided, enables the LLM-powered Tier-2 judge for context-aware
264
- * PII detection. When omitted, Tier 2 is disabled.
265
- */
266
- llmJudge?: LlmJudgeConfig;
267
- /**
268
- * Determines which agent messages are evaluated by the guardrail hook.
269
- * - `'input'` — only inbound user messages
270
- * - `'output'` — only outbound assistant messages
271
- * - `'both'` — evaluate and redact in both directions
272
- * @default 'both'
273
- */
274
- guardrailScope?: 'input' | 'output' | 'both';
275
- /**
276
- * When `true`, the guardrail hook will also evaluate individual streaming
277
- * chunks (SSE deltas) as they arrive, not just the fully-assembled message.
278
- * This reduces the window during which PII could be leaked but increases
279
- * CPU overhead.
280
- * @default false
281
- */
282
- evaluateStreamingChunks?: boolean;
283
- /**
284
- * Maximum number of streaming chunks evaluated per request when
285
- * {@link evaluateStreamingChunks} is `true`. Older chunks are dropped
286
- * once the limit is reached to bound memory growth on long streams.
287
- * @default 50
288
- */
289
- maxStreamingEvaluations?: number;
290
- }
291
- /**
292
- * Stable string identifiers for every injectable service provided by the PII
293
- * redaction pack. Values follow the AgentOS convention:
294
- * `agentos:<domain>:<service-name>`.
295
- *
296
- * These constants are used as keys in the {@link ISharedServiceRegistry} so
297
- * that other extensions and tools can look up pack services without importing
298
- * concrete implementations.
299
- *
300
- * @example
301
- * ```ts
302
- * const detector = registry.get<IPiiDetectionService>(PII_SERVICE_IDS.DETECTION_SERVICE);
303
- * ```
304
- */
305
- export declare const PII_SERVICE_IDS: {
306
- /**
307
- * Main detection service that orchestrates all tiers and returns
308
- * {@link PiiDetectionResult}.
309
- */
310
- readonly DETECTION_SERVICE: "agentos:pii:detection-service";
311
- /**
312
- * Redaction service that applies the configured {@link RedactionStyle}
313
- * to a raw string given a {@link PiiDetectionResult}.
314
- */
315
- readonly REDACTION_SERVICE: "agentos:pii:redaction-service";
316
- /**
317
- * Guardrail hook factory that integrates with the AgentOS hook pipeline
318
- * to intercept and sanitise agent messages automatically.
319
- */
320
- readonly GUARDRAIL_HOOK: "agentos:pii:guardrail-hook";
321
- /**
322
- * Audit logger that records redaction events for compliance reporting.
323
- * Implementations may write to stdout, a file, or a remote SIEM sink.
324
- */
325
- readonly AUDIT_LOGGER: "agentos:pii:audit-logger";
326
- };
327
- /**
328
- * Union of all {@link PII_SERVICE_IDS} values — useful for type-narrowing in
329
- * registry look-ups.
330
- */
331
- export type PiiServiceId = (typeof PII_SERVICE_IDS)[keyof typeof PII_SERVICE_IDS];
332
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/extensions/packs/pii-redaction/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,aAAa;AACvB,uDAAuD;AACrD,KAAK;AACP,2DAA2D;GACzD,aAAa;AACf,gCAAgC;GAC9B,OAAO;AACT,8EAA8E;GAC5E,OAAO;AACT,+BAA+B;GAC7B,YAAY;AACd,qDAAqD;GACnD,MAAM;AACR,0DAA0D;GACxD,UAAU;AACZ,qFAAqF;GACnF,iBAAiB;AACnB,qEAAqE;GACnE,QAAQ;AACV,2EAA2E;GACzE,eAAe;AACjB,oEAAoE;GAClE,SAAS;AACX,yDAAyD;GACvD,SAAS;AACX,6DAA6D;GAC3D,gBAAgB;AAClB,wDAAwD;GACtD,QAAQ;AACV,+DAA+D;GAC7D,cAAc;AAChB,yEAAyE;GACvE,UAAU;AACZ,0EAA0E;GACxE,cAAc;AAChB;;;GAGG;GACD,aAAa,CAAC;AAMlB;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,aAAa,EAmB/C,CAAC;AAMX;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,iDAAiD;IACjD,UAAU,EAAE,aAAa,CAAC;IAE1B;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;;OAKG;IACH,KAAK,EAAE,M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AAM,GAAG,MAAM,CAAC,CAAC;IAEnC;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAElC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAE1B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAE7C;;;;;;OAMG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAMD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe;IAC1B;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;CAEK,CAAC;AAEX;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC"}
@@ -1,83 +0,0 @@
1
- /**
2
- * @file types.ts
3
- * @description Core type definitions for the PII Redaction extension pack.
4
- *
5
- * This module defines all shared types used across the PII detection pipeline:
6
- * entity types, detection results, redaction styles, configuration interfaces,
7
- * and stable service identity constants.
8
- *
9
- * @module pii-redaction/types
10
- */
11
- // ---------------------------------------------------------------------------
12
- // Canonical array of all entity types
13
- // ---------------------------------------------------------------------------
14
- /**
15
- * Immutable array listing every {@link PiiEntityType} value in declaration
16
- * order. Useful for iterating all types, building UI checkboxes, or asserting
17
- * total coverage in tests.
18
- *
19
- * @example
20
- * ```ts
21
- * const allEnabled: PiiEntityType[] = [...ALL_PII_ENTITY_TYPES];
22
- * ```
23
- */
24
- export const ALL_PII_ENTITY_TYPES = [
25
- 'SSN',
26
- 'CREDIT_CARD',
27
- 'EMAIL',
28
- 'PHONE',
29
- 'IP_ADDRESS',
30
- 'IBAN',
31
- 'PASSPORT',
32
- 'DRIVERS_LICENSE',
33
- 'GOV_ID',
34
- 'DATE_OF_BIRTH',
35
- 'API_KEY',
36
- 'AWS_KEY',
37
- 'CRYPTO_ADDRESS',
38
- 'PERSON',
39
- 'ORGANIZATION',
40
- 'LOCATION',
41
- 'MEDICAL_TERM',
42
- 'UNKNOWN_PII',
43
- ];
44
- // ---------------------------------------------------------------------------
45
- // Service identity constants
46
- // ---------------------------------------------------------------------------
47
- /**
48
- * Stable string identifiers for every injectable service provided by the PII
49
- * redaction pack. Values follow the AgentOS convention:
50
- * `agentos:<domain>:<service-name>`.
51
- *
52
- * These constants are used as keys in the {@link ISharedServiceRegistry} so
53
- * that other extensions and tools can look up pack services without importing
54
- * concrete implementations.
55
- *
56
- * @example
57
- * ```ts
58
- * const detector = registry.get<IPiiDetectionService>(PII_SERVICE_IDS.DETECTION_SERVICE);
59
- * ```
60
- */
61
- export const PII_SERVICE_IDS = {
62
- /**
63
- * Main detection service that orchestrates all tiers and returns
64
- * {@link PiiDetectionResult}.
65
- */
66
- DETECTION_SERVICE: 'agentos:pii:detection-service',
67
- /**
68
- * Redaction service that applies the configured {@link RedactionStyle}
69
- * to a raw string given a {@link PiiDetectionResult}.
70
- */
71
- REDACTION_SERVICE: 'agentos:pii:redaction-service',
72
- /**
73
- * Guardrail hook factory that integrates with the AgentOS hook pipeline
74
- * to intercept and sanitise agent messages automatically.
75
- */
76
- GUARDRAIL_HOOK: 'agentos:pii:guardrail-hook',
77
- /**
78
- * Audit logger that records redaction events for compliance reporting.
79
- * Implementations may write to stdout, a file, or a remote SIEM sink.
80
- */
81
- AUDIT_LOGGER: 'agentos:pii:audit-logger',
82
- };
83
- //# sourceMappingURL=types.js.map