@soederpop/luca 0.0.25 → 0.0.28

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/src/container.ts CHANGED
@@ -10,6 +10,7 @@ import { pluralize, singularize } from 'inflect'
10
10
  import { z } from 'zod'
11
11
  import { ContainerStateSchema, describeZodShape } from './schemas/base'
12
12
  import { getContainerBuildTimeData, type ContainerIntrospection, type RegistryIntrospection, type IntrospectionSection } from './introspection/index'
13
+ import { ContainerDescriber } from './container-describer'
13
14
 
14
15
  export { z }
15
16
 
@@ -148,6 +149,16 @@ export class Container<Features extends AvailableFeatures = AvailableFeatures, C
148
149
  }
149
150
  }
150
151
 
152
+ private _describer?: ContainerDescriber
153
+
154
+ /** Lazy-initialized ContainerDescriber for introspecting registries, helpers, and members. */
155
+ get describer(): ContainerDescriber {
156
+ if (!this._describer) {
157
+ this._describer = new ContainerDescriber(this)
158
+ }
159
+ return this._describer
160
+ }
161
+
151
162
  /**
152
163
  * Add a value to the container's shared context, which is passed to all helper instances.
153
164
  * Accepts either a key and value, or an object of key-value pairs to add.
package/src/helper.ts CHANGED
@@ -138,9 +138,16 @@ export abstract class Helper<T extends HelperState = HelperState, K extends Help
138
138
  this.container.emit('helperInitialized', this)
139
139
  }
140
140
 
141
- /**
141
+ /**
142
+ * The static shortcut identifier for this helper type, e.g. "features.assistant".
143
+ */
144
+ get shortcut(): string {
145
+ return (this.constructor as any).shortcut || ''
146
+ }
147
+
148
+ /**
142
149
  * Every helper has a cache key which is computed at the time it is created through the container.
143
- *
150
+ *
144
151
  * This ensures only a single instance of the helper exists for the requested options.
145
152
  */
146
153
  get cacheKey() {
@@ -189,6 +196,26 @@ export abstract class Helper<T extends HelperState = HelperState, K extends Help
189
196
  return this
190
197
  }
191
198
 
199
+ /**
200
+ * Called when another helper (e.g. an assistant) consumes this helper's
201
+ * tools via `use()`. Override this to detect the consumer type and react —
202
+ * for example, adding system prompt extensions to an assistant.
203
+ *
204
+ * Use `consumer.shortcut` to identify the consumer type:
205
+ * ```typescript
206
+ * override setupToolsConsumer(consumer: Helper) {
207
+ * if (consumer.shortcut === 'features.assistant') {
208
+ * (consumer as any).addSystemPromptExtension('myFeature', 'usage hints here')
209
+ * }
210
+ * }
211
+ * ```
212
+ *
213
+ * The default implementation is a no-op.
214
+ *
215
+ * @param consumer - The helper instance that is consuming this helper's tools
216
+ */
217
+ setupToolsConsumer(consumer: Helper): void {}
218
+
192
219
  /**
193
220
  * Collect all tools from the inheritance chain and instance, returning
194
221
  * { schemas, handlers } with matching keys. Walks the prototype chain