@nebulaos/client 0.1.0 → 0.1.2
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/index.d.mts +1 -4
- package/dist/index.d.ts +1 -4
- package/dist/index.js +170 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +199 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -25
package/dist/index.d.mts
CHANGED
|
@@ -595,9 +595,6 @@ declare class DBMemory implements IMemory {
|
|
|
595
595
|
declare class PromptCapture {
|
|
596
596
|
}
|
|
597
597
|
|
|
598
|
-
declare class RAGClient {
|
|
599
|
-
}
|
|
600
|
-
|
|
601
598
|
declare class ClientError extends Error {
|
|
602
599
|
readonly code: string;
|
|
603
600
|
readonly statusCode: number;
|
|
@@ -626,4 +623,4 @@ declare class InstrumentedHttpClient implements IHttpClient {
|
|
|
626
623
|
post<T = unknown>(url: string, body?: unknown, options?: Omit<HttpRequestOptions, "method" | "body">): Promise<HttpResponse<T>>;
|
|
627
624
|
}
|
|
628
625
|
|
|
629
|
-
export { type AgentFactory, type AgentOrFactory, AuthenticationError, Batcher, type ClientConfig, ClientError, ConnectionError, DBMemory, HttpDomainEventsExporter, type HttpDomainEventsExporterConfig, type HttpRequestOptions, HttpTelemetryExporter, type HttpTelemetryExporterConfig, InstrumentedHttpClient, NebulaClient, NotFoundError, type OTelTracingClientConfig, type OTelTracingConfig, OTelTracingProvider, PromptCapture,
|
|
626
|
+
export { type AgentFactory, type AgentOrFactory, AuthenticationError, Batcher, type ClientConfig, ClientError, ConnectionError, DBMemory, HttpDomainEventsExporter, type HttpDomainEventsExporterConfig, type HttpRequestOptions, HttpTelemetryExporter, type HttpTelemetryExporterConfig, InstrumentedHttpClient, NebulaClient, NotFoundError, type OTelTracingClientConfig, type OTelTracingConfig, OTelTracingProvider, PromptCapture, RegistryError, type ServerConfig, SocketTelemetryExporter, type SocketTelemetryExporterConfig, TelemetryService, clientConfigSchema, otelTracingConfigSchema, serverConfigSchema, setupOTelTracing };
|
package/dist/index.d.ts
CHANGED
|
@@ -595,9 +595,6 @@ declare class DBMemory implements IMemory {
|
|
|
595
595
|
declare class PromptCapture {
|
|
596
596
|
}
|
|
597
597
|
|
|
598
|
-
declare class RAGClient {
|
|
599
|
-
}
|
|
600
|
-
|
|
601
598
|
declare class ClientError extends Error {
|
|
602
599
|
readonly code: string;
|
|
603
600
|
readonly statusCode: number;
|
|
@@ -626,4 +623,4 @@ declare class InstrumentedHttpClient implements IHttpClient {
|
|
|
626
623
|
post<T = unknown>(url: string, body?: unknown, options?: Omit<HttpRequestOptions, "method" | "body">): Promise<HttpResponse<T>>;
|
|
627
624
|
}
|
|
628
625
|
|
|
629
|
-
export { type AgentFactory, type AgentOrFactory, AuthenticationError, Batcher, type ClientConfig, ClientError, ConnectionError, DBMemory, HttpDomainEventsExporter, type HttpDomainEventsExporterConfig, type HttpRequestOptions, HttpTelemetryExporter, type HttpTelemetryExporterConfig, InstrumentedHttpClient, NebulaClient, NotFoundError, type OTelTracingClientConfig, type OTelTracingConfig, OTelTracingProvider, PromptCapture,
|
|
626
|
+
export { type AgentFactory, type AgentOrFactory, AuthenticationError, Batcher, type ClientConfig, ClientError, ConnectionError, DBMemory, HttpDomainEventsExporter, type HttpDomainEventsExporterConfig, type HttpRequestOptions, HttpTelemetryExporter, type HttpTelemetryExporterConfig, InstrumentedHttpClient, NebulaClient, NotFoundError, type OTelTracingClientConfig, type OTelTracingConfig, OTelTracingProvider, PromptCapture, RegistryError, type ServerConfig, SocketTelemetryExporter, type SocketTelemetryExporterConfig, TelemetryService, clientConfigSchema, otelTracingConfigSchema, serverConfigSchema, setupOTelTracing };
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
8
11
|
var __export = (target, all) => {
|
|
9
12
|
for (var name in all)
|
|
10
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,6 +30,172 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
30
|
));
|
|
28
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
32
|
|
|
33
|
+
// ../rag-openai-skill/dist/ClientContext.js
|
|
34
|
+
var require_ClientContext = __commonJS({
|
|
35
|
+
"../rag-openai-skill/dist/ClientContext.js"(exports2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
38
|
+
exports2.ClientContext = void 0;
|
|
39
|
+
var ClientContextManager = class {
|
|
40
|
+
apiKey;
|
|
41
|
+
serverUrl;
|
|
42
|
+
setApiKey(apiKey) {
|
|
43
|
+
this.apiKey = apiKey;
|
|
44
|
+
}
|
|
45
|
+
setServerUrl(url) {
|
|
46
|
+
this.serverUrl = url;
|
|
47
|
+
}
|
|
48
|
+
getApiKey() {
|
|
49
|
+
return this.apiKey;
|
|
50
|
+
}
|
|
51
|
+
getServerUrl() {
|
|
52
|
+
return this.serverUrl;
|
|
53
|
+
}
|
|
54
|
+
clear() {
|
|
55
|
+
this.apiKey = void 0;
|
|
56
|
+
this.serverUrl = void 0;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports2.ClientContext = new ClientContextManager();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// ../rag-openai-skill/dist/RagOpenAISkill.js
|
|
64
|
+
var require_RagOpenAISkill = __commonJS({
|
|
65
|
+
"../rag-openai-skill/dist/RagOpenAISkill.js"(exports2) {
|
|
66
|
+
"use strict";
|
|
67
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
68
|
+
exports2.RagOpenAISkill = void 0;
|
|
69
|
+
var core_1 = require("@nebulaos/core");
|
|
70
|
+
var ClientContext_js_1 = require_ClientContext();
|
|
71
|
+
var RagOpenAISkill = class {
|
|
72
|
+
config;
|
|
73
|
+
constructor(config) {
|
|
74
|
+
const apiKey = config.apiKey || ClientContext_js_1.ClientContext.getApiKey();
|
|
75
|
+
const apiEndpoint = config.apiEndpoint || ClientContext_js_1.ClientContext.getServerUrl() || "https://api.nebulaos.com";
|
|
76
|
+
this.config = {
|
|
77
|
+
connectionId: config.connectionId,
|
|
78
|
+
apiKey: apiKey || "",
|
|
79
|
+
// Will be validated in initialize
|
|
80
|
+
apiEndpoint,
|
|
81
|
+
timeout: config.timeout || 3e4,
|
|
82
|
+
maxResults: config.maxResults,
|
|
83
|
+
minScore: config.minScore
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Optional initialization - validates configuration
|
|
88
|
+
*/
|
|
89
|
+
async initialize() {
|
|
90
|
+
if (!this.config.connectionId) {
|
|
91
|
+
throw new Error("RagOpenAISkill: connectionId is required");
|
|
92
|
+
}
|
|
93
|
+
if (!this.config.apiKey) {
|
|
94
|
+
const contextApiKey = ClientContext_js_1.ClientContext.getApiKey();
|
|
95
|
+
if (contextApiKey) {
|
|
96
|
+
this.config.apiKey = contextApiKey;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (!this.config.apiKey) {
|
|
100
|
+
throw new Error("RagOpenAISkill: apiKey is required. Make sure your agent is registered with a NebulaClient that has server.apiKey configured.");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Returns the vector store search tool
|
|
105
|
+
*/
|
|
106
|
+
getTools() {
|
|
107
|
+
const toolId = `search_vector_store_${this.config.connectionId.slice(-8)}`;
|
|
108
|
+
return [
|
|
109
|
+
new core_1.Tool({
|
|
110
|
+
id: toolId,
|
|
111
|
+
description: `Search through the knowledge base using semantic search. Returns relevant documents and information based on the query.`,
|
|
112
|
+
inputSchema: core_1.z.object({
|
|
113
|
+
query: core_1.z.string().describe("The search query or question to find relevant information"),
|
|
114
|
+
maxResults: core_1.z.number().optional().describe("Maximum number of results to return (overrides default)"),
|
|
115
|
+
minScore: core_1.z.number().min(0).max(1).optional().describe("Minimum relevance score threshold (0-1, overrides default)")
|
|
116
|
+
}),
|
|
117
|
+
handler: async (ctx, input) => {
|
|
118
|
+
return this.searchVectorStore(input.query, {
|
|
119
|
+
maxResults: input.maxResults,
|
|
120
|
+
minScore: input.minScore
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
];
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Optional instructions for the agent on how to use the RAG tool
|
|
128
|
+
*/
|
|
129
|
+
getInstructions() {
|
|
130
|
+
return `You have access to a knowledge base search tool. Use it whenever you need to:
|
|
131
|
+
- Find specific information or documentation
|
|
132
|
+
- Answer questions that require domain knowledge
|
|
133
|
+
- Retrieve relevant context before responding
|
|
134
|
+
|
|
135
|
+
The search results include relevance scores. Prioritize higher-scoring results when formulating your response.`;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Search the vector store via NebulaOS Cloud API
|
|
139
|
+
*/
|
|
140
|
+
async searchVectorStore(query, options = {}) {
|
|
141
|
+
const url = `${this.config.apiEndpoint}/rag-openai/search`;
|
|
142
|
+
const requestBody = {
|
|
143
|
+
connectionId: this.config.connectionId,
|
|
144
|
+
query,
|
|
145
|
+
maxResults: options.maxResults ?? this.config.maxResults,
|
|
146
|
+
minScore: options.minScore ?? this.config.minScore
|
|
147
|
+
};
|
|
148
|
+
try {
|
|
149
|
+
const controller = new AbortController();
|
|
150
|
+
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
151
|
+
const response = await fetch(url, {
|
|
152
|
+
method: "POST",
|
|
153
|
+
headers: {
|
|
154
|
+
"Content-Type": "application/json",
|
|
155
|
+
Authorization: `Bearer ${this.config.apiKey}`
|
|
156
|
+
},
|
|
157
|
+
body: JSON.stringify(requestBody),
|
|
158
|
+
signal: controller.signal
|
|
159
|
+
});
|
|
160
|
+
clearTimeout(timeoutId);
|
|
161
|
+
if (!response.ok) {
|
|
162
|
+
const errorText = await response.text();
|
|
163
|
+
throw new Error(`RAG search failed: ${response.status} ${response.statusText}. ${errorText}`);
|
|
164
|
+
}
|
|
165
|
+
const data = await response.json();
|
|
166
|
+
return data;
|
|
167
|
+
} catch (error) {
|
|
168
|
+
if (error instanceof Error) {
|
|
169
|
+
if (error.name === "AbortError") {
|
|
170
|
+
throw new Error(`RAG search timeout after ${this.config.timeout}ms`);
|
|
171
|
+
}
|
|
172
|
+
throw new Error(`RAG search error: ${error.message}`);
|
|
173
|
+
}
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
exports2.RagOpenAISkill = RagOpenAISkill;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// ../rag-openai-skill/dist/index.js
|
|
183
|
+
var require_dist = __commonJS({
|
|
184
|
+
"../rag-openai-skill/dist/index.js"(exports2) {
|
|
185
|
+
"use strict";
|
|
186
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
187
|
+
exports2.ClientContext = exports2.RagOpenAISkill = void 0;
|
|
188
|
+
var RagOpenAISkill_js_1 = require_RagOpenAISkill();
|
|
189
|
+
Object.defineProperty(exports2, "RagOpenAISkill", { enumerable: true, get: function() {
|
|
190
|
+
return RagOpenAISkill_js_1.RagOpenAISkill;
|
|
191
|
+
} });
|
|
192
|
+
var ClientContext_js_1 = require_ClientContext();
|
|
193
|
+
Object.defineProperty(exports2, "ClientContext", { enumerable: true, get: function() {
|
|
194
|
+
return ClientContext_js_1.ClientContext;
|
|
195
|
+
} });
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
|
|
30
199
|
// src/index.ts
|
|
31
200
|
var index_exports = {};
|
|
32
201
|
__export(index_exports, {
|
|
@@ -42,7 +211,6 @@ __export(index_exports, {
|
|
|
42
211
|
NotFoundError: () => NotFoundError,
|
|
43
212
|
OTelTracingProvider: () => OTelTracingProvider,
|
|
44
213
|
PromptCapture: () => PromptCapture,
|
|
45
|
-
RAGClient: () => RAGClient,
|
|
46
214
|
RegistryError: () => RegistryError,
|
|
47
215
|
SocketTelemetryExporter: () => SocketTelemetryExporter,
|
|
48
216
|
TelemetryService: () => TelemetryService,
|
|
@@ -1693,7 +1861,7 @@ var NebulaClient = class {
|
|
|
1693
1861
|
*/
|
|
1694
1862
|
setGlobalClientContext(apiKey, serverUrl) {
|
|
1695
1863
|
try {
|
|
1696
|
-
|
|
1864
|
+
Promise.resolve().then(() => __toESM(require_dist())).then((module2) => {
|
|
1697
1865
|
if (module2.ClientContext) {
|
|
1698
1866
|
module2.ClientContext.setApiKey(apiKey);
|
|
1699
1867
|
module2.ClientContext.setServerUrl(serverUrl);
|
|
@@ -1789,10 +1957,6 @@ var DBMemory = class {
|
|
|
1789
1957
|
// src/prompts/prompt-capture.ts
|
|
1790
1958
|
var PromptCapture = class {
|
|
1791
1959
|
};
|
|
1792
|
-
|
|
1793
|
-
// src/rag/rag-client.ts
|
|
1794
|
-
var RAGClient = class {
|
|
1795
|
-
};
|
|
1796
1960
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1797
1961
|
0 && (module.exports = {
|
|
1798
1962
|
AuthenticationError,
|
|
@@ -1807,7 +1971,6 @@ var RAGClient = class {
|
|
|
1807
1971
|
NotFoundError,
|
|
1808
1972
|
OTelTracingProvider,
|
|
1809
1973
|
PromptCapture,
|
|
1810
|
-
RAGClient,
|
|
1811
1974
|
RegistryError,
|
|
1812
1975
|
SocketTelemetryExporter,
|
|
1813
1976
|
TelemetryService,
|