@paybond/kit 0.11.1 → 0.11.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/README.md +1 -1
- package/dist/agent/facade.d.ts +1 -1
- package/dist/agent/facade.js +1 -1
- package/dist/agent/guarded-agent.d.ts +1 -1
- package/dist/agent/guarded-agent.js +1 -1
- package/dist/claude-agents/config.d.ts +2 -2
- package/dist/claude-agents/config.js +22 -1
- package/dist/cli/commands/agent.js +2 -1
- package/dist/langgraph/awrap-tool-call.d.ts +2 -2
- package/dist/langgraph/awrap-tool-call.js +40 -3
- package/dist/langgraph/tool-node.d.ts +4 -1
- package/dist/langgraph/tool-node.js +44 -26
- package/dist/mcp-server.js +1 -1
- package/dist/openai-agents/index.d.ts +2 -2
- package/dist/openai-agents/index.js +23 -1
- package/package.json +4 -3
- package/policy/presets/aws.yaml +19 -0
- package/policy/presets/domain/aws.yaml +15 -0
- package/policy/presets/domain/saas.yaml +15 -0
- package/policy/presets/domain/shopping.yaml +15 -0
- package/policy/presets/domain/travel.yaml +15 -0
- package/policy/presets/guardrails/default-aws.yaml +8 -0
- package/policy/presets/guardrails/default-saas.yaml +8 -0
- package/policy/presets/guardrails/default-shopping.yaml +8 -0
- package/policy/presets/guardrails/default-travel.yaml +8 -0
- package/policy/presets/read-only.yaml +23 -0
- package/policy/presets/saas.yaml +19 -0
- package/policy/presets/shopping.yaml +19 -0
- package/policy/presets/strict.yaml +16 -0
- package/policy/presets/travel.yaml +19 -0
- package/templates/manifest.json +9 -9
- package/templates/openai-shopping-agent/package-lock.json +8 -12
- package/templates/openai-shopping-agent/package.json +1 -1
- package/templates/paybond-aws-operator/package-lock.json +58 -4
- package/templates/paybond-aws-operator/package.json +1 -1
- package/templates/paybond-claude-agents-demo/package-lock.json +5 -4
- package/templates/paybond-claude-agents-demo/package.json +1 -1
- package/templates/paybond-invoice-agent/requirements.txt +1 -1
- package/templates/paybond-mcp-coding-agent/package-lock.json +58 -4
- package/templates/paybond-mcp-coding-agent/package.json +1 -1
- package/templates/paybond-openai-agents-demo/package-lock.json +8 -12
- package/templates/paybond-openai-agents-demo/package.json +1 -1
- package/templates/paybond-procurement-agent/package-lock.json +58 -4
- package/templates/paybond-procurement-agent/package.json +1 -1
- package/templates/paybond-travel-agent/package-lock.json +58 -4
- package/templates/paybond-travel-agent/package.json +1 -1
- package/templates/paybond-vercel-shopping-agent/package-lock.json +58 -4
- package/templates/paybond-vercel-shopping-agent/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Paybond is the SDK to use when you do not want to build your own delegated agent
|
|
|
12
12
|
npm install @paybond/kit
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
`@paybond/kit` is an ESM-only package for
|
|
15
|
+
`@paybond/kit` is an ESM-only package for Node.js runtimes. Use `import` from a Node ESM / `NodeNext` project or a compatible bundler.
|
|
16
16
|
|
|
17
17
|
### Optional framework integrations
|
|
18
18
|
|
package/dist/agent/facade.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClaudeAgentsConfig } from "../claude-agents/
|
|
1
|
+
import type { ClaudeAgentsConfig } from "../claude-agents/config.js";
|
|
2
2
|
import type { PaybondLangGraphHooks } from "../langgraph/config.js";
|
|
3
3
|
import { createOpenAIAgentsAdapter } from "../openai-agents/index.js";
|
|
4
4
|
import type { PaybondPolicy } from "../policy/load.js";
|
package/dist/agent/facade.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createPaybondClaudeAgentsConfig } from "../claude-agents/
|
|
1
|
+
import { createPaybondClaudeAgentsConfig } from "../claude-agents/config.js";
|
|
2
2
|
import { createPaybondOpenAIAgentsConfig } from "../openai-agents/index.js";
|
|
3
3
|
import { isKnownPolicyPresetId, resolvePolicyPresetPath } from "../policy/presets.js";
|
|
4
4
|
import { createPaybondVercelAgentConfig } from "../vercel-ai/config.js";
|
|
@@ -6,7 +6,7 @@ import type { PolicyValidatorOptions } from "../policy/validate.js";
|
|
|
6
6
|
import { paybondVercelToolApproval } from "../vercel-ai/tool-approval.js";
|
|
7
7
|
import { type PaybondLangGraphAwrapToolCall } from "../langgraph/awrap-tool-call.js";
|
|
8
8
|
import { paybondToolNode } from "../langgraph/tool-node.js";
|
|
9
|
-
import { type ClaudeAgentsConfig } from "../claude-agents/
|
|
9
|
+
import { type ClaudeAgentsConfig } from "../claude-agents/config.js";
|
|
10
10
|
import type { PaybondToolRegistry } from "./registry.js";
|
|
11
11
|
import type { PaybondAgentRunHost } from "./run.js";
|
|
12
12
|
import { PaybondAgentRun } from "./run.js";
|
|
@@ -2,7 +2,7 @@ import { createOpenAIAgentsAdapter, createPaybondOpenAIAgentsConfig, } from "../
|
|
|
2
2
|
import { PaybondPolicy } from "../policy/load.js";
|
|
3
3
|
import { createPaybondVercelAgentConfig } from "../vercel-ai/config.js";
|
|
4
4
|
import { createPaybondLangGraphHooks } from "../langgraph/config.js";
|
|
5
|
-
import { createPaybondClaudeAgentsConfig, } from "../claude-agents/
|
|
5
|
+
import { createPaybondClaudeAgentsConfig, } from "../claude-agents/config.js";
|
|
6
6
|
import { createPaybondGenericAgentConfig, } from "./generic-runner.js";
|
|
7
7
|
import { PaybondAgentRun } from "./run.js";
|
|
8
8
|
async function resolvePolicy(source) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SdkMcpToolDefinition } from "@anthropic-ai/claude-agent-sdk";
|
|
2
2
|
import type { PaybondAgentRun } from "../agent/run.js";
|
|
3
3
|
/** Pre-built SDK tool from `tool()` in `@anthropic-ai/claude-agent-sdk`. */
|
|
4
4
|
export type ClaudeAgentSdkTool = SdkMcpToolDefinition;
|
|
@@ -9,7 +9,7 @@ export type PaybondClaudeAgentsConfigOptions = {
|
|
|
9
9
|
serverVersion?: string;
|
|
10
10
|
};
|
|
11
11
|
export type ClaudeAgentsConfig = {
|
|
12
|
-
mcpServer: ReturnType<typeof createSdkMcpServer>;
|
|
12
|
+
mcpServer: ReturnType<typeof import("@anthropic-ai/claude-agent-sdk").createSdkMcpServer>;
|
|
13
13
|
allowedTools: string[];
|
|
14
14
|
/** Same tool array as input — side-effecting handlers are wrapped in-place. */
|
|
15
15
|
agentTools: ClaudeAgentSdkTool[];
|
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
2
|
import { PaybondAutoEvidenceSubmitError, PaybondUnregisteredSideEffectingToolError, } from "../agent/types.js";
|
|
3
3
|
import { PaybondSpendApprovalRequiredError, PaybondSpendDeniedError, } from "../index.js";
|
|
4
|
+
let cachedClaudeAgentSdk;
|
|
5
|
+
/**
|
|
6
|
+
* Lazily resolve the optional `@anthropic-ai/claude-agent-sdk` peer dependency.
|
|
7
|
+
*
|
|
8
|
+
* Importing this module must not require the peer to be installed, so the Paybond barrel
|
|
9
|
+
* can load for consumers of other frameworks. The peer is only needed when the Claude Agents
|
|
10
|
+
* config is actually built.
|
|
11
|
+
*/
|
|
12
|
+
function loadClaudeAgentSdk() {
|
|
13
|
+
if (cachedClaudeAgentSdk === undefined) {
|
|
14
|
+
try {
|
|
15
|
+
const require = createRequire(import.meta.url);
|
|
16
|
+
cachedClaudeAgentSdk = require("@anthropic-ai/claude-agent-sdk");
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
throw new Error('The Claude Agents integration requires the optional peer dependency "@anthropic-ai/claude-agent-sdk"; install it with: npm install @anthropic-ai/claude-agent-sdk', { cause: err });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return cachedClaudeAgentSdk;
|
|
23
|
+
}
|
|
4
24
|
function claudeMcpAllowedToolName(serverName, toolName) {
|
|
5
25
|
return `mcp__${serverName}__${toolName}`;
|
|
6
26
|
}
|
|
@@ -127,6 +147,7 @@ function wrapClaudeAgentSdkTool(run, sdkTool) {
|
|
|
127
147
|
* into an in-process MCP server for `query({ options: { mcpServers, allowedTools } })`.
|
|
128
148
|
*/
|
|
129
149
|
export function createPaybondClaudeAgentsConfig(run, tools, options) {
|
|
150
|
+
const { createSdkMcpServer } = loadClaudeAgentSdk();
|
|
130
151
|
const sdkTools = assertClaudeAgentSdkTools(tools);
|
|
131
152
|
const serverName = options?.serverName?.trim() || "paybond";
|
|
132
153
|
for (const sdkTool of sdkTools) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
-
import { PaybondAgentRun
|
|
3
|
+
import { PaybondAgentRun } from "../../agent/run.js";
|
|
4
|
+
import { PaybondAutoEvidenceSubmitError, PaybondToolRegistryValidationError, PaybondUnregisteredSideEffectingToolError, } from "../../agent/types.js";
|
|
4
5
|
import { runGenericSandboxDemo } from "../../agent/generic-sandbox-demo.js";
|
|
5
6
|
import { loadRunClaudeAgentsSandboxDemo, loadRunLangGraphSandboxDemo, loadRunOpenAIAgentsSandboxDemo, loadRunVercelAiSandboxDemo, } from "../agent/demo-loaders.js";
|
|
6
7
|
import { buildSmokeRegistry, loadAgentRegistryFile, validateAgentRegistryDocument, } from "../../agent/registry-file.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ToolMessage } from "@langchain/core/messages";
|
|
2
|
-
import {
|
|
1
|
+
import type { ToolMessage } from "@langchain/core/messages";
|
|
2
|
+
import type { Command } from "@langchain/langgraph";
|
|
3
3
|
import type { PaybondAgentRun } from "../agent/run.js";
|
|
4
4
|
/** LangGraph `ToolCallRequest`-compatible shape used by Paybond interceptors. */
|
|
5
5
|
export type PaybondLangGraphToolCallRequest = {
|
|
@@ -1,7 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isCommand } from "@langchain/langgraph";
|
|
1
|
+
import { createRequire } from "node:module";
|
|
3
2
|
import { PaybondAutoEvidenceSubmitError, PaybondUnregisteredSideEffectingToolError, } from "../agent/types.js";
|
|
4
3
|
import { PaybondSpendApprovalRequiredError, PaybondSpendDeniedError, } from "../index.js";
|
|
4
|
+
let cachedCoreMessages;
|
|
5
|
+
let cachedLangGraph;
|
|
6
|
+
function missingLangGraphPeerError(err) {
|
|
7
|
+
return new Error('The LangGraph integration requires the optional peer dependencies "@langchain/core" and "@langchain/langgraph"; install them with: npm install @langchain/core @langchain/langgraph', { cause: err });
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Lazily resolve `@langchain/core/messages`; importing this module must not require the peer.
|
|
11
|
+
*/
|
|
12
|
+
function loadCoreMessages() {
|
|
13
|
+
if (cachedCoreMessages === undefined) {
|
|
14
|
+
try {
|
|
15
|
+
const require = createRequire(import.meta.url);
|
|
16
|
+
cachedCoreMessages = require("@langchain/core/messages");
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
throw missingLangGraphPeerError(err);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return cachedCoreMessages;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Lazily resolve `@langchain/langgraph`; importing this module must not require the peer.
|
|
26
|
+
*/
|
|
27
|
+
function loadLangGraph() {
|
|
28
|
+
if (cachedLangGraph === undefined) {
|
|
29
|
+
try {
|
|
30
|
+
const require = createRequire(import.meta.url);
|
|
31
|
+
cachedLangGraph = require("@langchain/langgraph");
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
throw missingLangGraphPeerError(err);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return cachedLangGraph;
|
|
38
|
+
}
|
|
5
39
|
function toolCallFields(request) {
|
|
6
40
|
const call = request.tool_call;
|
|
7
41
|
return {
|
|
@@ -11,6 +45,7 @@ function toolCallFields(request) {
|
|
|
11
45
|
};
|
|
12
46
|
}
|
|
13
47
|
function denyToolMessage(name, toolCallId, content) {
|
|
48
|
+
const { ToolMessage } = loadCoreMessages();
|
|
14
49
|
return new ToolMessage({
|
|
15
50
|
content,
|
|
16
51
|
name: name || "unknown",
|
|
@@ -19,9 +54,11 @@ function denyToolMessage(name, toolCallId, content) {
|
|
|
19
54
|
});
|
|
20
55
|
}
|
|
21
56
|
function isToolMessage(value) {
|
|
22
|
-
return value instanceof ToolMessage;
|
|
57
|
+
return value instanceof loadCoreMessages().ToolMessage;
|
|
23
58
|
}
|
|
24
59
|
export function normalizeLangGraphHookResult(call, result) {
|
|
60
|
+
const { isCommand } = loadLangGraph();
|
|
61
|
+
const { ToolMessage } = loadCoreMessages();
|
|
25
62
|
if (isToolMessage(result) || isCommand(result)) {
|
|
26
63
|
return result;
|
|
27
64
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { DynamicTool, StructuredToolInterface } from "@langchain/core/tools";
|
|
2
2
|
import type { RunnableToolLike } from "@langchain/core/runnables";
|
|
3
|
-
import { ToolNode,
|
|
3
|
+
import type { ToolNode, ToolNodeOptions } from "@langchain/langgraph/prebuilt";
|
|
4
4
|
import type { PaybondAgentRun } from "../agent/run.js";
|
|
5
5
|
type LangGraphTool = StructuredToolInterface | DynamicTool | RunnableToolLike;
|
|
6
6
|
/**
|
|
7
7
|
* Convenience factory: `ToolNode` with Paybond spend guard + auto-evidence on every tool call.
|
|
8
|
+
*
|
|
9
|
+
* LangGraph JS does not yet expose `awrapToolCall` on `ToolNode`; the returned subclass provides
|
|
10
|
+
* the same interceptor boundary as Python's `ToolNode(..., awrap_tool_call=...)`.
|
|
8
11
|
*/
|
|
9
12
|
export declare function paybondToolNode(tools: LangGraphTool[], run: PaybondAgentRun, options?: ToolNodeOptions): ToolNode;
|
|
10
13
|
export {};
|
|
@@ -1,38 +1,56 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
2
|
import { normalizeLangGraphHookResult, paybondAwrapToolCall, } from "./awrap-tool-call.js";
|
|
3
|
+
let cachedPrebuilt;
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Lazily resolve the optional `@langchain/langgraph` peer dependency.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* Importing this module must not require the peer to be installed, so the Paybond barrel
|
|
8
|
+
* can load for consumers of other frameworks. The peer is only needed when a guarded
|
|
9
|
+
* LangGraph `ToolNode` is actually constructed.
|
|
8
10
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
name: call.name,
|
|
19
|
-
id: call.id,
|
|
20
|
-
args: (call.args ?? {}),
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
const execute = async (req) => super.runTool({
|
|
24
|
-
...call,
|
|
25
|
-
name: req.tool_call.name,
|
|
26
|
-
id: req.tool_call.id ?? call.id,
|
|
27
|
-
args: req.tool_call.args ?? call.args,
|
|
28
|
-
}, config, state);
|
|
29
|
-
const result = await this.awrap(request, execute);
|
|
30
|
-
return normalizeLangGraphHookResult(call, result);
|
|
11
|
+
function loadLangGraphPrebuilt() {
|
|
12
|
+
if (cachedPrebuilt === undefined) {
|
|
13
|
+
try {
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
cachedPrebuilt = require("@langchain/langgraph/prebuilt");
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
throw new Error('The LangGraph integration requires the optional peer dependencies "@langchain/core" and "@langchain/langgraph"; install them with: npm install @langchain/core @langchain/langgraph', { cause: err });
|
|
19
|
+
}
|
|
31
20
|
}
|
|
21
|
+
return cachedPrebuilt;
|
|
32
22
|
}
|
|
33
23
|
/**
|
|
34
24
|
* Convenience factory: `ToolNode` with Paybond spend guard + auto-evidence on every tool call.
|
|
25
|
+
*
|
|
26
|
+
* LangGraph JS does not yet expose `awrapToolCall` on `ToolNode`; the returned subclass provides
|
|
27
|
+
* the same interceptor boundary as Python's `ToolNode(..., awrap_tool_call=...)`.
|
|
35
28
|
*/
|
|
36
29
|
export function paybondToolNode(tools, run, options) {
|
|
30
|
+
const { ToolNode: ToolNodeCtor } = loadLangGraphPrebuilt();
|
|
31
|
+
class PaybondGuardedToolNode extends ToolNodeCtor {
|
|
32
|
+
awrap;
|
|
33
|
+
constructor(guardedTools, guardedRun, guardedOptions) {
|
|
34
|
+
super(guardedTools, guardedOptions);
|
|
35
|
+
this.awrap = paybondAwrapToolCall(guardedRun);
|
|
36
|
+
}
|
|
37
|
+
async runTool(call, config, state) {
|
|
38
|
+
const request = {
|
|
39
|
+
tool_call: {
|
|
40
|
+
name: call.name,
|
|
41
|
+
id: call.id,
|
|
42
|
+
args: (call.args ?? {}),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
const execute = async (req) => super.runTool({
|
|
46
|
+
...call,
|
|
47
|
+
name: req.tool_call.name,
|
|
48
|
+
id: req.tool_call.id ?? call.id,
|
|
49
|
+
args: req.tool_call.args ?? call.args,
|
|
50
|
+
}, config, state);
|
|
51
|
+
const result = await this.awrap(request, execute);
|
|
52
|
+
return normalizeLangGraphHookResult(call, result);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
37
55
|
return new PaybondGuardedToolNode(tools, run, options);
|
|
38
56
|
}
|
package/dist/mcp-server.js
CHANGED
|
@@ -13,7 +13,7 @@ import { McpCapabilityTokenCache, mcpToolStoresCapabilityToken, parseMcpCapabili
|
|
|
13
13
|
import { createMcpPolicyGatewayAdapter, McpPolicyReloadGate, parseMcpPolicyReloadConfig, } from "./mcp-policy-reload.js";
|
|
14
14
|
import { DEFAULT_PAYBOND_GATEWAY_BASE_URL, GatewayFraudClient, GatewaySignalClient, } from "./index.js";
|
|
15
15
|
const SERVER_NAME = "Paybond MCP";
|
|
16
|
-
const SERVER_VERSION = "0.11.
|
|
16
|
+
const SERVER_VERSION = "0.11.3";
|
|
17
17
|
const MCP_PROTOCOL_VERSION = "2025-11-25";
|
|
18
18
|
const DEFAULT_PRINCIPAL_PATH = "/v1/auth/principal";
|
|
19
19
|
const DEFAULT_RECOGNITION_VERIFIER_ID = "paybond-gateway";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FunctionTool, RunConfig, ToolInputGuardrailDefinition } from "@openai/agents";
|
|
2
2
|
import { type PaybondAgentRun, type PaybondToolInputGuardDecision } from "../agent/index.js";
|
|
3
3
|
export type PaybondOpenAIAgentsAdapterOptions = {
|
|
4
4
|
/**
|
|
@@ -11,7 +11,7 @@ declare function isFunctionTool(value: unknown): value is FunctionTool;
|
|
|
11
11
|
/** Detect OpenAI Agents SDK function tools (`type: "function"`). */
|
|
12
12
|
export { isFunctionTool as isOpenAIFunctionTool };
|
|
13
13
|
/** Map a framework-neutral Paybond decision to OpenAI tool guardrail output. */
|
|
14
|
-
export declare function mapPaybondDecisionToOpenAIToolGuardrail(decision: PaybondToolInputGuardDecision): ReturnType<typeof ToolGuardrailFunctionOutputFactory.allow>;
|
|
14
|
+
export declare function mapPaybondDecisionToOpenAIToolGuardrail(decision: PaybondToolInputGuardDecision): ReturnType<typeof import("@openai/agents").ToolGuardrailFunctionOutputFactory.allow>;
|
|
15
15
|
/** RunConfig fragment enabling Paybond verify before OpenAI approval interruptions. */
|
|
16
16
|
export declare const paybondOpenAIAgentsRunConfig: Pick<RunConfig, "toolExecution">;
|
|
17
17
|
/** Translate Paybond middleware into OpenAI Agents SDK tool input guardrails. */
|
|
@@ -1,5 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
2
|
import { createToolInputGuardAdapter, } from "../agent/index.js";
|
|
3
|
+
let cachedOpenAIAgents;
|
|
4
|
+
/**
|
|
5
|
+
* Lazily resolve the optional `@openai/agents` peer dependency.
|
|
6
|
+
*
|
|
7
|
+
* Importing this module must not require the peer to be installed, so consumers of
|
|
8
|
+
* other frameworks (LangGraph, Vercel AI, etc.) can load the Paybond barrel without it.
|
|
9
|
+
* The peer is only needed when the OpenAI Agents adapter functions actually run.
|
|
10
|
+
*/
|
|
11
|
+
function loadOpenAIAgents() {
|
|
12
|
+
if (cachedOpenAIAgents === undefined) {
|
|
13
|
+
try {
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
cachedOpenAIAgents = require("@openai/agents");
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
throw new Error('The OpenAI Agents integration requires the optional peer dependency "@openai/agents"; install it with: npm install @openai/agents', { cause: err });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return cachedOpenAIAgents;
|
|
22
|
+
}
|
|
3
23
|
function parseToolArguments(raw) {
|
|
4
24
|
if (!raw.trim()) {
|
|
5
25
|
return {};
|
|
@@ -17,6 +37,7 @@ function isFunctionTool(value) {
|
|
|
17
37
|
export { isFunctionTool as isOpenAIFunctionTool };
|
|
18
38
|
/** Map a framework-neutral Paybond decision to OpenAI tool guardrail output. */
|
|
19
39
|
export function mapPaybondDecisionToOpenAIToolGuardrail(decision) {
|
|
40
|
+
const { ToolGuardrailFunctionOutputFactory } = loadOpenAIAgents();
|
|
20
41
|
if (decision.kind === "allow") {
|
|
21
42
|
return ToolGuardrailFunctionOutputFactory.allow({
|
|
22
43
|
paybond: {
|
|
@@ -37,6 +58,7 @@ export function mapPaybondDecisionToOpenAIToolGuardrail(decision) {
|
|
|
37
58
|
});
|
|
38
59
|
}
|
|
39
60
|
function buildPaybondInputGuardrail(run, toolName) {
|
|
61
|
+
const { defineToolInputGuardrail } = loadOpenAIAgents();
|
|
40
62
|
const guard = createToolInputGuardAdapter(run);
|
|
41
63
|
return defineToolInputGuardrail({
|
|
42
64
|
name: `paybond_spend_${toolName}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paybond/kit",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"mcpName": "io.github.nonameuserd/paybond",
|
|
5
5
|
"description": "Paybond Kit for TypeScript: agent spend governance for paid tool calls with spend authorization, evidence receipts, refunds, disputes, hosted Gateway sessions, and settlement.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"files": [
|
|
55
55
|
"dist",
|
|
56
|
+
"policy",
|
|
56
57
|
"completion-presets",
|
|
57
58
|
"solutions",
|
|
58
59
|
"templates",
|
|
@@ -109,7 +110,7 @@
|
|
|
109
110
|
},
|
|
110
111
|
"scripts": {
|
|
111
112
|
"clean": "node ./scripts/clean-dist.mjs",
|
|
112
|
-
"build": "npm run clean && tsc -p tsconfig.json && node ../scripts/sync-completion-catalog.mjs && node ../scripts/sync-dev-trace-ui.mjs && node ./scripts/generate-templates.mjs",
|
|
113
|
+
"build": "npm run clean && tsc -p tsconfig.json && node ../scripts/sync-completion-catalog.mjs && node ../scripts/sync-policy-presets.mjs && node ../scripts/sync-dev-trace-ui.mjs && node ./scripts/generate-templates.mjs",
|
|
113
114
|
"cli": "node dist/cli.js",
|
|
114
115
|
"cli:dev": "npm run build --silent && node dist/cli.js",
|
|
115
116
|
"generate:cli-contract": "node ../cli-parity/generate.mjs",
|
|
@@ -150,6 +151,7 @@
|
|
|
150
151
|
"@noble/ed25519": "^2.2.1",
|
|
151
152
|
"@noble/hashes": "^1.7.1",
|
|
152
153
|
"@noble/secp256k1": "^2.2.3",
|
|
154
|
+
"ajv": "^8.17.1",
|
|
153
155
|
"blake3": "^2.1.7",
|
|
154
156
|
"uuid": "^14.0.0"
|
|
155
157
|
},
|
|
@@ -161,7 +163,6 @@
|
|
|
161
163
|
"@openai/agents": "^0.12.0",
|
|
162
164
|
"@types/node": "^22.10.0",
|
|
163
165
|
"ai": "^7.0.4",
|
|
164
|
-
"ajv": "^8.17.1",
|
|
165
166
|
"typescript": "^5.7.2",
|
|
166
167
|
"vitest": "^4.1.8",
|
|
167
168
|
"zod": "^4.4.3"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
name: aws-operator-v1
|
|
3
|
+
default_deny: true
|
|
4
|
+
|
|
5
|
+
tools:
|
|
6
|
+
aws.ec2.start_instance:
|
|
7
|
+
side_effecting: true
|
|
8
|
+
max_spend_cents: 50000
|
|
9
|
+
evidence_preset: cost_and_completion
|
|
10
|
+
|
|
11
|
+
aws.ec2.describe_instances:
|
|
12
|
+
side_effecting: false
|
|
13
|
+
|
|
14
|
+
intent:
|
|
15
|
+
allowed_tools:
|
|
16
|
+
- aws.ec2.start_instance
|
|
17
|
+
budget:
|
|
18
|
+
currency: usd
|
|
19
|
+
max_spend_usd: 500
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
name: aws-operator-v1
|
|
3
|
+
default_deny: true
|
|
4
|
+
|
|
5
|
+
tools:
|
|
6
|
+
aws.ec2.start_instance:
|
|
7
|
+
side_effecting: true
|
|
8
|
+
evidence_preset: cost_and_completion
|
|
9
|
+
|
|
10
|
+
aws.ec2.describe_instances:
|
|
11
|
+
side_effecting: false
|
|
12
|
+
|
|
13
|
+
intent:
|
|
14
|
+
allowed_tools:
|
|
15
|
+
- aws.ec2.start_instance
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
name: saas-agent-v1
|
|
3
|
+
default_deny: true
|
|
4
|
+
|
|
5
|
+
tools:
|
|
6
|
+
saas.provision_seat:
|
|
7
|
+
side_effecting: true
|
|
8
|
+
evidence_preset: cost_and_completion
|
|
9
|
+
|
|
10
|
+
saas.list_plans:
|
|
11
|
+
side_effecting: false
|
|
12
|
+
|
|
13
|
+
intent:
|
|
14
|
+
allowed_tools:
|
|
15
|
+
- saas.provision_seat
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
name: shopping-agent-v1
|
|
3
|
+
default_deny: true
|
|
4
|
+
|
|
5
|
+
tools:
|
|
6
|
+
commerce.checkout:
|
|
7
|
+
side_effecting: true
|
|
8
|
+
evidence_preset: cost_and_completion
|
|
9
|
+
|
|
10
|
+
search.products:
|
|
11
|
+
side_effecting: false
|
|
12
|
+
|
|
13
|
+
intent:
|
|
14
|
+
allowed_tools:
|
|
15
|
+
- commerce.checkout
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
name: read-only-agent-v1
|
|
3
|
+
default_deny: true
|
|
4
|
+
|
|
5
|
+
tools:
|
|
6
|
+
search.web:
|
|
7
|
+
side_effecting: false
|
|
8
|
+
|
|
9
|
+
search.products:
|
|
10
|
+
side_effecting: false
|
|
11
|
+
|
|
12
|
+
saas.list_plans:
|
|
13
|
+
side_effecting: false
|
|
14
|
+
|
|
15
|
+
aws.ec2.describe_instances:
|
|
16
|
+
side_effecting: false
|
|
17
|
+
|
|
18
|
+
intent:
|
|
19
|
+
allowed_tools:
|
|
20
|
+
- search.web
|
|
21
|
+
- search.products
|
|
22
|
+
- saas.list_plans
|
|
23
|
+
- aws.ec2.describe_instances
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
name: saas-agent-v1
|
|
3
|
+
default_deny: true
|
|
4
|
+
|
|
5
|
+
tools:
|
|
6
|
+
saas.provision_seat:
|
|
7
|
+
side_effecting: true
|
|
8
|
+
max_spend_cents: 5000
|
|
9
|
+
evidence_preset: cost_and_completion
|
|
10
|
+
|
|
11
|
+
saas.list_plans:
|
|
12
|
+
side_effecting: false
|
|
13
|
+
|
|
14
|
+
intent:
|
|
15
|
+
allowed_tools:
|
|
16
|
+
- saas.provision_seat
|
|
17
|
+
budget:
|
|
18
|
+
currency: usd
|
|
19
|
+
max_spend_usd: 50
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
name: shopping-agent-v1
|
|
3
|
+
default_deny: true
|
|
4
|
+
|
|
5
|
+
tools:
|
|
6
|
+
commerce.checkout:
|
|
7
|
+
side_effecting: true
|
|
8
|
+
max_spend_cents: 10000
|
|
9
|
+
evidence_preset: cost_and_completion
|
|
10
|
+
|
|
11
|
+
search.products:
|
|
12
|
+
side_effecting: false
|
|
13
|
+
|
|
14
|
+
intent:
|
|
15
|
+
allowed_tools:
|
|
16
|
+
- commerce.checkout
|
|
17
|
+
budget:
|
|
18
|
+
currency: usd
|
|
19
|
+
max_spend_usd: 100
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
name: strict-agent-v1
|
|
3
|
+
default_deny: true
|
|
4
|
+
|
|
5
|
+
tools:
|
|
6
|
+
travel.book_hotel:
|
|
7
|
+
side_effecting: true
|
|
8
|
+
max_spend_cents: 1000
|
|
9
|
+
evidence_preset: cost_and_completion
|
|
10
|
+
|
|
11
|
+
intent:
|
|
12
|
+
allowed_tools:
|
|
13
|
+
- travel.book_hotel
|
|
14
|
+
budget:
|
|
15
|
+
currency: usd
|
|
16
|
+
max_spend_usd: 10
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
name: travel-agent-v1
|
|
3
|
+
default_deny: true
|
|
4
|
+
|
|
5
|
+
tools:
|
|
6
|
+
travel.book_hotel:
|
|
7
|
+
side_effecting: true
|
|
8
|
+
max_spend_cents: 20000
|
|
9
|
+
evidence_preset: cost_and_completion
|
|
10
|
+
|
|
11
|
+
search.web:
|
|
12
|
+
side_effecting: false
|
|
13
|
+
|
|
14
|
+
intent:
|
|
15
|
+
allowed_tools:
|
|
16
|
+
- travel.book_hotel
|
|
17
|
+
budget:
|
|
18
|
+
currency: usd
|
|
19
|
+
max_spend_usd: 200
|