@noodleseed/assistant 1.24.0 → 1.25.0
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/README.md +4 -9
- package/dist/{app-view-element-DSPtyEul.d.cts → app-view-element-9ojWWYov.d.cts} +3 -2
- package/dist/{app-view-element-DDtXu08a.d.ts → app-view-element-BM4lral-.d.ts} +3 -2
- package/dist/app-view.cjs +213 -41
- package/dist/app-view.cjs.map +1 -1
- package/dist/app-view.d.cts +3 -3
- package/dist/app-view.d.ts +3 -3
- package/dist/app-view.js +2 -2
- package/dist/{appearance-0nS2LFjb.d.cts → appearance-B6vSg8Ub.d.cts} +4 -0
- package/dist/{appearance-0nS2LFjb.d.ts → appearance-B6vSg8Ub.d.ts} +4 -0
- package/dist/{chunk-IBDP6PXQ.js → chunk-7BQHW37I.js} +71 -3
- package/dist/chunk-7BQHW37I.js.map +1 -0
- package/dist/{chunk-5NBHHNI3.js → chunk-LNBUYHL7.js} +2 -2
- package/dist/chunk-LNBUYHL7.js.map +1 -0
- package/dist/{chunk-XKTUXFGX.js → chunk-P32MAR4K.js} +214 -42
- package/dist/chunk-P32MAR4K.js.map +1 -0
- package/dist/{chunk-6PVDV7SO.js → chunk-SGMECNNU.js} +55 -21
- package/dist/chunk-SGMECNNU.js.map +1 -0
- package/dist/{client-By4gqB1k.d.cts → client-BkogON2A.d.ts} +11 -1
- package/dist/{client-Cf38TgwN.d.ts → client-C07ppTU_.d.cts} +11 -1
- package/dist/client.cjs +70 -2
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +1 -1
- package/dist/embed.global.js +149 -114
- package/dist/index.cjs +357 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/react/client.cjs +70 -2
- package/dist/react/client.cjs.map +1 -1
- package/dist/react/client.d.cts +2 -2
- package/dist/react/client.d.ts +2 -2
- package/dist/react/client.js +1 -1
- package/dist/react.cjs +357 -83
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +4 -4
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +3 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-5NBHHNI3.js.map +0 -1
- package/dist/chunk-6PVDV7SO.js.map +0 -1
- package/dist/chunk-IBDP6PXQ.js.map +0 -1
- package/dist/chunk-XKTUXFGX.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AssistantConfiguration } from './appearance-
|
|
1
|
+
import { A as AssistantConfiguration } from './appearance-B6vSg8Ub.js';
|
|
2
2
|
import { ChatStatus, UIMessage } from 'ai';
|
|
3
3
|
|
|
4
4
|
type AssistantJsonValue = string | number | boolean | null | readonly AssistantJsonValue[] | {
|
|
@@ -170,11 +170,19 @@ type AssistantInputRequestData = AssistantInputRequestedDetail & {
|
|
|
170
170
|
};
|
|
171
171
|
type AssistantToolResultData = AssistantToolCompletedDetail;
|
|
172
172
|
type AssistantViewData = AssistantViewAvailableDetail;
|
|
173
|
+
/**
|
|
174
|
+
* The sign-in moment as a transcript part for headless renderers (ADR 0201, 5.6b). It carries no
|
|
175
|
+
* `status` field because it is not respondable through `client.respond`: resolution is the elevated
|
|
176
|
+
* session — the host page spends the ticket with its backend, and the conversation continues via
|
|
177
|
+
* `resume_started` under the new principal.
|
|
178
|
+
*/
|
|
179
|
+
type AssistantSignInRequestData = AssistantAuthRequestedDetail;
|
|
173
180
|
type AssistantUIDataTypes = {
|
|
174
181
|
readonly confirmation: AssistantConfirmationData;
|
|
175
182
|
readonly 'input-request': AssistantInputRequestData;
|
|
176
183
|
readonly 'tool-result': AssistantToolResultData;
|
|
177
184
|
readonly view: AssistantViewData;
|
|
185
|
+
readonly 'sign-in': AssistantSignInRequestData;
|
|
178
186
|
};
|
|
179
187
|
/** AI SDK UI message shape used by the DOM-free client and customer-owned renderers. */
|
|
180
188
|
type AssistantUIMessage = UIMessage<undefined, AssistantUIDataTypes>;
|
|
@@ -231,6 +239,8 @@ interface AssistantSessionResponse {
|
|
|
231
239
|
readonly apps?: string;
|
|
232
240
|
/** Additive hosted sandbox document for widget frames; absent on older services. */
|
|
233
241
|
readonly sandbox?: string;
|
|
242
|
+
/** Additive bounded visible-transcript endpoint; absent on older services. */
|
|
243
|
+
readonly transcript?: string;
|
|
234
244
|
};
|
|
235
245
|
readonly configuration?: AssistantConfiguration;
|
|
236
246
|
/** Armed post-sign-in resume hint: present only on an elevation exchange (issue #1177). */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AssistantConfiguration } from './appearance-
|
|
1
|
+
import { A as AssistantConfiguration } from './appearance-B6vSg8Ub.cjs';
|
|
2
2
|
import { ChatStatus, UIMessage } from 'ai';
|
|
3
3
|
|
|
4
4
|
type AssistantJsonValue = string | number | boolean | null | readonly AssistantJsonValue[] | {
|
|
@@ -170,11 +170,19 @@ type AssistantInputRequestData = AssistantInputRequestedDetail & {
|
|
|
170
170
|
};
|
|
171
171
|
type AssistantToolResultData = AssistantToolCompletedDetail;
|
|
172
172
|
type AssistantViewData = AssistantViewAvailableDetail;
|
|
173
|
+
/**
|
|
174
|
+
* The sign-in moment as a transcript part for headless renderers (ADR 0201, 5.6b). It carries no
|
|
175
|
+
* `status` field because it is not respondable through `client.respond`: resolution is the elevated
|
|
176
|
+
* session — the host page spends the ticket with its backend, and the conversation continues via
|
|
177
|
+
* `resume_started` under the new principal.
|
|
178
|
+
*/
|
|
179
|
+
type AssistantSignInRequestData = AssistantAuthRequestedDetail;
|
|
173
180
|
type AssistantUIDataTypes = {
|
|
174
181
|
readonly confirmation: AssistantConfirmationData;
|
|
175
182
|
readonly 'input-request': AssistantInputRequestData;
|
|
176
183
|
readonly 'tool-result': AssistantToolResultData;
|
|
177
184
|
readonly view: AssistantViewData;
|
|
185
|
+
readonly 'sign-in': AssistantSignInRequestData;
|
|
178
186
|
};
|
|
179
187
|
/** AI SDK UI message shape used by the DOM-free client and customer-owned renderers. */
|
|
180
188
|
type AssistantUIMessage = UIMessage<undefined, AssistantUIDataTypes>;
|
|
@@ -231,6 +239,8 @@ interface AssistantSessionResponse {
|
|
|
231
239
|
readonly apps?: string;
|
|
232
240
|
/** Additive hosted sandbox document for widget frames; absent on older services. */
|
|
233
241
|
readonly sandbox?: string;
|
|
242
|
+
/** Additive bounded visible-transcript endpoint; absent on older services. */
|
|
243
|
+
readonly transcript?: string;
|
|
234
244
|
};
|
|
235
245
|
readonly configuration?: AssistantConfiguration;
|
|
236
246
|
/** Armed post-sign-in resume hint: present only on an elevation exchange (issue #1177). */
|
package/dist/client.cjs
CHANGED
|
@@ -22665,6 +22665,9 @@ var AssistantChatStateStore = class {
|
|
|
22665
22665
|
})
|
|
22666
22666
|
);
|
|
22667
22667
|
return;
|
|
22668
|
+
case "auth_requested":
|
|
22669
|
+
this.#writeStandaloneData(() => this.#writeData("sign-in", event.data.id, event.data));
|
|
22670
|
+
return;
|
|
22668
22671
|
case "tool_completed":
|
|
22669
22672
|
this.#writeData("tool-result", event.data.id, event.data);
|
|
22670
22673
|
return;
|
|
@@ -22929,7 +22932,8 @@ function parseSession(value) {
|
|
|
22929
22932
|
const interactions = value.endpoints.interactions;
|
|
22930
22933
|
const apps = value.endpoints.apps;
|
|
22931
22934
|
const sandbox = value.endpoints.sandbox;
|
|
22932
|
-
|
|
22935
|
+
const transcript = value.endpoints.transcript;
|
|
22936
|
+
if (typeof value.token !== "string" || typeof value.expiresAt !== "string" || typeof value.endpoints.turns !== "string" || typeof value.endpoints.toolConfirmations !== "string" || interactions !== void 0 && typeof interactions !== "string" || apps !== void 0 && typeof apps !== "string" || sandbox !== void 0 && typeof sandbox !== "string" || transcript !== void 0 && typeof transcript !== "string") {
|
|
22933
22937
|
throw clientError("session_failed", "Assistant session response is invalid", true);
|
|
22934
22938
|
}
|
|
22935
22939
|
return {
|
|
@@ -22940,7 +22944,8 @@ function parseSession(value) {
|
|
|
22940
22944
|
toolConfirmations: value.endpoints.toolConfirmations,
|
|
22941
22945
|
...typeof interactions === "string" ? { interactions } : {},
|
|
22942
22946
|
...typeof apps === "string" ? { apps } : {},
|
|
22943
|
-
...typeof sandbox === "string" ? { sandbox } : {}
|
|
22947
|
+
...typeof sandbox === "string" ? { sandbox } : {},
|
|
22948
|
+
...typeof transcript === "string" ? { transcript } : {}
|
|
22944
22949
|
},
|
|
22945
22950
|
...isRecord2(value.configuration) ? { configuration: value.configuration } : {},
|
|
22946
22951
|
...isRecord2(value.resume) && typeof value.resume.tool === "string" ? { resume: { tool: value.resume.tool } } : {}
|
|
@@ -23205,6 +23210,43 @@ function resolveSessionSource(options) {
|
|
|
23205
23210
|
return { kind: "exchange", url: sessionEndpoint };
|
|
23206
23211
|
}
|
|
23207
23212
|
|
|
23213
|
+
// src/transcript-replay.ts
|
|
23214
|
+
function parseTranscriptEntries(value) {
|
|
23215
|
+
if (typeof value !== "object" || value === null) return [];
|
|
23216
|
+
const entries = value.entries;
|
|
23217
|
+
if (!Array.isArray(entries)) return [];
|
|
23218
|
+
const parsed = [];
|
|
23219
|
+
for (const entry of entries) {
|
|
23220
|
+
const { role, text: text2 } = entry ?? {};
|
|
23221
|
+
if (role !== "user" && role !== "assistant" || typeof text2 !== "string") return [];
|
|
23222
|
+
parsed.push({ role, text: text2 });
|
|
23223
|
+
}
|
|
23224
|
+
return parsed;
|
|
23225
|
+
}
|
|
23226
|
+
function transcriptReplayEvents(entries) {
|
|
23227
|
+
const events = [];
|
|
23228
|
+
let open = false;
|
|
23229
|
+
let awaitingAssistant = false;
|
|
23230
|
+
for (const entry of entries) {
|
|
23231
|
+
if (entry.role === "user") {
|
|
23232
|
+
if (open) events.push({ event: "message_completed", data: {} });
|
|
23233
|
+
events.push({ event: "message_started", data: { message: entry.text } });
|
|
23234
|
+
open = true;
|
|
23235
|
+
awaitingAssistant = true;
|
|
23236
|
+
continue;
|
|
23237
|
+
}
|
|
23238
|
+
if (!open || !awaitingAssistant) {
|
|
23239
|
+
if (open) events.push({ event: "message_completed", data: {} });
|
|
23240
|
+
events.push({ event: "resume_started", data: { tool: "" } });
|
|
23241
|
+
open = true;
|
|
23242
|
+
}
|
|
23243
|
+
events.push({ event: "content", data: { delta: entry.text } });
|
|
23244
|
+
awaitingAssistant = false;
|
|
23245
|
+
}
|
|
23246
|
+
if (open) events.push({ event: "message_completed", data: {} });
|
|
23247
|
+
return events;
|
|
23248
|
+
}
|
|
23249
|
+
|
|
23208
23250
|
// src/transport.ts
|
|
23209
23251
|
var AssistantTransportError = class extends Error {
|
|
23210
23252
|
code = "invalid_response";
|
|
@@ -23375,6 +23417,12 @@ var DefaultAssistantClient = class {
|
|
|
23375
23417
|
await this.#singleFlight(async (signal) => {
|
|
23376
23418
|
if (this.#session) return;
|
|
23377
23419
|
const session = await this.#createSession(signal);
|
|
23420
|
+
if (this.#source.kind !== "public" && session.endpoints.transcript) {
|
|
23421
|
+
try {
|
|
23422
|
+
await this.#replayTranscript(session, signal);
|
|
23423
|
+
} catch {
|
|
23424
|
+
}
|
|
23425
|
+
}
|
|
23378
23426
|
if (session.resume) {
|
|
23379
23427
|
try {
|
|
23380
23428
|
await this.#runChatOperation(signal, () => this.#resumeTurn(session, signal));
|
|
@@ -23383,6 +23431,26 @@ var DefaultAssistantClient = class {
|
|
|
23383
23431
|
}
|
|
23384
23432
|
});
|
|
23385
23433
|
}
|
|
23434
|
+
/** Fetch and re-emit the bounded visible transcript through the standard event path. */
|
|
23435
|
+
async #replayTranscript(session, signal) {
|
|
23436
|
+
const endpoint = session.endpoints.transcript;
|
|
23437
|
+
if (!endpoint) return;
|
|
23438
|
+
const response = await this.#request(
|
|
23439
|
+
endpoint,
|
|
23440
|
+
{
|
|
23441
|
+
method: "POST",
|
|
23442
|
+
headers: authorizedHeaders(session.token, "application/json"),
|
|
23443
|
+
body: "{}",
|
|
23444
|
+
signal
|
|
23445
|
+
},
|
|
23446
|
+
"turn_failed"
|
|
23447
|
+
);
|
|
23448
|
+
if (!response.ok) return;
|
|
23449
|
+
for (const event of transcriptReplayEvents(parseTranscriptEntries(await response.json()))) {
|
|
23450
|
+
this.#emit(event);
|
|
23451
|
+
if (event.event === "message_completed") await this.#chat.flush();
|
|
23452
|
+
}
|
|
23453
|
+
}
|
|
23386
23454
|
/** POST the one-shot resume trigger; a 409 means nothing was pending, which renders as silence. */
|
|
23387
23455
|
async #resumeTurn(session, signal) {
|
|
23388
23456
|
const response = await this.#request(
|