@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/index.cjs
CHANGED
|
@@ -27092,6 +27092,11 @@ function toAssistantClientEvent(event) {
|
|
|
27092
27092
|
return event;
|
|
27093
27093
|
}
|
|
27094
27094
|
break;
|
|
27095
|
+
case "auth_requested":
|
|
27096
|
+
if (hasString(value, "id") && hasString(value, "tool") && hasString(value, "continuation") && hasString(value, "expiresAt") && hasOptionalTurnId(value)) {
|
|
27097
|
+
return event;
|
|
27098
|
+
}
|
|
27099
|
+
break;
|
|
27095
27100
|
case "interaction_resolved":
|
|
27096
27101
|
if (hasString(value, "id") && (value.action === void 0 || isInteractionAction(value.action)) && hasOptionalTurnId(value)) {
|
|
27097
27102
|
return event;
|
|
@@ -27472,6 +27477,10 @@ var DefaultAssistantClient = class {
|
|
|
27472
27477
|
getChatState() {
|
|
27473
27478
|
return this.#chat.getState();
|
|
27474
27479
|
}
|
|
27480
|
+
/** Whether a session already exists, so a caller can avoid re-entering its loading state. */
|
|
27481
|
+
hasSession() {
|
|
27482
|
+
return this.#session !== void 0;
|
|
27483
|
+
}
|
|
27475
27484
|
async connect() {
|
|
27476
27485
|
if (this.#session) return;
|
|
27477
27486
|
await this.#singleFlight(async (signal) => {
|
|
@@ -31041,6 +31050,28 @@ function renderMarkdown(text3) {
|
|
|
31041
31050
|
});
|
|
31042
31051
|
}
|
|
31043
31052
|
|
|
31053
|
+
// src/sign-in-card.ts
|
|
31054
|
+
function createSignInCard(options) {
|
|
31055
|
+
const card = document.createElement("div");
|
|
31056
|
+
card.className = "noodle-assistant-card noodle-assistant-sign-in";
|
|
31057
|
+
card.dataset.tool = options.tool;
|
|
31058
|
+
card.setAttribute("role", "status");
|
|
31059
|
+
const heading = document.createElement("p");
|
|
31060
|
+
heading.className = "noodle-assistant-card-heading";
|
|
31061
|
+
heading.textContent = options.labels.heading;
|
|
31062
|
+
card.append(heading);
|
|
31063
|
+
const action = document.createElement("button");
|
|
31064
|
+
action.type = "button";
|
|
31065
|
+
action.className = "noodle-assistant-card-action";
|
|
31066
|
+
action.textContent = options.labels.action;
|
|
31067
|
+
action.addEventListener("click", () => {
|
|
31068
|
+
action.disabled = true;
|
|
31069
|
+
options.onSignIn();
|
|
31070
|
+
});
|
|
31071
|
+
card.append(action);
|
|
31072
|
+
return card;
|
|
31073
|
+
}
|
|
31074
|
+
|
|
31044
31075
|
// src/element-event-controller.ts
|
|
31045
31076
|
var AssistantElementEventController = class {
|
|
31046
31077
|
#host;
|
|
@@ -31135,6 +31166,15 @@ var AssistantElementEventController = class {
|
|
|
31135
31166
|
);
|
|
31136
31167
|
return;
|
|
31137
31168
|
}
|
|
31169
|
+
if (name21 === "auth_requested" && typeof data.continuation === "string") {
|
|
31170
|
+
this.#appendSignInRequest(
|
|
31171
|
+
String(data.id ?? ""),
|
|
31172
|
+
String(data.tool ?? "this"),
|
|
31173
|
+
data.continuation,
|
|
31174
|
+
String(data.expiresAt ?? "")
|
|
31175
|
+
);
|
|
31176
|
+
return;
|
|
31177
|
+
}
|
|
31138
31178
|
if (name21 === "input_requested" && isRecord5(data.requestedSchema)) {
|
|
31139
31179
|
this.#appendInputRequest(
|
|
31140
31180
|
String(data.id ?? ""),
|
|
@@ -31220,6 +31260,40 @@ var AssistantElementEventController = class {
|
|
|
31220
31260
|
})
|
|
31221
31261
|
);
|
|
31222
31262
|
}
|
|
31263
|
+
/**
|
|
31264
|
+
* The host application owns the login. This renders the prompt and raises
|
|
31265
|
+
* `assistant-sign-in-requested`; the page signs the visitor in however it already does, then its
|
|
31266
|
+
* backend spends the continuation. Nothing here talks to an identity provider.
|
|
31267
|
+
*/
|
|
31268
|
+
#appendSignInRequest(id, tool, continuation, expiresAt) {
|
|
31269
|
+
const messages = this.#host.messages();
|
|
31270
|
+
if (!messages) return;
|
|
31271
|
+
this.#proposalCards.get(id)?.remove();
|
|
31272
|
+
const card = createSignInCard({
|
|
31273
|
+
tool,
|
|
31274
|
+
continuation,
|
|
31275
|
+
expiresAt,
|
|
31276
|
+
labels: {
|
|
31277
|
+
heading: "Sign in to continue",
|
|
31278
|
+
action: "Sign in"
|
|
31279
|
+
},
|
|
31280
|
+
onSignIn: () => this.#host.element.dispatchEvent(
|
|
31281
|
+
new CustomEvent("assistant-sign-in-requested", {
|
|
31282
|
+
detail: { id, tool, continuation, expiresAt },
|
|
31283
|
+
bubbles: true,
|
|
31284
|
+
composed: true
|
|
31285
|
+
})
|
|
31286
|
+
)
|
|
31287
|
+
});
|
|
31288
|
+
messages.append(card);
|
|
31289
|
+
this.#proposalCards.set(id, card);
|
|
31290
|
+
this.#host.revealLatest();
|
|
31291
|
+
this.#host.element.dispatchEvent(
|
|
31292
|
+
new CustomEvent("assistant-sign-in-required", {
|
|
31293
|
+
detail: { id, tool, continuation, expiresAt }
|
|
31294
|
+
})
|
|
31295
|
+
);
|
|
31296
|
+
}
|
|
31223
31297
|
#appendInputRequest(id, message, requestedSchema) {
|
|
31224
31298
|
const messages = this.#host.messages();
|
|
31225
31299
|
if (!messages || !id) return;
|
|
@@ -32106,7 +32180,13 @@ var NoodleAssistantElement = class extends HTMLElementBase {
|
|
|
32106
32180
|
if (this.#appearance.behavior.startOpen) this.#applyStartOpenPolicy();
|
|
32107
32181
|
this.#render();
|
|
32108
32182
|
this.dispatchEvent(new CustomEvent("assistant-ready"));
|
|
32109
|
-
this
|
|
32183
|
+
if (this.hasAttribute("start-open")) {
|
|
32184
|
+
this.setAttribute("open", "");
|
|
32185
|
+
this.#startOpenApplied = true;
|
|
32186
|
+
this.#primeSession();
|
|
32187
|
+
} else if (!this.embedId) {
|
|
32188
|
+
this.#primeSession();
|
|
32189
|
+
}
|
|
32110
32190
|
}
|
|
32111
32191
|
disconnectedCallback() {
|
|
32112
32192
|
this.#conversationGeneration += 1;
|
|
@@ -32128,6 +32208,7 @@ var NoodleAssistantElement = class extends HTMLElementBase {
|
|
|
32128
32208
|
}
|
|
32129
32209
|
open() {
|
|
32130
32210
|
this.setAttribute("open", "");
|
|
32211
|
+
this.#primeSession();
|
|
32131
32212
|
this.dispatchEvent(new CustomEvent("assistant-open"));
|
|
32132
32213
|
}
|
|
32133
32214
|
close() {
|
|
@@ -32295,6 +32376,7 @@ var NoodleAssistantElement = class extends HTMLElementBase {
|
|
|
32295
32376
|
}
|
|
32296
32377
|
#primeSession() {
|
|
32297
32378
|
if (!this.sessionEndpoint && !this.embedId) return;
|
|
32379
|
+
if (this.#sessionBootstrap || this.#client?.hasSession()) return;
|
|
32298
32380
|
const client = this.#ensureClient();
|
|
32299
32381
|
const generation = this.#conversationGeneration;
|
|
32300
32382
|
this.#setSessionState("loading");
|