@vertesia/client 0.80.0-dev.20251121 → 0.80.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +110 -0
- package/lib/cjs/InteractionsApi.js +12 -0
- package/lib/cjs/InteractionsApi.js.map +1 -1
- package/lib/cjs/SkillsApi.js +39 -0
- package/lib/cjs/SkillsApi.js.map +1 -0
- package/lib/cjs/client.js +5 -6
- package/lib/cjs/client.js.map +1 -1
- package/lib/cjs/store/FilesApi.js +78 -1
- package/lib/cjs/store/FilesApi.js.map +1 -1
- package/lib/cjs/store/ObjectsApi.js +1 -0
- package/lib/cjs/store/ObjectsApi.js.map +1 -1
- package/lib/cjs/store/index.js +1 -0
- package/lib/cjs/store/index.js.map +1 -1
- package/lib/esm/InteractionsApi.js +12 -0
- package/lib/esm/InteractionsApi.js.map +1 -1
- package/lib/esm/SkillsApi.js +36 -0
- package/lib/esm/SkillsApi.js.map +1 -0
- package/lib/esm/client.js +5 -6
- package/lib/esm/client.js.map +1 -1
- package/lib/esm/store/FilesApi.js +76 -0
- package/lib/esm/store/FilesApi.js.map +1 -1
- package/lib/esm/store/ObjectsApi.js +1 -0
- package/lib/esm/store/ObjectsApi.js.map +1 -1
- package/lib/esm/store/index.js +1 -0
- package/lib/esm/store/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/InteractionsApi.d.ts +7 -1
- package/lib/types/InteractionsApi.d.ts.map +1 -1
- package/lib/types/SkillsApi.d.ts +26 -0
- package/lib/types/SkillsApi.d.ts.map +1 -0
- package/lib/types/client.d.ts +3 -1
- package/lib/types/client.d.ts.map +1 -1
- package/lib/types/store/FilesApi.d.ts +55 -0
- package/lib/types/store/FilesApi.d.ts.map +1 -1
- package/lib/types/store/ObjectsApi.d.ts.map +1 -1
- package/lib/types/store/index.d.ts +1 -0
- package/lib/types/store/index.d.ts.map +1 -1
- package/lib/vertesia-client.js +1 -1
- package/lib/vertesia-client.js.map +1 -1
- package/package.json +13 -4
- package/src/InteractionsApi.ts +14 -1
- package/src/SkillsApi.ts +46 -0
- package/src/client.ts +5 -6
- package/src/store/FilesApi.ts +93 -0
- package/src/store/ObjectsApi.ts +1 -0
- package/src/store/index.ts +1 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
|
|
2
|
-
import { AsyncExecutionPayload, ComputeInteractionFacetPayload, GenerateInteractionPayload, GenerateTestDataPayload, ImprovePromptPayload, ImprovePromptPayloadConfig, Interaction, InteractionCreatePayload, InteractionEndpoint, InteractionEndpointQuery, InteractionExecutionPayload, InteractionForkPayload, InteractionPublishPayload, InteractionRef, InteractionRefWithSchema, InteractionSearchPayload, InteractionsExportPayload, InteractionUpdatePayload, RateLimitRequestPayload, RateLimitRequestResponse } from "@vertesia/common";
|
|
2
|
+
import { AsyncExecutionPayload, ComputeInteractionFacetPayload, GenerateInteractionPayload, GenerateTestDataPayload, ImprovePromptPayload, ImprovePromptPayloadConfig, Interaction, InteractionCreatePayload, InteractionEndpoint, InteractionEndpointQuery, InteractionExecutionPayload, InteractionForkPayload, InteractionPublishPayload, InteractionRef, InteractionRefWithSchema, InteractionSearchPayload, InteractionSearchQuery, InteractionsExportPayload, InteractionTags, InteractionUpdatePayload, RateLimitRequestPayload, RateLimitRequestResponse } from "@vertesia/common";
|
|
3
3
|
import { InteractionCatalogApi } from "./InteractionCatalogApi.js";
|
|
4
4
|
import { EnhancedExecutionRun, EnhancedInteractionExecutionResult } from "./InteractionOutput.js";
|
|
5
5
|
export interface ComputeInteractionFacetsResponse {
|
|
@@ -38,6 +38,12 @@ export default class InteractionsApi extends ApiTopic {
|
|
|
38
38
|
* @param name
|
|
39
39
|
*/
|
|
40
40
|
listVersionsByName(name: string): Promise<InteractionRef[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Get the list of all interaction tags in the current project
|
|
43
|
+
* @param query optional query parameters to filter the tags
|
|
44
|
+
* @returns InteractionTags[]
|
|
45
|
+
**/
|
|
46
|
+
listTags(query?: InteractionSearchQuery): Promise<InteractionTags[]>;
|
|
41
47
|
/**
|
|
42
48
|
* Get the list of all interactions facets
|
|
43
49
|
* @param payload query payload to filter facet search
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InteractionsApi.d.ts","sourceRoot":"","sources":["../../src/InteractionsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAe,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EACH,qBAAqB,EAAE,8BAA8B,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,oBAAoB,EAChI,0BAA0B,EAC1B,WAAW,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,wBAAwB,EACpF,2BAA2B,EAAE,sBAAsB,EACnD,yBAAyB,EAAE,cAAc,EAAE,wBAAwB,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"InteractionsApi.d.ts","sourceRoot":"","sources":["../../src/InteractionsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAe,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EACH,qBAAqB,EAAE,8BAA8B,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,oBAAoB,EAChI,0BAA0B,EAC1B,WAAW,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,wBAAwB,EACpF,2BAA2B,EAAE,sBAAsB,EACnD,yBAAyB,EAAE,cAAc,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,sBAAsB,EACrH,yBAAyB,EAAE,eAAe,EAAE,wBAAwB,EACpE,uBAAuB,EAAE,wBAAwB,EACpD,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,kCAAkC,EAA0D,MAAM,wBAAwB,CAAC;AAE1J,MAAM,WAAW,gCAAgC;IAC7C,IAAI,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O9E;;;OAGG;IACG,mBAAmB,CAAC,OAAO,GAAG,GAAG,EAAE,OAAO,GAAG,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAOnJ,yBAAyB,CAAC,OAAO,GAAG,GAAG,EAAE,OAAO,GAAG,GAAG,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,kCAAkC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAQ3J;;;;OAIG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAInD;;;;OAIG;IACH,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAIhD;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;CAInF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
|
|
2
|
+
import { InjectedSkill, SkillContext } from "@vertesia/common";
|
|
3
|
+
/**
|
|
4
|
+
* API client for skill operations.
|
|
5
|
+
* Skills are interactions with agent_runner_options.is_skill = true.
|
|
6
|
+
* They provide contextual instructions to agents by executing/rendering
|
|
7
|
+
* the interaction and returning the result.
|
|
8
|
+
*/
|
|
9
|
+
export default class SkillsApi extends ApiTopic {
|
|
10
|
+
constructor(parent: ClientBase);
|
|
11
|
+
/**
|
|
12
|
+
* Find skills relevant to a given context.
|
|
13
|
+
* This is the core skill matching API for auto-injection.
|
|
14
|
+
* @param context The context to match against
|
|
15
|
+
* @param limit Maximum number of skills to return (default: 5)
|
|
16
|
+
* @returns Array of injected skills with match scores
|
|
17
|
+
*/
|
|
18
|
+
findRelevant(context: SkillContext, limit?: number): Promise<InjectedSkill[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Convenience method to find relevant skills by task description
|
|
21
|
+
* @param taskDescription The task or prompt to match
|
|
22
|
+
* @param toolNames Optional list of tools being used
|
|
23
|
+
* @returns Array of injected skills
|
|
24
|
+
*/
|
|
25
|
+
findRelevantForTask(taskDescription: string, toolNames?: string[]): Promise<InjectedSkill[]>;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SkillsApi.d.ts","sourceRoot":"","sources":["../../src/SkillsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAEH,aAAa,EACb,YAAY,EACf,MAAM,kBAAkB,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,QAAQ;gBAC/B,MAAM,EAAE,UAAU;IAI9B;;;;;;OAMG;IACH,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAK7E;;;;;OAKG;IACH,mBAAmB,CACf,eAAe,EAAE,MAAM,EACvB,SAAS,CAAC,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,aAAa,EAAE,CAAC;CAM9B"}
|
package/lib/types/client.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import EnvironmentsApi from "./EnvironmentsApi.js";
|
|
|
10
10
|
import { IamApi } from "./IamApi.js";
|
|
11
11
|
import InteractionsApi from "./InteractionsApi.js";
|
|
12
12
|
import ProjectsApi from "./ProjectsApi.js";
|
|
13
|
+
import SkillsApi from "./SkillsApi.js";
|
|
13
14
|
import PromptsApi from "./PromptsApi.js";
|
|
14
15
|
import { RefsApi } from "./RefsApi.js";
|
|
15
16
|
import { RunsApi } from "./RunsApi.js";
|
|
@@ -86,7 +87,7 @@ export declare class VertesiaClient extends AbstractFetchClient<VertesiaClient>
|
|
|
86
87
|
* Alias for store.objects
|
|
87
88
|
*/
|
|
88
89
|
get objects(): import("./index.js").ObjectsApi;
|
|
89
|
-
get files(): import("./
|
|
90
|
+
get files(): import("./index.js").FilesApi;
|
|
90
91
|
/**
|
|
91
92
|
* Alias for store.types
|
|
92
93
|
*/
|
|
@@ -106,6 +107,7 @@ export declare class VertesiaClient extends AbstractFetchClient<VertesiaClient>
|
|
|
106
107
|
projects: ProjectsApi;
|
|
107
108
|
environments: EnvironmentsApi;
|
|
108
109
|
interactions: InteractionsApi;
|
|
110
|
+
skills: SkillsApi;
|
|
109
111
|
prompts: PromptsApi;
|
|
110
112
|
runs: RunsApi;
|
|
111
113
|
account: AccountApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,eAAe,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,eAAe,MAAM,sBAAsB,CAAC;AACnD,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,WAAW,MAAM,kBAAk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AgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAIvD;AA2BD,wBAAgB,eAAe,CAC3B,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GACvD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASxB"}
|
|
@@ -2,7 +2,14 @@ import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
|
|
|
2
2
|
import { GetFileUrlPayload, GetFileUrlResponse, GetUploadUrlPayload } from "@vertesia/common";
|
|
3
3
|
import { StreamSource } from "../StreamSource.js";
|
|
4
4
|
export declare const MEMORIES_PREFIX = "memories";
|
|
5
|
+
export declare const ARTIFACTS_PREFIX = "agents";
|
|
5
6
|
export declare function getMemoryFilePath(name: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Build the storage path for an agent artifact
|
|
9
|
+
* @param runId - The workflow run ID
|
|
10
|
+
* @param name - The artifact filename
|
|
11
|
+
*/
|
|
12
|
+
export declare function getAgentArtifactPath(runId: string, name: string): string;
|
|
6
13
|
export declare class FilesApi extends ApiTopic {
|
|
7
14
|
constructor(parent: ClientBase);
|
|
8
15
|
deleteFile(path: string, prefix?: boolean): Promise<void | number>;
|
|
@@ -19,6 +26,17 @@ export declare class FilesApi extends ApiTopic {
|
|
|
19
26
|
contentType: string;
|
|
20
27
|
contentDisposition?: string;
|
|
21
28
|
etag?: string;
|
|
29
|
+
customMetadata?: Record<string, string>;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Set custom metadata on a file
|
|
33
|
+
* @param file - The file path or URI
|
|
34
|
+
* @param metadata - Custom metadata key-value pairs
|
|
35
|
+
* @returns Success status
|
|
36
|
+
*/
|
|
37
|
+
setFileMetadata(file: string, metadata: Record<string, string>): Promise<{
|
|
38
|
+
success: boolean;
|
|
39
|
+
file: string;
|
|
22
40
|
}>;
|
|
23
41
|
/**
|
|
24
42
|
* Get or create a bucket for the project. If the bucket already exists, it does nothing.
|
|
@@ -45,4 +63,41 @@ export declare class FilesApi extends ApiTopic {
|
|
|
45
63
|
downloadFile(location: string): Promise<ReadableStream<Uint8Array<ArrayBuffer>>>;
|
|
46
64
|
uploadMemoryPack(source: StreamSource | File): Promise<string>;
|
|
47
65
|
downloadMemoryPack(name: string, gunzip?: boolean): Promise<ReadableStream<Uint8Array>>;
|
|
66
|
+
/**
|
|
67
|
+
* List files by prefix
|
|
68
|
+
* @param prefix - Path prefix to filter files
|
|
69
|
+
* @returns Array of file paths matching the prefix
|
|
70
|
+
*/
|
|
71
|
+
listByPrefix(prefix: string): Promise<{
|
|
72
|
+
files: string[];
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Upload an artifact for an agent run
|
|
76
|
+
* @param runId - The workflow run ID
|
|
77
|
+
* @param name - Artifact name (e.g., "output.json")
|
|
78
|
+
* @param source - File content source
|
|
79
|
+
* @returns The full path of the uploaded artifact
|
|
80
|
+
*/
|
|
81
|
+
uploadArtifact(runId: string, name: string, source: StreamSource | File): Promise<string>;
|
|
82
|
+
/**
|
|
83
|
+
* Download an artifact from an agent run
|
|
84
|
+
* @param runId - The workflow run ID
|
|
85
|
+
* @param name - Artifact name
|
|
86
|
+
* @returns ReadableStream of the artifact content
|
|
87
|
+
*/
|
|
88
|
+
downloadArtifact(runId: string, name: string): Promise<ReadableStream<Uint8Array>>;
|
|
89
|
+
/**
|
|
90
|
+
* Get download URL for an artifact
|
|
91
|
+
* @param runId - The workflow run ID
|
|
92
|
+
* @param name - Artifact name
|
|
93
|
+
* @param disposition - Content disposition (inline or attachment)
|
|
94
|
+
* @returns Signed URL response
|
|
95
|
+
*/
|
|
96
|
+
getArtifactDownloadUrl(runId: string, name: string, disposition?: "inline" | "attachment"): Promise<GetFileUrlResponse>;
|
|
97
|
+
/**
|
|
98
|
+
* List artifacts for an agent run
|
|
99
|
+
* @param runId - The workflow run ID
|
|
100
|
+
* @returns Array of artifact file paths
|
|
101
|
+
*/
|
|
102
|
+
listArtifacts(runId: string): Promise<string[]>;
|
|
48
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilesApi.d.ts","sourceRoot":"","sources":["../../../src/store/FilesApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EACH,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"FilesApi.d.ts","sourceRoot":"","sources":["../../../src/store/FilesApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EACH,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EAEtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,eAAO,MAAM,eAAe,aAAa,CAAC;AAC1C,eAAO,MAAM,gBAAgB,WAAW,CAAC;AAEzC,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,UAG7C;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAExE;AAED,qBAAa,QAAS,SAAQ,QAAQ;gBACtB,MAAM,EAAE,UAAU;IAIxB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC;IAKxE;;;;;;OAMG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QAC9B,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,cAAc,CAAC,EAAE,MAAM,CAAC,MA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AO,CAAC,iBAAiB,EAAE,CAAC;IAIhE,YAAY,CACR,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,kBAAkB,GAC5B,OAAO,CAAC,oBAAoB,CAAC;IAahC,gBAAgB,CACZ,OAAO,EAAE,uBAAuB,GACjC,OAAO,CAAC,wBAAwB,CAAC;IAMpC,YAAY,CACR,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,uBAAuB,EAC7B,OAAO,EAAE,SAAS,GACnB,OAAO,CAAC,MAAM,CAAC,uBAAuB,EAAE,SAAS,CAAC,CAAC;CAKzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
|
package/lib/vertesia-client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ExecutionRunStatus as t,ContentObjectApiHeaders as e,AgentMessageType as s}from"@vertesia/common";class r extends Error{constructor(t,e,s,r,n=!0){super(function(t,e,s,r,n){let i=t;if(n){i+="\nRequest: "+e.method+" "+e.url+" => "+s;const t=r?.details||r?.error?.details;if(t){const e=typeof t;"string"===e?i+="\nDetails: "+t:"object"===e&&(i+="\nDetails: "+JSON.stringify(t,void 0,2))}i+="\nStack Trace: "}return i}(t,e,s,r,n)),this.original_message=t,this.request=e,this.status=s,this.payload=r,this.request_info=e.method+" "+e.url+" => "+s,this.displayDetails=n}get details(){return this.payload?.details||this.payload?.error?.details}}class n extends r{constructor(t,e,s,r,n=!0){super(t,e,s,r,n)}updateDetails(t){return t!==this.details?new n(this.original_message,this.request,this.status,{...this.payload,details:t},this.displayDetails):this}}class i extends r{constructor(t,e){super("Failed to connect to server: "+e.message,t,0,e)}}let o;if(globalThis.TextDecoderStream&&"function"==typeof globalThis.TextDecoderStream)o=globalThis.TextDecoderStream;else{class t extends TransformStream{constructor(t="utf-8",{fatal:s=!1,ignoreBOM:r=!1}={}){super(new e(new TextDecoder(t,{fatal:s,ignoreBOM:r}))),this._options={fatal:s,ignoreBOM:r,encoding:t}}get encoding(){return this._options.encoding}get fatal(){return this._options.fatal}get ignoreBOM(){return this._options.ignoreBOM}}class e{constructor(t){this.decoder=t}transform(t,e){if(!(t instanceof ArrayBuffer||ArrayBuffer.isView(t)))throw new TypeError("Input must be a compatible with: ArrayBuffer | Uint8Array");const s=this.decoder.decode(t,{stream:!0});0!==s.length&&e.enqueue(s)}flush(t){const e=this.decoder.decode();0!==e.length&&t.enqueue(e)}}o=t}const a=[239,187,191];class u extends TransformStream{constructor(){let t;super({start(e){t=function(t){let e,s,r,n,i,o,u;return l(),{feed:function(t){s=s?s+t:t,e&&function(t){return a.every(((e,s)=>t.charCodeAt(s)===e))}(s)&&(s=s.slice(a.length)),e=!1;const i=s.length;let o=0,u=!1;for(;o<i;){u&&("\n"===s[o]&&++o,u=!1);let t,e=-1,a=n;for(let n=r;e<0&&n<i;++n)t=s[n],":"===t&&a<0?a=n-o:"\r"===t?(u=!0,e=n-o):"\n"===t&&(e=n-o);if(e<0){r=i-o,n=a;break}r=0,n=-1,c(s,o,a,e),o+=e+1}o===i?s="":o>0&&(s=s.slice(o))},reset:l};function l(){e=!0,s="",r=0,n=-1,i=void 0,o=void 0,u=""}function c(e,s,r,n){if(0===n)return u.length>0&&(t({type:"event",id:i,event:o||void 0,data:u.slice(0,-1)}),u="",i=void 0),void(o=void 0);const a=r<0,l=e.slice(s,s+(a?n:r));let c=0;c=a?n:" "===e[s+r+1]?r+2:r+1;const h=s+c,p=n-c,d=e.slice(h,h+p).toString();if("data"===l)u+=d?"".concat(d,"\n"):"\n";else if("event"===l)o=d;else if("id"!==l||d.includes("\0")){if("retry"===l){const e=parseInt(d,10);Number.isNaN(e)||t({type:"reconnect-interval",value:e})}}else i=d}}((t=>{"event"===t.type&&e.enqueue(t)}))},transform(e){t.feed(e)}})}}function l(t){return"/"===t[t.length-1]?t.slice(0,-1):t}class c{constructor(t,e){this.errorFactory=t=>t,this.verboseErrors=!0,this.baseUrl=l(t),this._fetch=function(t){return t?Promise.resolve(t):"function"==typeof globalThis.fetch?Promise.resolve(globalThis.fetch):Promise.resolve((()=>{throw new Error("No Fetch implementation found")}))}(e)}throwError(t){throw this.errorFactory(t)}getUrl(t){return l((e=this.baseUrl,s=t,e.endsWith("/")?s.startsWith("/")?e+s.substring(1):e+s:s.startsWith("/")?e+s:e+"/"+s));var e,s}get(t,e){return this.request("GET",t,e)}del(t,e){return this.request("DELETE",t,e)}delete(t,e){return this.request("DELETE",t,e)}post(t,e){return this.request("POST",t,e)}put(t,e){return this.request("PUT",t,e)}jsonParse(t){return JSON.parse(t)}createRequest(t,e){return Promise.resolve(new Request(t,e))}createServerError(t,e,s){let r="Server Error: "+e.status;return s&&(s.message?r=String(s.message):s.error&&("string"==typeof s.error?r=String(s.error):"string"==typeof s.error.message&&(r=String(s.error.message)))),new n(r,t,e.status,s,this.verboseErrors)}async readJSONPayload(t){return t.text().then((e=>{if(e)try{return this.jsonParse(e)}catch(s){return{status:t.status,error:"Not a valid JSON payload",message:s.message,text:e}}})).catch((e=>({status:t.status,error:"Unable to load response content",message:e.message})))}handleResponse(t,e,s){return e.url,s&&s.reader?"sse"===s.reader?async function(t){if(!t.ok){const e=await t.text(),s=new Error("SSE error: "+t.status+". Content:\n"+e);throw s.status=t.status,s}if(!t.body)throw new Error("No body in response");return t.body.pipeThrough(new o).pipeThrough(new u)}(e):s.reader.call(this,e):this.readJSONPayload(e).then((s=>{if(e.ok)return s;this.throwError(this.createServerError(t,e,s))}))}async request(t,e,s){let r=this.getUrl(e);s?.query&&(r+="?"+function(t){const e=[];for(const s of Object.keys(t)){const r=t[s];null!=r&&e.push(encodeURIComponent(s)+"="+encodeURIComponent(String(r)))}return e.join("&")}(s.query));const n=this.headers?Object.assign({},this.headers):{},o=s?.headers;if(o)for(const t in o)n[t.toLowerCase()]=o[t];let a;const u=s?.payload;u&&(s&&!1===s.jsonPayload?a=u:(a="string"!=typeof u?JSON.stringify(u):u,"content-type"in n||(n["content-type"]="application/json")));const l={method:t,headers:n,body:a},c=await this.createRequest(r,l);return this._fetch.then((t=>t(c).catch((t=>{console.error(`Failed to connect to ${r}`,t),this.throwError(new i(c,t))})).then((t=>this.handleResponse(c,t,s)))))}fetch(t,e){return this._fetch.then((s=>s(t,e)))}}class h extends c{constructor(t,e){super(t,e),this.baseUrl="/"===t[t.length-1]?t.substring(0,t.length-1):t,this.headers=this.initialHeaders}get initialHeaders(){return{accept:"application/json"}}withAuthCallback(t){return this._auth=t||void 0,this}withErrorFactory(t){return this.errorFactory=t,this}withLang(t){return t?this.headers["accept-language"]=t:delete this.headers["accept-language"],this}withHeaders(t){const e=this.headers;for(const s in t){const r=t[s];null!=r&&(e[s.toLowerCase()]=r)}return this}setHeader(t,e){e?this.headers[t.toLowerCase()]=e:delete this.headers[t.toLowerCase()]}async createRequest(t,e){if(this._auth&&(!(s=e.headers)||!("authorization"in s))){const t=e.headers?e.headers:{};e.headers=t;const s=await this._auth();s&&(e.headers.authorization=s)}var s;this.response=void 0;const r=await super.createRequest(t,e);return this.onRequest&&this.onRequest(r),r}async handleResponse(t,e,s){return this.response=e,this.onResponse&&this.onResponse(e,t),super.handleResponse(t,e,s)}}class p extends c{constructor(t,e){super(t.getUrl(e),t._fetch),this.client=t,this.createServerError=t.createServerError,this.errorFactory=t.errorFactory,this.verboseErrors=t.verboseErrors}createRequest(t,e){return this.client.createRequest(t,e)}handleResponse(t,e,s){return this.client.handleResponse(t,e,s)}get headers(){return this.client.headers}}class d extends p{constructor(t){super(t,"/api/v1/account")}info(){return this.get("/")}update(t){return this.put("/",{payload:t})}projects(){return this.get("/projects").then((t=>t.data))}members(){return this.get("/members")}inviteUser(t){return this.post("/invites",{payload:t})}listInvites(){return this.get("/invites")}listInvitation(t="project"){return this.get(`/invites/${t}`)}acceptInvite(t){return this.put(`/invites/${t}`)}rejectInvite(t){return this.delete(`/invites/${t}`)}onboardingProgress(){return this.get("/onboarding")}getGoogleToken(){return this.get("/google-token")}getStripeBillingStatus(){return this.get("/stripe-billing-status")}}class g extends p{constructor(t){super(t,"/api/v1/accounts")}create(t){return this.post("/",{payload:{name:t}})}list(){return this.get("/")}}class y extends p{constructor(t){super(t,"/api/v1/analytics")}runs(t){return this.post("/runs",{payload:t})}}class m extends p{constructor(t){super(t,"/api/v1/apikeys")}list(t="account"){return this.get("/",{query:{level:t}})}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}retrieve(t,e=!1){return e?this.get(`/${t}`,{query:{withValue:!0}}):this.get(`/${t}`)}requestPublicKey(t={}){return this.get("/pk",{query:t})}}class f extends p{constructor(t){super(t,"/api/v1/apps")}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}listAppInstallationTools(t){return this.get(`/installations/${t}/tools`)}list(){return this.get("/")}install(t,e){return this.post("/install",{payload:{app_id:t,settings:e}})}uninstall(t){return this.del(`/install/${t}`)}getAppInstallationByName(t){return this.get(`/installations/name/${t}`).catch((t=>{if(404===t.status)return null;throw t}))}getAppInstallationProjects(t){if(!t.id&&!t.name)throw new Error("Invalid arguments: appId or appName must be specified");const e=t.id?{id:t.id}:{name:t.name};return this.get("/installations/projects",{query:e})}getInstalledApps(t){return this.get("/installations",{query:{kind:t}})}getAllAppInstallations(){return this.get("/installations/all")}listInstallations(){return this.get("/installations/refs")}updateInstallationSettings(t){return this.put(`/installations/settings/${t.app_id}`,{payload:{app_id:t.app_id,settings:t.settings}})}}let w=class extends p{constructor(t){super(t,"/api/v1/commands")}async isNamespaceAvailable(t){return this.get(`/namespaces/${t}/is_available`).then((t=>t.available))}async initSamples(){return this.post("/onboarding/init-samples")}};class v extends p{constructor(t){super(t,"/api/v1/environments")}list(t=!1){const e=t?{all:!0}:void 0;return this.get("/",{query:e})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get("/"+t)}update(t,e){return this.put("/"+t,{payload:e})}updateConfig(t,e){return this.put("/"+t+"/config",{payload:e})}listModels(t,e){return this.get("/"+t+"/models",{query:e?{...e}:void 0})}listTrainableModels(t){return this.get(`/${t}/trainable-models`)}embeddings(t,e){return this.post("/"+t+"/embeddings",{payload:e})}}class b extends p{constructor(t){super(t,"/groups")}list(t){return this.get("/",{query:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get("/"+t)}update(t,e){return this.put("/"+t,{payload:e})}delete(t){return this.del("/"+t)}listMembers(t){return this.get("/"+t+"/members")}addMember(t,e){return this.post("/"+t+"/members/"+e)}removeMember(t,e){return this.del("/"+t+"/members/"+e)}}class $ extends p{constructor(t){super(t,"/api/v1/iam"),this.aces=new k(this),this.roles=new S(this),this.groups=new b(this)}}class S extends p{constructor(t){super(t,"/roles")}list(){return this.get("/")}}class k extends p{constructor(t){super(t,"/aces")}list(t){return this.get("/",{query:{...t}})}retrieve(t){return this.get("/"+t)}create(t){return this.post("/",{payload:t})}delete(t){return this.del("/"+t)}}async function x(){return"function"==typeof globalThis.EventSource?globalThis.EventSource:(await import("eventsource")).EventSource}async function E(e,s,r={},n){const i=!!n,o=await e.runs.create({...r,interaction:s,stream:i});if(i){if(o.status===t.failed)return o;await T(e,o.id,n)}return o}function T(t,e,s){return new Promise((async(r,n)=>{try{const i=await x(),o=new URL(t.runs.baseUrl+"/"+e+"/stream"),a=t._auth?await t._auth():void 0;if(!a)throw new Error("No auth token available");{const t=a.split(" ")[1];o.searchParams.set("access_token",t)}const u=new i(o.href);u.addEventListener("message",(t=>{try{const e=JSON.parse(t.data);e&&s&&s(e)}catch(t){n(t)}})),u.addEventListener("close",(t=>{try{u.close();const e=JSON.parse(t.data);r(e)}catch(t){n(t)}}))}catch(t){n(t)}}))}class _ extends p{constructor(t){super(t,"/api/v1/interactions/catalog")}list(t={}){return this.get("/",{query:t})}listStoredInteractions(t={}){return this.get("/stored",{query:t})}listSysInteractions(t){return this.get("/sys",{query:{tag:t}})}listAppInteractions(t,e){return this.get(`/apps/${t}`,{query:{tag:e}})}listAllAppInteractions(t){return this.get("/apps",{query:{tag:t}})}resolve(t){return this.get(`/resolve/${t}`)}}const q=Symbol("InteractionOutput");function U(t){return t.result=I.from(t.result),t}function R(t){return t.result=I.from(t.result),t}class I{constructor(t){this.results=t}static from(t){return t?t[q]?t:Array.isArray(t)?A(t):A("object"==typeof t?[{type:"json",value:t}]:[{type:"text",value:String(t)}]):A([])}static isInteractionOutputArray(t){return t&&!0===t[q]}get isEmpty(){return 0===this.results.length}hasObject(){return this.results.some((t=>"json"===t.type))}hasText(){return this.results.some((t=>"text"===t.type))}hasImage(){return this.results.some((t=>"image"===t.type))}text(t="\n"){return this.results.filter((t=>"text"===t.type)).map((t=>t.value)).join(t)}texts(){return this.results.filter((t=>"text"===t.type)).map((t=>t.value))}object(){const t=this.results.find((t=>"json"===t.type));return t?t.value:function(t){let e;for(const s of t)if("text"===s.type){const t=s.value.trim();try{return JSON.parse(t)}catch(t){e=t}}e||(e=new Error("No JSON result found and no text available to parse"));throw e}(this.results)}objects(){return this.results.filter((t=>"json"===t.type)).map((t=>t.value))}objectAt(t){let e=0;for(const s of this.results)if("json"===s.type){if(e===t)return s.value;e++}throw new Error(`Object at index ${t} not found`)}image(){const t=this.results.find((t=>"image"===t.type));if(!t)throw new Error("No image result found");return t.value}images(){return this.results.filter((t=>"image"===t.type)).map((t=>t.value))}stringify(t="\n",e=2){return this.results.map((t=>"json"===t.type?JSON.stringify(t.value,null,e):String(t.value))).join(t)}toString(){return this.text()}toJSON(){return this.results}}function A(t){const e=new I(t);return new Proxy(t,{get(t,s,r){if(s===q)return!0;if(s in e){const t=e[s];return"function"==typeof t?t.bind(e):t}return Reflect.get(t,s,r)}})}class O extends p{constructor(t){super(t,"/api/v1/interactions"),this.catalog=new _(t)}list(t={}){const e=t.query||{};return this.get("/",{query:{...e}})}listEndpoints(t){return this.post("/endpoints",{payload:t})}listVersionsByName(t){return this.get(`/versions/${t}`)}computeFacets(t){return this.post("/facets",{payload:t})}listNames(){return this.get("/names")}export(t){return this.post("/export",{payload:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}async execute(t,e={},s){return U(await E(this.client,t,e,s).catch((t=>{throw t instanceof n&&t.payload?.id?t.updateDetails({run_id:t.payload.id}):t})))}async executeByName(e,s={},r){const i=await async function(e,s,r={},n){const i=!!n,o=await e.post("/api/v1/execute",{payload:{...r,interaction:s,stream:i}});if(i){if(o.status===t.failed)return o;await T(e,o.id,n)}return o}(this.client,e,s,r).catch((t=>{throw t instanceof n&&t.payload?.id?t.updateDetails({run_id:t.payload.id}):t}));return U(i)}executeAsync(t){return async function(t,e){return await t.post("/api/v1/execute/async",{payload:e})}(this.client,t)}publish(t,e){return this.post(`/${t}/publish`,{payload:e})}fork(t,e){return this.post(`/${t}/fork`,{payload:e})}generateInteraction(t,e){return this.post(`${t}/generate-interaction`,{payload:e})}generateTestData(t,e){return this.post(`${t}/generate-test-data`,{payload:e})}async suggestImprovements(t,e){return R(await this.post(`${t}/suggest-prompt-improvements`,{payload:e}))}async suggestPromptImprovements(t){return U(await this.post("/improve",{payload:t}))}listVersions(t){return this.get(`/${t}/versions`)}listForks(t){return this.get(`/${t}/forks`)}requestSlot(t){return async function(t,e){return await t.post("/api/v1/execute/rate-limit/request",{payload:e})}(this.client,t)}}class j extends p{constructor(t){super(t,"/api/v1/projects"),this.integrations=new P(this)}list(t){return this.get("/",{query:{account:t}})}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}updateConfiguration(t,e){return this.put(`/${t}/configuration`,{payload:e})}}class P extends p{constructor(t){super(t,"/")}list(t){return this.get(`/${t}/integrations`).then((t=>t.integrations))}retrieve(t,e){return this.get(`/${t}/integrations/${e}`).catch((t=>{if(404!==t.status)throw t}))}update(t,e,s){return this.put(`/${t}/integrations/${e}`,{payload:s})}}class N extends p{constructor(t){super(t,"/api/v1/prompts")}list(t={}){const e=t.query||{};return this.get("/",{query:{...e}})}computeFacets(t){return this.post("/facets",{payload:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}fork(t,e){return this.post(`/${t}/fork`,{payload:e})}render(t,e){return this.post(`/${t}/render`,{payload:e})}options(t){return this.get(`/options/${t}`)}listVersions(t){return this.get(`/${t}/versions`)}listInteractions(t){return this.get(`/${t}/interactions`)}listForks(t){return this.get(`/${t}/forks`)}}class C extends p{constructor(t){super(t,"/api/v1/refs")}resolve(t){return this.post("/resolve",{payload:{refs:t}})}}class F extends p{constructor(t){super(t,"/api/v1/runs")}list({limit:t,offset:e,filters:s}){const r={limit:t,offset:e,...s};return this.get("/",{query:r})}find(t){return this.post("/find",{payload:t})}async retrieve(t){return R(await this.get("/"+t))}retrievePopulated(t){return this.get("/"+t,{query:{populate:"true"}})}filterOptions(t,e){const s={...e};return this.get(`/filter-options/${t}`,{query:s})}async create(t){const e=this.client.sessionTags;if(e){let s=Array.isArray(e)?e:[e];Array.isArray(t.tags)?s=s.concat(t.tags):t.tags&&(s=s.concat([t.tags])),t={...t,tags:s}}return R(await this.post("/",{payload:t}))}sendToolResults(t){return this.post("/tool-results",{payload:t})}sendUserMessage(t){return this.post("/user-message",{payload:t})}createCheckpoint(t){return this.post("/checkpoint",{payload:t})}computeFacets(t){return this.post("/facets",{payload:t})}search(t){return this.post("/search",{payload:t})}}class M extends p{constructor(t){super(t,"/api/v1/agents")}async deploy(t){return this.post("/",{payload:t})}}class D extends p{constructor(t){super(t,"/api/v1/collections")}search(t){return this.post("/search",{payload:t})}computeListFacets(t){return this.post("/facets",{payload:t})}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}addMembers(t,e){return this.post(`/${t}/members`,{payload:{action:"add",members:e}})}listMembers(t,e){return this.get(`/${t}/members`,{query:{...e}})}computeFacets(t,e){return this.post(`/${t}/facets`,{payload:e})}searchMembers(t,e){return this.post(`/${t}/search`,{payload:e})}deleteMembers(t,e){return this.post(`/${t}/members`,{payload:{action:"delete",members:e}})}addChildren(t,e){return this.post(`/${t}/children`,{payload:{action:"add",children:e}})}deleteChildren(t,e){return this.post(`/${t}/children`,{payload:{action:"delete",children:e}})}searchChildren(t,e={}){return this.post(`/${t}/children/search`,{payload:e})}delete(t){return this.del(`/${t}`)}updatePermissions(t,e){return this.put(`/${t}/permissions`,{payload:e})}propagatePermissions(t){return this.post(`/${t}/propagate-permissions`)}propagateSharedProperties(t){return this.post(`/${t}/propagate-shared-props`)}}class W extends p{constructor(t,e="/api/v1/embeddings"){super(t,e)}async status(t){return this.get(t+"/status")}async activate(t,e){if(!e.environment)throw new Error("Invalid configuration: select environment");return this.post(t+"/enable",{payload:e})}async disable(t){return this.post(t+"/disable")}async recalculate(t){return this.post(t+"/recalculate")}}class L extends p{constructor(t){super(t,"/api/v1/commands"),this.embeddings=new W(this,"/embeddings")}}class J extends r{constructor(t,e){super("Resource not found: "+e.message,t,404,e.payload)}}class B{constructor(t,e,s,r){this.stream=t,this.name=e,this.type=s,this.id=r}}function z(t){return`memories/${t.endsWith(".tar.gz")?t:t+".tar.gz"}`}class V extends p{constructor(t){super(t,"/api/v1/files")}async deleteFile(t,e){return(await this.delete(`/${t}`,{query:{prefix:e}})).count}getMetadata(t){return this.get("/metadata",{query:{file:t}})}getOrCreateBucket(){return this.post("/bucket")}getUploadUrl(t){return this.post("/upload-url",{payload:t})}getDownloadUrl(t,e,s){const r={file:t,name:e,disposition:s};return this.post("/download-url",{payload:r})}getDownloadUrlWithOptions(t){return this.post("/download-url",{payload:t})}async uploadFile(t){const e=t instanceof B,{url:s,id:r,path:n}=await this.getUploadUrl(t);return await fetch(s,{method:"PUT",body:e?t.stream:t,duplex:e?"half":void 0,headers:{"Content-Type":t.type||"application/gzip"}}).then((t=>{if(t.ok)return t;throw console.log(t),new Error(`Failed to upload file: ${t.statusText}`)})).catch((t=>{throw console.error("Failed to upload file",{err:t,url:s,id:r,path:n}),t})),r}async downloadFile(t){const e=!t.startsWith("https:"),{url:s}=e?await this.getDownloadUrl(t):{url:t},r=await fetch(s,{method:"GET"}).then((e=>{if(e.ok)return e;throw 404===e.status?new Error(`File at ${s} not found`):403===e.status?new Error(`File at ${s} is forbidden`):(console.log(e),new Error(`Failed to download file ${t}: ${e.statusText}`))})).catch((e=>{throw console.error(`Failed to download file ${t}.`,e),e}));if(!r.body)throw new Error(`No body in response while downloading file ${t}`);return r.body}async uploadMemoryPack(t){const e=z(t.name),s=t.name.endsWith(".tar.gz")?t.name:t.name+".tar.gz";if(t instanceof File){let r=t;return this.uploadFile(new B(r.stream(),s,r.type,e))}return this.uploadFile(new B(t.stream,s,t.type,e))}async downloadMemoryPack(t,e=!1){let s=await this.downloadFile(z(t));if(e){const t=new DecompressionStream("gzip");s=s.pipeThrough(t)}return s}}class H extends p{constructor(t,e){super(t,`/${e}/analyze`),this.objectId=e}async start(t){return this.post("/",{payload:t})}async getStatus(){return this.get("/status")}async getResults(){return this.get("/results")}async adaptTables(t){return this.post("/adapt_tables",{payload:t})}async getAdaptedTables(t,e){const s=t?`/adapt_tables/${t}`:"/adapt_tables",r={};e?.format&&(r.format=e.format),void 0!==e?.raw&&(r.raw=e.raw);const n={query:r};return"csv"===e?.format&&(n.responseType="text"),this.get(s,n)}async getXml(){return this.get("/xml")}async getTables(t){const e={};return t&&(e.query={format:t}),this.get("/tables",e)}async getImages(){return this.get("/images")}async getAnnotated(){return this.get("/annotated")}}class G extends p{constructor(t){super(t,"/api/v1/objects")}analyze(t){return new H(this,t)}getUploadUrl(t){return this.post("/upload-url",{payload:t})}getDownloadUrl(t,e,s){return this.post("/download-url",{payload:{file:t,name:e,disposition:s}})}getDownloadUrlWithOptions(t){return this.post("/download-url",{payload:t})}getContentSource(t){return this.get(`/${t}/content-source`)}list(t={}){const e=t.limit||100,s=t.offset||0,r=t.query||{};return this.get("/",{query:{limit:e,offset:s,...r,all_revisions:t.all_revisions,from_root:t.from_root||void 0}})}computeFacets(t){return this.post("/facets",{payload:t})}listFolders(t="/"){}find(t){return this.post("/find",{payload:t})}count(t){return this.post("/count",{payload:t})}search(t){return this.post("/search",{payload:t})}retrieve(t,e){return this.get(`/${t}`,{query:{select:e}})}getObjectText(t){return this.get(`/${t}/text`)}async upload(t){const e=t instanceof B,{url:s,id:r,mime_type:n}=await this.getUploadUrl({id:e?t.id:void 0,name:t.name,mime_type:t.type}),i=await fetch(s,{method:"PUT",body:e?t.stream:t,duplex:e?"half":void 0,headers:{"Content-Type":n||"application/octet-stream"}}).then((t=>{if(t.ok)return t;throw console.log(t),new Error(`Failed to upload file: ${t.statusText}`)})).catch((t=>{throw console.error("Failed to upload file",t),t})),o=i.headers.get("etag")?.replace(/^"(.*)"$/,"$1");return{source:r,name:t.name,type:n,etag:o}}async create(t,s){const r={...t};(t.content instanceof B||t.content instanceof File)&&(r.content=await this.upload(t.content));const n={};return s?.processing_priority&&(n[e.PROCESSING_PRIORITY]=s.processing_priority),s?.collection_id&&(n[e.COLLECTION_ID]=s.collection_id),await this.post("/",{payload:r,headers:n})}async createFromExternalSource(t,s={},r){const n=await this.client.files.getMetadata(t),i={...s,content:{source:t,name:n.name,type:n.contentType,etag:n.etag}},o={};return r?.processing_priority&&(o[e.PROCESSING_PRIORITY]=r.processing_priority),r?.collection_id&&(o[e.COLLECTION_ID]=r.collection_id),await this.post("/",{payload:i,headers:o})}async update(t,s,r){const n={...s};(s.content instanceof B||s.content instanceof File)&&(n.content=await this.upload(s.content));const i={};return r?.processing_priority&&(i[e.PROCESSING_PRIORITY]=r.processing_priority),r?.createRevision&&(i[e.CREATE_REVISION]="true",r.revisionLabel&&(i[e.REVISION_LABEL]=r.revisionLabel)),this.put(`/${t}`,{payload:n,headers:i})}getRevisions(t){return this.get(`/${t}/revisions`)}getCollections(t){return this.get(`/${t}/collections`)}delete(t){return this.del(`/${t}`)}listWorkflowRuns(t){return this.get(`/${t}/workflow-runs`)}listRenditions(t){return this.get(`/${t}/renditions`)}getRendition(t,e){const s={max_hw:e.max_hw,generate_if_missing:e.generate_if_missing,sign_url:e.sign_url};return this.get(`/${t}/renditions/${e.format}`,{query:s})}exportProperties(t){return this.post("/export",{payload:t})}setEmbedding(t,e,s){return this.put(`/${t}/embeddings/${e}`,{payload:s})}}class K extends p{constructor(t){super(t,"/api/v1/types")}list(t={},e){const s=t.limit||2e3,r=t.offset||0,n=t.query||{};return this.get("/",{query:{limit:s,offset:r,layout:!!e?.layout,schema:!!e?.schema,...n}})}find(t){return this.post("/find",{payload:t})}retrieve(t){return this.get(`/${t}`)}getTypeByName(t){return this.get(`/name/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}}const Y="20250925",X="x-api-version";class Q extends p{constructor(t){super(t,"/api/v1/workflows"),this.rules=new Z(this),this.definitions=new tt(this)}getActivityCatalog(){return this.get("/activity-catalog")}listRuns(t,e,s){return this.post("/runs",{payload:{documentId:t,eventName:e,ruleId:s}})}listConversations(t){return this.post("/conversations",{payload:t})}searchRuns(t){return this.post("/runs",{payload:t})}sendSignal(t,e,s,r){return this.post(`/runs/${t}/${e}/signal/${s}`,{payload:r})}getRunDetails(t,e,s=!1){const r={include_history:s};return this.get(`/runs/${e}/${t}`,{query:r})}getRunInteraction(t,e){return this.get(`/runs/${t}/${e}/interaction`)}terminate(t,e,s){const r={reason:s};return this.post(`/runs/${t}/${e}/actions/terminate`,{payload:r})}cancel(t,e,s){const r={reason:s};return this.post(`/runs/${t}/${e}/actions/cancel`,{payload:r})}execute(t,e={}){return this.post(`/execute/${t}`,{payload:e})}postMessage(t,e){if(!t)throw new Error("runId is required");return this.post(`/runs/${t}/updates`,{payload:e})}retrieveMessages(t,e,s){const r={since:s};return this.get(`/runs/${t}/${e}/updates`,{query:r})}async streamMessages(t,e,r,n){return new Promise(((i,o)=>{let a=0,u=n||0,l=!1,c=null,h=null;const p=10,d=t=>{const e=Math.min(1e3*Math.pow(2,t),3e4);return e+.1*Math.random()*e},g=()=>{h&&(clearInterval(h),h=null),c&&(c.close(),c=null)},y=t=>{l||(l=!0,g(),i(t))},m=async(n=!1)=>{if(!l)try{const f=await x(),w=this.client,v=new URL(w.workflows.baseUrl+`/runs/${t}/${e}/stream`);u>0&&v.searchParams.set("since",u.toString());const b=w._auth?await w._auth():void 0;if(!b)return void o(new Error("No auth token available"));const $=b.split(" ")[1];v.searchParams.set("access_token",$),n&&console.log(`Reconnecting to SSE stream for run ${e} (attempt ${a+1}/10)`);const S=new f(v.href);c=S,h=setInterval((()=>{}),1e3),S.onopen=()=>{n&&console.log(`Successfully reconnected to SSE stream for run ${e}`),a=0},S.onmessage=t=>{if(t.data&&!t.data.startsWith(":"))try{const e=JSON.parse(t.data);e.timestamp&&(u=Math.max(u,e.timestamp)),r&&r(e,y);e.type===s.TERMINATED||e.type===s.COMPLETE&&(!e.workstream_id||"main"===e.workstream_id)?(console.log("Closing stream due to COMPLETE message from main workstream"),l||(l=!0,g(),i(null))):e.type===s.COMPLETE&&console.log(`Received COMPLETE message from non-main workstream: ${e.workstream_id||"unknown"}, keeping stream open`)}catch(e){console.error("Failed to parse SSE message:",e,t.data)}else console.log("Received comment or heartbeat; ignoring it.: ",t.data)},S.onerror=t=>{if(!l)if(console.warn(`SSE stream error for run ${e}:`,t),g(),a<p){const t=d(a);console.log(`Attempting to reconnect in ${t}ms (attempt ${a+1}/10)`),a++,setTimeout((()=>{l||m(!0)}),t)}else console.error(`Failed to reconnect to SSE stream for run ${e} after 10 attempts`),l=!0,o(new Error("SSE connection failed after 10 reconnection attempts"))}}catch(t){if(console.error("Error setting up SSE stream:",t),a<p){const t=d(a);a++,setTimeout((()=>{l||m(!0)}),t)}else o(t)}};return m(!1),()=>{l=!0,g()}}))}async streamMessagesWS(t,e,r,n){return new Promise(((i,o)=>{let a=0;const u=10;let l=null,c=n||0,h=!1;const p=t=>{const e=Math.min(1e3*Math.pow(2,t),3e4);return e+.1*Math.random()*e},d=async()=>{if(!h)try{const n=this.client,g=new URL(n.workflows.baseUrl+`/runs/${t}/${e}/ws`);g.protocol=g.protocol.replace("http","ws"),c>0&&g.searchParams.set("since",c.toString());const y=n._auth?await n._auth():void 0;if(!y)return void o(new Error("No auth token available"));const m=y.split(" ")[1];g.searchParams.set("access_token",m),a>0&&console.log(`Reconnecting to WebSocket for run ${e} (attempt ${a+1}/10)`),l=new WebSocket(g.href),l.onopen=()=>{a>0&&console.log(`Successfully reconnected to WebSocket for run ${e}`),a=0,h||i({cleanup:()=>{h=!0,l&&(l.close(),l=null)},sendSignal:(t,e)=>{if(l?.readyState===WebSocket.OPEN){const s={type:"signal",signalName:t,data:e,requestId:Date.now()};l.send(JSON.stringify(s))}else console.warn("WebSocket not open, cannot send signal")}})},l.onmessage=t=>{try{const e=JSON.parse(t.data);if("workflow_run_id"in e){const t=e;t.timestamp&&(c=Math.max(c,t.timestamp)),r&&r(t);(t.type===s.TERMINATED||t.type===s.COMPLETE&&(!t.workstream_id||"main"===t.workstream_id))&&(console.log("Closing WebSocket due to workflow completion"),h=!0,l&&(l.close(),l=null))}else"pong"===e.type?console.debug("Received pong"):"ack"===e.type?console.debug("Signal acknowledged",e):"error"===e.type&&console.error("WebSocket error message",e)}catch(t){console.error("Failed to parse WebSocket message",t)}},l.onerror=t=>{console.error("WebSocket error",t)},l.onclose=()=>{if(!h&&a<u){const t=p(a);console.log(`WebSocket closed, reconnecting in ${t}ms (attempt ${a+1}/10)`),a++,setTimeout(d,t)}else a>=u&&o(new Error("WebSocket connection failed after 10 attempts"))}}catch(t){if(console.error("Error setting up WebSocket",t),a<u){const t=p(a);a++,setTimeout(d,t)}else o(t)}};d()}))}}class Z extends p{constructor(t){super(t,"/rules")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}execute(t,e,s){const r={objectIds:e,vars:s};return this.post(`/${t}/execute`,{payload:r})}}class tt extends p{constructor(t){super(t,"/definitions")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}}class et extends h{constructor(t={}){super(function(t){if(!t)throw new Error("zeno client serverUrl is required");return t}(t.serverUrl)),this.objects=new G(this),this.types=new K(this),this.workflows=new Q(this),this.files=new V(this),this.commands=new L(this),this.agents=new M(this),this.collections=new D(this),this.embeddings=new W(this),t.apikey&&this.withApiKey(t.apikey),this.onRequest=t.onRequest,this.onResponse=t.onResponse,this.errorFactory=t=>404===t.status?new J(t.request,t):t}withApiVersion(t){return t?this.headers[X]=String(t):delete this.headers[X],this}withApiKey(t){return this.withAuthCallback(t?()=>Promise.resolve(`Bearer ${t}`):void 0)}runOperation(t){return this.post("/api/v1/operations",{payload:t})}get initialHeaders(){return{...super.initialHeaders,[X]:Y}}}class st extends p{constructor(t){super(t,"/api/v1/training")}listSessions(t={}){return this.get("/",{query:t})}listSessionNames(t={}){return this.get("/names",{query:t})}createSession(t){return this.post("/",{payload:t})}getSession(t){return this.get("/"+t)}addToSession(t,e){return this.post("/"+t+"/add",{payload:{runs:e}})}listSessionRuns(t,e=100,s=0){return this.get("/"+t+"/runs",{query:{limit:e,offset:s}})}buildSession(t){return this.post("/"+t+"/build")}getDataUrl(t){return this.get("/"+t+"/url")}getDataUploadUrl(t,e=!1){return this.get("/"+t+"/upload-url",e?{query:{resumable:"true"}}:{})}startTraining(t){return this.post("/"+t+"/start")}cancelTraining(t){return this.post("/"+t+"/cancel")}getTrainingJob(t){return this.get(`/job/${t}`)}getAndSyncTrainingJob(t){return this.get(`/job/${t}`,{query:{sync:"true"}})}setDataset(t,e="default"){return this.post("/"+t+"/dataset",{payload:{dataset:e}})}}class rt extends p{constructor(t){super(t,"/api/v1/users")}retrieve(t){return this.get("/"+t)}}class nt extends h{static async fromAuthToken(t,e){e||(e=it(t));const s=ot(e.endpoints);return await new nt({serverUrl:s.studio,storeUrl:s.store,tokenServerUrl:e.iss}).withApiKey(t)}static decodeEndpoints(){}constructor(t={site:"api.vertesia.io"}){let e,s;if(t.serverUrl)e=t.serverUrl;else{if(!t.site)throw new Error("Parameter 'site' or 'serverUrl' is required for VertesiaClient");e=`https://${t.site}`}if(t.storeUrl)s=t.storeUrl;else{if(!t.site)throw new Error("Parameter 'site' or 'storeUrl' is required for VertesiaClient");s=`https://${t.site}`}if(super(e),this._jwt=null,this.projects=new j(this),this.environments=new v(this),this.interactions=new O(this),this.prompts=new N(this),this.runs=new F(this),this.account=new d(this),this.accounts=new g(this),this.apikeys=new m(this),this.analytics=new y(this),this.training=new st(this),this.users=new rt(this),this.iam=new $(this),this.refs=new C(this),this.commands=new w(this),this.apps=new f(this),t.tokenServerUrl)this.tokenServerUrl=t.tokenServerUrl;else if(t.site)this.tokenServerUrl=`https://${t.site.replace(/^api/,"sts")}`;else if(t.serverUrl||t.storeUrl){const e=t.serverUrl||t.storeUrl||"";try{const t=new URL(e);t.hostname.includes("-production.")?this.tokenServerUrl="https://sts.vertesia.io":t.hostname.includes("-preview.")?this.tokenServerUrl="https://sts-preview.vertesia.io":"api.vertesia.io"===t.hostname?this.tokenServerUrl="https://sts.vertesia.io":"api-preview.vertesia.io"===t.hostname?this.tokenServerUrl="https://sts-preview.vertesia.io":"api-staging.vertesia.io"===t.hostname?this.tokenServerUrl="https://sts-staging.vertesia.io":t.hostname.startsWith("api")?(t.hostname=t.hostname.replace(/^api/,"sts"),this.tokenServerUrl=t.toString()):this.tokenServerUrl="https://sts-staging.vertesia.io"}catch(t){this.tokenServerUrl="https://sts-staging.vertesia.io"}}else this.tokenServerUrl="https://sts-staging.vertesia.io";this.store=new et({serverUrl:s,tokenServerUrl:this.tokenServerUrl,apikey:t.apikey,onRequest:t.onRequest,onResponse:t.onResponse}),t.apikey&&this.withApiKey(t.apikey),this.onRequest=t.onRequest,this.onResponse=t.onResponse,this.sessionTags=t.sessionTags}withApiVersion(t){return t?this.headers[X]=String(t):delete this.headers[X],this}withAuthCallback(t){return this.store.withAuthCallback(t),super.withAuthCallback(t)}async withApiKey(t){return this.withAuthCallback(t?async()=>{if(!function(t){return t.startsWith("pk-")||t.startsWith("sk-")}(t))return`Bearer ${t}`;if(function(t){if(!t)return!0;const e=it(t).exp;return Date.now()<=1e3*e-6e4}(this._jwt)){const e=await this.getAuthToken(t);this._jwt=e.token}return`Bearer ${this._jwt}`}:void 0)}async getRawJWT(){if(!this._jwt&&this._auth){const t=await this._auth();this._jwt||(this._jwt=t.trim().split(" ")[1])}return this._jwt||null}async getDecodedJWT(){const t=await this.getRawJWT();return t?it(t):null}async getProject(){const t=await this.getDecodedJWT();return t?.project||null}async getAccount(){const t=await this.getDecodedJWT();return t?.account||null}get workflows(){return this.store.workflows}get objects(){return this.store.objects}get files(){return this.store.files}get types(){return this.store.types}get storeUrl(){return this.store.baseUrl}async getAuthToken(t){return fetch(`${this.tokenServerUrl}/token/issue`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}}).then((t=>t.json())).then((t=>t)).catch((t=>{throw console.error(`Error fetching token from ${this.tokenServerUrl}:`,{error:t}),t}))}get initialHeaders(){return{...super.initialHeaders,[X]:Y}}}function it(t){const e=function(t){const e=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(4*Math.ceil(t.length/4),"=");if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("utf-8");if("undefined"!=typeof atob&&"undefined"!=typeof TextDecoder){const t=atob(e),s=Uint8Array.from(t,(t=>t.charCodeAt(0)));return(new TextDecoder).decode(s)}throw new Error("No base64 decoder available")}(t.split(".")[1]);return JSON.parse(e)}function ot(t){return t?"string"==typeof t?at(t):t:at("api.vertesia.io")}function at(t){if("local"===t)return{studio:"http://localhost:8091",store:"http://localhost:8092",token:process.env.STS_URL??"https://sts-staging.vertesia.io"};{const e=`https://${t}`;return{studio:e,store:e,token:e.replace("api","sts")}}}class ut{constructor(t,e){this.id=t,this.client=e instanceof nt?e:new nt(e)}retrieve(){return this.client.interactions.retrieve(this.id)}update(t){return this.client.interactions.update(this.id,t)}render(t){}async execute(t={},e){return E(this.client,this.id,t,e)}}export{L as CommandsApi,q as IS_INTERACTION_OUTPUT,ut as InteractionBase,I as InteractionOutput,G as ObjectsApi,B as StreamSource,K as TypesApi,nt as VertesiaClient,Q as WorkflowsApi,tt as WorkflowsDefinitionApi,Z as WorkflowsRulesApi,et as ZenoClient,A as createInteractionOutput,ot as decodeEndpoints,it as decodeJWT,R as enhanceExecutionRun,U as enhanceInteractionExecutionResult};
|
|
1
|
+
import{ExecutionRunStatus as t,ContentObjectApiHeaders as e,AgentMessageType as s}from"@vertesia/common";class r extends Error{constructor(t,e,s,r,n=!0){super(function(t,e,s,r,n){let i=t;if(n){i+="\nRequest: "+e.method+" "+e.url+" => "+s;const t=r?.details||r?.error?.details;if(t){const e=typeof t;"string"===e?i+="\nDetails: "+t:"object"===e&&(i+="\nDetails: "+JSON.stringify(t,void 0,2))}i+="\nStack Trace: "}return i}(t,e,s,r,n)),this.original_message=t,this.request=e,this.status=s,this.payload=r,this.request_info=e.method+" "+e.url+" => "+s,this.displayDetails=n}get details(){return this.payload?.details||this.payload?.error?.details}}class n extends r{constructor(t,e,s,r,n=!0){super(t,e,s,r,n)}updateDetails(t){return t!==this.details?new n(this.original_message,this.request,this.status,{...this.payload,details:t},this.displayDetails):this}}class i extends r{constructor(t,e){super("Failed to connect to server: "+e.message,t,0,e)}}let o;if(globalThis.TextDecoderStream&&"function"==typeof globalThis.TextDecoderStream)o=globalThis.TextDecoderStream;else{class t extends TransformStream{constructor(t="utf-8",{fatal:s=!1,ignoreBOM:r=!1}={}){super(new e(new TextDecoder(t,{fatal:s,ignoreBOM:r}))),this._options={fatal:s,ignoreBOM:r,encoding:t}}get encoding(){return this._options.encoding}get fatal(){return this._options.fatal}get ignoreBOM(){return this._options.ignoreBOM}}class e{constructor(t){this.decoder=t}transform(t,e){if(!(t instanceof ArrayBuffer||ArrayBuffer.isView(t)))throw new TypeError("Input must be a compatible with: ArrayBuffer | Uint8Array");const s=this.decoder.decode(t,{stream:!0});0!==s.length&&e.enqueue(s)}flush(t){const e=this.decoder.decode();0!==e.length&&t.enqueue(e)}}o=t}const a=[239,187,191];class l extends TransformStream{constructor(){let t;super({start(e){t=function(t){let e,s,r,n,i,o,l;return u(),{feed:function(t){s=s?s+t:t,e&&function(t){return a.every((e,s)=>t.charCodeAt(s)===e)}(s)&&(s=s.slice(a.length)),e=!1;const i=s.length;let o=0,l=!1;for(;o<i;){l&&("\n"===s[o]&&++o,l=!1);let t,e=-1,a=n;for(let n=r;e<0&&n<i;++n)t=s[n],":"===t&&a<0?a=n-o:"\r"===t?(l=!0,e=n-o):"\n"===t&&(e=n-o);if(e<0){r=i-o,n=a;break}r=0,n=-1,c(s,o,a,e),o+=e+1}o===i?s="":o>0&&(s=s.slice(o))},reset:u};function u(){e=!0,s="",r=0,n=-1,i=void 0,o=void 0,l=""}function c(e,s,r,n){if(0===n)return l.length>0&&(t({type:"event",id:i,event:o||void 0,data:l.slice(0,-1)}),l="",i=void 0),void(o=void 0);const a=r<0,u=e.slice(s,s+(a?n:r));let c=0;c=a?n:" "===e[s+r+1]?r+2:r+1;const h=s+c,p=n-c,d=e.slice(h,h+p).toString();if("data"===u)l+=d?"".concat(d,"\n"):"\n";else if("event"===u)o=d;else if("id"!==u||d.includes("\0")){if("retry"===u){const e=parseInt(d,10);Number.isNaN(e)||t({type:"reconnect-interval",value:e})}}else i=d}}(t=>{"event"===t.type&&e.enqueue(t)})},transform(e){t.feed(e)}})}}function u(t){return"/"===t[t.length-1]?t.slice(0,-1):t}class c{constructor(t,e){this.errorFactory=t=>t,this.verboseErrors=!0,this.baseUrl=u(t),this._fetch=function(t){return t?Promise.resolve(t):"function"==typeof globalThis.fetch?Promise.resolve(globalThis.fetch):Promise.resolve(()=>{throw new Error("No Fetch implementation found")})}(e)}throwError(t){throw this.errorFactory(t)}getUrl(t){return u((e=this.baseUrl,s=t,e.endsWith("/")?s.startsWith("/")?e+s.substring(1):e+s:s.startsWith("/")?e+s:e+"/"+s));var e,s}get(t,e){return this.request("GET",t,e)}del(t,e){return this.request("DELETE",t,e)}delete(t,e){return this.request("DELETE",t,e)}post(t,e){return this.request("POST",t,e)}put(t,e){return this.request("PUT",t,e)}jsonParse(t){return JSON.parse(t)}createRequest(t,e){return Promise.resolve(new Request(t,e))}createServerError(t,e,s){let r="Server Error: "+e.status;return s&&(s.message?r=String(s.message):s.error&&("string"==typeof s.error?r=String(s.error):"string"==typeof s.error.message&&(r=String(s.error.message)))),new n(r,t,e.status,s,this.verboseErrors)}async readJSONPayload(t){return t.text().then(e=>{if(e)try{return this.jsonParse(e)}catch(s){return{status:t.status,error:"Not a valid JSON payload",message:s.message,text:e}}}).catch(e=>({status:t.status,error:"Unable to load response content",message:e.message}))}handleResponse(t,e,s){return e.url,s&&s.reader?"sse"===s.reader?async function(t){if(!t.ok){const e=await t.text(),s=new Error("SSE error: "+t.status+". Content:\n"+e);throw s.status=t.status,s}if(!t.body)throw new Error("No body in response");return t.body.pipeThrough(new o).pipeThrough(new l)}(e):s.reader.call(this,e):this.readJSONPayload(e).then(s=>{if(e.ok)return s;this.throwError(this.createServerError(t,e,s))})}async request(t,e,s){let r=this.getUrl(e);s?.query&&(r+="?"+function(t){const e=[];for(const s of Object.keys(t)){const r=t[s];null!=r&&e.push(encodeURIComponent(s)+"="+encodeURIComponent(String(r)))}return e.join("&")}(s.query));const n=this.headers?Object.assign({},this.headers):{},o=s?.headers;if(o)for(const t in o)n[t.toLowerCase()]=o[t];let a;const l=s?.payload;l&&(s&&!1===s.jsonPayload?a=l:(a="string"!=typeof l?JSON.stringify(l):l,"content-type"in n||(n["content-type"]="application/json")));const u={method:t,headers:n,body:a},c=await this.createRequest(r,u);return this._fetch.then(t=>t(c).catch(t=>{console.error(`Failed to connect to ${r}`,t),this.throwError(new i(c,t))}).then(t=>this.handleResponse(c,t,s)))}fetch(t,e){return this._fetch.then(s=>s(t,e))}}class h extends c{constructor(t,e){super(t,e),this.baseUrl="/"===t[t.length-1]?t.substring(0,t.length-1):t,this.headers=this.initialHeaders}get initialHeaders(){return{accept:"application/json"}}withAuthCallback(t){return this._auth=t||void 0,this}withErrorFactory(t){return this.errorFactory=t,this}withLang(t){return t?this.headers["accept-language"]=t:delete this.headers["accept-language"],this}withHeaders(t){const e=this.headers;for(const s in t){const r=t[s];null!=r&&(e[s.toLowerCase()]=r)}return this}setHeader(t,e){e?this.headers[t.toLowerCase()]=e:delete this.headers[t.toLowerCase()]}async createRequest(t,e){if(this._auth&&(!(s=e.headers)||!("authorization"in s))){const t=e.headers?e.headers:{};e.headers=t;const s=await this._auth();s&&(e.headers.authorization=s)}var s;this.response=void 0;const r=await super.createRequest(t,e);return this.onRequest&&this.onRequest(r),r}async handleResponse(t,e,s){return this.response=e,this.onResponse&&this.onResponse(e,t),super.handleResponse(t,e,s)}}class p extends c{constructor(t,e){super(t.getUrl(e),t._fetch),this.client=t,this.createServerError=t.createServerError,this.errorFactory=t.errorFactory,this.verboseErrors=t.verboseErrors}createRequest(t,e){return this.client.createRequest(t,e)}handleResponse(t,e,s){return this.client.handleResponse(t,e,s)}get headers(){return this.client.headers}}class d extends p{constructor(t){super(t,"/api/v1/account")}info(){return this.get("/")}update(t){return this.put("/",{payload:t})}projects(){return this.get("/projects").then(t=>t.data)}members(){return this.get("/members")}inviteUser(t){return this.post("/invites",{payload:t})}listInvites(){return this.get("/invites")}listInvitation(t="project"){return this.get(`/invites/${t}`)}acceptInvite(t){return this.put(`/invites/${t}`)}rejectInvite(t){return this.delete(`/invites/${t}`)}onboardingProgress(){return this.get("/onboarding")}getGoogleToken(){return this.get("/google-token")}getStripeBillingStatus(){return this.get("/stripe-billing-status")}}class g extends p{constructor(t){super(t,"/api/v1/accounts")}create(t){return this.post("/",{payload:{name:t}})}list(){return this.get("/")}}class y extends p{constructor(t){super(t,"/api/v1/analytics")}runs(t){return this.post("/runs",{payload:t})}}class f extends p{constructor(t){super(t,"/api/v1/apikeys")}list(t="account"){return this.get("/",{query:{level:t}})}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}retrieve(t,e=!1){return e?this.get(`/${t}`,{query:{withValue:!0}}):this.get(`/${t}`)}requestPublicKey(t={}){return this.get("/pk",{query:t})}}class m extends p{constructor(t){super(t,"/api/v1/apps")}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}listAppInstallationTools(t){return this.get(`/installations/${t}/tools`)}list(){return this.get("/")}install(t,e){return this.post("/install",{payload:{app_id:t,settings:e}})}uninstall(t){return this.del(`/install/${t}`)}getAppInstallationByName(t){return this.get(`/installations/name/${t}`).catch(t=>{if(404===t.status)return null;throw t})}getAppInstallationProjects(t){if(!t.id&&!t.name)throw new Error("Invalid arguments: appId or appName must be specified");const e=t.id?{id:t.id}:{name:t.name};return this.get("/installations/projects",{query:e})}getInstalledApps(t){return this.get("/installations",{query:{kind:t}})}getAllAppInstallations(){return this.get("/installations/all")}listInstallations(){return this.get("/installations/refs")}updateInstallationSettings(t){return this.put(`/installations/settings/${t.app_id}`,{payload:{app_id:t.app_id,settings:t.settings}})}}let w=class extends p{constructor(t){super(t,"/api/v1/commands")}async isNamespaceAvailable(t){return this.get(`/namespaces/${t}/is_available`).then(t=>t.available)}async initSamples(){return this.post("/onboarding/init-samples")}};class v extends p{constructor(t){super(t,"/api/v1/environments")}list(t=!1){const e=t?{all:!0}:void 0;return this.get("/",{query:e})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get("/"+t)}update(t,e){return this.put("/"+t,{payload:e})}updateConfig(t,e){return this.put("/"+t+"/config",{payload:e})}listModels(t,e){return this.get("/"+t+"/models",{query:e?{...e}:void 0})}listTrainableModels(t){return this.get(`/${t}/trainable-models`)}embeddings(t,e){return this.post("/"+t+"/embeddings",{payload:e})}}class $ extends p{constructor(t){super(t,"/groups")}list(t){return this.get("/",{query:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get("/"+t)}update(t,e){return this.put("/"+t,{payload:e})}delete(t){return this.del("/"+t)}listMembers(t){return this.get("/"+t+"/members")}addMember(t,e){return this.post("/"+t+"/members/"+e)}removeMember(t,e){return this.del("/"+t+"/members/"+e)}}class b extends p{constructor(t){super(t,"/api/v1/iam"),this.aces=new k(this),this.roles=new S(this),this.groups=new $(this)}}class S extends p{constructor(t){super(t,"/roles")}list(){return this.get("/")}}class k extends p{constructor(t){super(t,"/aces")}list(t){return this.get("/",{query:{...t}})}retrieve(t){return this.get("/"+t)}create(t){return this.post("/",{payload:t})}delete(t){return this.del("/"+t)}}async function x(){return"function"==typeof globalThis.EventSource?globalThis.EventSource:(await import("eventsource")).EventSource}async function E(e,s,r={},n){const i=!!n,o=await e.runs.create({...r,interaction:s,stream:i});if(i){if(o.status===t.failed)return o;await _(e,o.id,n)}return o}function _(t,e,s){return new Promise(async(r,n)=>{try{const i=await x(),o=new URL(t.runs.baseUrl+"/"+e+"/stream"),a=t._auth?await t._auth():void 0;if(!a)throw new Error("No auth token available");{const t=a.split(" ")[1];o.searchParams.set("access_token",t)}const l=new i(o.href);l.addEventListener("message",t=>{try{const e=JSON.parse(t.data);e&&s&&s(e)}catch(t){n(t)}}),l.addEventListener("close",t=>{try{l.close();const e=JSON.parse(t.data);r(e)}catch(t){n(t)}})}catch(t){n(t)}})}class T extends p{constructor(t){super(t,"/api/v1/interactions/catalog")}list(t={}){return this.get("/",{query:t})}listStoredInteractions(t={}){return this.get("/stored",{query:t})}listSysInteractions(t){return this.get("/sys",{query:{tag:t}})}listAppInteractions(t,e){return this.get(`/apps/${t}`,{query:{tag:e}})}listAllAppInteractions(t){return this.get("/apps",{query:{tag:t}})}resolve(t){return this.get(`/resolve/${t}`)}}const q=Symbol("InteractionOutput");function R(t){return t.result=I.from(t.result),t}function U(t){return t.result=I.from(t.result),t}class I{constructor(t){this.results=t}static from(t){return t?t[q]?t:Array.isArray(t)?A(t):A("object"==typeof t?[{type:"json",value:t}]:[{type:"text",value:String(t)}]):A([])}static isInteractionOutputArray(t){return t&&!0===t[q]}get isEmpty(){return 0===this.results.length}hasObject(){return this.results.some(t=>"json"===t.type)}hasText(){return this.results.some(t=>"text"===t.type)}hasImage(){return this.results.some(t=>"image"===t.type)}text(t="\n"){return this.results.filter(t=>"text"===t.type).map(t=>t.value).join(t)}texts(){return this.results.filter(t=>"text"===t.type).map(t=>t.value)}object(){const t=this.results.find(t=>"json"===t.type);return t?t.value:function(t){let e;for(const s of t)if("text"===s.type){const t=s.value.trim();try{return JSON.parse(t)}catch(t){e=t}}e||(e=new Error("No JSON result found and no text available to parse"));throw e}(this.results)}objects(){return this.results.filter(t=>"json"===t.type).map(t=>t.value)}objectAt(t){let e=0;for(const s of this.results)if("json"===s.type){if(e===t)return s.value;e++}throw new Error(`Object at index ${t} not found`)}image(){const t=this.results.find(t=>"image"===t.type);if(!t)throw new Error("No image result found");return t.value}images(){return this.results.filter(t=>"image"===t.type).map(t=>t.value)}stringify(t="\n",e=2){return this.results.map(t=>"json"===t.type?JSON.stringify(t.value,null,e):String(t.value)).join(t)}toString(){return this.text()}toJSON(){return this.results}}function A(t){const e=new I(t);return new Proxy(t,{get(t,s,r){if(s===q)return!0;if(s in e){const t=e[s];return"function"==typeof t?t.bind(e):t}return Reflect.get(t,s,r)}})}class O extends p{constructor(t){super(t,"/api/v1/interactions"),this.catalog=new T(t)}list(t={}){const e=t.query||{};return this.get("/",{query:{...e}})}listEndpoints(t){return this.post("/endpoints",{payload:t})}listVersionsByName(t){return this.get(`/versions/${t}`)}listTags(t){return this.get("/tags",{query:{...t}})}computeFacets(t){return this.post("/facets",{payload:t})}listNames(){return this.get("/names")}export(t){return this.post("/export",{payload:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}async execute(t,e={},s){return R(await E(this.client,t,e,s).catch(t=>{throw t instanceof n&&t.payload?.id?t.updateDetails({run_id:t.payload.id}):t}))}async executeByName(e,s={},r){const i=await async function(e,s,r={},n){const i=!!n,o=await e.post("/api/v1/execute",{payload:{...r,interaction:s,stream:i}});if(i){if(o.status===t.failed)return o;await _(e,o.id,n)}return o}(this.client,e,s,r).catch(t=>{throw t instanceof n&&t.payload?.id?t.updateDetails({run_id:t.payload.id}):t});return R(i)}executeAsync(t){return async function(t,e){return await t.post("/api/v1/execute/async",{payload:e})}(this.client,t)}publish(t,e){return this.post(`/${t}/publish`,{payload:e})}fork(t,e){return this.post(`/${t}/fork`,{payload:e})}generateInteraction(t,e){return this.post(`${t}/generate-interaction`,{payload:e})}generateTestData(t,e){return this.post(`${t}/generate-test-data`,{payload:e})}async suggestImprovements(t,e){return U(await this.post(`${t}/suggest-prompt-improvements`,{payload:e}))}async suggestPromptImprovements(t){return R(await this.post("/improve",{payload:t}))}listVersions(t){return this.get(`/${t}/versions`)}listForks(t){return this.get(`/${t}/forks`)}requestSlot(t){return async function(t,e){return await t.post("/api/v1/execute/rate-limit/request",{payload:e})}(this.client,t)}}class j extends p{constructor(t){super(t,"/api/v1/projects"),this.integrations=new P(this)}list(t){return this.get("/",{query:{account:t}})}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}updateConfiguration(t,e){return this.put(`/${t}/configuration`,{payload:e})}}class P extends p{constructor(t){super(t,"/")}list(t){return this.get(`/${t}/integrations`).then(t=>t.integrations)}retrieve(t,e){return this.get(`/${t}/integrations/${e}`).catch(t=>{if(404!==t.status)throw t})}update(t,e,s){return this.put(`/${t}/integrations/${e}`,{payload:s})}}class N extends p{constructor(t){super(t,"/api/v1/skills")}findRelevant(t,e){const s={context:t,limit:e};return this.post("/find-relevant",{payload:s})}findRelevantForTask(t,e){return this.findRelevant({task_description:t,tool_names:e})}}class C extends p{constructor(t){super(t,"/api/v1/prompts")}list(t={}){const e=t.query||{};return this.get("/",{query:{...e}})}computeFacets(t){return this.post("/facets",{payload:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}fork(t,e){return this.post(`/${t}/fork`,{payload:e})}render(t,e){return this.post(`/${t}/render`,{payload:e})}options(t){return this.get(`/options/${t}`)}listVersions(t){return this.get(`/${t}/versions`)}listInteractions(t){return this.get(`/${t}/interactions`)}listForks(t){return this.get(`/${t}/forks`)}}class F extends p{constructor(t){super(t,"/api/v1/refs")}resolve(t){return this.post("/resolve",{payload:{refs:t}})}}class M extends p{constructor(t){super(t,"/api/v1/runs")}list({limit:t,offset:e,filters:s}){const r={limit:t,offset:e,...s};return this.get("/",{query:r})}find(t){return this.post("/find",{payload:t})}async retrieve(t){return U(await this.get("/"+t))}retrievePopulated(t){return this.get("/"+t,{query:{populate:"true"}})}filterOptions(t,e){const s={...e};return this.get(`/filter-options/${t}`,{query:s})}async create(t){const e=this.client.sessionTags;if(e){let s=Array.isArray(e)?e:[e];Array.isArray(t.tags)?s=s.concat(t.tags):t.tags&&(s=s.concat([t.tags])),t={...t,tags:s}}return U(await this.post("/",{payload:t}))}sendToolResults(t){return this.post("/tool-results",{payload:t})}sendUserMessage(t){return this.post("/user-message",{payload:t})}createCheckpoint(t){return this.post("/checkpoint",{payload:t})}computeFacets(t){return this.post("/facets",{payload:t})}search(t){return this.post("/search",{payload:t})}}class D extends p{constructor(t){super(t,"/api/v1/agents")}async deploy(t){return this.post("/",{payload:t})}}class W extends p{constructor(t){super(t,"/api/v1/collections")}search(t){return this.post("/search",{payload:t})}computeListFacets(t){return this.post("/facets",{payload:t})}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}addMembers(t,e){return this.post(`/${t}/members`,{payload:{action:"add",members:e}})}listMembers(t,e){return this.get(`/${t}/members`,{query:{...e}})}computeFacets(t,e){return this.post(`/${t}/facets`,{payload:e})}searchMembers(t,e){return this.post(`/${t}/search`,{payload:e})}deleteMembers(t,e){return this.post(`/${t}/members`,{payload:{action:"delete",members:e}})}addChildren(t,e){return this.post(`/${t}/children`,{payload:{action:"add",children:e}})}deleteChildren(t,e){return this.post(`/${t}/children`,{payload:{action:"delete",children:e}})}searchChildren(t,e={}){return this.post(`/${t}/children/search`,{payload:e})}delete(t){return this.del(`/${t}`)}updatePermissions(t,e){return this.put(`/${t}/permissions`,{payload:e})}propagatePermissions(t){return this.post(`/${t}/propagate-permissions`)}propagateSharedProperties(t){return this.post(`/${t}/propagate-shared-props`)}}class L extends p{constructor(t,e="/api/v1/embeddings"){super(t,e)}async status(t){return this.get(t+"/status")}async activate(t,e){if(!e.environment)throw new Error("Invalid configuration: select environment");return this.post(t+"/enable",{payload:e})}async disable(t){return this.post(t+"/disable")}async recalculate(t){return this.post(t+"/recalculate")}}class B extends p{constructor(t){super(t,"/api/v1/commands"),this.embeddings=new L(this,"/embeddings")}}class J extends r{constructor(t,e){super("Resource not found: "+e.message,t,404,e.payload)}}class z{constructor(t,e,s,r){this.stream=t,this.name=e,this.type=s,this.id=r}}const V="memories",H="agents";function G(t){const e=t.endsWith(".tar.gz")?t:t+".tar.gz";return`${V}/${e}`}function K(t,e){return`${H}/${t}/${e}`}class Y extends p{constructor(t){super(t,"/api/v1/files")}async deleteFile(t,e){return(await this.delete(`/${t}`,{query:{prefix:e}})).count}getMetadata(t){return this.get("/metadata",{query:{file:t}})}setFileMetadata(t,e){const s={file:t,metadata:e};return this.put("/metadata",{payload:s})}getOrCreateBucket(){return this.post("/bucket")}getUploadUrl(t){return this.post("/upload-url",{payload:t})}getDownloadUrl(t,e,s){const r={file:t,name:e,disposition:s};return this.post("/download-url",{payload:r})}getDownloadUrlWithOptions(t){return this.post("/download-url",{payload:t})}async uploadFile(t){const e=t instanceof z,{url:s,id:r,path:n}=await this.getUploadUrl(t);return await fetch(s,{method:"PUT",body:e?t.stream:t,duplex:e?"half":void 0,headers:{"Content-Type":t.type||"application/gzip"}}).then(t=>{if(t.ok)return t;throw console.log(t),new Error(`Failed to upload file: ${t.statusText}`)}).catch(t=>{throw console.error("Failed to upload file",{err:t,url:s,id:r,path:n}),t}),r}async downloadFile(t){const e=!t.startsWith("https:"),{url:s}=e?await this.getDownloadUrl(t):{url:t},r=await fetch(s,{method:"GET"}).then(e=>{if(e.ok)return e;throw 404===e.status?new Error(`File at ${s} not found`):403===e.status?new Error(`File at ${s} is forbidden`):(console.log(e),new Error(`Failed to download file ${t}: ${e.statusText}`))}).catch(e=>{throw console.error(`Failed to download file ${t}.`,e),e});if(!r.body)throw new Error(`No body in response while downloading file ${t}`);return r.body}async uploadMemoryPack(t){const e=G(t.name),s=t.name.endsWith(".tar.gz")?t.name:t.name+".tar.gz";if(t instanceof File){let r=t;return this.uploadFile(new z(r.stream(),s,r.type,e))}return this.uploadFile(new z(t.stream,s,t.type,e))}async downloadMemoryPack(t,e=!1){let s=await this.downloadFile(G(t));if(e){const t=new DecompressionStream("gzip");s=s.pipeThrough(t)}return s}listByPrefix(t){return this.get("/list",{query:{prefix:t}})}async uploadArtifact(t,e,s){const r=K(t,e);if(s instanceof File){const t=s;return this.uploadFile(new z(t.stream(),e,t.type,r))}return this.uploadFile(new z(s.stream,e,s.type,r))}async downloadArtifact(t,e){const s=K(t,e);return this.downloadFile(s)}getArtifactDownloadUrl(t,e,s){const r=K(t,e);return this.getDownloadUrl(r,e,s)}async listArtifacts(t){const e=`${H}/${t}/`;return(await this.listByPrefix(e)).files}}class X extends p{constructor(t,e){super(t,`/${e}/analyze`),this.objectId=e}async start(t){return this.post("/",{payload:t})}async getStatus(){return this.get("/status")}async getResults(){return this.get("/results")}async adaptTables(t){return this.post("/adapt_tables",{payload:t})}async getAdaptedTables(t,e){const s=t?`/adapt_tables/${t}`:"/adapt_tables",r={};e?.format&&(r.format=e.format),void 0!==e?.raw&&(r.raw=e.raw);const n={query:r};return"csv"===e?.format&&(n.responseType="text"),this.get(s,n)}async getXml(){return this.get("/xml")}async getTables(t){const e={};return t&&(e.query={format:t}),this.get("/tables",e)}async getImages(){return this.get("/images")}async getAnnotated(){return this.get("/annotated")}}class Q extends p{constructor(t){super(t,"/api/v1/objects")}analyze(t){return new X(this,t)}getUploadUrl(t){return this.post("/upload-url",{payload:t})}getDownloadUrl(t,e,s){return this.post("/download-url",{payload:{file:t,name:e,disposition:s}})}getDownloadUrlWithOptions(t){return this.post("/download-url",{payload:t})}getContentSource(t){return this.get(`/${t}/content-source`)}list(t={}){const e=t.limit||100,s=t.offset||0,r=t.query||{};return this.get("/",{query:{limit:e,offset:s,...r,all_revisions:t.all_revisions,from_root:t.from_root||void 0}})}computeFacets(t){return this.post("/facets",{payload:t})}listFolders(t="/"){}find(t){return this.post("/find",{payload:t})}count(t){return this.post("/count",{payload:t})}search(t){return this.post("/search",{payload:t})}retrieve(t,e){return this.get(`/${t}`,{query:{select:e}})}getObjectText(t){return this.get(`/${t}/text`)}async upload(t){const e=t instanceof z,{url:s,id:r,mime_type:n}=await this.getUploadUrl({id:e?t.id:void 0,name:t.name,mime_type:t.type}),i=await fetch(s,{method:"PUT",body:e?t.stream:t,duplex:e?"half":void 0,headers:{"Content-Type":n||"application/octet-stream"}}).then(t=>{if(t.ok)return t;throw console.log(t),new Error(`Failed to upload file: ${t.statusText}`)}).catch(t=>{throw console.error("Failed to upload file",t),t}),o=i.headers.get("etag")?.replace(/^"(.*)"$/,"$1");return{source:r,name:t.name,type:n,etag:o}}async create(t,s){const r={...t};(t.content instanceof z||t.content instanceof File)&&(r.content=await this.upload(t.content));const n={};return s?.processing_priority&&(n[e.PROCESSING_PRIORITY]=s.processing_priority),s?.collection_id&&(n[e.COLLECTION_ID]=s.collection_id),await this.post("/",{payload:r,headers:n})}async createFromExternalSource(t,s={},r){const n=await this.client.files.getMetadata(t),i={...s,content:{source:t,name:n.name,type:n.contentType,etag:n.etag}},o={};return r?.processing_priority&&(o[e.PROCESSING_PRIORITY]=r.processing_priority),r?.collection_id&&(o[e.COLLECTION_ID]=r.collection_id),await this.post("/",{payload:i,headers:o})}async update(t,s,r){const n={...s};(s.content instanceof z||s.content instanceof File)&&(n.content=await this.upload(s.content));const i={};return r?.processing_priority&&(i[e.PROCESSING_PRIORITY]=r.processing_priority),r?.createRevision&&(i[e.CREATE_REVISION]="true",r.revisionLabel&&(i[e.REVISION_LABEL]=r.revisionLabel)),this.put(`/${t}`,{payload:n,headers:i})}getRevisions(t){return this.get(`/${t}/revisions`)}getCollections(t){return this.get(`/${t}/collections`)}delete(t){return this.del(`/${t}`)}listWorkflowRuns(t){return this.get(`/${t}/workflow-runs`)}listRenditions(t){return this.get(`/${t}/renditions`)}getRendition(t,e){const s={max_hw:e.max_hw,generate_if_missing:e.generate_if_missing,sign_url:e.sign_url,block_on_generation:e.block_on_generation};return this.get(`/${t}/renditions/${e.format}`,{query:s})}exportProperties(t){return this.post("/export",{payload:t})}setEmbedding(t,e,s){return this.put(`/${t}/embeddings/${e}`,{payload:s})}}class Z extends p{constructor(t){super(t,"/api/v1/types")}list(t={},e){const s=t.limit||2e3,r=t.offset||0,n=t.query||{};return this.get("/",{query:{limit:s,offset:r,layout:!!e?.layout,schema:!!e?.schema,...n}})}find(t){return this.post("/find",{payload:t})}retrieve(t){return this.get(`/${t}`)}getTypeByName(t){return this.get(`/name/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}}const tt="20250925",et="x-api-version";class st extends p{constructor(t){super(t,"/api/v1/workflows"),this.rules=new rt(this),this.definitions=new nt(this)}getActivityCatalog(){return this.get("/activity-catalog")}listRuns(t,e,s){return this.post("/runs",{payload:{documentId:t,eventName:e,ruleId:s}})}listConversations(t){return this.post("/conversations",{payload:t})}searchRuns(t){return this.post("/runs",{payload:t})}sendSignal(t,e,s,r){return this.post(`/runs/${t}/${e}/signal/${s}`,{payload:r})}getRunDetails(t,e,s=!1){const r={include_history:s};return this.get(`/runs/${e}/${t}`,{query:r})}getRunInteraction(t,e){return this.get(`/runs/${t}/${e}/interaction`)}terminate(t,e,s){const r={reason:s};return this.post(`/runs/${t}/${e}/actions/terminate`,{payload:r})}cancel(t,e,s){const r={reason:s};return this.post(`/runs/${t}/${e}/actions/cancel`,{payload:r})}execute(t,e={}){return this.post(`/execute/${t}`,{payload:e})}postMessage(t,e){if(!t)throw new Error("runId is required");return this.post(`/runs/${t}/updates`,{payload:e})}retrieveMessages(t,e,s){const r={since:s};return this.get(`/runs/${t}/${e}/updates`,{query:r})}async streamMessages(t,e,r,n){return new Promise((i,o)=>{let a=0,l=n||0,u=!1,c=null,h=null;const p=10,d=t=>{const e=Math.min(1e3*Math.pow(2,t),3e4);return e+.1*Math.random()*e},g=()=>{h&&(clearInterval(h),h=null),c&&(c.close(),c=null)},y=t=>{u||(u=!0,g(),i(t))},f=async(n=!1)=>{if(!u)try{const m=await x(),w=this.client,v=new URL(w.workflows.baseUrl+`/runs/${t}/${e}/stream`);l>0&&v.searchParams.set("since",l.toString());const $=w._auth?await w._auth():void 0;if(!$)return void o(new Error("No auth token available"));const b=$.split(" ")[1];v.searchParams.set("access_token",b),n&&console.log(`Reconnecting to SSE stream for run ${e} (attempt ${a+1}/10)`);const S=new m(v.href);c=S,h=setInterval(()=>{},1e3),S.onopen=()=>{n&&console.log(`Successfully reconnected to SSE stream for run ${e}`),a=0},S.onmessage=t=>{if(t.data&&!t.data.startsWith(":"))try{const e=JSON.parse(t.data);e.timestamp&&(l=Math.max(l,e.timestamp)),r&&r(e,y);e.type===s.TERMINATED||e.type===s.COMPLETE&&(!e.workstream_id||"main"===e.workstream_id)?(console.log("Closing stream due to COMPLETE message from main workstream"),u||(u=!0,g(),i(null))):e.type===s.COMPLETE&&console.log(`Received COMPLETE message from non-main workstream: ${e.workstream_id||"unknown"}, keeping stream open`)}catch(e){console.error("Failed to parse SSE message:",e,t.data)}else console.log("Received comment or heartbeat; ignoring it.: ",t.data)},S.onerror=t=>{if(!u)if(console.warn(`SSE stream error for run ${e}:`,t),g(),a<p){const t=d(a);console.log(`Attempting to reconnect in ${t}ms (attempt ${a+1}/10)`),a++,setTimeout(()=>{u||f(!0)},t)}else console.error(`Failed to reconnect to SSE stream for run ${e} after 10 attempts`),u=!0,o(new Error("SSE connection failed after 10 reconnection attempts"))}}catch(t){if(console.error("Error setting up SSE stream:",t),a<p){const t=d(a);a++,setTimeout(()=>{u||f(!0)},t)}else o(t)}};return f(!1),()=>{u=!0,g()}})}async streamMessagesWS(t,e,r,n){return new Promise((i,o)=>{let a=0;const l=10;let u=null,c=n||0,h=!1;const p=t=>{const e=Math.min(1e3*Math.pow(2,t),3e4);return e+.1*Math.random()*e},d=async()=>{if(!h)try{const n=this.client,g=new URL(n.workflows.baseUrl+`/runs/${t}/${e}/ws`);g.protocol=g.protocol.replace("http","ws"),c>0&&g.searchParams.set("since",c.toString());const y=n._auth?await n._auth():void 0;if(!y)return void o(new Error("No auth token available"));const f=y.split(" ")[1];g.searchParams.set("access_token",f),a>0&&console.log(`Reconnecting to WebSocket for run ${e} (attempt ${a+1}/10)`),u=new WebSocket(g.href),u.onopen=()=>{a>0&&console.log(`Successfully reconnected to WebSocket for run ${e}`),a=0,h||i({cleanup:()=>{h=!0,u&&(u.close(),u=null)},sendSignal:(t,e)=>{if(u?.readyState===WebSocket.OPEN){const s={type:"signal",signalName:t,data:e,requestId:Date.now()};u.send(JSON.stringify(s))}else console.warn("WebSocket not open, cannot send signal")}})},u.onmessage=t=>{try{const e=JSON.parse(t.data);if("workflow_run_id"in e){const t=e;t.timestamp&&(c=Math.max(c,t.timestamp)),r&&r(t);(t.type===s.TERMINATED||t.type===s.COMPLETE&&(!t.workstream_id||"main"===t.workstream_id))&&(console.log("Closing WebSocket due to workflow completion"),h=!0,u&&(u.close(),u=null))}else"pong"===e.type?console.debug("Received pong"):"ack"===e.type?console.debug("Signal acknowledged",e):"error"===e.type&&console.error("WebSocket error message",e)}catch(t){console.error("Failed to parse WebSocket message",t)}},u.onerror=t=>{console.error("WebSocket error",t)},u.onclose=()=>{if(!h&&a<l){const t=p(a);console.log(`WebSocket closed, reconnecting in ${t}ms (attempt ${a+1}/10)`),a++,setTimeout(d,t)}else a>=l&&o(new Error("WebSocket connection failed after 10 attempts"))}}catch(t){if(console.error("Error setting up WebSocket",t),a<l){const t=p(a);a++,setTimeout(d,t)}else o(t)}};d()})}}class rt extends p{constructor(t){super(t,"/rules")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}execute(t,e,s){const r={objectIds:e,vars:s};return this.post(`/${t}/execute`,{payload:r})}}class nt extends p{constructor(t){super(t,"/definitions")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}}class it extends h{constructor(t={}){super(function(t){if(!t)throw new Error("zeno client serverUrl is required");return t}(t.serverUrl)),this.objects=new Q(this),this.types=new Z(this),this.workflows=new st(this),this.files=new Y(this),this.commands=new B(this),this.agents=new D(this),this.collections=new W(this),this.embeddings=new L(this),t.apikey&&this.withApiKey(t.apikey),this.onRequest=t.onRequest,this.onResponse=t.onResponse,this.errorFactory=t=>404===t.status?new J(t.request,t):t}withApiVersion(t){return t?this.headers[et]=String(t):delete this.headers[et],this}withApiKey(t){return this.withAuthCallback(t?()=>Promise.resolve(`Bearer ${t}`):void 0)}runOperation(t){return this.post("/api/v1/operations",{payload:t})}get initialHeaders(){return{...super.initialHeaders,[et]:tt}}}class ot extends p{constructor(t){super(t,"/api/v1/training")}listSessions(t={}){return this.get("/",{query:t})}listSessionNames(t={}){return this.get("/names",{query:t})}createSession(t){return this.post("/",{payload:t})}getSession(t){return this.get("/"+t)}addToSession(t,e){return this.post("/"+t+"/add",{payload:{runs:e}})}listSessionRuns(t,e=100,s=0){return this.get("/"+t+"/runs",{query:{limit:e,offset:s}})}buildSession(t){return this.post("/"+t+"/build")}getDataUrl(t){return this.get("/"+t+"/url")}getDataUploadUrl(t,e=!1){return this.get("/"+t+"/upload-url",e?{query:{resumable:"true"}}:{})}startTraining(t){return this.post("/"+t+"/start")}cancelTraining(t){return this.post("/"+t+"/cancel")}getTrainingJob(t){return this.get(`/job/${t}`)}getAndSyncTrainingJob(t){return this.get(`/job/${t}`,{query:{sync:"true"}})}setDataset(t,e="default"){return this.post("/"+t+"/dataset",{payload:{dataset:e}})}}class at extends p{constructor(t){super(t,"/api/v1/users")}retrieve(t){return this.get("/"+t)}}class lt extends h{static async fromAuthToken(t,e){e||(e=ut(t));const s=ct(e.endpoints);return await new lt({serverUrl:s.studio,storeUrl:s.store,tokenServerUrl:e.iss}).withApiKey(t)}static decodeEndpoints(){}constructor(t={site:"api.vertesia.io"}){let e,s;if(t.serverUrl)e=t.serverUrl;else{if(!t.site)throw new Error("Parameter 'site' or 'serverUrl' is required for VertesiaClient");e=`https://${t.site}`}if(t.storeUrl)s=t.storeUrl;else{if(!t.site)throw new Error("Parameter 'site' or 'storeUrl' is required for VertesiaClient");s=`https://${t.site}`}if(super(e),this._jwt=null,this.projects=new j(this),this.environments=new v(this),this.interactions=new O(this),this.skills=new N(this),this.prompts=new C(this),this.runs=new M(this),this.account=new d(this),this.accounts=new g(this),this.apikeys=new f(this),this.analytics=new y(this),this.training=new ot(this),this.users=new at(this),this.iam=new b(this),this.refs=new F(this),this.commands=new w(this),this.apps=new m(this),t.tokenServerUrl)this.tokenServerUrl=t.tokenServerUrl;else if(t.site)this.tokenServerUrl=`https://${t.site.replace(/^api/,"sts")}`;else if(t.serverUrl||t.storeUrl){const e=t.serverUrl||t.storeUrl||"";try{const t=new URL(e);t.hostname.includes("-production.")||t.hostname.includes("-preview.")||"api.vertesia.io"===t.hostname||"api-preview.vertesia.io"===t.hostname?this.tokenServerUrl="https://sts.vertesia.io":"api-staging.vertesia.io"===t.hostname?this.tokenServerUrl="https://sts-staging.vertesia.io":t.hostname.startsWith("api")?(t.hostname=t.hostname.replace(/^api/,"sts"),this.tokenServerUrl=t.toString()):this.tokenServerUrl="https://sts-staging.vertesia.io"}catch(t){this.tokenServerUrl="https://sts-staging.vertesia.io"}}else this.tokenServerUrl="https://sts-staging.vertesia.io";this.store=new it({serverUrl:s,tokenServerUrl:this.tokenServerUrl,apikey:t.apikey,onRequest:t.onRequest,onResponse:t.onResponse}),t.apikey&&this.withApiKey(t.apikey),this.onRequest=t.onRequest,this.onResponse=t.onResponse,this.sessionTags=t.sessionTags}withApiVersion(t){return t?this.headers[et]=String(t):delete this.headers[et],this}withAuthCallback(t){return this.store.withAuthCallback(t),super.withAuthCallback(t)}async withApiKey(t){return this.withAuthCallback(t?async()=>{if(!function(t){return t.startsWith("pk-")||t.startsWith("sk-")}(t))return`Bearer ${t}`;if(function(t){if(!t)return!0;const e=ut(t).exp;return Date.now()<=1e3*e-6e4}(this._jwt)){const e=await this.getAuthToken(t);this._jwt=e.token}return`Bearer ${this._jwt}`}:void 0)}async getRawJWT(){if(!this._jwt&&this._auth){const t=await this._auth();this._jwt||(this._jwt=t.trim().split(" ")[1])}return this._jwt||null}async getDecodedJWT(){const t=await this.getRawJWT();return t?ut(t):null}async getProject(){const t=await this.getDecodedJWT();return t?.project||null}async getAccount(){const t=await this.getDecodedJWT();return t?.account||null}get workflows(){return this.store.workflows}get objects(){return this.store.objects}get files(){return this.store.files}get types(){return this.store.types}get storeUrl(){return this.store.baseUrl}async getAuthToken(t){return fetch(`${this.tokenServerUrl}/token/issue`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}}).then(t=>t.json()).then(t=>t).catch(t=>{throw console.error(`Error fetching token from ${this.tokenServerUrl}:`,{error:t}),t})}get initialHeaders(){return{...super.initialHeaders,[et]:tt}}}function ut(t){const e=function(t){const e=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(4*Math.ceil(t.length/4),"=");if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("utf-8");if("undefined"!=typeof atob&&"undefined"!=typeof TextDecoder){const t=atob(e),s=Uint8Array.from(t,t=>t.charCodeAt(0));return(new TextDecoder).decode(s)}throw new Error("No base64 decoder available")}(t.split(".")[1]);return JSON.parse(e)}function ct(t){return t?"string"==typeof t?ht(t):t:ht("api.vertesia.io")}function ht(t){if("local"===t)return{studio:"http://localhost:8091",store:"http://localhost:8092",token:process.env.STS_URL??"https://sts-staging.vertesia.io"};{const e=`https://${t}`;return{studio:e,store:e,token:e.replace("api","sts")}}}class pt{constructor(t,e){this.id=t,this.client=e instanceof lt?e:new lt(e)}retrieve(){return this.client.interactions.retrieve(this.id)}update(t){return this.client.interactions.update(this.id,t)}render(t){}async execute(t={},e){return E(this.client,this.id,t,e)}}export{H as ARTIFACTS_PREFIX,B as CommandsApi,Y as FilesApi,q as IS_INTERACTION_OUTPUT,pt as InteractionBase,I as InteractionOutput,V as MEMORIES_PREFIX,Q as ObjectsApi,z as StreamSource,Z as TypesApi,lt as VertesiaClient,st as WorkflowsApi,nt as WorkflowsDefinitionApi,rt as WorkflowsRulesApi,it as ZenoClient,A as createInteractionOutput,ct as decodeEndpoints,ut as decodeJWT,U as enhanceExecutionRun,R as enhanceInteractionExecutionResult,K as getAgentArtifactPath,G as getMemoryFilePath};
|
|
2
2
|
//# sourceMappingURL=vertesia-client.js.map
|