@noodleseed/assistant 1.15.0 → 1.16.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/{chunk-SUHNNWKP.js → chunk-MZNENVFY.js} +76 -3
- package/dist/chunk-MZNENVFY.js.map +1 -0
- package/dist/{chunk-RRJIK473.js → chunk-RIKRQFKS.js} +10 -1
- package/dist/{chunk-RRJIK473.js.map → chunk-RIKRQFKS.js.map} +1 -1
- package/dist/{client-MnLfiyo2.d.ts → client-B6pnBmF8.d.ts} +14 -1
- package/dist/{client-B_l59rWg.d.cts → client-BQ30Fq-c.d.cts} +14 -1
- package/dist/client.cjs +9 -0
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/embed.global.js +32 -32
- package/dist/index.cjs +83 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/react/client.cjs +9 -0
- package/dist/react/client.cjs.map +1 -1
- package/dist/react/client.d.cts +1 -1
- package/dist/react/client.d.ts +1 -1
- package/dist/react/client.js +1 -1
- package/dist/react.cjs +83 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-SUHNNWKP.js.map +0 -1
package/dist/react/client.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AssistantPageContext, a as AssistantContext, C as CreateAssistantClientOptions, b as AssistantChatState, c as AssistantClient } from '../client-
|
|
1
|
+
import { A as AssistantPageContext, a as AssistantContext, C as CreateAssistantClientOptions, b as AssistantChatState, c as AssistantClient } from '../client-BQ30Fq-c.cjs';
|
|
2
2
|
import '../appearance-Cc-eqSbp.cjs';
|
|
3
3
|
import 'ai';
|
|
4
4
|
|
package/dist/react/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AssistantPageContext, a as AssistantContext, C as CreateAssistantClientOptions, b as AssistantChatState, c as AssistantClient } from '../client-
|
|
1
|
+
import { A as AssistantPageContext, a as AssistantContext, C as CreateAssistantClientOptions, b as AssistantChatState, c as AssistantClient } from '../client-B6pnBmF8.js';
|
|
2
2
|
import '../appearance-Cc-eqSbp.js';
|
|
3
3
|
import 'ai';
|
|
4
4
|
|
package/dist/react/client.js
CHANGED
package/dist/react.cjs
CHANGED
|
@@ -27095,6 +27095,11 @@ function toAssistantClientEvent(event) {
|
|
|
27095
27095
|
return event;
|
|
27096
27096
|
}
|
|
27097
27097
|
break;
|
|
27098
|
+
case "auth_requested":
|
|
27099
|
+
if (hasString(value, "id") && hasString(value, "tool") && hasString(value, "continuation") && hasString(value, "expiresAt") && hasOptionalTurnId(value)) {
|
|
27100
|
+
return event;
|
|
27101
|
+
}
|
|
27102
|
+
break;
|
|
27098
27103
|
case "interaction_resolved":
|
|
27099
27104
|
if (hasString(value, "id") && (value.action === void 0 || isInteractionAction(value.action)) && hasOptionalTurnId(value)) {
|
|
27100
27105
|
return event;
|
|
@@ -27475,6 +27480,10 @@ var DefaultAssistantClient = class {
|
|
|
27475
27480
|
getChatState() {
|
|
27476
27481
|
return this.#chat.getState();
|
|
27477
27482
|
}
|
|
27483
|
+
/** Whether a session already exists, so a caller can avoid re-entering its loading state. */
|
|
27484
|
+
hasSession() {
|
|
27485
|
+
return this.#session !== void 0;
|
|
27486
|
+
}
|
|
27478
27487
|
async connect() {
|
|
27479
27488
|
if (this.#session) return;
|
|
27480
27489
|
await this.#singleFlight(async (signal) => {
|
|
@@ -31044,6 +31053,28 @@ function renderMarkdown(text3) {
|
|
|
31044
31053
|
});
|
|
31045
31054
|
}
|
|
31046
31055
|
|
|
31056
|
+
// src/sign-in-card.ts
|
|
31057
|
+
function createSignInCard(options) {
|
|
31058
|
+
const card = document.createElement("div");
|
|
31059
|
+
card.className = "noodle-assistant-card noodle-assistant-sign-in";
|
|
31060
|
+
card.dataset.tool = options.tool;
|
|
31061
|
+
card.setAttribute("role", "status");
|
|
31062
|
+
const heading = document.createElement("p");
|
|
31063
|
+
heading.className = "noodle-assistant-card-heading";
|
|
31064
|
+
heading.textContent = options.labels.heading;
|
|
31065
|
+
card.append(heading);
|
|
31066
|
+
const action = document.createElement("button");
|
|
31067
|
+
action.type = "button";
|
|
31068
|
+
action.className = "noodle-assistant-card-action";
|
|
31069
|
+
action.textContent = options.labels.action;
|
|
31070
|
+
action.addEventListener("click", () => {
|
|
31071
|
+
action.disabled = true;
|
|
31072
|
+
options.onSignIn();
|
|
31073
|
+
});
|
|
31074
|
+
card.append(action);
|
|
31075
|
+
return card;
|
|
31076
|
+
}
|
|
31077
|
+
|
|
31047
31078
|
// src/element-event-controller.ts
|
|
31048
31079
|
var AssistantElementEventController = class {
|
|
31049
31080
|
#host;
|
|
@@ -31138,6 +31169,15 @@ var AssistantElementEventController = class {
|
|
|
31138
31169
|
);
|
|
31139
31170
|
return;
|
|
31140
31171
|
}
|
|
31172
|
+
if (name21 === "auth_requested" && typeof data.continuation === "string") {
|
|
31173
|
+
this.#appendSignInRequest(
|
|
31174
|
+
String(data.id ?? ""),
|
|
31175
|
+
String(data.tool ?? "this"),
|
|
31176
|
+
data.continuation,
|
|
31177
|
+
String(data.expiresAt ?? "")
|
|
31178
|
+
);
|
|
31179
|
+
return;
|
|
31180
|
+
}
|
|
31141
31181
|
if (name21 === "input_requested" && isRecord5(data.requestedSchema)) {
|
|
31142
31182
|
this.#appendInputRequest(
|
|
31143
31183
|
String(data.id ?? ""),
|
|
@@ -31223,6 +31263,40 @@ var AssistantElementEventController = class {
|
|
|
31223
31263
|
})
|
|
31224
31264
|
);
|
|
31225
31265
|
}
|
|
31266
|
+
/**
|
|
31267
|
+
* The host application owns the login. This renders the prompt and raises
|
|
31268
|
+
* `assistant-sign-in-requested`; the page signs the visitor in however it already does, then its
|
|
31269
|
+
* backend spends the continuation. Nothing here talks to an identity provider.
|
|
31270
|
+
*/
|
|
31271
|
+
#appendSignInRequest(id, tool, continuation, expiresAt) {
|
|
31272
|
+
const messages = this.#host.messages();
|
|
31273
|
+
if (!messages) return;
|
|
31274
|
+
this.#proposalCards.get(id)?.remove();
|
|
31275
|
+
const card = createSignInCard({
|
|
31276
|
+
tool,
|
|
31277
|
+
continuation,
|
|
31278
|
+
expiresAt,
|
|
31279
|
+
labels: {
|
|
31280
|
+
heading: "Sign in to continue",
|
|
31281
|
+
action: "Sign in"
|
|
31282
|
+
},
|
|
31283
|
+
onSignIn: () => this.#host.element.dispatchEvent(
|
|
31284
|
+
new CustomEvent("assistant-sign-in-requested", {
|
|
31285
|
+
detail: { id, tool, continuation, expiresAt },
|
|
31286
|
+
bubbles: true,
|
|
31287
|
+
composed: true
|
|
31288
|
+
})
|
|
31289
|
+
)
|
|
31290
|
+
});
|
|
31291
|
+
messages.append(card);
|
|
31292
|
+
this.#proposalCards.set(id, card);
|
|
31293
|
+
this.#host.revealLatest();
|
|
31294
|
+
this.#host.element.dispatchEvent(
|
|
31295
|
+
new CustomEvent("assistant-sign-in-required", {
|
|
31296
|
+
detail: { id, tool, continuation, expiresAt }
|
|
31297
|
+
})
|
|
31298
|
+
);
|
|
31299
|
+
}
|
|
31226
31300
|
#appendInputRequest(id, message, requestedSchema) {
|
|
31227
31301
|
const messages = this.#host.messages();
|
|
31228
31302
|
if (!messages || !id) return;
|
|
@@ -32109,7 +32183,13 @@ var NoodleAssistantElement = class extends HTMLElementBase {
|
|
|
32109
32183
|
if (this.#appearance.behavior.startOpen) this.#applyStartOpenPolicy();
|
|
32110
32184
|
this.#render();
|
|
32111
32185
|
this.dispatchEvent(new CustomEvent("assistant-ready"));
|
|
32112
|
-
this
|
|
32186
|
+
if (this.hasAttribute("start-open")) {
|
|
32187
|
+
this.setAttribute("open", "");
|
|
32188
|
+
this.#startOpenApplied = true;
|
|
32189
|
+
this.#primeSession();
|
|
32190
|
+
} else if (!this.embedId) {
|
|
32191
|
+
this.#primeSession();
|
|
32192
|
+
}
|
|
32113
32193
|
}
|
|
32114
32194
|
disconnectedCallback() {
|
|
32115
32195
|
this.#conversationGeneration += 1;
|
|
@@ -32131,6 +32211,7 @@ var NoodleAssistantElement = class extends HTMLElementBase {
|
|
|
32131
32211
|
}
|
|
32132
32212
|
open() {
|
|
32133
32213
|
this.setAttribute("open", "");
|
|
32214
|
+
this.#primeSession();
|
|
32134
32215
|
this.dispatchEvent(new CustomEvent("assistant-open"));
|
|
32135
32216
|
}
|
|
32136
32217
|
close() {
|
|
@@ -32298,6 +32379,7 @@ var NoodleAssistantElement = class extends HTMLElementBase {
|
|
|
32298
32379
|
}
|
|
32299
32380
|
#primeSession() {
|
|
32300
32381
|
if (!this.sessionEndpoint && !this.embedId) return;
|
|
32382
|
+
if (this.#sessionBootstrap || this.#client?.hasSession()) return;
|
|
32301
32383
|
const client = this.#ensureClient();
|
|
32302
32384
|
const generation = this.#conversationGeneration;
|
|
32303
32385
|
this.#setSessionState("loading");
|