@astralform/js 2.0.0 → 3.0.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.cjs +20 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -8
- package/dist/index.d.ts +19 -8
- package/dist/index.js +20 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -425,7 +425,7 @@ var AstralformClient = class {
|
|
|
425
425
|
Authorization: `Bearer ${this.auth.accessToken}`
|
|
426
426
|
};
|
|
427
427
|
if (this.auth.agentId) {
|
|
428
|
-
headers["X-
|
|
428
|
+
headers["X-Agent-ID"] = this.auth.agentId;
|
|
429
429
|
}
|
|
430
430
|
if (this.auth.endUserId) {
|
|
431
431
|
headers["X-End-User-ID"] = this.auth.endUserId;
|
|
@@ -480,10 +480,9 @@ var AstralformClient = class {
|
|
|
480
480
|
async getHealth() {
|
|
481
481
|
return this.get("/v1/health");
|
|
482
482
|
}
|
|
483
|
-
// Agent readiness check
|
|
484
|
-
// iOS SDK) — it scopes to the client's active agent via X-Project-ID.
|
|
483
|
+
// Agent readiness check, scoped to the client's active agent via X-Agent-ID.
|
|
485
484
|
async getAgentStatus() {
|
|
486
|
-
const raw = await this.get("/v1/
|
|
485
|
+
const raw = await this.get("/v1/agent/status");
|
|
487
486
|
const ui = raw.ui_components ?? {};
|
|
488
487
|
return {
|
|
489
488
|
isReady: raw.is_ready,
|
|
@@ -653,7 +652,7 @@ var AstralformClient = class {
|
|
|
653
652
|
// --- Account-scoped discovery (user-token mode) ---
|
|
654
653
|
//
|
|
655
654
|
// Lets a signed-in user pick which team/agent they want to act on.
|
|
656
|
-
// Backend gates these on OIDC user context (no X-
|
|
655
|
+
// Backend gates these on OIDC user context (no X-Agent-ID required) —
|
|
657
656
|
// sending them in API-key mode yields 401.
|
|
658
657
|
async listTeams() {
|
|
659
658
|
const raw = await this.get("/v1/teams");
|
|
@@ -1675,17 +1674,12 @@ var ChatSession = class {
|
|
|
1675
1674
|
]);
|
|
1676
1675
|
this.messages = messagesResult.status === "fulfilled" ? messagesResult.value : [];
|
|
1677
1676
|
if (eventsResult.status === "fulfilled") {
|
|
1678
|
-
|
|
1677
|
+
if (userMessageContent) {
|
|
1678
|
+
this.emit({ type: "user_message", content: userMessageContent });
|
|
1679
|
+
}
|
|
1679
1680
|
for (const ev of eventsResult.value) {
|
|
1680
1681
|
const type = ev.data.type || ev.event;
|
|
1681
1682
|
if (!type || type === "done") continue;
|
|
1682
|
-
if (!userMessageEmitted && type === "message_start") {
|
|
1683
|
-
this.emit({
|
|
1684
|
-
type: "user_message",
|
|
1685
|
-
content: userMessageContent
|
|
1686
|
-
});
|
|
1687
|
-
userMessageEmitted = true;
|
|
1688
|
-
}
|
|
1689
1683
|
const wire = { ...ev.data, type };
|
|
1690
1684
|
try {
|
|
1691
1685
|
await this.dispatchWireEvent(
|
|
@@ -1994,21 +1988,21 @@ function mapSseToChat(raw) {
|
|
|
1994
1988
|
function replayEvents(sseEvents, userMessages, handleEvent, addBlock) {
|
|
1995
1989
|
const userMsgs = userMessages.filter((m) => m.role === "user");
|
|
1996
1990
|
let userIdx = 0;
|
|
1997
|
-
let
|
|
1991
|
+
let currentJobId = null;
|
|
1998
1992
|
for (const raw of sseEvents) {
|
|
1999
1993
|
const type = raw.data.type || raw.event;
|
|
2000
|
-
if (type === "
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
1994
|
+
if (!type || type === "done") continue;
|
|
1995
|
+
const jobId = raw.data.job_id ?? null;
|
|
1996
|
+
if (jobId !== null && jobId !== currentJobId) {
|
|
1997
|
+
currentJobId = jobId;
|
|
1998
|
+
if (userIdx < userMsgs.length) {
|
|
1999
|
+
addBlock({
|
|
2000
|
+
type: "user",
|
|
2001
|
+
id: `replay_user_${userIdx}`,
|
|
2002
|
+
content: userMsgs[userIdx].content
|
|
2003
|
+
});
|
|
2004
|
+
userIdx++;
|
|
2005
|
+
}
|
|
2012
2006
|
}
|
|
2013
2007
|
for (const ce of mapSseToChat(raw)) {
|
|
2014
2008
|
handleEvent(ce);
|