@assistant-ui/store 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/README.md +59 -262
  2. package/dist/AssistantIf.d.ts +10 -0
  3. package/dist/AssistantIf.d.ts.map +1 -0
  4. package/dist/AssistantIf.js +13 -0
  5. package/dist/AssistantIf.js.map +1 -0
  6. package/dist/Derived.d.ts +34 -0
  7. package/dist/Derived.d.ts.map +1 -0
  8. package/dist/Derived.js +11 -0
  9. package/dist/Derived.js.map +1 -0
  10. package/dist/attachDefaultPeers.d.ts +56 -0
  11. package/dist/attachDefaultPeers.d.ts.map +1 -0
  12. package/dist/attachDefaultPeers.js +22 -0
  13. package/dist/attachDefaultPeers.js.map +1 -0
  14. package/dist/index.d.ts +11 -14
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +19 -16
  17. package/dist/index.js.map +1 -1
  18. package/dist/tapClientList.d.ts +24 -0
  19. package/dist/tapClientList.d.ts.map +1 -0
  20. package/dist/tapClientList.js +72 -0
  21. package/dist/tapClientList.js.map +1 -0
  22. package/dist/tapClientLookup.d.ts +11 -0
  23. package/dist/tapClientLookup.d.ts.map +1 -0
  24. package/dist/tapClientLookup.js +42 -0
  25. package/dist/tapClientLookup.js.map +1 -0
  26. package/dist/tapClientResource.d.ts +24 -0
  27. package/dist/tapClientResource.d.ts.map +1 -0
  28. package/dist/tapClientResource.js +100 -0
  29. package/dist/tapClientResource.js.map +1 -0
  30. package/dist/types/client.d.ts +117 -0
  31. package/dist/types/client.d.ts.map +1 -0
  32. package/dist/types/client.js +1 -0
  33. package/dist/types/events.d.ts +33 -0
  34. package/dist/types/events.d.ts.map +1 -0
  35. package/dist/types/events.js +12 -0
  36. package/dist/types/events.js.map +1 -0
  37. package/dist/useAssistantClient.d.ts +13 -41
  38. package/dist/useAssistantClient.d.ts.map +1 -1
  39. package/dist/useAssistantClient.js +185 -130
  40. package/dist/useAssistantClient.js.map +1 -1
  41. package/dist/useAssistantEvent.d.ts +2 -2
  42. package/dist/useAssistantEvent.d.ts.map +1 -1
  43. package/dist/useAssistantEvent.js +3 -6
  44. package/dist/useAssistantEvent.js.map +1 -1
  45. package/dist/useAssistantState.d.ts +2 -2
  46. package/dist/useAssistantState.d.ts.map +1 -1
  47. package/dist/useAssistantState.js +7 -36
  48. package/dist/useAssistantState.js.map +1 -1
  49. package/dist/utils/BaseProxyHandler.d.ts +23 -0
  50. package/dist/utils/BaseProxyHandler.d.ts.map +1 -0
  51. package/dist/utils/BaseProxyHandler.js +41 -0
  52. package/dist/utils/BaseProxyHandler.js.map +1 -0
  53. package/dist/utils/NotificationManager.d.ts +11 -0
  54. package/dist/utils/NotificationManager.d.ts.map +1 -0
  55. package/dist/utils/NotificationManager.js +81 -0
  56. package/dist/utils/NotificationManager.js.map +1 -0
  57. package/dist/utils/StoreResource.d.ts +14 -0
  58. package/dist/utils/StoreResource.d.ts.map +1 -0
  59. package/dist/utils/StoreResource.js +23 -0
  60. package/dist/utils/StoreResource.js.map +1 -0
  61. package/dist/utils/proxied-assistant-state.d.ts +8 -0
  62. package/dist/utils/proxied-assistant-state.d.ts.map +1 -0
  63. package/dist/utils/proxied-assistant-state.js +41 -0
  64. package/dist/utils/proxied-assistant-state.js.map +1 -0
  65. package/dist/{AssistantContext.d.ts → utils/react-assistant-context.d.ts} +6 -6
  66. package/dist/utils/react-assistant-context.d.ts.map +1 -0
  67. package/dist/utils/react-assistant-context.js +73 -0
  68. package/dist/utils/react-assistant-context.js.map +1 -0
  69. package/dist/utils/splitClients.d.ts +28 -0
  70. package/dist/utils/splitClients.d.ts.map +1 -0
  71. package/dist/utils/splitClients.js +37 -0
  72. package/dist/utils/splitClients.js.map +1 -0
  73. package/dist/utils/tap-assistant-context.d.ts +19 -0
  74. package/dist/utils/tap-assistant-context.d.ts.map +1 -0
  75. package/dist/utils/tap-assistant-context.js +37 -0
  76. package/dist/utils/tap-assistant-context.js.map +1 -0
  77. package/dist/utils/tap-client-stack-context.d.ts +23 -0
  78. package/dist/utils/tap-client-stack-context.d.ts.map +1 -0
  79. package/dist/utils/tap-client-stack-context.js +30 -0
  80. package/dist/utils/tap-client-stack-context.js.map +1 -0
  81. package/package.json +5 -6
  82. package/src/AssistantIf.tsx +17 -0
  83. package/src/Derived.ts +46 -0
  84. package/src/attachDefaultPeers.ts +78 -0
  85. package/src/index.ts +31 -25
  86. package/src/tapClientList.ts +105 -0
  87. package/src/tapClientLookup.ts +56 -0
  88. package/src/tapClientResource.ts +152 -0
  89. package/src/types/client.ts +186 -0
  90. package/src/types/events.ts +77 -0
  91. package/src/useAssistantClient.tsx +259 -217
  92. package/src/useAssistantEvent.ts +6 -9
  93. package/src/useAssistantState.tsx +10 -48
  94. package/src/utils/BaseProxyHandler.ts +50 -0
  95. package/src/utils/NotificationManager.ts +110 -0
  96. package/src/utils/StoreResource.ts +36 -0
  97. package/src/utils/proxied-assistant-state.tsx +53 -0
  98. package/src/utils/react-assistant-context.tsx +107 -0
  99. package/src/utils/splitClients.ts +85 -0
  100. package/src/utils/tap-assistant-context.ts +59 -0
  101. package/src/utils/tap-client-stack-context.ts +51 -0
  102. package/dist/AssistantContext.d.ts.map +0 -1
  103. package/dist/AssistantContext.js +0 -45
  104. package/dist/AssistantContext.js.map +0 -1
  105. package/dist/DerivedScope.d.ts +0 -18
  106. package/dist/DerivedScope.d.ts.map +0 -1
  107. package/dist/DerivedScope.js +0 -11
  108. package/dist/DerivedScope.js.map +0 -1
  109. package/dist/EventContext.d.ts +0 -65
  110. package/dist/EventContext.d.ts.map +0 -1
  111. package/dist/EventContext.js +0 -62
  112. package/dist/EventContext.js.map +0 -1
  113. package/dist/ScopeRegistry.d.ts +0 -41
  114. package/dist/ScopeRegistry.d.ts.map +0 -1
  115. package/dist/ScopeRegistry.js +0 -17
  116. package/dist/ScopeRegistry.js.map +0 -1
  117. package/dist/StoreContext.d.ts +0 -9
  118. package/dist/StoreContext.d.ts.map +0 -1
  119. package/dist/StoreContext.js +0 -20
  120. package/dist/StoreContext.js.map +0 -1
  121. package/dist/asStore.d.ts +0 -20
  122. package/dist/asStore.d.ts.map +0 -1
  123. package/dist/asStore.js +0 -23
  124. package/dist/asStore.js.map +0 -1
  125. package/dist/tapApi.d.ts +0 -36
  126. package/dist/tapApi.d.ts.map +0 -1
  127. package/dist/tapApi.js +0 -52
  128. package/dist/tapApi.js.map +0 -1
  129. package/dist/tapLookupResources.d.ts +0 -44
  130. package/dist/tapLookupResources.d.ts.map +0 -1
  131. package/dist/tapLookupResources.js +0 -21
  132. package/dist/tapLookupResources.js.map +0 -1
  133. package/dist/tapStoreList.d.ts +0 -76
  134. package/dist/tapStoreList.d.ts.map +0 -1
  135. package/dist/tapStoreList.js +0 -46
  136. package/dist/tapStoreList.js.map +0 -1
  137. package/dist/types.d.ts +0 -88
  138. package/dist/types.d.ts.map +0 -1
  139. package/dist/types.js +0 -1
  140. package/dist/utils/splitScopes.d.ts +0 -24
  141. package/dist/utils/splitScopes.d.ts.map +0 -1
  142. package/dist/utils/splitScopes.js +0 -18
  143. package/dist/utils/splitScopes.js.map +0 -1
  144. package/src/AssistantContext.tsx +0 -64
  145. package/src/DerivedScope.ts +0 -21
  146. package/src/EventContext.ts +0 -184
  147. package/src/ScopeRegistry.ts +0 -58
  148. package/src/StoreContext.ts +0 -28
  149. package/src/asStore.ts +0 -40
  150. package/src/tapApi.ts +0 -91
  151. package/src/tapLookupResources.ts +0 -62
  152. package/src/tapStoreList.ts +0 -133
  153. package/src/types.ts +0 -129
  154. package/src/utils/splitScopes.ts +0 -38
  155. /package/dist/{types.js.map → types/client.js.map} +0 -0
package/README.md CHANGED
@@ -1,295 +1,92 @@
1
1
  # @assistant-ui/store
2
2
 
3
- Tap-based state management for assistant-ui with React Context integration.
3
+ Tap-based state management with React Context integration.
4
4
 
5
- ## Overview
6
-
7
- The store package provides a bridge between tap Resources and React Components via React Context. It implements a scope-based system where you can define custom scopes using TypeScript module augmentation.
8
-
9
- ## Key Concepts
10
-
11
- ### Scopes
12
-
13
- A **scope** defines a piece of state in your application. Each scope has:
14
-
15
- - **value**: The state type (e.g., `{ bar: string }`)
16
- - **source**: Where this scope comes from (`"root"` for top-level, or name of parent scope)
17
- - **query**: Parameters needed to access this scope (e.g., `{ type: "index", index: number }`)
18
-
19
- ### Module Augmentation
20
-
21
- Define custom scopes by extending the `AssistantScopes` interface:
22
-
23
- ```typescript
24
- import type { ScopeDefinition } from "@assistant-ui/store";
25
-
26
- declare module "@assistant-ui/store" {
27
- interface AssistantScopes {
28
- foo: ScopeDefinition<{ bar: string }, "root", {}>;
29
- }
30
- }
31
- ```
32
-
33
- ## Usage
34
-
35
- ### 1. Define a Scope
5
+ ## Quick Start
36
6
 
37
7
  ```typescript
38
- // foo-scope.ts
39
8
  import { resource, tapState } from "@assistant-ui/tap";
40
- import { tapApi } from "@assistant-ui/store";
9
+ import { useAssistantClient, useAssistantState, AssistantProvider, type ClientOutput } from "@assistant-ui/store";
41
10
 
42
- // Define the scope type via module augmentation
43
- // Implement the scope definition raw (no need to import ScopeDefinition)
11
+ // 1. Define client type
44
12
  declare module "@assistant-ui/store" {
45
- interface AssistantScopes {
46
- foo: {
47
- value: {
48
- getState: () => { bar: string };
49
- updateBar: (newBar: string) => void;
50
- };
51
- source: "root";
52
- query: Record<string, never>;
53
- };
13
+ interface ClientRegistry {
14
+ counter: { state: { count: number }; methods: { increment: () => void } };
54
15
  }
55
16
  }
56
17
 
57
- // Create the resource
58
- export const FooResource = resource(() => {
59
- const [state, setState] = tapState<{ bar: string }>({ bar: "Hello, World!" });
60
-
61
- const updateBar = (newBar: string) => {
62
- setState({ bar: newBar });
63
- };
64
-
65
- // Use tapApi to wrap the API for stability and reactivity
66
- return tapApi({
67
- getState: () => state,
68
- updateBar,
69
- });
18
+ // 2. Create resource
19
+ const CounterClient = resource((): ClientOutput<"counter"> => {
20
+ const [state, setState] = tapState({ count: 0 });
21
+ return { state, methods: { increment: () => setState({ count: state.count + 1 }) } };
70
22
  });
71
- ```
72
-
73
- ### 2. Use in React Component
74
-
75
- ```typescript
76
- import { useAssistantClient } from "@assistant-ui/store";
77
- import { FooResource } from "./foo-scope";
78
-
79
- function MyComponent() {
80
- // Create a client with the foo scope
81
- const client = useAssistantClient({
82
- foo: FooResource(),
83
- });
84
-
85
- // Access the state
86
- const fooState = client.foo.getState();
87
- console.log(fooState.bar); // "Hello, World!"
88
-
89
- // Call actions
90
- const handleClick = () => {
91
- client.foo.updateBar("New value!");
92
- };
93
-
94
- return <div onClick={handleClick}>{fooState.bar}</div>;
95
- }
96
- ```
97
-
98
- ### 3. Use with Provider (Optional)
99
-
100
- ```typescript
101
- import { AssistantProvider, useAssistantClient } from "@assistant-ui/store";
102
- import { FooResource } from "./foo-scope";
103
23
 
24
+ // 3. Use in React
104
25
  function App() {
105
- const client = useAssistantClient({
106
- foo: FooResource,
107
- });
108
-
109
- return (
110
- <AssistantProvider client={client}>
111
- <MyComponent />
112
- </AssistantProvider>
113
- );
26
+ const aui = useAssistantClient({ counter: CounterClient() });
27
+ return <AssistantProvider client={aui}><Counter /></AssistantProvider>;
114
28
  }
115
29
 
116
- function MyComponent() {
117
- // Access client from context
118
- const client = useAssistantClient();
119
- const fooState = client.foo.getState();
120
-
121
- return <div>{fooState.bar}</div>;
30
+ function Counter() {
31
+ const count = useAssistantState(({ counter }) => counter.count);
32
+ const aui = useAssistantClient();
33
+ return <button onClick={() => aui.counter().increment()}>{count}</button>;
122
34
  }
123
35
  ```
124
36
 
125
- ### 4. Derived Scopes
126
-
127
- Create scopes that depend on other scopes:
37
+ ## Concepts
128
38
 
39
+ **Clients**: Named state containers registered via module augmentation.
129
40
  ```typescript
130
- import { DerivedScope } from "@assistant-ui/store";
131
-
132
- function MyComponent() {
133
- const client = useAssistantClient({
134
- foo: FooResource,
135
- message: DerivedScope({
136
- source: "thread",
137
- query: { type: "index", index: 0 },
138
- get: () => messageApi,
139
- }),
140
- });
141
-
142
- return <div>{client.message.getState().content}</div>;
41
+ declare module "@assistant-ui/store" {
42
+ interface ClientRegistry {
43
+ myClient: {
44
+ state: MyState;
45
+ methods: MyMethods;
46
+ meta?: { source: "parent"; query: { id: string } };
47
+ events?: { "myClient.updated": { id: string } };
48
+ };
49
+ }
143
50
  }
144
51
  ```
145
52
 
146
- ## API
147
-
148
- ### `useAssistantClient()`
149
-
150
- Returns the AssistantClient from context.
151
-
152
- ```typescript
153
- const client = useAssistantClient();
154
- ```
155
-
156
- ### `useAssistantClient(scopes)`
157
-
158
- Creates a new AssistantClient with the provided scopes, merging with any client from context.
159
-
53
+ **Derived Clients**: Access nested clients from parents.
160
54
  ```typescript
161
- const client = useAssistantClient({
162
- foo: FooResource,
55
+ useAssistantClient({
56
+ item: Derived({ source: "list", query: { index: 0 }, get: (aui) => aui.list().item({ index: 0 }) }),
163
57
  });
164
58
  ```
165
59
 
166
- ### `AssistantProvider`
167
-
168
- Provides an AssistantClient via React Context.
169
-
60
+ **Events**:
170
61
  ```typescript
171
- <AssistantProvider client={client}>
172
- {children}
173
- </AssistantProvider>
174
- ```
175
-
176
- ### `DerivedScope(config)`
62
+ const emit = tapAssistantEmit();
63
+ emit("myClient.updated", { id: "123" });
177
64
 
178
- Creates a derived scope field that memoizes based on source and query.
179
-
180
- ```typescript
181
- DerivedScope({
182
- source: "thread",
183
- query: { type: "index", index: 0 },
184
- get: () => messageApi,
185
- });
65
+ useAssistantEvent("myClient.updated", (p) => console.log(p.id));
186
66
  ```
187
67
 
188
- ## Advanced: List Management with tapLookupResources
189
-
190
- For managing lists of items, use `tapLookupResources`:
191
-
192
- ```typescript
193
- import { tapLookupResources, tapApi } from "@assistant-ui/store";
194
-
195
- // Define item resource
196
- const FooItemResource = resource(
197
- ({ id, initialBar }: { id: string; initialBar: string }) => {
198
- const [state, setState] = tapState({ id, bar: initialBar });
199
-
200
- return {
201
- key: id,
202
- state,
203
- api: tapApi({
204
- getState: () => state,
205
- updateBar: (newBar: string) => setState({ ...state, bar: newBar }),
206
- }),
207
- };
208
- },
209
- );
210
-
211
- // Define list resource
212
- const FooListResource = resource(() => {
213
- const items = [
214
- { id: "foo-1", initialBar: "First" },
215
- { id: "foo-2", initialBar: "Second" },
216
- ];
217
-
218
- const foos = tapLookupResources(
219
- items.map((item) => FooItemResource(item, { key: item.id })),
220
- );
221
-
222
- return tapApi({
223
- getState: () => ({ foos: foos.state }),
224
- // Wrap to rename "key" field to "id"
225
- foo: (lookup: { index: number } | { id: string }) => {
226
- return "id" in lookup
227
- ? foos.api({ key: lookup.id })
228
- : foos.api({ index: lookup.index });
229
- },
230
- }).api;
231
- });
232
- ```
233
-
234
- ### Provider Pattern
235
-
236
- Create providers to scope access to specific list items:
237
-
238
- ```typescript
239
- const FooProvider = ({ index, children }) => {
240
- const parentAui = useAssistantClient();
241
-
242
- const aui = useAssistantClient({
243
- foo: DerivedScope({
244
- source: "fooList",
245
- query: { index },
246
- get: () => parentAui.fooList().foo({ index }),
247
- }),
248
- });
249
-
250
- return <AssistantProvider client={aui}>{children}</AssistantProvider>;
251
- };
252
-
253
- // Render list
254
- const FooList = ({ components }) => {
255
- const aui = useAssistantClient();
256
- const { foos } = aui.fooList().getState();
257
-
258
- return (
259
- <div>
260
- {foos.map((_, index) => (
261
- <FooProvider key={index} index={index}>
262
- <components.Foo />
263
- </FooProvider>
264
- ))}
265
- </div>
266
- );
267
- };
268
- ```
269
-
270
- ## Examples
271
-
272
- See the [store-example](../store-example) Next.js app for a complete working example including:
273
-
274
- - Basic scope definition with `tapApi`
275
- - List management with `tapLookupResources`
276
- - Provider pattern for scoped access
277
- - Component composition
278
- - Tailwind CSS styling
279
-
280
- ## How It Works
281
-
282
- The store is implemented using tap resources:
283
-
284
- 1. Each scope is a tap resource that manages its own state
285
- 2. `useAssistantClient` creates a resource that composes all provided scopes
286
- 3. The React Context provides the client to child components
287
- 4. Scopes can be extended/overridden by calling `useAssistantClient` with new scope definitions
288
-
289
- This design allows for:
68
+ ## API
290
69
 
291
- - Type-safe scope definitions via module augmentation
292
- - ✅ Automatic cleanup of resources when components unmount
293
- - Composable scope hierarchy (root derived scopes)
294
- - Full TypeScript inference for state and APIs
295
- - Zero runtime overhead for scopes that aren't used
70
+ | Hook/Component | Description |
71
+ |----------------|-------------|
72
+ | `useAssistantClient()` | Get client from context |
73
+ | `useAssistantClient(clients)` | Create/extend client |
74
+ | `useAssistantState(selector)` | Subscribe to state |
75
+ | `useAssistantEvent(event, cb)` | Subscribe to events |
76
+ | `AssistantProvider` | Provide client to tree |
77
+ | `AssistantIf` | Conditional rendering |
78
+
79
+ | Tap Utility | Description |
80
+ |-------------|-------------|
81
+ | `tapAssistantClientRef()` | Access client ref in resources |
82
+ | `tapAssistantEmit()` | Emit events from resources |
83
+ | `tapClientResource(element)` | Wrap resource for event scoping (1:1 mappings) |
84
+ | `tapClientLookup(map, fn, deps)` | Lookup by `{index}` or `{key}` |
85
+ | `tapClientList(config)` | Dynamic list with add/remove |
86
+ | `attachDefaultPeers(resource, peers)` | Attach default peers |
87
+
88
+ | Type | Description |
89
+ |------|-------------|
90
+ | `ClientOutput<K>` | Resource return type: `{ state, methods }` |
91
+ | `ClientRegistry` | Module augmentation interface |
92
+ | `AssistantClient` | Full client type |
@@ -0,0 +1,10 @@
1
+ import type { FC, PropsWithChildren } from "react";
2
+ import type { AssistantState } from "./types/client";
3
+ export declare namespace AssistantIf {
4
+ type Props = PropsWithChildren<{
5
+ condition: AssistantIf.Condition;
6
+ }>;
7
+ type Condition = (state: AssistantState) => boolean;
8
+ }
9
+ export declare const AssistantIf: FC<AssistantIf.Props>;
10
+ //# sourceMappingURL=AssistantIf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AssistantIf.d.ts","sourceRoot":"","sources":["../src/AssistantIf.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,yBAAiB,WAAW,CAAC;IAC3B,KAAY,KAAK,GAAG,iBAAiB,CAAC;QAAE,SAAS,EAAE,WAAW,CAAC,SAAS,CAAA;KAAE,CAAC,CAAC;IAC5E,KAAY,SAAS,GAAG,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC;CAC5D;AAED,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAG7C,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use client";
2
+
3
+ // src/AssistantIf.tsx
4
+ import { useAssistantState } from "./useAssistantState.js";
5
+ var AssistantIf = ({ children, condition }) => {
6
+ const result = useAssistantState(condition);
7
+ return result ? children : null;
8
+ };
9
+ AssistantIf.displayName = "AssistantIf";
10
+ export {
11
+ AssistantIf
12
+ };
13
+ //# sourceMappingURL=AssistantIf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/AssistantIf.tsx"],"sourcesContent":["\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport { useAssistantState } from \"./useAssistantState\";\nimport type { AssistantState } from \"./types/client\";\n\nexport namespace AssistantIf {\n export type Props = PropsWithChildren<{ condition: AssistantIf.Condition }>;\n export type Condition = (state: AssistantState) => boolean;\n}\n\nexport const AssistantIf: FC<AssistantIf.Props> = ({ children, condition }) => {\n const result = useAssistantState(condition);\n return result ? children : null;\n};\n\nAssistantIf.displayName = \"AssistantIf\";\n"],"mappings":";;;AAGA,SAAS,yBAAyB;AAQ3B,IAAM,cAAqC,CAAC,EAAE,UAAU,UAAU,MAAM;AAC7E,QAAM,SAAS,kBAAkB,SAAS;AAC1C,SAAO,SAAS,WAAW;AAC7B;AAEA,YAAY,cAAc;","names":[]}
@@ -0,0 +1,34 @@
1
+ import { ResourceElement } from "@assistant-ui/tap";
2
+ import type { AssistantClient, ClientNames, AssistantClientAccessor, ClientMeta } from "./types/client";
3
+ /**
4
+ * Creates a derived client field that references a client from a parent scope.
5
+ * The get callback always calls the most recent version (useEffectEvent pattern).
6
+ *
7
+ * IMPORTANT: The `get` callback must return a client that was created via
8
+ * `tapClientResource` (or `tapClientLookup`/`tapClientList` which use it internally).
9
+ * This is required for event scoping to work correctly.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const aui = useAssistantClient({
14
+ * message: Derived({
15
+ * source: "thread",
16
+ * query: { index: 0 },
17
+ * get: (aui) => aui.thread().message({ index: 0 }),
18
+ * }),
19
+ * });
20
+ * ```
21
+ */
22
+ export declare const Derived: <K extends ClientNames>(...args: undefined extends Derived.Props<K> ? [props?: Derived.Props<K>] : [props: Derived.Props<K>]) => ResourceElement<null, Derived.Props<K>>;
23
+ export type DerivedElement<K extends ClientNames> = ResourceElement<null, Derived.Props<K>>;
24
+ export declare namespace Derived {
25
+ /**
26
+ * Props passed to a derived client resource element.
27
+ */
28
+ type Props<K extends ClientNames> = {
29
+ get: (client: AssistantClient) => ReturnType<AssistantClientAccessor<K>>;
30
+ } & (ClientMeta<K> | {
31
+ getMeta: (client: AssistantClient) => ClientMeta<K>;
32
+ });
33
+ }
34
+ //# sourceMappingURL=Derived.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Derived.d.ts","sourceRoot":"","sources":["../src/Derived.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,uBAAuB,EACvB,UAAU,EACX,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,OAAO,GACjB,CAAC,SAAS,WAAW,kJAGvB,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,WAAW,IAAI,eAAe,CACjE,IAAI,EACJ,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CACjB,CAAC;AAEF,yBAAiB,OAAO,CAAC;IACvB;;OAEG;IACH,KAAY,KAAK,CAAC,CAAC,SAAS,WAAW,IAAI;QACzC,GAAG,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,UAAU,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;KAC1E,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,UAAU,CAAC,CAAC,CAAC,CAAA;KAAE,CAAC,CAAC;CAC/E"}
@@ -0,0 +1,11 @@
1
+ // src/Derived.ts
2
+ import { resource } from "@assistant-ui/tap";
3
+ var Derived = resource(
4
+ (_config) => {
5
+ return null;
6
+ }
7
+ );
8
+ export {
9
+ Derived
10
+ };
11
+ //# sourceMappingURL=Derived.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/Derived.ts"],"sourcesContent":["import { resource, ResourceElement } from \"@assistant-ui/tap\";\nimport type {\n AssistantClient,\n ClientNames,\n AssistantClientAccessor,\n ClientMeta,\n} from \"./types/client\";\n\n/**\n * Creates a derived client field that references a client from a parent scope.\n * The get callback always calls the most recent version (useEffectEvent pattern).\n *\n * IMPORTANT: The `get` callback must return a client that was created via\n * `tapClientResource` (or `tapClientLookup`/`tapClientList` which use it internally).\n * This is required for event scoping to work correctly.\n *\n * @example\n * ```typescript\n * const aui = useAssistantClient({\n * message: Derived({\n * source: \"thread\",\n * query: { index: 0 },\n * get: (aui) => aui.thread().message({ index: 0 }),\n * }),\n * });\n * ```\n */\nexport const Derived = resource(\n <K extends ClientNames>(_config: Derived.Props<K>): null => {\n return null;\n },\n);\n\nexport type DerivedElement<K extends ClientNames> = ResourceElement<\n null,\n Derived.Props<K>\n>;\n\nexport namespace Derived {\n /**\n * Props passed to a derived client resource element.\n */\n export type Props<K extends ClientNames> = {\n get: (client: AssistantClient) => ReturnType<AssistantClientAccessor<K>>;\n } & (ClientMeta<K> | { getMeta: (client: AssistantClient) => ClientMeta<K> });\n}\n"],"mappings":";AAAA,SAAS,gBAAiC;AA2BnC,IAAM,UAAU;AAAA,EACrB,CAAwB,YAAoC;AAC1D,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,56 @@
1
+ import type { ResourceElement } from "@assistant-ui/tap";
2
+ import type { ClientElement, ClientNames } from "./types/client";
3
+ import type { DerivedElement } from "./Derived";
4
+ /**
5
+ * Symbol used to store default peer clients on a resource.
6
+ */
7
+ declare const DEFAULT_PEERS: unique symbol;
8
+ /**
9
+ * Type for resources that have default peers attached.
10
+ */
11
+ export type ResourceWithDefaultPeers = {
12
+ [DEFAULT_PEERS]?: DefaultPeers;
13
+ };
14
+ /**
15
+ * Default peers configuration - can be either root clients or derived clients.
16
+ */
17
+ export type DefaultPeers = {
18
+ [K in ClientNames]?: ClientElement<K> | DerivedElement<K>;
19
+ };
20
+ /**
21
+ * Attaches default peer clients to a resource.
22
+ *
23
+ * Default peers are only applied if the scope doesn't exist:
24
+ * - Not defined in parent context
25
+ * - Not provided by user
26
+ * - Not already defined by a previous resource's default peers
27
+ *
28
+ * First definition wins - no overriding is permitted.
29
+ *
30
+ * @param resource - The resource to attach default peers to
31
+ * @param peers - The default peer clients to attach
32
+ * @throws Error if a peer key already exists in the resource's default peers
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const ThreadListClient = resource(({ ... }) => { ... });
37
+ *
38
+ * attachDefaultPeers(ThreadListClient, {
39
+ * // Derived default peers
40
+ * thread: Derived({ source: "threads", query: { type: "main" }, get: ... }),
41
+ * threadListItem: Derived({ ... }),
42
+ * composer: Derived({ getMeta: ..., get: ... }),
43
+ *
44
+ * // Root default peers
45
+ * tools: Tools({}),
46
+ * modelContext: ModelContext({}),
47
+ * });
48
+ * ```
49
+ */
50
+ export declare function attachDefaultPeers<T extends (...args: any[]) => ResourceElement<any>>(resource: T, peers: DefaultPeers): void;
51
+ /**
52
+ * Gets the default peers attached to a resource, if any.
53
+ */
54
+ export declare function getDefaultPeers<T extends (...args: any[]) => ResourceElement<any>>(resource: T): DefaultPeers | undefined;
55
+ export {};
56
+ //# sourceMappingURL=attachDefaultPeers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachDefaultPeers.d.ts","sourceRoot":"","sources":["../src/attachDefaultPeers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD;;GAEG;AACH,QAAA,MAAM,aAAa,eAAuC,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,CAAC,aAAa,CAAC,CAAC,EAAE,YAAY,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;KACxB,CAAC,IAAI,WAAW,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC;CAC1D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,kBAAkB,CAChC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,eAAe,CAAC,GAAG,CAAC,EAClD,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAaxC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,eAAe,CAAC,GAAG,CAAC,EAClD,QAAQ,EAAE,CAAC,GAAG,YAAY,GAAG,SAAS,CAEvC"}
@@ -0,0 +1,22 @@
1
+ // src/attachDefaultPeers.ts
2
+ var DEFAULT_PEERS = /* @__PURE__ */ Symbol("assistant-ui.default-peers");
3
+ function attachDefaultPeers(resource, peers) {
4
+ const resourceWithPeers = resource;
5
+ const existing = resourceWithPeers[DEFAULT_PEERS] ?? {};
6
+ for (const key of Object.keys(peers)) {
7
+ if (key in existing) {
8
+ throw new Error(
9
+ `Default peer "${key}" is already attached to this resource`
10
+ );
11
+ }
12
+ }
13
+ resourceWithPeers[DEFAULT_PEERS] = { ...existing, ...peers };
14
+ }
15
+ function getDefaultPeers(resource) {
16
+ return resource[DEFAULT_PEERS];
17
+ }
18
+ export {
19
+ attachDefaultPeers,
20
+ getDefaultPeers
21
+ };
22
+ //# sourceMappingURL=attachDefaultPeers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/attachDefaultPeers.ts"],"sourcesContent":["import type { ResourceElement } from \"@assistant-ui/tap\";\nimport type { ClientElement, ClientNames } from \"./types/client\";\nimport type { DerivedElement } from \"./Derived\";\n\n/**\n * Symbol used to store default peer clients on a resource.\n */\nconst DEFAULT_PEERS = Symbol(\"assistant-ui.default-peers\");\n\n/**\n * Type for resources that have default peers attached.\n */\nexport type ResourceWithDefaultPeers = {\n [DEFAULT_PEERS]?: DefaultPeers;\n};\n\n/**\n * Default peers configuration - can be either root clients or derived clients.\n */\nexport type DefaultPeers = {\n [K in ClientNames]?: ClientElement<K> | DerivedElement<K>;\n};\n\n/**\n * Attaches default peer clients to a resource.\n *\n * Default peers are only applied if the scope doesn't exist:\n * - Not defined in parent context\n * - Not provided by user\n * - Not already defined by a previous resource's default peers\n *\n * First definition wins - no overriding is permitted.\n *\n * @param resource - The resource to attach default peers to\n * @param peers - The default peer clients to attach\n * @throws Error if a peer key already exists in the resource's default peers\n *\n * @example\n * ```typescript\n * const ThreadListClient = resource(({ ... }) => { ... });\n *\n * attachDefaultPeers(ThreadListClient, {\n * // Derived default peers\n * thread: Derived({ source: \"threads\", query: { type: \"main\" }, get: ... }),\n * threadListItem: Derived({ ... }),\n * composer: Derived({ getMeta: ..., get: ... }),\n *\n * // Root default peers\n * tools: Tools({}),\n * modelContext: ModelContext({}),\n * });\n * ```\n */\nexport function attachDefaultPeers<\n T extends (...args: any[]) => ResourceElement<any>,\n>(resource: T, peers: DefaultPeers): void {\n const resourceWithPeers = resource as T & ResourceWithDefaultPeers;\n const existing = resourceWithPeers[DEFAULT_PEERS] ?? {};\n\n for (const key of Object.keys(peers)) {\n if (key in existing) {\n throw new Error(\n `Default peer \"${key}\" is already attached to this resource`,\n );\n }\n }\n\n resourceWithPeers[DEFAULT_PEERS] = { ...existing, ...peers };\n}\n\n/**\n * Gets the default peers attached to a resource, if any.\n */\nexport function getDefaultPeers<\n T extends (...args: any[]) => ResourceElement<any>,\n>(resource: T): DefaultPeers | undefined {\n return (resource as T & ResourceWithDefaultPeers)[DEFAULT_PEERS];\n}\n"],"mappings":";AAOA,IAAM,gBAAgB,uBAAO,4BAA4B;AA8ClD,SAAS,mBAEd,UAAa,OAA2B;AACxC,QAAM,oBAAoB;AAC1B,QAAM,WAAW,kBAAkB,aAAa,KAAK,CAAC;AAEtD,aAAW,OAAO,OAAO,KAAK,KAAK,GAAG;AACpC,QAAI,OAAO,UAAU;AACnB,YAAM,IAAI;AAAA,QACR,iBAAiB,GAAG;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AAEA,oBAAkB,aAAa,IAAI,EAAE,GAAG,UAAU,GAAG,MAAM;AAC7D;AAKO,SAAS,gBAEd,UAAuC;AACvC,SAAQ,SAA0C,aAAa;AACjE;","names":[]}
package/dist/index.d.ts CHANGED
@@ -1,18 +1,15 @@
1
1
  export { useAssistantClient } from "./useAssistantClient";
2
2
  export { useAssistantState } from "./useAssistantState";
3
- export { AssistantProvider } from "./AssistantContext";
4
- export type { AssistantScopes, AssistantClient, AssistantState } from "./types";
5
- export { DerivedScope } from "./DerivedScope";
6
- export type { ApiObject } from "./tapApi";
7
- export { tapApi } from "./tapApi";
8
- export { tapLookupResources } from "./tapLookupResources";
9
- export { tapStoreList } from "./tapStoreList";
10
- export type { TapStoreListConfig } from "./tapStoreList";
11
- export { registerAssistantScope } from "./ScopeRegistry";
12
- export type { AssistantScopeRegistry } from "./types";
13
- export { tapStoreContext } from "./StoreContext";
14
- export type { StoreContextValue } from "./StoreContext";
15
3
  export { useAssistantEvent } from "./useAssistantEvent";
16
- export { normalizeEventSelector, checkEventScope } from "./EventContext";
17
- export type { AssistantEvent, AssistantEventRegistry, AssistantEventScopeConfig, AssistantEventMap, AssistantEventScope, AssistantEventSelector, AssistantEventCallback, EventSource, SourceByScope, EventManager, } from "./EventContext";
4
+ export { AssistantIf } from "./AssistantIf";
5
+ export { AssistantProvider } from "./utils/react-assistant-context";
6
+ export { Derived } from "./Derived";
7
+ export { attachDefaultPeers } from "./attachDefaultPeers";
8
+ export { tapAssistantClientRef, tapAssistantEmit, } from "./utils/tap-assistant-context";
9
+ export { tapClientResource } from "./tapClientResource";
10
+ export { tapClientLookup } from "./tapClientLookup";
11
+ export { tapClientList } from "./tapClientList";
12
+ export type { ClientRegistry, ClientOutput, AssistantClient, AssistantState, } from "./types/client";
13
+ export type { AssistantEventName, AssistantEventCallback, AssistantEventPayload, AssistantEventSelector, AssistantEventScope, } from "./types/events";
14
+ export type { DefaultPeers } from "./attachDefaultPeers";
18
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAGtD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACzE,YAAY,EACV,cAAc,EACd,sBAAsB,EACtB,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,WAAW,EACX,aAAa,EACb,YAAY,GACb,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAGpE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EACL,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,YAAY,EACV,cAAc,EACd,YAAY,EACZ,eAAe,EACf,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -1,25 +1,28 @@
1
1
  // src/index.ts
2
2
  import { useAssistantClient } from "./useAssistantClient.js";
3
3
  import { useAssistantState } from "./useAssistantState.js";
4
- import { AssistantProvider } from "./AssistantContext.js";
5
- import { DerivedScope } from "./DerivedScope.js";
6
- import { tapApi } from "./tapApi.js";
7
- import { tapLookupResources } from "./tapLookupResources.js";
8
- import { tapStoreList } from "./tapStoreList.js";
9
- import { registerAssistantScope } from "./ScopeRegistry.js";
10
- import { tapStoreContext } from "./StoreContext.js";
11
4
  import { useAssistantEvent } from "./useAssistantEvent.js";
12
- import { normalizeEventSelector, checkEventScope } from "./EventContext.js";
5
+ import { AssistantIf } from "./AssistantIf.js";
6
+ import { AssistantProvider } from "./utils/react-assistant-context.js";
7
+ import { Derived } from "./Derived.js";
8
+ import { attachDefaultPeers } from "./attachDefaultPeers.js";
9
+ import {
10
+ tapAssistantClientRef,
11
+ tapAssistantEmit
12
+ } from "./utils/tap-assistant-context.js";
13
+ import { tapClientResource } from "./tapClientResource.js";
14
+ import { tapClientLookup } from "./tapClientLookup.js";
15
+ import { tapClientList } from "./tapClientList.js";
13
16
  export {
17
+ AssistantIf,
14
18
  AssistantProvider,
15
- DerivedScope,
16
- checkEventScope,
17
- normalizeEventSelector,
18
- registerAssistantScope,
19
- tapApi,
20
- tapLookupResources,
21
- tapStoreContext,
22
- tapStoreList,
19
+ Derived,
20
+ attachDefaultPeers,
21
+ tapAssistantClientRef,
22
+ tapAssistantEmit,
23
+ tapClientList,
24
+ tapClientLookup,
25
+ tapClientResource,
23
26
  useAssistantClient,
24
27
  useAssistantEvent,
25
28
  useAssistantState
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { useAssistantClient } from \"./useAssistantClient\";\nexport { useAssistantState } from \"./useAssistantState\";\nexport { AssistantProvider } from \"./AssistantContext\";\nexport type { AssistantScopes, AssistantClient, AssistantState } from \"./types\";\nexport { DerivedScope } from \"./DerivedScope\";\nexport type { ApiObject } from \"./tapApi\";\nexport { tapApi } from \"./tapApi\";\nexport { tapLookupResources } from \"./tapLookupResources\";\nexport { tapStoreList } from \"./tapStoreList\";\nexport type { TapStoreListConfig } from \"./tapStoreList\";\nexport { registerAssistantScope } from \"./ScopeRegistry\";\n\nexport type { AssistantScopeRegistry } from \"./types\";\n\n// Events & Store Context\nexport { tapStoreContext } from \"./StoreContext\";\nexport type { StoreContextValue } from \"./StoreContext\";\nexport { useAssistantEvent } from \"./useAssistantEvent\";\nexport { normalizeEventSelector, checkEventScope } from \"./EventContext\";\nexport type {\n AssistantEvent,\n AssistantEventRegistry,\n AssistantEventScopeConfig,\n AssistantEventMap,\n AssistantEventScope,\n AssistantEventSelector,\n AssistantEventCallback,\n EventSource,\n SourceByScope,\n EventManager,\n} from \"./EventContext\";\n"],"mappings":";AAAA,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAElC,SAAS,oBAAoB;AAE7B,SAAS,cAAc;AACvB,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAE7B,SAAS,8BAA8B;AAKvC,SAAS,uBAAuB;AAEhC,SAAS,yBAAyB;AAClC,SAAS,wBAAwB,uBAAuB;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// hooks\nexport { useAssistantClient } from \"./useAssistantClient\";\nexport { useAssistantState } from \"./useAssistantState\";\nexport { useAssistantEvent } from \"./useAssistantEvent\";\n\n// components\nexport { AssistantIf } from \"./AssistantIf\";\nexport { AssistantProvider } from \"./utils/react-assistant-context\";\n\n// resources\nexport { Derived } from \"./Derived\";\nexport { attachDefaultPeers } from \"./attachDefaultPeers\";\n\n// tap hooks\nexport {\n tapAssistantClientRef,\n tapAssistantEmit,\n} from \"./utils/tap-assistant-context\";\nexport { tapClientResource } from \"./tapClientResource\";\nexport { tapClientLookup } from \"./tapClientLookup\";\nexport { tapClientList } from \"./tapClientList\";\n\n// types\nexport type {\n ClientRegistry,\n ClientOutput,\n AssistantClient,\n AssistantState,\n} from \"./types/client\";\nexport type {\n AssistantEventName,\n AssistantEventCallback,\n AssistantEventPayload,\n AssistantEventSelector,\n AssistantEventScope,\n} from \"./types/events\";\nexport type { DefaultPeers } from \"./attachDefaultPeers\";\n"],"mappings":";AACA,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAGlC,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAGlC,SAAS,eAAe;AACxB,SAAS,0BAA0B;AAGnC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;","names":[]}
@@ -0,0 +1,24 @@
1
+ import type { ContravariantResource } from "@assistant-ui/tap";
2
+ import type { ClientMethods, ClientOutputOf } from "./types/client";
3
+ export declare const tapClientList: <TData, TState, TMethods extends ClientMethods>(props: tapClientList.Props<TData, TState, TMethods>) => {
4
+ state: TState[];
5
+ get: (lookup: {
6
+ index: number;
7
+ } | {
8
+ key: string;
9
+ }) => TMethods;
10
+ add: (initialData: TData) => void;
11
+ };
12
+ export declare namespace tapClientList {
13
+ type ResourceProps<TData> = {
14
+ key: string;
15
+ getInitialData: () => TData;
16
+ remove: () => void;
17
+ };
18
+ type Props<TData, TState, TMethods extends ClientMethods> = {
19
+ initialValues: TData[];
20
+ getKey: (data: TData) => string;
21
+ resource: ContravariantResource<ClientOutputOf<TState, TMethods>, ResourceProps<TData>>;
22
+ };
23
+ }
24
+ //# sourceMappingURL=tapClientList.d.ts.map