hiloop-sdk 0.8.0 → 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.
Files changed (2) hide show
  1. package/dist/client.js +8 -4
  2. 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) {
@@ -388,7 +392,7 @@ export class HiloopClient {
388
392
  // Decrypt timeline items (session messages)
389
393
  if (Array.isArray(result.items)) {
390
394
  await Promise.all(result.items.map(async (item) => {
391
- if (item.kind === "message" && typeof item.encryptedContent === "string") {
395
+ if (typeof item.encryptedContent === "string") {
392
396
  const plain = await this.crypto.decryptSessionMessage(item.encryptedContent);
393
397
  if (plain !== null)
394
398
  item.content = plain;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hiloop-sdk",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "TypeScript SDK for Hiloop — zero-trust human-AI agent interaction platform",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",