@nebulaos/client 0.1.2 → 0.1.3
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/LICENSE.txt +21 -0
- package/dist/index.d.mts +79 -28
- package/dist/index.d.ts +79 -28
- package/dist/index.js +7 -187
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -216
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -17
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present, iamkun
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.mts
CHANGED
|
@@ -186,34 +186,6 @@ declare const clientConfigSchema: z.ZodObject<{
|
|
|
186
186
|
}>;
|
|
187
187
|
type ClientConfig = z.infer<typeof clientConfigSchema>;
|
|
188
188
|
|
|
189
|
-
declare class NebulaClient {
|
|
190
|
-
private readonly config;
|
|
191
|
-
private readonly registry;
|
|
192
|
-
private readonly serverConnection?;
|
|
193
|
-
private readonly telemetryExporter?;
|
|
194
|
-
private readonly domainEventsExporter?;
|
|
195
|
-
private readonly logger?;
|
|
196
|
-
constructor(config: ClientConfig);
|
|
197
|
-
registerAgent(agent: Parameters<Registry["registerAgent"]>[0]): void;
|
|
198
|
-
registerTool(tool: Parameters<Registry["registerTool"]>[0]): void;
|
|
199
|
-
registerWorkflow(workflow: Parameters<Registry["registerWorkflow"]>[0]): void;
|
|
200
|
-
start(): Promise<void>;
|
|
201
|
-
stop(): Promise<void>;
|
|
202
|
-
getClientId(): string | undefined;
|
|
203
|
-
isConnected(): boolean;
|
|
204
|
-
/**
|
|
205
|
-
* Sets global client context for skills to access API key and server URL
|
|
206
|
-
* This allows skills like RagOpenAISkill to automatically use the client's credentials
|
|
207
|
-
*/
|
|
208
|
-
private setGlobalClientContext;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
declare class TelemetryService {
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
declare class Batcher {
|
|
215
|
-
}
|
|
216
|
-
|
|
217
189
|
/**
|
|
218
190
|
* WebSocket Event Types for NebulaOS Client-Server Communication
|
|
219
191
|
*/
|
|
@@ -328,6 +300,61 @@ interface ClientToServerEvents {
|
|
|
328
300
|
"command:response": (response: CommandResponse) => void;
|
|
329
301
|
"command:error": (error: CommandError) => void;
|
|
330
302
|
"telemetry:batch": (payload: unknown) => void;
|
|
303
|
+
"memory:addMessage": (payload: {
|
|
304
|
+
featureKey: string;
|
|
305
|
+
memoryKey: string;
|
|
306
|
+
message: unknown;
|
|
307
|
+
maxMessages?: number;
|
|
308
|
+
}, callback: (response: {
|
|
309
|
+
success: boolean;
|
|
310
|
+
error?: string;
|
|
311
|
+
}) => void) => void;
|
|
312
|
+
"memory:getMessages": (payload: {
|
|
313
|
+
featureKey: string;
|
|
314
|
+
memoryKey: string;
|
|
315
|
+
}, callback: (response: {
|
|
316
|
+
success: boolean;
|
|
317
|
+
messages?: unknown[];
|
|
318
|
+
error?: string;
|
|
319
|
+
}) => void) => void;
|
|
320
|
+
"memory:clear": (payload: {
|
|
321
|
+
featureKey: string;
|
|
322
|
+
memoryKey: string;
|
|
323
|
+
}, callback: (response: {
|
|
324
|
+
success: boolean;
|
|
325
|
+
error?: string;
|
|
326
|
+
}) => void) => void;
|
|
327
|
+
"memory:setState": (payload: {
|
|
328
|
+
featureKey: string;
|
|
329
|
+
memoryKey: string;
|
|
330
|
+
key: string;
|
|
331
|
+
value: unknown;
|
|
332
|
+
}, callback: (response: {
|
|
333
|
+
success: boolean;
|
|
334
|
+
error?: string;
|
|
335
|
+
}) => void) => void;
|
|
336
|
+
"memory:getState": (payload: {
|
|
337
|
+
featureKey: string;
|
|
338
|
+
memoryKey: string;
|
|
339
|
+
key: string;
|
|
340
|
+
}, callback: (response: {
|
|
341
|
+
success: boolean;
|
|
342
|
+
value?: unknown;
|
|
343
|
+
error?: string;
|
|
344
|
+
}) => void) => void;
|
|
345
|
+
"memory:deleteState": (payload: {
|
|
346
|
+
featureKey: string;
|
|
347
|
+
memoryKey: string;
|
|
348
|
+
key: string;
|
|
349
|
+
}, callback: (response: {
|
|
350
|
+
success: boolean;
|
|
351
|
+
error?: string;
|
|
352
|
+
}) => void) => void;
|
|
353
|
+
"telemetry:client_metric": (payload: {
|
|
354
|
+
metric: string;
|
|
355
|
+
value: number;
|
|
356
|
+
attributes?: Record<string, string>;
|
|
357
|
+
}) => void;
|
|
331
358
|
}
|
|
332
359
|
/**
|
|
333
360
|
* WebSocket server-to-client events
|
|
@@ -339,6 +366,30 @@ interface ServerToClientEvents {
|
|
|
339
366
|
"command:execute:tool": (payload: ToolCommandPayload) => void;
|
|
340
367
|
}
|
|
341
368
|
|
|
369
|
+
declare class NebulaClient {
|
|
370
|
+
private readonly config;
|
|
371
|
+
private readonly registry;
|
|
372
|
+
private readonly serverConnection?;
|
|
373
|
+
private readonly telemetryExporter?;
|
|
374
|
+
private readonly domainEventsExporter?;
|
|
375
|
+
private readonly logger?;
|
|
376
|
+
constructor(config: ClientConfig);
|
|
377
|
+
registerAgent(agent: Parameters<Registry["registerAgent"]>[0]): void;
|
|
378
|
+
registerTool(tool: Parameters<Registry["registerTool"]>[0]): void;
|
|
379
|
+
registerWorkflow(workflow: Parameters<Registry["registerWorkflow"]>[0]): void;
|
|
380
|
+
start(): Promise<void>;
|
|
381
|
+
stop(): Promise<void>;
|
|
382
|
+
getClientId(): string | undefined;
|
|
383
|
+
isConnected(): boolean;
|
|
384
|
+
getSocket(): Socket<ServerToClientEvents, ClientToServerEvents> | undefined;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
declare class TelemetryService {
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
declare class Batcher {
|
|
391
|
+
}
|
|
392
|
+
|
|
342
393
|
interface ServerConnectionConfig {
|
|
343
394
|
url: string;
|
|
344
395
|
apiKey: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -186,34 +186,6 @@ declare const clientConfigSchema: z.ZodObject<{
|
|
|
186
186
|
}>;
|
|
187
187
|
type ClientConfig = z.infer<typeof clientConfigSchema>;
|
|
188
188
|
|
|
189
|
-
declare class NebulaClient {
|
|
190
|
-
private readonly config;
|
|
191
|
-
private readonly registry;
|
|
192
|
-
private readonly serverConnection?;
|
|
193
|
-
private readonly telemetryExporter?;
|
|
194
|
-
private readonly domainEventsExporter?;
|
|
195
|
-
private readonly logger?;
|
|
196
|
-
constructor(config: ClientConfig);
|
|
197
|
-
registerAgent(agent: Parameters<Registry["registerAgent"]>[0]): void;
|
|
198
|
-
registerTool(tool: Parameters<Registry["registerTool"]>[0]): void;
|
|
199
|
-
registerWorkflow(workflow: Parameters<Registry["registerWorkflow"]>[0]): void;
|
|
200
|
-
start(): Promise<void>;
|
|
201
|
-
stop(): Promise<void>;
|
|
202
|
-
getClientId(): string | undefined;
|
|
203
|
-
isConnected(): boolean;
|
|
204
|
-
/**
|
|
205
|
-
* Sets global client context for skills to access API key and server URL
|
|
206
|
-
* This allows skills like RagOpenAISkill to automatically use the client's credentials
|
|
207
|
-
*/
|
|
208
|
-
private setGlobalClientContext;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
declare class TelemetryService {
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
declare class Batcher {
|
|
215
|
-
}
|
|
216
|
-
|
|
217
189
|
/**
|
|
218
190
|
* WebSocket Event Types for NebulaOS Client-Server Communication
|
|
219
191
|
*/
|
|
@@ -328,6 +300,61 @@ interface ClientToServerEvents {
|
|
|
328
300
|
"command:response": (response: CommandResponse) => void;
|
|
329
301
|
"command:error": (error: CommandError) => void;
|
|
330
302
|
"telemetry:batch": (payload: unknown) => void;
|
|
303
|
+
"memory:addMessage": (payload: {
|
|
304
|
+
featureKey: string;
|
|
305
|
+
memoryKey: string;
|
|
306
|
+
message: unknown;
|
|
307
|
+
maxMessages?: number;
|
|
308
|
+
}, callback: (response: {
|
|
309
|
+
success: boolean;
|
|
310
|
+
error?: string;
|
|
311
|
+
}) => void) => void;
|
|
312
|
+
"memory:getMessages": (payload: {
|
|
313
|
+
featureKey: string;
|
|
314
|
+
memoryKey: string;
|
|
315
|
+
}, callback: (response: {
|
|
316
|
+
success: boolean;
|
|
317
|
+
messages?: unknown[];
|
|
318
|
+
error?: string;
|
|
319
|
+
}) => void) => void;
|
|
320
|
+
"memory:clear": (payload: {
|
|
321
|
+
featureKey: string;
|
|
322
|
+
memoryKey: string;
|
|
323
|
+
}, callback: (response: {
|
|
324
|
+
success: boolean;
|
|
325
|
+
error?: string;
|
|
326
|
+
}) => void) => void;
|
|
327
|
+
"memory:setState": (payload: {
|
|
328
|
+
featureKey: string;
|
|
329
|
+
memoryKey: string;
|
|
330
|
+
key: string;
|
|
331
|
+
value: unknown;
|
|
332
|
+
}, callback: (response: {
|
|
333
|
+
success: boolean;
|
|
334
|
+
error?: string;
|
|
335
|
+
}) => void) => void;
|
|
336
|
+
"memory:getState": (payload: {
|
|
337
|
+
featureKey: string;
|
|
338
|
+
memoryKey: string;
|
|
339
|
+
key: string;
|
|
340
|
+
}, callback: (response: {
|
|
341
|
+
success: boolean;
|
|
342
|
+
value?: unknown;
|
|
343
|
+
error?: string;
|
|
344
|
+
}) => void) => void;
|
|
345
|
+
"memory:deleteState": (payload: {
|
|
346
|
+
featureKey: string;
|
|
347
|
+
memoryKey: string;
|
|
348
|
+
key: string;
|
|
349
|
+
}, callback: (response: {
|
|
350
|
+
success: boolean;
|
|
351
|
+
error?: string;
|
|
352
|
+
}) => void) => void;
|
|
353
|
+
"telemetry:client_metric": (payload: {
|
|
354
|
+
metric: string;
|
|
355
|
+
value: number;
|
|
356
|
+
attributes?: Record<string, string>;
|
|
357
|
+
}) => void;
|
|
331
358
|
}
|
|
332
359
|
/**
|
|
333
360
|
* WebSocket server-to-client events
|
|
@@ -339,6 +366,30 @@ interface ServerToClientEvents {
|
|
|
339
366
|
"command:execute:tool": (payload: ToolCommandPayload) => void;
|
|
340
367
|
}
|
|
341
368
|
|
|
369
|
+
declare class NebulaClient {
|
|
370
|
+
private readonly config;
|
|
371
|
+
private readonly registry;
|
|
372
|
+
private readonly serverConnection?;
|
|
373
|
+
private readonly telemetryExporter?;
|
|
374
|
+
private readonly domainEventsExporter?;
|
|
375
|
+
private readonly logger?;
|
|
376
|
+
constructor(config: ClientConfig);
|
|
377
|
+
registerAgent(agent: Parameters<Registry["registerAgent"]>[0]): void;
|
|
378
|
+
registerTool(tool: Parameters<Registry["registerTool"]>[0]): void;
|
|
379
|
+
registerWorkflow(workflow: Parameters<Registry["registerWorkflow"]>[0]): void;
|
|
380
|
+
start(): Promise<void>;
|
|
381
|
+
stop(): Promise<void>;
|
|
382
|
+
getClientId(): string | undefined;
|
|
383
|
+
isConnected(): boolean;
|
|
384
|
+
getSocket(): Socket<ServerToClientEvents, ClientToServerEvents> | undefined;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
declare class TelemetryService {
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
declare class Batcher {
|
|
391
|
+
}
|
|
392
|
+
|
|
342
393
|
interface ServerConnectionConfig {
|
|
343
394
|
url: string;
|
|
344
395
|
apiKey: string;
|
package/dist/index.js
CHANGED
|
@@ -5,9 +5,6 @@ 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
|
-
};
|
|
11
8
|
var __export = (target, all) => {
|
|
12
9
|
for (var name in all)
|
|
13
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -30,172 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
27
|
));
|
|
31
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
29
|
|
|
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
|
-
|
|
199
30
|
// src/index.ts
|
|
200
31
|
var index_exports = {};
|
|
201
32
|
__export(index_exports, {
|
|
@@ -1753,9 +1584,6 @@ var NebulaClient = class {
|
|
|
1753
1584
|
if (!config.clientId) {
|
|
1754
1585
|
config.clientId = `client-${(0, import_uuid2.v4)()}`;
|
|
1755
1586
|
}
|
|
1756
|
-
if (config.server) {
|
|
1757
|
-
this.setGlobalClientContext(config.server.apiKey, config.server.url);
|
|
1758
|
-
}
|
|
1759
1587
|
this.registry = new Registry();
|
|
1760
1588
|
this.registry.setHttpClient(new InstrumentedHttpClient());
|
|
1761
1589
|
config.agents?.forEach((agent) => this.registry.registerAgent(agent));
|
|
@@ -1844,6 +1672,11 @@ var NebulaClient = class {
|
|
|
1844
1672
|
}
|
|
1845
1673
|
throw new Error(`Failed to connect to NebulaOS Cloud: ${String(error)}`);
|
|
1846
1674
|
}
|
|
1675
|
+
for (const agent of this.registry.listAgents()) {
|
|
1676
|
+
if (typeof agent.setClient === "function") {
|
|
1677
|
+
agent.setClient(this);
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1847
1680
|
}
|
|
1848
1681
|
}
|
|
1849
1682
|
async stop() {
|
|
@@ -1855,21 +1688,8 @@ var NebulaClient = class {
|
|
|
1855
1688
|
isConnected() {
|
|
1856
1689
|
return this.serverConnection?.isConnected() ?? false;
|
|
1857
1690
|
}
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
* This allows skills like RagOpenAISkill to automatically use the client's credentials
|
|
1861
|
-
*/
|
|
1862
|
-
setGlobalClientContext(apiKey, serverUrl) {
|
|
1863
|
-
try {
|
|
1864
|
-
Promise.resolve().then(() => __toESM(require_dist())).then((module2) => {
|
|
1865
|
-
if (module2.ClientContext) {
|
|
1866
|
-
module2.ClientContext.setApiKey(apiKey);
|
|
1867
|
-
module2.ClientContext.setServerUrl(serverUrl);
|
|
1868
|
-
}
|
|
1869
|
-
}).catch(() => {
|
|
1870
|
-
});
|
|
1871
|
-
} catch {
|
|
1872
|
-
}
|
|
1691
|
+
getSocket() {
|
|
1692
|
+
return this.serverConnection?.getSocket();
|
|
1873
1693
|
}
|
|
1874
1694
|
};
|
|
1875
1695
|
|