@eigenpal/sdk 0.12.2 → 0.13.1
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/CHANGELOG.md +17 -0
- package/package.json +2 -2
- package/src/client.ts +8 -0
- package/src/generated/client/client.gen.ts +1 -4
- package/src/generated/client/types.gen.ts +3 -2
- package/src/generated/client/utils.gen.ts +6 -8
- package/src/generated/core/params.gen.ts +4 -4
- package/src/generated/index.ts +2 -2
- package/src/generated/sdk.gen.ts +144 -3
- package/src/generated/types.gen.ts +834 -7
- package/src/index.ts +8 -0
- package/src/resources/automations.ts +58 -2
- package/src/resources/files.ts +29 -15
- package/src/resources/models.ts +30 -0
- package/src/resources/templates.ts +153 -0
- package/src/telemetry.ts +1 -1
package/src/index.ts
CHANGED
|
@@ -54,8 +54,14 @@ export type {
|
|
|
54
54
|
AutomationTriggerState,
|
|
55
55
|
AutomationTriggersResponse,
|
|
56
56
|
AutomationVersion,
|
|
57
|
+
CreateAutomationVersionRequest,
|
|
57
58
|
ExecutionStatus,
|
|
58
59
|
File,
|
|
60
|
+
ListModelsResponse,
|
|
61
|
+
PublicModel,
|
|
62
|
+
PublicModelCost,
|
|
63
|
+
PublicModelLimits,
|
|
64
|
+
RestoreAutomationVersionRequest,
|
|
59
65
|
Run,
|
|
60
66
|
RunAccepted,
|
|
61
67
|
RunArtifact,
|
|
@@ -79,4 +85,6 @@ export type {
|
|
|
79
85
|
RunsReviewsGetResponse,
|
|
80
86
|
RunsReviewsUpdateResponse,
|
|
81
87
|
RunsTraceGetResponse,
|
|
88
|
+
Template,
|
|
89
|
+
TemplateRevision,
|
|
82
90
|
} from './generated/types.gen';
|
|
@@ -23,9 +23,15 @@ import {
|
|
|
23
23
|
automationsReviewsHealth,
|
|
24
24
|
automationsSync,
|
|
25
25
|
automationsTriggersGet,
|
|
26
|
+
automationsVersionsCreate,
|
|
26
27
|
automationsVersionsList,
|
|
28
|
+
automationsVersionsPromote,
|
|
29
|
+
automationsVersionsRestore,
|
|
27
30
|
} from '../generated/sdk.gen';
|
|
28
|
-
import type {
|
|
31
|
+
import type {
|
|
32
|
+
AutomationsReviewsHealthData,
|
|
33
|
+
CreateAutomationVersionRequest,
|
|
34
|
+
} from '../generated/types.gen';
|
|
29
35
|
|
|
30
36
|
type Dispatch = <T>(call: () => Promise<OperationResult<T>>) => Promise<T>;
|
|
31
37
|
type SignalOptions = { signal?: AbortSignal };
|
|
@@ -74,6 +80,51 @@ export class AutomationsResource {
|
|
|
74
80
|
);
|
|
75
81
|
}
|
|
76
82
|
|
|
83
|
+
async createVersion(
|
|
84
|
+
id: string,
|
|
85
|
+
body: CreateAutomationVersionRequest,
|
|
86
|
+
options: SignalOptions = {}
|
|
87
|
+
): Promise<AnyResponse> {
|
|
88
|
+
return this.dispatch(() =>
|
|
89
|
+
automationsVersionsCreate({
|
|
90
|
+
client: this.client,
|
|
91
|
+
path: { id },
|
|
92
|
+
body,
|
|
93
|
+
signal: options.signal,
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async restoreVersion(
|
|
99
|
+
id: string,
|
|
100
|
+
versionId: string,
|
|
101
|
+
body: { message?: string } = {},
|
|
102
|
+
options: SignalOptions = {}
|
|
103
|
+
): Promise<AnyResponse> {
|
|
104
|
+
return this.dispatch(() =>
|
|
105
|
+
automationsVersionsRestore({
|
|
106
|
+
client: this.client,
|
|
107
|
+
path: { id, versionId },
|
|
108
|
+
body,
|
|
109
|
+
signal: options.signal,
|
|
110
|
+
})
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async promoteVersion(
|
|
115
|
+
id: string,
|
|
116
|
+
versionId: string,
|
|
117
|
+
options: SignalOptions = {}
|
|
118
|
+
): Promise<AnyResponse> {
|
|
119
|
+
return this.dispatch(() =>
|
|
120
|
+
automationsVersionsPromote({
|
|
121
|
+
client: this.client,
|
|
122
|
+
path: { id, versionId },
|
|
123
|
+
signal: options.signal,
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
77
128
|
async triggers(id: string, options: SignalOptions = {}): Promise<AnyResponse> {
|
|
78
129
|
return this.dispatch(() =>
|
|
79
130
|
automationsTriggersGet({ client: this.client, path: { id }, signal: options.signal })
|
|
@@ -163,7 +214,12 @@ export class AutomationExamplesResource {
|
|
|
163
214
|
|
|
164
215
|
async list(
|
|
165
216
|
automationId: string,
|
|
166
|
-
options: {
|
|
217
|
+
options: {
|
|
218
|
+
limit?: number;
|
|
219
|
+
offset?: number;
|
|
220
|
+
include?: 'full' | 'metadata';
|
|
221
|
+
signal?: AbortSignal;
|
|
222
|
+
} = {}
|
|
167
223
|
): Promise<AnyResponse> {
|
|
168
224
|
const { signal, ...query } = options;
|
|
169
225
|
return this.dispatch(() =>
|
package/src/resources/files.ts
CHANGED
|
@@ -32,6 +32,12 @@ type UploadOptions = SignalOptions & {
|
|
|
32
32
|
onProgress?: (uploadedBytes: number, totalBytes: number) => void;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
const UPLOAD_ABORT_CLEANUP_TIMEOUT_MS = 10_000;
|
|
36
|
+
|
|
37
|
+
function uploadAbortCleanupSignal(): AbortSignal {
|
|
38
|
+
return AbortSignal.timeout(UPLOAD_ABORT_CLEANUP_TIMEOUT_MS);
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
export type CreateUploadInput = {
|
|
36
42
|
filename: string;
|
|
37
43
|
contentType: string;
|
|
@@ -72,22 +78,30 @@ export class FilesResource {
|
|
|
72
78
|
);
|
|
73
79
|
|
|
74
80
|
if (negotiation.transport === 'presigned-put') {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
try {
|
|
82
|
+
const response = await fetch(negotiation.url, {
|
|
83
|
+
method: 'PUT',
|
|
84
|
+
headers: Object.fromEntries(
|
|
85
|
+
Object.entries((negotiation.headers ?? {}) as Record<string, string>).filter(
|
|
86
|
+
([name]) => name.toLowerCase() !== 'content-length'
|
|
87
|
+
)
|
|
88
|
+
),
|
|
89
|
+
body: file,
|
|
90
|
+
signal: options.signal,
|
|
91
|
+
});
|
|
92
|
+
if (!response.ok) {
|
|
93
|
+
throw new Error(`Storage upload failed (${response.status}); retry the upload`);
|
|
94
|
+
}
|
|
95
|
+
options.onProgress?.(file.size, file.size);
|
|
96
|
+
return await this.completeUpload(negotiation.uploadId, options);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
// Caller cancellation and response-loss also reach here. Cleanup must
|
|
99
|
+
// not inherit the failed/aborted signal, and must remain bounded.
|
|
100
|
+
await this.abortUpload(negotiation.uploadId, {
|
|
101
|
+
signal: uploadAbortCleanupSignal(),
|
|
102
|
+
}).catch(() => undefined);
|
|
103
|
+
throw error;
|
|
88
104
|
}
|
|
89
|
-
options.onProgress?.(file.size, file.size);
|
|
90
|
-
return this.completeUpload(negotiation.uploadId, options);
|
|
91
105
|
}
|
|
92
106
|
|
|
93
107
|
const form = new FormData();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { OperationResult } from '../client';
|
|
2
|
+
import type { Client } from '../generated/client';
|
|
3
|
+
import { modelsList } from '../generated/sdk.gen';
|
|
4
|
+
import type { ListModelsResponse } from '../generated/types.gen';
|
|
5
|
+
|
|
6
|
+
type Dispatch = <T>(call: () => Promise<OperationResult<T>>) => Promise<T>;
|
|
7
|
+
type SignalOptions = { signal?: AbortSignal };
|
|
8
|
+
|
|
9
|
+
export class ModelsResource {
|
|
10
|
+
constructor(
|
|
11
|
+
private readonly client: Client,
|
|
12
|
+
private readonly dispatch: Dispatch
|
|
13
|
+
) {}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* List text, vision, and OCR models configured for this tenant environment.
|
|
17
|
+
* Catalog inventory only — not a live provider health probe.
|
|
18
|
+
*/
|
|
19
|
+
async list(
|
|
20
|
+
options: SignalOptions & { capability?: 'text' | 'vision' | 'ocr' } = {}
|
|
21
|
+
): Promise<ListModelsResponse> {
|
|
22
|
+
return this.dispatch(() =>
|
|
23
|
+
modelsList({
|
|
24
|
+
client: this.client,
|
|
25
|
+
query: { capability: options.capability },
|
|
26
|
+
signal: options.signal,
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { OperationResult, RequestDispatchOptions } from '../client';
|
|
2
|
+
import type { Client } from '../generated/client';
|
|
3
|
+
import {
|
|
4
|
+
templatesContentGet,
|
|
5
|
+
templatesDelete,
|
|
6
|
+
templatesGet,
|
|
7
|
+
templatesList,
|
|
8
|
+
} from '../generated/sdk.gen';
|
|
9
|
+
import type { ListTemplatesResponse, Template } from '../generated/types.gen';
|
|
10
|
+
import type { FilesResource } from './files';
|
|
11
|
+
|
|
12
|
+
type Dispatch = <T>(
|
|
13
|
+
call: () => Promise<OperationResult<T>>,
|
|
14
|
+
options?: RequestDispatchOptions
|
|
15
|
+
) => Promise<T>;
|
|
16
|
+
type SignalOptions = { signal?: AbortSignal };
|
|
17
|
+
type UploadOptions = SignalOptions & {
|
|
18
|
+
/** Required only when `file` is a nameless Blob. */
|
|
19
|
+
filename?: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
};
|
|
23
|
+
type FileIdOptions = SignalOptions & {
|
|
24
|
+
name?: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const TEMPORARY_UPLOAD_CLEANUP_TIMEOUT_MS = 10_000;
|
|
29
|
+
|
|
30
|
+
function temporaryUploadCleanupSignal(): AbortSignal {
|
|
31
|
+
return AbortSignal.timeout(TEMPORARY_UPLOAD_CLEANUP_TIMEOUT_MS);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function filenameFor(file: Blob | File, filename?: string): string {
|
|
35
|
+
const resolved =
|
|
36
|
+
filename ?? (typeof File !== 'undefined' && file instanceof File ? file.name : undefined);
|
|
37
|
+
if (!resolved) throw new Error('filename is required when uploading a Blob');
|
|
38
|
+
return resolved;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class TemplatesResource {
|
|
42
|
+
constructor(
|
|
43
|
+
private readonly client: Client,
|
|
44
|
+
private readonly dispatch: Dispatch,
|
|
45
|
+
private readonly files: FilesResource
|
|
46
|
+
) {}
|
|
47
|
+
|
|
48
|
+
async list(
|
|
49
|
+
options: SignalOptions & { limit?: number; offset?: number } = {}
|
|
50
|
+
): Promise<ListTemplatesResponse> {
|
|
51
|
+
return this.dispatch(() =>
|
|
52
|
+
templatesList({
|
|
53
|
+
client: this.client,
|
|
54
|
+
query: { limit: options.limit, offset: options.offset },
|
|
55
|
+
signal: options.signal,
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async get(templateId: string, options: SignalOptions = {}): Promise<Template> {
|
|
61
|
+
return this.dispatch(() =>
|
|
62
|
+
templatesGet({ client: this.client, path: { id: templateId }, signal: options.signal })
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async create(file: Blob | File, options: UploadOptions = {}): Promise<Template> {
|
|
67
|
+
const uploaded = await this.files.upload(file, {
|
|
68
|
+
filename: filenameFor(file, options.filename),
|
|
69
|
+
signal: options.signal,
|
|
70
|
+
});
|
|
71
|
+
try {
|
|
72
|
+
return await this.createFromFileId(uploaded.id, options);
|
|
73
|
+
} finally {
|
|
74
|
+
await this.files
|
|
75
|
+
.delete(uploaded.id, { signal: temporaryUploadCleanupSignal() })
|
|
76
|
+
.catch(() => undefined);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Create a template from an existing reusable `file_…` resource. */
|
|
81
|
+
async createFromFileId(fileId: string, options: FileIdOptions = {}): Promise<Template> {
|
|
82
|
+
return this.dispatch(
|
|
83
|
+
() =>
|
|
84
|
+
this.client.post({
|
|
85
|
+
url: '/v1/templates',
|
|
86
|
+
body: {
|
|
87
|
+
fileId,
|
|
88
|
+
name: options.name,
|
|
89
|
+
description: options.description,
|
|
90
|
+
},
|
|
91
|
+
signal: options.signal,
|
|
92
|
+
}) as Promise<OperationResult<Template>>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async replace(
|
|
97
|
+
templateId: string,
|
|
98
|
+
file: Blob | File,
|
|
99
|
+
options: Pick<UploadOptions, 'filename' | 'signal'> = {}
|
|
100
|
+
): Promise<Template> {
|
|
101
|
+
const uploaded = await this.files.upload(file, {
|
|
102
|
+
filename: filenameFor(file, options.filename),
|
|
103
|
+
signal: options.signal,
|
|
104
|
+
});
|
|
105
|
+
try {
|
|
106
|
+
return await this.replaceFromFileId(templateId, uploaded.id, options);
|
|
107
|
+
} finally {
|
|
108
|
+
await this.files
|
|
109
|
+
.delete(uploaded.id, { signal: temporaryUploadCleanupSignal() })
|
|
110
|
+
.catch(() => undefined);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Append a revision from an existing reusable `file_…` resource. */
|
|
115
|
+
async replaceFromFileId(
|
|
116
|
+
templateId: string,
|
|
117
|
+
fileId: string,
|
|
118
|
+
options: SignalOptions = {}
|
|
119
|
+
): Promise<Template> {
|
|
120
|
+
return this.dispatch(
|
|
121
|
+
() =>
|
|
122
|
+
this.client.put({
|
|
123
|
+
url: '/v1/templates/{id}',
|
|
124
|
+
path: { id: templateId },
|
|
125
|
+
body: { fileId },
|
|
126
|
+
signal: options.signal,
|
|
127
|
+
}) as Promise<OperationResult<Template>>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async download(
|
|
132
|
+
templateId: string,
|
|
133
|
+
options: SignalOptions & { revisionId?: string } = {}
|
|
134
|
+
): Promise<Blob> {
|
|
135
|
+
return this.dispatch(
|
|
136
|
+
async () =>
|
|
137
|
+
(await templatesContentGet({
|
|
138
|
+
client: this.client,
|
|
139
|
+
path: { id: templateId },
|
|
140
|
+
query: { revisionId: options.revisionId },
|
|
141
|
+
parseAs: 'blob',
|
|
142
|
+
signal: options.signal,
|
|
143
|
+
})) as OperationResult<Blob>,
|
|
144
|
+
{ responseKind: 'binary' }
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async delete(templateId: string, options: SignalOptions = {}): Promise<{ deleted: boolean }> {
|
|
149
|
+
return this.dispatch(() =>
|
|
150
|
+
templatesDelete({ client: this.client, path: { id: templateId }, signal: options.signal })
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}
|
package/src/telemetry.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
export const SDK_LANGUAGE = 'typescript';
|
|
20
20
|
// Rewritten at publish time by scripts/release/platform/render-sdk-versions.sh.
|
|
21
21
|
// Keep this string literal exactly stable — sed matches on it.
|
|
22
|
-
export const SDK_VERSION = '0.
|
|
22
|
+
export const SDK_VERSION = '0.13.1';
|
|
23
23
|
|
|
24
24
|
function detectRuntime(): string {
|
|
25
25
|
const g = globalThis as unknown as {
|