@noodleseed/assistant 1.23.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.
Files changed (50) hide show
  1. package/README.md +4 -9
  2. package/dist/{app-view-element-7ZQZLYbL.d.ts → app-view-element-9ojWWYov.d.cts} +3 -2
  3. package/dist/{app-view-element-1i_w6FDf.d.cts → app-view-element-BM4lral-.d.ts} +3 -2
  4. package/dist/app-view.cjs +213 -41
  5. package/dist/app-view.cjs.map +1 -1
  6. package/dist/app-view.d.cts +3 -3
  7. package/dist/app-view.d.ts +3 -3
  8. package/dist/app-view.js +2 -2
  9. package/dist/{appearance-Cc-eqSbp.d.cts → appearance-B6vSg8Ub.d.cts} +5 -0
  10. package/dist/{appearance-Cc-eqSbp.d.ts → appearance-B6vSg8Ub.d.ts} +5 -0
  11. package/dist/{chunk-IBDP6PXQ.js → chunk-7BQHW37I.js} +71 -3
  12. package/dist/chunk-7BQHW37I.js.map +1 -0
  13. package/dist/{chunk-5NBHHNI3.js → chunk-LNBUYHL7.js} +2 -2
  14. package/dist/chunk-LNBUYHL7.js.map +1 -0
  15. package/dist/{chunk-XKTUXFGX.js → chunk-P32MAR4K.js} +214 -42
  16. package/dist/chunk-P32MAR4K.js.map +1 -0
  17. package/dist/{chunk-X7UQDIGS.js → chunk-SGMECNNU.js} +94 -43
  18. package/dist/chunk-SGMECNNU.js.map +1 -0
  19. package/dist/{client-Bp_VKpMg.d.ts → client-BkogON2A.d.ts} +11 -1
  20. package/dist/{client-uo57Swlm.d.cts → client-C07ppTU_.d.cts} +11 -1
  21. package/dist/client.cjs +70 -2
  22. package/dist/client.cjs.map +1 -1
  23. package/dist/client.d.cts +2 -2
  24. package/dist/client.d.ts +2 -2
  25. package/dist/client.js +1 -1
  26. package/dist/embed.global.js +149 -114
  27. package/dist/index.cjs +396 -105
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +3 -3
  30. package/dist/index.d.ts +3 -3
  31. package/dist/index.js +3 -3
  32. package/dist/react/client.cjs +70 -2
  33. package/dist/react/client.cjs.map +1 -1
  34. package/dist/react/client.d.cts +2 -2
  35. package/dist/react/client.d.ts +2 -2
  36. package/dist/react/client.js +1 -1
  37. package/dist/react.cjs +396 -105
  38. package/dist/react.cjs.map +1 -1
  39. package/dist/react.d.cts +3 -3
  40. package/dist/react.d.ts +3 -3
  41. package/dist/react.js +4 -4
  42. package/dist/server.cjs.map +1 -1
  43. package/dist/server.d.cts +3 -1
  44. package/dist/server.d.ts +3 -1
  45. package/dist/server.js.map +1 -1
  46. package/package.json +1 -1
  47. package/dist/chunk-5NBHHNI3.js.map +0 -1
  48. package/dist/chunk-IBDP6PXQ.js.map +0 -1
  49. package/dist/chunk-X7UQDIGS.js.map +0 -1
  50. package/dist/chunk-XKTUXFGX.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { a as AssistantViewAvailableDetail, g as AssistantClientEvent, c as AssistantContext, f as AssistantModelContextUpdate, b as AssistantPageContext, h as AssistantInteractionResponse } from './client-uo57Swlm.cjs';
2
- export { e as AssistantErrorDetail, i as AssistantEvent, j as AssistantViewAvailableEvent } from './client-uo57Swlm.cjs';
3
- import './appearance-Cc-eqSbp.cjs';
1
+ import { a as AssistantViewAvailableDetail, g as AssistantClientEvent, c as AssistantContext, f as AssistantModelContextUpdate, b as AssistantPageContext, h as AssistantInteractionResponse } from './client-C07ppTU_.cjs';
2
+ export { e as AssistantErrorDetail, i as AssistantEvent, j as AssistantViewAvailableEvent } from './client-C07ppTU_.cjs';
3
+ import './appearance-B6vSg8Ub.cjs';
4
4
  import 'ai';
5
5
 
6
6
  interface AssistantSurfaceAppearance {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { a as AssistantViewAvailableDetail, g as AssistantClientEvent, c as AssistantContext, f as AssistantModelContextUpdate, b as AssistantPageContext, h as AssistantInteractionResponse } from './client-Bp_VKpMg.js';
2
- export { e as AssistantErrorDetail, i as AssistantEvent, j as AssistantViewAvailableEvent } from './client-Bp_VKpMg.js';
3
- import './appearance-Cc-eqSbp.js';
1
+ import { a as AssistantViewAvailableDetail, g as AssistantClientEvent, c as AssistantContext, f as AssistantModelContextUpdate, b as AssistantPageContext, h as AssistantInteractionResponse } from './client-BkogON2A.js';
2
+ export { e as AssistantErrorDetail, i as AssistantEvent, j as AssistantViewAvailableEvent } from './client-BkogON2A.js';
3
+ import './appearance-B6vSg8Ub.js';
4
4
  import 'ai';
5
5
 
6
6
  interface AssistantSurfaceAppearance {
package/dist/index.js CHANGED
@@ -2,9 +2,9 @@ import {
2
2
  ASSISTANT_TAG_NAME,
3
3
  NoodleAssistantElement,
4
4
  registerNoodleAssistant
5
- } from "./chunk-X7UQDIGS.js";
6
- import "./chunk-XKTUXFGX.js";
7
- import "./chunk-IBDP6PXQ.js";
5
+ } from "./chunk-SGMECNNU.js";
6
+ import "./chunk-P32MAR4K.js";
7
+ import "./chunk-7BQHW37I.js";
8
8
  import "./chunk-P223CYPO.js";
9
9
  import "./chunk-3YYTUJPJ.js";
10
10
  import "./chunk-5FUTL2UF.js";
@@ -22666,6 +22666,9 @@ var AssistantChatStateStore = class {
22666
22666
  })
22667
22667
  );
22668
22668
  return;
22669
+ case "auth_requested":
22670
+ this.#writeStandaloneData(() => this.#writeData("sign-in", event.data.id, event.data));
22671
+ return;
22669
22672
  case "tool_completed":
22670
22673
  this.#writeData("tool-result", event.data.id, event.data);
22671
22674
  return;
@@ -22930,7 +22933,8 @@ function parseSession(value) {
22930
22933
  const interactions = value.endpoints.interactions;
22931
22934
  const apps = value.endpoints.apps;
22932
22935
  const sandbox = value.endpoints.sandbox;
22933
- 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") {
22936
+ const transcript = value.endpoints.transcript;
22937
+ 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") {
22934
22938
  throw clientError("session_failed", "Assistant session response is invalid", true);
22935
22939
  }
22936
22940
  return {
@@ -22941,7 +22945,8 @@ function parseSession(value) {
22941
22945
  toolConfirmations: value.endpoints.toolConfirmations,
22942
22946
  ...typeof interactions === "string" ? { interactions } : {},
22943
22947
  ...typeof apps === "string" ? { apps } : {},
22944
- ...typeof sandbox === "string" ? { sandbox } : {}
22948
+ ...typeof sandbox === "string" ? { sandbox } : {},
22949
+ ...typeof transcript === "string" ? { transcript } : {}
22945
22950
  },
22946
22951
  ...isRecord2(value.configuration) ? { configuration: value.configuration } : {},
22947
22952
  ...isRecord2(value.resume) && typeof value.resume.tool === "string" ? { resume: { tool: value.resume.tool } } : {}
@@ -23206,6 +23211,43 @@ function resolveSessionSource(options) {
23206
23211
  return { kind: "exchange", url: sessionEndpoint };
23207
23212
  }
23208
23213
 
23214
+ // src/transcript-replay.ts
23215
+ function parseTranscriptEntries(value) {
23216
+ if (typeof value !== "object" || value === null) return [];
23217
+ const entries = value.entries;
23218
+ if (!Array.isArray(entries)) return [];
23219
+ const parsed = [];
23220
+ for (const entry of entries) {
23221
+ const { role, text: text2 } = entry ?? {};
23222
+ if (role !== "user" && role !== "assistant" || typeof text2 !== "string") return [];
23223
+ parsed.push({ role, text: text2 });
23224
+ }
23225
+ return parsed;
23226
+ }
23227
+ function transcriptReplayEvents(entries) {
23228
+ const events = [];
23229
+ let open = false;
23230
+ let awaitingAssistant = false;
23231
+ for (const entry of entries) {
23232
+ if (entry.role === "user") {
23233
+ if (open) events.push({ event: "message_completed", data: {} });
23234
+ events.push({ event: "message_started", data: { message: entry.text } });
23235
+ open = true;
23236
+ awaitingAssistant = true;
23237
+ continue;
23238
+ }
23239
+ if (!open || !awaitingAssistant) {
23240
+ if (open) events.push({ event: "message_completed", data: {} });
23241
+ events.push({ event: "resume_started", data: { tool: "" } });
23242
+ open = true;
23243
+ }
23244
+ events.push({ event: "content", data: { delta: entry.text } });
23245
+ awaitingAssistant = false;
23246
+ }
23247
+ if (open) events.push({ event: "message_completed", data: {} });
23248
+ return events;
23249
+ }
23250
+
23209
23251
  // src/transport.ts
23210
23252
  var AssistantTransportError = class extends Error {
23211
23253
  code = "invalid_response";
@@ -23376,6 +23418,12 @@ var DefaultAssistantClient = class {
23376
23418
  await this.#singleFlight(async (signal) => {
23377
23419
  if (this.#session) return;
23378
23420
  const session = await this.#createSession(signal);
23421
+ if (this.#source.kind !== "public" && session.endpoints.transcript) {
23422
+ try {
23423
+ await this.#replayTranscript(session, signal);
23424
+ } catch {
23425
+ }
23426
+ }
23379
23427
  if (session.resume) {
23380
23428
  try {
23381
23429
  await this.#runChatOperation(signal, () => this.#resumeTurn(session, signal));
@@ -23384,6 +23432,26 @@ var DefaultAssistantClient = class {
23384
23432
  }
23385
23433
  });
23386
23434
  }
23435
+ /** Fetch and re-emit the bounded visible transcript through the standard event path. */
23436
+ async #replayTranscript(session, signal) {
23437
+ const endpoint = session.endpoints.transcript;
23438
+ if (!endpoint) return;
23439
+ const response = await this.#request(
23440
+ endpoint,
23441
+ {
23442
+ method: "POST",
23443
+ headers: authorizedHeaders(session.token, "application/json"),
23444
+ body: "{}",
23445
+ signal
23446
+ },
23447
+ "turn_failed"
23448
+ );
23449
+ if (!response.ok) return;
23450
+ for (const event of transcriptReplayEvents(parseTranscriptEntries(await response.json()))) {
23451
+ this.#emit(event);
23452
+ if (event.event === "message_completed") await this.#chat.flush();
23453
+ }
23454
+ }
23387
23455
  /** POST the one-shot resume trigger; a 409 means nothing was pending, which renders as silence. */
23388
23456
  async #resumeTurn(session, signal) {
23389
23457
  const response = await this.#request(