@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
@@ -1,6 +1,6 @@
1
- export { A as APP_VIEW_TAG_NAME, a as AssistantAppViewErrorDetail, N as NoodleAppViewElement } from './app-view-element-1i_w6FDf.cjs';
2
- export { A as AssistantClient, a as AssistantViewAvailableDetail } from './client-uo57Swlm.cjs';
3
- import './appearance-Cc-eqSbp.cjs';
1
+ export { A as APP_VIEW_TAG_NAME, a as AssistantAppViewErrorDetail, N as NoodleAppViewElement } from './app-view-element-9ojWWYov.cjs';
2
+ export { A as AssistantClient, a as AssistantViewAvailableDetail } from './client-C07ppTU_.cjs';
3
+ import './appearance-B6vSg8Ub.cjs';
4
4
  import 'ai';
5
5
 
6
6
  /** Register the framework-neutral MCP App host. Safe to call more than once or during SSR. */
@@ -1,6 +1,6 @@
1
- export { A as APP_VIEW_TAG_NAME, a as AssistantAppViewErrorDetail, N as NoodleAppViewElement } from './app-view-element-7ZQZLYbL.js';
2
- export { A as AssistantClient, a as AssistantViewAvailableDetail } from './client-Bp_VKpMg.js';
3
- import './appearance-Cc-eqSbp.js';
1
+ export { A as APP_VIEW_TAG_NAME, a as AssistantAppViewErrorDetail, N as NoodleAppViewElement } from './app-view-element-BM4lral-.js';
2
+ export { A as AssistantClient, a as AssistantViewAvailableDetail } from './client-BkogON2A.js';
3
+ import './appearance-B6vSg8Ub.js';
4
4
  import 'ai';
5
5
 
6
6
  /** Register the framework-neutral MCP App host. Safe to call more than once or during SSR. */
package/dist/app-view.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  APP_VIEW_TAG_NAME,
3
3
  NoodleAppViewElement,
4
4
  registerNoodleAppView
5
- } from "./chunk-5NBHHNI3.js";
6
- import "./chunk-XKTUXFGX.js";
5
+ } from "./chunk-LNBUYHL7.js";
6
+ import "./chunk-P32MAR4K.js";
7
7
  import "./chunk-P223CYPO.js";
8
8
  import "./chunk-3YYTUJPJ.js";
9
9
  import "./chunk-5FUTL2UF.js";
@@ -124,6 +124,7 @@ interface AssistantLabels {
124
124
  readonly copy: string;
125
125
  readonly newMessages: string;
126
126
  readonly reconnect: string;
127
+ readonly newConversation: string;
127
128
  readonly retry: string;
128
129
  readonly unavailable: string;
129
130
  readonly sessionExpired: string;
@@ -131,6 +132,10 @@ interface AssistantLabels {
131
132
  readonly sessionLoading: string;
132
133
  readonly sessionReady: string;
133
134
  readonly sessionError: string;
135
+ readonly signInHeading: string;
136
+ readonly signInBody: string;
137
+ readonly signInAction: string;
138
+ readonly signUpAction: string;
134
139
  }
135
140
 
136
141
  export type { AssistantConfiguration as A, AssistantThemeMode as a };
@@ -124,6 +124,7 @@ interface AssistantLabels {
124
124
  readonly copy: string;
125
125
  readonly newMessages: string;
126
126
  readonly reconnect: string;
127
+ readonly newConversation: string;
127
128
  readonly retry: string;
128
129
  readonly unavailable: string;
129
130
  readonly sessionExpired: string;
@@ -131,6 +132,10 @@ interface AssistantLabels {
131
132
  readonly sessionLoading: string;
132
133
  readonly sessionReady: string;
133
134
  readonly sessionError: string;
135
+ readonly signInHeading: string;
136
+ readonly signInBody: string;
137
+ readonly signInAction: string;
138
+ readonly signUpAction: string;
134
139
  }
135
140
 
136
141
  export type { AssistantConfiguration as A, AssistantThemeMode as a };
@@ -4257,6 +4257,9 @@ var AssistantChatStateStore = class {
4257
4257
  })
4258
4258
  );
4259
4259
  return;
4260
+ case "auth_requested":
4261
+ this.#writeStandaloneData(() => this.#writeData("sign-in", event.data.id, event.data));
4262
+ return;
4260
4263
  case "tool_completed":
4261
4264
  this.#writeData("tool-result", event.data.id, event.data);
4262
4265
  return;
@@ -4521,7 +4524,8 @@ function parseSession(value) {
4521
4524
  const interactions = value.endpoints.interactions;
4522
4525
  const apps = value.endpoints.apps;
4523
4526
  const sandbox = value.endpoints.sandbox;
4524
- 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") {
4527
+ const transcript = value.endpoints.transcript;
4528
+ 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") {
4525
4529
  throw clientError("session_failed", "Assistant session response is invalid", true);
4526
4530
  }
4527
4531
  return {
@@ -4532,7 +4536,8 @@ function parseSession(value) {
4532
4536
  toolConfirmations: value.endpoints.toolConfirmations,
4533
4537
  ...typeof interactions === "string" ? { interactions } : {},
4534
4538
  ...typeof apps === "string" ? { apps } : {},
4535
- ...typeof sandbox === "string" ? { sandbox } : {}
4539
+ ...typeof sandbox === "string" ? { sandbox } : {},
4540
+ ...typeof transcript === "string" ? { transcript } : {}
4536
4541
  },
4537
4542
  ...isRecord2(value.configuration) ? { configuration: value.configuration } : {},
4538
4543
  ...isRecord2(value.resume) && typeof value.resume.tool === "string" ? { resume: { tool: value.resume.tool } } : {}
@@ -4800,6 +4805,43 @@ function sessionSourceKey(options) {
4800
4805
  return `${options.embedId ?? ""}|${options.serviceUrl ?? ""}|${options.sessionEndpoint ?? ""}`;
4801
4806
  }
4802
4807
 
4808
+ // src/transcript-replay.ts
4809
+ function parseTranscriptEntries(value) {
4810
+ if (typeof value !== "object" || value === null) return [];
4811
+ const entries = value.entries;
4812
+ if (!Array.isArray(entries)) return [];
4813
+ const parsed = [];
4814
+ for (const entry of entries) {
4815
+ const { role, text: text2 } = entry ?? {};
4816
+ if (role !== "user" && role !== "assistant" || typeof text2 !== "string") return [];
4817
+ parsed.push({ role, text: text2 });
4818
+ }
4819
+ return parsed;
4820
+ }
4821
+ function transcriptReplayEvents(entries) {
4822
+ const events = [];
4823
+ let open = false;
4824
+ let awaitingAssistant = false;
4825
+ for (const entry of entries) {
4826
+ if (entry.role === "user") {
4827
+ if (open) events.push({ event: "message_completed", data: {} });
4828
+ events.push({ event: "message_started", data: { message: entry.text } });
4829
+ open = true;
4830
+ awaitingAssistant = true;
4831
+ continue;
4832
+ }
4833
+ if (!open || !awaitingAssistant) {
4834
+ if (open) events.push({ event: "message_completed", data: {} });
4835
+ events.push({ event: "resume_started", data: { tool: "" } });
4836
+ open = true;
4837
+ }
4838
+ events.push({ event: "content", data: { delta: entry.text } });
4839
+ awaitingAssistant = false;
4840
+ }
4841
+ if (open) events.push({ event: "message_completed", data: {} });
4842
+ return events;
4843
+ }
4844
+
4803
4845
  // src/transport.ts
4804
4846
  var AssistantTransportError = class extends Error {
4805
4847
  code = "invalid_response";
@@ -4970,6 +5012,12 @@ var DefaultAssistantClient = class {
4970
5012
  await this.#singleFlight(async (signal) => {
4971
5013
  if (this.#session) return;
4972
5014
  const session = await this.#createSession(signal);
5015
+ if (this.#source.kind !== "public" && session.endpoints.transcript) {
5016
+ try {
5017
+ await this.#replayTranscript(session, signal);
5018
+ } catch {
5019
+ }
5020
+ }
4973
5021
  if (session.resume) {
4974
5022
  try {
4975
5023
  await this.#runChatOperation(signal, () => this.#resumeTurn(session, signal));
@@ -4978,6 +5026,26 @@ var DefaultAssistantClient = class {
4978
5026
  }
4979
5027
  });
4980
5028
  }
5029
+ /** Fetch and re-emit the bounded visible transcript through the standard event path. */
5030
+ async #replayTranscript(session, signal) {
5031
+ const endpoint = session.endpoints.transcript;
5032
+ if (!endpoint) return;
5033
+ const response = await this.#request(
5034
+ endpoint,
5035
+ {
5036
+ method: "POST",
5037
+ headers: authorizedHeaders(session.token, "application/json"),
5038
+ body: "{}",
5039
+ signal
5040
+ },
5041
+ "turn_failed"
5042
+ );
5043
+ if (!response.ok) return;
5044
+ for (const event of transcriptReplayEvents(parseTranscriptEntries(await response.json()))) {
5045
+ this.#emit(event);
5046
+ if (event.event === "message_completed") await this.#chat.flush();
5047
+ }
5048
+ }
4981
5049
  /** POST the one-shot resume trigger; a 409 means nothing was pending, which renders as silence. */
4982
5050
  async #resumeTurn(session, signal) {
4983
5051
  const response = await this.#request(
@@ -5440,4 +5508,4 @@ export {
5440
5508
  sessionSourceKey,
5441
5509
  createAssistantClient
5442
5510
  };
5443
- //# sourceMappingURL=chunk-IBDP6PXQ.js.map
5511
+ //# sourceMappingURL=chunk-7BQHW37I.js.map