@runtypelabs/sdk 1.7.2 → 1.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/index.cjs +7026 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +5147 -0
  4. package/dist/index.d.ts +5146 -27
  5. package/dist/index.js +6955 -77
  6. package/dist/index.js.map +1 -1
  7. package/package.json +14 -7
  8. package/dist/batch-builder.d.ts +0 -106
  9. package/dist/batch-builder.d.ts.map +0 -1
  10. package/dist/batch-builder.js +0 -124
  11. package/dist/batch-builder.js.map +0 -1
  12. package/dist/batches-namespace.d.ts +0 -132
  13. package/dist/batches-namespace.d.ts.map +0 -1
  14. package/dist/batches-namespace.js +0 -128
  15. package/dist/batches-namespace.js.map +0 -1
  16. package/dist/case-types.d.ts +0 -42
  17. package/dist/case-types.d.ts.map +0 -1
  18. package/dist/case-types.js +0 -16
  19. package/dist/case-types.js.map +0 -1
  20. package/dist/client-token-types.d.ts +0 -143
  21. package/dist/client-token-types.d.ts.map +0 -1
  22. package/dist/client-token-types.js +0 -11
  23. package/dist/client-token-types.js.map +0 -1
  24. package/dist/client.d.ts +0 -135
  25. package/dist/client.d.ts.map +0 -1
  26. package/dist/client.js +0 -522
  27. package/dist/client.js.map +0 -1
  28. package/dist/endpoints.d.ts +0 -1353
  29. package/dist/endpoints.d.ts.map +0 -1
  30. package/dist/endpoints.js +0 -2936
  31. package/dist/endpoints.js.map +0 -1
  32. package/dist/error-handling-types.d.ts +0 -71
  33. package/dist/error-handling-types.d.ts.map +0 -1
  34. package/dist/error-handling-types.js +0 -12
  35. package/dist/error-handling-types.js.map +0 -1
  36. package/dist/eval-builder.d.ts +0 -216
  37. package/dist/eval-builder.d.ts.map +0 -1
  38. package/dist/eval-builder.js +0 -225
  39. package/dist/eval-builder.js.map +0 -1
  40. package/dist/evals-namespace.d.ts +0 -205
  41. package/dist/evals-namespace.d.ts.map +0 -1
  42. package/dist/evals-namespace.js +0 -208
  43. package/dist/evals-namespace.js.map +0 -1
  44. package/dist/flow-builder.d.ts +0 -717
  45. package/dist/flow-builder.d.ts.map +0 -1
  46. package/dist/flow-builder.js +0 -592
  47. package/dist/flow-builder.js.map +0 -1
  48. package/dist/flow-result.d.ts +0 -117
  49. package/dist/flow-result.d.ts.map +0 -1
  50. package/dist/flow-result.js +0 -175
  51. package/dist/flow-result.js.map +0 -1
  52. package/dist/flows-namespace.d.ts +0 -442
  53. package/dist/flows-namespace.d.ts.map +0 -1
  54. package/dist/flows-namespace.js +0 -686
  55. package/dist/flows-namespace.js.map +0 -1
  56. package/dist/generated-tool-gate.d.ts +0 -75
  57. package/dist/generated-tool-gate.d.ts.map +0 -1
  58. package/dist/generated-tool-gate.js +0 -314
  59. package/dist/generated-tool-gate.js.map +0 -1
  60. package/dist/index.d.ts.map +0 -1
  61. package/dist/prompts-namespace.d.ts +0 -237
  62. package/dist/prompts-namespace.d.ts.map +0 -1
  63. package/dist/prompts-namespace.js +0 -222
  64. package/dist/prompts-namespace.js.map +0 -1
  65. package/dist/runtype.d.ts +0 -232
  66. package/dist/runtype.d.ts.map +0 -1
  67. package/dist/runtype.js +0 -367
  68. package/dist/runtype.js.map +0 -1
  69. package/dist/stream-utils.d.ts +0 -58
  70. package/dist/stream-utils.d.ts.map +0 -1
  71. package/dist/stream-utils.js +0 -373
  72. package/dist/stream-utils.js.map +0 -1
  73. package/dist/transform.d.ts +0 -30
  74. package/dist/transform.d.ts.map +0 -1
  75. package/dist/transform.js +0 -196
  76. package/dist/transform.js.map +0 -1
  77. package/dist/types.d.ts +0 -717
  78. package/dist/types.d.ts.map +0 -1
  79. package/dist/types.js +0 -7
  80. package/dist/types.js.map +0 -1
@@ -1,237 +0,0 @@
1
- /**
2
- * PromptsNamespace - Static namespace for prompt operations
3
- *
4
- * Provides CRUD operations for prompts and execution methods
5
- * with streaming and non-streaming options.
6
- */
7
- import type { RuntypeClient } from './runtype';
8
- import type { ReasoningConfig } from './types';
9
- import { FlowResult } from './flow-result';
10
- import type { StreamCallbacks } from './flow-builder';
11
- export interface CreatePromptData {
12
- /** Prompt name */
13
- name: string;
14
- /** Prompt description */
15
- description?: string;
16
- /** Model to use */
17
- model: string;
18
- /** System prompt text */
19
- systemPrompt?: string;
20
- /** User prompt template */
21
- userPrompt: string;
22
- /** Response format */
23
- responseFormat?: 'text' | 'json' | 'markdown';
24
- /** Temperature */
25
- temperature?: number;
26
- /** Max tokens */
27
- maxTokens?: number;
28
- /** Enable reasoning/extended thinking. Use `true` for defaults or `ReasoningConfig` for fine-grained control */
29
- reasoning?: boolean | ReasoningConfig;
30
- /** Flow IDs to attach this prompt to */
31
- flowIds?: string[];
32
- }
33
- export interface UpdatePromptData {
34
- /** Prompt name */
35
- name?: string;
36
- /** Prompt description */
37
- description?: string;
38
- /** Model to use */
39
- model?: string;
40
- /** System prompt text */
41
- systemPrompt?: string;
42
- /** User prompt template */
43
- userPrompt?: string;
44
- /** Response format */
45
- responseFormat?: 'text' | 'json' | 'markdown';
46
- /** Temperature */
47
- temperature?: number;
48
- /** Max tokens */
49
- maxTokens?: number;
50
- /** Enable reasoning/extended thinking. Use `true` for defaults or `ReasoningConfig` for fine-grained control */
51
- reasoning?: boolean | ReasoningConfig;
52
- }
53
- export interface Prompt {
54
- id: string;
55
- userId: string;
56
- name: string;
57
- description?: string;
58
- model: string;
59
- systemPrompt?: string;
60
- userPrompt: string;
61
- responseFormat?: string;
62
- temperature?: number;
63
- maxTokens?: number;
64
- reasoning?: boolean | ReasoningConfig;
65
- createdAt: string;
66
- updatedAt: string;
67
- }
68
- export interface PromptRunOptions {
69
- /** Record ID to run the prompt against */
70
- recordId?: string;
71
- /** Record data (alternative to recordId) */
72
- record?: {
73
- name?: string;
74
- type?: string;
75
- metadata?: Record<string, any>;
76
- };
77
- /** Model override */
78
- modelOverride?: string;
79
- /** Temperature override */
80
- temperature?: number;
81
- /** Max tokens override */
82
- maxTokens?: number;
83
- /** Store the result */
84
- storeResult?: boolean;
85
- }
86
- export interface PromptListParams {
87
- /** Filter by flow ID */
88
- flowId?: string;
89
- /** Search by name */
90
- search?: string;
91
- /** Pagination limit */
92
- limit?: number;
93
- /** Pagination offset */
94
- offset?: number;
95
- }
96
- /**
97
- * PromptRunner - Builder returned by Runtype.prompts.run()
98
- *
99
- * Provides terminal methods for executing prompts:
100
- * - .stream() - Execute and stream results in real-time
101
- * - .result() - Execute and wait for complete result
102
- */
103
- export declare class PromptRunner {
104
- private getClient;
105
- private promptId;
106
- private options;
107
- constructor(getClient: () => RuntypeClient, promptId: string, options: PromptRunOptions);
108
- /**
109
- * Execute the prompt with streaming response
110
- *
111
- * Streams the prompt response as it's generated.
112
- *
113
- * @example
114
- * ```typescript
115
- * const result = await Runtype.prompts.run('prompt_123', {
116
- * recordId: 'rec_456'
117
- * }).stream()
118
- *
119
- * // Process with callbacks
120
- * await result.stream({
121
- * onStepChunk: (chunk) => process.stdout.write(chunk),
122
- * onFlowComplete: () => console.log('Done!'),
123
- * })
124
- * ```
125
- */
126
- stream(callbacks?: StreamCallbacks): Promise<FlowResult>;
127
- /**
128
- * Execute the prompt and wait for complete result
129
- *
130
- * Waits for the entire response before returning.
131
- *
132
- * @example
133
- * ```typescript
134
- * const result = await Runtype.prompts.run('prompt_123', {
135
- * recordId: 'rec_456'
136
- * }).result()
137
- *
138
- * const output = await result.getResult('prompt')
139
- * console.log(output)
140
- * ```
141
- */
142
- result(): Promise<FlowResult>;
143
- /**
144
- * Build the run payload
145
- */
146
- private buildPayload;
147
- }
148
- export declare class PromptsNamespace {
149
- private getClient;
150
- constructor(getClient: () => RuntypeClient);
151
- /**
152
- * Run a prompt
153
- *
154
- * Returns a PromptRunner with terminal methods:
155
- * - .stream() - Execute and stream results
156
- * - .result() - Execute and wait for complete result
157
- *
158
- * @example
159
- * ```typescript
160
- * // Stream the response
161
- * const result = await Runtype.prompts.run('prompt_123', {
162
- * recordId: 'rec_456'
163
- * }).stream()
164
- *
165
- * // Get complete result
166
- * const result = await Runtype.prompts.run('prompt_123', {
167
- * record: { name: 'Test', metadata: { input: 'Hello' } }
168
- * }).result()
169
- * ```
170
- */
171
- run(promptId: string, options?: PromptRunOptions): PromptRunner;
172
- /**
173
- * Create a new prompt
174
- *
175
- * @example
176
- * ```typescript
177
- * const prompt = await Runtype.prompts.create({
178
- * name: 'Summarizer',
179
- * model: 'gpt-4o',
180
- * userPrompt: 'Summarize the following: {{content}}',
181
- * systemPrompt: 'You are a helpful assistant.',
182
- * })
183
- * ```
184
- */
185
- create(data: CreatePromptData): Promise<Prompt>;
186
- /**
187
- * List prompts
188
- *
189
- * @example
190
- * ```typescript
191
- * // List all prompts
192
- * const prompts = await Runtype.prompts.list()
193
- *
194
- * // Filter by flow
195
- * const flowPrompts = await Runtype.prompts.list({ flowId: 'flow_123' })
196
- *
197
- * // Search by name
198
- * const results = await Runtype.prompts.list({ search: 'summarize' })
199
- * ```
200
- */
201
- list(params?: PromptListParams): Promise<{
202
- data: Prompt[];
203
- total: number;
204
- }>;
205
- /**
206
- * Get a prompt by ID
207
- *
208
- * @example
209
- * ```typescript
210
- * const prompt = await Runtype.prompts.get('prompt_123')
211
- * console.log(prompt.name, prompt.userPrompt)
212
- * ```
213
- */
214
- get(promptId: string): Promise<Prompt>;
215
- /**
216
- * Update a prompt
217
- *
218
- * @example
219
- * ```typescript
220
- * const updated = await Runtype.prompts.update('prompt_123', {
221
- * userPrompt: 'Updated prompt template: {{content}}',
222
- * temperature: 0.7,
223
- * })
224
- * ```
225
- */
226
- update(promptId: string, data: UpdatePromptData): Promise<Prompt>;
227
- /**
228
- * Delete a prompt
229
- *
230
- * @example
231
- * ```typescript
232
- * await Runtype.prompts.delete('prompt_123')
233
- * ```
234
- */
235
- delete(promptId: string): Promise<void>;
236
- }
237
- //# sourceMappingURL=prompts-namespace.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prompts-namespace.d.ts","sourceRoot":"","sources":["../src/prompts-namespace.ts"],"names":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";
2
- /**
3
- * PromptsNamespace - Static namespace for prompt operations
4
- *
5
- * Provides CRUD operations for prompts and execution methods
6
- * with streaming and non-streaming options.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.PromptsNamespace = exports.PromptRunner = void 0;
10
- const flow_result_1 = require("./flow-result");
11
- // ============================================================================
12
- // PromptRunner
13
- // ============================================================================
14
- /**
15
- * PromptRunner - Builder returned by Runtype.prompts.run()
16
- *
17
- * Provides terminal methods for executing prompts:
18
- * - .stream() - Execute and stream results in real-time
19
- * - .result() - Execute and wait for complete result
20
- */
21
- class PromptRunner {
22
- constructor(getClient, promptId, options) {
23
- this.getClient = getClient;
24
- this.promptId = promptId;
25
- this.options = options;
26
- }
27
- /**
28
- * Execute the prompt with streaming response
29
- *
30
- * Streams the prompt response as it's generated.
31
- *
32
- * @example
33
- * ```typescript
34
- * const result = await Runtype.prompts.run('prompt_123', {
35
- * recordId: 'rec_456'
36
- * }).stream()
37
- *
38
- * // Process with callbacks
39
- * await result.stream({
40
- * onStepChunk: (chunk) => process.stdout.write(chunk),
41
- * onFlowComplete: () => console.log('Done!'),
42
- * })
43
- * ```
44
- */
45
- async stream(callbacks) {
46
- const client = this.getClient();
47
- const payload = this.buildPayload();
48
- payload.stream = true;
49
- const response = await client.requestStream(`/prompts/${this.promptId}/run`, {
50
- method: 'POST',
51
- body: JSON.stringify(payload),
52
- });
53
- const result = new flow_result_1.FlowResult(response);
54
- if (callbacks) {
55
- await result.stream(callbacks);
56
- }
57
- return result;
58
- }
59
- /**
60
- * Execute the prompt and wait for complete result
61
- *
62
- * Waits for the entire response before returning.
63
- *
64
- * @example
65
- * ```typescript
66
- * const result = await Runtype.prompts.run('prompt_123', {
67
- * recordId: 'rec_456'
68
- * }).result()
69
- *
70
- * const output = await result.getResult('prompt')
71
- * console.log(output)
72
- * ```
73
- */
74
- async result() {
75
- const client = this.getClient();
76
- const payload = this.buildPayload();
77
- payload.stream = true; // Still use streaming internally for FlowResult
78
- const response = await client.requestStream(`/prompts/${this.promptId}/run`, {
79
- method: 'POST',
80
- body: JSON.stringify(payload),
81
- });
82
- const result = new flow_result_1.FlowResult(response);
83
- // Pre-process to cache results
84
- await result.getSummary();
85
- return result;
86
- }
87
- /**
88
- * Build the run payload
89
- */
90
- buildPayload() {
91
- const payload = {};
92
- if (this.options.recordId) {
93
- payload.recordId = this.options.recordId;
94
- }
95
- else if (this.options.record) {
96
- payload.record = this.options.record;
97
- }
98
- if (this.options.modelOverride) {
99
- payload.modelOverride = this.options.modelOverride;
100
- }
101
- if (this.options.temperature !== undefined) {
102
- payload.temperature = this.options.temperature;
103
- }
104
- if (this.options.maxTokens !== undefined) {
105
- payload.maxTokens = this.options.maxTokens;
106
- }
107
- if (this.options.storeResult !== undefined) {
108
- payload.storeResult = this.options.storeResult;
109
- }
110
- return payload;
111
- }
112
- }
113
- exports.PromptRunner = PromptRunner;
114
- // ============================================================================
115
- // PromptsNamespace
116
- // ============================================================================
117
- class PromptsNamespace {
118
- constructor(getClient) {
119
- this.getClient = getClient;
120
- }
121
- /**
122
- * Run a prompt
123
- *
124
- * Returns a PromptRunner with terminal methods:
125
- * - .stream() - Execute and stream results
126
- * - .result() - Execute and wait for complete result
127
- *
128
- * @example
129
- * ```typescript
130
- * // Stream the response
131
- * const result = await Runtype.prompts.run('prompt_123', {
132
- * recordId: 'rec_456'
133
- * }).stream()
134
- *
135
- * // Get complete result
136
- * const result = await Runtype.prompts.run('prompt_123', {
137
- * record: { name: 'Test', metadata: { input: 'Hello' } }
138
- * }).result()
139
- * ```
140
- */
141
- run(promptId, options = {}) {
142
- return new PromptRunner(this.getClient, promptId, options);
143
- }
144
- /**
145
- * Create a new prompt
146
- *
147
- * @example
148
- * ```typescript
149
- * const prompt = await Runtype.prompts.create({
150
- * name: 'Summarizer',
151
- * model: 'gpt-4o',
152
- * userPrompt: 'Summarize the following: {{content}}',
153
- * systemPrompt: 'You are a helpful assistant.',
154
- * })
155
- * ```
156
- */
157
- async create(data) {
158
- const client = this.getClient();
159
- return client.post('/prompts', data);
160
- }
161
- /**
162
- * List prompts
163
- *
164
- * @example
165
- * ```typescript
166
- * // List all prompts
167
- * const prompts = await Runtype.prompts.list()
168
- *
169
- * // Filter by flow
170
- * const flowPrompts = await Runtype.prompts.list({ flowId: 'flow_123' })
171
- *
172
- * // Search by name
173
- * const results = await Runtype.prompts.list({ search: 'summarize' })
174
- * ```
175
- */
176
- async list(params) {
177
- const client = this.getClient();
178
- return client.get('/prompts', params);
179
- }
180
- /**
181
- * Get a prompt by ID
182
- *
183
- * @example
184
- * ```typescript
185
- * const prompt = await Runtype.prompts.get('prompt_123')
186
- * console.log(prompt.name, prompt.userPrompt)
187
- * ```
188
- */
189
- async get(promptId) {
190
- const client = this.getClient();
191
- return client.get(`/prompts/${promptId}`);
192
- }
193
- /**
194
- * Update a prompt
195
- *
196
- * @example
197
- * ```typescript
198
- * const updated = await Runtype.prompts.update('prompt_123', {
199
- * userPrompt: 'Updated prompt template: {{content}}',
200
- * temperature: 0.7,
201
- * })
202
- * ```
203
- */
204
- async update(promptId, data) {
205
- const client = this.getClient();
206
- return client.post(`/prompts/${promptId}`, data);
207
- }
208
- /**
209
- * Delete a prompt
210
- *
211
- * @example
212
- * ```typescript
213
- * await Runtype.prompts.delete('prompt_123')
214
- * ```
215
- */
216
- async delete(promptId) {
217
- const client = this.getClient();
218
- await client.post(`/prompts/${promptId}/delete`);
219
- }
220
- }
221
- exports.PromptsNamespace = PromptsNamespace;
222
- //# sourceMappingURL=prompts-namespace.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prompts-namespace.js","sourceRoot":"","sources":["../src/prompts-namespace.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,+CAA0C;AAiG1C,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E;;;;;;GAMG;AACH,MAAa,YAAY;IACvB,YACU,SAA8B,EAC9B,QAAgB,EAChB,OAAyB;QAFzB,cAAS,GAAT,SAAS,CAAqB;Q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AQ,EAAE,OAAO,CAAC,CAAA;IAC5D,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,MAAM,CAAC,IAAsB;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;QAC/B,OAAO,MAAM,CAAC,IAAI,CAAS,UAAU,EAAE,IAAI,CAAC,CAAA;IAC9C,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,IAAI,CAAC,MAAyB;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;QAC/B,OAAO,MAAM,CAAC,GAAG,CAAoC,UAAU,EAAE,MAAM,CAAC,CAAA;IAC1E,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,GAAG,CAAC,QAAgB;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;QAC/B,OAAO,MAAM,CAAC,GAAG,CAAS,YAAY,QAAQ,EAAE,CAAC,CAAA;IACnD,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,MAAM,CAAC,QAAgB,EAAE,IAAsB;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;QAC/B,OAAO,MAAM,CAAC,IAAI,CAAS,YAAY,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAA;IAC1D,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CAAC,QAAgB;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;QAC/B,MAAM,MAAM,CAAC,IAAI,CAAO,YAAY,QAAQ,SAAS,CAAC,CAAA;IACxD,CAAC;CACF;AA3GD,4CA2GC"}
package/dist/runtype.d.ts DELETED
@@ -1,232 +0,0 @@
1
- /**
2
- * Runtype - The unified SDK client for building and executing flows, batches, evals, and prompts
3
- *
4
- * Provides a fluent API with static namespaces for all product areas.
5
- *
6
- * @example
7
- * ```typescript
8
- * import { Runtype } from '@runtypelabs/sdk'
9
- *
10
- * // Global configuration (once per app)
11
- * Runtype.configure({ apiKey: process.env.RUNTYPE_API_KEY })
12
- *
13
- * // Build and stream a flow
14
- * const stream = await Runtype.flows.upsert({ name: 'My Flow' })
15
- * .withRecord({ name: 'Test', metadata: {} })
16
- * .prompt({ name: 'Analyze', model: 'gpt-4o', userPrompt: '...' })
17
- * .stream()
18
- *
19
- * // Get complete result
20
- * const result = await Runtype.flows.use('flow_123')
21
- * .withRecord({ name: 'Test' })
22
- * .result()
23
- *
24
- * // Schedule a batch
25
- * const batch = await Runtype.batches.schedule({
26
- * flowId: 'flow_123',
27
- * recordType: 'customers',
28
- * })
29
- *
30
- * // Run an eval with streaming
31
- * const evalStream = await Runtype.evals.run({
32
- * flowId: 'flow_123',
33
- * recordType: 'test_data',
34
- * models: [{ stepName: 'Analyze', model: 'gpt-4o' }]
35
- * }).stream()
36
- *
37
- * // Execute a prompt
38
- * const promptResult = await Runtype.prompts.run('prompt_123', {
39
- * recordId: 'rec_456'
40
- * }).result()
41
- * ```
42
- */
43
- import { FlowsNamespace } from './flows-namespace';
44
- import { BatchesNamespace } from './batches-namespace';
45
- import { EvalsNamespace } from './evals-namespace';
46
- import { PromptsNamespace } from './prompts-namespace';
47
- export interface RuntypeConfig {
48
- /** API key for authentication */
49
- apiKey?: string;
50
- /** Base URL for the API (defaults to https://api.runtype.com) */
51
- baseUrl?: string;
52
- /** API version (defaults to 'v1') */
53
- apiVersion?: string;
54
- /** Request timeout in milliseconds (defaults to 30000) */
55
- timeout?: number;
56
- /** Additional headers to include in requests */
57
- headers?: Record<string, string>;
58
- }
59
- /**
60
- * Internal client implementation that handles HTTP requests
61
- */
62
- export declare class RuntypeClient {
63
- private baseUrl;
64
- private apiVersion;
65
- private timeout;
66
- private headers;
67
- constructor(config?: RuntypeConfig);
68
- /**
69
- * Set the API key for authentication
70
- */
71
- setApiKey(apiKey: string): void;
72
- /**
73
- * Generic GET request
74
- */
75
- get<T>(path: string, params?: Record<string, any>): Promise<T>;
76
- /**
77
- * Generic POST request
78
- */
79
- post<T>(path: string, data?: any): Promise<T>;
80
- /**
81
- * Generic request that returns raw Response for streaming
82
- */
83
- requestStream(path: string, options?: RequestInit): Promise<Response>;
84
- /**
85
- * Dispatch flow execution (streaming)
86
- */
87
- dispatch(config: any): Promise<Response>;
88
- /**
89
- * Build full URL with query parameters
90
- */
91
- private buildUrl;
92
- /**
93
- * Make HTTP request with timeout and error handling
94
- */
95
- private makeRequest;
96
- /**
97
- * Make HTTP request that returns raw Response (for streaming)
98
- */
99
- private makeRawRequest;
100
- /**
101
- * Transform response (placeholder for snake_case to camelCase)
102
- */
103
- private transformResponse;
104
- }
105
- /**
106
- * Runtype - Main entry point for the SDK
107
- *
108
- * Use static methods and namespaces to interact with the API.
109
- */
110
- export declare class Runtype {
111
- /**
112
- * Configure the global Runtype client
113
- *
114
- * Call this once at app startup to set the API key and other options.
115
- * All subsequent calls to Runtype.flows, Runtype.batches, etc. will use this config.
116
- *
117
- * @example
118
- * ```typescript
119
- * Runtype.configure({ apiKey: process.env.RUNTYPE_API_KEY })
120
- * ```
121
- */
122
- static configure(config: RuntypeConfig): void;
123
- /**
124
- * Get the global client instance, creating one if needed
125
- */
126
- static getClient(): RuntypeClient;
127
- /**
128
- * Create a new client instance with custom configuration
129
- *
130
- * Use this when you need a client with different settings than the global one.
131
- *
132
- * @example
133
- * ```typescript
134
- * const client = Runtype.createClient({ apiKey: 'different_key' })
135
- * ```
136
- */
137
- static createClient(config?: RuntypeConfig): RuntypeClient;
138
- /**
139
- * Flows namespace - Build and execute flows
140
- *
141
- * @example
142
- * ```typescript
143
- * // Upsert a flow (create or update)
144
- * const result = await Runtype.flows.upsert({ name: 'My Flow' })
145
- * .prompt({ name: 'Analyze', model: 'gpt-4o', userPrompt: '...' })
146
- * .stream()
147
- *
148
- * // Use an existing flow
149
- * const result = await Runtype.flows.use('flow_123')
150
- * .withRecord({ name: 'Test' })
151
- * .result()
152
- *
153
- * // Virtual flow (one-off, not saved)
154
- * const result = await Runtype.flows.virtual({ name: 'Temp Flow' })
155
- * .prompt({ ... })
156
- * .stream()
157
- * ```
158
- */
159
- static get flows(): FlowsNamespace;
160
- /**
161
- * Batches namespace - Schedule and manage batch operations
162
- *
163
- * @example
164
- * ```typescript
165
- * // Schedule a batch
166
- * const batch = await Runtype.batches.schedule({
167
- * flowId: 'flow_123',
168
- * recordType: 'customers',
169
- * })
170
- *
171
- * // Get batch status
172
- * const status = await Runtype.batches.get('batch_456')
173
- *
174
- * // Cancel a batch
175
- * await Runtype.batches.cancel('batch_456')
176
- *
177
- * // List batches
178
- * const batches = await Runtype.batches.list({ status: 'running' })
179
- * ```
180
- */
181
- static get batches(): BatchesNamespace;
182
- /**
183
- * Evals namespace - Run evaluations and compare models
184
- *
185
- * @example
186
- * ```typescript
187
- * // Run an eval with streaming
188
- * const stream = await Runtype.evals.run({
189
- * flowId: 'flow_123',
190
- * recordType: 'test_data',
191
- * models: [{ stepName: 'Analyze', model: 'gpt-4o' }]
192
- * }).stream()
193
- *
194
- * // Submit eval as batch job
195
- * const eval = await Runtype.evals.run({
196
- * flowId: 'flow_123',
197
- * recordType: 'test_data',
198
- * models: [
199
- * [{ stepName: 'Analyze', model: 'gpt-4o' }],
200
- * [{ stepName: 'Analyze', model: 'claude-3-opus' }],
201
- * ]
202
- * }).submit()
203
- * ```
204
- */
205
- static get evals(): EvalsNamespace;
206
- /**
207
- * Prompts namespace - Manage and execute prompts
208
- *
209
- * @example
210
- * ```typescript
211
- * // Execute a prompt with streaming
212
- * const stream = await Runtype.prompts.run('prompt_123', {
213
- * recordId: 'rec_456'
214
- * }).stream()
215
- *
216
- * // Get complete result
217
- * const result = await Runtype.prompts.run('prompt_123', {
218
- * recordId: 'rec_456'
219
- * }).result()
220
- *
221
- * // CRUD operations
222
- * const prompts = await Runtype.prompts.list()
223
- * const prompt = await Runtype.prompts.get('prompt_123')
224
- * const newPrompt = await Runtype.prompts.create({ ... })
225
- * await Runtype.prompts.update('prompt_123', { ... })
226
- * await Runtype.prompts.delete('prompt_123')
227
- * ```
228
- */
229
- static get prompts(): PromptsNamespace;
230
- }
231
- export default Runtype;
232
- //# sourceMappingURL=runtype.d.ts.map