hiloop-sdk 0.8.1 → 0.8.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/client.js +7 -3
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -34,7 +34,11 @@ export class HiloopClient {
|
|
|
34
34
|
* Initialize encryption: derive keypair from API key, register public key,
|
|
35
35
|
* and fetch space encryption info. Called automatically on first API call.
|
|
36
36
|
*/
|
|
37
|
-
async ensureInitialized() {
|
|
37
|
+
async ensureInitialized(agentName) {
|
|
38
|
+
// If an agentName is provided and we don't have one yet, store it for init
|
|
39
|
+
if (agentName && !this.options.agentName) {
|
|
40
|
+
this.options = { ...this.options, agentName };
|
|
41
|
+
}
|
|
38
42
|
if (this.initialized)
|
|
39
43
|
return;
|
|
40
44
|
if (this.initPromise)
|
|
@@ -101,7 +105,7 @@ export class HiloopClient {
|
|
|
101
105
|
const url = `${this.baseUrl}/v1${path}`;
|
|
102
106
|
const res = await fetch(url, {
|
|
103
107
|
method,
|
|
104
|
-
headers: this.buildHeaders(),
|
|
108
|
+
headers: this.buildHeaders(options?.agentName),
|
|
105
109
|
body: options?.body ? JSON.stringify(options.body) : undefined,
|
|
106
110
|
});
|
|
107
111
|
if (!res.ok) {
|
|
@@ -316,7 +320,7 @@ export class HiloopClient {
|
|
|
316
320
|
* This is the primary method for agent-to-human communication.
|
|
317
321
|
*/
|
|
318
322
|
async sendMessage(sessionId, content, opts) {
|
|
319
|
-
await this.ensureInitialized();
|
|
323
|
+
await this.ensureInitialized(opts?.agentName);
|
|
320
324
|
const encryptedContent = await this.crypto.encryptSessionMessage(content);
|
|
321
325
|
const body = { encryptedContent };
|
|
322
326
|
if (opts?.components && opts.components.length > 0) {
|