@realtimex/sdk 1.5.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-LM2TBHZ3.mjs +651 -0
- package/dist/errors-DXKB6v1J.d.mts +435 -0
- package/dist/errors-DXKB6v1J.d.ts +435 -0
- package/dist/index.d.mts +36 -1
- package/dist/index.d.ts +36 -1
- package/dist/index.js +676 -0
- package/dist/index.mjs +46 -0
- package/dist/v1/index.d.mts +117 -0
- package/dist/v1/index.d.ts +117 -0
- package/dist/v1/index.js +814 -0
- package/dist/v1/index.mjs +154 -0
- package/package.json +11 -3
- package/skills/realtimex-moderator-sdk/SKILL.md +28 -3
- package/skills/realtimex-moderator-sdk/references/api-reference.md +369 -2
- package/skills/realtimex-moderator-sdk/references/credentials.md +111 -0
- package/skills/realtimex-moderator-sdk/references/known-issues.md +1 -1
- package/skills/realtimex-moderator-sdk/scripts/lib/sdk-init.js +1 -1
- package/skills/realtimex-moderator-sdk/scripts/rtx.js +15 -2
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthenticationError,
|
|
3
|
+
DeveloperApiClient,
|
|
4
|
+
DeveloperApiError,
|
|
5
|
+
NotFoundError,
|
|
6
|
+
ServerError,
|
|
7
|
+
V1ApiNamespace,
|
|
8
|
+
ValidationError
|
|
9
|
+
} from "./chunk-LM2TBHZ3.mjs";
|
|
10
|
+
|
|
1
11
|
// src/modules/api.ts
|
|
2
12
|
var PermissionDeniedError = class extends Error {
|
|
3
13
|
constructor(permission, message, code = "PERMISSION_DENIED") {
|
|
@@ -2916,6 +2926,33 @@ var AuthModule = class {
|
|
|
2916
2926
|
}
|
|
2917
2927
|
};
|
|
2918
2928
|
|
|
2929
|
+
// src/modules/credentials.ts
|
|
2930
|
+
var CredentialsModule = class {
|
|
2931
|
+
constructor(httpClient) {
|
|
2932
|
+
this.httpClient = httpClient;
|
|
2933
|
+
}
|
|
2934
|
+
/** List available credentials (names and types, no values). */
|
|
2935
|
+
async list() {
|
|
2936
|
+
const response = await this.httpClient.fetch("/sdk/credentials");
|
|
2937
|
+
const data = await response.json();
|
|
2938
|
+
if (!response.ok) {
|
|
2939
|
+
throw new Error(data?.error || "Failed to list credentials");
|
|
2940
|
+
}
|
|
2941
|
+
return data.credentials || [];
|
|
2942
|
+
}
|
|
2943
|
+
/** Get a credential's decrypted payload by name. */
|
|
2944
|
+
async get(name) {
|
|
2945
|
+
const response = await this.httpClient.fetch(
|
|
2946
|
+
`/sdk/credentials/${encodeURIComponent(name)}`
|
|
2947
|
+
);
|
|
2948
|
+
const data = await response.json();
|
|
2949
|
+
if (!response.ok) {
|
|
2950
|
+
throw new Error(data?.error || `Failed to get credential: ${name}`);
|
|
2951
|
+
}
|
|
2952
|
+
return data.credential;
|
|
2953
|
+
}
|
|
2954
|
+
};
|
|
2955
|
+
|
|
2919
2956
|
// src/core/auth/AuthProvider.ts
|
|
2920
2957
|
var StaticAuthProvider = class {
|
|
2921
2958
|
constructor(options = {}) {
|
|
@@ -3613,6 +3650,8 @@ var _RealtimeXSDK = class _RealtimeXSDK {
|
|
|
3613
3650
|
});
|
|
3614
3651
|
this.database = new DatabaseModule(this.realtimexUrl, this.appId, this.apiKey);
|
|
3615
3652
|
this.auth = new AuthModule(this.realtimexUrl, this.appId, this.apiKey);
|
|
3653
|
+
this.credentials = new CredentialsModule(this.httpClient);
|
|
3654
|
+
this.v1 = this.apiKey || this.appId ? new V1ApiNamespace(this.realtimexUrl, this.apiKey ?? "", this.appId || void 0) : void 0;
|
|
3616
3655
|
if (this.permissions.length > 0 && this.appId && !this.apiKey) {
|
|
3617
3656
|
this.register().catch((err) => {
|
|
3618
3657
|
console.error("[RealtimeX SDK] Auto-registration failed:", err.message);
|
|
@@ -3722,6 +3761,7 @@ export {
|
|
|
3722
3761
|
AgentModule,
|
|
3723
3762
|
ApiModule,
|
|
3724
3763
|
AuthModule,
|
|
3764
|
+
AuthenticationError,
|
|
3725
3765
|
CONTRACT_ATTEMPT_PREFIX,
|
|
3726
3766
|
CONTRACT_EVENT_ID_HEADER,
|
|
3727
3767
|
CONTRACT_SIGNATURE_ALGORITHM,
|
|
@@ -3736,12 +3776,15 @@ export {
|
|
|
3736
3776
|
ContractRuntime,
|
|
3737
3777
|
ContractValidationError,
|
|
3738
3778
|
DatabaseModule,
|
|
3779
|
+
DeveloperApiClient,
|
|
3780
|
+
DeveloperApiError,
|
|
3739
3781
|
GeminiToolAdapter,
|
|
3740
3782
|
LLMModule,
|
|
3741
3783
|
LLMPermissionError,
|
|
3742
3784
|
LLMProviderError,
|
|
3743
3785
|
LOCAL_APP_CONTRACT_VERSION,
|
|
3744
3786
|
MCPModule,
|
|
3787
|
+
NotFoundError,
|
|
3745
3788
|
PermissionDeniedError,
|
|
3746
3789
|
PermissionRequiredError,
|
|
3747
3790
|
PortModule,
|
|
@@ -3751,12 +3794,15 @@ export {
|
|
|
3751
3794
|
STTModule,
|
|
3752
3795
|
ScopeDeniedError,
|
|
3753
3796
|
ScopeGuard,
|
|
3797
|
+
ServerError,
|
|
3754
3798
|
StaticAuthProvider,
|
|
3755
3799
|
TTSModule,
|
|
3756
3800
|
TaskModule,
|
|
3757
3801
|
ToolNotFoundError,
|
|
3758
3802
|
ToolProjector,
|
|
3759
3803
|
ToolValidationError,
|
|
3804
|
+
V1ApiNamespace,
|
|
3805
|
+
ValidationError,
|
|
3760
3806
|
VectorStore,
|
|
3761
3807
|
WebhookModule,
|
|
3762
3808
|
buildContractIdempotencyKey,
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { D as DeveloperApiClient } from '../errors-DXKB6v1J.mjs';
|
|
2
|
+
export { A as AuthenticationError, a as DeveloperApiError, N as NotFoundError, S as ServerError, d as V1AdminModule, V as V1ApiNamespace, c as V1AuthModule, e as V1DocumentModule, k as V1EmbedModule, j as V1OpenAIModule, g as V1SystemModule, h as V1ThreadModule, i as V1UsersModule, f as V1WorkspaceModule, b as ValidationError } from '../errors-DXKB6v1J.mjs';
|
|
3
|
+
|
|
4
|
+
interface WorkspaceStreamChunk {
|
|
5
|
+
/** The text fragment emitted by this SSE event */
|
|
6
|
+
textResponse: string;
|
|
7
|
+
/** Unique identifier for this chat session */
|
|
8
|
+
id: string;
|
|
9
|
+
/** Human-readable source references used for this response, if any */
|
|
10
|
+
sources: Array<{
|
|
11
|
+
id: string;
|
|
12
|
+
url?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
score?: number;
|
|
15
|
+
}>;
|
|
16
|
+
/** Whether this is the final chunk in the stream */
|
|
17
|
+
close: boolean;
|
|
18
|
+
/** Error message, present only when the server emits an error event */
|
|
19
|
+
error: string | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Execute a streamable chat with a workspace and yield typed SSE chunks.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const sdk = new RealtimeXSDK({ realtimex: { apiKey: 'sk-...' } });
|
|
27
|
+
* for await (const chunk of streamWorkspaceChat(sdk.v1!._client, 'my-workspace', { message: 'Hello' })) {
|
|
28
|
+
* process.stdout.write(chunk.textResponse);
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare function streamWorkspaceChat(client: DeveloperApiClient, slug: string, body?: Record<string, unknown>): AsyncGenerator<WorkspaceStreamChunk, void, unknown>;
|
|
33
|
+
|
|
34
|
+
interface ThreadStreamChunk {
|
|
35
|
+
/** The text fragment emitted by this SSE event */
|
|
36
|
+
textResponse: string;
|
|
37
|
+
/** Unique identifier for this chat session */
|
|
38
|
+
id: string;
|
|
39
|
+
/** Human-readable source references used for this response, if any */
|
|
40
|
+
sources: Array<{
|
|
41
|
+
id: string;
|
|
42
|
+
url?: string;
|
|
43
|
+
title?: string;
|
|
44
|
+
score?: number;
|
|
45
|
+
}>;
|
|
46
|
+
/** Whether this is the final chunk in the stream */
|
|
47
|
+
close: boolean;
|
|
48
|
+
/** Error message, present only when the server emits an error event */
|
|
49
|
+
error: string | null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Execute a streamable chat with a workspace thread and yield typed SSE chunks.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const sdk = new RealtimeXSDK({ realtimex: { apiKey: 'sk-...' } });
|
|
57
|
+
* for await (const chunk of streamThreadChat(sdk.v1!._client, 'my-workspace', 'my-thread', { message: 'Hello' })) {
|
|
58
|
+
* process.stdout.write(chunk.textResponse);
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
declare function streamThreadChat(client: DeveloperApiClient, slug: string, threadSlug: string, body?: Record<string, unknown>): AsyncGenerator<ThreadStreamChunk, void, unknown>;
|
|
63
|
+
|
|
64
|
+
interface UploadedDocument {
|
|
65
|
+
/** Whether the upload succeeded */
|
|
66
|
+
success: boolean;
|
|
67
|
+
/** Parsed document metadata returned by the server */
|
|
68
|
+
document?: {
|
|
69
|
+
id: string;
|
|
70
|
+
name: string;
|
|
71
|
+
location: string;
|
|
72
|
+
url: string | null;
|
|
73
|
+
title: string | null;
|
|
74
|
+
docAuthor: string | null;
|
|
75
|
+
description: string | null;
|
|
76
|
+
docSource: string | null;
|
|
77
|
+
chunkSource: string | null;
|
|
78
|
+
published: string | null;
|
|
79
|
+
wordCount: number;
|
|
80
|
+
token_count_estimate: number;
|
|
81
|
+
createdAt: string;
|
|
82
|
+
pinnedWorkspaces: string[];
|
|
83
|
+
canWatch: boolean;
|
|
84
|
+
};
|
|
85
|
+
/** Server-level error message when success is false */
|
|
86
|
+
error?: string | null;
|
|
87
|
+
}
|
|
88
|
+
interface UploadFileOptions {
|
|
89
|
+
/**
|
|
90
|
+
* Override the filename sent in the multipart form.
|
|
91
|
+
* Defaults to the `name` property of the `File` / `Blob`.
|
|
92
|
+
*/
|
|
93
|
+
filename?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Upload a `File` or `Blob` to the root documents directory.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* const sdk = new RealtimeXSDK({ realtimex: { apiKey: 'sk-...' } });
|
|
101
|
+
* const result = await uploadFile(sdk.v1!._client, myFile);
|
|
102
|
+
* console.log(result.document?.location);
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
declare function uploadFile(client: DeveloperApiClient, file: File | Blob, options?: UploadFileOptions): Promise<UploadedDocument>;
|
|
106
|
+
/**
|
|
107
|
+
* Upload a `File` or `Blob` to a specific folder (created automatically if absent).
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* const sdk = new RealtimeXSDK({ realtimex: { apiKey: 'sk-...' } });
|
|
112
|
+
* const result = await uploadFileToFolder(sdk.v1!._client, myFile, 'contracts');
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
declare function uploadFileToFolder(client: DeveloperApiClient, file: File | Blob, folderName: string, options?: UploadFileOptions): Promise<UploadedDocument>;
|
|
116
|
+
|
|
117
|
+
export { DeveloperApiClient, type ThreadStreamChunk, type UploadFileOptions, type UploadedDocument, type WorkspaceStreamChunk, streamThreadChat, streamWorkspaceChat, uploadFile, uploadFileToFolder };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { D as DeveloperApiClient } from '../errors-DXKB6v1J.js';
|
|
2
|
+
export { A as AuthenticationError, a as DeveloperApiError, N as NotFoundError, S as ServerError, d as V1AdminModule, V as V1ApiNamespace, c as V1AuthModule, e as V1DocumentModule, k as V1EmbedModule, j as V1OpenAIModule, g as V1SystemModule, h as V1ThreadModule, i as V1UsersModule, f as V1WorkspaceModule, b as ValidationError } from '../errors-DXKB6v1J.js';
|
|
3
|
+
|
|
4
|
+
interface WorkspaceStreamChunk {
|
|
5
|
+
/** The text fragment emitted by this SSE event */
|
|
6
|
+
textResponse: string;
|
|
7
|
+
/** Unique identifier for this chat session */
|
|
8
|
+
id: string;
|
|
9
|
+
/** Human-readable source references used for this response, if any */
|
|
10
|
+
sources: Array<{
|
|
11
|
+
id: string;
|
|
12
|
+
url?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
score?: number;
|
|
15
|
+
}>;
|
|
16
|
+
/** Whether this is the final chunk in the stream */
|
|
17
|
+
close: boolean;
|
|
18
|
+
/** Error message, present only when the server emits an error event */
|
|
19
|
+
error: string | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Execute a streamable chat with a workspace and yield typed SSE chunks.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const sdk = new RealtimeXSDK({ realtimex: { apiKey: 'sk-...' } });
|
|
27
|
+
* for await (const chunk of streamWorkspaceChat(sdk.v1!._client, 'my-workspace', { message: 'Hello' })) {
|
|
28
|
+
* process.stdout.write(chunk.textResponse);
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare function streamWorkspaceChat(client: DeveloperApiClient, slug: string, body?: Record<string, unknown>): AsyncGenerator<WorkspaceStreamChunk, void, unknown>;
|
|
33
|
+
|
|
34
|
+
interface ThreadStreamChunk {
|
|
35
|
+
/** The text fragment emitted by this SSE event */
|
|
36
|
+
textResponse: string;
|
|
37
|
+
/** Unique identifier for this chat session */
|
|
38
|
+
id: string;
|
|
39
|
+
/** Human-readable source references used for this response, if any */
|
|
40
|
+
sources: Array<{
|
|
41
|
+
id: string;
|
|
42
|
+
url?: string;
|
|
43
|
+
title?: string;
|
|
44
|
+
score?: number;
|
|
45
|
+
}>;
|
|
46
|
+
/** Whether this is the final chunk in the stream */
|
|
47
|
+
close: boolean;
|
|
48
|
+
/** Error message, present only when the server emits an error event */
|
|
49
|
+
error: string | null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Execute a streamable chat with a workspace thread and yield typed SSE chunks.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const sdk = new RealtimeXSDK({ realtimex: { apiKey: 'sk-...' } });
|
|
57
|
+
* for await (const chunk of streamThreadChat(sdk.v1!._client, 'my-workspace', 'my-thread', { message: 'Hello' })) {
|
|
58
|
+
* process.stdout.write(chunk.textResponse);
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
declare function streamThreadChat(client: DeveloperApiClient, slug: string, threadSlug: string, body?: Record<string, unknown>): AsyncGenerator<ThreadStreamChunk, void, unknown>;
|
|
63
|
+
|
|
64
|
+
interface UploadedDocument {
|
|
65
|
+
/** Whether the upload succeeded */
|
|
66
|
+
success: boolean;
|
|
67
|
+
/** Parsed document metadata returned by the server */
|
|
68
|
+
document?: {
|
|
69
|
+
id: string;
|
|
70
|
+
name: string;
|
|
71
|
+
location: string;
|
|
72
|
+
url: string | null;
|
|
73
|
+
title: string | null;
|
|
74
|
+
docAuthor: string | null;
|
|
75
|
+
description: string | null;
|
|
76
|
+
docSource: string | null;
|
|
77
|
+
chunkSource: string | null;
|
|
78
|
+
published: string | null;
|
|
79
|
+
wordCount: number;
|
|
80
|
+
token_count_estimate: number;
|
|
81
|
+
createdAt: string;
|
|
82
|
+
pinnedWorkspaces: string[];
|
|
83
|
+
canWatch: boolean;
|
|
84
|
+
};
|
|
85
|
+
/** Server-level error message when success is false */
|
|
86
|
+
error?: string | null;
|
|
87
|
+
}
|
|
88
|
+
interface UploadFileOptions {
|
|
89
|
+
/**
|
|
90
|
+
* Override the filename sent in the multipart form.
|
|
91
|
+
* Defaults to the `name` property of the `File` / `Blob`.
|
|
92
|
+
*/
|
|
93
|
+
filename?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Upload a `File` or `Blob` to the root documents directory.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* const sdk = new RealtimeXSDK({ realtimex: { apiKey: 'sk-...' } });
|
|
101
|
+
* const result = await uploadFile(sdk.v1!._client, myFile);
|
|
102
|
+
* console.log(result.document?.location);
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
declare function uploadFile(client: DeveloperApiClient, file: File | Blob, options?: UploadFileOptions): Promise<UploadedDocument>;
|
|
106
|
+
/**
|
|
107
|
+
* Upload a `File` or `Blob` to a specific folder (created automatically if absent).
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* const sdk = new RealtimeXSDK({ realtimex: { apiKey: 'sk-...' } });
|
|
112
|
+
* const result = await uploadFileToFolder(sdk.v1!._client, myFile, 'contracts');
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
declare function uploadFileToFolder(client: DeveloperApiClient, file: File | Blob, folderName: string, options?: UploadFileOptions): Promise<UploadedDocument>;
|
|
116
|
+
|
|
117
|
+
export { DeveloperApiClient, type ThreadStreamChunk, type UploadFileOptions, type UploadedDocument, type WorkspaceStreamChunk, streamThreadChat, streamWorkspaceChat, uploadFile, uploadFileToFolder };
|