@nebulaos/client 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,3 +1,201 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
32
+
33
+ // ../rag-openai-skill/dist/ClientContext.js
34
+ var require_ClientContext = __commonJS({
35
+ "../rag-openai-skill/dist/ClientContext.js"(exports) {
36
+ "use strict";
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.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
+ exports.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"(exports) {
66
+ "use strict";
67
+ Object.defineProperty(exports, "__esModule", { value: true });
68
+ exports.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
+ exports.RagOpenAISkill = RagOpenAISkill;
179
+ }
180
+ });
181
+
182
+ // ../rag-openai-skill/dist/index.js
183
+ var require_dist = __commonJS({
184
+ "../rag-openai-skill/dist/index.js"(exports) {
185
+ "use strict";
186
+ Object.defineProperty(exports, "__esModule", { value: true });
187
+ exports.ClientContext = exports.RagOpenAISkill = void 0;
188
+ var RagOpenAISkill_js_1 = require_RagOpenAISkill();
189
+ Object.defineProperty(exports, "RagOpenAISkill", { enumerable: true, get: function() {
190
+ return RagOpenAISkill_js_1.RagOpenAISkill;
191
+ } });
192
+ var ClientContext_js_1 = require_ClientContext();
193
+ Object.defineProperty(exports, "ClientContext", { enumerable: true, get: function() {
194
+ return ClientContext_js_1.ClientContext;
195
+ } });
196
+ }
197
+ });
198
+
1
199
  // src/config/client-config.ts
2
200
  import { z } from "zod";
3
201
  var serverConfigSchema = z.object({
@@ -1640,7 +1838,7 @@ var NebulaClient = class {
1640
1838
  */
1641
1839
  setGlobalClientContext(apiKey, serverUrl) {
1642
1840
  try {
1643
- import("@nebulaos/rag-openai-skill").then((module) => {
1841
+ Promise.resolve().then(() => __toESM(require_dist())).then((module) => {
1644
1842
  if (module.ClientContext) {
1645
1843
  module.ClientContext.setApiKey(apiKey);
1646
1844
  module.ClientContext.setServerUrl(serverUrl);
@@ -1736,10 +1934,6 @@ var DBMemory = class {
1736
1934
  // src/prompts/prompt-capture.ts
1737
1935
  var PromptCapture = class {
1738
1936
  };
1739
-
1740
- // src/rag/rag-client.ts
1741
- var RAGClient = class {
1742
- };
1743
1937
  export {
1744
1938
  AuthenticationError,
1745
1939
  Batcher,
@@ -1753,7 +1947,6 @@ export {
1753
1947
  NotFoundError,
1754
1948
  OTelTracingProvider,
1755
1949
  PromptCapture,
1756
- RAGClient,
1757
1950
  RegistryError,
1758
1951
  SocketTelemetryExporter,
1759
1952
  TelemetryService,