@soederpop/luca 0.0.32 → 0.0.34
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/README.md +241 -36
- package/bun.lock +24 -5
- package/commands/build-python-bridge.ts +43 -0
- package/docs/apis/clients/rest.md +7 -7
- package/docs/apis/clients/websocket.md +23 -10
- package/docs/apis/features/agi/assistant.md +155 -8
- package/docs/apis/features/agi/assistants-manager.md +90 -22
- package/docs/apis/features/agi/auto-assistant.md +377 -0
- package/docs/apis/features/agi/browser-use.md +802 -0
- package/docs/apis/features/agi/claude-code.md +6 -1
- package/docs/apis/features/agi/conversation-history.md +7 -6
- package/docs/apis/features/agi/conversation.md +111 -38
- package/docs/apis/features/agi/docs-reader.md +35 -57
- package/docs/apis/features/agi/file-tools.md +163 -0
- package/docs/apis/features/agi/openapi.md +2 -2
- package/docs/apis/features/agi/skills-library.md +227 -0
- package/docs/apis/features/node/content-db.md +125 -4
- package/docs/apis/features/node/disk-cache.md +11 -11
- package/docs/apis/features/node/downloader.md +1 -1
- package/docs/apis/features/node/file-manager.md +15 -15
- package/docs/apis/features/node/fs.md +78 -21
- package/docs/apis/features/node/git.md +50 -10
- package/docs/apis/features/node/google-calendar.md +3 -0
- package/docs/apis/features/node/google-docs.md +10 -1
- package/docs/apis/features/node/google-drive.md +3 -0
- package/docs/apis/features/node/google-mail.md +214 -0
- package/docs/apis/features/node/google-sheets.md +3 -0
- package/docs/apis/features/node/ink.md +10 -10
- package/docs/apis/features/node/ipc-socket.md +83 -93
- package/docs/apis/features/node/networking.md +5 -5
- package/docs/apis/features/node/os.md +7 -7
- package/docs/apis/features/node/package-finder.md +14 -14
- package/docs/apis/features/node/proc.md +2 -1
- package/docs/apis/features/node/process-manager.md +70 -3
- package/docs/apis/features/node/python.md +265 -9
- package/docs/apis/features/node/redis.md +380 -0
- package/docs/apis/features/node/ui.md +13 -13
- package/docs/apis/servers/express.md +35 -7
- package/docs/apis/servers/mcp.md +3 -3
- package/docs/apis/servers/websocket.md +51 -8
- package/docs/bootstrap/CLAUDE.md +1 -1
- package/docs/bootstrap/SKILL.md +93 -7
- package/docs/examples/feature-as-tool-provider.md +143 -0
- package/docs/examples/python.md +42 -1
- package/docs/introspection.md +15 -5
- package/docs/tutorials/00-bootstrap.md +3 -3
- package/docs/tutorials/02-container.md +2 -2
- package/docs/tutorials/10-creating-features.md +5 -0
- package/docs/tutorials/13-introspection.md +12 -2
- package/docs/tutorials/19-python-sessions.md +401 -0
- package/package.json +8 -4
- package/src/agi/container.server.ts +8 -0
- package/src/agi/features/assistant.ts +18 -0
- package/src/agi/features/autonomous-assistant.ts +435 -0
- package/src/agi/features/conversation.ts +58 -6
- package/src/agi/features/file-tools.ts +286 -0
- package/src/agi/features/luca-coder.ts +643 -0
- package/src/bootstrap/generated.ts +705 -17
- package/src/cli/build-info.ts +2 -2
- package/src/cli/cli.ts +22 -13
- package/src/commands/bootstrap.ts +49 -6
- package/src/commands/code.ts +369 -0
- package/src/commands/describe.ts +7 -2
- package/src/commands/index.ts +1 -0
- package/src/commands/sandbox-mcp.ts +7 -7
- package/src/commands/save-api-docs.ts +1 -1
- package/src/container-describer.ts +4 -4
- package/src/container.ts +10 -19
- package/src/helper.ts +24 -33
- package/src/introspection/generated.agi.ts +3026 -590
- package/src/introspection/generated.node.ts +1625 -688
- package/src/introspection/generated.web.ts +15 -57
- package/src/node/container.ts +5 -0
- package/src/node/features/figlet-fonts.ts +597 -0
- package/src/node/features/fs.ts +3 -9
- package/src/node/features/helpers.ts +20 -0
- package/src/node/features/python.ts +429 -16
- package/src/node/features/redis.ts +446 -0
- package/src/node/features/ui.ts +4 -11
- package/src/python/bridge.py +220 -0
- package/src/python/generated.ts +227 -0
- package/src/scaffolds/generated.ts +1 -1
- package/test/python-session.test.ts +105 -0
- package/assistants/lucaExpert/CORE.md +0 -37
- package/assistants/lucaExpert/hooks.ts +0 -9
- package/assistants/lucaExpert/tools.ts +0 -177
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
# Assistant (features.assistant)
|
|
2
2
|
|
|
3
|
-
An Assistant is a
|
|
3
|
+
An Assistant is a combination of a system prompt and tool calls that has a conversation with an LLM. You define an assistant by creating a folder with CORE.md (system prompt), tools.ts (tool implementations), and hooks.ts (event handlers).
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
container.feature('assistant', {
|
|
9
|
-
// The folder containing the assistant definition
|
|
9
|
+
// The folder containing the assistant definition. Defaults to cwd for runtime-created assistants.
|
|
10
10
|
folder,
|
|
11
11
|
// The folder containing the assistant documentation
|
|
12
12
|
docsFolder,
|
|
13
|
+
// Provide a complete system prompt directly, bypassing CORE.md
|
|
14
|
+
systemPrompt,
|
|
13
15
|
// Text to prepend to the system prompt
|
|
14
16
|
prependPrompt,
|
|
15
17
|
// Text to append to the system prompt
|
|
@@ -22,10 +24,30 @@ container.feature('assistant', {
|
|
|
22
24
|
model,
|
|
23
25
|
// Maximum number of output tokens per completion
|
|
24
26
|
maxTokens,
|
|
27
|
+
// Sampling temperature (0-2)
|
|
28
|
+
temperature,
|
|
29
|
+
// Nucleus sampling cutoff (0-1)
|
|
30
|
+
topP,
|
|
31
|
+
// Top-K sampling. Only supported by local/Anthropic models
|
|
32
|
+
topK,
|
|
33
|
+
// Frequency penalty (-2 to 2)
|
|
34
|
+
frequencyPenalty,
|
|
35
|
+
// Presence penalty (-2 to 2)
|
|
36
|
+
presencePenalty,
|
|
37
|
+
// Stop sequences
|
|
38
|
+
stop,
|
|
25
39
|
// Whether to use our local models for this
|
|
26
40
|
local,
|
|
27
41
|
// Conversation history persistence mode
|
|
28
42
|
historyMode,
|
|
43
|
+
// Prepend timestamps to user messages so the assistant can perceive time passing between sessions
|
|
44
|
+
injectTimestamps,
|
|
45
|
+
// Strict allowlist of tool name patterns. Only matching tools are available. Supports * glob matching.
|
|
46
|
+
allowTools,
|
|
47
|
+
// Denylist of tool name patterns to exclude. Supports * glob matching.
|
|
48
|
+
forbidTools,
|
|
49
|
+
// Explicit list of tool names to include (exact match). Shorthand for allowTools without glob patterns.
|
|
50
|
+
toolNames,
|
|
29
51
|
})
|
|
30
52
|
```
|
|
31
53
|
|
|
@@ -33,19 +55,45 @@ container.feature('assistant', {
|
|
|
33
55
|
|
|
34
56
|
| Property | Type | Description |
|
|
35
57
|
|----------|------|-------------|
|
|
36
|
-
| `folder` | `string` | The folder containing the assistant definition |
|
|
58
|
+
| `folder` | `string` | The folder containing the assistant definition. Defaults to cwd for runtime-created assistants. |
|
|
37
59
|
| `docsFolder` | `string` | The folder containing the assistant documentation |
|
|
60
|
+
| `systemPrompt` | `string` | Provide a complete system prompt directly, bypassing CORE.md |
|
|
38
61
|
| `prependPrompt` | `string` | Text to prepend to the system prompt |
|
|
39
62
|
| `appendPrompt` | `string` | Text to append to the system prompt |
|
|
40
63
|
| `tools` | `object` | Override or extend the tools loaded from tools.ts |
|
|
41
64
|
| `schemas` | `object` | Override or extend schemas whose keys match tool names |
|
|
42
65
|
| `model` | `string` | OpenAI model to use |
|
|
43
66
|
| `maxTokens` | `number` | Maximum number of output tokens per completion |
|
|
67
|
+
| `temperature` | `number` | Sampling temperature (0-2) |
|
|
68
|
+
| `topP` | `number` | Nucleus sampling cutoff (0-1) |
|
|
69
|
+
| `topK` | `number` | Top-K sampling. Only supported by local/Anthropic models |
|
|
70
|
+
| `frequencyPenalty` | `number` | Frequency penalty (-2 to 2) |
|
|
71
|
+
| `presencePenalty` | `number` | Presence penalty (-2 to 2) |
|
|
72
|
+
| `stop` | `array` | Stop sequences |
|
|
44
73
|
| `local` | `boolean` | Whether to use our local models for this |
|
|
45
74
|
| `historyMode` | `string` | Conversation history persistence mode |
|
|
75
|
+
| `injectTimestamps` | `boolean` | Prepend timestamps to user messages so the assistant can perceive time passing between sessions |
|
|
76
|
+
| `allowTools` | `array` | Strict allowlist of tool name patterns. Only matching tools are available. Supports * glob matching. |
|
|
77
|
+
| `forbidTools` | `array` | Denylist of tool name patterns to exclude. Supports * glob matching. |
|
|
78
|
+
| `toolNames` | `array` | Explicit list of tool names to include (exact match). Shorthand for allowTools without glob patterns. |
|
|
46
79
|
|
|
47
80
|
## Methods
|
|
48
81
|
|
|
82
|
+
### intercept
|
|
83
|
+
|
|
84
|
+
Register an interceptor at a given point in the pipeline.
|
|
85
|
+
|
|
86
|
+
**Parameters:**
|
|
87
|
+
|
|
88
|
+
| Name | Type | Required | Description |
|
|
89
|
+
|------|------|----------|-------------|
|
|
90
|
+
| `point` | `K` | ✓ | The interception point |
|
|
91
|
+
| `fn` | `InterceptorFn<InterceptorPoints[K]>` | ✓ | Middleware function receiving (ctx, next) |
|
|
92
|
+
|
|
93
|
+
**Returns:** `this`
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
49
97
|
### afterInitialize
|
|
50
98
|
|
|
51
99
|
Called immediately after the assistant is constructed. Synchronously loads the system prompt, tools, and hooks, then binds hooks as event listeners so every emitted event automatically invokes its corresponding hook.
|
|
@@ -54,22 +102,51 @@ Called immediately after the assistant is constructed. Synchronously loads the s
|
|
|
54
102
|
|
|
55
103
|
|
|
56
104
|
|
|
105
|
+
### addSystemPromptExtension
|
|
106
|
+
|
|
107
|
+
Add or update a named system prompt extension. The value is appended to the base system prompt when passed to the conversation.
|
|
108
|
+
|
|
109
|
+
**Parameters:**
|
|
110
|
+
|
|
111
|
+
| Name | Type | Required | Description |
|
|
112
|
+
|------|------|----------|-------------|
|
|
113
|
+
| `key` | `string` | ✓ | A unique identifier for this extension |
|
|
114
|
+
| `value` | `string` | ✓ | The text to append |
|
|
115
|
+
|
|
116
|
+
**Returns:** `this`
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
### removeSystemPromptExtension
|
|
121
|
+
|
|
122
|
+
Remove a named system prompt extension.
|
|
123
|
+
|
|
124
|
+
**Parameters:**
|
|
125
|
+
|
|
126
|
+
| Name | Type | Required | Description |
|
|
127
|
+
|------|------|----------|-------------|
|
|
128
|
+
| `key` | `string` | ✓ | The identifier of the extension to remove |
|
|
129
|
+
|
|
130
|
+
**Returns:** `this`
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
57
134
|
### use
|
|
58
135
|
|
|
59
|
-
Apply a setup function to this assistant.
|
|
136
|
+
Apply a setup function or a Helper instance to this assistant. When passed a function, it receives the assistant and can configure tools, hooks, event listeners, etc. When passed a Helper instance that exposes tools via toTools(), those tools are automatically added to this assistant.
|
|
60
137
|
|
|
61
138
|
**Parameters:**
|
|
62
139
|
|
|
63
140
|
| Name | Type | Required | Description |
|
|
64
141
|
|------|------|----------|-------------|
|
|
65
|
-
| `
|
|
142
|
+
| `fnOrHelper` | `((assistant: this) => void | Promise<void>) | { toTools: () => { schemas: Record<string, z.ZodType>, handlers: Record<string, Function> } } | { schemas: Record<string, z.ZodType>, handlers: Record<string, Function> }` | ✓ | Setup function or Helper instance |
|
|
66
143
|
|
|
67
144
|
**Returns:** `this`
|
|
68
145
|
|
|
69
146
|
```ts
|
|
70
147
|
assistant
|
|
71
148
|
.use(setupLogging)
|
|
72
|
-
.use(
|
|
149
|
+
.use(container.feature('git'))
|
|
73
150
|
```
|
|
74
151
|
|
|
75
152
|
|
|
@@ -82,6 +159,7 @@ Add a tool to this assistant. The tool name is derived from the handler's functi
|
|
|
82
159
|
|
|
83
160
|
| Name | Type | Required | Description |
|
|
84
161
|
|------|------|----------|-------------|
|
|
162
|
+
| `name` | `string` | ✓ | Parameter name |
|
|
85
163
|
| `handler` | `(...args: any[]) => any` | ✓ | A named function that implements the tool |
|
|
86
164
|
| `schema` | `z.ZodType` | | Optional Zod schema describing the tool's parameters |
|
|
87
165
|
|
|
@@ -142,7 +220,7 @@ Simulate a user question and assistant response by appending both messages to th
|
|
|
142
220
|
|
|
143
221
|
### loadSystemPrompt
|
|
144
222
|
|
|
145
|
-
Load the system prompt from CORE.md, applying any prepend/append options.
|
|
223
|
+
Load the system prompt from CORE.md, applying any prepend/append options. YAML frontmatter (between --- fences) is stripped from the prompt and stored in `_meta`.
|
|
146
224
|
|
|
147
225
|
**Returns:** `string`
|
|
148
226
|
|
|
@@ -200,6 +278,14 @@ Delete all history for this assistant+project.
|
|
|
200
278
|
|
|
201
279
|
|
|
202
280
|
|
|
281
|
+
### reload
|
|
282
|
+
|
|
283
|
+
Reload tools, hooks, and system prompt from disk. Useful during development or when tool/hook files have been modified and you want the assistant to pick up changes without restarting.
|
|
284
|
+
|
|
285
|
+
**Returns:** `this`
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
203
289
|
### start
|
|
204
290
|
|
|
205
291
|
Start the assistant by creating the conversation and wiring up events. The system prompt, tools, and hooks are already loaded synchronously during initialization.
|
|
@@ -241,6 +327,26 @@ Save the conversation to disk via conversationHistory.
|
|
|
241
327
|
|
|
242
328
|
|
|
243
329
|
|
|
330
|
+
### subagent
|
|
331
|
+
|
|
332
|
+
Get or create a subagent assistant. Uses the assistantsManager to discover and create the assistant, then caches the instance for reuse across tool calls.
|
|
333
|
+
|
|
334
|
+
**Parameters:**
|
|
335
|
+
|
|
336
|
+
| Name | Type | Required | Description |
|
|
337
|
+
|------|------|----------|-------------|
|
|
338
|
+
| `id` | `string` | ✓ | The assistant name (e.g. 'codingAssistant') |
|
|
339
|
+
| `options` | `Record<string, any>` | | Additional options to pass to the assistant constructor |
|
|
340
|
+
|
|
341
|
+
**Returns:** `Promise<Assistant>`
|
|
342
|
+
|
|
343
|
+
```ts
|
|
344
|
+
const researcher = await assistant.subagent('codingAssistant')
|
|
345
|
+
const answer = await researcher.ask('Find all usages of container.feature("fs")')
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
244
350
|
## Getters
|
|
245
351
|
|
|
246
352
|
| Property | Type | Description |
|
|
@@ -255,16 +361,21 @@ Save the conversation to disk via conversationHistory.
|
|
|
255
361
|
| `resolvedDocsFolder` | `any` | |
|
|
256
362
|
| `contentDb` | `ContentDb` | Returns an instance of a ContentDb feature for the resolved docs folder |
|
|
257
363
|
| `conversation` | `Conversation` | |
|
|
364
|
+
| `availableTools` | `any` | |
|
|
258
365
|
| `messages` | `any` | |
|
|
259
366
|
| `isStarted` | `boolean` | Whether the assistant has been started and is ready to receive questions. |
|
|
260
367
|
| `systemPrompt` | `string` | The current system prompt text. |
|
|
368
|
+
| `systemPromptExtensions` | `Record<string, string>` | The named extensions appended to the system prompt. |
|
|
369
|
+
| `effectiveSystemPrompt` | `string` | The system prompt with all extensions appended. This is the value passed to the conversation. |
|
|
261
370
|
| `tools` | `Record<string, ConversationTool>` | The tools registered with this assistant. |
|
|
371
|
+
| `meta` | `Record<string, any>` | Parsed YAML frontmatter from CORE.md, or empty object if none. |
|
|
262
372
|
| `paths` | `any` | Provides a helper for creating paths off of the assistant's base folder |
|
|
263
373
|
| `assistantName` | `string` | The assistant name derived from the folder basename. |
|
|
264
374
|
| `cwdHash` | `string` | An 8-char hash of the container cwd for per-project thread isolation. |
|
|
265
375
|
| `threadPrefix` | `string` | The thread prefix for this assistant+project combination. |
|
|
266
376
|
| `conversationHistory` | `ConversationHistory` | The conversationHistory feature instance. |
|
|
267
377
|
| `currentThreadId` | `string | undefined` | The active thread ID (undefined in lifecycle mode). |
|
|
378
|
+
| `availableSubagents` | `string[]` | Names of assistants available as subagents, discovered via the assistantsManager. |
|
|
268
379
|
|
|
269
380
|
## Events (Zod v4 schema)
|
|
270
381
|
|
|
@@ -274,6 +385,18 @@ Emitted immediately after the assistant loads its prompt, tools, and hooks.
|
|
|
274
385
|
|
|
275
386
|
|
|
276
387
|
|
|
388
|
+
### systemPromptExtensionsChanged
|
|
389
|
+
|
|
390
|
+
Emitted when system prompt extensions are added or removed
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
### toolsChanged
|
|
395
|
+
|
|
396
|
+
Event emitted by Assistant
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
|
|
277
400
|
### hookFired
|
|
278
401
|
|
|
279
402
|
Emitted when a hook function is called
|
|
@@ -286,6 +409,12 @@ Emitted when a hook function is called
|
|
|
286
409
|
|
|
287
410
|
|
|
288
411
|
|
|
412
|
+
### reloaded
|
|
413
|
+
|
|
414
|
+
Emitted after tools, hooks, and system prompt are reloaded from disk
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
289
418
|
### turnStart
|
|
290
419
|
|
|
291
420
|
Emitted when a new completion turn begins. isFollowUp is true when resuming after tool calls
|
|
@@ -435,6 +564,15 @@ Event emitted by Assistant
|
|
|
435
564
|
| `docsFolder` | `string` | The resolved docs folder |
|
|
436
565
|
| `conversationId` | `string` | The active conversation persistence ID |
|
|
437
566
|
| `threadId` | `string` | The active thread ID |
|
|
567
|
+
| `systemPrompt` | `string` | The loaded system prompt text |
|
|
568
|
+
| `systemPromptExtensions` | `object` | Named extensions appended to the system prompt |
|
|
569
|
+
| `meta` | `object` | Parsed YAML frontmatter from CORE.md |
|
|
570
|
+
| `tools` | `object` | Registered tool implementations |
|
|
571
|
+
| `hooks` | `object` | Loaded event hook functions |
|
|
572
|
+
| `resumeThreadId` | `string` | Thread ID override for resume |
|
|
573
|
+
| `pendingPlugins` | `array` | Pending async plugin promises |
|
|
574
|
+
| `conversation` | `any` | The active Conversation feature instance |
|
|
575
|
+
| `subagents` | `object` | Cached subagent instances |
|
|
438
576
|
|
|
439
577
|
## Examples
|
|
440
578
|
|
|
@@ -454,7 +592,7 @@ const answer = await assistant.ask('What capabilities do you have?')
|
|
|
454
592
|
```ts
|
|
455
593
|
assistant
|
|
456
594
|
.use(setupLogging)
|
|
457
|
-
.use(
|
|
595
|
+
.use(container.feature('git'))
|
|
458
596
|
```
|
|
459
597
|
|
|
460
598
|
|
|
@@ -475,3 +613,12 @@ assistant.addTool(function getWeather(args) {
|
|
|
475
613
|
const answer = await assistant.ask('What capabilities do you have?')
|
|
476
614
|
```
|
|
477
615
|
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
**subagent**
|
|
619
|
+
|
|
620
|
+
```ts
|
|
621
|
+
const researcher = await assistant.subagent('codingAssistant')
|
|
622
|
+
const answer = await researcher.ask('Find all usages of container.feature("fs")')
|
|
623
|
+
```
|
|
624
|
+
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
# AssistantsManager (features.assistantsManager)
|
|
2
2
|
|
|
3
|
-
Discovers and manages assistant definitions by
|
|
3
|
+
Discovers and manages assistant definitions by looking for subdirectories in two locations: ~/.luca/assistants/ and cwd/assistants/. Each subdirectory containing a CORE.md is treated as an assistant definition. Use `discover()` to scan for available assistants, `list()` to enumerate them, and `create(name)` to instantiate one as a running Assistant feature.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
|
-
container.feature('assistantsManager'
|
|
9
|
-
// Automatically discover assistants on init
|
|
10
|
-
autoDiscover,
|
|
11
|
-
})
|
|
8
|
+
container.feature('assistantsManager')
|
|
12
9
|
```
|
|
13
10
|
|
|
14
|
-
##
|
|
11
|
+
## Methods
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|----------|------|-------------|
|
|
18
|
-
| `autoDiscover` | `boolean` | Automatically discover assistants on init |
|
|
13
|
+
### discover
|
|
19
14
|
|
|
20
|
-
|
|
15
|
+
Discovers assistants by listing subdirectories in ~/.luca/assistants/ and cwd/assistants/. Each subdirectory containing a CORE.md is an assistant.
|
|
21
16
|
|
|
22
|
-
|
|
17
|
+
**Returns:** `Promise<this>`
|
|
23
18
|
|
|
24
|
-
**Returns:** `void`
|
|
25
19
|
|
|
26
20
|
|
|
21
|
+
### downloadLucaCoreAssistants
|
|
27
22
|
|
|
28
|
-
|
|
23
|
+
Downloads the core assistants that ship with luca from GitHub into ~/.luca/assistants.
|
|
29
24
|
|
|
30
|
-
|
|
25
|
+
**Returns:** `Promise<{ files: string[]`
|
|
31
26
|
|
|
32
|
-
|
|
27
|
+
```ts
|
|
28
|
+
const manager = container.feature('assistantsManager')
|
|
29
|
+
await manager.downloadLucaCoreAssistants()
|
|
30
|
+
await manager.discover()
|
|
31
|
+
console.log(manager.available)
|
|
32
|
+
```
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
@@ -49,27 +49,52 @@ Looks up a single assistant entry by name.
|
|
|
49
49
|
|
|
50
50
|
| Name | Type | Required | Description |
|
|
51
51
|
|------|------|----------|-------------|
|
|
52
|
-
| `name` | `string` | ✓ | The assistant name (e.g. '
|
|
52
|
+
| `name` | `string` | ✓ | The assistant name (e.g. 'chief-of-staff') |
|
|
53
53
|
|
|
54
54
|
**Returns:** `AssistantEntry | undefined`
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
|
|
58
|
+
### register
|
|
59
|
+
|
|
60
|
+
Registers a factory function that creates an assistant at runtime. Registered factories take precedence over discovered entries when calling `create()`.
|
|
61
|
+
|
|
62
|
+
**Parameters:**
|
|
63
|
+
|
|
64
|
+
| Name | Type | Required | Description |
|
|
65
|
+
|------|------|----------|-------------|
|
|
66
|
+
| `id` | `string` | ✓ | The assistant identifier |
|
|
67
|
+
| `factory` | `(options: Record<string, any>) => Assistant` | ✓ | Factory function that receives create options and returns an Assistant |
|
|
68
|
+
|
|
69
|
+
**Returns:** `this`
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
manager.register('custom-bot', (options) => {
|
|
73
|
+
return container.feature('assistant', {
|
|
74
|
+
systemPrompt: 'You are a custom bot.',
|
|
75
|
+
...options,
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
const bot = manager.create('custom-bot')
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
58
83
|
### create
|
|
59
84
|
|
|
60
|
-
Creates and returns a new Assistant feature instance for the given name. The assistant is configured with the discovered folder path. Any additional options are merged in.
|
|
85
|
+
Creates and returns a new Assistant feature instance for the given name. Checks runtime-registered factories first, then falls back to discovered entries. The assistant is configured with the discovered folder path. Any additional options are merged in.
|
|
61
86
|
|
|
62
87
|
**Parameters:**
|
|
63
88
|
|
|
64
89
|
| Name | Type | Required | Description |
|
|
65
90
|
|------|------|----------|-------------|
|
|
66
|
-
| `name` | `string` | ✓ | The assistant name (must match a discovered entry) |
|
|
91
|
+
| `name` | `string` | ✓ | The assistant name (must match a registered factory or discovered entry) |
|
|
67
92
|
| `options` | `Record<string, any>` | | Additional options to pass to the Assistant constructor |
|
|
68
93
|
|
|
69
94
|
**Returns:** `Assistant`
|
|
70
95
|
|
|
71
96
|
```ts
|
|
72
|
-
const assistant = manager.create('
|
|
97
|
+
const assistant = manager.create('chief-of-staff', { model: 'gpt-4.1' })
|
|
73
98
|
```
|
|
74
99
|
|
|
75
100
|
|
|
@@ -100,6 +125,9 @@ Generates a markdown summary of all discovered assistants, listing their names a
|
|
|
100
125
|
|
|
101
126
|
| Property | Type | Description |
|
|
102
127
|
|----------|------|-------------|
|
|
128
|
+
| `entries` | `Record<string, AssistantEntry>` | Discovered assistant entries keyed by name. |
|
|
129
|
+
| `instances` | `Record<string, Assistant>` | Active assistant instances keyed by name. |
|
|
130
|
+
| `factories` | `Record<string, (options: Record<string, any>) => Assistant>` | Registered factory functions keyed by name. |
|
|
103
131
|
| `available` | `any` | |
|
|
104
132
|
|
|
105
133
|
## Events (Zod v4 schema)
|
|
@@ -110,6 +138,18 @@ Emitted when assistant discovery scan completes
|
|
|
110
138
|
|
|
111
139
|
|
|
112
140
|
|
|
141
|
+
### assistantRegistered
|
|
142
|
+
|
|
143
|
+
Emitted when an assistant factory is registered at runtime
|
|
144
|
+
|
|
145
|
+
**Event Arguments:**
|
|
146
|
+
|
|
147
|
+
| Name | Type | Description |
|
|
148
|
+
|------|------|-------------|
|
|
149
|
+
| `arg0` | `string` | The assistant id |
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
113
153
|
### assistantCreated
|
|
114
154
|
|
|
115
155
|
Emitted when a new assistant instance is created
|
|
@@ -131,6 +171,9 @@ Emitted when a new assistant instance is created
|
|
|
131
171
|
| `discovered` | `boolean` | Whether discovery has been run |
|
|
132
172
|
| `assistantCount` | `number` | Number of discovered assistant definitions |
|
|
133
173
|
| `activeCount` | `number` | Number of currently instantiated assistants |
|
|
174
|
+
| `entries` | `object` | Discovered assistant entries keyed by name |
|
|
175
|
+
| `instances` | `object` | Active assistant instances keyed by name |
|
|
176
|
+
| `factories` | `object` | Registered factory functions keyed by name |
|
|
134
177
|
|
|
135
178
|
## Examples
|
|
136
179
|
|
|
@@ -139,16 +182,41 @@ Emitted when a new assistant instance is created
|
|
|
139
182
|
```ts
|
|
140
183
|
const manager = container.feature('assistantsManager')
|
|
141
184
|
manager.discover()
|
|
142
|
-
console.log(manager.list()) // [{ name: '
|
|
143
|
-
const assistant = manager.create('
|
|
185
|
+
console.log(manager.list()) // [{ name: 'chief-of-staff', folder: '...', ... }]
|
|
186
|
+
const assistant = manager.create('chief-of-staff')
|
|
144
187
|
const answer = await assistant.ask('Hello!')
|
|
145
188
|
```
|
|
146
189
|
|
|
147
190
|
|
|
148
191
|
|
|
192
|
+
**downloadLucaCoreAssistants**
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
const manager = container.feature('assistantsManager')
|
|
196
|
+
await manager.downloadLucaCoreAssistants()
|
|
197
|
+
await manager.discover()
|
|
198
|
+
console.log(manager.available)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
**register**
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
manager.register('custom-bot', (options) => {
|
|
207
|
+
return container.feature('assistant', {
|
|
208
|
+
systemPrompt: 'You are a custom bot.',
|
|
209
|
+
...options,
|
|
210
|
+
})
|
|
211
|
+
})
|
|
212
|
+
const bot = manager.create('custom-bot')
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
149
217
|
**create**
|
|
150
218
|
|
|
151
219
|
```ts
|
|
152
|
-
const assistant = manager.create('
|
|
220
|
+
const assistant = manager.create('chief-of-staff', { model: 'gpt-4.1' })
|
|
153
221
|
```
|
|
154
222
|
|