fullcourtdefense 1.0.2 → 1.0.3
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/cli/index.js +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +25 -8
- package/dist/types.d.ts +11 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -7,7 +7,7 @@ const credits_1 = require("./commands/credits");
|
|
|
7
7
|
const init_1 = require("./commands/init");
|
|
8
8
|
const doctor_1 = require("./commands/doctor");
|
|
9
9
|
const configure_1 = require("./commands/configure");
|
|
10
|
-
const VERSION = '0.
|
|
10
|
+
const VERSION = '1.0.2';
|
|
11
11
|
function parseArgs(argv) {
|
|
12
12
|
const flags = {};
|
|
13
13
|
let command = '';
|
package/dist/client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AgentRegistrationInput, AgentSecurityApiResult, AgentToolCallCheckResul
|
|
|
2
2
|
export declare class FullCourtDefense {
|
|
3
3
|
private config;
|
|
4
4
|
chat: ChatNamespace;
|
|
5
|
-
constructor(config
|
|
5
|
+
constructor(config?: FullCourtDefenseConfig);
|
|
6
6
|
get shieldKey(): string;
|
|
7
7
|
get baseURL(): string;
|
|
8
8
|
get apiKey(): string;
|
package/dist/client.js
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FullCourtDefense = void 0;
|
|
4
4
|
const DEFAULT_API_URL = 'https://api.fullcourtdefense.ai';
|
|
5
|
+
const SHIELD_ID_ENV_VARS = ['FCD_SHIELD_ID', 'FULLCOURTDEFENSE_SHIELD_ID', 'AGENTGUARD_SHIELD_ID'];
|
|
6
|
+
const SHIELD_KEY_ENV_VARS = ['FCD_SHIELD_KEY', 'FULLCOURTDEFENSE_SHIELD_KEY', 'AGENTGUARD_SHIELD_KEY'];
|
|
7
|
+
const API_URL_ENV_VARS = ['FCD_API_URL', 'FULLCOURTDEFENSE_API_URL'];
|
|
8
|
+
const API_KEY_ENV_VARS = ['FCD_API_KEY', 'FULLCOURTDEFENSE_API_KEY', 'BOTGUARD_API_KEY'];
|
|
9
|
+
function readEnv(names) {
|
|
10
|
+
const env = globalThis.process?.env;
|
|
11
|
+
if (!env)
|
|
12
|
+
return undefined;
|
|
13
|
+
for (const name of names) {
|
|
14
|
+
const value = env[name];
|
|
15
|
+
if (value && value.trim())
|
|
16
|
+
return value.trim();
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
5
20
|
function buildScanHeaders(shieldKey, metadata, inputSource) {
|
|
6
21
|
const headers = { 'Content-Type': 'application/json' };
|
|
7
22
|
if (shieldKey)
|
|
@@ -34,8 +49,9 @@ function extractShield(data) {
|
|
|
34
49
|
function validateShieldId(shieldId) {
|
|
35
50
|
if (!shieldId || typeof shieldId !== 'string' || !shieldId.trim()) {
|
|
36
51
|
throw new Error('FullCourtDefense: shieldId is required.\n' +
|
|
37
|
-
'
|
|
38
|
-
'
|
|
52
|
+
'Pass it as: new FullCourtDefense({ shieldId: "sh_your_shield_id" })\n' +
|
|
53
|
+
'Or set one of these env vars: FCD_SHIELD_ID, FULLCOURTDEFENSE_SHIELD_ID, AGENTGUARD_SHIELD_ID\n' +
|
|
54
|
+
'Get a free Shield ID at: https://fullcourtdefense.ai → Sign up → Shield → Create Shield');
|
|
39
55
|
}
|
|
40
56
|
if (!shieldId.startsWith('sh_')) {
|
|
41
57
|
throw new Error(`FullCourtDefense: Invalid shieldId "${shieldId}". Shield IDs start with "sh_" (e.g. "sh_2803733325433b6929281d5b").\n` +
|
|
@@ -62,13 +78,14 @@ function mcpTextResult(text, isError) {
|
|
|
62
78
|
};
|
|
63
79
|
}
|
|
64
80
|
class FullCourtDefense {
|
|
65
|
-
constructor(config) {
|
|
66
|
-
|
|
81
|
+
constructor(config = {}) {
|
|
82
|
+
const shieldId = config.shieldId ?? readEnv(SHIELD_ID_ENV_VARS);
|
|
83
|
+
validateShieldId(shieldId);
|
|
67
84
|
this.config = {
|
|
68
|
-
shieldId:
|
|
69
|
-
apiKey: config.apiKey
|
|
70
|
-
shieldKey: config.shieldKey
|
|
71
|
-
apiUrl: (config.apiUrl
|
|
85
|
+
shieldId: shieldId,
|
|
86
|
+
apiKey: config.apiKey ?? readEnv(API_KEY_ENV_VARS) ?? '',
|
|
87
|
+
shieldKey: config.shieldKey ?? readEnv(SHIELD_KEY_ENV_VARS) ?? '',
|
|
88
|
+
apiUrl: (config.apiUrl ?? readEnv(API_URL_ENV_VARS) ?? DEFAULT_API_URL).replace(/\/$/, ''),
|
|
72
89
|
timeout: config.timeout || 120000,
|
|
73
90
|
};
|
|
74
91
|
this.chat = new ChatNamespace(this);
|
package/dist/types.d.ts
CHANGED
|
@@ -20,14 +20,24 @@ export interface ShieldResult<T = any> {
|
|
|
20
20
|
content: string | null;
|
|
21
21
|
}
|
|
22
22
|
export interface FullCourtDefenseConfig {
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Shield ID (`sh_…`). If omitted, the SDK reads it from the first env var
|
|
25
|
+
* found in: `FCD_SHIELD_ID`, `FULLCOURTDEFENSE_SHIELD_ID`, `AGENTGUARD_SHIELD_ID`.
|
|
26
|
+
*/
|
|
27
|
+
shieldId?: string;
|
|
24
28
|
/** LLM provider key — only required when using `fcd.chat.completions.create()` (the gateway). */
|
|
25
29
|
apiKey?: string;
|
|
26
30
|
/**
|
|
27
31
|
* Per-shield key (sent as `x-shield-key`). Required when the shield owner has
|
|
28
32
|
* locked the shield down with an API key. See your Shield page → "Access" tab.
|
|
33
|
+
* If omitted, the SDK reads it from the first env var found in:
|
|
34
|
+
* `FCD_SHIELD_KEY`, `FULLCOURTDEFENSE_SHIELD_KEY`, `AGENTGUARD_SHIELD_KEY`.
|
|
29
35
|
*/
|
|
30
36
|
shieldKey?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Backend URL. Defaults to `https://api.fullcourtdefense.ai`. Can also be set
|
|
39
|
+
* via `FCD_API_URL` / `FULLCOURTDEFENSE_API_URL` env var.
|
|
40
|
+
*/
|
|
31
41
|
apiUrl?: string;
|
|
32
42
|
timeout?: number;
|
|
33
43
|
}
|
package/package.json
CHANGED