@gpt-platform/client 0.10.4 → 0.11.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/dist/_internal/client/client.gen.d.ts +3 -0
- package/dist/_internal/client/client.gen.d.ts.map +1 -0
- package/dist/_internal/client/index.d.ts +9 -0
- package/dist/_internal/client/index.d.ts.map +1 -0
- package/dist/_internal/client/types.gen.d.ts +118 -0
- package/dist/_internal/client/types.gen.d.ts.map +1 -0
- package/dist/_internal/client/utils.gen.d.ts +34 -0
- package/dist/_internal/client/utils.gen.d.ts.map +1 -0
- package/dist/_internal/client.gen.d.ts +13 -0
- package/dist/_internal/client.gen.d.ts.map +1 -0
- package/dist/_internal/core/auth.gen.d.ts +19 -0
- package/dist/_internal/core/auth.gen.d.ts.map +1 -0
- package/dist/_internal/core/bodySerializer.gen.d.ts +26 -0
- package/dist/_internal/core/bodySerializer.gen.d.ts.map +1 -0
- package/dist/_internal/core/params.gen.d.ts +44 -0
- package/dist/_internal/core/params.gen.d.ts.map +1 -0
- package/dist/_internal/core/pathSerializer.gen.d.ts +34 -0
- package/dist/_internal/core/pathSerializer.gen.d.ts.map +1 -0
- package/dist/_internal/core/queryKeySerializer.gen.d.ts +19 -0
- package/dist/_internal/core/queryKeySerializer.gen.d.ts.map +1 -0
- package/dist/_internal/core/serverSentEvents.gen.d.ts +72 -0
- package/dist/_internal/core/serverSentEvents.gen.d.ts.map +1 -0
- package/dist/_internal/core/types.gen.d.ts +79 -0
- package/dist/_internal/core/types.gen.d.ts.map +1 -0
- package/dist/_internal/core/utils.gen.d.ts +20 -0
- package/dist/_internal/core/utils.gen.d.ts.map +1 -0
- package/dist/_internal/index.d.ts +3 -0
- package/dist/_internal/index.d.ts.map +1 -0
- package/dist/_internal/sdk.gen.d.ts +7053 -0
- package/dist/_internal/sdk.gen.d.ts.map +1 -0
- package/dist/_internal/types.gen.d.ts +146633 -0
- package/dist/_internal/types.gen.d.ts.map +1 -0
- package/dist/base-client.d.ts +199 -0
- package/dist/base-client.d.ts.map +1 -0
- package/dist/errors/index.d.ts +128 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/events.d.ts +69 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/execution-events.d.ts +95 -0
- package/dist/execution-events.d.ts.map +1 -0
- package/dist/gpt-client.d.ts +2175 -0
- package/dist/gpt-client.d.ts.map +1 -0
- package/dist/index.d.ts +51 -30308
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +775 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +775 -14
- package/dist/index.mjs.map +1 -1
- package/dist/json-api.d.ts +26 -0
- package/dist/json-api.d.ts.map +1 -0
- package/dist/logging.d.ts +22 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/namespace-types.d.ts +79 -0
- package/dist/namespace-types.d.ts.map +1 -0
- package/dist/namespaces/access-grants.d.ts +71 -0
- package/dist/namespaces/access-grants.d.ts.map +1 -0
- package/dist/namespaces/agents.d.ts +1406 -0
- package/dist/namespaces/agents.d.ts.map +1 -0
- package/dist/namespaces/ai.d.ts +407 -0
- package/dist/namespaces/ai.d.ts.map +1 -0
- package/dist/namespaces/audit.d.ts +83 -0
- package/dist/namespaces/audit.d.ts.map +1 -0
- package/dist/namespaces/billing.d.ts +854 -0
- package/dist/namespaces/billing.d.ts.map +1 -0
- package/dist/namespaces/campaigns.d.ts +973 -0
- package/dist/namespaces/campaigns.d.ts.map +1 -0
- package/dist/namespaces/catalog.d.ts +964 -0
- package/dist/namespaces/catalog.d.ts.map +1 -0
- package/dist/namespaces/channels.d.ts +162 -0
- package/dist/namespaces/channels.d.ts.map +1 -0
- package/dist/namespaces/clinical.d.ts +2443 -0
- package/dist/namespaces/clinical.d.ts.map +1 -0
- package/dist/namespaces/communication.d.ts +439 -0
- package/dist/namespaces/communication.d.ts.map +1 -0
- package/dist/namespaces/compliance.d.ts +2310 -0
- package/dist/namespaces/compliance.d.ts.map +1 -0
- package/dist/namespaces/connectors.d.ts +1368 -0
- package/dist/namespaces/connectors.d.ts.map +1 -0
- package/dist/namespaces/content.d.ts +188 -0
- package/dist/namespaces/content.d.ts.map +1 -0
- package/dist/namespaces/crawler.d.ts +408 -0
- package/dist/namespaces/crawler.d.ts.map +1 -0
- package/dist/namespaces/crm-clusters.d.ts +31 -0
- package/dist/namespaces/crm-clusters.d.ts.map +1 -0
- package/dist/namespaces/crm.d.ts +1539 -0
- package/dist/namespaces/crm.d.ts.map +1 -0
- package/dist/namespaces/documents.d.ts +136 -0
- package/dist/namespaces/documents.d.ts.map +1 -0
- package/dist/namespaces/email.d.ts +550 -0
- package/dist/namespaces/email.d.ts.map +1 -0
- package/dist/namespaces/extraction.d.ts +1249 -0
- package/dist/namespaces/extraction.d.ts.map +1 -0
- package/dist/namespaces/identity.d.ts +411 -0
- package/dist/namespaces/identity.d.ts.map +1 -0
- package/dist/namespaces/imports.d.ts +177 -0
- package/dist/namespaces/imports.d.ts.map +1 -0
- package/dist/namespaces/index.d.ts +119 -0
- package/dist/namespaces/index.d.ts.map +1 -0
- package/dist/namespaces/memory.d.ts +105 -0
- package/dist/namespaces/memory.d.ts.map +1 -0
- package/dist/namespaces/models.d.ts +75 -0
- package/dist/namespaces/models.d.ts.map +1 -0
- package/dist/namespaces/permissions.d.ts +75 -0
- package/dist/namespaces/permissions.d.ts.map +1 -0
- package/dist/namespaces/pipeline-executions.d.ts +130 -0
- package/dist/namespaces/pipeline-executions.d.ts.map +1 -0
- package/dist/namespaces/pipelines.d.ts +120 -0
- package/dist/namespaces/pipelines.d.ts.map +1 -0
- package/dist/namespaces/platform.d.ts +1430 -0
- package/dist/namespaces/platform.d.ts.map +1 -0
- package/dist/namespaces/portal.d.ts +198 -0
- package/dist/namespaces/portal.d.ts.map +1 -0
- package/dist/namespaces/projects.d.ts +553 -0
- package/dist/namespaces/projects.d.ts.map +1 -0
- package/dist/namespaces/roles.d.ts +65 -0
- package/dist/namespaces/roles.d.ts.map +1 -0
- package/dist/namespaces/scheduling.d.ts +944 -0
- package/dist/namespaces/scheduling.d.ts.map +1 -0
- package/dist/namespaces/search.d.ts +224 -0
- package/dist/namespaces/search.d.ts.map +1 -0
- package/dist/namespaces/session-notes.d.ts +67 -0
- package/dist/namespaces/session-notes.d.ts.map +1 -0
- package/dist/namespaces/social.d.ts +330 -0
- package/dist/namespaces/social.d.ts.map +1 -0
- package/dist/namespaces/storage.d.ts +378 -0
- package/dist/namespaces/storage.d.ts.map +1 -0
- package/dist/namespaces/support.d.ts +427 -0
- package/dist/namespaces/support.d.ts.map +1 -0
- package/dist/namespaces/threads.d.ts +596 -0
- package/dist/namespaces/threads.d.ts.map +1 -0
- package/dist/namespaces/training.d.ts +358 -0
- package/dist/namespaces/training.d.ts.map +1 -0
- package/dist/namespaces/voice.d.ts +752 -0
- package/dist/namespaces/voice.d.ts.map +1 -0
- package/dist/namespaces/watcher.d.ts +425 -0
- package/dist/namespaces/watcher.d.ts.map +1 -0
- package/dist/namespaces/webhooks-ns.d.ts +3 -0
- package/dist/namespaces/webhooks-ns.d.ts.map +1 -0
- package/dist/pagination.d.ts +57 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/request-builder.d.ts +95 -0
- package/dist/request-builder.d.ts.map +1 -0
- package/dist/security.d.ts +32 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/streaming.d.ts +135 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/utils/retry.d.ts +63 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/webhook-signature.d.ts +109 -0
- package/dist/webhook-signature.d.ts.map +1 -0
- package/llms.txt +40 -1
- package/package.json +286 -36
- package/dist/index.d.mts +0 -30308
|
@@ -0,0 +1,1406 @@
|
|
|
1
|
+
import type { Agent, AgentDeployment, AgentStats, AgentTestResult, AgentUsage, AgentVersion, AgentVersionComparison, AgentVersionRevision, FieldTemplate, TrainingExample, TrainingSession, WorkspaceAgentConfig } from "../_internal/types.gen";
|
|
2
|
+
export type { AgentStats, AgentUsage, AgentVersionRevision, AgentVersionComparison, FieldTemplate, };
|
|
3
|
+
/** Agent statistics response — re-exported from generated types. */
|
|
4
|
+
export type AgentStatsResponse = AgentStats;
|
|
5
|
+
/** Agent usage statistics response — re-exported from generated types. */
|
|
6
|
+
export type AgentUsageResponse = AgentUsage;
|
|
7
|
+
/** Agent prediction response. */
|
|
8
|
+
export interface PredictionResponse {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
/** @public Input for the teach (training correction) operation on an agent. */
|
|
12
|
+
export interface TeachParams {
|
|
13
|
+
data: {
|
|
14
|
+
attributes?: {
|
|
15
|
+
/** Field names to mark as confirmed (correct). */
|
|
16
|
+
confirmed_fields?: Array<string>;
|
|
17
|
+
/** Per-field human-readable reasons for corrections. */
|
|
18
|
+
correction_reasons?: Record<string, unknown>;
|
|
19
|
+
/** Map of field names to corrected values. */
|
|
20
|
+
corrections: Record<string, unknown>;
|
|
21
|
+
/** The document ID used as the training source. */
|
|
22
|
+
document_id: string;
|
|
23
|
+
/** Optional free-text note for training context. */
|
|
24
|
+
training_note?: string;
|
|
25
|
+
/** Implicitly verify untouched fields. */
|
|
26
|
+
verify_remaining?: boolean;
|
|
27
|
+
};
|
|
28
|
+
type?: "agent";
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Agent training statistics response. */
|
|
32
|
+
export interface TrainingStatsResponse {
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}
|
|
35
|
+
/** Agent test result response — re-exported from generated types. */
|
|
36
|
+
export type AgentTestResultResponse = AgentTestResult;
|
|
37
|
+
/** Agent version metrics response. */
|
|
38
|
+
export interface VersionMetricsResponse {
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}
|
|
41
|
+
/** Agent version revision record — re-exported from generated types. */
|
|
42
|
+
export type VersionRevision = AgentVersionRevision;
|
|
43
|
+
/** Agent version comparison result — re-exported from generated types. */
|
|
44
|
+
export type VersionComparisonResponse = AgentVersionComparison;
|
|
45
|
+
/** Execution cost estimate response. */
|
|
46
|
+
export interface ExecutionEstimateResponse {
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
}
|
|
49
|
+
/** Execution tree response. */
|
|
50
|
+
export interface ExecutionTreeResponse {
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
/** Bulk delete response. */
|
|
54
|
+
export interface BulkDeleteResponse {
|
|
55
|
+
deleted_count?: number;
|
|
56
|
+
[key: string]: unknown;
|
|
57
|
+
}
|
|
58
|
+
/** Attributes accepted when updating an agent (PATCH semantics). */
|
|
59
|
+
export type UpdateAgentAttributes = {
|
|
60
|
+
name?: string;
|
|
61
|
+
description?: string;
|
|
62
|
+
instructions?: string;
|
|
63
|
+
tags?: string[];
|
|
64
|
+
execution_mode?: string;
|
|
65
|
+
[key: string]: unknown;
|
|
66
|
+
};
|
|
67
|
+
/** Attributes accepted when creating a new agent. */
|
|
68
|
+
export type CreateAgentAttributes = {
|
|
69
|
+
description?: string;
|
|
70
|
+
instructions?: string;
|
|
71
|
+
vertical?: string;
|
|
72
|
+
tags?: string[];
|
|
73
|
+
execution_mode?: string;
|
|
74
|
+
[key: string]: unknown;
|
|
75
|
+
};
|
|
76
|
+
/** Attributes accepted when creating an agent version. */
|
|
77
|
+
export type CreateAgentVersionAttributes = {
|
|
78
|
+
agent_id: string;
|
|
79
|
+
prompt_template?: unknown;
|
|
80
|
+
version_number?: number;
|
|
81
|
+
changes_summary?: string;
|
|
82
|
+
output_schema?: Record<string, unknown>;
|
|
83
|
+
input_schema?: Record<string, unknown>;
|
|
84
|
+
output_strict?: boolean;
|
|
85
|
+
input_strict?: boolean;
|
|
86
|
+
is_draft?: boolean;
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
};
|
|
89
|
+
/** Attributes accepted when updating an agent version (PATCH semantics). */
|
|
90
|
+
export type UpdateAgentVersionAttributes = {
|
|
91
|
+
output_schema?: Record<string, unknown>;
|
|
92
|
+
input_schema?: Record<string, unknown>;
|
|
93
|
+
output_strict?: boolean;
|
|
94
|
+
input_strict?: boolean;
|
|
95
|
+
prompt_template?: unknown;
|
|
96
|
+
changes_summary?: string;
|
|
97
|
+
[key: string]: unknown;
|
|
98
|
+
};
|
|
99
|
+
/** Attributes accepted when creating a test result. */
|
|
100
|
+
export type CreateTestResultAttributes = {
|
|
101
|
+
agent_id: string;
|
|
102
|
+
[key: string]: unknown;
|
|
103
|
+
};
|
|
104
|
+
/** Attributes accepted when creating a training example via agents namespace. */
|
|
105
|
+
export type CreateAgentTrainingExampleAttributes = {
|
|
106
|
+
agent_id?: string;
|
|
107
|
+
input_text: string;
|
|
108
|
+
output_json: Record<string, unknown>;
|
|
109
|
+
field_name?: string;
|
|
110
|
+
original_value?: string;
|
|
111
|
+
corrected_value?: string;
|
|
112
|
+
document_type?: string;
|
|
113
|
+
confidence_score?: number;
|
|
114
|
+
training_note?: string;
|
|
115
|
+
correction_reasons?: Record<string, string>;
|
|
116
|
+
is_confirmed?: boolean;
|
|
117
|
+
[key: string]: unknown;
|
|
118
|
+
};
|
|
119
|
+
/** Attributes accepted when updating a training example via agents namespace. */
|
|
120
|
+
export type UpdateAgentTrainingExampleAttributes = {
|
|
121
|
+
input_text?: string;
|
|
122
|
+
output_json?: Record<string, unknown>;
|
|
123
|
+
field_name?: string;
|
|
124
|
+
original_value?: string;
|
|
125
|
+
corrected_value?: string;
|
|
126
|
+
training_note?: string;
|
|
127
|
+
correction_reasons?: Record<string, string>;
|
|
128
|
+
is_confirmed?: boolean;
|
|
129
|
+
[key: string]: unknown;
|
|
130
|
+
};
|
|
131
|
+
/** Attributes accepted when creating a field template. */
|
|
132
|
+
export type CreateFieldTemplateAttributes = {
|
|
133
|
+
name: string;
|
|
134
|
+
[key: string]: unknown;
|
|
135
|
+
};
|
|
136
|
+
import type { RequestOptions } from "../base-client";
|
|
137
|
+
import { RequestBuilder } from "../request-builder";
|
|
138
|
+
import type { StreamOptions } from "../streaming";
|
|
139
|
+
import type { ExecutionEvent } from "../execution-events";
|
|
140
|
+
/**
|
|
141
|
+
* Execution record returned by the agent execution API.
|
|
142
|
+
*/
|
|
143
|
+
export interface Execution {
|
|
144
|
+
id: string;
|
|
145
|
+
agent_id: string;
|
|
146
|
+
workspace_id: string;
|
|
147
|
+
status: "pending" | "running" | "completed" | "failed" | "cancelled" | "awaiting_approval";
|
|
148
|
+
input: Record<string, unknown>;
|
|
149
|
+
result: Record<string, unknown> | null;
|
|
150
|
+
triggered_by_user_id: string | null;
|
|
151
|
+
total_tokens: number | null;
|
|
152
|
+
total_credits_charged: string | null;
|
|
153
|
+
model_used: string | null;
|
|
154
|
+
requested_model_id: string | null;
|
|
155
|
+
execution_mode: string | null;
|
|
156
|
+
error: Record<string, unknown> | null;
|
|
157
|
+
started_at: string | null;
|
|
158
|
+
completed_at: string | null;
|
|
159
|
+
created_at: string;
|
|
160
|
+
updated_at: string;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Creates the `agents` namespace, providing methods for managing AI agents,
|
|
164
|
+
* their immutable versions, and inline training examples.
|
|
165
|
+
*
|
|
166
|
+
* Agents are the core building block of the platform. Each agent has a name,
|
|
167
|
+
* a prompt template, and an optional structured output schema. Agents can be
|
|
168
|
+
* versioned (published as immutable snapshots), tested against sample input,
|
|
169
|
+
* trained with input/output examples, and cloned to create new variants.
|
|
170
|
+
*
|
|
171
|
+
* @param rb - The `RequestBuilder` instance bound to the authenticated client.
|
|
172
|
+
* @returns An object containing all agent-related methods and sub-namespaces.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
176
|
+
* const agent = await client.agents.create('Triage Bot', 'You are a support triage assistant.');
|
|
177
|
+
* console.log(agent.id);
|
|
178
|
+
*/
|
|
179
|
+
export declare function createAgentsNamespace(rb: RequestBuilder): {
|
|
180
|
+
/**
|
|
181
|
+
* Lists agents in the workspace, with optional pagination controls.
|
|
182
|
+
*
|
|
183
|
+
* Returns a single page of agents. Use {@link listAll} to fetch every agent
|
|
184
|
+
* across all pages automatically.
|
|
185
|
+
*
|
|
186
|
+
* @param options - Optional pagination and request options.
|
|
187
|
+
* @param options.page - The page number to fetch (1-based). Defaults to 1.
|
|
188
|
+
* @param options.pageSize - Number of agents per page. Defaults to the server default.
|
|
189
|
+
* @returns A promise that resolves to an array of `Agent` objects on the requested page.
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
193
|
+
*
|
|
194
|
+
* // First page with default page size
|
|
195
|
+
* const page1 = await client.agents.list();
|
|
196
|
+
*
|
|
197
|
+
* // Second page, 10 agents per page
|
|
198
|
+
* const page2 = await client.agents.list({ page: 2, pageSize: 10 });
|
|
199
|
+
*/
|
|
200
|
+
list: (options?: {
|
|
201
|
+
page?: number;
|
|
202
|
+
pageSize?: number;
|
|
203
|
+
} & RequestOptions) => Promise<Agent[]>;
|
|
204
|
+
/**
|
|
205
|
+
* Fetches all agents in the workspace by transparently paginating through
|
|
206
|
+
* every page until exhausted.
|
|
207
|
+
*
|
|
208
|
+
* This is a convenience wrapper around {@link list} that handles cursor/page
|
|
209
|
+
* management automatically. For workspaces with a very large number of agents,
|
|
210
|
+
* prefer {@link list} with explicit pagination to control memory usage.
|
|
211
|
+
*
|
|
212
|
+
* @param options - Optional request options (e.g. custom headers, abort signal).
|
|
213
|
+
* @returns A promise that resolves to a flat array of every `Agent` in the workspace.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
217
|
+
* const allAgents = await client.agents.listAll();
|
|
218
|
+
* console.log(`Total agents: ${allAgents.length}`);
|
|
219
|
+
*/
|
|
220
|
+
listAll: (options?: RequestOptions) => Promise<Agent[]>;
|
|
221
|
+
/**
|
|
222
|
+
* Permanently deletes an agent by its ID.
|
|
223
|
+
*
|
|
224
|
+
* This action is irreversible. All associated training examples, versions,
|
|
225
|
+
* and execution history will also be removed. If you only want to hide the
|
|
226
|
+
* agent from active use, consider archiving it instead.
|
|
227
|
+
*
|
|
228
|
+
* @param id - The UUID of the agent to delete.
|
|
229
|
+
* @param options - Optional request options.
|
|
230
|
+
* @returns A promise that resolves to `true` on successful deletion.
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
234
|
+
* await client.agents.delete('agt_01HXYZ...');
|
|
235
|
+
*/
|
|
236
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
237
|
+
/**
|
|
238
|
+
* Fetches a single agent by its ID.
|
|
239
|
+
*
|
|
240
|
+
* @param id - The UUID of the agent to retrieve.
|
|
241
|
+
* @param options - Optional request options.
|
|
242
|
+
* @returns A promise that resolves to the full `Agent` object.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
246
|
+
* const agent = await client.agents.get('agt_01HXYZ...');
|
|
247
|
+
* console.log(agent.attributes.name);
|
|
248
|
+
*/
|
|
249
|
+
get: (id: string, options?: RequestOptions) => Promise<Agent>;
|
|
250
|
+
/**
|
|
251
|
+
* Look up an agent by its system_slug. Use this for ISV-provisioned agents
|
|
252
|
+
* where the slug is a stable identifier that survives database resets.
|
|
253
|
+
*
|
|
254
|
+
* @param slug - The system_slug of the agent (e.g., "chartless-session-prep-briefing").
|
|
255
|
+
* @param options - Optional request options.
|
|
256
|
+
* @returns The Agent record.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```ts
|
|
260
|
+
* const agent = await client.agents.getBySlug("chartless-session-prep-briefing");
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
getBySlug: (slug: string, options?: RequestOptions) => Promise<Agent>;
|
|
264
|
+
/**
|
|
265
|
+
* Creates a new agent with a blank initial version (v1).
|
|
266
|
+
*
|
|
267
|
+
* The agent is created with default settings. To set the prompt template,
|
|
268
|
+
* create or update a schema version after creation:
|
|
269
|
+
*
|
|
270
|
+
* ```typescript
|
|
271
|
+
* const agent = await client.agents.create('Invoice Parser');
|
|
272
|
+
* await client.agents.updateSchemaVersion(agent.id, versionId, {
|
|
273
|
+
* prompt_template: 'You are an expert invoice parser...',
|
|
274
|
+
* });
|
|
275
|
+
* ```
|
|
276
|
+
*
|
|
277
|
+
* @param name - The display name for the agent.
|
|
278
|
+
* @param attributes - Optional agent attributes (description, instructions, tags, etc.).
|
|
279
|
+
* @param options - Optional request options.
|
|
280
|
+
* @returns A promise that resolves to the created `Agent` object with its auto-generated v1.
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
284
|
+
*
|
|
285
|
+
* const agent = await client.agents.create('Invoice Parser', {
|
|
286
|
+
* description: 'Extracts structured data from invoices',
|
|
287
|
+
* instructions: 'Focus on line items and totals',
|
|
288
|
+
* });
|
|
289
|
+
* console.log(`Created agent: ${agent.id}`);
|
|
290
|
+
*/
|
|
291
|
+
create: (name: string, attributes?: CreateAgentAttributes, options?: RequestOptions) => Promise<Agent>;
|
|
292
|
+
/**
|
|
293
|
+
* Updates one or more attributes of an existing agent.
|
|
294
|
+
*
|
|
295
|
+
* Only the fields present in `attributes` are changed; all other fields
|
|
296
|
+
* remain unchanged (PATCH semantics).
|
|
297
|
+
*
|
|
298
|
+
* @param id - The UUID of the agent to update.
|
|
299
|
+
* @param attributes - A partial map of agent attributes to update
|
|
300
|
+
* (e.g. `{ name: 'New Name', description: 'Updated description' }`).
|
|
301
|
+
* @param options - Optional request options.
|
|
302
|
+
* @returns A promise that resolves to the updated `Agent` object.
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
306
|
+
*
|
|
307
|
+
* const updated = await client.agents.update('agt_01HXYZ...', {
|
|
308
|
+
* name: 'Invoice Parser v2',
|
|
309
|
+
* temperature: 0.1,
|
|
310
|
+
* });
|
|
311
|
+
* console.log(updated.attributes.name); // 'Invoice Parser v2'
|
|
312
|
+
*/
|
|
313
|
+
update: (id: string, attributes: UpdateAgentAttributes, options?: RequestOptions) => Promise<Agent>;
|
|
314
|
+
/**
|
|
315
|
+
* Runs the agent against a sample input to verify end-to-end behavior.
|
|
316
|
+
*
|
|
317
|
+
* This triggers a live LLM call using the agent's current prompt template and
|
|
318
|
+
* configuration. The result is returned without persisting any output. Useful
|
|
319
|
+
* for smoke-testing an agent before publishing a version or deploying it to
|
|
320
|
+
* production traffic.
|
|
321
|
+
*
|
|
322
|
+
* @param id - The UUID of the agent to test.
|
|
323
|
+
* @param options - Optional request options.
|
|
324
|
+
* @returns A promise that resolves to the `Agent` object annotated with test output.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
328
|
+
* const result = await client.agents.test('agt_01HXYZ...');
|
|
329
|
+
* console.log(result.attributes.last_test_output);
|
|
330
|
+
*/
|
|
331
|
+
test: (id: string, options?: RequestOptions) => Promise<Agent>;
|
|
332
|
+
/**
|
|
333
|
+
* Validates sample output against the agent's declared output schema.
|
|
334
|
+
*
|
|
335
|
+
* Runs schema validation logic on the agent's current output definition to
|
|
336
|
+
* confirm that structured fields are consistent, required fields are present,
|
|
337
|
+
* and type constraints are satisfied. Does not trigger an LLM call.
|
|
338
|
+
*
|
|
339
|
+
* @param id - The UUID of the agent to validate.
|
|
340
|
+
* @param options - Optional request options.
|
|
341
|
+
* @returns A promise that resolves to the `Agent` object annotated with validation results.
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
345
|
+
* const result = await client.agents.validate('agt_01HXYZ...');
|
|
346
|
+
* console.log(result.attributes.validation_errors); // [] means valid
|
|
347
|
+
*/
|
|
348
|
+
validate: (id: string, options?: RequestOptions) => Promise<Agent>;
|
|
349
|
+
/**
|
|
350
|
+
* Creates a copy of the agent under a new identity.
|
|
351
|
+
*
|
|
352
|
+
* The cloned agent receives a new ID and a name derived from the original
|
|
353
|
+
* (e.g. `"Invoice Parser (copy)"`). All prompt template content, schema
|
|
354
|
+
* fields, and configuration are duplicated. Training examples and version
|
|
355
|
+
* history are NOT copied.
|
|
356
|
+
*
|
|
357
|
+
* @param id - The UUID of the agent to clone.
|
|
358
|
+
* @param options - Optional request options.
|
|
359
|
+
* @returns A promise that resolves to the newly created clone `Agent` object.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
363
|
+
* const clone = await client.agents.clone('agt_01HXYZ...');
|
|
364
|
+
* console.log(`New agent ID: ${clone.id}`); // different from original
|
|
365
|
+
*/
|
|
366
|
+
clone: (id: string, options?: RequestOptions) => Promise<Agent>;
|
|
367
|
+
/**
|
|
368
|
+
* Exports the agent's full configuration and training examples as a
|
|
369
|
+
* portable bundle.
|
|
370
|
+
*
|
|
371
|
+
* The export payload includes the agent's prompt template, schema definition,
|
|
372
|
+
* all training examples, and published version metadata. The format is
|
|
373
|
+
* suitable for importing into another workspace or backing up the agent.
|
|
374
|
+
*
|
|
375
|
+
* @param id - The UUID of the agent to export.
|
|
376
|
+
* @param options - Optional request options.
|
|
377
|
+
* @returns A promise that resolves to the `Agent` object containing the export payload.
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
381
|
+
* const bundle = await client.agents.export('agt_01HXYZ...');
|
|
382
|
+
* console.log(bundle.attributes.export_data); // JSON-serializable bundle
|
|
383
|
+
*/
|
|
384
|
+
export: (id: string, options?: RequestOptions) => Promise<Agent>;
|
|
385
|
+
/**
|
|
386
|
+
* Runs AI-powered analysis over the agent's training examples to detect
|
|
387
|
+
* conflicts, coverage gaps, and quality issues.
|
|
388
|
+
*
|
|
389
|
+
* The analysis inspects all training examples associated with the agent and
|
|
390
|
+
* uses an LLM to identify: duplicate or near-duplicate examples, contradictory
|
|
391
|
+
* input/output pairs, missing coverage for common scenarios, and low-quality
|
|
392
|
+
* examples that may harm model performance. Results are returned as structured
|
|
393
|
+
* findings attached to the agent.
|
|
394
|
+
*
|
|
395
|
+
* @param id - The UUID of the agent to analyze.
|
|
396
|
+
* @param options - Optional request options.
|
|
397
|
+
* @returns A promise that resolves to the `Agent` object annotated with analysis findings.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
401
|
+
* const analysis = await client.agents.analyzeTraining('agt_01HXYZ...');
|
|
402
|
+
* const findings = analysis.attributes.training_analysis;
|
|
403
|
+
* console.log(`Conflicts found: ${findings.conflicts.length}`);
|
|
404
|
+
* console.log(`Coverage gaps: ${findings.gaps.length}`);
|
|
405
|
+
*/
|
|
406
|
+
analyzeTraining: (id: string, options?: RequestOptions) => Promise<Agent>;
|
|
407
|
+
/**
|
|
408
|
+
* Triggers a fine-tuning or in-context learning run for the agent.
|
|
409
|
+
*
|
|
410
|
+
* Initiates a teach job that ingests the agent's current training examples and
|
|
411
|
+
* incorporates them into the agent's behavior — either by running a supervised
|
|
412
|
+
* fine-tuning job (for supported model backends) or by compiling examples into
|
|
413
|
+
* an optimized few-shot prompt block. The returned agent reflects the updated
|
|
414
|
+
* training state once the job completes.
|
|
415
|
+
*
|
|
416
|
+
* @param id - The UUID of the agent to teach.
|
|
417
|
+
* @param options - Optional request options.
|
|
418
|
+
* @returns A promise that resolves to the `Agent` object with updated training metadata.
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
422
|
+
* const taught = await client.agents.teach('agt_01HXYZ...');
|
|
423
|
+
* console.log(taught.attributes.last_trained_at); // ISO timestamp
|
|
424
|
+
*/
|
|
425
|
+
teach: (id: string, params?: TeachParams, options?: RequestOptions) => Promise<Agent>;
|
|
426
|
+
/**
|
|
427
|
+
* Snapshots the agent's current state as a new immutable version.
|
|
428
|
+
*
|
|
429
|
+
* Published versions are permanent, append-only records of an agent at a
|
|
430
|
+
* specific point in time. They capture the prompt template, schema fields,
|
|
431
|
+
* model configuration, and training state. Once published, a version cannot
|
|
432
|
+
* be modified — only the live (draft) agent continues to change. Versions are
|
|
433
|
+
* used for rollback, A/B comparison, and production promotion workflows.
|
|
434
|
+
*
|
|
435
|
+
* @param id - The UUID of the agent to publish a version for.
|
|
436
|
+
* @param options - Optional request options.
|
|
437
|
+
* @returns A promise that resolves to the `Agent` object with updated version metadata.
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
441
|
+
*
|
|
442
|
+
* // After making edits, lock the current state as a version
|
|
443
|
+
* const agent = await client.agents.publishVersion('agt_01HXYZ...');
|
|
444
|
+
* console.log(`Latest version: ${agent.attributes.current_version}`);
|
|
445
|
+
*/
|
|
446
|
+
publishVersion: (id: string, options?: RequestOptions) => Promise<Agent>;
|
|
447
|
+
/**
|
|
448
|
+
* Restores the agent's live (draft) state to match a previously published version.
|
|
449
|
+
*
|
|
450
|
+
* Copies the prompt template, schema fields, and model configuration from the
|
|
451
|
+
* target version back onto the live agent. Existing training examples are not
|
|
452
|
+
* affected. After restoring, you can make further edits before publishing a
|
|
453
|
+
* new version.
|
|
454
|
+
*
|
|
455
|
+
* @param id - The UUID of the agent (or version) to restore from.
|
|
456
|
+
* @param options - Optional request options.
|
|
457
|
+
* @returns A promise that resolves to the `Agent` object after restoration.
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
461
|
+
*
|
|
462
|
+
* // Roll back to the previous known-good state
|
|
463
|
+
* const agent = await client.agents.restoreVersion('agt_01HXYZ...');
|
|
464
|
+
* console.log('Agent restored to previous version');
|
|
465
|
+
*/
|
|
466
|
+
restoreVersion: (id: string, body?: {
|
|
467
|
+
version_id?: string;
|
|
468
|
+
}, options?: RequestOptions) => Promise<Agent>;
|
|
469
|
+
/**
|
|
470
|
+
* Retrieves usage statistics and performance metrics for an agent.
|
|
471
|
+
*
|
|
472
|
+
* Returns aggregated data such as total execution count, average latency,
|
|
473
|
+
* token consumption, error rates, and training example counts. Useful for
|
|
474
|
+
* monitoring agent health and understanding cost attribution.
|
|
475
|
+
*
|
|
476
|
+
* @param id - The UUID of the agent to retrieve stats for.
|
|
477
|
+
* @param options - Optional request options.
|
|
478
|
+
* @returns A promise that resolves to a map of metric names to their values.
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
482
|
+
* const stats = await client.agents.stats('agt_01HXYZ...');
|
|
483
|
+
* console.log(`Total executions: ${stats.execution_count}`);
|
|
484
|
+
* console.log(`Avg latency (ms): ${stats.avg_latency_ms}`);
|
|
485
|
+
*/
|
|
486
|
+
stats: (id: string, options?: RequestOptions) => Promise<AgentStatsResponse>;
|
|
487
|
+
/**
|
|
488
|
+
* Imports an agent from a portable export bundle.
|
|
489
|
+
*
|
|
490
|
+
* Accepts the JSON bundle produced by {@link export} and creates a new
|
|
491
|
+
* agent in the current workspace with all configuration, schema fields,
|
|
492
|
+
* and training examples from the bundle.
|
|
493
|
+
*
|
|
494
|
+
* @param data - The export bundle object.
|
|
495
|
+
* @param options - Optional request options.
|
|
496
|
+
* @returns The newly created Agent from the import.
|
|
497
|
+
*
|
|
498
|
+
* @example
|
|
499
|
+
* const imported = await client.agents.import(exportBundle);
|
|
500
|
+
*/
|
|
501
|
+
import: (data: Record<string, unknown>, options?: RequestOptions) => Promise<Agent>;
|
|
502
|
+
/**
|
|
503
|
+
* Retrieves usage information for a single agent.
|
|
504
|
+
*
|
|
505
|
+
* Returns metrics about how the agent is being used, including
|
|
506
|
+
* execution counts, sharing status, and ownership details.
|
|
507
|
+
*
|
|
508
|
+
* @param id - The UUID of the agent.
|
|
509
|
+
* @param options - Optional request options.
|
|
510
|
+
* @returns Usage data for the agent.
|
|
511
|
+
*
|
|
512
|
+
* @example
|
|
513
|
+
* const usage = await client.agents.usage('agt_01HXYZ...');
|
|
514
|
+
*/
|
|
515
|
+
usage: (id: string, options?: RequestOptions) => Promise<AgentUsageResponse>;
|
|
516
|
+
/**
|
|
517
|
+
* Retrieves usage information for all agents in the workspace.
|
|
518
|
+
*
|
|
519
|
+
* @param options - Optional request options.
|
|
520
|
+
* @returns Array of usage data for all agents.
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* const allUsage = await client.agents.usageAll();
|
|
524
|
+
*/
|
|
525
|
+
usageAll: (options?: RequestOptions) => Promise<AgentUsageResponse[]>;
|
|
526
|
+
/**
|
|
527
|
+
* Returns the existing draft version for this agent, or creates one.
|
|
528
|
+
*
|
|
529
|
+
* If a draft already exists, it is returned unchanged. If no draft exists
|
|
530
|
+
* and an active version is present, creates a draft by cloning the active
|
|
531
|
+
* version. If neither exists, creates an empty draft at v1.
|
|
532
|
+
*
|
|
533
|
+
* @param id - The UUID of the agent.
|
|
534
|
+
* @param options - Optional request options.
|
|
535
|
+
* @returns The draft AgentVersion.
|
|
536
|
+
*
|
|
537
|
+
* @example
|
|
538
|
+
* const draft = await client.agents.getOrCreateDraft('agt_01HXYZ...');
|
|
539
|
+
*/
|
|
540
|
+
getOrCreateDraft: (id: string, options?: RequestOptions) => Promise<AgentVersion>;
|
|
541
|
+
/**
|
|
542
|
+
* Promotes the draft version to active, deactivating the previous active version.
|
|
543
|
+
*
|
|
544
|
+
* @param id - The UUID of the agent.
|
|
545
|
+
* @param options - Optional request options.
|
|
546
|
+
* @returns The newly activated AgentVersion.
|
|
547
|
+
*
|
|
548
|
+
* @example
|
|
549
|
+
* const published = await client.agents.publishDraft('agt_01HXYZ...');
|
|
550
|
+
*/
|
|
551
|
+
publishDraft: (id: string, options?: RequestOptions) => Promise<AgentVersion>;
|
|
552
|
+
/**
|
|
553
|
+
* Clones an agent into a different workspace.
|
|
554
|
+
*
|
|
555
|
+
* @param agentId - The UUID of the agent to clone.
|
|
556
|
+
* @param targetWorkspaceId - The UUID of the destination workspace.
|
|
557
|
+
* @param options - Optional request options.
|
|
558
|
+
* @returns The cloned Agent in the target workspace.
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* const cloned = await client.agents.cloneForWorkspace('agt_01...', 'ws_02...');
|
|
562
|
+
*/
|
|
563
|
+
cloneForWorkspace: (agentId: string, targetWorkspaceId: string, options?: RequestOptions) => Promise<Agent>;
|
|
564
|
+
/**
|
|
565
|
+
* Retrieves training statistics for a single agent.
|
|
566
|
+
*
|
|
567
|
+
* @param id - The UUID of the agent.
|
|
568
|
+
* @param options - Optional request options.
|
|
569
|
+
* @returns Training statistics data.
|
|
570
|
+
*
|
|
571
|
+
* @example
|
|
572
|
+
* const stats = await client.agents.trainingStats('agt_01...');
|
|
573
|
+
*/
|
|
574
|
+
trainingStats: (id: string, options?: RequestOptions) => Promise<TrainingStatsResponse>;
|
|
575
|
+
/**
|
|
576
|
+
* Records a test result for an agent.
|
|
577
|
+
*
|
|
578
|
+
* @param attributes - Test result attributes (agent_id, input, expected_output, actual_output, passed, etc.).
|
|
579
|
+
* @param options - Optional request options.
|
|
580
|
+
* @returns The created test result record.
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
* const result = await client.agents.createTestResult({
|
|
584
|
+
* agent_id: 'agt_01...',
|
|
585
|
+
* input: { text: 'test input' },
|
|
586
|
+
* expected_output: { amount: 100 },
|
|
587
|
+
* actual_output: { amount: 100 },
|
|
588
|
+
* passed: true,
|
|
589
|
+
* });
|
|
590
|
+
*/
|
|
591
|
+
createTestResult: (attributes: CreateTestResultAttributes, options?: RequestOptions) => Promise<AgentTestResultResponse>;
|
|
592
|
+
/**
|
|
593
|
+
* Sub-namespace for managing immutable agent versions.
|
|
594
|
+
*
|
|
595
|
+
* Agent versions are permanent snapshots of an agent's configuration at a
|
|
596
|
+
* specific point in time. They cannot be edited after creation. Use
|
|
597
|
+
* `agents.publishVersion(id)` to create a new version from the live agent
|
|
598
|
+
* state, and use these methods to inspect, compare, or delete past versions.
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
602
|
+
* const versions = await client.agents.versions.listAll();
|
|
603
|
+
* console.log(`Published versions: ${versions.length}`);
|
|
604
|
+
*/
|
|
605
|
+
versions: {
|
|
606
|
+
/**
|
|
607
|
+
* Lists published agent versions with optional pagination controls.
|
|
608
|
+
*
|
|
609
|
+
* Returns a single page of versions. Use {@link listAll} to fetch every
|
|
610
|
+
* version across all pages automatically.
|
|
611
|
+
*
|
|
612
|
+
* @param options - Optional pagination and request options.
|
|
613
|
+
* @param options.page - The page number to fetch (1-based).
|
|
614
|
+
* @param options.pageSize - Number of versions per page.
|
|
615
|
+
* @returns A promise that resolves to an array of `AgentVersion` objects.
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
619
|
+
* const versions = await client.agents.versions.list({ page: 1, pageSize: 20 });
|
|
620
|
+
*/
|
|
621
|
+
list: (options?: {
|
|
622
|
+
page?: number;
|
|
623
|
+
pageSize?: number;
|
|
624
|
+
} & RequestOptions) => Promise<AgentVersion[]>;
|
|
625
|
+
/**
|
|
626
|
+
* Fetches all published agent versions by transparently paginating through
|
|
627
|
+
* every page until exhausted.
|
|
628
|
+
*
|
|
629
|
+
* @param options - Optional request options.
|
|
630
|
+
* @returns A promise that resolves to a flat array of all `AgentVersion` objects.
|
|
631
|
+
*
|
|
632
|
+
* @example
|
|
633
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
634
|
+
* const allVersions = await client.agents.versions.listAll();
|
|
635
|
+
* const latest = allVersions.at(-1);
|
|
636
|
+
*/
|
|
637
|
+
listAll: (options?: RequestOptions) => Promise<AgentVersion[]>;
|
|
638
|
+
/**
|
|
639
|
+
* Fetches a single published agent version by its ID.
|
|
640
|
+
*
|
|
641
|
+
* @param id - The UUID of the agent version to retrieve.
|
|
642
|
+
* @param options - Optional request options.
|
|
643
|
+
* @returns A promise that resolves to the full `AgentVersion` object.
|
|
644
|
+
*
|
|
645
|
+
* @example
|
|
646
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
647
|
+
* const version = await client.agents.versions.get('ver_01HXYZ...');
|
|
648
|
+
* console.log(version.attributes.schema_snapshot);
|
|
649
|
+
*/
|
|
650
|
+
get: (id: string, options?: RequestOptions) => Promise<AgentVersion>;
|
|
651
|
+
/**
|
|
652
|
+
* Permanently deletes a published agent version by its ID.
|
|
653
|
+
*
|
|
654
|
+
* Deleting a version does not affect the live agent. However, any
|
|
655
|
+
* production deployments pinned to this version will lose their reference.
|
|
656
|
+
* Ensure no active deployments depend on the version before deleting it.
|
|
657
|
+
*
|
|
658
|
+
* @param id - The UUID of the agent version to delete.
|
|
659
|
+
* @param options - Optional request options.
|
|
660
|
+
* @returns A promise that resolves to `true` on successful deletion.
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
664
|
+
* await client.agents.versions.delete('ver_01HXYZ...');
|
|
665
|
+
*/
|
|
666
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
667
|
+
/**
|
|
668
|
+
* Creates a new agent version directly from a set of attributes.
|
|
669
|
+
*
|
|
670
|
+
* In most cases you should use `agents.publishVersion(agentId)` to snapshot
|
|
671
|
+
* the live agent state. This lower-level method is provided for advanced
|
|
672
|
+
* workflows where version attributes must be specified explicitly (e.g.
|
|
673
|
+
* when importing a version from another workspace).
|
|
674
|
+
*
|
|
675
|
+
* @param attributes - The version attributes to set (e.g. schema snapshot, prompt).
|
|
676
|
+
* @param options - Optional request options.
|
|
677
|
+
* @returns A promise that resolves to the newly created `AgentVersion` object.
|
|
678
|
+
*
|
|
679
|
+
* @example
|
|
680
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
681
|
+
* const version = await client.agents.versions.create({
|
|
682
|
+
* agent_id: 'agt_01HXYZ...',
|
|
683
|
+
* prompt_template: 'You are a helpful assistant.',
|
|
684
|
+
* });
|
|
685
|
+
*/
|
|
686
|
+
create: (attributes: CreateAgentVersionAttributes, options?: RequestOptions) => Promise<AgentVersion>;
|
|
687
|
+
/**
|
|
688
|
+
* Adds a predefined platform system field to this version's output schema.
|
|
689
|
+
*
|
|
690
|
+
* System fields are underscore-prefixed metadata fields automatically
|
|
691
|
+
* populated during document processing (e.g. `_filename`, `_pages`,
|
|
692
|
+
* `_char_count`). Adding a system field makes it visible in exports and
|
|
693
|
+
* API responses for documents processed by this version.
|
|
694
|
+
*
|
|
695
|
+
* @param id - The UUID of the agent version to modify.
|
|
696
|
+
* @param fieldName - The name of the system field to add (e.g. `_filename`, `_pages`).
|
|
697
|
+
* @param options - Optional request options.
|
|
698
|
+
* @returns A promise that resolves to the updated `AgentVersion` object.
|
|
699
|
+
*
|
|
700
|
+
* @example
|
|
701
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
702
|
+
* const version = await client.agents.versions.addSystemField('ver_01HXYZ...', '_filename');
|
|
703
|
+
* console.log(version.attributes.system_fields); // includes newly added field
|
|
704
|
+
*/
|
|
705
|
+
addSystemField: (id: string, fieldName: string, options?: RequestOptions) => Promise<AgentVersion>;
|
|
706
|
+
/**
|
|
707
|
+
* Removes a system field from this version's output schema.
|
|
708
|
+
*
|
|
709
|
+
* After removal, the field will no longer appear in exports or API responses
|
|
710
|
+
* for documents processed by this version. Only system fields (underscore-
|
|
711
|
+
* prefixed) can be removed via this method; user-defined fields are managed
|
|
712
|
+
* through the agent update endpoint.
|
|
713
|
+
*
|
|
714
|
+
* @param id - The UUID of the agent version to modify.
|
|
715
|
+
* @param fieldName - The name of the system field to remove (e.g. `_filename`, `_pages`).
|
|
716
|
+
* @param options - Optional request options.
|
|
717
|
+
* @returns A promise that resolves to the updated `AgentVersion` object.
|
|
718
|
+
*
|
|
719
|
+
* @example
|
|
720
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
721
|
+
* const version = await client.agents.versions.removeSystemField('ver_01HXYZ...', '_filename');
|
|
722
|
+
*/
|
|
723
|
+
removeSystemField: (id: string, fieldName: string, options?: RequestOptions) => Promise<AgentVersion>;
|
|
724
|
+
/**
|
|
725
|
+
* Replaces the entire set of system fields on this version's schema in a
|
|
726
|
+
* single atomic batch operation.
|
|
727
|
+
*
|
|
728
|
+
* This is more efficient than calling `addSystemField` and `removeSystemField`
|
|
729
|
+
* repeatedly when reconfiguring which system metadata fields should appear in
|
|
730
|
+
* the output schema. All previously configured system fields not present in
|
|
731
|
+
* the new set will be removed.
|
|
732
|
+
*
|
|
733
|
+
* @param id - The UUID of the agent version to update.
|
|
734
|
+
* @param fieldNames - The complete list of system field names to set (e.g. `['_filename', '_pages']`).
|
|
735
|
+
* @param options - Optional request options.
|
|
736
|
+
* @returns A promise that resolves to the updated `AgentVersion` object.
|
|
737
|
+
*
|
|
738
|
+
* @example
|
|
739
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
740
|
+
* // Replace all system fields in one call
|
|
741
|
+
* const version = await client.agents.versions.setSystemFields('ver_01HXYZ...', ['_filename', '_pages']);
|
|
742
|
+
* console.log(version.attributes.system_fields);
|
|
743
|
+
*/
|
|
744
|
+
setSystemFields: (id: string, fieldNames: string[], options?: RequestOptions) => Promise<AgentVersion>;
|
|
745
|
+
/**
|
|
746
|
+
* Retrieves performance metrics for an agent version.
|
|
747
|
+
*
|
|
748
|
+
* @param id - The UUID of the agent version.
|
|
749
|
+
* @param options - Optional request options.
|
|
750
|
+
* @returns Metrics data for the version.
|
|
751
|
+
*
|
|
752
|
+
* @example
|
|
753
|
+
* const metrics = await client.agents.versions.metrics('ver_01HXYZ...');
|
|
754
|
+
*/
|
|
755
|
+
metrics: (id: string, options?: RequestOptions) => Promise<VersionMetricsResponse>;
|
|
756
|
+
/**
|
|
757
|
+
* Lists revision history for an agent version.
|
|
758
|
+
*
|
|
759
|
+
* Each revision represents a content change (prompt tweak, description
|
|
760
|
+
* update) within the same schema version.
|
|
761
|
+
*
|
|
762
|
+
* @param id - The UUID of the agent version.
|
|
763
|
+
* @param options - Optional request options.
|
|
764
|
+
* @returns Array of revision records.
|
|
765
|
+
*
|
|
766
|
+
* @example
|
|
767
|
+
* const revisions = await client.agents.versions.revisions('ver_01HXYZ...');
|
|
768
|
+
*/
|
|
769
|
+
revisions: (id: string, options?: RequestOptions) => Promise<VersionRevision[]>;
|
|
770
|
+
/**
|
|
771
|
+
* Fetches a single revision by ID.
|
|
772
|
+
*
|
|
773
|
+
* @param id - The UUID of the revision.
|
|
774
|
+
* @param options - Optional request options.
|
|
775
|
+
* @returns The revision record.
|
|
776
|
+
*
|
|
777
|
+
* @example
|
|
778
|
+
* const revision = await client.agents.versions.getRevision('rev_01...');
|
|
779
|
+
*/
|
|
780
|
+
getRevision: (id: string, options?: RequestOptions) => Promise<VersionRevision>;
|
|
781
|
+
/**
|
|
782
|
+
* Lists all revisions across all agent versions.
|
|
783
|
+
*
|
|
784
|
+
* @param options - Optional request options.
|
|
785
|
+
* @returns Array of all revision records.
|
|
786
|
+
*
|
|
787
|
+
* @example
|
|
788
|
+
* const allRevisions = await client.agents.versions.listAllRevisions();
|
|
789
|
+
*/
|
|
790
|
+
listAllRevisions: (options?: RequestOptions) => Promise<VersionRevision[]>;
|
|
791
|
+
/**
|
|
792
|
+
* Compares two agent versions side-by-side.
|
|
793
|
+
*
|
|
794
|
+
* Returns a structured diff of schema fields, prompt templates, and
|
|
795
|
+
* configuration between version A and version B.
|
|
796
|
+
*
|
|
797
|
+
* @param versionAId - UUID of the first version.
|
|
798
|
+
* @param versionBId - UUID of the second version.
|
|
799
|
+
* @param options - Optional request options.
|
|
800
|
+
* @returns Comparison result with schema_diff and prompt_diff.
|
|
801
|
+
*
|
|
802
|
+
* @example
|
|
803
|
+
* const diff = await client.agents.versions.compare('ver_A...', 'ver_B...');
|
|
804
|
+
*/
|
|
805
|
+
compare: (versionAId: string, versionBId: string, options?: RequestOptions) => Promise<VersionComparisonResponse>;
|
|
806
|
+
/**
|
|
807
|
+
* Sub-namespace for managing schema versions within an agent.
|
|
808
|
+
*
|
|
809
|
+
* Schema versions track structural changes (new fields, type changes)
|
|
810
|
+
* independently from content revisions (prompt tweaks).
|
|
811
|
+
*/
|
|
812
|
+
schemaVersions: {
|
|
813
|
+
/**
|
|
814
|
+
* Lists all schema versions for an agent.
|
|
815
|
+
*
|
|
816
|
+
* @param agentId - The UUID of the agent.
|
|
817
|
+
* @param options - Optional request options.
|
|
818
|
+
* @returns Array of schema version records.
|
|
819
|
+
*
|
|
820
|
+
* @example
|
|
821
|
+
* const versions = await client.agents.versions.schemaVersions.list('agt_01...');
|
|
822
|
+
*/
|
|
823
|
+
list: (agentId: string, options?: RequestOptions) => Promise<AgentVersion[]>;
|
|
824
|
+
/**
|
|
825
|
+
* Creates a new schema version for an agent.
|
|
826
|
+
*
|
|
827
|
+
* @param agentId - The UUID of the agent.
|
|
828
|
+
* @param attributes - Schema version attributes (fields, changes_summary).
|
|
829
|
+
* @param options - Optional request options.
|
|
830
|
+
* @returns The newly created schema version.
|
|
831
|
+
*
|
|
832
|
+
* @example
|
|
833
|
+
* const sv = await client.agents.versions.schemaVersions.create('agt_01...', {
|
|
834
|
+
* output_schema: { type: 'object', properties: { amount: { type: 'number' } } },
|
|
835
|
+
* });
|
|
836
|
+
*/
|
|
837
|
+
create: (agentId: string, attributes: CreateAgentVersionAttributes, options?: RequestOptions) => Promise<AgentVersion>;
|
|
838
|
+
/**
|
|
839
|
+
* Activates a schema version, making it the live version.
|
|
840
|
+
*
|
|
841
|
+
* @param agentId - The UUID of the agent.
|
|
842
|
+
* @param versionId - The UUID of the schema version to activate.
|
|
843
|
+
* @param options - Optional request options.
|
|
844
|
+
* @returns The activated schema version.
|
|
845
|
+
*
|
|
846
|
+
* @example
|
|
847
|
+
* await client.agents.versions.schemaVersions.activate('agt_01...', 'ver_01...');
|
|
848
|
+
*/
|
|
849
|
+
activate: (agentId: string, versionId: string, options?: RequestOptions) => Promise<AgentVersion>;
|
|
850
|
+
/**
|
|
851
|
+
* Updates fields or metadata on an existing schema version.
|
|
852
|
+
*
|
|
853
|
+
* @param agentId - The UUID of the agent.
|
|
854
|
+
* @param versionId - The UUID of the schema version to update.
|
|
855
|
+
* @param attributes - Attributes to update (fields, changes_summary).
|
|
856
|
+
* @param options - Optional request options.
|
|
857
|
+
* @returns The updated schema version.
|
|
858
|
+
*
|
|
859
|
+
* @example
|
|
860
|
+
* await client.agents.versions.schemaVersions.update('agt_01...', 'ver_01...', {
|
|
861
|
+
* output_schema: { type: 'object', properties: { total: { type: 'number' } } },
|
|
862
|
+
* });
|
|
863
|
+
*/
|
|
864
|
+
update: (agentId: string, versionId: string, attributes: UpdateAgentVersionAttributes, options?: RequestOptions) => Promise<AgentVersion>;
|
|
865
|
+
};
|
|
866
|
+
};
|
|
867
|
+
/**
|
|
868
|
+
* Sub-namespace for managing training examples attached to agents.
|
|
869
|
+
*
|
|
870
|
+
* Training examples are input/output pairs that teach an agent how to behave.
|
|
871
|
+
* They are used both for fine-tuning jobs (via `agents.teach`) and as few-shot
|
|
872
|
+
* context injected into the agent's prompt. More high-quality, diverse examples
|
|
873
|
+
* generally lead to better and more consistent agent outputs.
|
|
874
|
+
*
|
|
875
|
+
* @example
|
|
876
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
877
|
+
* await client.agents.training.create({
|
|
878
|
+
* agent_id: 'agt_01HXYZ...',
|
|
879
|
+
* input: 'What is the invoice total?',
|
|
880
|
+
* output: '$1,234.56',
|
|
881
|
+
* });
|
|
882
|
+
*/
|
|
883
|
+
training: {
|
|
884
|
+
/**
|
|
885
|
+
* Permanently deletes a training example by its ID.
|
|
886
|
+
*
|
|
887
|
+
* @param id - The UUID of the training example to delete.
|
|
888
|
+
* @param options - Optional request options.
|
|
889
|
+
* @returns A promise that resolves to `true` on successful deletion.
|
|
890
|
+
*
|
|
891
|
+
* @example
|
|
892
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
893
|
+
* await client.agents.training.delete('tex_01HXYZ...');
|
|
894
|
+
*/
|
|
895
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
896
|
+
/**
|
|
897
|
+
* Lists training examples with optional pagination controls.
|
|
898
|
+
*
|
|
899
|
+
* Returns a single page of training examples. Use {@link listAll} to fetch
|
|
900
|
+
* every example across all pages automatically.
|
|
901
|
+
*
|
|
902
|
+
* @param options - Optional pagination and request options.
|
|
903
|
+
* @param options.page - The page number to fetch (1-based).
|
|
904
|
+
* @param options.pageSize - Number of examples per page.
|
|
905
|
+
* @returns A promise that resolves to an array of `TrainingExample` objects.
|
|
906
|
+
*
|
|
907
|
+
* @example
|
|
908
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
909
|
+
* const examples = await client.agents.training.list({ pageSize: 50 });
|
|
910
|
+
*/
|
|
911
|
+
list: (options?: {
|
|
912
|
+
page?: number;
|
|
913
|
+
pageSize?: number;
|
|
914
|
+
} & RequestOptions) => Promise<TrainingExample[]>;
|
|
915
|
+
/**
|
|
916
|
+
* Fetches all training examples by transparently paginating through every
|
|
917
|
+
* page until exhausted.
|
|
918
|
+
*
|
|
919
|
+
* @param options - Optional request options.
|
|
920
|
+
* @returns A promise that resolves to a flat array of all `TrainingExample` objects.
|
|
921
|
+
*
|
|
922
|
+
* @example
|
|
923
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
924
|
+
* const allExamples = await client.agents.training.listAll();
|
|
925
|
+
* console.log(`Total training examples: ${allExamples.length}`);
|
|
926
|
+
*/
|
|
927
|
+
listAll: (options?: RequestOptions) => Promise<TrainingExample[]>;
|
|
928
|
+
/**
|
|
929
|
+
* Fetches a single training example by its ID.
|
|
930
|
+
*
|
|
931
|
+
* @param id - The UUID of the training example to retrieve.
|
|
932
|
+
* @param options - Optional request options.
|
|
933
|
+
* @returns A promise that resolves to the full `TrainingExample` object.
|
|
934
|
+
*
|
|
935
|
+
* @example
|
|
936
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
937
|
+
* const example = await client.agents.training.get('tex_01HXYZ...');
|
|
938
|
+
* console.log(example.attributes.input, '->', example.attributes.output);
|
|
939
|
+
*/
|
|
940
|
+
get: (id: string, options?: RequestOptions) => Promise<TrainingExample>;
|
|
941
|
+
/**
|
|
942
|
+
* Creates a new training example for an agent.
|
|
943
|
+
*
|
|
944
|
+
* At minimum you must supply an `agent_id`, an `input` string, and an
|
|
945
|
+
* `output` string. Additional metadata such as `label`, `weight`, or
|
|
946
|
+
* `source_document_id` can be included in `attributes`.
|
|
947
|
+
*
|
|
948
|
+
* @param attributes - The training example attributes, including at least
|
|
949
|
+
* `agent_id`, `input`, and `output`.
|
|
950
|
+
* @param options - Optional request options.
|
|
951
|
+
* @returns A promise that resolves to the newly created `TrainingExample` object.
|
|
952
|
+
*
|
|
953
|
+
* @example
|
|
954
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
955
|
+
*
|
|
956
|
+
* const example = await client.agents.training.create({
|
|
957
|
+
* agent_id: 'agt_01HXYZ...',
|
|
958
|
+
* input: 'Extract the vendor name from this invoice.',
|
|
959
|
+
* output: 'Acme Corp',
|
|
960
|
+
* });
|
|
961
|
+
*/
|
|
962
|
+
create: (attributes: CreateAgentTrainingExampleAttributes, options?: RequestOptions) => Promise<TrainingExample>;
|
|
963
|
+
/**
|
|
964
|
+
* Updates one or more attributes of an existing training example.
|
|
965
|
+
*
|
|
966
|
+
* Only the fields present in `attributes` are changed (PATCH semantics).
|
|
967
|
+
*
|
|
968
|
+
* @param id - The UUID of the training example to update.
|
|
969
|
+
* @param attributes - A partial map of attributes to update
|
|
970
|
+
* (e.g. `{ output: 'Corrected answer' }`).
|
|
971
|
+
* @param options - Optional request options.
|
|
972
|
+
* @returns A promise that resolves to the updated `TrainingExample` object.
|
|
973
|
+
*
|
|
974
|
+
* @example
|
|
975
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
976
|
+
*
|
|
977
|
+
* const updated = await client.agents.training.update('tex_01HXYZ...', {
|
|
978
|
+
* output: 'Corrected Corp',
|
|
979
|
+
* label: 'reviewed',
|
|
980
|
+
* });
|
|
981
|
+
*/
|
|
982
|
+
update: (id: string, attributes: UpdateAgentTrainingExampleAttributes, options?: RequestOptions) => Promise<TrainingExample>;
|
|
983
|
+
/**
|
|
984
|
+
* Creates multiple training examples in a single batch operation.
|
|
985
|
+
*
|
|
986
|
+
* @param examples - Array of training example attribute objects.
|
|
987
|
+
* @param options - Optional request options.
|
|
988
|
+
* @returns Array of created TrainingExample objects.
|
|
989
|
+
*
|
|
990
|
+
* @example
|
|
991
|
+
* const created = await client.agents.training.bulkCreate([
|
|
992
|
+
* { agent_id: 'agt_01...', input_text: '...', output_json: {} },
|
|
993
|
+
* { agent_id: 'agt_01...', input_text: '...', output_json: {} },
|
|
994
|
+
* ]);
|
|
995
|
+
*/
|
|
996
|
+
bulkCreate: (examples: CreateAgentTrainingExampleAttributes[], options?: RequestOptions) => Promise<TrainingExample[]>;
|
|
997
|
+
/**
|
|
998
|
+
* Deletes multiple training examples in a single batch operation.
|
|
999
|
+
*
|
|
1000
|
+
* @param ids - Array of training example UUIDs to delete.
|
|
1001
|
+
* @param options - Optional request options.
|
|
1002
|
+
* @returns Deletion result payload.
|
|
1003
|
+
*
|
|
1004
|
+
* @example
|
|
1005
|
+
* await client.agents.training.bulkDelete(['tex_01...', 'tex_02...']);
|
|
1006
|
+
*/
|
|
1007
|
+
bulkDelete: (ids: string[], options?: RequestOptions) => Promise<BulkDeleteResponse>;
|
|
1008
|
+
/**
|
|
1009
|
+
* Performs semantic search over training examples using vector similarity.
|
|
1010
|
+
*
|
|
1011
|
+
* @param query - The search query text.
|
|
1012
|
+
* @param options - Optional request options.
|
|
1013
|
+
* @returns Array of matching TrainingExample objects ranked by similarity.
|
|
1014
|
+
*
|
|
1015
|
+
* @example
|
|
1016
|
+
* const results = await client.agents.training.search('invoice total');
|
|
1017
|
+
*/
|
|
1018
|
+
search: (query: string, options?: RequestOptions) => Promise<TrainingExample[]>;
|
|
1019
|
+
/**
|
|
1020
|
+
* Lists training examples for a specific agent.
|
|
1021
|
+
*
|
|
1022
|
+
* @param agentId - The UUID of the agent.
|
|
1023
|
+
* @param options - Optional request options.
|
|
1024
|
+
* @returns Array of training examples for the agent.
|
|
1025
|
+
*
|
|
1026
|
+
* @example
|
|
1027
|
+
* const examples = await client.agents.training.listForAgent('agt_01...');
|
|
1028
|
+
*/
|
|
1029
|
+
listForAgent: (agentId: string, options?: RequestOptions) => Promise<TrainingExample[]>;
|
|
1030
|
+
/**
|
|
1031
|
+
* Deletes a training example for a specific agent.
|
|
1032
|
+
*
|
|
1033
|
+
* @param agentId - The UUID of the agent.
|
|
1034
|
+
* @param exampleId - The UUID of the training example to delete.
|
|
1035
|
+
* @param options - Optional request options.
|
|
1036
|
+
* @returns True on successful deletion.
|
|
1037
|
+
*
|
|
1038
|
+
* @example
|
|
1039
|
+
* await client.agents.training.deleteForAgent('agt_01...', 'tex_01...');
|
|
1040
|
+
*/
|
|
1041
|
+
deleteForAgent: (agentId: string, exampleId: string, options?: RequestOptions) => Promise<true>;
|
|
1042
|
+
/**
|
|
1043
|
+
* Sub-namespace for managing training sessions.
|
|
1044
|
+
*
|
|
1045
|
+
* Training sessions group related training examples and track
|
|
1046
|
+
* training progress over time.
|
|
1047
|
+
*/
|
|
1048
|
+
sessions: {
|
|
1049
|
+
/**
|
|
1050
|
+
* Lists training sessions for a specific agent.
|
|
1051
|
+
*
|
|
1052
|
+
* @param agentId - The UUID of the agent.
|
|
1053
|
+
* @param options - Optional request options.
|
|
1054
|
+
* @returns Array of training session records.
|
|
1055
|
+
*
|
|
1056
|
+
* @example
|
|
1057
|
+
* const sessions = await client.agents.training.sessions.list('agt_01...');
|
|
1058
|
+
*/
|
|
1059
|
+
list: (agentId: string, options?: RequestOptions) => Promise<TrainingSession[]>;
|
|
1060
|
+
/**
|
|
1061
|
+
* Fetches a single training session by ID.
|
|
1062
|
+
*
|
|
1063
|
+
* @param id - The UUID of the training session.
|
|
1064
|
+
* @param options - Optional request options.
|
|
1065
|
+
* @returns The training session record.
|
|
1066
|
+
*
|
|
1067
|
+
* @example
|
|
1068
|
+
* const session = await client.agents.training.sessions.get('ts_01...');
|
|
1069
|
+
*/
|
|
1070
|
+
get: (id: string, options?: RequestOptions) => Promise<TrainingSession>;
|
|
1071
|
+
/**
|
|
1072
|
+
* Deletes a training session by ID.
|
|
1073
|
+
*
|
|
1074
|
+
* @param id - The UUID of the training session to delete.
|
|
1075
|
+
* @param options - Optional request options.
|
|
1076
|
+
* @returns True on successful deletion.
|
|
1077
|
+
*
|
|
1078
|
+
* @example
|
|
1079
|
+
* await client.agents.training.sessions.delete('ts_01...');
|
|
1080
|
+
*/
|
|
1081
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
1082
|
+
};
|
|
1083
|
+
};
|
|
1084
|
+
/**
|
|
1085
|
+
* Sub-namespace for managing field templates.
|
|
1086
|
+
*
|
|
1087
|
+
* Field templates are reusable field definitions that can be applied
|
|
1088
|
+
* to agent schemas. They include extraction hints, validation patterns,
|
|
1089
|
+
* and LLM instructions for common field types.
|
|
1090
|
+
*/
|
|
1091
|
+
fieldTemplates: {
|
|
1092
|
+
/**
|
|
1093
|
+
* Lists all available field templates.
|
|
1094
|
+
*
|
|
1095
|
+
* @param options - Optional request options.
|
|
1096
|
+
* @returns Array of field template objects.
|
|
1097
|
+
*
|
|
1098
|
+
* @example
|
|
1099
|
+
* const templates = await client.agents.fieldTemplates.list();
|
|
1100
|
+
*/
|
|
1101
|
+
list: (options?: RequestOptions) => Promise<FieldTemplate[]>;
|
|
1102
|
+
/**
|
|
1103
|
+
* Fetches a single field template by ID.
|
|
1104
|
+
*
|
|
1105
|
+
* @param id - The UUID of the field template.
|
|
1106
|
+
* @param options - Optional request options.
|
|
1107
|
+
* @returns The field template object.
|
|
1108
|
+
*
|
|
1109
|
+
* @example
|
|
1110
|
+
* const template = await client.agents.fieldTemplates.get('ftpl_01...');
|
|
1111
|
+
*/
|
|
1112
|
+
get: (id: string, options?: RequestOptions) => Promise<FieldTemplate>;
|
|
1113
|
+
/**
|
|
1114
|
+
* Creates a new field template.
|
|
1115
|
+
*
|
|
1116
|
+
* @param attributes - Template attributes (name, category, field_type, etc.).
|
|
1117
|
+
* @param options - Optional request options.
|
|
1118
|
+
* @returns The newly created field template.
|
|
1119
|
+
*
|
|
1120
|
+
* @example
|
|
1121
|
+
* const template = await client.agents.fieldTemplates.create({
|
|
1122
|
+
* name: 'Invoice Amount',
|
|
1123
|
+
* category: 'finance',
|
|
1124
|
+
* field_type: 'currency',
|
|
1125
|
+
* });
|
|
1126
|
+
*/
|
|
1127
|
+
create: (attributes: CreateFieldTemplateAttributes, options?: RequestOptions) => Promise<FieldTemplate>;
|
|
1128
|
+
/**
|
|
1129
|
+
* Deletes a field template by ID.
|
|
1130
|
+
*
|
|
1131
|
+
* @param id - The UUID of the field template to delete.
|
|
1132
|
+
* @param options - Optional request options.
|
|
1133
|
+
* @returns True on successful deletion.
|
|
1134
|
+
*
|
|
1135
|
+
* @example
|
|
1136
|
+
* await client.agents.fieldTemplates.delete('ftpl_01...');
|
|
1137
|
+
*/
|
|
1138
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
1139
|
+
};
|
|
1140
|
+
/**
|
|
1141
|
+
* Sub-namespace for managing agent executions.
|
|
1142
|
+
*
|
|
1143
|
+
* Executions represent a running instance of an agent processing input.
|
|
1144
|
+
* Use {@link start} to begin an execution, {@link stream} to receive
|
|
1145
|
+
* real-time token deltas and lifecycle events via SSE, and
|
|
1146
|
+
* {@link approve}/{@link deny} to respond to human-in-the-loop prompts.
|
|
1147
|
+
*
|
|
1148
|
+
* @example
|
|
1149
|
+
* const exec = await client.agents.executions.start('agt_01...', { task: 'Process invoice' });
|
|
1150
|
+
* const stream = await client.agents.executions.stream(exec.id);
|
|
1151
|
+
*/
|
|
1152
|
+
executions: {
|
|
1153
|
+
/**
|
|
1154
|
+
* Starts a new agent execution.
|
|
1155
|
+
*
|
|
1156
|
+
* Creates an execution record, performs credit balance validation,
|
|
1157
|
+
* and enqueues the agent for processing. The returned execution
|
|
1158
|
+
* object includes the execution ID needed for streaming and lifecycle
|
|
1159
|
+
* management.
|
|
1160
|
+
*
|
|
1161
|
+
* @param agentId - The UUID of the agent to execute.
|
|
1162
|
+
* @param input - Input data for the agent (task description, documents, etc.).
|
|
1163
|
+
* @param opts - Additional execution options.
|
|
1164
|
+
* @param opts.workspace_id - The workspace to execute in. **Required** unless
|
|
1165
|
+
* `workspaceId` was set in the `GptClient` constructor config.
|
|
1166
|
+
* @param opts.model_id - Override model for this execution only (e.g., "anthropic/claude-sonnet-4").
|
|
1167
|
+
* Highest priority in the model resolution chain.
|
|
1168
|
+
* @returns The created execution record with status `pending`.
|
|
1169
|
+
*
|
|
1170
|
+
* @example
|
|
1171
|
+
* const exec = await client.agents.executions.start('agt_01...', {
|
|
1172
|
+
* task: 'Extract invoice fields',
|
|
1173
|
+
* document_id: 'doc_01...',
|
|
1174
|
+
* }, { workspace_id: 'ws_abc123' });
|
|
1175
|
+
* console.log(exec.id, exec.status); // 'pending'
|
|
1176
|
+
*
|
|
1177
|
+
* @example
|
|
1178
|
+
* // With model override
|
|
1179
|
+
* const exec = await client.agents.executions.start(
|
|
1180
|
+
* 'agt_01...',
|
|
1181
|
+
* { task: 'Complex reasoning' },
|
|
1182
|
+
* { workspace_id: 'ws_abc123', model_id: 'anthropic/claude-sonnet-4' },
|
|
1183
|
+
* );
|
|
1184
|
+
*/
|
|
1185
|
+
start: (agentId: string, input: Record<string, unknown>, opts?: {
|
|
1186
|
+
workspace_id?: string;
|
|
1187
|
+
model_id?: string;
|
|
1188
|
+
} & RequestOptions) => Promise<Execution>;
|
|
1189
|
+
/**
|
|
1190
|
+
* Estimates the credit cost of an execution before starting it.
|
|
1191
|
+
*
|
|
1192
|
+
* Returns a cost range (min/max) based on the agent's configuration,
|
|
1193
|
+
* expected token usage, and tool call patterns. Useful for showing
|
|
1194
|
+
* users the expected cost before confirming execution.
|
|
1195
|
+
*
|
|
1196
|
+
* @param agentId - The UUID of the agent.
|
|
1197
|
+
* @param input - Input data (same format as {@link start}).
|
|
1198
|
+
* @param opts - Additional options.
|
|
1199
|
+
* @param opts.workspace_id - The workspace to estimate for. Required for `sk_app_` key auth.
|
|
1200
|
+
* @returns Cost estimate with min/max credit ranges.
|
|
1201
|
+
*
|
|
1202
|
+
* @example
|
|
1203
|
+
* const estimate = await client.agents.executions.estimate('agt_01...', {
|
|
1204
|
+
* task: 'Process batch',
|
|
1205
|
+
* }, { workspace_id: 'ws_abc123' });
|
|
1206
|
+
* console.log(`Estimated cost: ${estimate.min_credits} - ${estimate.max_credits}`);
|
|
1207
|
+
*/
|
|
1208
|
+
estimate: (agentId: string, input: Record<string, unknown>, opts?: {
|
|
1209
|
+
workspace_id?: string;
|
|
1210
|
+
} & RequestOptions) => Promise<ExecutionEstimateResponse>;
|
|
1211
|
+
/**
|
|
1212
|
+
* Fetches a single execution by ID.
|
|
1213
|
+
*
|
|
1214
|
+
* Returns the full execution record including status, result,
|
|
1215
|
+
* token usage, and credit charges.
|
|
1216
|
+
*
|
|
1217
|
+
* @param id - The UUID of the execution.
|
|
1218
|
+
* @param options - Optional request options.
|
|
1219
|
+
* @returns The execution record.
|
|
1220
|
+
*
|
|
1221
|
+
* @example
|
|
1222
|
+
* const exec = await client.agents.executions.get('exec_01...');
|
|
1223
|
+
* console.log(exec.status, exec.total_tokens);
|
|
1224
|
+
*/
|
|
1225
|
+
get: (id: string, options?: RequestOptions) => Promise<Execution>;
|
|
1226
|
+
/**
|
|
1227
|
+
* Lists executions for the current user.
|
|
1228
|
+
*
|
|
1229
|
+
* Returns only executions triggered by the authenticated user,
|
|
1230
|
+
* ordered by creation time descending.
|
|
1231
|
+
*
|
|
1232
|
+
* @param opts - Optional filtering and request options.
|
|
1233
|
+
* @param opts.workspace_id - Filter to a specific workspace. Required for `sk_app_` key auth.
|
|
1234
|
+
* @returns Array of execution records.
|
|
1235
|
+
*
|
|
1236
|
+
* @example
|
|
1237
|
+
* const executions = await client.agents.executions.list({ workspace_id: 'ws_abc123' });
|
|
1238
|
+
*/
|
|
1239
|
+
list: (opts?: {
|
|
1240
|
+
workspace_id?: string;
|
|
1241
|
+
} & RequestOptions) => Promise<Execution[]>;
|
|
1242
|
+
/**
|
|
1243
|
+
* Opens an SSE stream for real-time execution events.
|
|
1244
|
+
*
|
|
1245
|
+
* Yields typed {@link ExecutionEvent} objects including token deltas,
|
|
1246
|
+
* tool calls, iteration completions, approval requests, and
|
|
1247
|
+
* terminal events (done/error). The stream closes automatically
|
|
1248
|
+
* when the execution completes or fails.
|
|
1249
|
+
*
|
|
1250
|
+
* @param id - The UUID of the execution to stream.
|
|
1251
|
+
* @param options - Optional request and stream options (signal, timeout, maxChunks).
|
|
1252
|
+
* @returns An async iterator of ExecutionEvent objects.
|
|
1253
|
+
*
|
|
1254
|
+
* @example
|
|
1255
|
+
* const stream = await client.agents.executions.stream('exec_01...');
|
|
1256
|
+
* for await (const event of stream) {
|
|
1257
|
+
* if (event.type === 'token_delta') process.stdout.write(event.data.content);
|
|
1258
|
+
* if (event.type === 'done') console.log('Complete');
|
|
1259
|
+
* }
|
|
1260
|
+
*/
|
|
1261
|
+
stream: (id: string, options?: RequestOptions & StreamOptions) => Promise<AsyncIterableIterator<ExecutionEvent>>;
|
|
1262
|
+
/**
|
|
1263
|
+
* Approves a pending human-in-the-loop tool call.
|
|
1264
|
+
*
|
|
1265
|
+
* When an execution encounters a sensitive or external tool that
|
|
1266
|
+
* requires approval, it pauses and emits an `approval_required` event.
|
|
1267
|
+
* Call this method to approve the tool call and resume execution.
|
|
1268
|
+
*
|
|
1269
|
+
* @param id - The UUID of the execution with a pending approval.
|
|
1270
|
+
* @param options - Optional request options.
|
|
1271
|
+
* @returns The updated execution record.
|
|
1272
|
+
*
|
|
1273
|
+
* @example
|
|
1274
|
+
* await client.agents.executions.approve('exec_01...');
|
|
1275
|
+
*/
|
|
1276
|
+
approve: (id: string, approvedData?: Record<string, unknown>, options?: RequestOptions) => Promise<Execution>;
|
|
1277
|
+
/**
|
|
1278
|
+
* Denies a pending human-in-the-loop tool call.
|
|
1279
|
+
*
|
|
1280
|
+
* The execution will record the denial and continue without executing
|
|
1281
|
+
* the tool. The LLM receives the denial reason and can adjust its
|
|
1282
|
+
* approach accordingly.
|
|
1283
|
+
*
|
|
1284
|
+
* @param id - The UUID of the execution.
|
|
1285
|
+
* @param reason - Human-readable reason for denying the tool call.
|
|
1286
|
+
* @param options - Optional request options.
|
|
1287
|
+
* @returns The updated execution record.
|
|
1288
|
+
*
|
|
1289
|
+
* @example
|
|
1290
|
+
* await client.agents.executions.deny('exec_01...', 'Not authorized to send emails');
|
|
1291
|
+
*/
|
|
1292
|
+
deny: (id: string, reason: string, options?: RequestOptions) => Promise<Execution>;
|
|
1293
|
+
/**
|
|
1294
|
+
* Cancels a running or paused execution.
|
|
1295
|
+
*
|
|
1296
|
+
* The execution transitions to `cancelled` status. Any in-progress
|
|
1297
|
+
* tool calls are abandoned. Credits charged up to the cancellation
|
|
1298
|
+
* point are not refunded.
|
|
1299
|
+
*
|
|
1300
|
+
* @param id - The UUID of the execution to cancel.
|
|
1301
|
+
* @param options - Optional request options.
|
|
1302
|
+
* @returns The updated execution record with `cancelled` status.
|
|
1303
|
+
*
|
|
1304
|
+
* @example
|
|
1305
|
+
* await client.agents.executions.cancel('exec_01...');
|
|
1306
|
+
*/
|
|
1307
|
+
cancel: (id: string, options?: RequestOptions) => Promise<Execution>;
|
|
1308
|
+
/**
|
|
1309
|
+
* Lists child executions of a delegation chain.
|
|
1310
|
+
*
|
|
1311
|
+
* When an agent delegates sub-tasks to other agents, each delegation
|
|
1312
|
+
* creates a child execution. This method returns all direct children.
|
|
1313
|
+
*
|
|
1314
|
+
* @param id - The UUID of the parent execution.
|
|
1315
|
+
* @param options - Optional request options.
|
|
1316
|
+
* @returns Array of child execution records.
|
|
1317
|
+
*
|
|
1318
|
+
* @example
|
|
1319
|
+
* const children = await client.agents.executions.children('exec_01...');
|
|
1320
|
+
*/
|
|
1321
|
+
children: (id: string, options?: RequestOptions) => Promise<Execution[]>;
|
|
1322
|
+
/**
|
|
1323
|
+
* Retrieves the full execution tree (depth-first).
|
|
1324
|
+
*
|
|
1325
|
+
* Returns a hierarchical view of the execution and all its descendants
|
|
1326
|
+
* in the delegation chain.
|
|
1327
|
+
*
|
|
1328
|
+
* @param id - The UUID of the root execution.
|
|
1329
|
+
* @param options - Optional request options.
|
|
1330
|
+
* @returns Execution tree structure.
|
|
1331
|
+
*
|
|
1332
|
+
* @example
|
|
1333
|
+
* const tree = await client.agents.executions.tree('exec_01...');
|
|
1334
|
+
*/
|
|
1335
|
+
tree: (id: string, options?: RequestOptions) => Promise<ExecutionTreeResponse>;
|
|
1336
|
+
};
|
|
1337
|
+
/**
|
|
1338
|
+
* Read-only access to agent deployments for the current application.
|
|
1339
|
+
* Create/update/delete operations are available via the admin SDK.
|
|
1340
|
+
*/
|
|
1341
|
+
deployments: {
|
|
1342
|
+
/**
|
|
1343
|
+
* Lists all agent deployments for the current application.
|
|
1344
|
+
*
|
|
1345
|
+
* @param options - Optional request options (pagination, filters).
|
|
1346
|
+
* @returns A paginated list of agent deployments.
|
|
1347
|
+
*
|
|
1348
|
+
* @example
|
|
1349
|
+
* const deployments = await client.agents.deployments.list();
|
|
1350
|
+
*/
|
|
1351
|
+
list: (options?: RequestOptions) => Promise<AgentDeployment[]>;
|
|
1352
|
+
/**
|
|
1353
|
+
* Retrieves a single agent deployment by ID.
|
|
1354
|
+
*
|
|
1355
|
+
* @param id - The UUID of the deployment.
|
|
1356
|
+
* @param options - Optional request options.
|
|
1357
|
+
* @returns The agent deployment.
|
|
1358
|
+
*
|
|
1359
|
+
* @example
|
|
1360
|
+
* const deployment = await client.agents.deployments.get('dep_01...');
|
|
1361
|
+
*/
|
|
1362
|
+
get: (id: string, options?: RequestOptions) => Promise<AgentDeployment>;
|
|
1363
|
+
};
|
|
1364
|
+
/**
|
|
1365
|
+
* Workspace-level agent configuration overrides.
|
|
1366
|
+
* End users can read and update overrides; create/delete via admin SDK.
|
|
1367
|
+
*/
|
|
1368
|
+
workspaceConfigs: {
|
|
1369
|
+
/**
|
|
1370
|
+
* Lists all workspace agent configs.
|
|
1371
|
+
*
|
|
1372
|
+
* @param options - Optional request options (pagination, filters).
|
|
1373
|
+
* @returns A paginated list of workspace agent configs.
|
|
1374
|
+
*
|
|
1375
|
+
* @example
|
|
1376
|
+
* const configs = await client.agents.workspaceConfigs.list();
|
|
1377
|
+
*/
|
|
1378
|
+
list: (options?: RequestOptions) => Promise<WorkspaceAgentConfig[]>;
|
|
1379
|
+
/**
|
|
1380
|
+
* Retrieves a single workspace agent config by ID.
|
|
1381
|
+
*
|
|
1382
|
+
* @param id - The UUID of the config.
|
|
1383
|
+
* @param options - Optional request options.
|
|
1384
|
+
* @returns The workspace agent config.
|
|
1385
|
+
*
|
|
1386
|
+
* @example
|
|
1387
|
+
* const config = await client.agents.workspaceConfigs.get('wac_01...');
|
|
1388
|
+
*/
|
|
1389
|
+
get: (id: string, options?: RequestOptions) => Promise<WorkspaceAgentConfig>;
|
|
1390
|
+
/**
|
|
1391
|
+
* Updates a workspace agent config's overrides.
|
|
1392
|
+
*
|
|
1393
|
+
* @param id - The UUID of the config.
|
|
1394
|
+
* @param attributes - Attributes to update (e.g. overrides).
|
|
1395
|
+
* @param options - Optional request options.
|
|
1396
|
+
* @returns The updated workspace agent config.
|
|
1397
|
+
*
|
|
1398
|
+
* @example
|
|
1399
|
+
* await client.agents.workspaceConfigs.update('wac_01...', {
|
|
1400
|
+
* overrides: { prompt_template: 'Custom prompt...' },
|
|
1401
|
+
* });
|
|
1402
|
+
*/
|
|
1403
|
+
update: (id: string, attributes: Record<string, unknown>, options?: RequestOptions) => Promise<WorkspaceAgentConfig>;
|
|
1404
|
+
};
|
|
1405
|
+
};
|
|
1406
|
+
//# sourceMappingURL=agents.d.ts.map
|