@juspay/neurolink 12.4.3 → 12.5.0
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 +3 -3
- package/dist/browser/neurolink.min.js +2 -2
- package/dist/hitl/hitlManager.d.ts +14 -0
- package/dist/hitl/hitlManager.js +16 -0
- package/dist/neurolink.d.ts +37 -0
- package/dist/neurolink.js +39 -0
- package/dist/types/hitl.d.ts +2 -0
- package/package.json +1 -1
|
@@ -97,4 +97,18 @@ export declare class HITLManager extends EventEmitter {
|
|
|
97
97
|
* Get count of pending confirmations
|
|
98
98
|
*/
|
|
99
99
|
getPendingCount(): number;
|
|
100
|
+
/**
|
|
101
|
+
* Whether a specific confirmation is still awaiting a response on this manager.
|
|
102
|
+
*
|
|
103
|
+
* A pending entry holds the `resolve`/`reject` of the suspended tool call, so it
|
|
104
|
+
* exists only in the memory of the manager that issued it. A manager constructed
|
|
105
|
+
* after the confirmation was issued — a session rebuilt from persisted state, for
|
|
106
|
+
* example — has an empty set, and `processUserResponse` for such an id logs a
|
|
107
|
+
* warning and returns without resolving anything.
|
|
108
|
+
*
|
|
109
|
+
* Callers that report an outcome back to a user should check this before treating
|
|
110
|
+
* a delivered `hitl:confirmation-response` as acted upon: the event being received
|
|
111
|
+
* says a listener existed, not that anything was waiting for it.
|
|
112
|
+
*/
|
|
113
|
+
hasPendingConfirmation(confirmationId: string): boolean;
|
|
100
114
|
}
|
package/dist/hitl/hitlManager.js
CHANGED
|
@@ -457,4 +457,20 @@ export class HITLManager extends EventEmitter {
|
|
|
457
457
|
getPendingCount() {
|
|
458
458
|
return this.pendingConfirmations.size;
|
|
459
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* Whether a specific confirmation is still awaiting a response on this manager.
|
|
462
|
+
*
|
|
463
|
+
* A pending entry holds the `resolve`/`reject` of the suspended tool call, so it
|
|
464
|
+
* exists only in the memory of the manager that issued it. A manager constructed
|
|
465
|
+
* after the confirmation was issued — a session rebuilt from persisted state, for
|
|
466
|
+
* example — has an empty set, and `processUserResponse` for such an id logs a
|
|
467
|
+
* warning and returns without resolving anything.
|
|
468
|
+
*
|
|
469
|
+
* Callers that report an outcome back to a user should check this before treating
|
|
470
|
+
* a delivered `hitl:confirmation-response` as acted upon: the event being received
|
|
471
|
+
* says a listener existed, not that anything was waiting for it.
|
|
472
|
+
*/
|
|
473
|
+
hasPendingConfirmation(confirmationId) {
|
|
474
|
+
return this.pendingConfirmations.has(confirmationId);
|
|
475
|
+
}
|
|
460
476
|
}
|
package/dist/neurolink.d.ts
CHANGED
|
@@ -1311,6 +1311,43 @@ export declare class NeuroLink {
|
|
|
1311
1311
|
* @see {@link NeuroLink.executeTool} for events related to tool execution
|
|
1312
1312
|
*/
|
|
1313
1313
|
getEventEmitter(): TypedEventEmitter<NeuroLinkEvents>;
|
|
1314
|
+
/**
|
|
1315
|
+
* Whether a HITL confirmation is still awaiting a response on THIS instance.
|
|
1316
|
+
*
|
|
1317
|
+
* Emitting `hitl:confirmation-response` is not proof the decision landed. The
|
|
1318
|
+
* forwarding listener for that event is installed once at construction, so
|
|
1319
|
+
* `emitter.emit(...)` reports a listener was invoked even when nothing is
|
|
1320
|
+
* waiting — the pending set lives one hop further in, on the HITL manager, and
|
|
1321
|
+
* holds the `resolve`/`reject` of the suspended tool call. An instance built
|
|
1322
|
+
* after the confirmation was issued (a session rebuilt from persisted state)
|
|
1323
|
+
* therefore accepts the event and resolves nothing.
|
|
1324
|
+
*
|
|
1325
|
+
* Returns `false` in two different situations, which it deliberately does not
|
|
1326
|
+
* distinguish: HITL was never configured on this instance, and the id is
|
|
1327
|
+
* unknown or already settled. Both mean "emitting a response here achieves
|
|
1328
|
+
* nothing", which is the question this answers. A caller that needs to tell a
|
|
1329
|
+
* configuration mistake from an expired confirmation should check the HITL
|
|
1330
|
+
* config separately rather than read that into this boolean.
|
|
1331
|
+
*
|
|
1332
|
+
* This is advisory, not atomic: it reports the state at the moment it is
|
|
1333
|
+
* called. Nothing stops the confirmation timing out immediately afterwards, so
|
|
1334
|
+
* emit on the answer without an `await` in between. Over the case it exists
|
|
1335
|
+
* for — an instance rebuilt from persisted state, whose pending set is empty
|
|
1336
|
+
* and can never repopulate for an id it never issued — absence cannot become
|
|
1337
|
+
* presence, so the answer cannot go stale in the unsafe direction.
|
|
1338
|
+
*
|
|
1339
|
+
* @param confirmationId - The id from the `hitl:confirmation-request` event
|
|
1340
|
+
* @returns `true` only if this instance is still holding that confirmation
|
|
1341
|
+
*
|
|
1342
|
+
* @example
|
|
1343
|
+
* ```typescript
|
|
1344
|
+
* if (!neurolink.hasPendingHITLConfirmation(confirmationId)) {
|
|
1345
|
+
* return refuse("This conversation has expired, so the action was not carried out.");
|
|
1346
|
+
* }
|
|
1347
|
+
* neurolink.getEventEmitter().emit("hitl:confirmation-response", { ... });
|
|
1348
|
+
* ```
|
|
1349
|
+
*/
|
|
1350
|
+
hasPendingHITLConfirmation(confirmationId: string): boolean;
|
|
1314
1351
|
/**
|
|
1315
1352
|
* Returns the instance-level tool-dedup configuration, or `undefined` when
|
|
1316
1353
|
* toolDedup was not provided at construction time.
|
package/dist/neurolink.js
CHANGED
|
@@ -9132,6 +9132,45 @@ Current user's request: ${currentInput}`;
|
|
|
9132
9132
|
getEventEmitter() {
|
|
9133
9133
|
return this.emitter;
|
|
9134
9134
|
}
|
|
9135
|
+
/**
|
|
9136
|
+
* Whether a HITL confirmation is still awaiting a response on THIS instance.
|
|
9137
|
+
*
|
|
9138
|
+
* Emitting `hitl:confirmation-response` is not proof the decision landed. The
|
|
9139
|
+
* forwarding listener for that event is installed once at construction, so
|
|
9140
|
+
* `emitter.emit(...)` reports a listener was invoked even when nothing is
|
|
9141
|
+
* waiting — the pending set lives one hop further in, on the HITL manager, and
|
|
9142
|
+
* holds the `resolve`/`reject` of the suspended tool call. An instance built
|
|
9143
|
+
* after the confirmation was issued (a session rebuilt from persisted state)
|
|
9144
|
+
* therefore accepts the event and resolves nothing.
|
|
9145
|
+
*
|
|
9146
|
+
* Returns `false` in two different situations, which it deliberately does not
|
|
9147
|
+
* distinguish: HITL was never configured on this instance, and the id is
|
|
9148
|
+
* unknown or already settled. Both mean "emitting a response here achieves
|
|
9149
|
+
* nothing", which is the question this answers. A caller that needs to tell a
|
|
9150
|
+
* configuration mistake from an expired confirmation should check the HITL
|
|
9151
|
+
* config separately rather than read that into this boolean.
|
|
9152
|
+
*
|
|
9153
|
+
* This is advisory, not atomic: it reports the state at the moment it is
|
|
9154
|
+
* called. Nothing stops the confirmation timing out immediately afterwards, so
|
|
9155
|
+
* emit on the answer without an `await` in between. Over the case it exists
|
|
9156
|
+
* for — an instance rebuilt from persisted state, whose pending set is empty
|
|
9157
|
+
* and can never repopulate for an id it never issued — absence cannot become
|
|
9158
|
+
* presence, so the answer cannot go stale in the unsafe direction.
|
|
9159
|
+
*
|
|
9160
|
+
* @param confirmationId - The id from the `hitl:confirmation-request` event
|
|
9161
|
+
* @returns `true` only if this instance is still holding that confirmation
|
|
9162
|
+
*
|
|
9163
|
+
* @example
|
|
9164
|
+
* ```typescript
|
|
9165
|
+
* if (!neurolink.hasPendingHITLConfirmation(confirmationId)) {
|
|
9166
|
+
* return refuse("This conversation has expired, so the action was not carried out.");
|
|
9167
|
+
* }
|
|
9168
|
+
* neurolink.getEventEmitter().emit("hitl:confirmation-response", { ... });
|
|
9169
|
+
* ```
|
|
9170
|
+
*/
|
|
9171
|
+
hasPendingHITLConfirmation(confirmationId) {
|
|
9172
|
+
return this.hitlManager?.hasPendingConfirmation(confirmationId) ?? false;
|
|
9173
|
+
}
|
|
9135
9174
|
/**
|
|
9136
9175
|
* Returns the instance-level tool-dedup configuration, or `undefined` when
|
|
9137
9176
|
* toolDedup was not provided at construction time.
|
package/dist/types/hitl.d.ts
CHANGED
|
@@ -228,6 +228,8 @@ export type HITLManager = {
|
|
|
228
228
|
cleanup(): void;
|
|
229
229
|
/** Get count of pending confirmations */
|
|
230
230
|
getPendingCount(): number;
|
|
231
|
+
/** Whether a specific confirmation is still awaiting a response on this manager */
|
|
232
|
+
hasPendingConfirmation(confirmationId: string): boolean;
|
|
231
233
|
/** EventEmitter methods for HITL events */
|
|
232
234
|
on(event: string, listener: (...args: unknown[]) => void): HITLManager;
|
|
233
235
|
emit(event: string, ...args: unknown[]): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.5.0",
|
|
4
4
|
"packageManager": "pnpm@10.15.1",
|
|
5
5
|
"description": "TypeScript AI SDK with 24+ LLM providers behind one consistent API. MCP-native (connect any MCP server), voice TTS/STT/realtime, RAG, agents, memory, context compaction. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · DeepSeek · NVIDIA NIM and more.",
|
|
6
6
|
"author": {
|