@secureai-sdk/sdk 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/bin/cli.d.ts +7 -0
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +970 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/bin/mcp-proxy.js +0 -0
- package/dist/client.d.ts +13 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +13 -1
- package/dist/client.js.map +1 -1
- package/dist/grok-bot.d.ts +14 -0
- package/dist/grok-bot.d.ts.map +1 -1
- package/dist/grok-bot.js +21 -1
- package/dist/grok-bot.js.map +1 -1
- package/dist/guard.d.ts +1 -0
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +2 -1
- package/dist/guard.js.map +1 -1
- package/dist/vault.d.ts +2 -0
- package/dist/vault.d.ts.map +1 -1
- package/dist/vault.js +5 -1
- package/dist/vault.js.map +1 -1
- package/package.json +4 -2
- package/src/bin/cli.ts +958 -0
- package/src/client.ts +26 -1
- package/src/grok-bot.ts +28 -0
- package/src/guard.ts +3 -0
- package/src/vault.ts +4 -0
package/src/client.ts
CHANGED
|
@@ -47,7 +47,7 @@ export class SecureAI {
|
|
|
47
47
|
headers: {
|
|
48
48
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
49
49
|
"Content-Type": "application/json",
|
|
50
|
-
"User-Agent": "@secureai-sdk/sdk-node/1.2.
|
|
50
|
+
"User-Agent": "@secureai-sdk/sdk-node/1.2.4",
|
|
51
51
|
...(options.headers || {})
|
|
52
52
|
}
|
|
53
53
|
});
|
|
@@ -115,6 +115,31 @@ export class SecureAI {
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Convenience alias for LangGraph and prompt inspection.
|
|
120
|
+
*/
|
|
121
|
+
public async inspectPrompt(prompt: string, context?: UserSecurityContext): Promise<PromptInspectionResult> {
|
|
122
|
+
return this.inspect(prompt, context);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Convenience alias for CrewAI and agent tool call interceptors.
|
|
127
|
+
*/
|
|
128
|
+
public async interceptTool(options: {
|
|
129
|
+
botId?: string;
|
|
130
|
+
toolName: string;
|
|
131
|
+
arguments?: Record<string, any>;
|
|
132
|
+
context?: UserSecurityContext;
|
|
133
|
+
}): Promise<AgentActionVerdict> {
|
|
134
|
+
return this.interceptAgentAction(
|
|
135
|
+
"EXECUTE_SHELL",
|
|
136
|
+
options.toolName,
|
|
137
|
+
JSON.stringify(options.arguments || {}),
|
|
138
|
+
options.context
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
118
143
|
/**
|
|
119
144
|
* Scans serialized ML model weights (.pkl, .pt, .onnx) for remote code execution opcodes.
|
|
120
145
|
*/
|
package/src/grok-bot.ts
CHANGED
|
@@ -126,4 +126,32 @@ export class GrokBotGuard {
|
|
|
126
126
|
latencyMs
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Complete 3-Stage Lifecycle Protector for GrokBot and Social Agents.
|
|
132
|
+
*/
|
|
133
|
+
public async protectInteraction(options: {
|
|
134
|
+
mentionText: string;
|
|
135
|
+
userId?: string;
|
|
136
|
+
executeLLM?: (sanitized: string) => Promise<string>;
|
|
137
|
+
}): Promise<{ allow: boolean; safeText: string; sanitizedResponse: string }> {
|
|
138
|
+
const ingress = this.sanitizeMention(options.mentionText);
|
|
139
|
+
if (!ingress.isSafe) {
|
|
140
|
+
return { allow: false, safeText: ingress.sanitizedText, sanitizedResponse: "Query blocked due to policy violation." };
|
|
141
|
+
}
|
|
142
|
+
let responseText = "";
|
|
143
|
+
if (options.executeLLM) {
|
|
144
|
+
responseText = await options.executeLLM(ingress.sanitizedText);
|
|
145
|
+
}
|
|
146
|
+
const egress = this.sanitizeEgress(responseText);
|
|
147
|
+
return {
|
|
148
|
+
allow: true,
|
|
149
|
+
safeText: ingress.sanitizedText,
|
|
150
|
+
sanitizedResponse: egress.sanitizedText
|
|
151
|
+
};
|
|
152
|
+
}
|
|
129
153
|
}
|
|
154
|
+
|
|
155
|
+
export const GrokBotMiddleware = GrokBotGuard;
|
|
156
|
+
export type GrokBotMiddleware = GrokBotGuard;
|
|
157
|
+
|
package/src/guard.ts
CHANGED
package/src/vault.ts
CHANGED
|
@@ -45,3 +45,7 @@ export class PIIVault {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export const defaultVault = new PIIVault();
|
|
48
|
+
|
|
49
|
+
export const tokenizePII = (text: string) => defaultVault.tokenize(text);
|
|
50
|
+
export const detokenizePII = (text: string, tokenMap: Record<string, string>) => defaultVault.detokenize(text, tokenMap);
|
|
51
|
+
|