@aomi-labs/client 0.1.12 → 0.1.13
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/cli.js +40 -2
- package/dist/index.cjs +40 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -2
- package/dist/index.d.ts +28 -2
- package/dist/index.js +40 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -792,9 +792,10 @@ var AomiClient = class {
|
|
|
792
792
|
/**
|
|
793
793
|
* Fetch current session state (messages, processing status, title).
|
|
794
794
|
*/
|
|
795
|
-
async fetchState(sessionId, userState) {
|
|
795
|
+
async fetchState(sessionId, userState, clientId) {
|
|
796
796
|
const url = buildApiUrl(this.baseUrl, "/api/state", {
|
|
797
|
-
user_state: userState ? JSON.stringify(userState) : void 0
|
|
797
|
+
user_state: userState ? JSON.stringify(userState) : void 0,
|
|
798
|
+
client_id: clientId
|
|
798
799
|
});
|
|
799
800
|
const response = await fetch(url, {
|
|
800
801
|
headers: withSessionHeader(sessionId)
|
|
@@ -818,6 +819,9 @@ var AomiClient = class {
|
|
|
818
819
|
if (options == null ? void 0 : options.userState) {
|
|
819
820
|
payload.user_state = JSON.stringify(options.userState);
|
|
820
821
|
}
|
|
822
|
+
if (options == null ? void 0 : options.clientId) {
|
|
823
|
+
payload.client_id = options.clientId;
|
|
824
|
+
}
|
|
821
825
|
return postState(
|
|
822
826
|
this.baseUrl,
|
|
823
827
|
"/api/chat",
|
|
@@ -849,6 +853,40 @@ var AomiClient = class {
|
|
|
849
853
|
);
|
|
850
854
|
}
|
|
851
855
|
// ===========================================================================
|
|
856
|
+
// Secrets
|
|
857
|
+
// ===========================================================================
|
|
858
|
+
/**
|
|
859
|
+
* Ingest secrets for a client. Returns opaque `$SECRET:<name>` handles.
|
|
860
|
+
* Call this once at page load (or when secrets change) with a stable
|
|
861
|
+
* client_id for the browser tab. The same client_id should be passed
|
|
862
|
+
* to `sendMessage` / `fetchState` so sessions get associated.
|
|
863
|
+
*/
|
|
864
|
+
async ingestSecrets(clientId, secrets) {
|
|
865
|
+
const url = joinApiPath(this.baseUrl, "/api/secrets");
|
|
866
|
+
const response = await fetch(url, {
|
|
867
|
+
method: "POST",
|
|
868
|
+
headers: { "Content-Type": "application/json" },
|
|
869
|
+
body: JSON.stringify({ client_id: clientId, secrets })
|
|
870
|
+
});
|
|
871
|
+
if (!response.ok) {
|
|
872
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
873
|
+
}
|
|
874
|
+
return await response.json();
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Clear all secrets for a client (e.g. on page unload or logout).
|
|
878
|
+
*/
|
|
879
|
+
async clearSecrets(clientId) {
|
|
880
|
+
const url = buildApiUrl(this.baseUrl, "/api/secrets", {
|
|
881
|
+
client_id: clientId
|
|
882
|
+
});
|
|
883
|
+
const response = await fetch(url, { method: "DELETE" });
|
|
884
|
+
if (!response.ok) {
|
|
885
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
886
|
+
}
|
|
887
|
+
return await response.json();
|
|
888
|
+
}
|
|
889
|
+
// ===========================================================================
|
|
852
890
|
// SSE (Real-time Updates)
|
|
853
891
|
// ===========================================================================
|
|
854
892
|
/**
|
package/dist/index.cjs
CHANGED
|
@@ -317,9 +317,10 @@ var AomiClient = class {
|
|
|
317
317
|
/**
|
|
318
318
|
* Fetch current session state (messages, processing status, title).
|
|
319
319
|
*/
|
|
320
|
-
async fetchState(sessionId, userState) {
|
|
320
|
+
async fetchState(sessionId, userState, clientId) {
|
|
321
321
|
const url = buildApiUrl(this.baseUrl, "/api/state", {
|
|
322
|
-
user_state: userState ? JSON.stringify(userState) : void 0
|
|
322
|
+
user_state: userState ? JSON.stringify(userState) : void 0,
|
|
323
|
+
client_id: clientId
|
|
323
324
|
});
|
|
324
325
|
const response = await fetch(url, {
|
|
325
326
|
headers: withSessionHeader(sessionId)
|
|
@@ -343,6 +344,9 @@ var AomiClient = class {
|
|
|
343
344
|
if (options == null ? void 0 : options.userState) {
|
|
344
345
|
payload.user_state = JSON.stringify(options.userState);
|
|
345
346
|
}
|
|
347
|
+
if (options == null ? void 0 : options.clientId) {
|
|
348
|
+
payload.client_id = options.clientId;
|
|
349
|
+
}
|
|
346
350
|
return postState(
|
|
347
351
|
this.baseUrl,
|
|
348
352
|
"/api/chat",
|
|
@@ -374,6 +378,40 @@ var AomiClient = class {
|
|
|
374
378
|
);
|
|
375
379
|
}
|
|
376
380
|
// ===========================================================================
|
|
381
|
+
// Secrets
|
|
382
|
+
// ===========================================================================
|
|
383
|
+
/**
|
|
384
|
+
* Ingest secrets for a client. Returns opaque `$SECRET:<name>` handles.
|
|
385
|
+
* Call this once at page load (or when secrets change) with a stable
|
|
386
|
+
* client_id for the browser tab. The same client_id should be passed
|
|
387
|
+
* to `sendMessage` / `fetchState` so sessions get associated.
|
|
388
|
+
*/
|
|
389
|
+
async ingestSecrets(clientId, secrets) {
|
|
390
|
+
const url = joinApiPath(this.baseUrl, "/api/secrets");
|
|
391
|
+
const response = await fetch(url, {
|
|
392
|
+
method: "POST",
|
|
393
|
+
headers: { "Content-Type": "application/json" },
|
|
394
|
+
body: JSON.stringify({ client_id: clientId, secrets })
|
|
395
|
+
});
|
|
396
|
+
if (!response.ok) {
|
|
397
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
398
|
+
}
|
|
399
|
+
return await response.json();
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Clear all secrets for a client (e.g. on page unload or logout).
|
|
403
|
+
*/
|
|
404
|
+
async clearSecrets(clientId) {
|
|
405
|
+
const url = buildApiUrl(this.baseUrl, "/api/secrets", {
|
|
406
|
+
client_id: clientId
|
|
407
|
+
});
|
|
408
|
+
const response = await fetch(url, { method: "DELETE" });
|
|
409
|
+
if (!response.ok) {
|
|
410
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
411
|
+
}
|
|
412
|
+
return await response.json();
|
|
413
|
+
}
|
|
414
|
+
// ===========================================================================
|
|
377
415
|
// SSE (Real-time Updates)
|
|
378
416
|
// ===========================================================================
|
|
379
417
|
/**
|