@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
@@ -7,11 +7,11 @@ export type AssistantRuntime = {
7
7
  /**
8
8
  * The currently selected main thread.
9
9
  */
10
- thread: ThreadRuntime;
10
+ readonly thread: ThreadRuntime;
11
11
  /**
12
12
  * The thread manager, to rename, archive and delete threads.
13
13
  */
14
- threadList: ThreadListRuntime;
14
+ readonly threadList: ThreadListRuntime;
15
15
  /**
16
16
  * Switch to a new thread.
17
17
  */
@@ -34,41 +34,11 @@ export declare class AssistantRuntimeImpl implements Omit<AssistantRuntimeCore,
34
34
  private readonly _thread;
35
35
  readonly threadList: ThreadListRuntimeImpl;
36
36
  protected constructor(_core: AssistantRuntimeCore, _thread: ThreadRuntime);
37
- get thread(): Readonly<{
38
- readonly path: import("./RuntimePathTypes").ThreadRuntimePath;
39
- readonly composer: import("./ComposerRuntime").ThreadComposerRuntime;
40
- getState(): import("./ThreadRuntime").ThreadState;
41
- append(message: import("./ThreadRuntime").CreateAppendMessage): void;
42
- startRun(parentId: string | null): void;
43
- subscribe(callback: () => void): Unsubscribe;
44
- cancelRun(): void;
45
- getModelConfig(): import("..").ModelConfig;
46
- export(): import("../runtimes/utils/MessageRepository").ExportedMessageRepository;
47
- import(repository: import("../runtimes/utils/MessageRepository").ExportedMessageRepository): void;
48
- getMesssageByIndex(idx: number): import("./MessageRuntime").MessageRuntime;
49
- getMesssageById(messageId: string): import("./MessageRuntime").MessageRuntime;
50
- stopSpeaking: () => void;
51
- unstable_on(event: import("../runtimes/core/ThreadRuntimeCore").ThreadRuntimeEventType, callback: () => void): Unsubscribe;
52
- }>;
37
+ get thread(): ThreadRuntime;
53
38
  switchToNewThread(): Promise<void>;
54
39
  switchToThread(threadId: string): Promise<void>;
55
40
  registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
56
- protected static createMainThreadRuntime(_core: AssistantRuntimeCore, CustomThreadRuntime?: new (binding: ThreadRuntimeCoreBinding) => ThreadRuntime): Readonly<{
57
- readonly path: import("./RuntimePathTypes").ThreadRuntimePath;
58
- readonly composer: import("./ComposerRuntime").ThreadComposerRuntime;
59
- getState(): import("./ThreadRuntime").ThreadState;
60
- append(message: import("./ThreadRuntime").CreateAppendMessage): void;
61
- startRun(parentId: string | null): void;
62
- subscribe(callback: () => void): Unsubscribe;
63
- cancelRun(): void;
64
- getModelConfig(): import("..").ModelConfig;
65
- export(): import("../runtimes/utils/MessageRepository").ExportedMessageRepository;
66
- import(repository: import("../runtimes/utils/MessageRepository").ExportedMessageRepository): void;
67
- getMesssageByIndex(idx: number): import("./MessageRuntime").MessageRuntime;
68
- getMesssageById(messageId: string): import("./MessageRuntime").MessageRuntime;
69
- stopSpeaking: () => void;
70
- unstable_on(event: import("../runtimes/core/ThreadRuntimeCore").ThreadRuntimeEventType, callback: () => void): Unsubscribe;
71
- }>;
41
+ protected static createMainThreadRuntime(_core: AssistantRuntimeCore, CustomThreadRuntime?: new (binding: ThreadRuntimeCoreBinding) => ThreadRuntime): ThreadRuntime;
72
42
  static create(_core: AssistantRuntimeCore, CustomThreadRuntime?: new (binding: ThreadRuntimeCoreBinding) => ThreadRuntime): AssistantRuntime;
73
43
  }
74
44
  //# sourceMappingURL=AssistantRuntime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AssistantRuntime.d.ts","sourceRoot":"","sources":["../../src/api/AssistantRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EACL,aAAa,EACb,wBAAwB,EAEzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE/E,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC;IAEtB;;OAEG;IACH,UAAU,EAAE,iBAAiB,CAAC;IAE9B;;OAEG;IACH,iBAAiB,IAAI,IAAI,CAAC;IAE1B;;;;OAIG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvC;;;;OAIG;IACH,2BAA2B,CAAC,QAAQ,EAAE,mBAAmB,GAAG,WAAW,CAAC;CACzE,CAAC;AAEF,qBAAa,oBACX,YACE,IAAI,CAAC,oBAAoB,EAAE,QAAQ,GAAG,YAAY,CAAC,EACnD,gBAAgB;IAKhB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAC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mB,GAAG,WAAW,CAAC;CACzE,CAAC;AAEF,qBAAa,oBACX,YACE,IAAI,CAAC,oBAAoB,EAAE,QAAQ,GAAG,YAAY,CAAC,EACnD,gBAAgB;IAKhB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ1B,SAAgB,UAAU,wBAAC;IAE3B,SAAS,aACU,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,aAAa;IAKzC,IAAW,MAAM,kBAEhB;IAEM,iBAAiB;IAIjB,cAAc,CAAC,QAAQ,EAAE,MAAM;IAI/B,2BAA2B,CAAC,QAAQ,EAAE,mBAAmB;IAIhE,SAAS,CAAC,MAAM,CAAC,uBAAuB,CACtC,KAAK,EAAE,oBAAoB,EAC3B,mBAAmB,GAAE,KACnB,OAAO,EAAE,wBAAwB,KAC9B,aAAiC;WAc1B,MAAM,CAClB,KAAK,EAAE,oBAAoB,EAC3B,mBAAmB,GAAE,KACnB,OAAO,EAAE,wBAAwB,KAC9B,aAAiC,GAKjC,gBAAgB;CAExB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/AssistantRuntime.ts"],"sourcesContent":["import { AssistantRuntimeCore } from \"../runtimes/core/AssistantRuntimeCore\";\nimport { NestedSubscriptionSubject } from \"./subscribable/NestedSubscriptionSubject\";\nimport { ModelConfigProvider } from \"../types/ModelConfigTypes\";\nimport {\n ThreadRuntime,\n ThreadRuntimeCoreBinding,\n ThreadRuntimeImpl,\n} from \"./ThreadRuntime\";\nimport { Unsubscribe } from \"../types\";\nimport { ThreadListRuntime, ThreadListRuntimeImpl } from \"./ThreadListRuntime\";\n\nexport type AssistantRuntime = {\n /**\n * The currently selected main thread.\n */\n thread: ThreadRuntime;\n\n /**\n * The thread manager, to rename, archive and delete threads.\n */\n threadList: ThreadListRuntime;\n\n /**\n * Switch to a new thread.\n */\n switchToNewThread(): void;\n\n /**\n * Switch to a thread.\n *\n * @param threadId The thread ID to switch to.\n */\n switchToThread(threadId: string): void;\n\n /**\n * Register a model config provider. Model config providers are configuration such as system message, temperature, etc. that are set in the frontend.\n *\n * @param provider The model config provider to register.\n */\n registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;\n};\n\nexport class AssistantRuntimeImpl\n implements\n Omit<AssistantRuntimeCore, \"thread\" | \"threadList\">,\n AssistantRuntime\n{\n public readonly threadList;\n\n protected constructor(\n private readonly _core: AssistantRuntimeCore,\n private readonly _thread: ThreadRuntime,\n ) {\n this.threadList = new ThreadListRuntimeImpl(_core.threadList);\n }\n\n public get thread() {\n return this._thread;\n }\n\n public switchToNewThread() {\n return this._core.threadList.switchToNewThread();\n }\n\n public switchToThread(threadId: string) {\n return this._core.threadList.switchToThread(threadId);\n }\n\n public registerModelConfigProvider(provider: ModelConfigProvider) {\n return this._core.registerModelConfigProvider(provider);\n }\n\n protected static createMainThreadRuntime(\n _core: AssistantRuntimeCore,\n CustomThreadRuntime: new (\n binding: ThreadRuntimeCoreBinding,\n ) => ThreadRuntime = ThreadRuntimeImpl,\n ) {\n return new CustomThreadRuntime(\n new NestedSubscriptionSubject({\n path: {\n ref: \"threads.main\",\n threadSelector: { type: \"main\" },\n },\n getState: () => _core.threadList.mainThread,\n subscribe: (callback) => _core.threadList.subscribe(callback),\n }),\n );\n }\n\n public static create(\n _core: AssistantRuntimeCore,\n CustomThreadRuntime: new (\n binding: ThreadRuntimeCoreBinding,\n ) => ThreadRuntime = ThreadRuntimeImpl,\n ) {\n return new AssistantRuntimeImpl(\n _core,\n AssistantRuntimeImpl.createMainThreadRuntime(_core, CustomThreadRuntime),\n ) as AssistantRuntime;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uCAA0C;AAE1C,2BAIO;AAEP,+BAAyD;AAiClD,IAAM,uBAAN,MAAM,sBAIb;AAAA,EAGY,YACS,OACA,SACjB;AAFiB;AACA;AAEjB,SAAK,aAAa,IAAI,+CAAsB,MAAM,UAAU;AAAA,EAC9D;AAAA,EAPgB;AAAA,EAShB,IAAW,SAAS;AAClB,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,oBAAoB;AACzB,WAAO,KAAK,MAAM,WAAW,kBAAkB;AAAA,EACjD;AAAA,EAEO,eAAe,UAAkB;AACtC,WAAO,KAAK,MAAM,WAAW,eAAe,QAAQ;AAAA,EACtD;AAAA,EAEO,4BAA4B,UAA+B;AAChE,WAAO,KAAK,MAAM,4BAA4B,QAAQ;AAAA,EACxD;AAAA,EAEA,OAAiB,wBACf,OACA,sBAEqB,wCACrB;AACA,WAAO,IAAI;AAAA,MACT,IAAI,2DAA0B;AAAA,QAC5B,MAAM;AAAA,UACJ,KAAK;AAAA,UACL,gBAAgB,EAAE,MAAM,OAAO;AAAA,QACjC;AAAA,QACA,UAAU,MAAM,MAAM,WAAW;AAAA,QACjC,WAAW,CAAC,aAAa,MAAM,WAAW,UAAU,QAAQ;AAAA,MAC9D,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,OAAc,OACZ,OACA,sBAEqB,wCACrB;AACA,WAAO,IAAI;AAAA,MACT;AAAA,MACA,sBAAqB,wBAAwB,OAAO,mBAAmB;AAAA,IACzE;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/api/AssistantRuntime.ts"],"sourcesContent":["import { AssistantRuntimeCore } from \"../runtimes/core/AssistantRuntimeCore\";\nimport { NestedSubscriptionSubject } from \"./subscribable/NestedSubscriptionSubject\";\nimport { ModelConfigProvider } from \"../types/ModelConfigTypes\";\nimport {\n ThreadRuntime,\n ThreadRuntimeCoreBinding,\n ThreadRuntimeImpl,\n} from \"./ThreadRuntime\";\nimport { Unsubscribe } from \"../types\";\nimport { ThreadListRuntime, ThreadListRuntimeImpl } from \"./ThreadListRuntime\";\n\nexport type AssistantRuntime = {\n /**\n * The currently selected main thread.\n */\n readonly thread: ThreadRuntime;\n\n /**\n * The thread manager, to rename, archive and delete threads.\n */\n readonly threadList: ThreadListRuntime;\n\n /**\n * Switch to a new thread.\n */\n switchToNewThread(): void;\n\n /**\n * Switch to a thread.\n *\n * @param threadId The thread ID to switch to.\n */\n switchToThread(threadId: string): void;\n\n /**\n * Register a model config provider. Model config providers are configuration such as system message, temperature, etc. that are set in the frontend.\n *\n * @param provider The model config provider to register.\n */\n registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;\n};\n\nexport class AssistantRuntimeImpl\n implements\n Omit<AssistantRuntimeCore, \"thread\" | \"threadList\">,\n AssistantRuntime\n{\n public readonly threadList;\n\n protected constructor(\n private readonly _core: AssistantRuntimeCore,\n private readonly _thread: ThreadRuntime,\n ) {\n this.threadList = new ThreadListRuntimeImpl(_core.threadList);\n }\n\n public get thread() {\n return this._thread;\n }\n\n public switchToNewThread() {\n return this._core.threadList.switchToNewThread();\n }\n\n public switchToThread(threadId: string) {\n return this._core.threadList.switchToThread(threadId);\n }\n\n public registerModelConfigProvider(provider: ModelConfigProvider) {\n return this._core.registerModelConfigProvider(provider);\n }\n\n protected static createMainThreadRuntime(\n _core: AssistantRuntimeCore,\n CustomThreadRuntime: new (\n binding: ThreadRuntimeCoreBinding,\n ) => ThreadRuntime = ThreadRuntimeImpl,\n ) {\n return new CustomThreadRuntime(\n new NestedSubscriptionSubject({\n path: {\n ref: \"threads.main\",\n threadSelector: { type: \"main\" },\n },\n getState: () => _core.threadList.mainThread,\n subscribe: (callback) => _core.threadList.subscribe(callback),\n }),\n );\n }\n\n public static create(\n _core: AssistantRuntimeCore,\n CustomThreadRuntime: new (\n binding: ThreadRuntimeCoreBinding,\n ) => ThreadRuntime = ThreadRuntimeImpl,\n ) {\n return new AssistantRuntimeImpl(\n _core,\n AssistantRuntimeImpl.createMainThreadRuntime(_core, CustomThreadRuntime),\n ) as AssistantRuntime;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uCAA0C;AAE1C,2BAIO;AAEP,+BAAyD;AAiClD,IAAM,uBAAN,MAAM,sBAIb;AAAA,EAGY,YACS,OACA,SACjB;AAFiB;AACA;AAEjB,SAAK,aAAa,IAAI,+CAAsB,MAAM,UAAU;AAAA,EAC9D;AAAA,EAPgB;AAAA,EAShB,IAAW,SAAS;AAClB,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,oBAAoB;AACzB,WAAO,KAAK,MAAM,WAAW,kBAAkB;AAAA,EACjD;AAAA,EAEO,eAAe,UAAkB;AACtC,WAAO,KAAK,MAAM,WAAW,eAAe,QAAQ;AAAA,EACtD;AAAA,EAEO,4BAA4B,UAA+B;AAChE,WAAO,KAAK,MAAM,4BAA4B,QAAQ;AAAA,EACxD;AAAA,EAEA,OAAiB,wBACf,OACA,sBAEqB,wCACrB;AACA,WAAO,IAAI;AAAA,MACT,IAAI,2DAA0B;AAAA,QAC5B,MAAM;AAAA,UACJ,KAAK;AAAA,UACL,gBAAgB,EAAE,MAAM,OAAO;AAAA,QACjC;AAAA,QACA,UAAU,MAAM,MAAM,WAAW;AAAA,QACjC,WAAW,CAAC,aAAa,MAAM,WAAW,UAAU,QAAQ;AAAA,MAC9D,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,OAAc,OACZ,OACA,sBAEqB,wCACrB;AACA,WAAO,IAAI;AAAA,MACT;AAAA,MACA,sBAAqB,wBAAwB,OAAO,mBAAmB;AAAA,IACzE;AAAA,EACF;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/AssistantRuntime.ts"],"sourcesContent":["import { AssistantRuntimeCore } from \"../runtimes/core/AssistantRuntimeCore\";\nimport { NestedSubscriptionSubject } from \"./subscribable/NestedSubscriptionSubject\";\nimport { ModelConfigProvider } from \"../types/ModelConfigTypes\";\nimport {\n ThreadRuntime,\n ThreadRuntimeCoreBinding,\n ThreadRuntimeImpl,\n} from \"./ThreadRuntime\";\nimport { Unsubscribe } from \"../types\";\nimport { ThreadListRuntime, ThreadListRuntimeImpl } from \"./ThreadListRuntime\";\n\nexport type AssistantRuntime = {\n /**\n * The currently selected main thread.\n */\n thread: ThreadRuntime;\n\n /**\n * The thread manager, to rename, archive and delete threads.\n */\n threadList: ThreadListRuntime;\n\n /**\n * Switch to a new thread.\n */\n switchToNewThread(): void;\n\n /**\n * Switch to a thread.\n *\n * @param threadId The thread ID to switch to.\n */\n switchToThread(threadId: string): void;\n\n /**\n * Register a model config provider. Model config providers are configuration such as system message, temperature, etc. that are set in the frontend.\n *\n * @param provider The model config provider to register.\n */\n registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;\n};\n\nexport class AssistantRuntimeImpl\n implements\n Omit<AssistantRuntimeCore, \"thread\" | \"threadList\">,\n AssistantRuntime\n{\n public readonly threadList;\n\n protected constructor(\n private readonly _core: AssistantRuntimeCore,\n private readonly _thread: ThreadRuntime,\n ) {\n this.threadList = new ThreadListRuntimeImpl(_core.threadList);\n }\n\n public get thread() {\n return this._thread;\n }\n\n public switchToNewThread() {\n return this._core.threadList.switchToNewThread();\n }\n\n public switchToThread(threadId: string) {\n return this._core.threadList.switchToThread(threadId);\n }\n\n public registerModelConfigProvider(provider: ModelConfigProvider) {\n return this._core.registerModelConfigProvider(provider);\n }\n\n protected static createMainThreadRuntime(\n _core: AssistantRuntimeCore,\n CustomThreadRuntime: new (\n binding: ThreadRuntimeCoreBinding,\n ) => ThreadRuntime = ThreadRuntimeImpl,\n ) {\n return new CustomThreadRuntime(\n new NestedSubscriptionSubject({\n path: {\n ref: \"threads.main\",\n threadSelector: { type: \"main\" },\n },\n getState: () => _core.threadList.mainThread,\n subscribe: (callback) => _core.threadList.subscribe(callback),\n }),\n );\n }\n\n public static create(\n _core: AssistantRuntimeCore,\n CustomThreadRuntime: new (\n binding: ThreadRuntimeCoreBinding,\n ) => ThreadRuntime = ThreadRuntimeImpl,\n ) {\n return new AssistantRuntimeImpl(\n _core,\n AssistantRuntimeImpl.createMainThreadRuntime(_core, CustomThreadRuntime),\n ) as AssistantRuntime;\n }\n}\n"],"mappings":";AACA,SAAS,iCAAiC;AAE1C;AAAA,EAGE;AAAA,OACK;AAEP,SAA4B,6BAA6B;AAiClD,IAAM,uBAAN,MAAM,sBAIb;AAAA,EAGY,YACS,OACA,SACjB;AAFiB;AACA;AAEjB,SAAK,aAAa,IAAI,sBAAsB,MAAM,UAAU;AAAA,EAC9D;AAAA,EAPgB;AAAA,EAShB,IAAW,SAAS;AAClB,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,oBAAoB;AACzB,WAAO,KAAK,MAAM,WAAW,kBAAkB;AAAA,EACjD;AAAA,EAEO,eAAe,UAAkB;AACtC,WAAO,KAAK,MAAM,WAAW,eAAe,QAAQ;AAAA,EACtD;AAAA,EAEO,4BAA4B,UAA+B;AAChE,WAAO,KAAK,MAAM,4BAA4B,QAAQ;AAAA,EACxD;AAAA,EAEA,OAAiB,wBACf,OACA,sBAEqB,mBACrB;AACA,WAAO,IAAI;AAAA,MACT,IAAI,0BAA0B;AAAA,QAC5B,MAAM;AAAA,UACJ,KAAK;AAAA,UACL,gBAAgB,EAAE,MAAM,OAAO;AAAA,QACjC;AAAA,QACA,UAAU,MAAM,MAAM,WAAW;AAAA,QACjC,WAAW,CAAC,aAAa,MAAM,WAAW,UAAU,QAAQ;AAAA,MAC9D,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,OAAc,OACZ,OACA,sBAEqB,mBACrB;AACA,WAAO,IAAI;AAAA,MACT;AAAA,MACA,sBAAqB,wBAAwB,OAAO,mBAAmB;AAAA,IACzE;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/api/AssistantRuntime.ts"],"sourcesContent":["import { AssistantRuntimeCore } from \"../runtimes/core/AssistantRuntimeCore\";\nimport { NestedSubscriptionSubject } from \"./subscribable/NestedSubscriptionSubject\";\nimport { ModelConfigProvider } from \"../types/ModelConfigTypes\";\nimport {\n ThreadRuntime,\n ThreadRuntimeCoreBinding,\n ThreadRuntimeImpl,\n} from \"./ThreadRuntime\";\nimport { Unsubscribe } from \"../types\";\nimport { ThreadListRuntime, ThreadListRuntimeImpl } from \"./ThreadListRuntime\";\n\nexport type AssistantRuntime = {\n /**\n * The currently selected main thread.\n */\n readonly thread: ThreadRuntime;\n\n /**\n * The thread manager, to rename, archive and delete threads.\n */\n readonly threadList: ThreadListRuntime;\n\n /**\n * Switch to a new thread.\n */\n switchToNewThread(): void;\n\n /**\n * Switch to a thread.\n *\n * @param threadId The thread ID to switch to.\n */\n switchToThread(threadId: string): void;\n\n /**\n * Register a model config provider. Model config providers are configuration such as system message, temperature, etc. that are set in the frontend.\n *\n * @param provider The model config provider to register.\n */\n registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;\n};\n\nexport class AssistantRuntimeImpl\n implements\n Omit<AssistantRuntimeCore, \"thread\" | \"threadList\">,\n AssistantRuntime\n{\n public readonly threadList;\n\n protected constructor(\n private readonly _core: AssistantRuntimeCore,\n private readonly _thread: ThreadRuntime,\n ) {\n this.threadList = new ThreadListRuntimeImpl(_core.threadList);\n }\n\n public get thread() {\n return this._thread;\n }\n\n public switchToNewThread() {\n return this._core.threadList.switchToNewThread();\n }\n\n public switchToThread(threadId: string) {\n return this._core.threadList.switchToThread(threadId);\n }\n\n public registerModelConfigProvider(provider: ModelConfigProvider) {\n return this._core.registerModelConfigProvider(provider);\n }\n\n protected static createMainThreadRuntime(\n _core: AssistantRuntimeCore,\n CustomThreadRuntime: new (\n binding: ThreadRuntimeCoreBinding,\n ) => ThreadRuntime = ThreadRuntimeImpl,\n ) {\n return new CustomThreadRuntime(\n new NestedSubscriptionSubject({\n path: {\n ref: \"threads.main\",\n threadSelector: { type: \"main\" },\n },\n getState: () => _core.threadList.mainThread,\n subscribe: (callback) => _core.threadList.subscribe(callback),\n }),\n );\n }\n\n public static create(\n _core: AssistantRuntimeCore,\n CustomThreadRuntime: new (\n binding: ThreadRuntimeCoreBinding,\n ) => ThreadRuntime = ThreadRuntimeImpl,\n ) {\n return new AssistantRuntimeImpl(\n _core,\n AssistantRuntimeImpl.createMainThreadRuntime(_core, CustomThreadRuntime),\n ) as AssistantRuntime;\n }\n}\n"],"mappings":";AACA,SAAS,iCAAiC;AAE1C;AAAA,EAGE;AAAA,OACK;AAEP,SAA4B,6BAA6B;AAiClD,IAAM,uBAAN,MAAM,sBAIb;AAAA,EAGY,YACS,OACA,SACjB;AAFiB;AACA;AAEjB,SAAK,aAAa,IAAI,sBAAsB,MAAM,UAAU;AAAA,EAC9D;AAAA,EAPgB;AAAA,EAShB,IAAW,SAAS;AAClB,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,oBAAoB;AACzB,WAAO,KAAK,MAAM,WAAW,kBAAkB;AAAA,EACjD;AAAA,EAEO,eAAe,UAAkB;AACtC,WAAO,KAAK,MAAM,WAAW,eAAe,QAAQ;AAAA,EACtD;AAAA,EAEO,4BAA4B,UAA+B;AAChE,WAAO,KAAK,MAAM,4BAA4B,QAAQ;AAAA,EACxD;AAAA,EAEA,OAAiB,wBACf,OACA,sBAEqB,mBACrB;AACA,WAAO,IAAI;AAAA,MACT,IAAI,0BAA0B;AAAA,QAC5B,MAAM;AAAA,UACJ,KAAK;AAAA,UACL,gBAAgB,EAAE,MAAM,OAAO;AAAA,QACjC;AAAA,QACA,UAAU,MAAM,MAAM,WAAW;AAAA,QACjC,WAAW,CAAC,aAAa,MAAM,WAAW,UAAU,QAAQ;AAAA,MAC9D,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,OAAc,OACZ,OACA,sBAEqB,mBACrB;AACA,WAAO,IAAI;AAAA,MACT;AAAA,MACA,sBAAqB,wBAAwB,OAAO,mBAAmB;AAAA,IACzE;AAAA,EACF;AACF;","names":[]}
@@ -3,13 +3,13 @@ import { ComposerRuntimeCoreBinding } from "./ComposerRuntime";
3
3
  import { Attachment, CompleteAttachment, PendingAttachment, Unsubscribe } from "../types";
4
4
  import { AttachmentRuntimePath } from "./RuntimePathTypes";
5
5
  type MessageAttachmentState = CompleteAttachment & {
6
- source: "message";
6
+ readonly source: "message";
7
7
  };
8
8
  type ThreadComposerAttachmentState = PendingAttachment & {
9
- source: "thread-composer";
9
+ readonly source: "thread-composer";
10
10
  };
11
11
  type EditComposerAttachmentState = Attachment & {
12
- source: "edit-composer";
12
+ readonly source: "edit-composer";
13
13
  };
14
14
  export type AttachmentState = ThreadComposerAttachmentState | EditComposerAttachmentState | MessageAttachmentState;
15
15
  type AttachmentSnapshotBinding<Source extends AttachmentRuntimeSource> = SubscribableWithState<AttachmentState & {
@@ -19,7 +19,7 @@ type AttachmentSnapshotBinding<Source extends AttachmentRuntimeSource> = Subscri
19
19
  }>;
20
20
  type AttachmentRuntimeSource = AttachmentState["source"];
21
21
  export type AttachmentRuntime<TSource extends AttachmentRuntimeSource = AttachmentRuntimeSource> = {
22
- path: AttachmentRuntimePath & {
22
+ readonly path: AttachmentRuntimePath & {
23
23
  attachmentSource: TSource;
24
24
  };
25
25
  readonly source: TSource;
@@ -1 +1 @@
1
- {"version":3,"file":"AttachmentRuntime.d.ts","sourceRoot":"","sources":["../../src/api/AttachmentRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,KAAK,sBAAsB,GAAG,kBAAkB,GAAG;IACjD,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,KAAK,6BAA6B,GAAG,iBAAiB,GAAG;IACvD,MAAM,EAAE,iBAAiB,CAAC;CAC3B,CAAC;AAEF,KAAK,2BAA2B,GAAG,UAAU,GAAG;IAC9C,MAAM,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,eAAe,GACvB,6BAA6B,GAC7B,2BAA2B,GAC3B,s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Q,yBAAyB,CAAC,eAAe,CAAC;IAC/F,IAAW,MAAM,IAAI,eAAe,CAEnC;CACF;AAED,qBAAa,4BAA6B,SAAQ,qBAAqB,CAAC,SAAS,CAAC;IAChF,IAAW,MAAM,IAAI,SAAS,CAE7B;gBAEW,IAAI,EAAE,yBAAyB,CAAC,SAAS,CAAC;IAI/C,MAAM,IAAI,KAAK;CAGvB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/AttachmentRuntime.ts"],"sourcesContent":["import { SubscribableWithState } from \"./subscribable/Subscribable\";\n\nimport { ComposerRuntimeCoreBinding } from \"./ComposerRuntime\";\nimport {\n Attachment,\n CompleteAttachment,\n PendingAttachment,\n Unsubscribe,\n} from \"../types\";\nimport { AttachmentRuntimePath } from \"./RuntimePathTypes\";\n\ntype MessageAttachmentState = CompleteAttachment & {\n source: \"message\";\n};\n\ntype ThreadComposerAttachmentState = PendingAttachment & {\n source: \"thread-composer\";\n};\n\ntype EditComposerAttachmentState = Attachment & {\n source: \"edit-composer\";\n};\n\nexport type AttachmentState =\n | ThreadComposerAttachmentState\n | EditComposerAttachmentState\n | MessageAttachmentState;\n\ntype AttachmentSnapshotBinding<Source extends AttachmentRuntimeSource> =\n SubscribableWithState<\n AttachmentState & { source: Source },\n AttachmentRuntimePath & { attachmentSource: Source }\n >;\n\ntype AttachmentRuntimeSource = AttachmentState[\"source\"];\n\nexport type AttachmentRuntime<\n TSource extends AttachmentRuntimeSource = AttachmentRuntimeSource,\n> = {\n path: AttachmentRuntimePath & { attachmentSource: TSource };\n readonly source: TSource;\n getState(): AttachmentState & { source: TSource };\n remove(): Promise<void>;\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport abstract class AttachmentRuntimeImpl<\n Source extends AttachmentRuntimeSource = AttachmentRuntimeSource,\n> implements AttachmentRuntime\n{\n public get path() {\n return this._core.path;\n }\n\n public abstract get source(): Source;\n\n constructor(private _core: AttachmentSnapshotBinding<Source>) {}\n\n public getState(): AttachmentState & { source: Source } {\n return this._core.getState();\n }\n\n public abstract remove(): Promise<void>;\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n}\n\nabstract class ComposerAttachmentRuntime<\n Source extends \"thread-composer\" | \"edit-composer\",\n> extends AttachmentRuntimeImpl<Source> {\n constructor(\n core: AttachmentSnapshotBinding<Source>,\n private _composerApi: ComposerRuntimeCoreBinding,\n ) {\n super(core);\n }\n\n public remove() {\n const core = this._composerApi.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.removeAttachment(this.getState().id);\n }\n}\n\nexport class ThreadComposerAttachmentRuntimeImpl extends ComposerAttachmentRuntime<\"thread-composer\"> {\n public get source(): \"thread-composer\" {\n return \"thread-composer\";\n }\n}\n\nexport class EditComposerAttachmentRuntimeImpl extends ComposerAttachmentRuntime<\"edit-composer\"> {\n public get source(): \"edit-composer\" {\n return \"edit-composer\";\n }\n}\n\nexport class MessageAttachmentRuntimeImpl extends AttachmentRuntimeImpl<\"message\"> {\n public get source(): \"message\" {\n return \"message\";\n }\n\n constructor(core: AttachmentSnapshotBinding<\"message\">) {\n super(core);\n }\n\n public remove(): never {\n throw new Error(\"Message attachments cannot be removed\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8CO,IAAe,wBAAf,MAGP;AAAA,EAOE,YAAoB,OAA0C;AAA1C;AAAA,EAA2C;AAAA,EAN/D,IAAW,OAAO;AAChB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA,EAMO,WAAiD;AACtD,WAAO,KAAK,MAAM,SAAS;AAAA,EAC7B;AAAA,EAIO,UAAU,UAAsB;AACrC,WAAO,KAAK,MAAM,UAAU,QAAQ;AAAA,EACtC;AACF;AAEA,IAAe,4BAAf,cAEU,sBAA8B;AAAA,EACtC,YACE,MACQ,cACR;AACA,UAAM,IAAI;AAFF;AAAA,EAGV;AAAA,EAEO,SAAS;AACd,UAAM,OAAO,KAAK,aAAa,SAAS;AACxC,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,2BAA2B;AACtD,WAAO,KAAK,iBAAiB,KAAK,SAAS,EAAE,EAAE;AAAA,EACjD;AACF;AAEO,IAAM,sCAAN,cAAkD,0BAA6C;AAAA,EACpG,IAAW,SAA4B;AACrC,WAAO;AAAA,EACT;AACF;AAEO,IAAM,oCAAN,cAAgD,0BAA2C;AAAA,EAChG,IAAW,SAA0B;AACnC,WAAO;AAAA,EACT;AACF;AAEO,IAAM,+BAAN,cAA2C,sBAAiC;AAAA,EACjF,IAAW,SAAoB;AAC7B,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,MAA4C;AACtD,UAAM,IAAI;AAAA,EACZ;AAAA,EAEO,SAAgB;AACrB,UAAM,IAAI,MAAM,uCAAuC;AAAA,EACzD;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/api/AttachmentRuntime.ts"],"sourcesContent":["import { SubscribableWithState } from \"./subscribable/Subscribable\";\n\nimport { ComposerRuntimeCoreBinding } from \"./ComposerRuntime\";\nimport {\n Attachment,\n CompleteAttachment,\n PendingAttachment,\n Unsubscribe,\n} from \"../types\";\nimport { AttachmentRuntimePath } from \"./RuntimePathTypes\";\n\ntype MessageAttachmentState = CompleteAttachment & {\n readonly source: \"message\";\n};\n\ntype ThreadComposerAttachmentState = PendingAttachment & {\n readonly source: \"thread-composer\";\n};\n\ntype EditComposerAttachmentState = Attachment & {\n readonly source: \"edit-composer\";\n};\n\nexport type AttachmentState =\n | ThreadComposerAttachmentState\n | EditComposerAttachmentState\n | MessageAttachmentState;\n\ntype AttachmentSnapshotBinding<Source extends AttachmentRuntimeSource> =\n SubscribableWithState<\n AttachmentState & { source: Source },\n AttachmentRuntimePath & { attachmentSource: Source }\n >;\n\ntype AttachmentRuntimeSource = AttachmentState[\"source\"];\n\nexport type AttachmentRuntime<\n TSource extends AttachmentRuntimeSource = AttachmentRuntimeSource,\n> = {\n readonly path: AttachmentRuntimePath & { attachmentSource: TSource };\n readonly source: TSource;\n getState(): AttachmentState & { source: TSource };\n remove(): Promise<void>;\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport abstract class AttachmentRuntimeImpl<\n Source extends AttachmentRuntimeSource = AttachmentRuntimeSource,\n> implements AttachmentRuntime\n{\n public get path() {\n return this._core.path;\n }\n\n public abstract get source(): Source;\n\n constructor(private _core: AttachmentSnapshotBinding<Source>) {}\n\n public getState(): AttachmentState & { source: Source } {\n return this._core.getState();\n }\n\n public abstract remove(): Promise<void>;\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n}\n\nabstract class ComposerAttachmentRuntime<\n Source extends \"thread-composer\" | \"edit-composer\",\n> extends AttachmentRuntimeImpl<Source> {\n constructor(\n core: AttachmentSnapshotBinding<Source>,\n private _composerApi: ComposerRuntimeCoreBinding,\n ) {\n super(core);\n }\n\n public remove() {\n const core = this._composerApi.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.removeAttachment(this.getState().id);\n }\n}\n\nexport class ThreadComposerAttachmentRuntimeImpl extends ComposerAttachmentRuntime<\"thread-composer\"> {\n public get source(): \"thread-composer\" {\n return \"thread-composer\";\n }\n}\n\nexport class EditComposerAttachmentRuntimeImpl extends ComposerAttachmentRuntime<\"edit-composer\"> {\n public get source(): \"edit-composer\" {\n return \"edit-composer\";\n }\n}\n\nexport class MessageAttachmentRuntimeImpl extends AttachmentRuntimeImpl<\"message\"> {\n public get source(): \"message\" {\n return \"message\";\n }\n\n constructor(core: AttachmentSnapshotBinding<\"message\">) {\n super(core);\n }\n\n public remove(): never {\n throw new Error(\"Message attachments cannot be removed\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8CO,IAAe,wBAAf,MAGP;AAAA,EAOE,YAAoB,OAA0C;AAA1C;AAAA,EAA2C;AAAA,EAN/D,IAAW,OAAO;AAChB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA,EAMO,WAAiD;AACtD,WAAO,KAAK,MAAM,SAAS;AAAA,EAC7B;AAAA,EAIO,UAAU,UAAsB;AACrC,WAAO,KAAK,MAAM,UAAU,QAAQ;AAAA,EACtC;AACF;AAEA,IAAe,4BAAf,cAEU,sBAA8B;AAAA,EACtC,YACE,MACQ,cACR;AACA,UAAM,IAAI;AAFF;AAAA,EAGV;AAAA,EAEO,SAAS;AACd,UAAM,OAAO,KAAK,aAAa,SAAS;AACxC,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,2BAA2B;AACtD,WAAO,KAAK,iBAAiB,KAAK,SAAS,EAAE,EAAE;AAAA,EACjD;AACF;AAEO,IAAM,sCAAN,cAAkD,0BAA6C;AAAA,EACpG,IAAW,SAA4B;AACrC,WAAO;AAAA,EACT;AACF;AAEO,IAAM,oCAAN,cAAgD,0BAA2C;AAAA,EAChG,IAAW,SAA0B;AACnC,WAAO;AAAA,EACT;AACF;AAEO,IAAM,+BAAN,cAA2C,sBAAiC;AAAA,EACjF,IAAW,SAAoB;AAC7B,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,MAA4C;AACtD,UAAM,IAAI;AAAA,EACZ;AAAA,EAEO,SAAgB;AACrB,UAAM,IAAI,MAAM,uCAAuC;AAAA,EACzD;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/AttachmentRuntime.ts"],"sourcesContent":["import { SubscribableWithState } from \"./subscribable/Subscribable\";\n\nimport { ComposerRuntimeCoreBinding } from \"./ComposerRuntime\";\nimport {\n Attachment,\n CompleteAttachment,\n PendingAttachment,\n Unsubscribe,\n} from \"../types\";\nimport { AttachmentRuntimePath } from \"./RuntimePathTypes\";\n\ntype MessageAttachmentState = CompleteAttachment & {\n source: \"message\";\n};\n\ntype ThreadComposerAttachmentState = PendingAttachment & {\n source: \"thread-composer\";\n};\n\ntype EditComposerAttachmentState = Attachment & {\n source: \"edit-composer\";\n};\n\nexport type AttachmentState =\n | ThreadComposerAttachmentState\n | EditComposerAttachmentState\n | MessageAttachmentState;\n\ntype AttachmentSnapshotBinding<Source extends AttachmentRuntimeSource> =\n SubscribableWithState<\n AttachmentState & { source: Source },\n AttachmentRuntimePath & { attachmentSource: Source }\n >;\n\ntype AttachmentRuntimeSource = AttachmentState[\"source\"];\n\nexport type AttachmentRuntime<\n TSource extends AttachmentRuntimeSource = AttachmentRuntimeSource,\n> = {\n path: AttachmentRuntimePath & { attachmentSource: TSource };\n readonly source: TSource;\n getState(): AttachmentState & { source: TSource };\n remove(): Promise<void>;\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport abstract class AttachmentRuntimeImpl<\n Source extends AttachmentRuntimeSource = AttachmentRuntimeSource,\n> implements AttachmentRuntime\n{\n public get path() {\n return this._core.path;\n }\n\n public abstract get source(): Source;\n\n constructor(private _core: AttachmentSnapshotBinding<Source>) {}\n\n public getState(): AttachmentState & { source: Source } {\n return this._core.getState();\n }\n\n public abstract remove(): Promise<void>;\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n}\n\nabstract class ComposerAttachmentRuntime<\n Source extends \"thread-composer\" | \"edit-composer\",\n> extends AttachmentRuntimeImpl<Source> {\n constructor(\n core: AttachmentSnapshotBinding<Source>,\n private _composerApi: ComposerRuntimeCoreBinding,\n ) {\n super(core);\n }\n\n public remove() {\n const core = this._composerApi.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.removeAttachment(this.getState().id);\n }\n}\n\nexport class ThreadComposerAttachmentRuntimeImpl extends ComposerAttachmentRuntime<\"thread-composer\"> {\n public get source(): \"thread-composer\" {\n return \"thread-composer\";\n }\n}\n\nexport class EditComposerAttachmentRuntimeImpl extends ComposerAttachmentRuntime<\"edit-composer\"> {\n public get source(): \"edit-composer\" {\n return \"edit-composer\";\n }\n}\n\nexport class MessageAttachmentRuntimeImpl extends AttachmentRuntimeImpl<\"message\"> {\n public get source(): \"message\" {\n return \"message\";\n }\n\n constructor(core: AttachmentSnapshotBinding<\"message\">) {\n super(core);\n }\n\n public remove(): never {\n throw new Error(\"Message attachments cannot be removed\");\n }\n}\n"],"mappings":";AA8CO,IAAe,wBAAf,MAGP;AAAA,EAOE,YAAoB,OAA0C;AAA1C;AAAA,EAA2C;AAAA,EAN/D,IAAW,OAAO;AAChB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA,EAMO,WAAiD;AACtD,WAAO,KAAK,MAAM,SAAS;AAAA,EAC7B;AAAA,EAIO,UAAU,UAAsB;AACrC,WAAO,KAAK,MAAM,UAAU,QAAQ;AAAA,EACtC;AACF;AAEA,IAAe,4BAAf,cAEU,sBAA8B;AAAA,EACtC,YACE,MACQ,cACR;AACA,UAAM,IAAI;AAFF;AAAA,EAGV;AAAA,EAEO,SAAS;AACd,UAAM,OAAO,KAAK,aAAa,SAAS;AACxC,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,2BAA2B;AACtD,WAAO,KAAK,iBAAiB,KAAK,SAAS,EAAE,EAAE;AAAA,EACjD;AACF;AAEO,IAAM,sCAAN,cAAkD,0BAA6C;AAAA,EACpG,IAAW,SAA4B;AACrC,WAAO;AAAA,EACT;AACF;AAEO,IAAM,oCAAN,cAAgD,0BAA2C;AAAA,EAChG,IAAW,SAA0B;AACnC,WAAO;AAAA,EACT;AACF;AAEO,IAAM,+BAAN,cAA2C,sBAAiC;AAAA,EACjF,IAAW,SAAoB;AAC7B,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,MAA4C;AACtD,UAAM,IAAI;AAAA,EACZ;AAAA,EAEO,SAAgB;AACrB,UAAM,IAAI,MAAM,uCAAuC;AAAA,EACzD;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/api/AttachmentRuntime.ts"],"sourcesContent":["import { SubscribableWithState } from \"./subscribable/Subscribable\";\n\nimport { ComposerRuntimeCoreBinding } from \"./ComposerRuntime\";\nimport {\n Attachment,\n CompleteAttachment,\n PendingAttachment,\n Unsubscribe,\n} from \"../types\";\nimport { AttachmentRuntimePath } from \"./RuntimePathTypes\";\n\ntype MessageAttachmentState = CompleteAttachment & {\n readonly source: \"message\";\n};\n\ntype ThreadComposerAttachmentState = PendingAttachment & {\n readonly source: \"thread-composer\";\n};\n\ntype EditComposerAttachmentState = Attachment & {\n readonly source: \"edit-composer\";\n};\n\nexport type AttachmentState =\n | ThreadComposerAttachmentState\n | EditComposerAttachmentState\n | MessageAttachmentState;\n\ntype AttachmentSnapshotBinding<Source extends AttachmentRuntimeSource> =\n SubscribableWithState<\n AttachmentState & { source: Source },\n AttachmentRuntimePath & { attachmentSource: Source }\n >;\n\ntype AttachmentRuntimeSource = AttachmentState[\"source\"];\n\nexport type AttachmentRuntime<\n TSource extends AttachmentRuntimeSource = AttachmentRuntimeSource,\n> = {\n readonly path: AttachmentRuntimePath & { attachmentSource: TSource };\n readonly source: TSource;\n getState(): AttachmentState & { source: TSource };\n remove(): Promise<void>;\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport abstract class AttachmentRuntimeImpl<\n Source extends AttachmentRuntimeSource = AttachmentRuntimeSource,\n> implements AttachmentRuntime\n{\n public get path() {\n return this._core.path;\n }\n\n public abstract get source(): Source;\n\n constructor(private _core: AttachmentSnapshotBinding<Source>) {}\n\n public getState(): AttachmentState & { source: Source } {\n return this._core.getState();\n }\n\n public abstract remove(): Promise<void>;\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n}\n\nabstract class ComposerAttachmentRuntime<\n Source extends \"thread-composer\" | \"edit-composer\",\n> extends AttachmentRuntimeImpl<Source> {\n constructor(\n core: AttachmentSnapshotBinding<Source>,\n private _composerApi: ComposerRuntimeCoreBinding,\n ) {\n super(core);\n }\n\n public remove() {\n const core = this._composerApi.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.removeAttachment(this.getState().id);\n }\n}\n\nexport class ThreadComposerAttachmentRuntimeImpl extends ComposerAttachmentRuntime<\"thread-composer\"> {\n public get source(): \"thread-composer\" {\n return \"thread-composer\";\n }\n}\n\nexport class EditComposerAttachmentRuntimeImpl extends ComposerAttachmentRuntime<\"edit-composer\"> {\n public get source(): \"edit-composer\" {\n return \"edit-composer\";\n }\n}\n\nexport class MessageAttachmentRuntimeImpl extends AttachmentRuntimeImpl<\"message\"> {\n public get source(): \"message\" {\n return \"message\";\n }\n\n constructor(core: AttachmentSnapshotBinding<\"message\">) {\n super(core);\n }\n\n public remove(): never {\n throw new Error(\"Message attachments cannot be removed\");\n }\n}\n"],"mappings":";AA8CO,IAAe,wBAAf,MAGP;AAAA,EAOE,YAAoB,OAA0C;AAA1C;AAAA,EAA2C;AAAA,EAN/D,IAAW,OAAO;AAChB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA,EAMO,WAAiD;AACtD,WAAO,KAAK,MAAM,SAAS;AAAA,EAC7B;AAAA,EAIO,UAAU,UAAsB;AACrC,WAAO,KAAK,MAAM,UAAU,QAAQ;AAAA,EACtC;AACF;AAEA,IAAe,4BAAf,cAEU,sBAA8B;AAAA,EACtC,YACE,MACQ,cACR;AACA,UAAM,IAAI;AAFF;AAAA,EAGV;AAAA,EAEO,SAAS;AACd,UAAM,OAAO,KAAK,aAAa,SAAS;AACxC,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,2BAA2B;AACtD,WAAO,KAAK,iBAAiB,KAAK,SAAS,EAAE,EAAE;AAAA,EACjD;AACF;AAEO,IAAM,sCAAN,cAAkD,0BAA6C;AAAA,EACpG,IAAW,SAA4B;AACrC,WAAO;AAAA,EACT;AACF;AAEO,IAAM,oCAAN,cAAgD,0BAA2C;AAAA,EAChG,IAAW,SAA0B;AACnC,WAAO;AAAA,EACT;AACF;AAEO,IAAM,+BAAN,cAA2C,sBAAiC;AAAA,EACjF,IAAW,SAAoB;AAC7B,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,MAA4C;AACtD,UAAM,IAAI;AAAA,EACZ;AAAA,EAEO,SAAgB;AACrB,UAAM,IAAI,MAAM,uCAAuC;AAAA,EACzD;AACF;","names":[]}
@@ -13,23 +13,23 @@ export type EditComposerRuntimeCoreBinding = SubscribableWithState<ComposerRunti
13
13
  }>;
14
14
  export type ComposerRuntimeCoreBinding = SubscribableWithState<ComposerRuntimeCore | undefined, ComposerRuntimePath>;
15
15
  type BaseComposerState = {
16
- text: string;
17
- role: MessageRole;
18
- attachments: readonly Attachment[];
19
- canCancel: boolean;
20
- isEditing: boolean;
21
- isEmpty: boolean;
16
+ readonly text: string;
17
+ readonly role: MessageRole;
18
+ readonly attachments: readonly Attachment[];
19
+ readonly canCancel: boolean;
20
+ readonly isEditing: boolean;
21
+ readonly isEmpty: boolean;
22
22
  };
23
23
  export type ThreadComposerState = BaseComposerState & {
24
- type: "thread";
25
- attachments: readonly PendingAttachment[];
24
+ readonly type: "thread";
25
+ readonly attachments: readonly PendingAttachment[];
26
26
  };
27
27
  export type EditComposerState = BaseComposerState & {
28
- type: "edit";
28
+ readonly type: "edit";
29
29
  };
30
30
  export type ComposerState = ThreadComposerState | EditComposerState;
31
31
  export type ComposerRuntime = {
32
- path: ComposerRuntimePath;
32
+ readonly path: ComposerRuntimePath;
33
33
  readonly type: "edit" | "thread";
34
34
  getState(): ComposerState;
35
35
  setText(text: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"ComposerRuntime.d.ts","sourceRoot":"","sources":["../../src/api/ComposerRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,OAAO,EACL,iBAAiB,EAEjB,iCAAiC,EACjC,mCAAmC,EACpC,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC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AI,iBAAiB;IAItC,SAAS;IAIT,oBAAoB,CAAC,GAAG,EAAE,MAAM;CAwBxC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/ComposerRuntime.ts"],"sourcesContent":["import { Attachment, PendingAttachment } from \"../types/AttachmentTypes\";\nimport {\n ComposerRuntimeCore,\n ThreadComposerRuntimeCore,\n} from \"../runtimes/core/ComposerRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport {\n AttachmentRuntime,\n AttachmentState,\n EditComposerAttachmentRuntimeImpl,\n ThreadComposerAttachmentRuntimeImpl,\n} from \"./AttachmentRuntime\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ComposerRuntimePath } from \"./RuntimePathTypes\";\nimport { MessageRole } from \"../types/AssistantTypes\";\n\nexport type ThreadComposerRuntimeCoreBinding = SubscribableWithState<\n ThreadComposerRuntimeCore | undefined,\n ComposerRuntimePath & { composerSource: \"thread\" }\n>;\n\nexport type EditComposerRuntimeCoreBinding = SubscribableWithState<\n ComposerRuntimeCore | undefined,\n ComposerRuntimePath & { composerSource: \"edit\" }\n>;\n\nexport type ComposerRuntimeCoreBinding = SubscribableWithState<\n ComposerRuntimeCore | undefined,\n ComposerRuntimePath\n>;\n\ntype BaseComposerState = {\n text: string;\n role: MessageRole;\n attachments: readonly Attachment[];\n\n canCancel: boolean;\n isEditing: boolean;\n isEmpty: boolean;\n};\n\nexport type ThreadComposerState = BaseComposerState & {\n type: \"thread\";\n\n attachments: readonly PendingAttachment[];\n};\n\nexport type EditComposerState = BaseComposerState & {\n type: \"edit\";\n};\n\nexport type ComposerState = ThreadComposerState | EditComposerState;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst getThreadComposerState = (\n runtime: ThreadComposerRuntimeCore | undefined,\n): ThreadComposerState => {\n return Object.freeze({\n type: \"thread\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n text: runtime?.text ?? \"\",\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n role: runtime?.role ?? \"user\",\n\n value: runtime?.text ?? \"\",\n });\n};\n\nconst getEditComposerState = (\n runtime: ComposerRuntimeCore | undefined,\n): EditComposerState => {\n return Object.freeze({\n type: \"edit\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n text: runtime?.text ?? \"\",\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n role: runtime?.role ?? \"user\",\n\n value: runtime?.text ?? \"\",\n });\n};\n\nexport type ComposerRuntime = {\n path: ComposerRuntimePath;\n readonly type: \"edit\" | \"thread\";\n getState(): ComposerState;\n\n setText(text: string): void;\n setValue(text: string): void;\n\n getAttachmentAccept(): string;\n addAttachment(file: File): Promise<void>;\n\n reset(): void;\n send(): void;\n cancel(): void;\n subscribe(callback: () => void): Unsubscribe;\n getAttachmentByIndex(idx: number): AttachmentRuntime;\n};\n\nexport abstract class ComposerRuntimeImpl implements ComposerRuntime {\n public get path() {\n return this._core.path;\n }\n\n public abstract get type(): \"edit\" | \"thread\";\n\n constructor(protected _core: ComposerRuntimeCoreBinding) {}\n\n public abstract getState(): ComposerState;\n\n public setText(text: string) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setText(text);\n }\n\n public setValue(text: string) {\n this.setText(text);\n }\n\n public addAttachment(file: File) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.addAttachment(file);\n }\n\n public reset() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.reset();\n }\n\n public send() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.send();\n }\n\n public cancel() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.cancel();\n }\n\n public setRole(role: MessageRole) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setRole(role);\n }\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n\n public getAttachmentAccept(): string {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.getAttachmentAccept();\n }\n\n public abstract getAttachmentByIndex(idx: number): AttachmentRuntime;\n}\n\nexport type ThreadComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"thread\" };\n readonly type: \"thread\";\n getState(): ThreadComposerState;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"thread-composer\" };\n};\n\nexport class ThreadComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements ThreadComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & {\n composerSource: \"thread\";\n };\n }\n\n public get type() {\n return \"thread\" as const;\n }\n\n private _getState;\n\n constructor(core: ThreadComposerRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getThreadComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public override getState(): ThreadComposerState {\n return this._getState();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new ThreadComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"thread-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: this.path.ref + `${this.path.ref}.attachments[${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: \"thread-composer\",\n } satisfies AttachmentState & { source: \"thread-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n\nexport type EditComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"edit\" };\n readonly type: \"edit\";\n\n getState(): EditComposerState;\n beginEdit(): void;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"edit-composer\" };\n};\n\nexport class EditComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements EditComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & { composerSource: \"edit\" };\n }\n\n public get type() {\n return \"edit\" as const;\n }\n\n private _getState;\n constructor(\n core: EditComposerRuntimeCoreBinding,\n private _beginEdit: () => void,\n ) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getEditComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public override getState(): EditComposerState {\n return this._getState();\n }\n\n public beginEdit() {\n this._beginEdit();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new EditComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"edit-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: this.path.ref + `${this.path.ref}.attachments[${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: \"edit-composer\",\n } satisfies AttachmentState & { source: \"edit-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,gCAAmC;A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;AAChB,WAAO;AAAA,EACT;AAAA,EAEQ;AAAA,EAoBQ,WAA8B;AAC5C,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEO,YAAY;AACjB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEO,qBAAqB,KAAa;AACvC,WAAO,IAAI;AAAA,MACT,IAAI,mDAAsB;AAAA,QACxB,MAAM;AAAA,UACJ,GAAG,KAAK;AAAA,UACR,kBAAkB;AAAA,UAClB,oBAAoB,EAAE,MAAM,SAAS,OAAO,IAAI;AAAA,UAChD,KAAK,KAAK,KAAK,MAAM,GAAG,KAAK,KAAK,GAAG,gBAAgB,GAAG;AAAA,QAC1D;AAAA,QACA,UAAU,MAAM;AACd,gBAAM,cAAc,KAAK,SAAS,EAAE;AACpC,gBAAM,aAAa,YAAY,GAAG;AAClC,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,MACD,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/api/ComposerRuntime.ts"],"sourcesContent":["import { Attachment, PendingAttachment } from \"../types/AttachmentTypes\";\nimport {\n ComposerRuntimeCore,\n ThreadComposerRuntimeCore,\n} from \"../runtimes/core/ComposerRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport {\n AttachmentRuntime,\n AttachmentState,\n EditComposerAttachmentRuntimeImpl,\n ThreadComposerAttachmentRuntimeImpl,\n} from \"./AttachmentRuntime\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ComposerRuntimePath } from \"./RuntimePathTypes\";\nimport { MessageRole } from \"../types/AssistantTypes\";\n\nexport type ThreadComposerRuntimeCoreBinding = SubscribableWithState<\n ThreadComposerRuntimeCore | undefined,\n ComposerRuntimePath & { composerSource: \"thread\" }\n>;\n\nexport type EditComposerRuntimeCoreBinding = SubscribableWithState<\n ComposerRuntimeCore | undefined,\n ComposerRuntimePath & { composerSource: \"edit\" }\n>;\n\nexport type ComposerRuntimeCoreBinding = SubscribableWithState<\n ComposerRuntimeCore | undefined,\n ComposerRuntimePath\n>;\n\ntype BaseComposerState = {\n readonly text: string;\n readonly role: MessageRole;\n readonly attachments: readonly Attachment[];\n\n readonly canCancel: boolean;\n readonly isEditing: boolean;\n readonly isEmpty: boolean;\n};\n\nexport type ThreadComposerState = BaseComposerState & {\n readonly type: \"thread\";\n\n readonly attachments: readonly PendingAttachment[];\n};\n\nexport type EditComposerState = BaseComposerState & {\n readonly type: \"edit\";\n};\n\nexport type ComposerState = ThreadComposerState | EditComposerState;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst getThreadComposerState = (\n runtime: ThreadComposerRuntimeCore | undefined,\n): ThreadComposerState => {\n return Object.freeze({\n type: \"thread\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n text: runtime?.text ?? \"\",\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n role: runtime?.role ?? \"user\",\n\n value: runtime?.text ?? \"\",\n });\n};\n\nconst getEditComposerState = (\n runtime: ComposerRuntimeCore | undefined,\n): EditComposerState => {\n return Object.freeze({\n type: \"edit\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n text: runtime?.text ?? \"\",\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n role: runtime?.role ?? \"user\",\n\n value: runtime?.text ?? \"\",\n });\n};\n\nexport type ComposerRuntime = {\n readonly path: ComposerRuntimePath;\n readonly type: \"edit\" | \"thread\";\n getState(): ComposerState;\n\n setText(text: string): void;\n setValue(text: string): void;\n\n getAttachmentAccept(): string;\n addAttachment(file: File): Promise<void>;\n\n reset(): void;\n send(): void;\n cancel(): void;\n subscribe(callback: () => void): Unsubscribe;\n getAttachmentByIndex(idx: number): AttachmentRuntime;\n};\n\nexport abstract class ComposerRuntimeImpl implements ComposerRuntime {\n public get path() {\n return this._core.path;\n }\n\n public abstract get type(): \"edit\" | \"thread\";\n\n constructor(protected _core: ComposerRuntimeCoreBinding) {}\n\n public abstract getState(): ComposerState;\n\n public setText(text: string) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setText(text);\n }\n\n public setValue(text: string) {\n this.setText(text);\n }\n\n public addAttachment(file: File) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.addAttachment(file);\n }\n\n public reset() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.reset();\n }\n\n public send() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.send();\n }\n\n public cancel() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.cancel();\n }\n\n public setRole(role: MessageRole) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setRole(role);\n }\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n\n public getAttachmentAccept(): string {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.getAttachmentAccept();\n }\n\n public abstract getAttachmentByIndex(idx: number): AttachmentRuntime;\n}\n\nexport type ThreadComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"thread\" };\n readonly type: \"thread\";\n getState(): ThreadComposerState;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"thread-composer\" };\n};\n\nexport class ThreadComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements ThreadComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & {\n composerSource: \"thread\";\n };\n }\n\n public get type() {\n return \"thread\" as const;\n }\n\n private _getState;\n\n constructor(core: ThreadComposerRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getThreadComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public override getState(): ThreadComposerState {\n return this._getState();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new ThreadComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"thread-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: this.path.ref + `${this.path.ref}.attachments[${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: \"thread-composer\",\n } satisfies AttachmentState & { source: \"thread-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n\nexport type EditComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"edit\" };\n readonly type: \"edit\";\n\n getState(): EditComposerState;\n beginEdit(): void;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"edit-composer\" };\n};\n\nexport class EditComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements EditComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & { composerSource: \"edit\" };\n }\n\n public get type() {\n return \"edit\" as const;\n }\n\n private _getState;\n constructor(\n core: EditComposerRuntimeCoreBinding,\n private _beginEdit: () => void,\n ) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getEditComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public override getState(): EditComposerState {\n return this._getState();\n }\n\n public beginEdit() {\n this._beginEdit();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new EditComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"edit-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: this.path.ref + `${this.path.ref}.attachments[${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: \"edit-composer\",\n } satisfies AttachmentState & { source: \"edit-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,gCAAmC;AACnC,+BAKO;AACP,mCAAsC;AACtC,yBAA4B;AAyC5B,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AACpC,IAAM,yBAAyB,CAC7B,YACwB;AACxB,SAAO,OAAO,OAAO;AAAA,IACnB,MAAM;AAAA,IAEN,WAAW,SAAS,aAAa;AAAA,IACjC,WAAW,SAAS,aAAa;AAAA,IACjC,SAAS,SAAS,WAAW;AAAA,IAC7B,MAAM,SAAS,QAAQ;AAAA,IACvB,aAAa,SAAS,eAAe;AAAA,IACrC,MAAM,SAAS,QAAQ;AAAA,IAEvB,OAAO,SAAS,QAAQ;AAAA,EAC1B,CAAC;AACH;AAEA,IAAM,uBAAuB,CAC3B,YACsB;AACtB,SAAO,OAAO,OAAO;AAAA,IACnB,MAAM;AAAA,IAEN,WAAW,SAAS,aAAa;AAAA,IACjC,WAAW,SAAS,aAAa;AAAA,IACjC,SAAS,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ACL,GAAG;AAAA,YACH,QAAQ;AAAA,UACV;AAAA,QACF;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/ComposerRuntime.ts"],"sourcesContent":["import { Attachment, PendingAttachment } from \"../types/AttachmentTypes\";\nimport {\n ComposerRuntimeCore,\n ThreadComposerRuntimeCore,\n} from \"../runtimes/core/ComposerRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport {\n AttachmentRuntime,\n AttachmentState,\n EditComposerAttachmentRuntimeImpl,\n ThreadComposerAttachmentRuntimeImpl,\n} from \"./AttachmentRuntime\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ComposerRuntimePath } from \"./RuntimePathTypes\";\nimport { MessageRole } from \"../types/AssistantTypes\";\n\nexport type ThreadComposerRuntimeCoreBinding = SubscribableWithState<\n ThreadComposerRuntimeCore | undefined,\n ComposerRuntimePath & { composerSource: \"thread\" }\n>;\n\nexport type EditComposerRuntimeCoreBinding = SubscribableWithState<\n ComposerRuntimeCore | undefined,\n ComposerRuntimePath & { composerSource: \"edit\" }\n>;\n\nexport type ComposerRuntimeCoreBinding = SubscribableWithState<\n ComposerRuntimeCore | undefined,\n ComposerRuntimePath\n>;\n\ntype BaseComposerState = {\n text: string;\n role: MessageRole;\n attachments: readonly Attachment[];\n\n canCancel: boolean;\n isEditing: boolean;\n isEmpty: boolean;\n};\n\nexport type ThreadComposerState = BaseComposerState & {\n type: \"thread\";\n\n attachments: readonly PendingAttachment[];\n};\n\nexport type EditComposerState = BaseComposerState & {\n type: \"edit\";\n};\n\nexport type ComposerState = ThreadComposerState | EditComposerState;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst getThreadComposerState = (\n runtime: ThreadComposerRuntimeCore | undefined,\n): ThreadComposerState => {\n return Object.freeze({\n type: \"thread\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n text: runtime?.text ?? \"\",\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n role: runtime?.role ?? \"user\",\n\n value: runtime?.text ?? \"\",\n });\n};\n\nconst getEditComposerState = (\n runtime: ComposerRuntimeCore | undefined,\n): EditComposerState => {\n return Object.freeze({\n type: \"edit\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n text: runtime?.text ?? \"\",\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n role: runtime?.role ?? \"user\",\n\n value: runtime?.text ?? \"\",\n });\n};\n\nexport type ComposerRuntime = {\n path: ComposerRuntimePath;\n readonly type: \"edit\" | \"thread\";\n getState(): ComposerState;\n\n setText(text: string): void;\n setValue(text: string): void;\n\n getAttachmentAccept(): string;\n addAttachment(file: File): Promise<void>;\n\n reset(): void;\n send(): void;\n cancel(): void;\n subscribe(callback: () => void): Unsubscribe;\n getAttachmentByIndex(idx: number): AttachmentRuntime;\n};\n\nexport abstract class ComposerRuntimeImpl implements ComposerRuntime {\n public get path() {\n return this._core.path;\n }\n\n public abstract get type(): \"edit\" | \"thread\";\n\n constructor(protected _core: ComposerRuntimeCoreBinding) {}\n\n public abstract getState(): ComposerState;\n\n public setText(text: string) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setText(text);\n }\n\n public setValue(text: string) {\n this.setText(text);\n }\n\n public addAttachment(file: File) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.addAttachment(file);\n }\n\n public reset() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.reset();\n }\n\n public send() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.send();\n }\n\n public cancel() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.cancel();\n }\n\n public setRole(role: MessageRole) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setRole(role);\n }\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n\n public getAttachmentAccept(): string {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.getAttachmentAccept();\n }\n\n public abstract getAttachmentByIndex(idx: number): AttachmentRuntime;\n}\n\nexport type ThreadComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"thread\" };\n readonly type: \"thread\";\n getState(): ThreadComposerState;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"thread-composer\" };\n};\n\nexport class ThreadComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements ThreadComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & {\n composerSource: \"thread\";\n };\n }\n\n public get type() {\n return \"thread\" as const;\n }\n\n private _getState;\n\n constructor(core: ThreadComposerRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getThreadComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public override getState(): ThreadComposerState {\n return this._getState();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new ThreadComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"thread-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: this.path.ref + `${this.path.ref}.attachments[${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: \"thread-composer\",\n } satisfies AttachmentState & { source: \"thread-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n\nexport type EditComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"edit\" };\n readonly type: \"edit\";\n\n getState(): EditComposerState;\n beginEdit(): void;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"edit-composer\" };\n};\n\nexport class EditComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements EditComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & { composerSource: \"edit\" };\n }\n\n public get type() {\n return \"edit\" as const;\n }\n\n private _getState;\n constructor(\n core: EditComposerRuntimeCoreBinding,\n private _beginEdit: () => void,\n ) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getEditComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public override getState(): EditComposerState {\n return this._getState();\n }\n\n public beginEdit() {\n this._beginEdit();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new EditComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"edit-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: this.path.ref + `${this.path.ref}.attachments[${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: \"edit-composer\",\n } satisfies AttachmentState & { source: \"edit-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );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EA1BA,IAAoB,OAAO;AACzB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA,EAEA,IAAW,OAAO;AAChB,WAAO;AAAA,EACT;AAAA,EAEQ;AAAA,EAoBQ,WAA8B;AAC5C,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEO,YAAY;AACjB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEO,qBAAqB,KAAa;AACvC,WAAO,IAAI;AAAA,MACT,IAAI,sBAAsB;AAAA,QACxB,MAAM;AAAA,UACJ,GAAG,KAAK;AAAA,UACR,kBAAkB;AAAA,UAClB,oBAAoB,EAAE,MAAM,SAAS,OAAO,IAAI;AAAA,UAChD,KAAK,KAAK,KAAK,MAAM,GAAG,KAAK,KAAK,GAAG,gBAAgB,GAAG;AAAA,QAC1D;AAAA,QACA,UAAU,MAAM;AACd,gBAAM,cAAc,KAAK,SAAS,EAAE;AACpC,gBAAM,aAAa,YAAY,GAAG;AAClC,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,MACD,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/api/ComposerRuntime.ts"],"sourcesContent":["import { Attachment, PendingAttachment } from \"../types/AttachmentTypes\";\nimport {\n ComposerRuntimeCore,\n ThreadComposerRuntimeCore,\n} from \"../runtimes/core/ComposerRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport {\n AttachmentRuntime,\n AttachmentState,\n EditComposerAttachmentRuntimeImpl,\n ThreadComposerAttachmentRuntimeImpl,\n} from \"./AttachmentRuntime\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ComposerRuntimePath } from \"./RuntimePathTypes\";\nimport { MessageRole } from \"../types/AssistantTypes\";\n\nexport type ThreadComposerRuntimeCoreBinding = SubscribableWithState<\n ThreadComposerRuntimeCore | undefined,\n ComposerRuntimePath & { composerSource: \"thread\" }\n>;\n\nexport type EditComposerRuntimeCoreBinding = SubscribableWithState<\n ComposerRuntimeCore | undefined,\n ComposerRuntimePath & { composerSource: \"edit\" }\n>;\n\nexport type ComposerRuntimeCoreBinding = SubscribableWithState<\n ComposerRuntimeCore | undefined,\n ComposerRuntimePath\n>;\n\ntype BaseComposerState = {\n readonly text: string;\n readonly role: MessageRole;\n readonly attachments: readonly Attachment[];\n\n readonly canCancel: boolean;\n readonly isEditing: boolean;\n readonly isEmpty: boolean;\n};\n\nexport type ThreadComposerState = BaseComposerState & {\n readonly type: \"thread\";\n\n readonly attachments: readonly PendingAttachment[];\n};\n\nexport type EditComposerState = BaseComposerState & {\n readonly type: \"edit\";\n};\n\nexport type ComposerState = ThreadComposerState | EditComposerState;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst getThreadComposerState = (\n runtime: ThreadComposerRuntimeCore | undefined,\n): ThreadComposerState => {\n return Object.freeze({\n type: \"thread\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n text: runtime?.text ?? \"\",\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n role: runtime?.role ?? \"user\",\n\n value: runtime?.text ?? \"\",\n });\n};\n\nconst getEditComposerState = (\n runtime: ComposerRuntimeCore | undefined,\n): EditComposerState => {\n return Object.freeze({\n type: \"edit\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n text: runtime?.text ?? \"\",\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n role: runtime?.role ?? \"user\",\n\n value: runtime?.text ?? \"\",\n });\n};\n\nexport type ComposerRuntime = {\n readonly path: ComposerRuntimePath;\n readonly type: \"edit\" | \"thread\";\n getState(): ComposerState;\n\n setText(text: string): void;\n setValue(text: string): void;\n\n getAttachmentAccept(): string;\n addAttachment(file: File): Promise<void>;\n\n reset(): void;\n send(): void;\n cancel(): void;\n subscribe(callback: () => void): Unsubscribe;\n getAttachmentByIndex(idx: number): AttachmentRuntime;\n};\n\nexport abstract class ComposerRuntimeImpl implements ComposerRuntime {\n public get path() {\n return this._core.path;\n }\n\n public abstract get type(): \"edit\" | \"thread\";\n\n constructor(protected _core: ComposerRuntimeCoreBinding) {}\n\n public abstract getState(): ComposerState;\n\n public setText(text: string) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setText(text);\n }\n\n public setValue(text: string) {\n this.setText(text);\n }\n\n public addAttachment(file: File) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.addAttachment(file);\n }\n\n public reset() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.reset();\n }\n\n public send() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.send();\n }\n\n public cancel() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.cancel();\n }\n\n public setRole(role: MessageRole) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setRole(role);\n }\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n\n public getAttachmentAccept(): string {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.getAttachmentAccept();\n }\n\n public abstract getAttachmentByIndex(idx: number): AttachmentRuntime;\n}\n\nexport type ThreadComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"thread\" };\n readonly type: \"thread\";\n getState(): ThreadComposerState;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"thread-composer\" };\n};\n\nexport class ThreadComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements ThreadComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & {\n composerSource: \"thread\";\n };\n }\n\n public get type() {\n return \"thread\" as const;\n }\n\n private _getState;\n\n constructor(core: ThreadComposerRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getThreadComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public override getState(): ThreadComposerState {\n return this._getState();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new ThreadComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"thread-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: this.path.ref + `${this.path.ref}.attachments[${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: \"thread-composer\",\n } satisfies AttachmentState & { source: \"thread-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n\nexport type EditComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"edit\" };\n readonly type: \"edit\";\n\n getState(): EditComposerState;\n beginEdit(): void;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"edit-composer\" };\n};\n\nexport class EditComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements EditComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & { composerSource: \"edit\" };\n }\n\n public get type() {\n return \"edit\" as const;\n }\n\n private _getState;\n constructor(\n core: EditComposerRuntimeCoreBinding,\n private _beginEdit: () => void,\n ) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getEditComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public override getState(): EditComposerState {\n return this._getState();\n }\n\n public beginEdit() {\n this._beginEdit();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new EditComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"edit-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: this.path.ref + `${this.path.ref}.attachments[${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: \"edit-composer\",\n } satisfies AttachmentState & { source: \"edit-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";AAOA,SAAS,0BAA0B;AACnC;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC,SAAS,mBAAmB;AAyC5B,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AACpC,IAAM,yBAAyB,CAC7B,YACwB;AACxB,SAAO,OAAO,OAAO;AAAA,IACnB,MAAM;AAAA,IAEN,WAAW,SAAS,aAAa;AAAA,IACjC,WAAW,SAAS,aAAa;AAAA,IACjC,SAAS,SAAS,WAAW;AAAA,IAC7B,MAAM,SAAS,QAAQ;AAAA,IACvB,aAAa,SAAS,eAAe;AAAA,IACrC,MAAM,SAAS,QAAQ;AAAA,IAEvB,OAAO,SAAS,QAAQ;AAAA,EAC1B,CAAC;AACH;AAEA,IAAM,uBAAuB,CAC3B,YACsB;AACtB,SAAO,OAAO,OAAO;AAAA,IACnB,MAAM;AAAA,IAEN,WAAW,S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Y,GAAG;AAClC,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,MACD,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
@@ -5,11 +5,11 @@ import { SubscribableWithState } from "./subscribable/Subscribable";
5
5
  import { Unsubscribe } from "../types";
6
6
  import { ContentPartRuntimePath } from "./RuntimePathTypes";
7
7
  export type ContentPartState = (ThreadUserContentPart | ThreadAssistantContentPart) & {
8
- status: ContentPartStatus | ToolCallContentPartStatus;
8
+ readonly status: ContentPartStatus | ToolCallContentPartStatus;
9
9
  };
10
10
  type ContentPartSnapshotBinding = SubscribableWithState<ContentPartState, ContentPartRuntimePath>;
11
11
  export type ContentPartRuntime = {
12
- path: ContentPartRuntimePath;
12
+ readonly path: ContentPartRuntimePath;
13
13
  getState(): ContentPartState;
14
14
  addToolResult(result: any): void;
15
15
  subscribe(callback: () => void): Unsubscribe;
@@ -1 +1 @@
1
- {"version":3,"file":"ContentPartRuntime.d.ts","sourceRoot":"","sources":["../../src/api/ContentPartRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,MAAM,gBAAgB,GAAG,CAC3B,qBAAqB,GACrB,0BAA0B,CAC7B,GAAG;IACF,MAAM,E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BAAiB,GAAG,yBAAyB,CAAC;CAChE,CAAC;AAEF,KAAK,0BAA0B,GAAG,qBAAqB,CACrD,gBAAgB,EAChB,sBAAsB,CACvB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;IAEtC,QAAQ,IAAI,gBAAgB,CAAC;IAC7B,aAAa,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC;IACjC,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;CAC9C,CAAC;AAEF,qBAAa,sBAAuB,YAAW,kBAAkB;IAM7D,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,SAAS;IAPnB,IAAW,IAAI,2BAEd;gBAGS,cAAc,EAAE,0BAA0B,EAC1C,UAAU,EAAE,mBAAmB,EAC/B,SAAS,EAAE,wBAAwB;IAGtC,QAAQ;IAIR,aAAa,CAAC,MAAM,EAAE,GAAG;IAqBzB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI;CAGtC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/ContentPartRuntime.ts"],"sourcesContent":["import {\n ThreadAssistantContentPart,\n ThreadUserContentPart,\n ContentPartStatus,\n ToolCallContentPartStatus,\n} from \"../types/AssistantTypes\";\nimport { ThreadRuntimeCoreBinding } from \"./ThreadRuntime\";\nimport { MessageStateBinding } from \"./MessageRuntime\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { Unsubscribe } from \"../types\";\nimport { ContentPartRuntimePath } from \"./RuntimePathTypes\";\n\nexport type ContentPartState = (\n | ThreadUserContentPart\n | ThreadAssistantContentPart\n) & {\n status: ContentPartStatus | ToolCallContentPartStatus;\n};\n\ntype ContentPartSnapshotBinding = SubscribableWithState<\n ContentPartState,\n ContentPartRuntimePath\n>;\n\nexport type ContentPartRuntime = {\n path: ContentPartRuntimePath;\n\n getState(): ContentPartState;\n addToolResult(result: any): void;\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport class ContentPartRuntimeImpl implements ContentPartRuntime {\n public get path() {\n return this.contentBinding.path;\n }\n\n constructor(\n private contentBinding: ContentPartSnapshotBinding,\n private messageApi: MessageStateBinding,\n private threadApi: ThreadRuntimeCoreBinding,\n ) {}\n\n public getState() {\n return this.contentBinding.getState();\n }\n\n public addToolResult(result: any) {\n const message = this.messageApi.getState();\n if (!message) throw new Error(\"Message is not available\");\n\n const state = this.contentBinding.getState();\n if (!state) throw new Error(\"Content part is not available\");\n\n if (state.type !== \"tool-call\")\n throw new Error(\"Tried to add tool result to non-tool content part\");\n\n const toolName = state.toolName;\n const toolCallId = state.toolCallId;\n\n this.threadApi.getState().addToolResult({\n messageId: message.id,\n toolName,\n toolCallId,\n result,\n });\n }\n\n public subscribe(callback: () => void) {\n return this.contentBinding.subscribe(callback);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCO,IAAM,yBAAN,MAA2D;AAAA,EAKhE,YACU,gBACA,YACA,WACR;AAHQ;AACA;AACA;AAAA,EACP;AAAA,EARH,IAAW,OAAO;AAChB,WAAO,KAAK,eAAe;AAAA,EAC7B;AAAA,EAQO,WAAW;AAChB,WAAO,KAAK,eAAe,SAAS;AAAA,EACtC;AAAA,EAEO,cAAc,QAAa;AAChC,UAAM,UAAU,KAAK,WAAW,SAAS;AACzC,QAAI,CAAC,QAAS,OAAM,IAAI,MAAM,0BAA0B;AAExD,UAAM,QAAQ,KAAK,eAAe,SAAS;AAC3C,QAAI,CAAC,MAAO,OAAM,IAAI,MAAM,+BAA+B;AAE3D,QAAI,MAAM,SAAS;AACjB,YAAM,IAAI,MAAM,mDAAmD;AAErE,UAAM,WAAW,MAAM;AACvB,UAAM,aAAa,MAAM;AAEzB,SAAK,UAAU,SAAS,EAAE,cAAc;AAAA,MACtC,WAAW,QAAQ;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEO,UAAU,UAAsB;AACrC,WAAO,KAAK,eAAe,UAAU,QAAQ;AAAA,EAC/C;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/api/ContentPartRuntime.ts"],"sourcesContent":["import {\n ThreadAssistantContentPart,\n ThreadUserContentPart,\n ContentPartStatus,\n ToolCallContentPartStatus,\n} from \"../types/AssistantTypes\";\nimport { ThreadRuntimeCoreBinding } from \"./ThreadRuntime\";\nimport { MessageStateBinding } from \"./MessageRuntime\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { Unsubscribe } from \"../types\";\nimport { ContentPartRuntimePath } from \"./RuntimePathTypes\";\n\nexport type ContentPartState = (\n | ThreadUserContentPart\n | ThreadAssistantContentPart\n) & {\n readonly status: ContentPartStatus | ToolCallContentPartStatus;\n};\n\ntype ContentPartSnapshotBinding = SubscribableWithState<\n ContentPartState,\n ContentPartRuntimePath\n>;\n\nexport type ContentPartRuntime = {\n readonly path: ContentPartRuntimePath;\n\n getState(): ContentPartState;\n addToolResult(result: any): void;\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport class ContentPartRuntimeImpl implements ContentPartRuntime {\n public get path() {\n return this.contentBinding.path;\n }\n\n constructor(\n private contentBinding: ContentPartSnapshotBinding,\n private messageApi: MessageStateBinding,\n private threadApi: ThreadRuntimeCoreBinding,\n ) {}\n\n public getState() {\n return this.contentBinding.getState();\n }\n\n public addToolResult(result: any) {\n const message = this.messageApi.getState();\n if (!message) throw new Error(\"Message is not available\");\n\n const state = this.contentBinding.getState();\n if (!state) throw new Error(\"Content part is not available\");\n\n if (state.type !== \"tool-call\")\n throw new Error(\"Tried to add tool result to non-tool content part\");\n\n const toolName = state.toolName;\n const toolCallId = state.toolCallId;\n\n this.threadApi.getState().addToolResult({\n messageId: message.id,\n toolName,\n toolCallId,\n result,\n });\n }\n\n public subscribe(callback: () => void) {\n return this.contentBinding.subscribe(callback);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCO,IAAM,yBAAN,MAA2D;AAAA,EAKhE,YACU,gBACA,YACA,WACR;AAHQ;AACA;AACA;AAAA,EACP;AAAA,EARH,IAAW,OAAO;AAChB,WAAO,KAAK,eAAe;AAAA,EAC7B;AAAA,EAQO,WAAW;AAChB,WAAO,KAAK,eAAe,SAAS;AAAA,EACtC;AAAA,EAEO,cAAc,QAAa;AAChC,UAAM,UAAU,KAAK,WAAW,SAAS;AACzC,QAAI,CAAC,QAAS,OAAM,IAAI,MAAM,0BAA0B;AAExD,UAAM,QAAQ,KAAK,eAAe,SAAS;AAC3C,QAAI,CAAC,MAAO,OAAM,IAAI,MAAM,+BAA+B;AAE3D,QAAI,MAAM,SAAS;AACjB,YAAM,IAAI,MAAM,mDAAmD;AAErE,UAAM,WAAW,MAAM;AACvB,UAAM,aAAa,MAAM;AAEzB,SAAK,UAAU,SAAS,EAAE,cAAc;AAAA,MACtC,WAAW,QAAQ;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEO,UAAU,UAAsB;AACrC,WAAO,KAAK,eAAe,UAAU,QAAQ;AAAA,EAC/C;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/ContentPartRuntime.ts"],"sourcesContent":["import {\n ThreadAssistantContentPart,\n ThreadUserContentPart,\n ContentPartStatus,\n ToolCallContentPartStatus,\n} from \"../types/AssistantTypes\";\nimport { ThreadRuntimeCoreBinding } from \"./ThreadRuntime\";\nimport { MessageStateBinding } from \"./MessageRuntime\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { Unsubscribe } from \"../types\";\nimport { ContentPartRuntimePath } from \"./RuntimePathTypes\";\n\nexport type ContentPartState = (\n | ThreadUserContentPart\n | ThreadAssistantContentPart\n) & {\n status: ContentPartStatus | ToolCallContentPartStatus;\n};\n\ntype ContentPartSnapshotBinding = SubscribableWithState<\n ContentPartState,\n ContentPartRuntimePath\n>;\n\nexport type ContentPartRuntime = {\n path: ContentPartRuntimePath;\n\n getState(): ContentPartState;\n addToolResult(result: any): void;\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport class ContentPartRuntimeImpl implements ContentPartRuntime {\n public get path() {\n return this.contentBinding.path;\n }\n\n constructor(\n private contentBinding: ContentPartSnapshotBinding,\n private messageApi: MessageStateBinding,\n private threadApi: ThreadRuntimeCoreBinding,\n ) {}\n\n public getState() {\n return this.contentBinding.getState();\n }\n\n public addToolResult(result: any) {\n const message = this.messageApi.getState();\n if (!message) throw new Error(\"Message is not available\");\n\n const state = this.contentBinding.getState();\n if (!state) throw new Error(\"Content part is not available\");\n\n if (state.type !== \"tool-call\")\n throw new Error(\"Tried to add tool result to non-tool content part\");\n\n const toolName = state.toolName;\n const toolCallId = state.toolCallId;\n\n this.threadApi.getState().addToolResult({\n messageId: message.id,\n toolName,\n toolCallId,\n result,\n });\n }\n\n public subscribe(callback: () => void) {\n return this.contentBinding.subscribe(callback);\n }\n}\n"],"mappings":";AAgCO,IAAM,yBAAN,MAA2D;AAAA,EAKhE,YACU,gBACA,YACA,WACR;AAHQ;AACA;AACA;AAAA,EACP;AAAA,EARH,IAAW,OAAO;AAChB,WAAO,KAAK,eAAe;AAAA,EAC7B;AAAA,EAQO,WAAW;AAChB,WAAO,KAAK,eAAe,SAAS;AAAA,EACtC;AAAA,EAEO,cAAc,QAAa;AAChC,UAAM,UAAU,KAAK,WAAW,SAAS;AACzC,QAAI,CAAC,QAAS,OAAM,IAAI,MAAM,0BAA0B;AAExD,UAAM,QAAQ,KAAK,eAAe,SAAS;AAC3C,QAAI,CAAC,MAAO,OAAM,IAAI,MAAM,+BAA+B;AAE3D,QAAI,MAAM,SAAS;AACjB,YAAM,IAAI,MAAM,mDAAmD;AAErE,UAAM,WAAW,MAAM;AACvB,UAAM,aAAa,MAAM;AAEzB,SAAK,UAAU,SAAS,EAAE,cAAc;AAAA,MACtC,WAAW,QAAQ;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEO,UAAU,UAAsB;AACrC,WAAO,KAAK,eAAe,UAAU,QAAQ;AAAA,EAC/C;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/api/ContentPartRuntime.ts"],"sourcesContent":["import {\n ThreadAssistantContentPart,\n ThreadUserContentPart,\n ContentPartStatus,\n ToolCallContentPartStatus,\n} from \"../types/AssistantTypes\";\nimport { ThreadRuntimeCoreBinding } from \"./ThreadRuntime\";\nimport { MessageStateBinding } from \"./MessageRuntime\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { Unsubscribe } from \"../types\";\nimport { ContentPartRuntimePath } from \"./RuntimePathTypes\";\n\nexport type ContentPartState = (\n | ThreadUserContentPart\n | ThreadAssistantContentPart\n) & {\n readonly status: ContentPartStatus | ToolCallContentPartStatus;\n};\n\ntype ContentPartSnapshotBinding = SubscribableWithState<\n ContentPartState,\n ContentPartRuntimePath\n>;\n\nexport type ContentPartRuntime = {\n readonly path: ContentPartRuntimePath;\n\n getState(): ContentPartState;\n addToolResult(result: any): void;\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport class ContentPartRuntimeImpl implements ContentPartRuntime {\n public get path() {\n return this.contentBinding.path;\n }\n\n constructor(\n private contentBinding: ContentPartSnapshotBinding,\n private messageApi: MessageStateBinding,\n private threadApi: ThreadRuntimeCoreBinding,\n ) {}\n\n public getState() {\n return this.contentBinding.getState();\n }\n\n public addToolResult(result: any) {\n const message = this.messageApi.getState();\n if (!message) throw new Error(\"Message is not available\");\n\n const state = this.contentBinding.getState();\n if (!state) throw new Error(\"Content part is not available\");\n\n if (state.type !== \"tool-call\")\n throw new Error(\"Tried to add tool result to non-tool content part\");\n\n const toolName = state.toolName;\n const toolCallId = state.toolCallId;\n\n this.threadApi.getState().addToolResult({\n messageId: message.id,\n toolName,\n toolCallId,\n result,\n });\n }\n\n public subscribe(callback: () => void) {\n return this.contentBinding.subscribe(callback);\n }\n}\n"],"mappings":";AAgCO,IAAM,yBAAN,MAA2D;AAAA,EAKhE,YACU,gBACA,YACA,WACR;AAHQ;AACA;AACA;AAAA,EACP;AAAA,EARH,IAAW,OAAO;AAChB,WAAO,KAAK,eAAe;AAAA,EAC7B;AAAA,EAQO,WAAW;AAChB,WAAO,KAAK,eAAe,SAAS;AAAA,EACtC;AAAA,EAEO,cAAc,QAAa;AAChC,UAAM,UAAU,KAAK,WAAW,SAAS;AACzC,QAAI,CAAC,QAAS,OAAM,IAAI,MAAM,0BAA0B;AAExD,UAAM,QAAQ,KAAK,eAAe,SAAS;AAC3C,QAAI,CAAC,MAAO,OAAM,IAAI,MAAM,+BAA+B;AAE3D,QAAI,MAAM,SAAS;AACjB,YAAM,IAAI,MAAM,mDAAmD;AAErE,UAAM,WAAW,MAAM;AACvB,UAAM,aAAa,MAAM;AAEzB,SAAK,UAAU,SAAS,EAAE,cAAc;AAAA,MACtC,WAAW,QAAQ;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEO,UAAU,UAAsB;AACrC,WAAO,KAAK,eAAe,UAAU,QAAQ;AAAA,EAC/C;AACF;","names":[]}
@@ -10,15 +10,15 @@ import { SubscribableWithState } from "./subscribable/Subscribable";
10
10
  export declare const toContentPartStatus: (message: ThreadMessage, partIndex: number, part: ThreadUserContentPart | ThreadAssistantContentPart) => ToolCallContentPartStatus;
11
11
  export declare const EMPTY_CONTENT_SYMBOL: unique symbol;
12
12
  export type MessageState = ThreadMessage & {
13
- parentId: string | null;
14
- isLast: boolean;
15
- branchNumber: number;
16
- branchCount: number;
13
+ readonly parentId: string | null;
14
+ readonly isLast: boolean;
15
+ readonly branchNumber: number;
16
+ readonly branchCount: number;
17
17
  /**
18
18
  * @deprecated This API is still under active development and might change without notice.
19
19
  */
20
- speech: SpeechState | undefined;
21
- submittedFeedback: SubmittedFeedback | undefined;
20
+ readonly speech: SpeechState | undefined;
21
+ readonly submittedFeedback: SubmittedFeedback | undefined;
22
22
  };
23
23
  export type MessageStateBinding = SubscribableWithState<MessageState, MessageRuntimePath>;
24
24
  export type MessageRuntime = {
@@ -54,7 +54,7 @@ export declare class MessageRuntimeImpl implements MessageRuntime {
54
54
  private _threadBinding;
55
55
  get path(): MessageRuntimePath;
56
56
  constructor(_core: MessageStateBinding, _threadBinding: ThreadRuntimeCoreBinding);
57
- composer: EditComposerRuntimeImpl;
57
+ readonly composer: EditComposerRuntimeImpl;
58
58
  getState(): MessageState;
59
59
  reload(): void;
60
60
  speak(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"MessageRuntime.d.ts","sourceRoot":"","sources":["../../src/api/MessageRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,EAClB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,0BAA0B,EAC1B,qBAAqB,EACrB,WAAW,EACZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAEL,yBAAyB,EAC1B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EAEjB,4BAA4B,EAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EAEvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAI3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAMpE,eAAO,MAAM,mBAAmB,YACrB,aAAa,aACX,MAAM,QACX,qBAAqB,GAAG,0BAA0B,KACvD,yBAcF,CAAC;AAEF,eAAO,MAAM,oBAAoB,eAA0B,CAAC;AAiC5D,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG;I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AAC;KAC/B,GAAG,IAAI,CAAC;IACT,oBAAoB,IAAI,MAAM,CAAC;IAE/B,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;IAE7C,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAAC;IACvD,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,CAAC;IAEnE,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,GAAG;QAAE,MAAM,EAAE,SAAS,CAAA;KAAE,CAAC;CAC9E,CAAC;AAEF,qBAAa,kBAAmB,YAAW,cAAc;IAMrD,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,cAAc;IANxB,IAAW,IAAI,uBAEd;gBAGS,KAAK,EAAE,mBAAmB,EAC1B,cAAc,EAAE,wBAAwB;IAmBlD,SAAgB,QAAQ,0BAAC;IAElB,QAAQ;IAIR,MAAM;IAQN,KAAK;IAKL,YAAY;IAUZ,cAAc,CAAC,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,UAAU,GAAG,UAAU,CAAA;KAAE;IAQ1D,cAAc,CAAC,EACpB,QAAQ,EACR,QAAQ,GACT,EAAE;QACD,QAAQ,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;QAC3C,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC/B;IAqBM,oBAAoB;IAIpB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI;IAI9B,qBAAqB,CAAC,GAAG,EAAE,MAAM;IAmBjC,0BAA0B,CAAC,UAAU,EAAE,MAAM;IA0B7C,oBAAoB,CAAC,GAAG,EAAE,MAAM;CAuBxC"}
@@ -32,9 +32,9 @@ var import_ContentPartRuntime = require("./ContentPartRuntime.cjs");
32
32
  var import_NestedSubscriptionSubject = require("./subscribable/NestedSubscriptionSubject.cjs");
33
33
  var import_SKIP_UPDATE = require("./subscribable/SKIP_UPDATE.cjs");
34
34
  var import_ShallowMemoizeSubject = require("./subscribable/ShallowMemoizeSubject.cjs");
35
- var COMPLETE_STATUS = {
35
+ var COMPLETE_STATUS = Object.freeze({
36
36
  type: "complete"
37
- };
37
+ });
38
38
  var toContentPartStatus = (message, partIndex, part) => {
39
39
  if (message.role !== "assistant") return COMPLETE_STATUS;
40
40
  if (part.type === "tool-call") {
@@ -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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AA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State,\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,kCAAqC;AACrC,+BAIO;AACP,6BAGO;AACP,gCAIO;AAGP,uCAA0C;AAC1C,yBAA4B;AAC5B,mCAAsC;AAGtC,IAAM,kBAAqC,OAAO,OAAO;AAAA,EACvD,MAAM;AACR,CAAC;AAEM,IAAM,sBAAsB,CACjC,SACA,WACA,SAC8B;AAC9B,MAAI,QAAQ,SAAS,YAAa,QAAO;AAEz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;AAAA,QACA,UAAU,MAAM;AACd,gBAAM,QAAQ,KAAK,MAAM,SAAS;AAClC,gBAAM,MAAM,MAAM,QAAQ;AAAA,YACxB,CAAC,SACC,KAAK,SAAS,eAAe,KAAK,eAAe;AAAA,UACrD;AACA,cAAI,QAAQ,GAAI,QAAO;AACvB,iBAAO,oBAAoB,OAAO,GAAG;AAAA,QACvC;AAAA,QACA,WAAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,MACD,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EAEO,qBAAqB,KAAa;AACvC,WAAO,IAAI;AAAA,MACT,IAAI,mDAAsB;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":[]}
@@ -12,9 +12,9 @@ import {
12
12
  import { NestedSubscriptionSubject } from "./subscribable/NestedSubscriptionSubject.mjs";
13
13
  import { SKIP_UPDATE } from "./subscribable/SKIP_UPDATE.mjs";
14
14
  import { ShallowMemoizeSubject } from "./subscribable/ShallowMemoizeSubject.mjs";
15
- var COMPLETE_STATUS = {
15
+ var COMPLETE_STATUS = Object.freeze({
16
16
  type: "complete"
17
- };
17
+ });
18
18
  var toContentPartStatus = (message, partIndex, part) => {
19
19
  if (message.role !== "assistant") return COMPLETE_STATUS;
20
20
  if (part.type === "tool-call") {