@assistant-ui/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/attachment.d.ts +36 -0
- package/dist/adapters/attachment.d.ts.map +1 -0
- package/dist/adapters/attachment.js +148 -0
- package/dist/adapters/attachment.js.map +1 -0
- package/dist/adapters/feedback.d.ts +10 -0
- package/dist/adapters/feedback.d.ts.map +1 -0
- package/dist/adapters/feedback.js +2 -0
- package/dist/adapters/feedback.js.map +1 -0
- package/dist/adapters/index.d.ts +8 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/speech.d.ts +76 -0
- package/dist/adapters/speech.d.ts.map +1 -0
- package/dist/adapters/speech.js +179 -0
- package/dist/adapters/speech.js.map +1 -0
- package/dist/adapters/suggestion.d.ts +10 -0
- package/dist/adapters/suggestion.d.ts.map +1 -0
- package/dist/adapters/suggestion.js +2 -0
- package/dist/adapters/suggestion.js.map +1 -0
- package/dist/adapters/thread-history.d.ts +43 -0
- package/dist/adapters/thread-history.d.ts.map +1 -0
- package/dist/adapters/thread-history.js +2 -0
- package/dist/adapters/thread-history.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +5 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +7 -0
- package/dist/internal.js.map +1 -0
- package/dist/model-context/frame/host.d.ts +21 -0
- package/dist/model-context/frame/host.d.ts.map +1 -0
- package/dist/model-context/frame/host.js +141 -0
- package/dist/model-context/frame/host.js.map +1 -0
- package/dist/model-context/frame/index.d.ts +5 -0
- package/dist/model-context/frame/index.d.ts.map +1 -0
- package/dist/model-context/frame/index.js +4 -0
- package/dist/model-context/frame/index.js.map +1 -0
- package/dist/model-context/frame/provider.d.ts +18 -0
- package/dist/model-context/frame/provider.d.ts.map +1 -0
- package/dist/model-context/frame/provider.js +133 -0
- package/dist/model-context/frame/provider.js.map +1 -0
- package/dist/model-context/frame/types.d.ts +29 -0
- package/dist/model-context/frame/types.d.ts.map +1 -0
- package/dist/model-context/frame/types.js +2 -0
- package/dist/model-context/frame/types.js.map +1 -0
- package/dist/model-context/index.d.ts +8 -0
- package/dist/model-context/index.d.ts.map +1 -0
- package/dist/model-context/index.js +9 -0
- package/dist/model-context/index.js.map +1 -0
- package/dist/model-context/registry-handles.d.ts +13 -0
- package/dist/model-context/registry-handles.d.ts.map +1 -0
- package/dist/model-context/registry-handles.js +2 -0
- package/dist/model-context/registry-handles.js.map +1 -0
- package/dist/model-context/registry.d.ts +17 -0
- package/dist/model-context/registry.d.ts.map +1 -0
- package/dist/model-context/registry.js +108 -0
- package/dist/model-context/registry.js.map +1 -0
- package/dist/model-context/tool.d.ts +3 -0
- package/dist/model-context/tool.d.ts.map +1 -0
- package/dist/model-context/tool.js +5 -0
- package/dist/model-context/tool.js.map +1 -0
- package/dist/model-context/types.d.ts +37 -0
- package/dist/model-context/types.d.ts.map +1 -0
- package/dist/model-context/types.js +43 -0
- package/dist/model-context/types.js.map +1 -0
- package/dist/runtime/api/assistant-runtime.d.ts +64 -0
- package/dist/runtime/api/assistant-runtime.d.ts.map +1 -0
- package/dist/runtime/api/assistant-runtime.js +46 -0
- package/dist/runtime/api/assistant-runtime.js.map +1 -0
- package/dist/runtime/api/attachment-runtime.d.ts +63 -0
- package/dist/runtime/api/attachment-runtime.d.ts.map +1 -0
- package/dist/runtime/api/attachment-runtime.js +56 -0
- package/dist/runtime/api/attachment-runtime.js.map +1 -0
- package/dist/runtime/api/bindings.d.ts +31 -0
- package/dist/runtime/api/bindings.d.ts.map +1 -0
- package/dist/runtime/api/bindings.js +2 -0
- package/dist/runtime/api/bindings.js.map +1 -0
- package/dist/runtime/api/composer-runtime.d.ts +181 -0
- package/dist/runtime/api/composer-runtime.d.ts.map +1 -0
- package/dist/runtime/api/composer-runtime.js +247 -0
- package/dist/runtime/api/composer-runtime.js.map +1 -0
- package/dist/runtime/api/message-part-runtime.d.ts +31 -0
- package/dist/runtime/api/message-part-runtime.d.ts.map +1 -0
- package/dist/runtime/api/message-part-runtime.js +67 -0
- package/dist/runtime/api/message-part-runtime.js.map +1 -0
- package/dist/runtime/api/message-runtime.d.ts +91 -0
- package/dist/runtime/api/message-runtime.d.ts.map +1 -0
- package/dist/runtime/api/message-runtime.js +199 -0
- package/dist/runtime/api/message-runtime.js.map +1 -0
- package/dist/runtime/api/paths.d.ts +64 -0
- package/dist/runtime/api/paths.d.ts.map +1 -0
- package/dist/runtime/api/paths.js +2 -0
- package/dist/runtime/api/paths.js.map +1 -0
- package/dist/runtime/api/thread-list-item-runtime.d.ts +50 -0
- package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -0
- package/dist/runtime/api/thread-list-item-runtime.js +85 -0
- package/dist/runtime/api/thread-list-item-runtime.js.map +1 -0
- package/dist/runtime/api/thread-list-runtime.d.ts +44 -0
- package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -0
- package/dist/runtime/api/thread-list-runtime.js +136 -0
- package/dist/runtime/api/thread-list-runtime.js.map +1 -0
- package/dist/runtime/api/thread-runtime.d.ts +272 -0
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -0
- package/dist/runtime/api/thread-runtime.js +240 -0
- package/dist/runtime/api/thread-runtime.js.map +1 -0
- package/dist/runtime/base/base-assistant-runtime-core.d.ts +12 -0
- package/dist/runtime/base/base-assistant-runtime-core.d.ts.map +1 -0
- package/dist/runtime/base/base-assistant-runtime-core.js +11 -0
- package/dist/runtime/base/base-assistant-runtime-core.js.map +1 -0
- package/dist/runtime/base/base-composer-runtime-core.d.ts +55 -0
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -0
- package/dist/runtime/base/base-composer-runtime-core.js +320 -0
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -0
- package/dist/runtime/base/base-thread-runtime-core.d.ts +67 -0
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -0
- package/dist/runtime/base/base-thread-runtime-core.js +157 -0
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -0
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +28 -0
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -0
- package/dist/runtime/base/default-edit-composer-runtime-core.js +49 -0
- package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -0
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +24 -0
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -0
- package/dist/runtime/base/default-thread-composer-runtime-core.js +41 -0
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -0
- package/dist/runtime/index.d.ts +20 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +7 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/interfaces/assistant-runtime-core.d.ts +10 -0
- package/dist/runtime/interfaces/assistant-runtime-core.d.ts.map +1 -0
- package/dist/runtime/interfaces/assistant-runtime-core.js +2 -0
- package/dist/runtime/interfaces/assistant-runtime-core.js.map +1 -0
- package/dist/runtime/interfaces/composer-runtime-core.d.ts +38 -0
- package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -0
- package/dist/runtime/interfaces/composer-runtime-core.js +2 -0
- package/dist/runtime/interfaces/composer-runtime-core.js.map +1 -0
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +37 -0
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -0
- package/dist/runtime/interfaces/thread-list-runtime-core.js +2 -0
- package/dist/runtime/interfaces/thread-list-runtime-core.js.map +1 -0
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +97 -0
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -0
- package/dist/runtime/interfaces/thread-runtime-core.js +2 -0
- package/dist/runtime/interfaces/thread-runtime-core.js.map +1 -0
- package/dist/runtime/internal.d.ts +23 -0
- package/dist/runtime/internal.d.ts.map +1 -0
- package/dist/runtime/internal.js +25 -0
- package/dist/runtime/internal.js.map +1 -0
- package/dist/runtime/utils/auto-status.d.ts +5 -0
- package/dist/runtime/utils/auto-status.d.ts.map +1 -0
- package/dist/runtime/utils/auto-status.js +32 -0
- package/dist/runtime/utils/auto-status.js.map +1 -0
- package/dist/runtime/utils/chat-model-adapter.d.ts +40 -0
- package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -0
- package/dist/runtime/utils/chat-model-adapter.js +2 -0
- package/dist/runtime/utils/chat-model-adapter.js.map +1 -0
- package/dist/runtime/utils/external-store-message.d.ts +10 -0
- package/dist/runtime/utils/external-store-message.d.ts.map +1 -0
- package/dist/runtime/utils/external-store-message.js +22 -0
- package/dist/runtime/utils/external-store-message.js.map +1 -0
- package/dist/runtime/utils/message-repository.d.ts +43 -0
- package/dist/runtime/utils/message-repository.d.ts.map +1 -0
- package/dist/runtime/utils/message-repository.js +257 -0
- package/dist/runtime/utils/message-repository.js.map +1 -0
- package/dist/runtime/utils/thread-message-like.d.ts +34 -0
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -0
- package/dist/runtime/utils/thread-message-like.js +129 -0
- package/dist/runtime/utils/thread-message-like.js.map +1 -0
- package/dist/runtimes/assistant-transport/utils.d.ts +11 -0
- package/dist/runtimes/assistant-transport/utils.d.ts.map +1 -0
- package/dist/runtimes/assistant-transport/utils.js +20 -0
- package/dist/runtimes/assistant-transport/utils.js.map +1 -0
- package/dist/runtimes/external-store/external-store-adapter.d.ts +81 -0
- package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -0
- package/dist/runtimes/external-store/external-store-adapter.js +2 -0
- package/dist/runtimes/external-store/external-store-adapter.js.map +1 -0
- package/dist/runtimes/external-store/external-store-runtime-core.d.ts +9 -0
- package/dist/runtimes/external-store/external-store-runtime-core.d.ts.map +1 -0
- package/dist/runtimes/external-store/external-store-runtime-core.js +19 -0
- package/dist/runtimes/external-store/external-store-runtime-core.js.map +1 -0
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +42 -0
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -0
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js +174 -0
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -0
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +47 -0
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -0
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js +260 -0
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -0
- package/dist/runtimes/external-store/index.d.ts +8 -0
- package/dist/runtimes/external-store/index.d.ts.map +1 -0
- package/dist/runtimes/external-store/index.js +5 -0
- package/dist/runtimes/external-store/index.js.map +1 -0
- package/dist/runtimes/external-store/thread-message-converter.d.ts +7 -0
- package/dist/runtimes/external-store/thread-message-converter.d.ts.map +1 -0
- package/dist/runtimes/external-store/thread-message-converter.js +12 -0
- package/dist/runtimes/external-store/thread-message-converter.js.map +1 -0
- package/dist/runtimes/index.d.ts +6 -0
- package/dist/runtimes/index.d.ts.map +1 -0
- package/dist/runtimes/index.js +4 -0
- package/dist/runtimes/index.js.map +1 -0
- package/dist/runtimes/internal.d.ts +18 -0
- package/dist/runtimes/internal.d.ts.map +1 -0
- package/dist/runtimes/internal.js +15 -0
- package/dist/runtimes/internal.js.map +1 -0
- package/dist/runtimes/local/index.d.ts +7 -0
- package/dist/runtimes/local/index.d.ts.map +1 -0
- package/dist/runtimes/local/index.js +5 -0
- package/dist/runtimes/local/index.js.map +1 -0
- package/dist/runtimes/local/local-runtime-core.d.ts +11 -0
- package/dist/runtimes/local/local-runtime-core.d.ts.map +1 -0
- package/dist/runtimes/local/local-runtime-core.js +22 -0
- package/dist/runtimes/local/local-runtime-core.js.map +1 -0
- package/dist/runtimes/local/local-runtime-options.d.ts +23 -0
- package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -0
- package/dist/runtimes/local/local-runtime-options.js +2 -0
- package/dist/runtimes/local/local-runtime-options.js.map +1 -0
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts +46 -0
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts.map +1 -0
- package/dist/runtimes/local/local-thread-list-runtime-core.js +87 -0
- package/dist/runtimes/local/local-thread-list-runtime-core.js.map +1 -0
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +59 -0
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -0
- package/dist/runtimes/local/local-thread-runtime-core.js +423 -0
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -0
- package/dist/runtimes/local/should-continue.d.ts +3 -0
- package/dist/runtimes/local/should-continue.d.ts.map +1 -0
- package/dist/runtimes/local/should-continue.js +14 -0
- package/dist/runtimes/local/should-continue.js.map +1 -0
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts +13 -0
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/adapter/in-memory.js +29 -0
- package/dist/runtimes/remote-thread-list/adapter/in-memory.js.map +1 -0
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts +3 -0
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/empty-thread-core.js +146 -0
- package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -0
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts +23 -0
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/optimistic-state.js +57 -0
- package/dist/runtimes/remote-thread-list/optimistic-state.js.map +1 -0
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +37 -0
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/remote-thread-state.js +62 -0
- package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -0
- package/dist/runtimes/remote-thread-list/types.d.ts +38 -0
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/types.js +2 -0
- package/dist/runtimes/remote-thread-list/types.js.map +1 -0
- package/dist/store/clients/chain-of-thought-client.d.ts +15 -0
- package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -0
- package/dist/store/clients/chain-of-thought-client.js +18 -0
- package/dist/store/clients/chain-of-thought-client.js.map +1 -0
- package/dist/store/clients/index.d.ts +6 -0
- package/dist/store/clients/index.d.ts.map +1 -0
- package/dist/store/clients/index.js +6 -0
- package/dist/store/clients/index.js.map +1 -0
- package/dist/store/clients/model-context-client.d.ts +3 -0
- package/dist/store/clients/model-context-client.d.ts.map +1 -0
- package/dist/store/clients/model-context-client.js +14 -0
- package/dist/store/clients/model-context-client.js.map +1 -0
- package/dist/store/clients/no-op-composer-client.d.ts +7 -0
- package/dist/store/clients/no-op-composer-client.d.ts.map +1 -0
- package/dist/store/clients/no-op-composer-client.js +61 -0
- package/dist/store/clients/no-op-composer-client.js.map +1 -0
- package/dist/store/clients/suggestions.d.ts +11 -0
- package/dist/store/clients/suggestions.d.ts.map +1 -0
- package/dist/store/clients/suggestions.js +37 -0
- package/dist/store/clients/suggestions.js.map +1 -0
- package/dist/store/clients/thread-message-client.d.ts +11 -0
- package/dist/store/clients/thread-message-client.d.ts.map +1 -0
- package/dist/store/clients/thread-message-client.js +112 -0
- package/dist/store/clients/thread-message-client.js.map +1 -0
- package/dist/store/index.d.ts +14 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +14 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/internal.d.ts +11 -0
- package/dist/store/internal.d.ts.map +1 -0
- package/dist/store/internal.js +12 -0
- package/dist/store/internal.js.map +1 -0
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts +8 -0
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -0
- package/dist/store/runtime-clients/attachment-runtime-client.js +11 -0
- package/dist/store/runtime-clients/attachment-runtime-client.js.map +1 -0
- package/dist/store/runtime-clients/composer-runtime-client.d.ts +13 -0
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -0
- package/dist/store/runtime-clients/composer-runtime-client.js +83 -0
- package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -0
- package/dist/store/runtime-clients/index.d.ts +8 -0
- package/dist/store/runtime-clients/index.d.ts.map +1 -0
- package/dist/store/runtime-clients/index.js +8 -0
- package/dist/store/runtime-clients/index.js.map +1 -0
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts +8 -0
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -0
- package/dist/store/runtime-clients/message-part-runtime-client.js +12 -0
- package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -0
- package/dist/store/runtime-clients/message-runtime-client.d.ts +11 -0
- package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -0
- package/dist/store/runtime-clients/message-runtime-client.js +78 -0
- package/dist/store/runtime-clients/message-runtime-client.js.map +1 -0
- package/dist/store/runtime-clients/tap-subscribable.d.ts +3 -0
- package/dist/store/runtime-clients/tap-subscribable.d.ts.map +1 -0
- package/dist/store/runtime-clients/tap-subscribable.js +12 -0
- package/dist/store/runtime-clients/tap-subscribable.js.map +1 -0
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +8 -0
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -0
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js +41 -0
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js.map +1 -0
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +10 -0
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -0
- package/dist/store/runtime-clients/thread-list-runtime-client.js +54 -0
- package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -0
- package/dist/store/runtime-clients/thread-runtime-client.d.ts +8 -0
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -0
- package/dist/store/runtime-clients/thread-runtime-client.js +91 -0
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -0
- package/dist/store/scopes/attachment.d.ts +23 -0
- package/dist/store/scopes/attachment.d.ts.map +1 -0
- package/dist/store/scopes/attachment.js +2 -0
- package/dist/store/scopes/attachment.js.map +1 -0
- package/dist/store/scopes/chain-of-thought.d.ts +39 -0
- package/dist/store/scopes/chain-of-thought.d.ts.map +1 -0
- package/dist/store/scopes/chain-of-thought.js +2 -0
- package/dist/store/scopes/chain-of-thought.js.map +1 -0
- package/dist/store/scopes/composer.d.ts +75 -0
- package/dist/store/scopes/composer.d.ts.map +1 -0
- package/dist/store/scopes/composer.js +2 -0
- package/dist/store/scopes/composer.js.map +1 -0
- package/dist/store/scopes/index.d.ts +12 -0
- package/dist/store/scopes/index.d.ts.map +1 -0
- package/dist/store/scopes/index.js +2 -0
- package/dist/store/scopes/index.js.map +1 -0
- package/dist/store/scopes/message.d.ts +86 -0
- package/dist/store/scopes/message.d.ts.map +1 -0
- package/dist/store/scopes/message.js +2 -0
- package/dist/store/scopes/message.js.map +1 -0
- package/dist/store/scopes/model-context.d.ts +11 -0
- package/dist/store/scopes/model-context.d.ts.map +1 -0
- package/dist/store/scopes/model-context.js +2 -0
- package/dist/store/scopes/model-context.js.map +1 -0
- package/dist/store/scopes/part.d.ts +44 -0
- package/dist/store/scopes/part.d.ts.map +1 -0
- package/dist/store/scopes/part.js +2 -0
- package/dist/store/scopes/part.js.map +1 -0
- package/dist/store/scopes/suggestion.d.ts +19 -0
- package/dist/store/scopes/suggestion.d.ts.map +1 -0
- package/dist/store/scopes/suggestion.js +2 -0
- package/dist/store/scopes/suggestion.js.map +1 -0
- package/dist/store/scopes/suggestions.d.ts +19 -0
- package/dist/store/scopes/suggestions.d.ts.map +1 -0
- package/dist/store/scopes/suggestions.js +2 -0
- package/dist/store/scopes/suggestions.js.map +1 -0
- package/dist/store/scopes/thread-list-item.d.ts +50 -0
- package/dist/store/scopes/thread-list-item.d.ts.map +1 -0
- package/dist/store/scopes/thread-list-item.js +2 -0
- package/dist/store/scopes/thread-list-item.js.map +1 -0
- package/dist/store/scopes/thread.d.ts +135 -0
- package/dist/store/scopes/thread.d.ts.map +1 -0
- package/dist/store/scopes/thread.js +2 -0
- package/dist/store/scopes/thread.js.map +1 -0
- package/dist/store/scopes/threads.d.ts +29 -0
- package/dist/store/scopes/threads.d.ts.map +1 -0
- package/dist/store/scopes/threads.js +2 -0
- package/dist/store/scopes/threads.js.map +1 -0
- package/dist/store/types/client.d.ts +137 -0
- package/dist/store/types/client.d.ts.map +1 -0
- package/dist/store/types/client.js +2 -0
- package/dist/store/types/client.js.map +1 -0
- package/dist/store/types/events.d.ts +33 -0
- package/dist/store/types/events.d.ts.map +1 -0
- package/dist/store/types/events.js +8 -0
- package/dist/store/types/events.js.map +1 -0
- package/dist/store/types/index.d.ts +3 -0
- package/dist/store/types/index.d.ts.map +1 -0
- package/dist/store/types/index.js +2 -0
- package/dist/store/types/index.js.map +1 -0
- package/dist/store/utils/attach-transform-scopes.d.ts +11 -0
- package/dist/store/utils/attach-transform-scopes.d.ts.map +1 -0
- package/dist/store/utils/attach-transform-scopes.js +12 -0
- package/dist/store/utils/attach-transform-scopes.js.map +1 -0
- package/dist/store/utils/base-proxy-handler.d.ts +23 -0
- package/dist/store/utils/base-proxy-handler.d.ts.map +1 -0
- package/dist/store/utils/base-proxy-handler.js +46 -0
- package/dist/store/utils/base-proxy-handler.js.map +1 -0
- package/dist/store/utils/derived.d.ts +34 -0
- package/dist/store/utils/derived.d.ts.map +1 -0
- package/dist/store/utils/derived.js +24 -0
- package/dist/store/utils/derived.js.map +1 -0
- package/dist/store/utils/index.d.ts +7 -0
- package/dist/store/utils/index.d.ts.map +1 -0
- package/dist/store/utils/index.js +7 -0
- package/dist/store/utils/index.js.map +1 -0
- package/dist/store/utils/notification-manager.d.ts +11 -0
- package/dist/store/utils/notification-manager.d.ts.map +1 -0
- package/dist/store/utils/notification-manager.js +84 -0
- package/dist/store/utils/notification-manager.js.map +1 -0
- package/dist/store/utils/proxied-assistant-state.d.ts +8 -0
- package/dist/store/utils/proxied-assistant-state.d.ts.map +1 -0
- package/dist/store/utils/proxied-assistant-state.js +33 -0
- package/dist/store/utils/proxied-assistant-state.js.map +1 -0
- package/dist/store/utils/split-clients.d.ts +10 -0
- package/dist/store/utils/split-clients.d.ts.map +1 -0
- package/dist/store/utils/split-clients.js +53 -0
- package/dist/store/utils/split-clients.js.map +1 -0
- package/dist/store/utils/tap-assistant-context.d.ts +19 -0
- package/dist/store/utils/tap-assistant-context.d.ts.map +1 -0
- package/dist/store/utils/tap-assistant-context.js +23 -0
- package/dist/store/utils/tap-assistant-context.js.map +1 -0
- package/dist/store/utils/tap-client-list.d.ts +28 -0
- package/dist/store/utils/tap-client-list.d.ts.map +1 -0
- package/dist/store/utils/tap-client-list.js +68 -0
- package/dist/store/utils/tap-client-list.js.map +1 -0
- package/dist/store/utils/tap-client-lookup.d.ts +15 -0
- package/dist/store/utils/tap-client-lookup.d.ts.map +1 -0
- package/dist/store/utils/tap-client-lookup.js +42 -0
- package/dist/store/utils/tap-client-lookup.js.map +1 -0
- package/dist/store/utils/tap-client-resource.d.ts +13 -0
- package/dist/store/utils/tap-client-resource.d.ts.map +1 -0
- package/dist/store/utils/tap-client-resource.js +114 -0
- package/dist/store/utils/tap-client-resource.js.map +1 -0
- package/dist/store/utils/tap-client-stack-context.d.ts +23 -0
- package/dist/store/utils/tap-client-stack-context.d.ts.map +1 -0
- package/dist/store/utils/tap-client-stack-context.js +28 -0
- package/dist/store/utils/tap-client-stack-context.js.map +1 -0
- package/dist/store/utils/wrapper-resource.d.ts +3 -0
- package/dist/store/utils/wrapper-resource.d.ts.map +1 -0
- package/dist/store/utils/wrapper-resource.js +11 -0
- package/dist/store/utils/wrapper-resource.js.map +1 -0
- package/dist/subscribable/index.d.ts +3 -0
- package/dist/subscribable/index.d.ts.map +1 -0
- package/dist/subscribable/index.js +8 -0
- package/dist/subscribable/index.js.map +1 -0
- package/dist/subscribable/subscribable.d.ts +68 -0
- package/dist/subscribable/subscribable.d.ts.map +1 -0
- package/dist/subscribable/subscribable.js +237 -0
- package/dist/subscribable/subscribable.js.map +1 -0
- package/dist/types/attachment.d.ts +35 -0
- package/dist/types/attachment.d.ts.map +1 -0
- package/dist/types/attachment.js +2 -0
- package/dist/types/attachment.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/message.d.ts +179 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/message.js +2 -0
- package/dist/types/message.js.map +1 -0
- package/dist/types/quote.d.ts +5 -0
- package/dist/types/quote.d.ts.map +1 -0
- package/dist/types/quote.js +2 -0
- package/dist/types/quote.js.map +1 -0
- package/dist/types/unsubscribe.d.ts +2 -0
- package/dist/types/unsubscribe.d.ts.map +1 -0
- package/dist/types/unsubscribe.js +2 -0
- package/dist/types/unsubscribe.js.map +1 -0
- package/dist/utils/composite-context-provider.d.ts +10 -0
- package/dist/utils/composite-context-provider.d.ts.map +1 -0
- package/dist/utils/composite-context-provider.js +29 -0
- package/dist/utils/composite-context-provider.js.map +1 -0
- package/dist/utils/id.d.ts +6 -0
- package/dist/utils/id.d.ts.map +1 -0
- package/dist/utils/id.js +9 -0
- package/dist/utils/id.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/text.d.ts +3 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +5 -0
- package/dist/utils/text.js.map +1 -0
- package/package.json +85 -0
- package/src/adapters/attachment.ts +209 -0
- package/src/adapters/feedback.ts +10 -0
- package/src/adapters/index.ts +30 -0
- package/src/adapters/speech.ts +338 -0
- package/src/adapters/suggestion.ts +14 -0
- package/src/adapters/thread-history.ts +72 -0
- package/src/index.ts +7 -0
- package/src/internal.ts +7 -0
- package/src/model-context/frame/host.ts +195 -0
- package/src/model-context/frame/index.ts +10 -0
- package/src/model-context/frame/provider.ts +193 -0
- package/src/model-context/frame/types.ts +40 -0
- package/src/model-context/index.ts +35 -0
- package/src/model-context/registry-handles.ts +18 -0
- package/src/model-context/registry.ts +159 -0
- package/src/model-context/tool.ts +9 -0
- package/src/model-context/types.ts +104 -0
- package/src/runtime/api/assistant-runtime.ts +115 -0
- package/src/runtime/api/attachment-runtime.ts +119 -0
- package/src/runtime/api/bindings.ts +49 -0
- package/src/runtime/api/composer-runtime.ts +505 -0
- package/src/runtime/api/message-part-runtime.ts +108 -0
- package/src/runtime/api/message-runtime.ts +335 -0
- package/src/runtime/api/paths.ts +61 -0
- package/src/runtime/api/thread-list-item-runtime.ts +145 -0
- package/src/runtime/api/thread-list-runtime.ts +227 -0
- package/src/runtime/api/thread-runtime.ts +568 -0
- package/src/runtime/base/base-assistant-runtime-core.ts +20 -0
- package/src/runtime/base/base-composer-runtime-core.ts +418 -0
- package/src/runtime/base/base-thread-runtime-core.ts +234 -0
- package/src/runtime/base/default-edit-composer-runtime-core.ts +71 -0
- package/src/runtime/base/default-thread-composer-runtime-core.ts +65 -0
- package/src/runtime/index.ts +108 -0
- package/src/runtime/interfaces/assistant-runtime-core.ts +12 -0
- package/src/runtime/interfaces/composer-runtime-core.ts +64 -0
- package/src/runtime/interfaces/thread-list-runtime-core.ts +49 -0
- package/src/runtime/interfaces/thread-runtime-core.ts +142 -0
- package/src/runtime/internal.ts +64 -0
- package/src/runtime/utils/auto-status.ts +67 -0
- package/src/runtime/utils/chat-model-adapter.ts +66 -0
- package/src/runtime/utils/external-store-message.ts +37 -0
- package/src/runtime/utils/message-repository.ts +390 -0
- package/src/runtime/utils/thread-message-like.ts +225 -0
- package/src/runtimes/assistant-transport/utils.ts +37 -0
- package/src/runtimes/external-store/external-store-adapter.ts +111 -0
- package/src/runtimes/external-store/external-store-runtime-core.ts +26 -0
- package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +235 -0
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +368 -0
- package/src/runtimes/external-store/index.ts +15 -0
- package/src/runtimes/external-store/thread-message-converter.ts +23 -0
- package/src/runtimes/index.ts +28 -0
- package/src/runtimes/internal.ts +36 -0
- package/src/runtimes/local/index.ts +6 -0
- package/src/runtimes/local/local-runtime-core.ts +32 -0
- package/src/runtimes/local/local-runtime-options.ts +27 -0
- package/src/runtimes/local/local-thread-list-runtime-core.ts +116 -0
- package/src/runtimes/local/local-thread-runtime-core.ts +534 -0
- package/src/runtimes/local/should-continue.ts +26 -0
- package/src/runtimes/remote-thread-list/adapter/in-memory.ts +43 -0
- package/src/runtimes/remote-thread-list/empty-thread-core.ts +200 -0
- package/src/runtimes/remote-thread-list/optimistic-state.ts +89 -0
- package/src/runtimes/remote-thread-list/remote-thread-state.ts +123 -0
- package/src/runtimes/remote-thread-list/types.ts +48 -0
- package/src/store/clients/chain-of-thought-client.ts +40 -0
- package/src/store/clients/index.ts +8 -0
- package/src/store/clients/model-context-client.ts +20 -0
- package/src/store/clients/no-op-composer-client.ts +66 -0
- package/src/store/clients/suggestions.ts +69 -0
- package/src/store/clients/thread-message-client.ts +170 -0
- package/src/store/index.ts +44 -0
- package/src/store/internal.ts +32 -0
- package/src/store/runtime-clients/attachment-runtime-client.ts +16 -0
- package/src/store/runtime-clients/composer-runtime-client.ts +131 -0
- package/src/store/runtime-clients/index.ts +7 -0
- package/src/store/runtime-clients/message-part-runtime-client.ts +17 -0
- package/src/store/runtime-clients/message-runtime-client.ts +141 -0
- package/src/store/runtime-clients/tap-subscribable.ts +16 -0
- package/src/store/runtime-clients/thread-list-item-runtime-client.ts +53 -0
- package/src/store/runtime-clients/thread-list-runtime-client.ts +86 -0
- package/src/store/runtime-clients/thread-runtime-client.ts +141 -0
- package/src/store/scopes/attachment.ts +20 -0
- package/src/store/scopes/chain-of-thought.ts +38 -0
- package/src/store/scopes/composer.ts +80 -0
- package/src/store/scopes/index.ts +68 -0
- package/src/store/scopes/message.ts +75 -0
- package/src/store/scopes/model-context.ts +13 -0
- package/src/store/scopes/part.ts +47 -0
- package/src/store/scopes/suggestion.ts +19 -0
- package/src/store/scopes/suggestions.ts +20 -0
- package/src/store/scopes/thread-list-item.ts +44 -0
- package/src/store/scopes/thread.ts +135 -0
- package/src/store/scopes/threads.ts +34 -0
- package/src/store/types/client.ts +203 -0
- package/src/store/types/events.ts +77 -0
- package/src/store/types/index.ts +23 -0
- package/src/store/utils/attach-transform-scopes.ts +38 -0
- package/src/store/utils/base-proxy-handler.ts +50 -0
- package/src/store/utils/derived.ts +46 -0
- package/src/store/utils/index.ts +28 -0
- package/src/store/utils/notification-manager.ts +114 -0
- package/src/store/utils/proxied-assistant-state.ts +55 -0
- package/src/store/utils/split-clients.ts +82 -0
- package/src/store/utils/tap-assistant-context.ts +58 -0
- package/src/store/utils/tap-client-list.ts +121 -0
- package/src/store/utils/tap-client-lookup.ts +79 -0
- package/src/store/utils/tap-client-resource.ts +187 -0
- package/src/store/utils/tap-client-stack-context.ts +51 -0
- package/src/store/utils/wrapper-resource.ts +17 -0
- package/src/subscribable/index.ts +21 -0
- package/src/subscribable/subscribable.ts +317 -0
- package/src/tests/BaseSubscribable.test.ts +54 -0
- package/src/tests/MessageRepository.test.ts +607 -0
- package/src/tests/OptimisticState-delete-crash.test.ts +206 -0
- package/src/types/attachment.ts +45 -0
- package/src/types/index.ts +39 -0
- package/src/types/message.ts +248 -0
- package/src/types/quote.ts +4 -0
- package/src/types/unsubscribe.ts +1 -0
- package/src/utils/composite-context-provider.ts +36 -0
- package/src/utils/id.ts +14 -0
- package/src/utils/index.ts +14 -0
- package/src/utils/text.ts +11 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { resource } from "@assistant-ui/tap";
|
|
2
|
+
import type { ClientStack } from "./tap-client-stack-context";
|
|
3
|
+
import type {
|
|
4
|
+
AssistantEventName,
|
|
5
|
+
AssistantEventPayload,
|
|
6
|
+
} from "../types/events";
|
|
7
|
+
import { Unsubscribe } from "../types/client";
|
|
8
|
+
import { tapConst } from "@assistant-ui/tap";
|
|
9
|
+
|
|
10
|
+
type InternalCallback = (payload: unknown, clientStack: ClientStack) => void;
|
|
11
|
+
|
|
12
|
+
export type NotificationManager = {
|
|
13
|
+
on<TEvent extends AssistantEventName>(
|
|
14
|
+
event: TEvent,
|
|
15
|
+
callback: (
|
|
16
|
+
payload: AssistantEventPayload[TEvent],
|
|
17
|
+
clientStack: ClientStack,
|
|
18
|
+
) => void,
|
|
19
|
+
): Unsubscribe;
|
|
20
|
+
emit<TEvent extends Exclude<AssistantEventName, "*">>(
|
|
21
|
+
event: TEvent,
|
|
22
|
+
payload: AssistantEventPayload[TEvent],
|
|
23
|
+
clientStack: ClientStack,
|
|
24
|
+
): void;
|
|
25
|
+
subscribe(callback: () => void): Unsubscribe;
|
|
26
|
+
notifySubscribers(): void;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const NotificationManager = resource((): NotificationManager => {
|
|
30
|
+
return tapConst(() => {
|
|
31
|
+
const listeners = new Map<string, Set<InternalCallback>>();
|
|
32
|
+
const wildcardListeners = new Set<InternalCallback>();
|
|
33
|
+
const subscribers = new Set<() => void>();
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
on(event, callback) {
|
|
37
|
+
const cb = callback as InternalCallback;
|
|
38
|
+
if (event === "*") {
|
|
39
|
+
wildcardListeners.add(cb);
|
|
40
|
+
return () => wildcardListeners.delete(cb);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let set = listeners.get(event);
|
|
44
|
+
if (!set) {
|
|
45
|
+
set = new Set();
|
|
46
|
+
listeners.set(event, set);
|
|
47
|
+
}
|
|
48
|
+
set.add(cb);
|
|
49
|
+
|
|
50
|
+
return () => {
|
|
51
|
+
set!.delete(cb);
|
|
52
|
+
if (set!.size === 0) listeners.delete(event);
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
emit(event, payload, clientStack) {
|
|
57
|
+
const eventListeners = listeners.get(event);
|
|
58
|
+
if (!eventListeners && wildcardListeners.size === 0) return;
|
|
59
|
+
|
|
60
|
+
queueMicrotask(() => {
|
|
61
|
+
const errors = [];
|
|
62
|
+
if (eventListeners) {
|
|
63
|
+
for (const cb of eventListeners) {
|
|
64
|
+
try {
|
|
65
|
+
cb(payload, clientStack);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
errors.push(e);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (wildcardListeners.size > 0) {
|
|
72
|
+
const wrapped = { event, payload };
|
|
73
|
+
for (const cb of wildcardListeners) {
|
|
74
|
+
try {
|
|
75
|
+
cb(wrapped, clientStack);
|
|
76
|
+
} catch (e) {
|
|
77
|
+
errors.push(e);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (errors.length > 0) {
|
|
83
|
+
if (errors.length === 1) {
|
|
84
|
+
throw errors[0];
|
|
85
|
+
} else {
|
|
86
|
+
for (const error of errors) {
|
|
87
|
+
console.error(error);
|
|
88
|
+
}
|
|
89
|
+
throw new AggregateError(
|
|
90
|
+
errors,
|
|
91
|
+
"Errors occurred during event emission",
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
subscribe(callback) {
|
|
99
|
+
subscribers.add(callback);
|
|
100
|
+
return () => subscribers.delete(callback);
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
notifySubscribers() {
|
|
104
|
+
for (const cb of subscribers) {
|
|
105
|
+
try {
|
|
106
|
+
cb();
|
|
107
|
+
} catch (e) {
|
|
108
|
+
console.error("NotificationManager: subscriber callback error", e);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}, []);
|
|
114
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getClientState } from "./tap-client-resource";
|
|
2
|
+
import type { AssistantClient, AssistantState } from "../types/client";
|
|
3
|
+
import {
|
|
4
|
+
BaseProxyHandler,
|
|
5
|
+
handleIntrospectionProp,
|
|
6
|
+
} from "./base-proxy-handler";
|
|
7
|
+
|
|
8
|
+
export const PROXIED_ASSISTANT_STATE_SYMBOL = Symbol(
|
|
9
|
+
"assistant-ui.store.proxiedAssistantState",
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const isIgnoredKey = (key: string | symbol): key is "on" | "subscribe" => {
|
|
13
|
+
return key === "on" || key === "subscribe" || typeof key === "symbol";
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Proxied state that lazily accesses scope states
|
|
18
|
+
*/
|
|
19
|
+
export const createProxiedAssistantState = (
|
|
20
|
+
client: AssistantClient,
|
|
21
|
+
): AssistantState => {
|
|
22
|
+
class ProxiedAssistantStateProxyHandler
|
|
23
|
+
extends BaseProxyHandler
|
|
24
|
+
implements ProxyHandler<AssistantState>
|
|
25
|
+
{
|
|
26
|
+
get(_: unknown, prop: string | symbol) {
|
|
27
|
+
const introspection = handleIntrospectionProp(prop, "AssistantState");
|
|
28
|
+
if (introspection !== false) return introspection;
|
|
29
|
+
const scope = prop as keyof AssistantClient;
|
|
30
|
+
if (isIgnoredKey(scope)) return undefined;
|
|
31
|
+
return getClientState(client[scope]());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
ownKeys(): ArrayLike<string | symbol> {
|
|
35
|
+
return Object.keys(client).filter((key) => !isIgnoredKey(key));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
has(_: unknown, prop: string | symbol): boolean {
|
|
39
|
+
return !isIgnoredKey(prop) && prop in client;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return new Proxy<AssistantState>(
|
|
44
|
+
{} as AssistantState,
|
|
45
|
+
new ProxiedAssistantStateProxyHandler(),
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const getProxiedAssistantState = (
|
|
50
|
+
client: AssistantClient,
|
|
51
|
+
): AssistantState => {
|
|
52
|
+
return (
|
|
53
|
+
client as unknown as { [PROXIED_ASSISTANT_STATE_SYMBOL]: AssistantState }
|
|
54
|
+
)[PROXIED_ASSISTANT_STATE_SYMBOL];
|
|
55
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Derived, DerivedElement } from "./derived";
|
|
2
|
+
import type {
|
|
3
|
+
AssistantClient,
|
|
4
|
+
ClientElement,
|
|
5
|
+
ClientNames,
|
|
6
|
+
} from "../types/client";
|
|
7
|
+
import {
|
|
8
|
+
getTransformScopes,
|
|
9
|
+
type ScopesConfig,
|
|
10
|
+
} from "./attach-transform-scopes";
|
|
11
|
+
import { tapMemo } from "@assistant-ui/tap";
|
|
12
|
+
|
|
13
|
+
export type RootClients = Partial<
|
|
14
|
+
Record<ClientNames, ClientElement<ClientNames>>
|
|
15
|
+
>;
|
|
16
|
+
export type DerivedClients = Partial<
|
|
17
|
+
Record<ClientNames, DerivedElement<ClientNames>>
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Splits a clients object into root clients and derived clients,
|
|
22
|
+
* applying transformScopes from root client elements.
|
|
23
|
+
*/
|
|
24
|
+
function splitClients(clients: ScopesConfig, baseClient: AssistantClient) {
|
|
25
|
+
// 1. Collect transforms from root elements and run them iteratively
|
|
26
|
+
let scopes = { ...clients } as Record<
|
|
27
|
+
string,
|
|
28
|
+
ClientElement<ClientNames> | DerivedElement<ClientNames>
|
|
29
|
+
>;
|
|
30
|
+
const visited = new Set<(...args: any[]) => any>();
|
|
31
|
+
|
|
32
|
+
let changed = true;
|
|
33
|
+
while (changed) {
|
|
34
|
+
changed = false;
|
|
35
|
+
for (const clientElement of Object.values(scopes)) {
|
|
36
|
+
if (clientElement.type === (Derived as unknown)) continue;
|
|
37
|
+
if (visited.has(clientElement.type)) continue;
|
|
38
|
+
visited.add(clientElement.type);
|
|
39
|
+
|
|
40
|
+
const transform = getTransformScopes(clientElement.type);
|
|
41
|
+
if (transform) {
|
|
42
|
+
scopes = transform(scopes, baseClient) as typeof scopes;
|
|
43
|
+
changed = true;
|
|
44
|
+
break; // restart iteration since scopes may have new root elements
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// 2. Split result into root/derived
|
|
50
|
+
const rootClients: RootClients = {};
|
|
51
|
+
const derivedClients: DerivedClients = {};
|
|
52
|
+
|
|
53
|
+
for (const [key, clientElement] of Object.entries(scopes) as [
|
|
54
|
+
ClientNames,
|
|
55
|
+
ClientElement<ClientNames> | DerivedElement<ClientNames>,
|
|
56
|
+
][]) {
|
|
57
|
+
if (clientElement.type === (Derived as unknown)) {
|
|
58
|
+
derivedClients[key] = clientElement as DerivedElement<ClientNames>;
|
|
59
|
+
} else {
|
|
60
|
+
rootClients[key] = clientElement as ClientElement<ClientNames>;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return { rootClients, derivedClients };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const tapShallowMemoObject = <T extends object>(object: T) => {
|
|
68
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: shallow memo
|
|
69
|
+
return tapMemo(() => object, [...Object.entries(object).flat()]);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const tapSplitClients = (
|
|
73
|
+
clients: ScopesConfig,
|
|
74
|
+
baseClient: AssistantClient,
|
|
75
|
+
) => {
|
|
76
|
+
const { rootClients, derivedClients } = splitClients(clients, baseClient);
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
rootClients: tapShallowMemoObject(rootClients),
|
|
80
|
+
derivedClients: tapShallowMemoObject(derivedClients),
|
|
81
|
+
};
|
|
82
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createResourceContext,
|
|
3
|
+
tap,
|
|
4
|
+
withContextProvider,
|
|
5
|
+
tapEffectEvent,
|
|
6
|
+
} from "@assistant-ui/tap";
|
|
7
|
+
import type {
|
|
8
|
+
AssistantEventName,
|
|
9
|
+
AssistantEventPayload,
|
|
10
|
+
} from "../types/events";
|
|
11
|
+
import type { AssistantClient } from "../types/client";
|
|
12
|
+
import { tapClientStack, type ClientStack } from "./tap-client-stack-context";
|
|
13
|
+
|
|
14
|
+
type EmitFn = <TEvent extends Exclude<AssistantEventName, "*">>(
|
|
15
|
+
event: TEvent,
|
|
16
|
+
payload: AssistantEventPayload[TEvent],
|
|
17
|
+
clientStack: ClientStack,
|
|
18
|
+
) => void;
|
|
19
|
+
|
|
20
|
+
export type AssistantTapContextValue = {
|
|
21
|
+
clientRef: { parent: AssistantClient; current: AssistantClient | null };
|
|
22
|
+
emit: EmitFn;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const AssistantTapContext =
|
|
26
|
+
createResourceContext<AssistantTapContextValue | null>(null);
|
|
27
|
+
|
|
28
|
+
export const withAssistantTapContextProvider = <TResult>(
|
|
29
|
+
value: AssistantTapContextValue,
|
|
30
|
+
fn: () => TResult,
|
|
31
|
+
) => {
|
|
32
|
+
return withContextProvider(AssistantTapContext, value, fn);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const tapAssistantTapContext = () => {
|
|
36
|
+
const ctx = tap(AssistantTapContext);
|
|
37
|
+
if (!ctx) throw new Error("AssistantTapContext is not available");
|
|
38
|
+
|
|
39
|
+
return ctx;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const tapAssistantClientRef = () => {
|
|
43
|
+
return tapAssistantTapContext().clientRef;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const tapAssistantEmit = () => {
|
|
47
|
+
const { emit } = tapAssistantTapContext();
|
|
48
|
+
const clientStack = tapClientStack();
|
|
49
|
+
|
|
50
|
+
return tapEffectEvent(
|
|
51
|
+
<TEvent extends Exclude<AssistantEventName, "*">>(
|
|
52
|
+
event: TEvent,
|
|
53
|
+
payload: AssistantEventPayload[TEvent],
|
|
54
|
+
) => {
|
|
55
|
+
emit(event, payload, clientStack);
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { tapConst, tapState, withKey } from "@assistant-ui/tap";
|
|
2
|
+
import type { ContravariantResource } from "@assistant-ui/tap";
|
|
3
|
+
import { tapClientLookup } from "./tap-client-lookup";
|
|
4
|
+
import type { ClientMethods } from "../types/client";
|
|
5
|
+
|
|
6
|
+
type InferClientState<TMethods> = TMethods extends {
|
|
7
|
+
getState: () => infer S;
|
|
8
|
+
}
|
|
9
|
+
? S
|
|
10
|
+
: unknown;
|
|
11
|
+
|
|
12
|
+
type DataHandle<TData> = { data: TData | undefined; hasData: boolean };
|
|
13
|
+
|
|
14
|
+
const createProps = <TData>(
|
|
15
|
+
key: string,
|
|
16
|
+
data: DataHandle<TData>,
|
|
17
|
+
remove: () => void,
|
|
18
|
+
): tapClientList.ResourceProps<TData> => {
|
|
19
|
+
return {
|
|
20
|
+
key,
|
|
21
|
+
getInitialData: () => {
|
|
22
|
+
if (!data.hasData) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
"getInitialData may only be called during initial render",
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
return data.data!;
|
|
28
|
+
},
|
|
29
|
+
remove,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const tapClientList = <TData, TMethods extends ClientMethods>(
|
|
34
|
+
props: tapClientList.Props<TData, TMethods>,
|
|
35
|
+
): {
|
|
36
|
+
state: InferClientState<TMethods>[];
|
|
37
|
+
get: (lookup: { index: number } | { key: string }) => TMethods;
|
|
38
|
+
add: (initialData: TData) => void;
|
|
39
|
+
} => {
|
|
40
|
+
const { initialValues, getKey, resource: Resource } = props;
|
|
41
|
+
|
|
42
|
+
type Props = tapClientList.ResourceProps<TData>;
|
|
43
|
+
|
|
44
|
+
const initialDataHandles: DataHandle<TData>[] = tapConst(() => [], []);
|
|
45
|
+
|
|
46
|
+
const [items, setItems] = tapState<Record<string, Props>>(() => {
|
|
47
|
+
const entries: [string, Props][] = [];
|
|
48
|
+
for (const data of initialValues) {
|
|
49
|
+
const key = getKey(data);
|
|
50
|
+
const handle = { data, hasData: true };
|
|
51
|
+
entries.push([
|
|
52
|
+
key,
|
|
53
|
+
createProps(key, handle, () => {
|
|
54
|
+
setItems((items) => {
|
|
55
|
+
const newItems = { ...items };
|
|
56
|
+
delete newItems[key];
|
|
57
|
+
return newItems;
|
|
58
|
+
});
|
|
59
|
+
}),
|
|
60
|
+
]);
|
|
61
|
+
initialDataHandles.push(handle);
|
|
62
|
+
}
|
|
63
|
+
return Object.fromEntries(entries);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const lookup = tapClientLookup<TMethods>(
|
|
67
|
+
() =>
|
|
68
|
+
Object.values(items).map((props) => withKey(props.key, Resource(props))),
|
|
69
|
+
[items, Resource],
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
initialDataHandles.forEach((handle) => {
|
|
73
|
+
handle.data = undefined;
|
|
74
|
+
handle.hasData = false;
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const add = (data: TData) => {
|
|
78
|
+
const key = getKey(data);
|
|
79
|
+
setItems((items) => {
|
|
80
|
+
if (key in items) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
`Tried to add item with a key ${key} that already exists`,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const handle = { data, hasData: true };
|
|
87
|
+
initialDataHandles.push(handle);
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
...items,
|
|
91
|
+
[key]: createProps(key, handle, () => {
|
|
92
|
+
setItems((items) => {
|
|
93
|
+
const newItems = { ...items };
|
|
94
|
+
delete newItems[key];
|
|
95
|
+
return newItems;
|
|
96
|
+
});
|
|
97
|
+
}),
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
state: lookup.state,
|
|
104
|
+
get: lookup.get,
|
|
105
|
+
add,
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export namespace tapClientList {
|
|
110
|
+
export type ResourceProps<TData> = {
|
|
111
|
+
key: string;
|
|
112
|
+
getInitialData: () => TData;
|
|
113
|
+
remove: () => void;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export type Props<TData, TMethods extends ClientMethods> = {
|
|
117
|
+
initialValues: TData[];
|
|
118
|
+
getKey: (data: TData) => string;
|
|
119
|
+
resource: ContravariantResource<TMethods, ResourceProps<TData>>;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
tapMemo,
|
|
3
|
+
tapResource,
|
|
4
|
+
tapResources,
|
|
5
|
+
type ResourceElement,
|
|
6
|
+
} from "@assistant-ui/tap";
|
|
7
|
+
import type { ClientMethods } from "../types/client";
|
|
8
|
+
import { ClientResource } from "./tap-client-resource";
|
|
9
|
+
import { wrapperResource } from "./wrapper-resource";
|
|
10
|
+
|
|
11
|
+
type InferClientState<TMethods> = TMethods extends {
|
|
12
|
+
getState: () => infer S;
|
|
13
|
+
}
|
|
14
|
+
? S
|
|
15
|
+
: unknown;
|
|
16
|
+
|
|
17
|
+
const ClientResourceWithKey = wrapperResource(
|
|
18
|
+
<TMethods extends ClientMethods>(el: ResourceElement<TMethods>) => {
|
|
19
|
+
if (el.key === undefined) {
|
|
20
|
+
throw new Error("tapClientResource: Element has no key");
|
|
21
|
+
}
|
|
22
|
+
return tapResource(ClientResource(el)) as {
|
|
23
|
+
methods: TMethods;
|
|
24
|
+
state: InferClientState<TMethods>;
|
|
25
|
+
key: string | number;
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export function tapClientLookup<TMethods extends ClientMethods>(
|
|
31
|
+
getElements: () => readonly ResourceElement<TMethods>[],
|
|
32
|
+
getElementsDeps: readonly unknown[],
|
|
33
|
+
): {
|
|
34
|
+
state: InferClientState<TMethods>[];
|
|
35
|
+
get: (lookup: { index: number } | { key: string }) => TMethods;
|
|
36
|
+
} {
|
|
37
|
+
const resources = tapResources(
|
|
38
|
+
() => getElements().map((el) => ClientResourceWithKey(el)),
|
|
39
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: getElementsDeps is passed through from caller
|
|
40
|
+
getElementsDeps,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const keys = tapMemo(() => Object.keys(resources), [resources]);
|
|
44
|
+
|
|
45
|
+
// For arrays, track element key -> index mapping
|
|
46
|
+
const keyToIndex = tapMemo(() => {
|
|
47
|
+
return resources.reduce(
|
|
48
|
+
(acc, resource, index) => {
|
|
49
|
+
acc[resource.key] = index;
|
|
50
|
+
return acc;
|
|
51
|
+
},
|
|
52
|
+
{} as Record<string, number>,
|
|
53
|
+
);
|
|
54
|
+
}, [resources]);
|
|
55
|
+
|
|
56
|
+
const state = tapMemo(() => {
|
|
57
|
+
return resources.map((r) => r.state);
|
|
58
|
+
}, [resources]);
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
state,
|
|
62
|
+
get: (lookup: { index: number } | { key: string }) => {
|
|
63
|
+
if ("index" in lookup) {
|
|
64
|
+
if (lookup.index < 0 || lookup.index >= keys.length) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`tapClientLookup: Index ${lookup.index} out of bounds (length: ${keys.length})`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return resources[lookup.index]!.methods;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const index = keyToIndex[lookup.key];
|
|
73
|
+
if (index === undefined) {
|
|
74
|
+
throw new Error(`tapClientLookup: Key "${lookup.key}" not found`);
|
|
75
|
+
}
|
|
76
|
+
return resources[index]!.methods;
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import {
|
|
2
|
+
tapEffect,
|
|
3
|
+
tapMemo,
|
|
4
|
+
tapRef,
|
|
5
|
+
type ResourceElement,
|
|
6
|
+
tapResource,
|
|
7
|
+
} from "@assistant-ui/tap";
|
|
8
|
+
import type { ClientMethods } from "../types/client";
|
|
9
|
+
import {
|
|
10
|
+
tapClientStack,
|
|
11
|
+
tapWithClientStack,
|
|
12
|
+
SYMBOL_CLIENT_INDEX,
|
|
13
|
+
} from "./tap-client-stack-context";
|
|
14
|
+
import {
|
|
15
|
+
BaseProxyHandler,
|
|
16
|
+
handleIntrospectionProp,
|
|
17
|
+
} from "./base-proxy-handler";
|
|
18
|
+
import { wrapperResource } from "./wrapper-resource";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Symbol used internally to get state from ClientProxy.
|
|
22
|
+
* This allows getState() to be optional in the user-facing client.
|
|
23
|
+
*/
|
|
24
|
+
const SYMBOL_GET_OUTPUT = Symbol("assistant-ui.store.getValue");
|
|
25
|
+
|
|
26
|
+
type ClientInternal = {
|
|
27
|
+
[SYMBOL_GET_OUTPUT]: ClientMethods;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const getClientState = (client: ClientMethods) => {
|
|
31
|
+
const output = (client as unknown as ClientInternal)[SYMBOL_GET_OUTPUT];
|
|
32
|
+
if (!output) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
"Client scope contains a non-client resource. " +
|
|
35
|
+
"Ensure your Derived get() returns a client created with tapClientResource(), not a plain resource.",
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
return (output as any).getState?.();
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Global cache for function templates by field name
|
|
42
|
+
const fieldAccessFns = new Map<
|
|
43
|
+
string | symbol,
|
|
44
|
+
(this: unknown, ...args: unknown[]) => unknown
|
|
45
|
+
>();
|
|
46
|
+
|
|
47
|
+
function getOrCreateProxyFn(prop: string | symbol) {
|
|
48
|
+
let template = fieldAccessFns.get(prop);
|
|
49
|
+
if (!template) {
|
|
50
|
+
template = function (this: unknown, ...args: unknown[]) {
|
|
51
|
+
if (!this || typeof this !== "object") {
|
|
52
|
+
throw new Error(
|
|
53
|
+
`Method "${String(prop)}" called without proper context. ` +
|
|
54
|
+
`This may indicate the function was called incorrectly.`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const output = (this as ClientInternal)[SYMBOL_GET_OUTPUT];
|
|
59
|
+
if (!output) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`Method "${String(prop)}" called on invalid client proxy. ` +
|
|
62
|
+
`Ensure you are calling this method on a valid client instance.`,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const method = output[prop];
|
|
67
|
+
if (!method)
|
|
68
|
+
throw new Error(`Method "${String(prop)}" is not implemented.`);
|
|
69
|
+
if (typeof method !== "function")
|
|
70
|
+
throw new Error(`"${String(prop)}" is not a function.`);
|
|
71
|
+
return method(...args);
|
|
72
|
+
};
|
|
73
|
+
fieldAccessFns.set(prop, template);
|
|
74
|
+
}
|
|
75
|
+
return template;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
class ClientProxyHandler
|
|
79
|
+
extends BaseProxyHandler
|
|
80
|
+
implements ProxyHandler<object>
|
|
81
|
+
{
|
|
82
|
+
private boundFns: Map<string | symbol, Function> | undefined;
|
|
83
|
+
private cachedReceiver: unknown;
|
|
84
|
+
|
|
85
|
+
constructor(
|
|
86
|
+
private readonly outputRef: {
|
|
87
|
+
current: ClientMethods;
|
|
88
|
+
},
|
|
89
|
+
private readonly index: number,
|
|
90
|
+
) {
|
|
91
|
+
super();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
get(_: unknown, prop: string | symbol, receiver: unknown) {
|
|
95
|
+
if (prop === SYMBOL_GET_OUTPUT) return this.outputRef.current;
|
|
96
|
+
if (prop === SYMBOL_CLIENT_INDEX) return this.index;
|
|
97
|
+
const introspection = handleIntrospectionProp(prop, "ClientProxy");
|
|
98
|
+
if (introspection !== false) return introspection;
|
|
99
|
+
const value = this.outputRef.current[prop];
|
|
100
|
+
if (typeof value === "function") {
|
|
101
|
+
if (this.cachedReceiver !== receiver) {
|
|
102
|
+
this.boundFns = new Map();
|
|
103
|
+
this.cachedReceiver = receiver;
|
|
104
|
+
}
|
|
105
|
+
let bound = this.boundFns!.get(prop);
|
|
106
|
+
if (!bound) {
|
|
107
|
+
bound = getOrCreateProxyFn(prop).bind(receiver);
|
|
108
|
+
this.boundFns!.set(prop, bound);
|
|
109
|
+
}
|
|
110
|
+
return bound;
|
|
111
|
+
}
|
|
112
|
+
return value;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
ownKeys(): ArrayLike<string | symbol> {
|
|
116
|
+
return Object.keys(this.outputRef.current);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
has(_: unknown, prop: string | symbol) {
|
|
120
|
+
if (prop === SYMBOL_GET_OUTPUT) return true;
|
|
121
|
+
if (prop === SYMBOL_CLIENT_INDEX) return true;
|
|
122
|
+
return prop in this.outputRef.current;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Resource that wraps a plain resource element to create a stable client proxy.
|
|
128
|
+
*
|
|
129
|
+
* Takes a ResourceElement that returns methods (with optional getState()) and
|
|
130
|
+
* wraps it to produce a stable client proxy. This adds the client to the
|
|
131
|
+
* client stack, enabling event scoping.
|
|
132
|
+
*
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
export const ClientResource = wrapperResource(
|
|
136
|
+
<TMethods extends ClientMethods>(
|
|
137
|
+
element: ResourceElement<TMethods>,
|
|
138
|
+
): {
|
|
139
|
+
methods: TMethods;
|
|
140
|
+
state: unknown;
|
|
141
|
+
key: string | number | undefined;
|
|
142
|
+
} => {
|
|
143
|
+
const valueRef = tapRef(null as unknown as TMethods);
|
|
144
|
+
|
|
145
|
+
const index = tapClientStack().length;
|
|
146
|
+
const methods = tapMemo(
|
|
147
|
+
() =>
|
|
148
|
+
new Proxy<TMethods>(
|
|
149
|
+
{} as TMethods,
|
|
150
|
+
new ClientProxyHandler(valueRef, index),
|
|
151
|
+
),
|
|
152
|
+
[index],
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
const value = tapWithClientStack(methods, () => tapResource(element));
|
|
156
|
+
if (!valueRef.current) {
|
|
157
|
+
valueRef.current = value;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
tapEffect(() => {
|
|
161
|
+
valueRef.current = value;
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const state = (value as any).getState?.();
|
|
165
|
+
return { methods, state, key: element.key };
|
|
166
|
+
},
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
type InferClientState<TMethods> = TMethods extends {
|
|
170
|
+
getState: () => infer S;
|
|
171
|
+
}
|
|
172
|
+
? S
|
|
173
|
+
: undefined;
|
|
174
|
+
|
|
175
|
+
export const tapClientResource = <TMethods extends ClientMethods>(
|
|
176
|
+
element: ResourceElement<TMethods>,
|
|
177
|
+
): {
|
|
178
|
+
state: InferClientState<TMethods>;
|
|
179
|
+
methods: TMethods;
|
|
180
|
+
key: string | number | undefined;
|
|
181
|
+
} => {
|
|
182
|
+
return tapResource(ClientResource(element)) as {
|
|
183
|
+
state: InferClientState<TMethods>;
|
|
184
|
+
methods: TMethods;
|
|
185
|
+
key: string | number | undefined;
|
|
186
|
+
};
|
|
187
|
+
};
|