@getenki/ai-darwin-arm64 0.5.40 → 0.5.61

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 CHANGED
@@ -19,6 +19,7 @@ The package ships prebuilt native binaries for:
19
19
  The current package surface is:
20
20
 
21
21
  - `NativeEnkiAgent`
22
+ - `NativeToolRegistry`
22
23
  - `NativeMultiAgentRuntime`
23
24
  - `NativeWorkflowRuntime`
24
25
  - `JsAgentStatus`
@@ -29,13 +30,27 @@ The current package surface is:
29
30
  - `JsAgentRunResult`
30
31
  - `JsExecutionStep`
31
32
 
32
- `NativeEnkiAgent` is the main entrypoint. It can be created in four modes:
33
+ `NativeEnkiAgent` is the main entrypoint. It can be created in five modes:
33
34
 
34
35
  - `new(...)` for a plain agent
35
36
  - `NativeEnkiAgent.withTools(...)`
37
+ - `NativeEnkiAgent.withToolRegistry(...)`
36
38
  - `NativeEnkiAgent.withMemory(...)`
37
39
  - `NativeEnkiAgent.withToolsAndMemory(...)`
38
40
 
41
+ `NativeToolRegistry` supports:
42
+
43
+ - `new(...)`
44
+ - `registerTools(...)`
45
+ - `clear()`
46
+ - `toolNames()`
47
+ - `size`
48
+
49
+ It also supports two loop customization levels:
50
+
51
+ - `agenticLoop` constructor arguments for prompt-level loop customization
52
+ - `setAgentLoopHandler(...)` for a JavaScript-defined loop override
53
+
39
54
  `NativeMultiAgentRuntime` supports:
40
55
 
41
56
  - `new(...)`
@@ -101,9 +116,70 @@ Constructor arguments:
101
116
  - `model?: string`
102
117
  - `maxIterations?: number`
103
118
  - `workspaceHome?: string`
119
+ - `agenticLoop?: string`
104
120
 
105
121
  If omitted, the runtime falls back to built-in defaults for name, prompt, and max iterations.
106
122
 
123
+ ## Custom Agentic Loops
124
+
125
+ Use the optional `agenticLoop` argument when you want to replace the default loop instructions seen by the model but still keep the normal Rust runtime loop:
126
+
127
+ ```js
128
+ const { NativeEnkiAgent } = require('@getenki/ai')
129
+
130
+ const agent = new NativeEnkiAgent(
131
+ 'Assistant',
132
+ 'Answer clearly and keep responses short.',
133
+ 'ollama::qwen3.5:latest',
134
+ 20,
135
+ process.cwd(),
136
+ [
137
+ '1. Understand the request.',
138
+ '2. Decide whether a tool is needed.',
139
+ '3. Summarize observations.',
140
+ '4. Return the final answer.',
141
+ ].join('\n'),
142
+ )
143
+ ```
144
+
145
+ Use `setAgentLoopHandler(...)` when you want JavaScript to own the loop itself:
146
+
147
+ ```js
148
+ const { NativeEnkiAgent } = require('@getenki/ai')
149
+
150
+ const agent = new NativeEnkiAgent(
151
+ 'Assistant',
152
+ 'Answer clearly and keep responses short.',
153
+ 'ollama::qwen3.5:latest',
154
+ 8,
155
+ process.cwd(),
156
+ )
157
+
158
+ agent.setAgentLoopHandler((requestJson) => {
159
+ const request = JSON.parse(requestJson)
160
+ return JSON.stringify({
161
+ content: `Handled in JavaScript for: ${request.user_message}`,
162
+ steps: [
163
+ {
164
+ index: 1,
165
+ phase: 'Custom',
166
+ kind: 'final',
167
+ detail: 'Returned a final answer from JavaScript',
168
+ },
169
+ ],
170
+ })
171
+ })
172
+ ```
173
+
174
+ The handler receives a JSON request containing the current transcript, system prompt, tool catalog, model, iteration limit, and workspace paths.
175
+
176
+ Use `clearAgentLoopHandler()` to restore the default runtime loop.
177
+
178
+ Repository examples:
179
+
180
+ - [`example/basic-js/custom-agent-loop.js`](/I:/projects/enki/core-next/example/basic-js/custom-agent-loop.js)
181
+ - [`example/basic-js/react-custom-agent-loop.js`](/I:/projects/enki/core-next/example/basic-js/react-custom-agent-loop.js)
182
+
107
183
  ## Tools
108
184
 
109
185
  Tools can be attached with `NativeEnkiAgent.withTools(...)`. Each tool object must provide:
@@ -224,6 +300,79 @@ Instead of putting `execute` on every tool, you can pass a shared `toolHandler`
224
300
  - `workspaceDir`
225
301
  - `sessionsDir`
226
302
 
303
+ ### Reusable Tool Registries
304
+
305
+ If you want to manage a shared pool of tools and attach it to multiple agents later, create a `NativeToolRegistry` and connect it dynamically:
306
+
307
+ ```js
308
+ const { NativeEnkiAgent, NativeToolRegistry } = require('@getenki/ai')
309
+
310
+ const registry = new NativeToolRegistry()
311
+ registry.registerTools(
312
+ [
313
+ {
314
+ name: 'lookup_release',
315
+ description: 'Return a canned release note.',
316
+ parametersJson: JSON.stringify({
317
+ type: 'object',
318
+ properties: {
319
+ version: { type: 'string' },
320
+ },
321
+ required: ['version'],
322
+ }),
323
+ },
324
+ ],
325
+ (toolName, inputJson) => JSON.stringify({ toolName, inputJson }),
326
+ )
327
+
328
+ const agent = new NativeEnkiAgent(
329
+ 'Registry Agent',
330
+ 'Use connected tools when they help.',
331
+ 'ollama::qwen3.5:latest',
332
+ 20,
333
+ process.cwd(),
334
+ )
335
+
336
+ agent.connectToolRegistry(registry)
337
+ ```
338
+
339
+ You can also construct the agent directly from a registry with `NativeEnkiAgent.withToolRegistry(...)`.
340
+
341
+ This is the cleanest path when multiple agents should share the same tool catalog or when tools need to be connected after agent construction.
342
+
343
+ TypeScript uses the same API:
344
+
345
+ ```ts
346
+ import { NativeEnkiAgent, NativeToolRegistry } from '@getenki/ai'
347
+
348
+ const registry = new NativeToolRegistry()
349
+ registry.registerTools(
350
+ [
351
+ {
352
+ name: 'lookup_release',
353
+ description: 'Return a canned release note.',
354
+ parameters: {
355
+ type: 'object',
356
+ properties: {
357
+ version: { type: 'string' },
358
+ },
359
+ required: ['version'],
360
+ },
361
+ },
362
+ ],
363
+ (toolName: string, inputJson: string) => JSON.stringify({ toolName, inputJson }),
364
+ )
365
+
366
+ const agent = NativeEnkiAgent.withToolRegistry(
367
+ 'Registry Agent',
368
+ 'Use connected tools when they help.',
369
+ 'ollama::qwen3.5:latest',
370
+ 20,
371
+ process.cwd(),
372
+ registry,
373
+ )
374
+ ```
375
+
227
376
  ## Memory
228
377
 
229
378
  Memory modules are plain objects:
@@ -542,6 +691,9 @@ JavaScript example:
542
691
  cd example/basic-js
543
692
  npm install
544
693
  npm start
694
+ npm run start:tool-registry
695
+ npm run start:custom-agent-loop
696
+ npm run start:react-custom-agent-loop
545
697
  npm run start:multi-agent-tools-memory
546
698
  ```
547
699
 
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getenki/ai-darwin-arm64",
3
- "version": "0.5.40",
3
+ "version": "0.5.61",
4
4
  "cpu": [
5
5
  "arm64"
6
6
  ],