@assistant-ui/react 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. package/dist/api/AssistantRuntime.d.ts +4 -34
  2. package/dist/api/AssistantRuntime.d.ts.map +1 -1
  3. package/dist/api/AssistantRuntime.js.map +1 -1
  4. package/dist/api/AssistantRuntime.mjs.map +1 -1
  5. package/dist/api/AttachmentRuntime.d.ts +4 -4
  6. package/dist/api/AttachmentRuntime.d.ts.map +1 -1
  7. package/dist/api/AttachmentRuntime.js.map +1 -1
  8. package/dist/api/AttachmentRuntime.mjs.map +1 -1
  9. package/dist/api/ComposerRuntime.d.ts +10 -10
  10. package/dist/api/ComposerRuntime.d.ts.map +1 -1
  11. package/dist/api/ComposerRuntime.js.map +1 -1
  12. package/dist/api/ComposerRuntime.mjs.map +1 -1
  13. package/dist/api/ContentPartRuntime.d.ts +2 -2
  14. package/dist/api/ContentPartRuntime.d.ts.map +1 -1
  15. package/dist/api/ContentPartRuntime.js.map +1 -1
  16. package/dist/api/ContentPartRuntime.mjs.map +1 -1
  17. package/dist/api/MessageRuntime.d.ts +7 -7
  18. package/dist/api/MessageRuntime.d.ts.map +1 -1
  19. package/dist/api/MessageRuntime.js +2 -2
  20. package/dist/api/MessageRuntime.js.map +1 -1
  21. package/dist/api/MessageRuntime.mjs +2 -2
  22. package/dist/api/MessageRuntime.mjs.map +1 -1
  23. package/dist/api/RuntimePathTypes.d.ts +33 -33
  24. package/dist/api/RuntimePathTypes.d.ts.map +1 -1
  25. package/dist/api/RuntimePathTypes.js.map +1 -1
  26. package/dist/api/ThreadListItemRuntime.d.ts +4 -4
  27. package/dist/api/ThreadListItemRuntime.d.ts.map +1 -1
  28. package/dist/api/ThreadListItemRuntime.js.map +1 -1
  29. package/dist/api/ThreadListItemRuntime.mjs.map +1 -1
  30. package/dist/api/ThreadListRuntime.d.ts +9 -9
  31. package/dist/api/ThreadListRuntime.d.ts.map +1 -1
  32. package/dist/api/ThreadListRuntime.js.map +1 -1
  33. package/dist/api/ThreadListRuntime.mjs.map +1 -1
  34. package/dist/api/ThreadRuntime.d.ts +45 -56
  35. package/dist/api/ThreadRuntime.d.ts.map +1 -1
  36. package/dist/api/ThreadRuntime.js.map +1 -1
  37. package/dist/api/ThreadRuntime.mjs.map +1 -1
  38. package/dist/api/index.d.ts +1 -0
  39. package/dist/api/index.d.ts.map +1 -1
  40. package/dist/api/index.js.map +1 -1
  41. package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts +1 -1
  42. package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
  43. package/dist/context/react/AssistantContext.d.ts +10 -48
  44. package/dist/context/react/AssistantContext.d.ts.map +1 -1
  45. package/dist/context/react/AttachmentContext.d.ts +16 -16
  46. package/dist/context/react/MessageContext.d.ts +6 -36
  47. package/dist/context/react/MessageContext.d.ts.map +1 -1
  48. package/dist/context/react/ThreadContext.d.ts +10 -138
  49. package/dist/context/react/ThreadContext.d.ts.map +1 -1
  50. package/dist/context/stores/AssistantToolUIs.d.ts +9 -6
  51. package/dist/context/stores/AssistantToolUIs.d.ts.map +1 -1
  52. package/dist/context/stores/AssistantToolUIs.js.map +1 -1
  53. package/dist/context/stores/AssistantToolUIs.mjs.map +1 -1
  54. package/dist/context/stores/MessageUtils.d.ts +7 -12
  55. package/dist/context/stores/MessageUtils.d.ts.map +1 -1
  56. package/dist/context/stores/MessageUtils.js.map +1 -1
  57. package/dist/context/stores/MessageUtils.mjs.map +1 -1
  58. package/dist/context/stores/ThreadViewport.d.ts +6 -10
  59. package/dist/context/stores/ThreadViewport.d.ts.map +1 -1
  60. package/dist/context/stores/ThreadViewport.js +0 -1
  61. package/dist/context/stores/ThreadViewport.js.map +1 -1
  62. package/dist/context/stores/ThreadViewport.mjs +0 -2
  63. package/dist/context/stores/ThreadViewport.mjs.map +1 -1
  64. package/dist/primitive-hooks/contentPart/useContentPartDisplay.d.ts +1 -1
  65. package/dist/primitive-hooks/contentPart/useContentPartImage.d.ts +1 -1
  66. package/dist/primitive-hooks/contentPart/useContentPartText.d.ts +1 -1
  67. package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts +2 -4
  68. package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts.map +1 -1
  69. package/dist/runtimes/core/ThreadRuntimeCore.d.ts +22 -22
  70. package/dist/runtimes/core/ThreadRuntimeCore.d.ts.map +1 -1
  71. package/dist/runtimes/core/ThreadRuntimeCore.js.map +1 -1
  72. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts +3 -3
  73. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts +2 -11
  74. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
  75. package/package.json +3 -3
  76. package/src/api/AssistantRuntime.ts +2 -2
  77. package/src/api/AttachmentRuntime.ts +4 -4
  78. package/src/api/ComposerRuntime.ts +10 -10
  79. package/src/api/ContentPartRuntime.ts +2 -2
  80. package/src/api/MessageRuntime.ts +9 -9
  81. package/src/api/RuntimePathTypes.ts +26 -26
  82. package/src/api/ThreadListItemRuntime.ts +4 -4
  83. package/src/api/ThreadListRuntime.ts +10 -10
  84. package/src/api/ThreadRuntime.ts +45 -14
  85. package/src/api/index.ts +4 -0
  86. package/src/context/stores/AssistantToolUIs.ts +9 -2
  87. package/src/context/stores/MessageUtils.ts +6 -6
  88. package/src/context/stores/ThreadViewport.tsx +5 -6
  89. package/src/runtimes/core/ThreadRuntimeCore.tsx +28 -29
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/MessageRuntime.ts"],"sourcesContent":["import {\n SpeechState,\n SubmittedFeedback,\n} from \"../runtimes/core/ThreadRuntimeCore\";\nimport {\n ThreadMessage,\n ThreadAssistantContentPart,\n ThreadUserContentPart,\n Unsubscribe,\n} from \"../types\";\nimport {\n ContentPartStatus,\n ToolCallContentPartStatus,\n} from \"../types/AssistantTypes\";\nimport { getThreadMessageText } from \"../utils/getThreadMessageText\";\nimport {\n AttachmentRuntime,\n AttachmentState,\n MessageAttachmentRuntimeImpl,\n} from \"./AttachmentRuntime\";\nimport {\n EditComposerRuntime,\n EditComposerRuntimeImpl,\n} from \"./ComposerRuntime\";\nimport {\n ContentPartRuntime,\n ContentPartRuntimeImpl,\n ContentPartState,\n} from \"./ContentPartRuntime\";\nimport { MessageRuntimePath } from \"./RuntimePathTypes\";\nimport { ThreadRuntimeCoreBinding } from \"./ThreadRuntime\";\nimport { NestedSubscriptionSubject } from \"./subscribable/NestedSubscriptionSubject\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\n\nconst COMPLETE_STATUS: ContentPartStatus = {\n type: \"complete\",\n};\n\nexport const toContentPartStatus = (\n message: ThreadMessage,\n partIndex: number,\n part: ThreadUserContentPart | ThreadAssistantContentPart,\n): ToolCallContentPartStatus => {\n if (message.role !== \"assistant\") return COMPLETE_STATUS;\n\n if (part.type === \"tool-call\") {\n if (!part.result) {\n return message.status as ToolCallContentPartStatus;\n } else {\n return COMPLETE_STATUS;\n }\n }\n\n const isLastPart = partIndex === Math.max(0, message.content.length - 1);\n if (message.status.type === \"requires-action\") return COMPLETE_STATUS;\n return isLastPart ? (message.status as ContentPartStatus) : COMPLETE_STATUS;\n};\n\nexport const EMPTY_CONTENT_SYMBOL = Symbol(\"empty-content\");\nconst EMPTY_CONTENT = Object.freeze({\n type: \"text\",\n text: \"\",\n [EMPTY_CONTENT_SYMBOL]: true,\n});\n\nconst getContentPartState = (\n message: MessageState,\n partIndex: number,\n): ContentPartState | SKIP_UPDATE => {\n let part = message.content[partIndex];\n if (!part) {\n // for empty messages, show an empty text content part\n if (message.content.length === 0 && partIndex === 0) {\n part = EMPTY_CONTENT;\n } else {\n return SKIP_UPDATE;\n }\n } else if (\n message.content.length === 1 &&\n part.type === \"text\" &&\n part.text.length === 0\n ) {\n // ensure reference equality for equivalent empty text parts\n part = EMPTY_CONTENT;\n }\n\n // if the content part is the same, don't update\n const status = toContentPartStatus(message, partIndex, part);\n return Object.freeze({ ...part, status });\n};\n\nexport type MessageState = ThreadMessage & {\n parentId: string | null;\n isLast: boolean;\n\n branchNumber: number;\n branchCount: number;\n\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n speech: SpeechState | undefined;\n submittedFeedback: SubmittedFeedback | undefined;\n};\n\nexport type MessageStateBinding = SubscribableWithState<\n MessageState,\n MessageRuntimePath\n>;\n\nexport type MessageRuntime = {\n readonly path: MessageRuntimePath;\n\n readonly composer: EditComposerRuntime;\n\n getState(): MessageState;\n reload(): void;\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n speak(): void;\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n stopSpeaking(): void;\n submitFeedback({ type }: { type: \"positive\" | \"negative\" }): void;\n switchToBranch({\n position,\n branchId,\n }: {\n position?: \"previous\" | \"next\" | undefined;\n branchId?: string | undefined;\n }): void;\n unstable_getCopyText(): string;\n\n subscribe(callback: () => void): Unsubscribe;\n\n getContentPartByIndex(idx: number): ContentPartRuntime;\n getContentPartByToolCallId(toolCallId: string): ContentPartRuntime;\n\n getAttachmentByIndex(idx: number): AttachmentRuntime & { source: \"message\" };\n};\n\nexport class MessageRuntimeImpl implements MessageRuntime {\n public get path() {\n return this._core.path;\n }\n\n constructor(\n private _core: MessageStateBinding,\n private _threadBinding: ThreadRuntimeCoreBinding,\n ) {\n this.composer = new EditComposerRuntimeImpl(\n new NestedSubscriptionSubject({\n path: {\n ...this.path,\n ref: this.path.ref + `${this.path.ref}.composer`,\n composerSource: \"edit\",\n },\n getState: () =>\n this._threadBinding\n .getState()\n .getEditComposer(this._core.getState().id),\n subscribe: (callback) => this._threadBinding.subscribe(callback),\n }),\n () => this._threadBinding.getState().beginEdit(this._core.getState().id),\n );\n }\n\n public composer;\n\n public getState() {\n return this._core.getState();\n }\n\n public reload() {\n const state = this._core.getState();\n if (state.role !== \"assistant\")\n throw new Error(\"Can only reload assistant messages\");\n\n this._threadBinding.getState().startRun(state.parentId);\n }\n\n public speak() {\n const state = this._core.getState();\n return this._threadBinding.getState().speak(state.id);\n }\n\n public stopSpeaking() {\n const state = this._core.getState();\n const thread = this._threadBinding.getState();\n if (thread.speech?.messageId === state.id) {\n this._threadBinding.getState().stopSpeaking();\n } else {\n throw new Error(\"Message is not being spoken\");\n }\n }\n\n public submitFeedback({ type }: { type: \"positive\" | \"negative\" }) {\n const state = this._core.getState();\n this._threadBinding.getState().submitFeedback({\n messageId: state.id,\n type,\n });\n }\n\n public switchToBranch({\n position,\n branchId,\n }: {\n position?: \"previous\" | \"next\" | undefined;\n branchId?: string | undefined;\n }) {\n const state = this._core.getState();\n if (branchId && position) {\n throw new Error(\"May not specify both branchId and position\");\n } else if (!branchId && !position) {\n throw new Error(\"Must specify either branchId or position\");\n }\n\n const thread = this._threadBinding.getState();\n const branches = thread.getBranches(state.id);\n let targetBranch = branchId;\n if (position === \"previous\") {\n targetBranch = branches[state.branchNumber - 2];\n } else if (position === \"next\") {\n targetBranch = branches[state.branchNumber];\n }\n if (!targetBranch) throw new Error(\"Branch not found\");\n\n this._threadBinding.getState().switchToBranch(targetBranch);\n }\n\n public unstable_getCopyText() {\n return getThreadMessageText(this.getState());\n }\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n\n public getContentPartByIndex(idx: number) {\n if (idx < 0) throw new Error(\"Content part index must be >= 0\");\n return new ContentPartRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n ref: this.path.ref + `${this.path.ref}.content[${idx}]`,\n contentPartSelector: { type: \"index\", index: idx },\n },\n getState: () => {\n return getContentPartState(this.getState(), idx);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n this._threadBinding,\n );\n }\n\n public getContentPartByToolCallId(toolCallId: string) {\n return new ContentPartRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n ref:\n this.path.ref +\n `${this.path.ref}.content[toolCallId=${JSON.stringify(toolCallId)}]`,\n contentPartSelector: { type: \"toolCallId\", toolCallId },\n },\n getState: () => {\n const state = this._core.getState();\n const idx = state.content.findIndex(\n (part) =>\n part.type === \"tool-call\" && part.toolCallId === toolCallId,\n );\n if (idx === -1) return SKIP_UPDATE;\n return getContentPartState(state, idx);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n this._threadBinding,\n );\n }\n\n public getAttachmentByIndex(idx: number) {\n return new MessageAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n ref: this.path.ref + `${this.path.ref}.attachments[${idx}]`,\n attachmentSource: \"message\",\n attachmentSelector: { type: \"index\", index: idx },\n },\n getState: () => {\n const attachments = this.getState().attachments;\n const attachment = attachments?.[idx];\n if (!attachment) return SKIP_UPDATE;\n\n return {\n ...attachment,\n source: \"message\",\n } satisfies AttachmentState & { source: \"message\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n );\n }\n}\n"],"mappings":";AAcA,SAAS,4BAA4B;AACrC;AAAA,EAGE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OAEK;AAGP,SAAS,iCAAiC;AAC1C,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAGtC,IAAM,kBAAqC;AAAA,EACzC,MAAM;AACR;AAEO,IAAM,sBAAsB,CACjC,SACA,WACA,SAC8B;AAC9B,MAAI,QAAQ,SAAS,YAAa,QAAO;AAEzC,MAAI,KAAK,SAAS,aAAa;AAC7B,QAAI,CAAC,KAAK,QAAQ;AAChB,aAAO,QAAQ;AAAA,IACjB,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,aAAa,cAAc,KAAK,IAAI,GAAG,QAAQ,QAAQ,SAAS,CAAC;AACvE,MAAI,QAAQ,OAAO,SAAS,kBAAmB,QAAO;AACtD,SAAO,aAAc,QAAQ,SAA+B;AAC9D;AAEO,IAAM,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MACxD,CAAC;AAAA,MACD,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EAEO,qBAAqB,KAAa;AACvC,WAAO,IAAI;AAAA,MACT,IAAI,sBAAsB;AAAA,QACxB,MAAM;AAAA,UACJ,GAAG,KAAK;AAAA,UACR,KAAK,KAAK,KAAK,MAAM,GAAG,KAAK,KAAK,GAAG,gBAAgB,GAAG;AAAA,UACxD,kBAAkB;AAAA,UAClB,oBAAoB,EAAE,MAAM,SAAS,OAAO,IAAI;AAAA,QAClD;AAAA,QACA,UAAU,MAAM;AACd,gBAAM,cAAc,KAAK,SAAS,EAAE;AACpC,gBAAM,aAAa,cAAc,GAAG;AACpC,cAAI,CAAC,WAAY,QAAO;AAExB,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,QACA,WAAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/api/MessageRuntime.ts"],"sourcesContent":["import {\n SpeechState,\n SubmittedFeedback,\n} from \"../runtimes/core/ThreadRuntimeCore\";\nimport {\n ThreadMessage,\n ThreadAssistantContentPart,\n ThreadUserContentPart,\n Unsubscribe,\n} from \"../types\";\nimport {\n ContentPartStatus,\n ToolCallContentPartStatus,\n} from \"../types/AssistantTypes\";\nimport { getThreadMessageText } from \"../utils/getThreadMessageText\";\nimport {\n AttachmentRuntime,\n AttachmentState,\n MessageAttachmentRuntimeImpl,\n} from \"./AttachmentRuntime\";\nimport {\n EditComposerRuntime,\n EditComposerRuntimeImpl,\n} from \"./ComposerRuntime\";\nimport {\n ContentPartRuntime,\n ContentPartRuntimeImpl,\n ContentPartState,\n} from \"./ContentPartRuntime\";\nimport { MessageRuntimePath } from \"./RuntimePathTypes\";\nimport { ThreadRuntimeCoreBinding } from \"./ThreadRuntime\";\nimport { NestedSubscriptionSubject } from \"./subscribable/NestedSubscriptionSubject\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\n\nconst COMPLETE_STATUS: ContentPartStatus = Object.freeze({\n type: \"complete\",\n});\n\nexport const toContentPartStatus = (\n message: ThreadMessage,\n partIndex: number,\n part: ThreadUserContentPart | ThreadAssistantContentPart,\n): ToolCallContentPartStatus => {\n if (message.role !== \"assistant\") return COMPLETE_STATUS;\n\n if (part.type === \"tool-call\") {\n if (!part.result) {\n return message.status as ToolCallContentPartStatus;\n } else {\n return COMPLETE_STATUS;\n }\n }\n\n const isLastPart = partIndex === Math.max(0, message.content.length - 1);\n if (message.status.type === \"requires-action\") return COMPLETE_STATUS;\n return isLastPart ? (message.status as ContentPartStatus) : COMPLETE_STATUS;\n};\n\nexport const EMPTY_CONTENT_SYMBOL = Symbol(\"empty-content\");\nconst EMPTY_CONTENT = Object.freeze({\n type: \"text\",\n text: \"\",\n [EMPTY_CONTENT_SYMBOL]: true,\n});\n\nconst getContentPartState = (\n message: MessageState,\n partIndex: number,\n): ContentPartState | SKIP_UPDATE => {\n let part = message.content[partIndex];\n if (!part) {\n // for empty messages, show an empty text content part\n if (message.content.length === 0 && partIndex === 0) {\n part = EMPTY_CONTENT;\n } else {\n return SKIP_UPDATE;\n }\n } else if (\n message.content.length === 1 &&\n part.type === \"text\" &&\n part.text.length === 0\n ) {\n // ensure reference equality for equivalent empty text parts\n part = EMPTY_CONTENT;\n }\n\n // if the content part is the same, don't update\n const status = toContentPartStatus(message, partIndex, part);\n return Object.freeze({ ...part, status });\n};\n\nexport type MessageState = ThreadMessage & {\n readonly parentId: string | null;\n readonly isLast: boolean;\n\n readonly branchNumber: number;\n readonly branchCount: number;\n\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n readonly speech: SpeechState | undefined;\n readonly submittedFeedback: SubmittedFeedback | undefined;\n};\n\nexport type MessageStateBinding = SubscribableWithState<\n MessageState,\n MessageRuntimePath\n>;\n\nexport type MessageRuntime = {\n readonly path: MessageRuntimePath;\n\n readonly composer: EditComposerRuntime;\n\n getState(): MessageState;\n reload(): void;\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n speak(): void;\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n stopSpeaking(): void;\n submitFeedback({ type }: { type: \"positive\" | \"negative\" }): void;\n switchToBranch({\n position,\n branchId,\n }: {\n position?: \"previous\" | \"next\" | undefined;\n branchId?: string | undefined;\n }): void;\n unstable_getCopyText(): string;\n\n subscribe(callback: () => void): Unsubscribe;\n\n getContentPartByIndex(idx: number): ContentPartRuntime;\n getContentPartByToolCallId(toolCallId: string): ContentPartRuntime;\n\n getAttachmentByIndex(idx: number): AttachmentRuntime & { source: \"message\" };\n};\n\nexport class MessageRuntimeImpl implements MessageRuntime {\n public get path() {\n return this._core.path;\n }\n\n constructor(\n private _core: MessageStateBinding,\n private _threadBinding: ThreadRuntimeCoreBinding,\n ) {\n this.composer = new EditComposerRuntimeImpl(\n new NestedSubscriptionSubject({\n path: {\n ...this.path,\n ref: this.path.ref + `${this.path.ref}.composer`,\n composerSource: \"edit\",\n },\n getState: () =>\n this._threadBinding\n .getState()\n .getEditComposer(this._core.getState().id),\n subscribe: (callback) => this._threadBinding.subscribe(callback),\n }),\n () => this._threadBinding.getState().beginEdit(this._core.getState().id),\n );\n }\n\n public readonly composer;\n\n public getState() {\n return this._core.getState();\n }\n\n public reload() {\n const state = this._core.getState();\n if (state.role !== \"assistant\")\n throw new Error(\"Can only reload assistant messages\");\n\n this._threadBinding.getState().startRun(state.parentId);\n }\n\n public speak() {\n const state = this._core.getState();\n return this._threadBinding.getState().speak(state.id);\n }\n\n public stopSpeaking() {\n const state = this._core.getState();\n const thread = this._threadBinding.getState();\n if (thread.speech?.messageId === state.id) {\n this._threadBinding.getState().stopSpeaking();\n } else {\n throw new Error(\"Message is not being spoken\");\n }\n }\n\n public submitFeedback({ type }: { type: \"positive\" | \"negative\" }) {\n const state = this._core.getState();\n this._threadBinding.getState().submitFeedback({\n messageId: state.id,\n type,\n });\n }\n\n public switchToBranch({\n position,\n branchId,\n }: {\n position?: \"previous\" | \"next\" | undefined;\n branchId?: string | undefined;\n }) {\n const state = this._core.getState();\n if (branchId && position) {\n throw new Error(\"May not specify both branchId and position\");\n } else if (!branchId && !position) {\n throw new Error(\"Must specify either branchId or position\");\n }\n\n const thread = this._threadBinding.getState();\n const branches = thread.getBranches(state.id);\n let targetBranch = branchId;\n if (position === \"previous\") {\n targetBranch = branches[state.branchNumber - 2];\n } else if (position === \"next\") {\n targetBranch = branches[state.branchNumber];\n }\n if (!targetBranch) throw new Error(\"Branch not found\");\n\n this._threadBinding.getState().switchToBranch(targetBranch);\n }\n\n public unstable_getCopyText() {\n return getThreadMessageText(this.getState());\n }\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n\n public getContentPartByIndex(idx: number) {\n if (idx < 0) throw new Error(\"Content part index must be >= 0\");\n return new ContentPartRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n ref: this.path.ref + `${this.path.ref}.content[${idx}]`,\n contentPartSelector: { type: \"index\", index: idx },\n },\n getState: () => {\n return getContentPartState(this.getState(), idx);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n this._threadBinding,\n );\n }\n\n public getContentPartByToolCallId(toolCallId: string) {\n return new ContentPartRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n ref:\n this.path.ref +\n `${this.path.ref}.content[toolCallId=${JSON.stringify(toolCallId)}]`,\n contentPartSelector: { type: \"toolCallId\", toolCallId },\n },\n getState: () => {\n const state = this._core.getState();\n const idx = state.content.findIndex(\n (part) =>\n part.type === \"tool-call\" && part.toolCallId === toolCallId,\n );\n if (idx === -1) return SKIP_UPDATE;\n return getContentPartState(state, idx);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n this._threadBinding,\n );\n }\n\n public getAttachmentByIndex(idx: number) {\n return new MessageAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n ref: this.path.ref + `${this.path.ref}.attachments[${idx}]`,\n attachmentSource: \"message\",\n attachmentSelector: { type: \"index\", index: idx },\n },\n getState: () => {\n const attachments = this.getState().attachments;\n const attachment = attachments?.[idx];\n if (!attachment) return SKIP_UPDATE;\n\n return {\n ...attachment,\n source: \"message\",\n } satisfies AttachmentState & { source: \"message\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n );\n }\n}\n"],"mappings":";AAcA,SAAS,4BAA4B;AACrC;AAAA,EAGE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OAEK;AAGP,SAAS,iCAAiC;AAC1C,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAGtC,IAAM,kBAAqC,OAAO,OAAO;AAAA,EACvD,MAAM;AACR,CAAC;AAEM,IAAM,sBAAsB,CACjC,SACA,WACA,SAC8B;AAC9B,MAAI,QAAQ,SAAS,YAAa,QAAO;AAEzC,MAAI,KAAK,SAAS,aAAa;AAC7B,QAAI,CAAC,KAAK,QAAQ;AAChB,aAAO,QAAQ;AAAA,IACjB,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,aAAa,cAAc,KAAK,IAAI,GAAG,QAAQ,QAAQ,SAAS,CAAC;AACvE,MAAI,QAAQ,OAAO,SAAS,kBAAmB,QAAO;AACtD,SAAO,aAAc,QAAQ,SAA+B;AAC9D;AAEO,IAAM,uBAAuB,OAAO,eAAe;AAC1D,IAAM,gBAAgB,OAAO,OAAO;AAAA,EAClC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,CAAC,oBAAoB,GAAG;AAC1B,CAAC;AAED,IAAM,sBAAsB,CAC1B,SACA,cACmC;AACnC,MAAI,OAAO,QAAQ,QAAQ,SAAS;AACpC,MAAI,CAAC,MAAM;AAET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,gBAAgB,GAAG;AAAA,UACxD,kBAAkB;AAAA,UAClB,oBAAoB,EAAE,MAAM,SAAS,OAAO,IAAI;AAAA,QAClD;AAAA,QACA,UAAU,MAAM;AACd,gBAAM,cAAc,KAAK,SAAS,EAAE;AACpC,gBAAM,aAAa,cAAc,GAAG;AACpC,cAAI,CAAC,WAAY,QAAO;AAExB,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,QACA,WAAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
@@ -1,64 +1,64 @@
1
1
  export type ThreadListRuntimePath = {
2
- ref: string;
2
+ readonly ref: string;
3
3
  };
4
4
  export type ThreadListItemRuntimePath = {
5
- ref: string;
6
- threadSelector: {
7
- type: "main";
5
+ readonly ref: string;
6
+ readonly threadSelector: {
7
+ readonly type: "main";
8
8
  } | {
9
- type: "index";
10
- index: number;
9
+ readonly type: "index";
10
+ readonly index: number;
11
11
  } | {
12
- type: "archiveIndex";
13
- index: number;
12
+ readonly type: "archiveIndex";
13
+ readonly index: number;
14
14
  } | {
15
- type: "threadId";
16
- threadId: string;
15
+ readonly type: "threadId";
16
+ readonly threadId: string;
17
17
  };
18
18
  };
19
19
  export type ThreadRuntimePath = {
20
- ref: string;
21
- threadSelector: {
20
+ readonly ref: string;
21
+ readonly threadSelector: {
22
22
  type: "main";
23
23
  };
24
24
  };
25
25
  export type MessageRuntimePath = ThreadRuntimePath & {
26
- messageSelector: {
27
- type: "messageId";
28
- messageId: string;
26
+ readonly messageSelector: {
27
+ readonly type: "messageId";
28
+ readonly messageId: string;
29
29
  } | {
30
- type: "index";
31
- index: number;
30
+ readonly type: "index";
31
+ readonly index: number;
32
32
  };
33
33
  };
34
34
  export type ContentPartRuntimePath = MessageRuntimePath & {
35
- contentPartSelector: {
36
- type: "index";
37
- index: number;
35
+ readonly contentPartSelector: {
36
+ readonly type: "index";
37
+ readonly index: number;
38
38
  } | {
39
- type: "toolCallId";
40
- toolCallId: string;
39
+ readonly type: "toolCallId";
40
+ readonly toolCallId: string;
41
41
  };
42
42
  };
43
43
  export type AttachmentRuntimePath = ((MessageRuntimePath & {
44
- attachmentSource: "message" | "edit-composer";
44
+ readonly attachmentSource: "message" | "edit-composer";
45
45
  }) | (ThreadRuntimePath & {
46
- attachmentSource: "thread-composer";
46
+ readonly attachmentSource: "thread-composer";
47
47
  })) & {
48
- attachmentSelector: {
49
- type: "index";
50
- index: number;
48
+ readonly attachmentSelector: {
49
+ readonly type: "index";
50
+ readonly index: number;
51
51
  } | {
52
- type: "index";
53
- index: number;
52
+ readonly type: "index";
53
+ readonly index: number;
54
54
  } | {
55
- type: "index";
56
- index: number;
55
+ readonly type: "index";
56
+ readonly index: number;
57
57
  };
58
58
  };
59
59
  export type ComposerRuntimePath = (ThreadRuntimePath & {
60
- composerSource: "thread";
60
+ readonly composerSource: "thread";
61
61
  }) | (MessageRuntimePath & {
62
- composerSource: "edit";
62
+ readonly composerSource: "edit";
63
63
  });
64
64
  //# sourceMappingURL=RuntimePathTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RuntimePathTypes.d.ts","sourceRoot":"","sources":["../../src/api/RuntimePathTypes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EACV;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAChB;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAChC;QAAE,IAAI,EAAE,cAAc,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GACvC;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5C,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,GAClD;QAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;QAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;CAClE,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,CAChC,CAAC,kBAAkB,GAAG;IACpB,QAAQ,CAAC,gBAAgB,EAAE,SAAS,GAAG,eAAe,CAAC;CACxD,CAAC,GACF,CAAC,iBAAiB,GAAG;IACnB,QAAQ,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;CAC9C,CAAC,CACL,GAAG;IACF,QAAQ,CAAC,kBAAkB,EACvB;QACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;QACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;KACxB,GACD;QACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;QACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;KACxB,GACD;QACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;QACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;KACxB,CAAC;CACP,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC3B,CAAC,iBAAiB,GAAG;IACnB,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC;CACnC,CAAC,GACF,CAAC,kBAAkB,GAAG;IACpB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/RuntimePathTypes.ts"],"sourcesContent":["export type ThreadListRuntimePath = {\n ref: string;\n};\n\nexport type ThreadListItemRuntimePath = {\n ref: string;\n threadSelector:\n | { type: \"main\" }\n | { type: \"index\"; index: number }\n | { type: \"archiveIndex\"; index: number }\n | { type: \"threadId\"; threadId: string };\n};\n\nexport type ThreadRuntimePath = {\n ref: string;\n threadSelector: { type: \"main\" };\n};\n\nexport type MessageRuntimePath = ThreadRuntimePath & {\n messageSelector:\n | { type: \"messageId\"; messageId: string }\n | { type: \"index\"; index: number };\n};\n\nexport type ContentPartRuntimePath = MessageRuntimePath & {\n contentPartSelector:\n | { type: \"index\"; index: number }\n | { type: \"toolCallId\"; toolCallId: string };\n};\n\nexport type AttachmentRuntimePath = (\n | (MessageRuntimePath & {\n attachmentSource: \"message\" | \"edit-composer\";\n })\n | (ThreadRuntimePath & {\n attachmentSource: \"thread-composer\";\n })\n) & {\n attachmentSelector:\n | {\n type: \"index\";\n index: number;\n }\n | {\n type: \"index\";\n index: number;\n }\n | {\n type: \"index\";\n index: number;\n };\n};\n\nexport type ComposerRuntimePath =\n | (ThreadRuntimePath & {\n composerSource: \"thread\";\n })\n | (MessageRuntimePath & {\n composerSource: \"edit\";\n });\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/api/RuntimePathTypes.ts"],"sourcesContent":["export type ThreadListRuntimePath = {\n readonly ref: string;\n};\n\nexport type ThreadListItemRuntimePath = {\n readonly ref: string;\n readonly threadSelector:\n | { readonly type: \"main\" }\n | { readonly type: \"index\"; readonly index: number }\n | { readonly type: \"archiveIndex\"; readonly index: number }\n | { readonly type: \"threadId\"; readonly threadId: string };\n};\n\nexport type ThreadRuntimePath = {\n readonly ref: string;\n readonly threadSelector: { type: \"main\" };\n};\n\nexport type MessageRuntimePath = ThreadRuntimePath & {\n readonly messageSelector:\n | { readonly type: \"messageId\"; readonly messageId: string }\n | { readonly type: \"index\"; readonly index: number };\n};\n\nexport type ContentPartRuntimePath = MessageRuntimePath & {\n readonly contentPartSelector:\n | { readonly type: \"index\"; readonly index: number }\n | { readonly type: \"toolCallId\"; readonly toolCallId: string };\n};\n\nexport type AttachmentRuntimePath = (\n | (MessageRuntimePath & {\n readonly attachmentSource: \"message\" | \"edit-composer\";\n })\n | (ThreadRuntimePath & {\n readonly attachmentSource: \"thread-composer\";\n })\n) & {\n readonly attachmentSelector:\n | {\n readonly type: \"index\";\n readonly index: number;\n }\n | {\n readonly type: \"index\";\n readonly index: number;\n }\n | {\n readonly type: \"index\";\n readonly index: number;\n };\n};\n\nexport type ComposerRuntimePath =\n | (ThreadRuntimePath & {\n readonly composerSource: \"thread\";\n })\n | (MessageRuntimePath & {\n readonly composerSource: \"edit\";\n });\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -4,10 +4,10 @@ import { ThreadListItemRuntimePath } from "./RuntimePathTypes";
4
4
  import { SubscribableWithState } from "./subscribable/Subscribable";
5
5
  import { ThreadListRuntimeCoreBinding } from "./ThreadListRuntime";
6
6
  export type ThreadListItemState = ThreadMetadata & {
7
- isMain: boolean;
7
+ readonly isMain: boolean;
8
8
  };
9
- export type ThreadListItemRuntime = Readonly<{
10
- path: ThreadListItemRuntimePath;
9
+ export type ThreadListItemRuntime = {
10
+ readonly path: ThreadListItemRuntimePath;
11
11
  getState(): ThreadListItemState;
12
12
  switchTo(): Promise<void>;
13
13
  rename(newTitle: string): Promise<void>;
@@ -15,7 +15,7 @@ export type ThreadListItemRuntime = Readonly<{
15
15
  unarchive(): Promise<void>;
16
16
  delete(): Promise<void>;
17
17
  subscribe(callback: () => void): Unsubscribe;
18
- }>;
18
+ };
19
19
  export type ThreadListItemStateBinding = SubscribableWithState<ThreadListItemState, ThreadListItemRuntimePath>;
20
20
  export declare class ThreadListItemRuntimeImpl implements ThreadListItemRuntime {
21
21
  private _core;
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadListItemRuntime.d.ts","sourceRoot":"","sources":["../../src/api/ThreadListItemRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAEnE,MAAM,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AAC,IAAI,CAAC;IAMxB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAM1B,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAMvB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW;CAGpD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/ThreadListItemRuntime.ts"],"sourcesContent":["import { ThreadMetadata } from \"../runtimes/core/ThreadRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport { ThreadListItemRuntimePath } from \"./RuntimePathTypes\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { ThreadListRuntimeCoreBinding } from \"./ThreadListRuntime\";\n\nexport type ThreadListItemState = ThreadMetadata & {\n isMain: boolean;\n};\n\nexport type ThreadListItemRuntime = Readonly<{\n path: ThreadListItemRuntimePath;\n getState(): ThreadListItemState;\n\n switchTo(): Promise<void>;\n rename(newTitle: string): Promise<void>;\n archive(): Promise<void>;\n unarchive(): Promise<void>;\n delete(): Promise<void>;\n\n subscribe(callback: () => void): Unsubscribe;\n}>;\n\nexport type ThreadListItemStateBinding = SubscribableWithState<\n ThreadListItemState,\n ThreadListItemRuntimePath\n>;\n\nexport class ThreadListItemRuntimeImpl implements ThreadListItemRuntime {\n public get path() {\n return this._core.path;\n }\n\n constructor(\n private _core: ThreadListItemStateBinding,\n private _threadListBinding: ThreadListRuntimeCoreBinding,\n ) {}\n\n public getState(): ThreadListItemState {\n return this._core.getState();\n }\n\n public switchTo(): Promise<void> {\n const state = this._core.getState();\n return this._threadListBinding.switchToThread(state.threadId);\n }\n\n public rename(newTitle: string): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.rename(state.threadId, newTitle);\n }\n\n public archive(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.archive(state.threadId);\n }\n\n public unarchive(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.unarchive(state.threadId);\n }\n\n public delete(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.delete(state.threadId);\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n return this._core.subscribe(callback);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BO,IAAM,4BAAN,MAAiE;AAAA,EAKtE,YACU,OACA,oBACR;AAFQ;AACA;AAAA,EACP;AAAA,EAPH,IAAW,OAAO;AAChB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA,EAOO,WAAgC;AACrC,WAAO,KAAK,MAAM,SAAS;AAAA,EAC7B;AAAA,EAEO,WAA0B;AAC/B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAClC,WAAO,KAAK,mBAAmB,eAAe,MAAM,QAAQ;AAAA,EAC9D;AAAA,EAEO,OAAO,UAAiC;AAC7C,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,OAAO,MAAM,UAAU,QAAQ;AAAA,EAChE;AAAA,EAEO,UAAyB;AAC9B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,QAAQ,MAAM,QAAQ;AAAA,EACvD;AAAA,EAEO,YAA2B;AAChC,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,UAAU,MAAM,QAAQ;AAAA,EACzD;AAAA,EAEO,SAAwB;AAC7B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,OAAO,MAAM,QAAQ;AAAA,EACtD;AAAA,EAEO,UAAU,UAAmC;AAClD,WAAO,KAAK,MAAM,UAAU,QAAQ;AAAA,EACtC;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/api/ThreadListItemRuntime.ts"],"sourcesContent":["import { ThreadMetadata } from \"../runtimes/core/ThreadRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport { ThreadListItemRuntimePath } from \"./RuntimePathTypes\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { ThreadListRuntimeCoreBinding } from \"./ThreadListRuntime\";\n\nexport type ThreadListItemState = ThreadMetadata & {\n readonly isMain: boolean;\n};\n\nexport type ThreadListItemRuntime = {\n readonly path: ThreadListItemRuntimePath;\n getState(): ThreadListItemState;\n\n switchTo(): Promise<void>;\n rename(newTitle: string): Promise<void>;\n archive(): Promise<void>;\n unarchive(): Promise<void>;\n delete(): Promise<void>;\n\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport type ThreadListItemStateBinding = SubscribableWithState<\n ThreadListItemState,\n ThreadListItemRuntimePath\n>;\n\nexport class ThreadListItemRuntimeImpl implements ThreadListItemRuntime {\n public get path() {\n return this._core.path;\n }\n\n constructor(\n private _core: ThreadListItemStateBinding,\n private _threadListBinding: ThreadListRuntimeCoreBinding,\n ) {}\n\n public getState(): ThreadListItemState {\n return this._core.getState();\n }\n\n public switchTo(): Promise<void> {\n const state = this._core.getState();\n return this._threadListBinding.switchToThread(state.threadId);\n }\n\n public rename(newTitle: string): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.rename(state.threadId, newTitle);\n }\n\n public archive(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.archive(state.threadId);\n }\n\n public unarchive(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.unarchive(state.threadId);\n }\n\n public delete(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.delete(state.threadId);\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n return this._core.subscribe(callback);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BO,IAAM,4BAAN,MAAiE;AAAA,EAKtE,YACU,OACA,oBACR;AAFQ;AACA;AAAA,EACP;AAAA,EAPH,IAAW,OAAO;AAChB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA,EAOO,WAAgC;AACrC,WAAO,KAAK,MAAM,SAAS;AAAA,EAC7B;AAAA,EAEO,WAA0B;AAC/B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAClC,WAAO,KAAK,mBAAmB,eAAe,MAAM,QAAQ;AAAA,EAC9D;AAAA,EAEO,OAAO,UAAiC;AAC7C,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,OAAO,MAAM,UAAU,QAAQ;AAAA,EAChE;AAAA,EAEO,UAAyB;AAC9B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,QAAQ,MAAM,QAAQ;AAAA,EACvD;AAAA,EAEO,YAA2B;AAChC,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,UAAU,MAAM,QAAQ;AAAA,EACzD;AAAA,EAEO,SAAwB;AAC7B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,OAAO,MAAM,QAAQ;AAAA,EACtD;AAAA,EAEO,UAAU,UAAmC;AAClD,WAAO,KAAK,MAAM,UAAU,QAAQ;AAAA,EACtC;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/ThreadListItemRuntime.ts"],"sourcesContent":["import { ThreadMetadata } from \"../runtimes/core/ThreadRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport { ThreadListItemRuntimePath } from \"./RuntimePathTypes\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { ThreadListRuntimeCoreBinding } from \"./ThreadListRuntime\";\n\nexport type ThreadListItemState = ThreadMetadata & {\n isMain: boolean;\n};\n\nexport type ThreadListItemRuntime = Readonly<{\n path: ThreadListItemRuntimePath;\n getState(): ThreadListItemState;\n\n switchTo(): Promise<void>;\n rename(newTitle: string): Promise<void>;\n archive(): Promise<void>;\n unarchive(): Promise<void>;\n delete(): Promise<void>;\n\n subscribe(callback: () => void): Unsubscribe;\n}>;\n\nexport type ThreadListItemStateBinding = SubscribableWithState<\n ThreadListItemState,\n ThreadListItemRuntimePath\n>;\n\nexport class ThreadListItemRuntimeImpl implements ThreadListItemRuntime {\n public get path() {\n return this._core.path;\n }\n\n constructor(\n private _core: ThreadListItemStateBinding,\n private _threadListBinding: ThreadListRuntimeCoreBinding,\n ) {}\n\n public getState(): ThreadListItemState {\n return this._core.getState();\n }\n\n public switchTo(): Promise<void> {\n const state = this._core.getState();\n return this._threadListBinding.switchToThread(state.threadId);\n }\n\n public rename(newTitle: string): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.rename(state.threadId, newTitle);\n }\n\n public archive(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.archive(state.threadId);\n }\n\n public unarchive(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.unarchive(state.threadId);\n }\n\n public delete(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.delete(state.threadId);\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n return this._core.subscribe(callback);\n }\n}\n"],"mappings":";AA4BO,IAAM,4BAAN,MAAiE;AAAA,EAKtE,YACU,OACA,oBACR;AAFQ;AACA;AAAA,EACP;AAAA,EAPH,IAAW,OAAO;AAChB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA,EAOO,WAAgC;AACrC,WAAO,KAAK,MAAM,SAAS;AAAA,EAC7B;AAAA,EAEO,WAA0B;AAC/B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAClC,WAAO,KAAK,mBAAmB,eAAe,MAAM,QAAQ;AAAA,EAC9D;AAAA,EAEO,OAAO,UAAiC;AAC7C,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,OAAO,MAAM,UAAU,QAAQ;AAAA,EAChE;AAAA,EAEO,UAAyB;AAC9B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,QAAQ,MAAM,QAAQ;AAAA,EACvD;AAAA,EAEO,YAA2B;AAChC,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,UAAU,MAAM,QAAQ;AAAA,EACzD;AAAA,EAEO,SAAwB;AAC7B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,OAAO,MAAM,QAAQ;AAAA,EACtD;AAAA,EAEO,UAAU,UAAmC;AAClD,WAAO,KAAK,MAAM,UAAU,QAAQ;AAAA,EACtC;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/api/ThreadListItemRuntime.ts"],"sourcesContent":["import { ThreadMetadata } from \"../runtimes/core/ThreadRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport { ThreadListItemRuntimePath } from \"./RuntimePathTypes\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { ThreadListRuntimeCoreBinding } from \"./ThreadListRuntime\";\n\nexport type ThreadListItemState = ThreadMetadata & {\n readonly isMain: boolean;\n};\n\nexport type ThreadListItemRuntime = {\n readonly path: ThreadListItemRuntimePath;\n getState(): ThreadListItemState;\n\n switchTo(): Promise<void>;\n rename(newTitle: string): Promise<void>;\n archive(): Promise<void>;\n unarchive(): Promise<void>;\n delete(): Promise<void>;\n\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport type ThreadListItemStateBinding = SubscribableWithState<\n ThreadListItemState,\n ThreadListItemRuntimePath\n>;\n\nexport class ThreadListItemRuntimeImpl implements ThreadListItemRuntime {\n public get path() {\n return this._core.path;\n }\n\n constructor(\n private _core: ThreadListItemStateBinding,\n private _threadListBinding: ThreadListRuntimeCoreBinding,\n ) {}\n\n public getState(): ThreadListItemState {\n return this._core.getState();\n }\n\n public switchTo(): Promise<void> {\n const state = this._core.getState();\n return this._threadListBinding.switchToThread(state.threadId);\n }\n\n public rename(newTitle: string): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.rename(state.threadId, newTitle);\n }\n\n public archive(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.archive(state.threadId);\n }\n\n public unarchive(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.unarchive(state.threadId);\n }\n\n public delete(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.delete(state.threadId);\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n return this._core.subscribe(callback);\n }\n}\n"],"mappings":";AA4BO,IAAM,4BAAN,MAAiE;AAAA,EAKtE,YACU,OACA,oBACR;AAFQ;AACA;AAAA,EACP;AAAA,EAPH,IAAW,OAAO;AAChB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA,EAOO,WAAgC;AACrC,WAAO,KAAK,MAAM,SAAS;AAAA,EAC7B;AAAA,EAEO,WAA0B;AAC/B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAClC,WAAO,KAAK,mBAAmB,eAAe,MAAM,QAAQ;AAAA,EAC9D;AAAA,EAEO,OAAO,UAAiC;AAC7C,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,OAAO,MAAM,UAAU,QAAQ;AAAA,EAChE;AAAA,EAEO,UAAyB;AAC9B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,QAAQ,MAAM,QAAQ;AAAA,EACvD;AAAA,EAEO,YAA2B;AAChC,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,UAAU,MAAM,QAAQ;AAAA,EACzD;AAAA,EAEO,SAAwB;AAC7B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,OAAO,MAAM,QAAQ;AAAA,EACtD;AAAA,EAEO,UAAU,UAAmC;AAClD,WAAO,KAAK,MAAM,UAAU,QAAQ;AAAA,EACtC;AACF;","names":[]}
@@ -2,20 +2,20 @@ import { ThreadListRuntimeCore } from "../runtimes/core/ThreadListRuntimeCore";
2
2
  import { Unsubscribe } from "../types";
3
3
  import { ThreadListRuntimePath } from "./RuntimePathTypes";
4
4
  import { ThreadListItemRuntime, ThreadListItemRuntimeImpl } from "./ThreadListItemRuntime";
5
- export type ThreadListState = Readonly<{
6
- mainThreadId: string;
7
- newThread: string | undefined;
8
- threads: readonly string[];
9
- archivedThreads: readonly string[];
10
- }>;
11
- export type ThreadListRuntime = Readonly<{
12
- path: ThreadListRuntimePath;
5
+ export type ThreadListState = {
6
+ readonly mainThreadId: string;
7
+ readonly newThread: string | undefined;
8
+ readonly threads: readonly string[];
9
+ readonly archivedThreads: readonly string[];
10
+ };
11
+ export type ThreadListRuntime = {
12
+ readonly path: ThreadListRuntimePath;
13
13
  getState(): ThreadListState;
14
14
  subscribe(callback: () => void): Unsubscribe;
15
15
  getThreadListItemById(threadId: string): ThreadListItemRuntime;
16
16
  getThreadListItemByIndex(idx: number): ThreadListItemRuntime;
17
17
  getThreadListArchivedItemByIndex(idx: number): ThreadListItemRuntime;
18
- }>;
18
+ };
19
19
  export type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;
20
20
  export declare class ThreadListRuntimeImpl implements ThreadListRuntime {
21
21
  private _core;
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadListRuntime.d.ts","sourceRoot":"","sources":["../../src/api/ThreadListRuntime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EAE1B,MAAM,yBAAyB,CAAC;AAIjC,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC,CAAC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,QAAQ,IA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,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,IAAI,eAAe,CAAC;IAE5B,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;IAE7C,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,CAAC;IAC/D,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAAC;IAC7D,gCAAgC,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAAC;CACtE,CAAC;AAiCF,MAAM,MAAM,4BAA4B,GAAG,qBAAqB,CAAC;AAEjE,qBAAa,qBAAsB,YAAW,iBAAiB;IAMjD,OAAO,CAAC,KAAK;IALzB,IAAW,IAAI;;MAEd;IAED,OAAO,CAAC,SAAS,CAAC;gBACE,KAAK,EAAE,4BAA4B;IAUhD,QAAQ,IAAI,eAAe;IAI3B,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW;IAI5C,wBAAwB,CAAC,GAAG,EAAE,MAAM;IAgBpC,gCAAgC,CAAC,GAAG,EAAE,MAAM;IAmB5C,qBAAqB,CAAC,QAAQ,EAAE,MAAM;CAiB9C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/ThreadListRuntime.ts"],"sourcesContent":["import { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport { ThreadListRuntimeCore } from \"../runtimes/core/ThreadListRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport { ThreadListRuntimePath } from \"./RuntimePathTypes\";\nimport {\n ThreadListItemRuntime,\n ThreadListItemRuntimeImpl,\n ThreadListItemState,\n} from \"./ThreadListItemRuntime\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\n\nexport type ThreadListState = Readonly<{\n mainThreadId: string;\n newThread: string | undefined;\n threads: readonly string[];\n archivedThreads: readonly string[];\n}>;\n\nexport type ThreadListRuntime = Readonly<{\n path: ThreadListRuntimePath;\n getState(): ThreadListState;\n\n subscribe(callback: () => void): Unsubscribe;\n\n getThreadListItemById(threadId: string): ThreadListItemRuntime;\n getThreadListItemByIndex(idx: number): ThreadListItemRuntime;\n getThreadListArchivedItemByIndex(idx: number): ThreadListItemRuntime;\n}>;\n\nconst getThreadListState = (\n threadList: ThreadListRuntimeCore,\n): ThreadListState => {\n return {\n mainThreadId: threadList.mainThread.metadata.threadId,\n newThread: threadList.newThread,\n threads: threadList.threads,\n archivedThreads: threadList.archivedThreads,\n };\n};\n\nconst getThreadListItemState = (\n threadList: ThreadListRuntimeCore,\n threadId: string | undefined,\n): ThreadListItemState | SKIP_UPDATE => {\n if (threadId === undefined) return SKIP_UPDATE;\n\n const threadData = threadList.getThreadMetadataById(threadId);\n if (!threadData) return SKIP_UPDATE;\n return {\n threadId: threadData.threadId,\n title: threadData.title,\n state: threadData.state,\n isMain: threadList.mainThread.metadata.threadId === threadId,\n };\n};\n\nconst THREAD_MANAGER_PATH = {\n ref: \"ThreadList\",\n};\n\nexport type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;\n\nexport class ThreadListRuntimeImpl implements ThreadListRuntime {\n public get path() {\n return THREAD_MANAGER_PATH;\n }\n\n private _getState;\n constructor(private _core: ThreadListRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: THREAD_MANAGER_PATH,\n getState: () => getThreadListState(_core),\n subscribe: (callback) => _core.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public getState(): ThreadListState {\n return this._getState();\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n return this._core.subscribe(callback);\n }\n\n public getThreadListItemByIndex(idx: number) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: this.path.ref + `${this.path.ref}.threadItems[${idx}]`,\n threadSelector: { type: \"index\", index: idx },\n },\n getState: () => {\n return getThreadListItemState(this._core, this._core.threads[idx]);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getThreadListArchivedItemByIndex(idx: number) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: this.path.ref + `${this.path.ref}.archivedThreadItems[${idx}]`,\n threadSelector: { type: \"archiveIndex\", index: idx },\n },\n getState: () => {\n return getThreadListItemState(\n this._core,\n this._core.archivedThreads[idx],\n );\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getThreadListItemById(threadId: string) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref:\n this.path.ref +\n `${this.path.ref}.threadItems[threadId=${threadId}]`,\n threadSelector: { type: \"threadId\", threadId },\n },\n getState: () => {\n return getThreadListItemState(this._core, threadId);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAmC;AAInC,mCAIO;AACP,yBAA4B;AAC5B,mCAAsC;AAoBtC,IAAM,qBAAqB,CACzB,eACoB;AACpB,SAAO;AAAA,IACL,cAAc,WAAW,WAAW,SAAS;AAAA,IAC7C,WAAW,WAAW;AAAA,IACtB,SAAS,WAAW;AAAA,IACpB,iBAAiB,WAAW;AAAA,EAC9B;AACF;AAEA,IAAM,yBAAyB,CAC7B,YACA,aACsC;AACtC,MAAI,aAAa,OAAW,QAAO;AAEnC,QAAM,aAAa,WAAW,sBAAsB,QAAQ;AAC5D,MAAI,CAAC,WAAY,QAAO;AACxB,SAAO;AAAA,IACL,UAAU,WAAW;AAAA,IACrB,OAAO,WAAW;AAAA,IAClB,OAAO,WAAW;AAAA,IAClB,QAAQ,WAAW,WAAW,SAAS,aAAa;AAAA,EACtD;AACF;AAEA,IAAM,sBAAsB;AAA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G;AAAA,UAChC;AAAA,QACF;AAAA,QACA,WAAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,MACD,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EAEO,sBAAsB,UAAkB;AAC7C,WAAO,IAAI;AAAA,MACT,IAAI,mDAAsB;AAAA,QACxB,MAAM;AAAA,UACJ,KACE,KAAK,KAAK,MACV,GAAG,KAAK,KAAK,GAAG,yBAAyB,QAAQ;AAAA,UACnD,gBAAgB,EAAE,MAAM,YAAY,SAAS;AAAA,QAC/C;AAAA,QACA,UAAU,MAAM;AACd,iBAAO,uBAAuB,KAAK,OAAO,QAAQ;AAAA,QACpD;AAAA,QACA,WAAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,MACD,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/api/ThreadListRuntime.ts"],"sourcesContent":["import { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport { ThreadListRuntimeCore } from \"../runtimes/core/ThreadListRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport { ThreadListRuntimePath } from \"./RuntimePathTypes\";\nimport {\n ThreadListItemRuntime,\n ThreadListItemRuntimeImpl,\n ThreadListItemState,\n} from \"./ThreadListItemRuntime\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\n\nexport type ThreadListState = {\n readonly mainThreadId: string;\n readonly newThread: string | undefined;\n readonly threads: readonly string[];\n readonly archivedThreads: readonly string[];\n};\n\nexport type ThreadListRuntime = {\n readonly path: ThreadListRuntimePath;\n getState(): ThreadListState;\n\n subscribe(callback: () => void): Unsubscribe;\n\n getThreadListItemById(threadId: string): ThreadListItemRuntime;\n getThreadListItemByIndex(idx: number): ThreadListItemRuntime;\n getThreadListArchivedItemByIndex(idx: number): ThreadListItemRuntime;\n};\n\nconst getThreadListState = (\n threadList: ThreadListRuntimeCore,\n): ThreadListState => {\n return {\n mainThreadId: threadList.mainThread.metadata.threadId,\n newThread: threadList.newThread,\n threads: threadList.threads,\n archivedThreads: threadList.archivedThreads,\n };\n};\n\nconst getThreadListItemState = (\n threadList: ThreadListRuntimeCore,\n threadId: string | undefined,\n): ThreadListItemState | SKIP_UPDATE => {\n if (threadId === undefined) return SKIP_UPDATE;\n\n const threadData = threadList.getThreadMetadataById(threadId);\n if (!threadData) return SKIP_UPDATE;\n return {\n threadId: threadData.threadId,\n title: threadData.title,\n state: threadData.state,\n isMain: threadList.mainThread.metadata.threadId === threadId,\n };\n};\n\nconst THREAD_MANAGER_PATH = {\n ref: \"ThreadList\",\n};\n\nexport type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;\n\nexport class ThreadListRuntimeImpl implements ThreadListRuntime {\n public get path() {\n return THREAD_MANAGER_PATH;\n }\n\n private _getState;\n constructor(private _core: ThreadListRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: THREAD_MANAGER_PATH,\n getState: () => getThreadListState(_core),\n subscribe: (callback) => _core.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public getState(): ThreadListState {\n return this._getState();\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n return this._core.subscribe(callback);\n }\n\n public getThreadListItemByIndex(idx: number) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: this.path.ref + `${this.path.ref}.threadItems[${idx}]`,\n threadSelector: { type: \"index\", index: idx },\n },\n getState: () => {\n return getThreadListItemState(this._core, this._core.threads[idx]);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getThreadListArchivedItemByIndex(idx: number) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: this.path.ref + `${this.path.ref}.archivedThreadItems[${idx}]`,\n threadSelector: { type: \"archiveIndex\", index: idx },\n },\n getState: () => {\n return getThreadListItemState(\n this._core,\n this._core.archivedThreads[idx],\n );\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getThreadListItemById(threadId: string) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref:\n this.path.ref +\n `${this.path.ref}.threadItems[threadId=${threadId}]`,\n threadSelector: { type: \"threadId\", threadId },\n },\n getState: () => {\n return getThreadListItemState(this._core, threadId);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAmC;AAInC,mCAIO;AACP,yBAA4B;AAC5B,mCAAsC;AAoBtC,IAAM,qBAAqB,CACzB,eACoB;AACpB,SAAO;AAAA,IACL,cAAc,WAAW,WAAW,SAAS;AAAA,IAC7C,WAAW,WAAW;AAAA,IACtB,SAAS,WAAW;AAAA,IACpB,iBAAiB,WAAW;AAAA,EAC9B;AACF;AAEA,IAAM,yBAAyB,CAC7B,YACA,aACsC;AACtC,MAAI,aAAa,OAAW,QAAO;AAEnC,QAAM,aAAa,WAAW,sBAAsB,QAAQ;AAC5D,MAAI,CAAC,WAAY,QAAO;AACxB,SAAO;AAAA,IACL,UAAU,WAAW;AAAA,IACrB,OAAO,WAAW;AAAA,IAClB,OAAO,WAAW;AAAA,IAClB,QAAQ,WAAW,WAAW,SAAS,aAAa;AAAA,EACtD;AACF;AAEA,IAAM,sBAAsB;AAAA,EAC1B,KAAK;AACP;AAIO,IAAM,wBAAN,MAAyD;AAAA,EAM9D,YAAoB,OAAqC;AAArC;AAClB,UAAM,eAAe,IAAI,6CAAmB;AAAA,MAC1C,MAAM;AAAA,MACN,UAAU,MAAM,mBAAmB,KAAK;AAAA,MACxC,WAAW,CAAC,aAAa,MAAM,UAAU,QAAQ;AAAA,IACnD,CAAC;AAED,SAAK,YAA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AK,MACV,GAAG,KAAK,KAAK,GAAG,yBAAyB,QAAQ;AAAA,UACnD,gBAAgB,EAAE,MAAM,YAAY,SAAS;AAAA,QAC/C;AAAA,QACA,UAAU,MAAM;AACd,iBAAO,uBAAuB,KAAK,OAAO,QAAQ;AAAA,QACpD;AAAA,QACA,WAAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,MACD,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/ThreadListRuntime.ts"],"sourcesContent":["import { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport { ThreadListRuntimeCore } from \"../runtimes/core/ThreadListRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport { ThreadListRuntimePath } from \"./RuntimePathTypes\";\nimport {\n ThreadListItemRuntime,\n ThreadListItemRuntimeImpl,\n ThreadListItemState,\n} from \"./ThreadListItemRuntime\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\n\nexport type ThreadListState = Readonly<{\n mainThreadId: string;\n newThread: string | undefined;\n threads: readonly string[];\n archivedThreads: readonly string[];\n}>;\n\nexport type ThreadListRuntime = Readonly<{\n path: ThreadListRuntimePath;\n getState(): ThreadListState;\n\n subscribe(callback: () => void): Unsubscribe;\n\n getThreadListItemById(threadId: string): ThreadListItemRuntime;\n getThreadListItemByIndex(idx: number): ThreadListItemRuntime;\n getThreadListArchivedItemByIndex(idx: number): ThreadListItemRuntime;\n}>;\n\nconst getThreadListState = (\n threadList: ThreadListRuntimeCore,\n): ThreadListState => {\n return {\n mainThreadId: threadList.mainThread.metadata.threadId,\n newThread: threadList.newThread,\n threads: threadList.threads,\n archivedThreads: threadList.archivedThreads,\n };\n};\n\nconst getThreadListItemState = (\n threadList: ThreadListRuntimeCore,\n threadId: string | undefined,\n): ThreadListItemState | SKIP_UPDATE => {\n if (threadId === undefined) return SKIP_UPDATE;\n\n const threadData = threadList.getThreadMetadataById(threadId);\n if (!threadData) return SKIP_UPDATE;\n return {\n threadId: threadData.threadId,\n title: threadData.title,\n state: threadData.state,\n isMain: threadList.mainThread.metadata.threadId === threadId,\n };\n};\n\nconst THREAD_MANAGER_PATH = {\n ref: \"ThreadList\",\n};\n\nexport type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;\n\nexport class ThreadListRuntimeImpl implements ThreadListRuntime {\n public get path() {\n return THREAD_MANAGER_PATH;\n }\n\n private _getState;\n constructor(private _core: ThreadListRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: THREAD_MANAGER_PATH,\n getState: () => getThreadListState(_core),\n subscribe: (callback) => _core.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public getState(): ThreadListState {\n return this._getState();\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n return this._core.subscribe(callback);\n }\n\n public getThreadListItemByIndex(idx: number) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: this.path.ref + `${this.path.ref}.threadItems[${idx}]`,\n threadSelector: { type: \"index\", index: idx },\n },\n getState: () => {\n return getThreadListItemState(this._core, this._core.threads[idx]);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getThreadListArchivedItemByIndex(idx: number) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: this.path.ref + `${this.path.ref}.archivedThreadItems[${idx}]`,\n threadSelector: { type: \"archiveIndex\", index: idx },\n },\n getState: () => {\n return getThreadListItemState(\n this._core,\n this._core.archivedThreads[idx],\n );\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getThreadListItemById(threadId: string) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref:\n this.path.ref +\n `${this.path.ref}.threadItems[threadId=${threadId}]`,\n threadSelector: { type: \"threadId\", threadId },\n },\n getState: () => {\n return getThreadListItemState(this._core, threadId);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";AAAA,SAAS,0BAA0B;AAInC;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAoBtC,IAAM,qBAAqB,CACzB,eACoB;AACpB,SAAO;AAAA,IACL,cAAc,WAAW,WAAW,SAAS;AAAA,IAC7C,WAAW,WAAW;AAAA,IACtB,SAAS,WAAW;AAAA,IACpB,iBAAiB,WAAW;AAAA,EAC9B;AACF;AAEA,IAAM,yBAAyB,CAC7B,YACA,aACsC;AACtC,MAAI,aAAa,OAAW,QAAO;AAEnC,QAAM,aAAa,WAAW,sBAAsB,QAAQ;AAC5D,MAAI,CAAC,WAAY,QAAO;AACxB,SAAO;AAAA,IACL,UAAU,WAAW;AAAA,IACrB,OAAO,WAAW;AAAA,IAClB,OAAO,WAAW;AAAA,IAClB,QAAQ,WAAW,WAAW,SAAS,aAAa;AAAA,EACtD;AACF;AAEA,IAAM,sBAAsB;AAAA,EAC1B,KAAK;AACP;AAIO,IAAM,wBAAN,MAAyD;AAAA,EAM9D,YAAoB,OAAqC;AAArC;AAClB,UAAM,eAAe,IAAI,mBAAmB;AAAA,MAC1C,MAAM;AAAA,MACN,UAAU,MAAM,mBAAmB,KAAK;AAAA,MACxC,WAAW,CAAC,aAAa,MAAM,UAAU,QAAQ;AAAA,IACnD,CAAC;AAED,SAAK,YAAY,aAAa,SAAS,KAAK,YAAY;AAAA,EAC1D;AAAA,EAbA,IAAW,OAAO;AAChB,WAAO;AAAA,EACT;AAAA,EAEQ;AAAA,EAWD,WAA4B;AACjC,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEO,UAAU,UAAmC;AAClD,WAAO,KAAK,MAAM,UAAU,QAAQ;AAAA,EACtC;AAAA,EAEO,yBAAyB,KAAa;A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,MACD,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/api/ThreadListRuntime.ts"],"sourcesContent":["import { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport { ThreadListRuntimeCore } from \"../runtimes/core/ThreadListRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport { ThreadListRuntimePath } from \"./RuntimePathTypes\";\nimport {\n ThreadListItemRuntime,\n ThreadListItemRuntimeImpl,\n ThreadListItemState,\n} from \"./ThreadListItemRuntime\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\n\nexport type ThreadListState = {\n readonly mainThreadId: string;\n readonly newThread: string | undefined;\n readonly threads: readonly string[];\n readonly archivedThreads: readonly string[];\n};\n\nexport type ThreadListRuntime = {\n readonly path: ThreadListRuntimePath;\n getState(): ThreadListState;\n\n subscribe(callback: () => void): Unsubscribe;\n\n getThreadListItemById(threadId: string): ThreadListItemRuntime;\n getThreadListItemByIndex(idx: number): ThreadListItemRuntime;\n getThreadListArchivedItemByIndex(idx: number): ThreadListItemRuntime;\n};\n\nconst getThreadListState = (\n threadList: ThreadListRuntimeCore,\n): ThreadListState => {\n return {\n mainThreadId: threadList.mainThread.metadata.threadId,\n newThread: threadList.newThread,\n threads: threadList.threads,\n archivedThreads: threadList.archivedThreads,\n };\n};\n\nconst getThreadListItemState = (\n threadList: ThreadListRuntimeCore,\n threadId: string | undefined,\n): ThreadListItemState | SKIP_UPDATE => {\n if (threadId === undefined) return SKIP_UPDATE;\n\n const threadData = threadList.getThreadMetadataById(threadId);\n if (!threadData) return SKIP_UPDATE;\n return {\n threadId: threadData.threadId,\n title: threadData.title,\n state: threadData.state,\n isMain: threadList.mainThread.metadata.threadId === threadId,\n };\n};\n\nconst THREAD_MANAGER_PATH = {\n ref: \"ThreadList\",\n};\n\nexport type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;\n\nexport class ThreadListRuntimeImpl implements ThreadListRuntime {\n public get path() {\n return THREAD_MANAGER_PATH;\n }\n\n private _getState;\n constructor(private _core: ThreadListRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: THREAD_MANAGER_PATH,\n getState: () => getThreadListState(_core),\n subscribe: (callback) => _core.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public getState(): ThreadListState {\n return this._getState();\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n return this._core.subscribe(callback);\n }\n\n public getThreadListItemByIndex(idx: number) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: this.path.ref + `${this.path.ref}.threadItems[${idx}]`,\n threadSelector: { type: \"index\", index: idx },\n },\n getState: () => {\n return getThreadListItemState(this._core, this._core.threads[idx]);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getThreadListArchivedItemByIndex(idx: number) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: this.path.ref + `${this.path.ref}.archivedThreadItems[${idx}]`,\n threadSelector: { type: \"archiveIndex\", index: idx },\n },\n getState: () => {\n return getThreadListItemState(\n this._core,\n this._core.archivedThreads[idx],\n );\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getThreadListItemById(threadId: string) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref:\n this.path.ref +\n `${this.path.ref}.threadItems[threadId=${threadId}]`,\n threadSelector: { type: \"threadId\", threadId },\n },\n getState: () => {\n return getThreadListItemState(this._core, threadId);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";AAAA,SAAS,0BAA0B;AAInC;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAoBtC,IAAM,qBAAqB,CACzB,e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AQ,GAAG,CAAC;AAAA,QACnE;AAAA,QACA,WAAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,MACD,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EAEO,iCAAiC,KAAa;AACnD,WAAO,IAAI;AAAA,MACT,IAAI,sBAAsB;AAAA,QACxB,MAAM;AAAA,UACJ,KAAK,KAAK,KAAK,MAAM,GAAG,KAAK,KAAK,GAAG,wBAAwB,GAAG;AAAA,UAChE,gBAAgB,EAAE,MAAM,gBAAgB,OAAO,IAAI;AAAA,QACrD;AAAA,QACA,UAAU,MAAM;AACd,iBAAO;AAAA,YACL,KAAK;AAAA,YACL,KAAK,MAAM,gBAAgB,GAAG;AAAA,UAChC;AAAA,QACF;AAAA,QACA,WAAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,MACD,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EAEO,sBAAsB,UAAkB;AAC7C,WAAO,IAAI;AAAA,MACT,IAAI,sBAAsB;AAAA,QACxB,MAAM;AAAA,UACJ,KACE,KAAK,KAAK,MACV,GAAG,KAAK,KAAK,GAAG,yBAAyB,QAAQ;AAAA,UACnD,gBAAgB,EAAE,MAAM,YAAY,SAAS;AAAA,QAC/C;AAAA,QACA,UAAU,MAAM;AACd,iBAAO,uBAAuB,KAAK,OAAO,QAAQ;AAAA,QACpD;AAAA,QACA,WAAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,MACD,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
@@ -15,51 +15,80 @@ export type CreateAppendMessage = string | {
15
15
  export type ThreadRuntimeCoreBinding = SubscribableWithState<ThreadRuntimeCore, ThreadRuntimePath> & {
16
16
  outerSubscribe(callback: () => void): Unsubscribe;
17
17
  };
18
- export type ThreadState = Readonly<{
18
+ export type ThreadState = {
19
19
  /**
20
20
  * The thread ID.
21
- * @deprecated This field is deprecated and will be removed in 0.7.0. Use `metadata.threadId` instead.
21
+ * @deprecated This field is deprecated and will be removed in 0.8.0. Use `metadata.threadId` instead.
22
22
  */
23
- threadId: string;
23
+ readonly threadId: string;
24
24
  /**
25
25
  * The thread metadata.
26
26
  */
27
- metadata: ThreadMetadata;
27
+ readonly metadata: ThreadMetadata;
28
28
  /**
29
29
  * Whether the thread is disabled. Disabled threads cannot receive new messages.
30
30
  */
31
- isDisabled: boolean;
31
+ readonly isDisabled: boolean;
32
32
  /**
33
33
  * Whether the thread is running. A thread is considered running when there is an active stream connection to the backend.
34
34
  */
35
- isRunning: boolean;
35
+ readonly isRunning: boolean;
36
36
  /**
37
37
  * The capabilities of the thread, such as whether the thread supports editing, branch switching, etc.
38
38
  */
39
- capabilities: RuntimeCapabilities;
39
+ readonly capabilities: RuntimeCapabilities;
40
40
  /**
41
41
  * The messages in the currently selected branch of the thread.
42
42
  */
43
- messages: readonly ThreadMessage[];
43
+ readonly messages: readonly ThreadMessage[];
44
44
  /**
45
45
  * Follow up message suggestions to show the user.
46
46
  */
47
- suggestions: readonly ThreadSuggestion[];
47
+ readonly suggestions: readonly ThreadSuggestion[];
48
48
  /**
49
49
  * Custom extra information provided by the runtime.
50
50
  */
51
- extras: unknown;
51
+ readonly extras: unknown;
52
52
  /**
53
53
  * @deprecated This API is still under active development and might change without notice.
54
54
  */
55
- speech: SpeechState | undefined;
56
- }>;
55
+ readonly speech: SpeechState | undefined;
56
+ };
57
57
  export declare const getThreadState: (runtime: ThreadRuntimeCore) => ThreadState;
58
- export type ThreadRuntime = Readonly<{
58
+ export type ThreadRuntime = {
59
+ /**
60
+ * The selector for the thread runtime.
61
+ */
59
62
  readonly path: ThreadRuntimePath;
63
+ /**
64
+ * The thread composer runtime.
65
+ */
60
66
  readonly composer: ThreadComposerRuntime;
67
+ /**
68
+ * Gets a snapshot of the thread state.
69
+ */
61
70
  getState(): ThreadState;
71
+ /**
72
+ * Append a new message to the thread.
73
+ *
74
+ * @example ```ts
75
+ * // append a new user message with the text "Hello, world!"
76
+ * threadRuntime.append("Hello, world!");
77
+ * ```
78
+ *
79
+ * @example ```ts
80
+ * // append a new assistant message with the text "Hello, world!"
81
+ * threadRuntime.append({
82
+ * role: "assistant",
83
+ * content: [{ type: "text", text: "Hello, world!" }],
84
+ * });
85
+ * ```
86
+ */
62
87
  append(message: CreateAppendMessage): void;
88
+ /**
89
+ *
90
+ * @param parentId
91
+ */
63
92
  startRun(parentId: string | null): void;
64
93
  subscribe(callback: () => void): Unsubscribe;
65
94
  cancelRun(): void;
@@ -73,7 +102,7 @@ export type ThreadRuntime = Readonly<{
73
102
  */
74
103
  stopSpeaking: () => void;
75
104
  unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
76
- }>;
105
+ };
77
106
  export declare class ThreadRuntimeImpl implements ThreadRuntime {
78
107
  get path(): ThreadRuntimePath;
79
108
  unstable_getCore(): Readonly<{
@@ -110,54 +139,14 @@ export declare class ThreadRuntimeImpl implements ThreadRuntime {
110
139
  private _threadBinding;
111
140
  constructor(threadBinding: ThreadRuntimeCoreBinding);
112
141
  readonly composer: ThreadComposerRuntimeImpl;
113
- getState(): Readonly<{
114
- /**
115
- * The thread ID.
116
- * @deprecated This field is deprecated and will be removed in 0.7.0. Use `metadata.threadId` instead.
117
- */
118
- threadId: string;
119
- /**
120
- * The thread metadata.
121
- */
122
- metadata: ThreadMetadata;
123
- /**
124
- * Whether the thread is disabled. Disabled threads cannot receive new messages.
125
- */
126
- isDisabled: boolean;
127
- /**
128
- * Whether the thread is running. A thread is considered running when there is an active stream connection to the backend.
129
- */
130
- isRunning: boolean;
131
- /**
132
- * The capabilities of the thread, such as whether the thread supports editing, branch switching, etc.
133
- */
134
- capabilities: RuntimeCapabilities;
135
- /**
136
- * The messages in the currently selected branch of the thread.
137
- */
138
- messages: readonly ThreadMessage[];
139
- /**
140
- * Follow up message suggestions to show the user.
141
- */
142
- suggestions: readonly ThreadSuggestion[];
143
- /**
144
- * Custom extra information provided by the runtime.
145
- */
146
- extras: unknown;
147
- /**
148
- * @deprecated This API is still under active development and might change without notice.
149
- */
150
- speech: SpeechState | undefined;
151
- }>;
142
+ getState(): ThreadState;
152
143
  append(message: CreateAppendMessage): void;
153
144
  subscribe(callback: () => void): Unsubscribe;
154
145
  getModelConfig(): ModelConfig;
155
146
  startRun(parentId: string | null): void;
156
147
  cancelRun(): void;
157
148
  stopSpeaking(): void;
158
- getSubmittedFeedback(messageId: string): Readonly<{
159
- type: "negative" | "positive";
160
- }> | undefined;
149
+ getSubmittedFeedback(messageId: string): import("../runtimes/core/ThreadRuntimeCore").SubmittedFeedback | undefined;
161
150
  export(): ExportedMessageRepository;
162
151
  import(data: ExportedMessageRepository): void;
163
152
  getMesssageByIndex(idx: number): MessageRuntimeImpl;
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadRuntime.d.ts","sourceRoot":"","sources":["../../src/api/ThreadRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,sBAAsB,EACtB,cAAc,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EACL,aAAa,EACb,WAAW,EACX,aAAa,EACb,WAAW,EACZ,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,cAAc,EACd,kBAAkB,EAEnB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAEL,qBAAqB,EACtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EAC1B,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAsB,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE3E,MAAM,MAAM,mBAAmB,GAC3B,MAAM,GACN;IACE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACrC,IAAI,CAAC,EAAE,aAAa,CAAC,MA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