burrow-sdk 0.5.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.
Files changed (38) hide show
  1. package/README.md +176 -0
  2. package/dist/errors.d.ts +12 -0
  3. package/dist/errors.d.ts.map +1 -0
  4. package/dist/errors.js +21 -0
  5. package/dist/errors.js.map +1 -0
  6. package/dist/index.d.ts +19 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +102 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/integrations/adk.d.ts +144 -0
  11. package/dist/integrations/adk.d.ts.map +1 -0
  12. package/dist/integrations/adk.js +323 -0
  13. package/dist/integrations/adk.js.map +1 -0
  14. package/dist/integrations/ai-sdk.d.ts +71 -0
  15. package/dist/integrations/ai-sdk.d.ts.map +1 -0
  16. package/dist/integrations/ai-sdk.js +115 -0
  17. package/dist/integrations/ai-sdk.js.map +1 -0
  18. package/dist/integrations/claude-sdk.d.ts +75 -0
  19. package/dist/integrations/claude-sdk.d.ts.map +1 -0
  20. package/dist/integrations/claude-sdk.js +127 -0
  21. package/dist/integrations/claude-sdk.js.map +1 -0
  22. package/dist/integrations/langchain.d.ts +88 -0
  23. package/dist/integrations/langchain.d.ts.map +1 -0
  24. package/dist/integrations/langchain.js +162 -0
  25. package/dist/integrations/langchain.js.map +1 -0
  26. package/dist/integrations/openai-agents.d.ts +112 -0
  27. package/dist/integrations/openai-agents.d.ts.map +1 -0
  28. package/dist/integrations/openai-agents.js +139 -0
  29. package/dist/integrations/openai-agents.js.map +1 -0
  30. package/dist/integrations/strands.d.ts +81 -0
  31. package/dist/integrations/strands.d.ts.map +1 -0
  32. package/dist/integrations/strands.js +274 -0
  33. package/dist/integrations/strands.js.map +1 -0
  34. package/dist/types.d.ts +30 -0
  35. package/dist/types.d.ts.map +1 -0
  36. package/dist/types.js +7 -0
  37. package/dist/types.js.map +1 -0
  38. package/package.json +66 -0
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Burrow adapter for the Anthropic Claude Agent SDK (TypeScript).
3
+ *
4
+ * Provides hook callbacks for PreToolUse and PostToolUse events that scan
5
+ * tool inputs/outputs through Burrow for prompt injection detection.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { BurrowGuard } from "burrow-sdk";
10
+ * import { createBurrowHooks } from "burrow-sdk/integrations/claude-sdk";
11
+ * import { query } from "@anthropic-ai/claude-agent-sdk";
12
+ *
13
+ * const guard = new BurrowGuard({ clientId: "...", clientSecret: "..." });
14
+ * const hooks = createBurrowHooks(guard);
15
+ *
16
+ * for await (const message of query({
17
+ * prompt: "Your prompt",
18
+ * options: { hooks },
19
+ * })) {
20
+ * console.log(message);
21
+ * }
22
+ * ```
23
+ */
24
+ /** Thrown when Burrow blocks a Claude SDK tool call. */
25
+ export class BurrowBlockedError extends Error {
26
+ result;
27
+ constructor(result) {
28
+ super(`Burrow blocked: ${result.category} (${Math.round(result.confidence * 100)}% confidence)`);
29
+ this.name = "BurrowBlockedError";
30
+ this.result = result;
31
+ }
32
+ }
33
+ /**
34
+ * Extract scannable text from tool input arguments.
35
+ * Prioritizes known text-bearing fields, falls back to JSON serialization.
36
+ */
37
+ function extractToolInputText(toolInput) {
38
+ const textFields = ["command", "content", "query", "text", "url", "file_path", "pattern"];
39
+ const parts = [];
40
+ for (const key of textFields) {
41
+ if (key in toolInput && toolInput[key] != null) {
42
+ parts.push(String(toolInput[key]));
43
+ }
44
+ }
45
+ return parts.length > 0 ? parts.join(" ").trim() : JSON.stringify(toolInput);
46
+ }
47
+ /**
48
+ * Create Claude Agent SDK hooks that scan tool calls with Burrow.
49
+ *
50
+ * Returns a hooks configuration object compatible with the `query()` function
51
+ * from `@anthropic-ai/claude-agent-sdk`. The hooks intercept PreToolUse
52
+ * and PostToolUse events to scan for prompt injection.
53
+ *
54
+ * **Per-agent identity limitation:** The Claude Agent SDK hook context does
55
+ * not currently carry agent identity. For multi-agent setups, create
56
+ * separate hooks with different `agentName` values:
57
+ *
58
+ * ```ts
59
+ * const orchestratorHooks = createBurrowHooks(guard, { agentName: "claude-sdk:orchestrator" });
60
+ * const researcherHooks = createBurrowHooks(guard, { agentName: "claude-sdk:researcher" });
61
+ * ```
62
+ */
63
+ export function createBurrowHooks(guard, options = {}) {
64
+ const agentName = options.agentName ?? "claude-sdk";
65
+ const blockOnWarn = options.blockOnWarn ?? false;
66
+ const scanToolCalls = options.scanToolCalls ?? true;
67
+ const scanToolResults = options.scanToolResults ?? true;
68
+ function shouldBlock(result) {
69
+ return result.action === "block" || (blockOnWarn && result.action === "warn");
70
+ }
71
+ const hooks = {};
72
+ if (scanToolCalls) {
73
+ const preToolCallback = async (input, _toolUseId, _context) => {
74
+ const toolInput = input.tool_input ?? {};
75
+ const text = extractToolInputText(toolInput);
76
+ if (!text.trim())
77
+ return {};
78
+ const result = await guard.scan(text, {
79
+ contentType: "tool_call",
80
+ agent: agentName,
81
+ toolName: input.tool_name,
82
+ });
83
+ if (shouldBlock(result)) {
84
+ return {
85
+ hookSpecificOutput: {
86
+ hookEventName: input.hook_event_name,
87
+ permissionDecision: "deny",
88
+ permissionDecisionReason: `Blocked by Burrow: ${result.category} ` +
89
+ `(${Math.round(result.confidence * 100)}% confidence)`,
90
+ },
91
+ };
92
+ }
93
+ return {};
94
+ };
95
+ hooks.PreToolUse = [{ matcher: ".*", hooks: [preToolCallback] }];
96
+ }
97
+ if (scanToolResults) {
98
+ const postToolCallback = async (input, _toolUseId, _context) => {
99
+ // PostToolUse events include the tool output in tool_input
100
+ const output = input.tool_input ?? {};
101
+ const text = typeof output === "string" ? output : JSON.stringify(output);
102
+ if (!text.trim())
103
+ return {};
104
+ const result = await guard.scan(text.slice(0, 4096), {
105
+ contentType: "tool_response",
106
+ agent: agentName,
107
+ toolName: input.tool_name,
108
+ });
109
+ if (shouldBlock(result)) {
110
+ // Log warning but don't block post-execution — the tool already ran.
111
+ // The deny signal tells the agent to treat the result with caution.
112
+ return {
113
+ hookSpecificOutput: {
114
+ hookEventName: input.hook_event_name,
115
+ burrowAction: result.action,
116
+ burrowCategory: result.category,
117
+ burrowConfidence: result.confidence,
118
+ },
119
+ };
120
+ }
121
+ return {};
122
+ };
123
+ hooks.PostToolUse = [{ matcher: ".*", hooks: [postToolCallback] }];
124
+ }
125
+ return hooks;
126
+ }
127
+ //# sourceMappingURL=claude-sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-sdk.js","sourceRoot":"","sources":["../../src/integrations/claude-sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,wDAAwD;AACxD,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3B,MAAM,CAAa;IAEnC,YAAY,MAAkB;QAC5B,KAAK,CACH,mBAAmB,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,GAAG,GAAG,CAAC,eAAe,CAC1F,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAkCD;;;GAGG;AACH,SAAS,oBAAoB,CAAC,SAAkC;IAC9D,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IAC1F,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,IAAI,GAAG,IAAI,SAAS,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;YAC/C,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,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,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC;QAEF,KAAK,CAAC,WAAW,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Burrow adapter for LangChain.js.
3
+ *
4
+ * Provides a callback handler that scans messages before they reach the LLM.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { BurrowGuard } from "burrow-sdk";
9
+ * import { createBurrowCallback } from "burrow-sdk/integrations/langchain";
10
+ *
11
+ * const guard = new BurrowGuard({ clientId: "...", clientSecret: "..." });
12
+ * const callback = createBurrowCallback(guard);
13
+ *
14
+ * const model = new ChatOpenAI({ model: "gpt-4", callbacks: [callback] });
15
+ * ```
16
+ */
17
+ import type { BurrowGuard } from "../index.js";
18
+ /** Thrown when Burrow blocks a LangChain message. */
19
+ export declare class BurrowScanError extends Error {
20
+ readonly result: {
21
+ action: string;
22
+ category: string;
23
+ confidence: number;
24
+ };
25
+ constructor(result: {
26
+ action: string;
27
+ category: string;
28
+ confidence: number;
29
+ });
30
+ }
31
+ export interface BurrowCallbackOptions {
32
+ /** Agent name for scan context. */
33
+ agent?: string;
34
+ /** If true, also block on "warn" verdicts. */
35
+ blockOnWarn?: boolean;
36
+ }
37
+ /**
38
+ * Create a LangChain.js callback handler that scans messages with Burrow.
39
+ *
40
+ * Returns an object implementing the BaseCallbackHandler interface from
41
+ * `@langchain/core/callbacks`. Pass it to any LangChain model or chain
42
+ * via the `callbacks` option.
43
+ *
44
+ * The handler is framework-agnostic — it only uses the callback method
45
+ * signatures so you don't need `@langchain/core` installed to import this
46
+ * module. The actual types are resolved at runtime by LangChain.
47
+ */
48
+ export declare function createBurrowCallback(guard: BurrowGuard, options?: BurrowCallbackOptions): {
49
+ name: string;
50
+ /**
51
+ * Scan prompts before a completion-style LLM call.
52
+ */
53
+ handleLLMStart(_serialized: Record<string, unknown>, prompts: string[]): Promise<void>;
54
+ /**
55
+ * Scan messages before a chat-style LLM call.
56
+ */
57
+ handleChatModelStart(_serialized: Record<string, unknown>, messages: Array<Array<{
58
+ content?: string;
59
+ type?: string;
60
+ }>>): Promise<void>;
61
+ /**
62
+ * Scan tool output after execution.
63
+ */
64
+ handleToolEnd(output: string, kwargs?: Record<string, unknown>): Promise<void>;
65
+ };
66
+ export interface BurrowCallbackV2Options {
67
+ /** Fallback agent name when LangGraph node is unavailable. */
68
+ defaultAgent?: string;
69
+ /** If true, also block on "warn" verdicts. */
70
+ blockOnWarn?: boolean;
71
+ }
72
+ /**
73
+ * Create a LangChain.js callback handler with per-agent identity.
74
+ *
75
+ * Automatically extracts the LangGraph node name from callback metadata,
76
+ * producing agent names like `langchain:retriever` or `langchain:writer`.
77
+ * Falls back to `defaultAgent` when no node name is available.
78
+ */
79
+ export declare function createBurrowCallbackV2(guard: BurrowGuard, options?: BurrowCallbackV2Options): {
80
+ name: string;
81
+ handleLLMStart(_serialized: Record<string, unknown>, prompts: string[], kwargs?: Record<string, unknown>): Promise<void>;
82
+ handleChatModelStart(_serialized: Record<string, unknown>, messages: Array<Array<{
83
+ content?: string;
84
+ type?: string;
85
+ }>>, kwargs?: Record<string, unknown>): Promise<void>;
86
+ handleToolEnd(output: string, kwargs?: Record<string, unknown>): Promise<void>;
87
+ };
88
+ //# sourceMappingURL=langchain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langchain.d.ts","sourceRoot":"","sources":["../../src/integrations/langchain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,qDAAqD;AACrD,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAgB,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAA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C;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,WAClD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,IAAI,CAAC;0BAiBY,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;EAYvF"}
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Burrow adapter for LangChain.js.
3
+ *
4
+ * Provides a callback handler that scans messages before they reach the LLM.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { BurrowGuard } from "burrow-sdk";
9
+ * import { createBurrowCallback } from "burrow-sdk/integrations/langchain";
10
+ *
11
+ * const guard = new BurrowGuard({ clientId: "...", clientSecret: "..." });
12
+ * const callback = createBurrowCallback(guard);
13
+ *
14
+ * const model = new ChatOpenAI({ model: "gpt-4", callbacks: [callback] });
15
+ * ```
16
+ */
17
+ /** Thrown when Burrow blocks a LangChain message. */
18
+ export class BurrowScanError extends Error {
19
+ result;
20
+ constructor(result) {
21
+ super(`Burrow blocked message: ${result.category} (${Math.round(result.confidence * 100)}% confidence)`);
22
+ this.name = "BurrowScanError";
23
+ this.result = result;
24
+ }
25
+ }
26
+ /**
27
+ * Create a LangChain.js callback handler that scans messages with Burrow.
28
+ *
29
+ * Returns an object implementing the BaseCallbackHandler interface from
30
+ * `@langchain/core/callbacks`. Pass it to any LangChain model or chain
31
+ * via the `callbacks` option.
32
+ *
33
+ * The handler is framework-agnostic — it only uses the callback method
34
+ * signatures so you don't need `@langchain/core` installed to import this
35
+ * module. The actual types are resolved at runtime by LangChain.
36
+ */
37
+ export function createBurrowCallback(guard, options = {}) {
38
+ const agent = options.agent ?? "langchain";
39
+ const blockOnWarn = options.blockOnWarn ?? false;
40
+ function shouldBlock(result) {
41
+ return result.action === "block" || (blockOnWarn && result.action === "warn");
42
+ }
43
+ return {
44
+ name: "burrow_guard",
45
+ /**
46
+ * Scan prompts before a completion-style LLM call.
47
+ */
48
+ async handleLLMStart(_serialized, prompts) {
49
+ for (const prompt of prompts) {
50
+ if (!prompt.trim())
51
+ continue;
52
+ const result = await guard.scan(prompt, {
53
+ contentType: "user_prompt",
54
+ agent,
55
+ });
56
+ if (shouldBlock(result))
57
+ throw new BurrowScanError(result);
58
+ }
59
+ },
60
+ /**
61
+ * Scan messages before a chat-style LLM call.
62
+ */
63
+ async handleChatModelStart(_serialized, messages) {
64
+ for (const batch of messages) {
65
+ for (const msg of batch) {
66
+ const content = typeof msg.content === "string" ? msg.content : String(msg.content ?? "");
67
+ if (!content.trim())
68
+ continue;
69
+ const contentType = msg.type === "tool" ? "tool_response" : "user_prompt";
70
+ const result = await guard.scan(content, {
71
+ contentType: contentType,
72
+ agent,
73
+ });
74
+ if (shouldBlock(result))
75
+ throw new BurrowScanError(result);
76
+ }
77
+ }
78
+ },
79
+ /**
80
+ * Scan tool output after execution.
81
+ */
82
+ async handleToolEnd(output, kwargs) {
83
+ if (typeof output === "string" && output.trim()) {
84
+ const result = await guard.scan(output, {
85
+ contentType: "tool_response",
86
+ agent,
87
+ toolName: kwargs?.name,
88
+ });
89
+ if (shouldBlock(result))
90
+ throw new BurrowScanError(result);
91
+ }
92
+ },
93
+ };
94
+ }
95
+ /**
96
+ * Create a LangChain.js callback handler with per-agent identity.
97
+ *
98
+ * Automatically extracts the LangGraph node name from callback metadata,
99
+ * producing agent names like `langchain:retriever` or `langchain:writer`.
100
+ * Falls back to `defaultAgent` when no node name is available.
101
+ */
102
+ export function createBurrowCallbackV2(guard, options = {}) {
103
+ const defaultAgent = options.defaultAgent ?? "langchain";
104
+ const blockOnWarn = options.blockOnWarn ?? false;
105
+ function shouldBlock(result) {
106
+ return result.action === "block" || (blockOnWarn && result.action === "warn");
107
+ }
108
+ function resolveAgent(kwargs) {
109
+ const metadata = kwargs?.metadata;
110
+ const node = metadata?.langgraph_node;
111
+ if (typeof node === "string" && node) {
112
+ return `langchain:${node}`;
113
+ }
114
+ return defaultAgent;
115
+ }
116
+ return {
117
+ name: "burrow_guard_v2",
118
+ async handleLLMStart(_serialized, prompts, kwargs) {
119
+ const agent = resolveAgent(kwargs);
120
+ for (const prompt of prompts) {
121
+ if (!prompt.trim())
122
+ continue;
123
+ const result = await guard.scan(prompt, {
124
+ contentType: "user_prompt",
125
+ agent,
126
+ });
127
+ if (shouldBlock(result))
128
+ throw new BurrowScanError(result);
129
+ }
130
+ },
131
+ async handleChatModelStart(_serialized, messages, kwargs) {
132
+ const agent = resolveAgent(kwargs);
133
+ for (const batch of messages) {
134
+ for (const msg of batch) {
135
+ const content = typeof msg.content === "string" ? msg.content : String(msg.content ?? "");
136
+ if (!content.trim())
137
+ continue;
138
+ const contentType = msg.type === "tool" ? "tool_response" : "user_prompt";
139
+ const result = await guard.scan(content, {
140
+ contentType: contentType,
141
+ agent,
142
+ });
143
+ if (shouldBlock(result))
144
+ throw new BurrowScanError(result);
145
+ }
146
+ }
147
+ },
148
+ async handleToolEnd(output, kwargs) {
149
+ if (typeof output === "string" && output.trim()) {
150
+ const agent = resolveAgent(kwargs);
151
+ const result = await guard.scan(output, {
152
+ contentType: "tool_response",
153
+ agent,
154
+ toolName: kwargs?.name,
155
+ });
156
+ if (shouldBlock(result))
157
+ throw new BurrowScanError(result);
158
+ }
159
+ },
160
+ };
161
+ }
162
+ //# sourceMappingURL=langchain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langchain.js","sourceRoot":"","sources":["../../src/integrations/langchain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,qDAAqD;AACrD,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxB,MAAM,CAA2D;IAEjF,YAAY,MAAgE;QAC1E,KAAK,CACH,2BAA2B,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,GAAG,GAAG,CAAC,eAAe,CAClG,CAAC;QACF,IAAI,CAAC,IAAI,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C,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC;oBAC1E,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE;wBACvC,WAAW,EAAE,WAA8C;wBAC3D,KAAK;qBACN,CAAC,CAAC;oBACH,IAAI,WAAW,CAAC,MAAM,CAAC;wBAAE,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;gBAC7D,CAAC;YACH,CAAC;QACH,CAAC;QAED,KAAK,CAAC,aAAa,CAAC,MAAc,EAAE,MAAgC;YAClE,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;gBAChD,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;gBACnC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE;oBACtC,WAAW,EAAE,eAAe;oBAC5B,KAAK;oBACL,QAAQ,EAAG,MAA8C,EAAE,IAA0B;iBACtF,CAAC,CAAC;gBACH,IAAI,WAAW,CAAC,MAAM,CAAC;oBAAE,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Burrow adapter for the OpenAI Agents SDK (JavaScript/TypeScript).
3
+ *
4
+ * Provides InputGuardrail and OutputGuardrail objects that scan messages
5
+ * with Burrow before/after agent processing.
6
+ *
7
+ * **Tool-level scanning limitation:** The OpenAI Agents SDK guardrails
8
+ * operate at the input/output level only — they see the full agent input
9
+ * or output text, but do **not** have access to individual `toolName` or
10
+ * `toolArgs`. This is an architectural limitation of the Agents SDK
11
+ * guardrail system.
12
+ *
13
+ * For tool-level scanning, call `guard.scan()` directly inside your tool
14
+ * implementations:
15
+ *
16
+ * ```ts
17
+ * const result = await guard.scan(query, {
18
+ * contentType: "tool_call",
19
+ * toolName: "my_tool",
20
+ * });
21
+ * if (result.action === "block") throw new Error("Blocked by security policy.");
22
+ * ```
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import { BurrowGuard } from "burrow-sdk";
27
+ * import { createBurrowGuardrail } from "burrow-sdk/integrations/openai-agents";
28
+ * import { Agent } from "@openai/agents";
29
+ *
30
+ * const guard = new BurrowGuard({ clientId: "...", clientSecret: "..." });
31
+ * const burrowRail = createBurrowGuardrail(guard);
32
+ *
33
+ * const agent = new Agent({
34
+ * name: "my-agent",
35
+ * inputGuardrails: [burrowRail],
36
+ * });
37
+ * ```
38
+ */
39
+ import type { BurrowGuard } from "../index.js";
40
+ export interface GuardrailFunctionOutput {
41
+ outputInfo: Record<string, unknown>;
42
+ tripwireTriggered: boolean;
43
+ }
44
+ export interface BurrowGuardrailOptions {
45
+ /** Agent name for scan context. */
46
+ agentName?: string;
47
+ /** If true, also trigger on "warn" verdicts. */
48
+ blockOnWarn?: boolean;
49
+ }
50
+ /**
51
+ * Create an OpenAI Agents SDK input guardrail powered by Burrow.
52
+ *
53
+ * The returned object conforms to the `InputGuardrail` interface from
54
+ * `@openai/agents`. It scans the input text and triggers if injection
55
+ * is detected.
56
+ */
57
+ export declare function createBurrowGuardrail(guard: BurrowGuard, options?: BurrowGuardrailOptions): {
58
+ name: string;
59
+ execute({ input, }: {
60
+ input: unknown;
61
+ context: unknown;
62
+ }): Promise<GuardrailFunctionOutput>;
63
+ };
64
+ /**
65
+ * Create an OpenAI Agents SDK output guardrail powered by Burrow.
66
+ *
67
+ * Scans agent outputs for injection content that may have been
68
+ * triggered by indirect injection in tool results.
69
+ */
70
+ export declare function createBurrowOutputGuardrail(guard: BurrowGuard, options?: BurrowGuardrailOptions): {
71
+ name: string;
72
+ execute({ agentOutput, }: {
73
+ agentOutput: unknown;
74
+ context: unknown;
75
+ }): Promise<GuardrailFunctionOutput>;
76
+ };
77
+ export interface BurrowGuardrailV2Options {
78
+ /** If true, also trigger on "warn" verdicts. */
79
+ blockOnWarn?: boolean;
80
+ }
81
+ /**
82
+ * Create an OpenAI Agents SDK input guardrail with per-agent identity.
83
+ *
84
+ * Automatically reads `agent.name` from the guardrail context to produce
85
+ * agent names like `openai-agents:research-agent`.
86
+ */
87
+ export declare function createBurrowGuardrailV2(guard: BurrowGuard, options?: BurrowGuardrailV2Options): {
88
+ name: string;
89
+ execute({ input, agent, }: {
90
+ input: unknown;
91
+ agent?: {
92
+ name?: string;
93
+ };
94
+ context: unknown;
95
+ }): Promise<GuardrailFunctionOutput>;
96
+ };
97
+ /**
98
+ * Create an OpenAI Agents SDK output guardrail with per-agent identity.
99
+ *
100
+ * Automatically reads `agent.name` from the guardrail context.
101
+ */
102
+ export declare function createBurrowOutputGuardrailV2(guard: BurrowGuard, options?: BurrowGuardrailV2Options): {
103
+ name: string;
104
+ execute({ agentOutput, agent, }: {
105
+ agentOutput: unknown;
106
+ agent?: {
107
+ name?: string;
108
+ };
109
+ context: unknown;
110
+ }): Promise<GuardrailFunctionOutput>;
111
+ };
112
+ //# sourceMappingURL=openai-agents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-agents.d.ts","sourceRoot":"","sources":["../../src/integrations/openai-agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACrC,mCAAmC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAsCD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,sBAA2B;;wBAS/B;QACD,KAAK,EAAE,OAAO,CAAC;QACf,OAAO,EAAE,OAAO,CAAC;KAClB,GAAG,OAAO,CAAC,uBAAuB,CAAC;EAIvC;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,sBAA2B;;8BAS/B;QACD,WAAW,EAAE,OAAO,CAAC;QACrB,OAAO,EAAE,OAAO,CAAC;KAClB,GAAG,OAAO,CAAC,uBAAuB,CAAC;EAQvC;AAED,MAAM,WAAW,wBAAwB;IACvC,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,wBAA6B;;+BASjC;QACD,KAAK,EAAE,OAAO,CAAC;QACf,KAAK,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAC1B,OAAO,EAAE,OAAO,CAAC;KAClB,GAAG,OAAO,CAAC,uBAAuB,CAAC;EAOvC;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,wBAA6B;;qCASjC;QACD,WAAW,EAAE,OAAO,CAAC;QACrB,KAAK,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAC1B,OAAO,EAAE,OAAO,CAAC;KAClB,GAAG,OAAO,CAAC,uBAAuB,CAAC;EAWvC"}
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Burrow adapter for the OpenAI Agents SDK (JavaScript/TypeScript).
3
+ *
4
+ * Provides InputGuardrail and OutputGuardrail objects that scan messages
5
+ * with Burrow before/after agent processing.
6
+ *
7
+ * **Tool-level scanning limitation:** The OpenAI Agents SDK guardrails
8
+ * operate at the input/output level only — they see the full agent input
9
+ * or output text, but do **not** have access to individual `toolName` or
10
+ * `toolArgs`. This is an architectural limitation of the Agents SDK
11
+ * guardrail system.
12
+ *
13
+ * For tool-level scanning, call `guard.scan()` directly inside your tool
14
+ * implementations:
15
+ *
16
+ * ```ts
17
+ * const result = await guard.scan(query, {
18
+ * contentType: "tool_call",
19
+ * toolName: "my_tool",
20
+ * });
21
+ * if (result.action === "block") throw new Error("Blocked by security policy.");
22
+ * ```
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import { BurrowGuard } from "burrow-sdk";
27
+ * import { createBurrowGuardrail } from "burrow-sdk/integrations/openai-agents";
28
+ * import { Agent } from "@openai/agents";
29
+ *
30
+ * const guard = new BurrowGuard({ clientId: "...", clientSecret: "..." });
31
+ * const burrowRail = createBurrowGuardrail(guard);
32
+ *
33
+ * const agent = new Agent({
34
+ * name: "my-agent",
35
+ * inputGuardrails: [burrowRail],
36
+ * });
37
+ * ```
38
+ */
39
+ /**
40
+ * Shared guardrail execution logic for input and output guardrails.
41
+ */
42
+ async function executeGuardrail(guard, data, contentType, agentName, blockOnWarn) {
43
+ const text = typeof data === "string" ? data : String(data ?? "");
44
+ if (!text.trim()) {
45
+ return {
46
+ outputInfo: { action: "allow", reason: "empty" },
47
+ tripwireTriggered: false,
48
+ };
49
+ }
50
+ const result = await guard.scan(text, {
51
+ contentType,
52
+ agent: agentName,
53
+ });
54
+ const triggered = result.action === "block" || (blockOnWarn && result.action === "warn");
55
+ return {
56
+ outputInfo: {
57
+ action: result.action,
58
+ category: result.category,
59
+ confidence: result.confidence,
60
+ request_id: result.request_id,
61
+ },
62
+ tripwireTriggered: triggered,
63
+ };
64
+ }
65
+ /**
66
+ * Create an OpenAI Agents SDK input guardrail powered by Burrow.
67
+ *
68
+ * The returned object conforms to the `InputGuardrail` interface from
69
+ * `@openai/agents`. It scans the input text and triggers if injection
70
+ * is detected.
71
+ */
72
+ export function createBurrowGuardrail(guard, options = {}) {
73
+ const agentName = options.agentName ?? "openai-agents";
74
+ const blockOnWarn = options.blockOnWarn ?? false;
75
+ return {
76
+ name: "Burrow Injection Guard",
77
+ async execute({ input, }) {
78
+ return executeGuardrail(guard, input, "user_prompt", agentName, blockOnWarn);
79
+ },
80
+ };
81
+ }
82
+ /**
83
+ * Create an OpenAI Agents SDK output guardrail powered by Burrow.
84
+ *
85
+ * Scans agent outputs for injection content that may have been
86
+ * triggered by indirect injection in tool results.
87
+ */
88
+ export function createBurrowOutputGuardrail(guard, options = {}) {
89
+ const agentName = options.agentName ?? "openai-agents";
90
+ const blockOnWarn = options.blockOnWarn ?? false;
91
+ return {
92
+ name: "Burrow Output Guard",
93
+ async execute({ agentOutput, }) {
94
+ const text = typeof agentOutput === "object" && agentOutput !== null
95
+ ? JSON.stringify(agentOutput)
96
+ : String(agentOutput ?? "");
97
+ return executeGuardrail(guard, text, "tool_response", agentName, blockOnWarn);
98
+ },
99
+ };
100
+ }
101
+ /**
102
+ * Create an OpenAI Agents SDK input guardrail with per-agent identity.
103
+ *
104
+ * Automatically reads `agent.name` from the guardrail context to produce
105
+ * agent names like `openai-agents:research-agent`.
106
+ */
107
+ export function createBurrowGuardrailV2(guard, options = {}) {
108
+ const blockOnWarn = options.blockOnWarn ?? false;
109
+ return {
110
+ name: "Burrow Injection Guard v2",
111
+ async execute({ input, agent, }) {
112
+ const agentName = agent?.name
113
+ ? `openai-agents:${agent.name}`
114
+ : "openai-agents";
115
+ return executeGuardrail(guard, input, "user_prompt", agentName, blockOnWarn);
116
+ },
117
+ };
118
+ }
119
+ /**
120
+ * Create an OpenAI Agents SDK output guardrail with per-agent identity.
121
+ *
122
+ * Automatically reads `agent.name` from the guardrail context.
123
+ */
124
+ export function createBurrowOutputGuardrailV2(guard, options = {}) {
125
+ const blockOnWarn = options.blockOnWarn ?? false;
126
+ return {
127
+ name: "Burrow Output Guard v2",
128
+ async execute({ agentOutput, agent, }) {
129
+ const agentName = agent?.name
130
+ ? `openai-agents:${agent.name}`
131
+ : "openai-agents";
132
+ const text = typeof agentOutput === "object" && agentOutput !== null
133
+ ? JSON.stringify(agentOutput)
134
+ : String(agentOutput ?? "");
135
+ return executeGuardrail(guard, text, "tool_response", agentName, blockOnWarn);
136
+ },
137
+ };
138
+ }
139
+ //# sourceMappingURL=openai-agents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-agents.js","sourceRoot":"","sources":["../../src/integrations/openai-agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAgBH;;GAEG;AACH,KAAK,UAAU,gBAAgB,CAC7B,KAAkB,EAClB,IAAa,EACb,WAA4C,EAC5C,SAAiB,EACjB,WAAoB;IAEpB,MAAM,IAAI,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAClE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QACjB,OAAO;YACL,UAAU,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;YAChD,iBAAiB,EAAE,KAAK;SACzB,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE;QACpC,WAAW;QACX,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,KAAK,OAAO,IAAI,CAAC,WAAW,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;IAEzF,OAAO;QACL,UAAU,EAAE;YACV,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,UAAU,EAAE,MAAM,CAAC,UAAU;SAC9B;QACD,iBAAiB,EAAE,SAAS;KAC7B,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAkB,EAClB,UAAkC,EAAE;IAEpC,MAAM,SAAS,GAAG,OAAO,CA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