@zuora/agent-toolkit 0.0.1-alpha.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.
@@ -0,0 +1,94 @@
1
+ import { tool } from '@openai/agents';
2
+ import { ToolkitCore } from '../shared/toolkit-core.js';
3
+ import { Z as ZuoraToolDefinition, a as ZuoraAgentToolkitConfigInput, T as ToolSelection } from '../async-jobs-Dd8Jafv0.js';
4
+ import { Z as ZuoraOpenAIAgentToolkit } from '../toolkit-CafRZuAV.js';
5
+ import 'openai/resources/chat/completions';
6
+
7
+ /** Native tool type returned by `tool()` from `@openai/agents`. */
8
+ type AgentsFunctionTool = ReturnType<typeof tool>;
9
+ /**
10
+ * OpenAI Agents SDK adapter for the Zuora Agent Kit.
11
+ *
12
+ * Extends `ToolkitCore` so all shared capabilities (auth, approval policy,
13
+ * observability, async job handling, native file tools) are inherited.
14
+ * `convertTools()` is the only override — it wraps each `ZuoraToolDefinition`
15
+ * in an `@openai/agents` `tool()` object whose `execute()` function:
16
+ *
17
+ * 1. Calls `this.callTool()` (MCP execution + approval policy enforcement)
18
+ * 2. Blocks on `this.waitForJob()` if the tool started an async job
19
+ * 3. Embeds `recommendedNextTool` hints for the download chain
20
+ *
21
+ * Schema strictification for the OpenAI Responses API is applied
22
+ * automatically inside `convertTools()` — callers do not need to know about it.
23
+ */
24
+ declare class ZuoraOpenAIAgentsToolkit extends ToolkitCore<AgentsFunctionTool> {
25
+ /**
26
+ * Serialises the agent tool response, emits an `agent.tool.response`
27
+ * observability event (with the response in `metadata` when
28
+ * `includePayloads` is enabled), and returns the JSON string to execute().
29
+ *
30
+ * This surfaces what the LLM actually receives — which may differ from the
31
+ * raw `callTool` output when execute() adds directives or download hints.
32
+ */
33
+ private emitAgentToolResponse;
34
+ protected convertTools(tools: ZuoraToolDefinition[]): AgentsFunctionTool[];
35
+ }
36
+ /**
37
+ * Creates and initialises a `ZuoraOpenAIAgentsToolkit`.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * import { Agent, run } from "@openai/agents";
42
+ * import { createZuoraOpenAIAgentsToolkit } from "@zuora/agent-toolkit/openai-agents";
43
+ *
44
+ * const toolkit = await createZuoraOpenAIAgentsToolkit({ env: true });
45
+ * const tools = await toolkit.getTools({ bundles: ["query"], mode: "readOnly" });
46
+ * const agent = new Agent({ name: "Cli Agent", tools });
47
+ * const result = await run(agent, "How many active accounts?");
48
+ * ```
49
+ */
50
+ declare const createZuoraOpenAIAgentsToolkit: (config: ZuoraAgentToolkitConfigInput) => Promise<ZuoraOpenAIAgentsToolkit>;
51
+
52
+ /**
53
+ * Bridge: Zuora toolkit → OpenAI Agents SDK tool() objects.
54
+ *
55
+ * Each Zuora tool becomes a native `tool()` with:
56
+ * - Its full `inputSchema` strictified for the Responses API (invisible to callers)
57
+ * - `strict: false` as an API-level safeguard against residual schema 400 errors
58
+ * - `needsApproval: true` for write tools (SDK-native HITL)
59
+ * - An `execute()` that calls `toolkit.callTool()`, inline `waitForJob()` for
60
+ * async results, and embeds `recommendedNextTool` hints for the download chain
61
+ *
62
+ * @module openai-agents
63
+ */
64
+
65
+ type AgentsTool = any;
66
+ /**
67
+ * The minimal interface of `tool()` from `@openai/agents` that we need.
68
+ * Typed as `unknown` so this module compiles without `@openai/agents` installed.
69
+ */
70
+ type AgentsToolFactory = (options: any) => AgentsTool;
71
+ /**
72
+ * Converts a single `ZuoraToolDefinition` into an `@openai/agents` `tool()`
73
+ * object with the `execute()` function fully wired to the Zuora toolkit.
74
+ *
75
+ * Schema strictification and async-job handling are applied internally —
76
+ * callers receive a ready-to-use tool without needing to know about them.
77
+ *
78
+ * @param toolFactory - The `tool` function imported from `@openai/agents`
79
+ * @param def - The Zuora tool definition
80
+ * @param toolkit - The Zuora toolkit instance (provides callTool / waitForJob)
81
+ */
82
+ declare const buildAgentsTool: (toolFactory: AgentsToolFactory, sanitizedName: string, def: ZuoraToolDefinition, toolkit: ZuoraOpenAIAgentToolkit) => AgentsTool;
83
+ /**
84
+ * Converts the Zuora toolkit's tool catalog into `@openai/agents` `tool()`
85
+ * objects ready to pass to `new Agent({ tools })`.
86
+ *
87
+ * @param toolFactory - The `tool` function imported from `@openai/agents`
88
+ * @param toolkit - An initialised `ZuoraOpenAIAgentToolkit` instance
89
+ * @param selection - Bundle and mode filter (same as `toolkit.getTools()`)
90
+ * @param maxTools - Optional cap on returned tool count
91
+ */
92
+ declare const buildAgentsTools: (toolFactory: AgentsToolFactory, toolkit: ZuoraOpenAIAgentToolkit, selection?: ToolSelection, maxTools?: number) => Promise<AgentsTool[]>;
93
+
94
+ export { ZuoraOpenAIAgentsToolkit, buildAgentsTool, buildAgentsTools, createZuoraOpenAIAgentsToolkit };