@connekz/connekz-agent 1.4.1 → 1.5.1

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/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ## [1.4.1] - 2026-03-25 (Patch Release)
1
+ ## [1.5.1] - 2026-04-01 (Patch Release)
2
2
 
3
3
  ### Added
4
4
 
@@ -8,15 +8,20 @@
8
8
 
9
9
  ### Security
10
10
 
11
- ## [1.4.0] - 2026-03-25 (Minor Release)
11
+ ## [1.5.0] - 2026-04-01 (Minor Release)
12
12
 
13
- ### Added
13
+ ### Security
14
+ - Security enhancements
14
15
 
15
- ### Changed
16
+ ## [1.4.1] - 2026-03-25 (Patch Release)
16
17
 
17
- ### Fixed
18
+ ### Added
19
+ - On-demand tools and memory support
20
+
21
+ ## [1.4.0] - 2026-03-25 (Minor Release)
18
22
 
19
23
  ### Security
24
+ - Security enhancements
20
25
 
21
26
  ## [1.3.7] - 2026-02-24 (Patch Release)
22
27
 
package/README.md CHANGED
@@ -333,3 +333,110 @@ async function handleToolCall(tool: ConnekzToolCallPayload): Promise<string> {
333
333
  ### Tool Call Response:
334
334
  Always return a string (plain text or JSON.stringify for structured data).
335
335
 
336
+ ---
337
+
338
+ ## On-Demand Tools & Memories (v1.5.0+)
339
+
340
+ By default, tools and memories are loaded automatically via semantic search based on conversation context. With **on-demand loading**, you can explicitly control which tools and memories are available in a session.
341
+
342
+ ### Setup
343
+
344
+ 1. In the Connekz developer portal, create a tool or memory and set **Load Mode** to `On-Demand`.
345
+ 2. Assign a unique **Slug** (e.g., `navigate-dashboard`, `onboarding-context`).
346
+ 3. From your app, call `setSessionTools()` with an array of slugs to load.
347
+
348
+ ### Usage
349
+
350
+ ```typescript
351
+ // Load specific tools and memories into the active session
352
+ connekzInstance.connekzAgent.setSessionTools([
353
+ 'navigate-to-page',
354
+ 'fill-form-field',
355
+ 'onboarding-welcome-context',
356
+ ]);
357
+
358
+ // Replace with a different set (previous on-demand items are removed)
359
+ connekzInstance.connekzAgent.setSessionTools([
360
+ 'dashboard-tools',
361
+ 'search-products',
362
+ ]);
363
+
364
+ // Clear all on-demand tools/memories
365
+ connekzInstance.connekzAgent.setSessionTools([]);
366
+ ```
367
+
368
+ ### How It Works
369
+
370
+ - **Auto tools/memories** (default): Loaded via semantic search every conversation turn. Best for general-purpose knowledge.
371
+ - **On-demand tools/memories**: Only loaded when your app explicitly requests them by slug. Not included in semantic search results.
372
+ - Both types run in parallel — auto and on-demand items are merged in the active session.
373
+ - Calling `setSessionTools()` again replaces the previous on-demand set.
374
+ - Max 30 slugs per call.
375
+
376
+ ### Server Confirmation
377
+
378
+ The server emits a `session-tools-updated` event (via `cnkz-voice-agent` channel) with:
379
+ ```json
380
+ { "type": "session-tools-updated", "data": { "tools": ["tool-name-1"], "memories": 2 } }
381
+ ```
382
+
383
+ ---
384
+
385
+ ## Developer API: Usage Tracking
386
+
387
+ ### Get Total Token Usage
388
+
389
+ Retrieve aggregated token usage for your instance within a date range (max 1 month).
390
+
391
+ ```
392
+ GET /api/v1/developer/usage/total
393
+ ```
394
+
395
+ **Headers:**
396
+ ```
397
+ Authorization: Bearer <your-secret-key>
398
+ X-Client-Id: <your-client-id>
399
+ ```
400
+
401
+ **Query Parameters:**
402
+ | Param | Required | Description |
403
+ |-------|----------|-------------|
404
+ | `startDate` | Yes | ISO 8601 date (e.g., `2026-04-01`) |
405
+ | `endDate` | Yes | ISO 8601 date (e.g., `2026-04-30`) |
406
+ | `userIdentity` | No | Filter by guest user identity |
407
+
408
+ **Response:**
409
+ ```json
410
+ {
411
+ "totalConnekzTokens": 142.5,
412
+ "sessionCount": 47,
413
+ "periodStart": "2026-04-01",
414
+ "periodEnd": "2026-04-30"
415
+ }
416
+ ```
417
+
418
+ **With userIdentity filter:**
419
+ ```json
420
+ {
421
+ "totalConnekzTokens": 12.3,
422
+ "sessionCount": 5,
423
+ "periodStart": "2026-04-01",
424
+ "periodEnd": "2026-04-30",
425
+ "userIdentity": "user-abc-123"
426
+ }
427
+ ```
428
+
429
+ ### User Identity Tracking
430
+
431
+ When initializing the agent with `userIdentity`, all token usage is tagged with that identity:
432
+
433
+ ```typescript
434
+ const instance = init({
435
+ clientId: 'your-client-id',
436
+ clientSecret: 'your-secret',
437
+ userIdentity: 'user-abc-123', // Tagged on all usage records
438
+ });
439
+ ```
440
+
441
+ This allows per-user usage tracking on shared instances (e.g., onboarding flows where multiple users share one instance).
442
+