@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.
- package/README.md +298 -0
- package/dist/async-jobs-Dd8Jafv0.d.ts +532 -0
- package/dist/bundle-catalog-3V6EICKE.json +289 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +496 -0
- package/dist/index.js.map +1 -0
- package/dist/langchain/index.d.ts +2 -0
- package/dist/langchain/index.js +1 -0
- package/dist/langchain/index.js.map +1 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/openai/index.d.ts +165 -0
- package/dist/openai/index.js +5257 -0
- package/dist/openai/index.js.map +1 -0
- package/dist/openai-agents/index.d.ts +94 -0
- package/dist/openai-agents/index.js +5203 -0
- package/dist/openai-agents/index.js.map +1 -0
- package/dist/shared/resources/bundle-catalog.json +289 -0
- package/dist/shared/toolkit-core.d.ts +73 -0
- package/dist/shared/toolkit-core.js +4686 -0
- package/dist/shared/toolkit-core.js.map +1 -0
- package/dist/toolkit-CafRZuAV.d.ts +31 -0
- package/dist/vercel-ai/index.d.ts +2 -0
- package/dist/vercel-ai/index.js +1 -0
- package/dist/vercel-ai/index.js.map +1 -0
- package/package.json +95 -0
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
type McpTool = {
|
|
2
|
+
name: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
inputSchema?: JsonSchema;
|
|
5
|
+
outputSchema?: JsonSchema;
|
|
6
|
+
_meta?: Record<string, unknown>;
|
|
7
|
+
annotations?: {
|
|
8
|
+
readOnlyHint?: boolean;
|
|
9
|
+
destructiveHint?: boolean;
|
|
10
|
+
idempotentHint?: boolean;
|
|
11
|
+
openWorldHint?: boolean;
|
|
12
|
+
title?: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
type McpResourceContent = {
|
|
16
|
+
uri: string;
|
|
17
|
+
mimeType?: string;
|
|
18
|
+
text?: string;
|
|
19
|
+
blob?: string;
|
|
20
|
+
};
|
|
21
|
+
type McpReadResourceResult = {
|
|
22
|
+
contents: McpResourceContent[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type EventSanitizerLimits = {
|
|
26
|
+
maxDepth: number;
|
|
27
|
+
maxArrayLength: number;
|
|
28
|
+
maxObjectKeys: number;
|
|
29
|
+
maxStringLength: number;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type ZuoraEnvironment = "sandbox" | "production";
|
|
33
|
+
type ZuoraSafetyMode = "readOnly" | "writeEnabled";
|
|
34
|
+
type ZuoraToolOperation = "read" | "write";
|
|
35
|
+
type ZuoraRiskLevel = "low" | "medium" | "high";
|
|
36
|
+
/**
|
|
37
|
+
* Well-known Zuora bundle names. Provided for autocompletion in
|
|
38
|
+
* `ToolSelection.bundles` and `ZuoraToolkitConfiguration.bundles`.
|
|
39
|
+
*
|
|
40
|
+
* The `string & {}` tail widens the type to accept any string (so new
|
|
41
|
+
* server-side bundles are never rejected) while preserving IDE autocomplete
|
|
42
|
+
* for the known literal members.
|
|
43
|
+
*
|
|
44
|
+
* `ZuoraToolDefinition.meta.bundle` is plain `string` — the server value
|
|
45
|
+
* is passed through as-is with no normalisation or fallback.
|
|
46
|
+
*/
|
|
47
|
+
type ZuoraBundleName = "accounts" | "catalog" | "subscriptions" | "orders" | "billing" | "payments" | "usage" | "revenue" | "finance" | "workflows" | "query" | "admin" | (string & {});
|
|
48
|
+
type ZuoraAsyncOperationMeta = {
|
|
49
|
+
/** Operation on the polling MCP tool. Omitted when pollingTool is the standalone poll target. */
|
|
50
|
+
pollingOperation?: string;
|
|
51
|
+
/** Source MCP tool for cross-tool polling, or standalone poll tool when pollingOperation is omitted. */
|
|
52
|
+
pollingTool?: string;
|
|
53
|
+
jobIdPath: string;
|
|
54
|
+
statusPath: string;
|
|
55
|
+
pollingArgs?: Record<string, string>;
|
|
56
|
+
terminalStatuses: {
|
|
57
|
+
success: string[];
|
|
58
|
+
failure: string[];
|
|
59
|
+
canceled?: string[];
|
|
60
|
+
};
|
|
61
|
+
recommendedPollIntervalMs?: number;
|
|
62
|
+
defaultTimeoutMs?: number;
|
|
63
|
+
maxPollAttempts?: number;
|
|
64
|
+
};
|
|
65
|
+
type ZuoraServicePermission = {
|
|
66
|
+
scope: string;
|
|
67
|
+
name: string;
|
|
68
|
+
};
|
|
69
|
+
type ZuoraToolDefinition = {
|
|
70
|
+
name: string;
|
|
71
|
+
description: string;
|
|
72
|
+
inputSchema: JsonSchema;
|
|
73
|
+
outputSchema?: JsonSchema;
|
|
74
|
+
meta: {
|
|
75
|
+
bundle: string;
|
|
76
|
+
access: ZuoraToolOperation;
|
|
77
|
+
riskLevel: ZuoraRiskLevel;
|
|
78
|
+
asyncOperation?: ZuoraAsyncOperationMeta;
|
|
79
|
+
/** Present on multi-op merged tools (splitOperations: false). Keyed by operation name. Used at
|
|
80
|
+
* call time to look up the async meta for the operation the LLM actually invoked. */
|
|
81
|
+
asyncOperations?: Record<string, ZuoraAsyncOperationMeta>;
|
|
82
|
+
/** Per-operation access levels for merged tools. Used at call time to enforce the correct access for the invoked operation. */
|
|
83
|
+
operationAccess?: Record<string, ZuoraToolOperation>;
|
|
84
|
+
/** Per-operation risk levels for merged tools. Used at call time to enforce the correct risk for the invoked operation. */
|
|
85
|
+
operationRiskLevel?: Record<string, ZuoraRiskLevel>;
|
|
86
|
+
requiredServicePermissions: ZuoraServicePermission[];
|
|
87
|
+
limitations: string[];
|
|
88
|
+
sourceName: string;
|
|
89
|
+
/** Present on split multi-operation tools — MCP input field auto-injected at call time. */
|
|
90
|
+
operationSelector?: string;
|
|
91
|
+
/** Present on split multi-operation tools — the underlying MCP operation name. */
|
|
92
|
+
operationName?: string;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
type NativeToolMetadataConfig = {
|
|
96
|
+
enabled?: boolean;
|
|
97
|
+
operationAccess?: ZuoraToolOperation;
|
|
98
|
+
riskLevel?: ZuoraRiskLevel;
|
|
99
|
+
description?: string;
|
|
100
|
+
};
|
|
101
|
+
type NativeFileToolsConfig = {
|
|
102
|
+
enabled?: boolean;
|
|
103
|
+
bundleName?: string;
|
|
104
|
+
tools?: {
|
|
105
|
+
downloadFile?: NativeToolMetadataConfig;
|
|
106
|
+
readDownloadedFile?: NativeToolMetadataConfig;
|
|
107
|
+
downloadQueryResult?: NativeToolMetadataConfig;
|
|
108
|
+
downloadZuoraFile?: NativeToolMetadataConfig;
|
|
109
|
+
extractDownloadedArchive?: NativeToolMetadataConfig;
|
|
110
|
+
readResource?: NativeToolMetadataConfig;
|
|
111
|
+
};
|
|
112
|
+
rootDir?: string;
|
|
113
|
+
userHomeDir?: string;
|
|
114
|
+
requireRootUnderUserHome?: boolean;
|
|
115
|
+
allowOverwrite?: boolean;
|
|
116
|
+
maxDownloadBytes?: number;
|
|
117
|
+
maxReadBytes?: number;
|
|
118
|
+
maxReadLines?: number;
|
|
119
|
+
maxExtractedFiles?: number;
|
|
120
|
+
maxExtractedBytes?: number;
|
|
121
|
+
downloadTimeoutMs?: number;
|
|
122
|
+
allowedProtocols?: string[];
|
|
123
|
+
allowedHosts?: string[];
|
|
124
|
+
allowedUrlPrefixes?: string[];
|
|
125
|
+
zuoraDownloadHosts?: string[];
|
|
126
|
+
allowZuoraAuthenticatedDownload?: boolean;
|
|
127
|
+
allowS3PresignedDownload?: boolean;
|
|
128
|
+
allowArchiveExtraction?: boolean;
|
|
129
|
+
};
|
|
130
|
+
type NativeFileApprovalMetadata = {
|
|
131
|
+
source: "native";
|
|
132
|
+
nativeToolType: "fileArtifacts";
|
|
133
|
+
filesystemRoot: string;
|
|
134
|
+
sideEffects: Array<"networkRead" | "localFileWrite" | "localFileRead">;
|
|
135
|
+
urlHost?: string;
|
|
136
|
+
urlProtocol?: string;
|
|
137
|
+
urlPath?: string;
|
|
138
|
+
urlKind?: string;
|
|
139
|
+
outputRelativePath?: string;
|
|
140
|
+
artifactId?: string;
|
|
141
|
+
relativePath?: string;
|
|
142
|
+
};
|
|
143
|
+
type NativeToolApprovalMetadata = NativeFileApprovalMetadata;
|
|
144
|
+
type ToolkitBundleName = string;
|
|
145
|
+
type ZuoraBundleDefinition = {
|
|
146
|
+
name: ToolkitBundleName;
|
|
147
|
+
description: string;
|
|
148
|
+
examples: string[];
|
|
149
|
+
commonObjects: string[];
|
|
150
|
+
keywords: string[];
|
|
151
|
+
toolCount: number;
|
|
152
|
+
readToolCount: number;
|
|
153
|
+
writeToolCount: number;
|
|
154
|
+
tools: ZuoraToolDefinition[];
|
|
155
|
+
};
|
|
156
|
+
type JsonSchema = {
|
|
157
|
+
type?: string;
|
|
158
|
+
properties?: Record<string, JsonSchema>;
|
|
159
|
+
items?: JsonSchema;
|
|
160
|
+
required?: string[];
|
|
161
|
+
enum?: string[];
|
|
162
|
+
description?: string;
|
|
163
|
+
additionalProperties?: boolean | JsonSchema;
|
|
164
|
+
[key: string]: unknown;
|
|
165
|
+
};
|
|
166
|
+
type ZuoraAuthConfig = {
|
|
167
|
+
type: "oauthClientCredentials";
|
|
168
|
+
clientId: string;
|
|
169
|
+
clientSecret: string;
|
|
170
|
+
scope?: string;
|
|
171
|
+
} | {
|
|
172
|
+
type: "accessToken";
|
|
173
|
+
accessToken: string;
|
|
174
|
+
};
|
|
175
|
+
type ZuoraTenantAuthConfig = {
|
|
176
|
+
enabled: true;
|
|
177
|
+
tenantId: string;
|
|
178
|
+
tokenId: string;
|
|
179
|
+
userId: string;
|
|
180
|
+
} | {
|
|
181
|
+
enabled?: false;
|
|
182
|
+
};
|
|
183
|
+
type EnabledZuoraTenantAuthConfig = Extract<ZuoraTenantAuthConfig, {
|
|
184
|
+
enabled: true;
|
|
185
|
+
}>;
|
|
186
|
+
type BundleConfiguration = {
|
|
187
|
+
include?: string[];
|
|
188
|
+
exclude?: string[];
|
|
189
|
+
};
|
|
190
|
+
type ZuoraToolkitConfiguration = {
|
|
191
|
+
mode?: ZuoraSafetyMode;
|
|
192
|
+
bundles?: Partial<Record<ZuoraBundleName, boolean | BundleConfiguration>>;
|
|
193
|
+
tools?: Record<string, boolean>;
|
|
194
|
+
context?: Record<string, string | undefined>;
|
|
195
|
+
splitOperations?: boolean;
|
|
196
|
+
};
|
|
197
|
+
type ToolSelection = {
|
|
198
|
+
bundles?: ZuoraBundleName[];
|
|
199
|
+
include?: string[];
|
|
200
|
+
exclude?: string[];
|
|
201
|
+
mode?: ZuoraSafetyMode;
|
|
202
|
+
};
|
|
203
|
+
type ZuoraExecutionRequestMetadata = {
|
|
204
|
+
requestId?: string;
|
|
205
|
+
zuoraRequestId?: string;
|
|
206
|
+
environment?: ZuoraEnvironment;
|
|
207
|
+
tenantId?: string;
|
|
208
|
+
entityIds?: string[];
|
|
209
|
+
orgIds?: string[];
|
|
210
|
+
};
|
|
211
|
+
type ZuoraToolExecutionResult<TData = unknown> = {
|
|
212
|
+
toolName: string;
|
|
213
|
+
data: TData;
|
|
214
|
+
riskLevel?: ZuoraRiskLevel;
|
|
215
|
+
requestId?: string;
|
|
216
|
+
request?: ZuoraExecutionRequestMetadata;
|
|
217
|
+
warnings?: string[];
|
|
218
|
+
};
|
|
219
|
+
type ZuoraMcpClient = {
|
|
220
|
+
initialize?: () => Promise<void>;
|
|
221
|
+
listTools: () => Promise<McpTool[]>;
|
|
222
|
+
callTool: (name: string, input: Record<string, unknown>) => Promise<ZuoraToolExecutionResult>;
|
|
223
|
+
readResource?: (uri: string) => Promise<McpReadResourceResult>;
|
|
224
|
+
getTenantId?: () => string | undefined;
|
|
225
|
+
getSensitiveValues?: () => readonly string[];
|
|
226
|
+
close?: () => Promise<void>;
|
|
227
|
+
};
|
|
228
|
+
type ZuoraConnectionConfigBase = {
|
|
229
|
+
tokenEndpoint?: string;
|
|
230
|
+
tokenAuthMethod?: "client_secret_post" | "client_secret_basic";
|
|
231
|
+
headers?: Record<string, string | undefined>;
|
|
232
|
+
entityIds?: string | string[];
|
|
233
|
+
orgIds?: string | string[];
|
|
234
|
+
zuoraVersion?: string;
|
|
235
|
+
protocolVersion?: string;
|
|
236
|
+
};
|
|
237
|
+
type ZuoraTenantAuthConnectionConfig = ZuoraConnectionConfigBase & {
|
|
238
|
+
tenantAuth: EnabledZuoraTenantAuthConfig;
|
|
239
|
+
};
|
|
240
|
+
type ZuoraStandardConnectionConfig = ZuoraConnectionConfigBase & {
|
|
241
|
+
tenantAuth?: Exclude<ZuoraTenantAuthConfig, EnabledZuoraTenantAuthConfig>;
|
|
242
|
+
};
|
|
243
|
+
type ZuoraConnectionConfig = ZuoraStandardConnectionConfig | ZuoraTenantAuthConnectionConfig;
|
|
244
|
+
declare const ApprovalPolicyPreset: {
|
|
245
|
+
readonly Off: "off";
|
|
246
|
+
readonly AllWrites: "all_writes";
|
|
247
|
+
readonly HighRisk: "high_risk";
|
|
248
|
+
readonly ProductionWrites: "production_writes";
|
|
249
|
+
readonly ProductionHighRisk: "production_high_risk";
|
|
250
|
+
};
|
|
251
|
+
type ApprovalPolicyPresetValue = (typeof ApprovalPolicyPreset)[keyof typeof ApprovalPolicyPreset];
|
|
252
|
+
type ApprovalPolicyResult = "not_required" | "deny" | {
|
|
253
|
+
decision: "not_required" | "deny";
|
|
254
|
+
reason?: string;
|
|
255
|
+
};
|
|
256
|
+
type ApprovalPolicyHandler = (request: ApprovalRequest) => ApprovalPolicyResult | Promise<ApprovalPolicyResult>;
|
|
257
|
+
type ApprovalPolicy = ApprovalPolicyPresetValue | ApprovalPolicyHandler;
|
|
258
|
+
type ApprovalRequest = {
|
|
259
|
+
tool: ZuoraToolDefinition;
|
|
260
|
+
input: Record<string, unknown>;
|
|
261
|
+
environment: ZuoraEnvironment;
|
|
262
|
+
/** Present only for SDK-native tools (e.g. download_file). Undefined for MCP-sourced tools. */
|
|
263
|
+
native?: NativeToolApprovalMetadata;
|
|
264
|
+
};
|
|
265
|
+
type ZuoraToolkitEventName = "tool.called" | "tool.completed" | "tool.failed" | "approval.requested"
|
|
266
|
+
/**
|
|
267
|
+
* Internal name used when emitting the approval outcome from
|
|
268
|
+
* `enforceApproval()`. It is normalised to the `"approval.decided"` type
|
|
269
|
+
* by `normalizeToolkitEvent()` before being delivered to observers.
|
|
270
|
+
* @see ZuoraToolkitEventType
|
|
271
|
+
*/
|
|
272
|
+
| "approval.resolved" | "approval.decided" | "metadata.loaded" | "async.poll.checked" | "observability.sink_failed"
|
|
273
|
+
/**
|
|
274
|
+
* Emitted by framework adapters (e.g. the Agents SDK adapter) after
|
|
275
|
+
* `execute()` finishes post-processing the raw MCP result. The `metadata`
|
|
276
|
+
* field carries the actual response the LLM receives, which may differ from
|
|
277
|
+
* the raw `callTool` output (e.g. async-job directives, download hints).
|
|
278
|
+
* Consumers can subscribe to this event to audit what the LLM was told.
|
|
279
|
+
*/
|
|
280
|
+
| "agent.tool.response";
|
|
281
|
+
/**
|
|
282
|
+
* The canonical event type delivered to `onEvent` / `emit` sinks.
|
|
283
|
+
*
|
|
284
|
+
* Note the asymmetry with `ZuoraToolkitEventName`: the internal name
|
|
285
|
+
* `"approval.resolved"` is normalised to `"approval.decided"` before
|
|
286
|
+
* delivery. Consumers should match on `type`, not `name`, when they need
|
|
287
|
+
* a stable identifier for approval-outcome events.
|
|
288
|
+
*/
|
|
289
|
+
type ZuoraToolkitEventType = "tool.called" | "tool.completed" | "tool.failed" | "approval.requested" | "approval.decided" | "metadata.loaded" | "async.poll.checked" | "observability.sink_failed" | "agent.tool.response";
|
|
290
|
+
type ZuoraToolkitApprovalDecision = "allow" | "deny";
|
|
291
|
+
type ZuoraToolkitApprovalStatus = "requested" | "rejected" | "not_required";
|
|
292
|
+
type ZuoraToolkitEventError = {
|
|
293
|
+
code: string;
|
|
294
|
+
category: string;
|
|
295
|
+
recoverable: boolean;
|
|
296
|
+
retryable?: boolean;
|
|
297
|
+
requestId?: string;
|
|
298
|
+
message?: string;
|
|
299
|
+
};
|
|
300
|
+
type ZuoraToolExecutionPhase = "primary" | "async_poll";
|
|
301
|
+
type ZuoraToolkitEvent = {
|
|
302
|
+
type: ZuoraToolkitEventType;
|
|
303
|
+
name: ZuoraToolkitEventName;
|
|
304
|
+
timestamp: string;
|
|
305
|
+
toolName?: string;
|
|
306
|
+
access?: ZuoraToolOperation;
|
|
307
|
+
bundle?: string;
|
|
308
|
+
executionPhase?: ZuoraToolExecutionPhase;
|
|
309
|
+
input?: Record<string, unknown>;
|
|
310
|
+
output?: Record<string, unknown>;
|
|
311
|
+
requestId?: string;
|
|
312
|
+
zuoraRequestId?: string;
|
|
313
|
+
riskLevel?: ZuoraRiskLevel;
|
|
314
|
+
latencyMs?: number;
|
|
315
|
+
environment?: ZuoraEnvironment;
|
|
316
|
+
tenantId?: string;
|
|
317
|
+
entityIds?: string[];
|
|
318
|
+
orgIds?: string[];
|
|
319
|
+
approvalDecision?: ZuoraToolkitApprovalDecision;
|
|
320
|
+
approvalStatus?: ZuoraToolkitApprovalStatus;
|
|
321
|
+
error?: ZuoraToolkitEventError;
|
|
322
|
+
metadata?: Record<string, unknown>;
|
|
323
|
+
};
|
|
324
|
+
type ZuoraToolkitLogger = {
|
|
325
|
+
debug?: (message: string, event?: ZuoraToolkitEvent) => void;
|
|
326
|
+
info?: (message: string, event?: ZuoraToolkitEvent) => void;
|
|
327
|
+
warn?: (message: string, event?: ZuoraToolkitEvent) => void;
|
|
328
|
+
error?: (message: string, event?: ZuoraToolkitEvent) => void;
|
|
329
|
+
};
|
|
330
|
+
type ZuoraAgentToolkitConfigBase = {
|
|
331
|
+
baseUrl: string;
|
|
332
|
+
configuration?: ZuoraToolkitConfiguration;
|
|
333
|
+
approvalPolicy?: ApprovalPolicy;
|
|
334
|
+
/**
|
|
335
|
+
* SDK-internal overrides for native file download/read infrastructure.
|
|
336
|
+
* Auto-enabled when the query bundle is configured — agents never set this.
|
|
337
|
+
*/
|
|
338
|
+
nativeFileTools?: NativeFileToolsConfig;
|
|
339
|
+
observability?: {
|
|
340
|
+
logger?: ZuoraToolkitLogger;
|
|
341
|
+
emit?: (event: ZuoraToolkitEvent) => void | Promise<void>;
|
|
342
|
+
onEvent?: (event: ZuoraToolkitEvent) => void;
|
|
343
|
+
/**
|
|
344
|
+
* When true, tool.called/tool.completed/tool.failed events include
|
|
345
|
+
* sanitized input and output payloads. Defaults to false.
|
|
346
|
+
*/
|
|
347
|
+
includePayloads?: boolean;
|
|
348
|
+
/**
|
|
349
|
+
* Limits applied when sanitizing event metadata fields.
|
|
350
|
+
* Use `resolveEventSanitizerLimits(process.env)` to populate from
|
|
351
|
+
* environment variables, or supply explicit values.
|
|
352
|
+
* Defaults to built-in conservative limits when omitted.
|
|
353
|
+
*/
|
|
354
|
+
sanitizerLimits?: EventSanitizerLimits;
|
|
355
|
+
};
|
|
356
|
+
};
|
|
357
|
+
type ZuoraAgentToolkitEnvSource = true | {
|
|
358
|
+
env?: Record<string, string | undefined>;
|
|
359
|
+
};
|
|
360
|
+
type ZuoraAgentToolkitEnvConfig = Omit<ZuoraAgentToolkitConfigBase, "baseUrl"> & {
|
|
361
|
+
env: ZuoraAgentToolkitEnvSource;
|
|
362
|
+
};
|
|
363
|
+
type ZuoraAgentToolkitConfig = (ZuoraAgentToolkitConfigBase & {
|
|
364
|
+
auth: ZuoraAuthConfig;
|
|
365
|
+
connection?: ZuoraConnectionConfig;
|
|
366
|
+
}) | (ZuoraAgentToolkitConfigBase & {
|
|
367
|
+
auth?: ZuoraAuthConfig;
|
|
368
|
+
connection: ZuoraTenantAuthConnectionConfig;
|
|
369
|
+
});
|
|
370
|
+
type ZuoraAgentToolkitConfigInput = ZuoraAgentToolkitConfig | ZuoraAgentToolkitEnvConfig;
|
|
371
|
+
/**
|
|
372
|
+
* Terminal state of a completed async job.
|
|
373
|
+
*/
|
|
374
|
+
type ZuoraAsyncJobTerminalState = "success" | "failure" | "canceled";
|
|
375
|
+
/**
|
|
376
|
+
* Configuration for which status strings are considered terminal for each outcome.
|
|
377
|
+
*/
|
|
378
|
+
type ZuoraAsyncJobTerminalStatuses = {
|
|
379
|
+
success: string[];
|
|
380
|
+
failure: string[];
|
|
381
|
+
canceled?: string[];
|
|
382
|
+
};
|
|
383
|
+
/**
|
|
384
|
+
* Rich resolution of the current async job status returned by resolveAsyncJobStatusDetails.
|
|
385
|
+
*/
|
|
386
|
+
type ZuoraAsyncJobStatusResolution = {
|
|
387
|
+
/** Raw status string extracted from the tool result, if any. */
|
|
388
|
+
status: string | undefined;
|
|
389
|
+
/** True if the job has reached a terminal state. */
|
|
390
|
+
isTerminal: boolean;
|
|
391
|
+
/** The resolved terminal state, or undefined if not yet terminal. */
|
|
392
|
+
terminalState: ZuoraAsyncJobTerminalState | undefined;
|
|
393
|
+
};
|
|
394
|
+
/**
|
|
395
|
+
* Options for waitForJob() — all fields override the async meta defaults.
|
|
396
|
+
*/
|
|
397
|
+
type ZuoraWaitForJobOptions = {
|
|
398
|
+
/**
|
|
399
|
+
* Maximum number of polling attempts before giving up.
|
|
400
|
+
* Overrides asyncMeta.maxPollAttempts.
|
|
401
|
+
*/
|
|
402
|
+
maxPollAttempts?: number;
|
|
403
|
+
/**
|
|
404
|
+
* Interval in milliseconds between polling attempts.
|
|
405
|
+
* Overrides asyncMeta.recommendedPollIntervalMs.
|
|
406
|
+
*/
|
|
407
|
+
pollIntervalMs?: number;
|
|
408
|
+
/**
|
|
409
|
+
* Absolute timeout in milliseconds from when waitForJob() was called.
|
|
410
|
+
* Overrides asyncMeta.defaultTimeoutMs.
|
|
411
|
+
*
|
|
412
|
+
* **Note:** the timeout is checked at the start of each loop iteration,
|
|
413
|
+
* before the poll is issued. A value of `0` will therefore cause
|
|
414
|
+
* `waitForJob` to throw `ASYNC_JOB_TIMEOUT` immediately without ever
|
|
415
|
+
* making a poll attempt.
|
|
416
|
+
*/
|
|
417
|
+
timeoutMs?: number;
|
|
418
|
+
/**
|
|
419
|
+
* Custom terminal status sets. When provided, overrides the terminal statuses
|
|
420
|
+
* defined in the async operation meta.
|
|
421
|
+
*/
|
|
422
|
+
terminalStatuses?: ZuoraAsyncJobTerminalStatuses;
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
type BuildAsyncJobResultContext = {
|
|
426
|
+
sourceToolName: string;
|
|
427
|
+
operationSelector?: string;
|
|
428
|
+
/** Split operation names registered for sourceToolName. */
|
|
429
|
+
sourceOperationNames?: string[];
|
|
430
|
+
};
|
|
431
|
+
type ZuoraAsyncJobResult = {
|
|
432
|
+
toolName: string;
|
|
433
|
+
status: "pending";
|
|
434
|
+
jobId: string;
|
|
435
|
+
/** Resolved toolkit tool name to call when polling or auto-waiting. */
|
|
436
|
+
pollingToolName: string;
|
|
437
|
+
/** Original MCP pollingOperation metadata, when present. */
|
|
438
|
+
pollingOperation?: string;
|
|
439
|
+
pollingArgs?: Record<string, string>;
|
|
440
|
+
/** Dot-path to the status field in the poll result (e.g. "data.status"). Populated from asyncMeta.statusPath at job-start time. */
|
|
441
|
+
statusPath?: string;
|
|
442
|
+
/** Terminal status sets for this job. Populated from asyncMeta.terminalStatuses at job-start time. */
|
|
443
|
+
terminalStatuses?: ZuoraAsyncJobTerminalStatuses;
|
|
444
|
+
recommendedPollIntervalMs?: number;
|
|
445
|
+
maxPollAttempts?: number;
|
|
446
|
+
defaultTimeoutMs?: number;
|
|
447
|
+
};
|
|
448
|
+
/**
|
|
449
|
+
* Default terminal statuses applied when the async operation meta does not
|
|
450
|
+
* specify its own terminal status sets and no override is provided to waitForJob.
|
|
451
|
+
*/
|
|
452
|
+
declare const DEFAULT_ASYNC_JOB_TERMINAL_STATUSES: ZuoraAsyncJobTerminalStatuses;
|
|
453
|
+
/**
|
|
454
|
+
* Returns `true` when `data` is a `ZuoraAsyncJobResult` — a pending async job
|
|
455
|
+
* result produced by `ToolkitCore.callTool()` via `buildAsyncJobResult()`.
|
|
456
|
+
*
|
|
457
|
+
* The check requires `status === "pending"`, a non-empty `jobId` string, and
|
|
458
|
+
* at least one of `pollingToolName` or `pollingOperation`. Those routing fields
|
|
459
|
+
* are only present on data shaped by `buildAsyncJobResult` — plain API responses
|
|
460
|
+
* that happen to contain a job-ID-like field will not pass this guard.
|
|
461
|
+
*/
|
|
462
|
+
declare const isAsyncJobResult: (data: unknown) => data is ZuoraAsyncJobResult;
|
|
463
|
+
/**
|
|
464
|
+
* Builds a structured async-pending result to return to the agent when a tool
|
|
465
|
+
* call produces a job that requires polling.
|
|
466
|
+
*
|
|
467
|
+
* @throws ZuoraAgentToolkitError with TOOL_EXECUTION_ERROR if jobIdPath
|
|
468
|
+
* resolves to undefined or null on the raw result.
|
|
469
|
+
*/
|
|
470
|
+
declare function buildAsyncJobResult(result: ZuoraToolExecutionResult, asyncMeta: ZuoraAsyncOperationMeta, context: BuildAsyncJobResultContext): ZuoraAsyncJobResult;
|
|
471
|
+
/**
|
|
472
|
+
* Returns true when the given status string matches any status in the success,
|
|
473
|
+
* failure, or canceled sets of the provided terminal statuses config.
|
|
474
|
+
*
|
|
475
|
+
* The comparison is case-insensitive.
|
|
476
|
+
*/
|
|
477
|
+
declare function matchesAsyncJobTerminalStatus(status: string, statuses: ZuoraAsyncJobTerminalStatuses): boolean;
|
|
478
|
+
/**
|
|
479
|
+
* Resolves the terminal state ("success" | "failure" | "canceled") for the
|
|
480
|
+
* given status string against the provided terminal statuses config.
|
|
481
|
+
*
|
|
482
|
+
* Returns undefined when the status has not yet reached a terminal state.
|
|
483
|
+
*/
|
|
484
|
+
declare function resolveAsyncJobTerminalState(status: string, statuses: ZuoraAsyncJobTerminalStatuses): ZuoraAsyncJobTerminalState | undefined;
|
|
485
|
+
/**
|
|
486
|
+
* Returns true when the given async job result has reached a terminal state
|
|
487
|
+
* according to the provided terminal statuses config.
|
|
488
|
+
*
|
|
489
|
+
* The job is considered terminal only when a non-null, non-empty status string
|
|
490
|
+
* is present in the result data and that status matches one of the terminal sets.
|
|
491
|
+
*/
|
|
492
|
+
declare function isAsyncJobTerminal(result: ZuoraToolExecutionResult, statusPath: string, statuses: ZuoraAsyncJobTerminalStatuses): boolean;
|
|
493
|
+
/**
|
|
494
|
+
* Extracts the current job status string from a polling tool result.
|
|
495
|
+
*
|
|
496
|
+
* @param result - The result returned by the polling tool.
|
|
497
|
+
* @param statusPath - Dot-path to the status field within result.data,
|
|
498
|
+
* e.g. "status" or "job.state". Paths are normalized at parse time by
|
|
499
|
+
* parseAsyncOperationMeta, so callers within the SDK should always pass
|
|
500
|
+
* already-normalized paths here.
|
|
501
|
+
* @returns The extracted status string, or undefined if not present.
|
|
502
|
+
*/
|
|
503
|
+
declare function resolveAsyncJobStatus(result: ZuoraToolExecutionResult, statusPath: string): string | undefined;
|
|
504
|
+
/**
|
|
505
|
+
* Extracts the job ID from a ZuoraAsyncJobResult embedded inside a tool
|
|
506
|
+
* execution result, or returns the jobId directly from a ZuoraAsyncJobResult.
|
|
507
|
+
*
|
|
508
|
+
* Supports two calling patterns:
|
|
509
|
+
* - resolveAsyncJobId(asyncJobResult)
|
|
510
|
+
* - resolveAsyncJobId(toolResult, jobIdPath)
|
|
511
|
+
*/
|
|
512
|
+
declare function resolveAsyncJobId(result: ZuoraAsyncJobResult | ZuoraToolExecutionResult, jobIdPath?: string): string | undefined;
|
|
513
|
+
/**
|
|
514
|
+
* Extracts the name of the next polling tool from a ZuoraAsyncJobResult.
|
|
515
|
+
* Returns undefined if result is not a ZuoraAsyncJobResult.
|
|
516
|
+
*
|
|
517
|
+
* pollingToolName is always set on ZuoraAsyncJobResult (resolved at job-start
|
|
518
|
+
* time by resolveAsyncJobPollingToolNameFromMeta), so it is returned directly.
|
|
519
|
+
*/
|
|
520
|
+
declare function resolveAsyncJobPollingToolName(result: ZuoraAsyncJobResult | ZuoraToolExecutionResult): string | undefined;
|
|
521
|
+
/**
|
|
522
|
+
* Returns a rich ZuoraAsyncJobStatusResolution describing the current status
|
|
523
|
+
* of an async job, including whether it has reached a terminal state and what
|
|
524
|
+
* the terminal state is.
|
|
525
|
+
*
|
|
526
|
+
* @param result - The result returned by the polling tool.
|
|
527
|
+
* @param statusPath - Dot-path to the status field (e.g. "data.status").
|
|
528
|
+
* @param terminalStatuses - Terminal status configuration to match against.
|
|
529
|
+
*/
|
|
530
|
+
declare function resolveAsyncJobStatusDetails(result: ZuoraToolExecutionResult, statusPath: string, terminalStatuses: ZuoraAsyncJobTerminalStatuses): ZuoraAsyncJobStatusResolution;
|
|
531
|
+
|
|
532
|
+
export { type ApprovalPolicy as A, resolveAsyncJobId as B, resolveAsyncJobPollingToolName as C, DEFAULT_ASYNC_JOB_TERMINAL_STATUSES as D, resolveAsyncJobStatus as E, resolveAsyncJobStatusDetails as F, resolveAsyncJobTerminalState as G, type NativeFileApprovalMetadata as N, type ToolSelection as T, type ZuoraToolDefinition as Z, type ZuoraAgentToolkitConfigInput as a, type ZuoraToolExecutionResult as b, type ZuoraAsyncJobResult as c, type ZuoraToolkitEvent as d, type ZuoraAgentToolkitConfig as e, type ZuoraMcpClient as f, type ZuoraBundleDefinition as g, type ZuoraBundleName as h, type ZuoraWaitForJobOptions as i, ApprovalPolicyPreset as j, type ApprovalPolicyPresetValue as k, type ApprovalRequest as l, type NativeFileToolsConfig as m, type NativeToolApprovalMetadata as n, type NativeToolMetadataConfig as o, type ToolkitBundleName as p, type ZuoraAsyncJobStatusResolution as q, type ZuoraAsyncJobTerminalState as r, type ZuoraAsyncJobTerminalStatuses as s, type ZuoraSafetyMode as t, type ZuoraToolkitConfiguration as u, type ZuoraToolkitLogger as v, buildAsyncJobResult as w, isAsyncJobResult as x, isAsyncJobTerminal as y, matchesAsyncJobTerminalStatus as z };
|