@juspay/neurolink 10.5.3 → 10.6.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.
Files changed (96) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/agent/agent.js +39 -8
  3. package/dist/agent/agentNetwork.js +62 -20
  4. package/dist/agent/agentToolRegistrar.d.ts +48 -0
  5. package/dist/agent/agentToolRegistrar.js +336 -0
  6. package/dist/agent/index.d.ts +3 -0
  7. package/dist/agent/index.js +4 -0
  8. package/dist/agent/isolatedAgentRunner.d.ts +73 -0
  9. package/dist/agent/isolatedAgentRunner.js +946 -0
  10. package/dist/agent/structuredRecovery.d.ts +30 -0
  11. package/dist/agent/structuredRecovery.js +104 -0
  12. package/dist/browser/neurolink.min.js +414 -398
  13. package/dist/cli/loop/optionsSchema.d.ts +1 -1
  14. package/dist/core/baseProvider.d.ts +8 -0
  15. package/dist/core/baseProvider.js +40 -19
  16. package/dist/core/modules/GenerationHandler.d.ts +2 -6
  17. package/dist/core/modules/GenerationHandler.js +10 -1
  18. package/dist/core/toolExecutionRecorder.d.ts +76 -0
  19. package/dist/core/toolExecutionRecorder.js +261 -0
  20. package/dist/evaluation/contextBuilder.js +6 -6
  21. package/dist/lib/agent/agent.js +39 -8
  22. package/dist/lib/agent/agentNetwork.js +62 -20
  23. package/dist/lib/agent/agentToolRegistrar.d.ts +48 -0
  24. package/dist/lib/agent/agentToolRegistrar.js +337 -0
  25. package/dist/lib/agent/index.d.ts +3 -0
  26. package/dist/lib/agent/index.js +4 -0
  27. package/dist/lib/agent/isolatedAgentRunner.d.ts +73 -0
  28. package/dist/lib/agent/isolatedAgentRunner.js +947 -0
  29. package/dist/lib/agent/structuredRecovery.d.ts +30 -0
  30. package/dist/lib/agent/structuredRecovery.js +105 -0
  31. package/dist/lib/core/baseProvider.d.ts +8 -0
  32. package/dist/lib/core/baseProvider.js +40 -19
  33. package/dist/lib/core/modules/GenerationHandler.d.ts +2 -6
  34. package/dist/lib/core/modules/GenerationHandler.js +10 -1
  35. package/dist/lib/core/toolExecutionRecorder.d.ts +76 -0
  36. package/dist/lib/core/toolExecutionRecorder.js +262 -0
  37. package/dist/lib/evaluation/contextBuilder.js +6 -6
  38. package/dist/lib/models/modelRegistry.d.ts +23 -0
  39. package/dist/lib/models/modelRegistry.js +62 -1
  40. package/dist/lib/models/modelResolver.js +1 -0
  41. package/dist/lib/neurolink.d.ts +80 -1
  42. package/dist/lib/neurolink.js +199 -37
  43. package/dist/lib/processors/media/index.js +0 -10
  44. package/dist/lib/providers/amazonBedrock.js +15 -2
  45. package/dist/lib/providers/anthropic.js +23 -11
  46. package/dist/lib/providers/googleAiStudio.js +8 -1
  47. package/dist/lib/providers/googleNativeGemini3.d.ts +2 -0
  48. package/dist/lib/providers/googleNativeGemini3.js +8 -1
  49. package/dist/lib/providers/googleVertex.js +56 -16
  50. package/dist/lib/providers/openaiChatCompletionsClient.js +18 -5
  51. package/dist/lib/tasks/autoresearchTaskExecutor.js +7 -6
  52. package/dist/lib/tasks/taskExecutor.js +2 -5
  53. package/dist/lib/types/agentNetwork.d.ts +23 -8
  54. package/dist/lib/types/generate.d.ts +62 -5
  55. package/dist/lib/types/index.d.ts +1 -0
  56. package/dist/lib/types/index.js +1 -0
  57. package/dist/lib/types/isolatedAgent.d.ts +365 -0
  58. package/dist/lib/types/isolatedAgent.js +12 -0
  59. package/dist/lib/types/model.d.ts +8 -0
  60. package/dist/lib/types/stream.d.ts +3 -1
  61. package/dist/lib/types/task.d.ts +3 -3
  62. package/dist/lib/utils/logger.d.ts +12 -3
  63. package/dist/lib/utils/logger.js +11 -3
  64. package/dist/lib/utils/transformationUtils.d.ts +14 -0
  65. package/dist/lib/utils/transformationUtils.js +33 -10
  66. package/dist/lib/voice/livekit/realtimeVoiceAgent.js +6 -3
  67. package/dist/models/modelRegistry.d.ts +23 -0
  68. package/dist/models/modelRegistry.js +62 -1
  69. package/dist/models/modelResolver.js +1 -0
  70. package/dist/neurolink.d.ts +80 -1
  71. package/dist/neurolink.js +199 -37
  72. package/dist/processors/media/index.js +0 -10
  73. package/dist/providers/amazonBedrock.js +15 -2
  74. package/dist/providers/anthropic.js +23 -11
  75. package/dist/providers/googleAiStudio.js +8 -1
  76. package/dist/providers/googleNativeGemini3.d.ts +2 -0
  77. package/dist/providers/googleNativeGemini3.js +8 -1
  78. package/dist/providers/googleVertex.js +56 -16
  79. package/dist/providers/openaiChatCompletionsClient.js +18 -5
  80. package/dist/tasks/autoresearchTaskExecutor.js +7 -6
  81. package/dist/tasks/taskExecutor.js +2 -5
  82. package/dist/types/agentNetwork.d.ts +23 -8
  83. package/dist/types/generate.d.ts +62 -5
  84. package/dist/types/index.d.ts +1 -0
  85. package/dist/types/index.js +1 -0
  86. package/dist/types/isolatedAgent.d.ts +365 -0
  87. package/dist/types/isolatedAgent.js +11 -0
  88. package/dist/types/model.d.ts +8 -0
  89. package/dist/types/stream.d.ts +3 -1
  90. package/dist/types/task.d.ts +3 -3
  91. package/dist/utils/logger.d.ts +12 -3
  92. package/dist/utils/logger.js +11 -3
  93. package/dist/utils/transformationUtils.d.ts +14 -0
  94. package/dist/utils/transformationUtils.js +33 -10
  95. package/dist/voice/livekit/realtimeVoiceAgent.js +6 -3
  96. package/package.json +3 -2
@@ -0,0 +1,73 @@
1
+ /**
2
+ * runIsolatedAgent() — the production sub-agent runner.
3
+ *
4
+ * One function replacing what every consumer hand-rolled on top of
5
+ * generate(): a worker-mode instance (memory off, orchestration off,
6
+ * observability inherited), a tool-using research pass under the turn budget
7
+ * (wrap-up nudge + stall watchdog + honest stopReason), an extraction pass
8
+ * that ALWAYS runs tools-off on its own timeout, a structured-recovery
9
+ * ladder with corrective re-asks, a delivery guarantee (non-empty execution
10
+ * records never produce an empty result), abort chaining, a lifecycle event
11
+ * stream, leashed legs with TTL'd resume handles, and mechanical
12
+ * waste-signature detection.
13
+ *
14
+ * Behavioral contract: docs/plans/2026-07-27-isolated-agent-runner-rfc.md.
15
+ */
16
+ import type { NeuroLink } from "../neurolink.js";
17
+ import type { AgentRunOptions, AgentRunOutcome, IsolatedAgentDefinition, ToolExecutionRecord } from "../types/index.js";
18
+ /**
19
+ * True when the SAME host + caller session already has an open (live)
20
+ * leashed handle for this agent definition.
21
+ *
22
+ * Deliberately narrow: a handle belongs to the conversation that opened it,
23
+ * so the conflict only exists when the caller-supplied `sessionId` matches —
24
+ * a multi-tenant host must never refuse thread B because thread A has an
25
+ * in-flight leg (thread B cannot see, continue, or legitimately steer that
26
+ * handle). Callers without a stable sessionId get no conflict detection;
27
+ * cross-session concurrency is the delegation pool's job.
28
+ */
29
+ export declare function hasOpenIsolatedAgentHandle(host: unknown, definitionId: string, callerSessionId?: string): {
30
+ open: boolean;
31
+ handle?: string;
32
+ };
33
+ /**
34
+ * Mechanical digest of a run's execution records: which tools ran, ok/failed
35
+ * counts, and bounded excerpts of successful payloads. The delivery
36
+ * guarantee's last line of defense — a non-empty execution record can never
37
+ * produce an empty result.
38
+ */
39
+ export declare function buildMechanicalDigest(records: ToolExecutionRecord[]): {
40
+ kind: "mechanical-digest";
41
+ toolsRun: Record<string, {
42
+ calls: number;
43
+ ok: number;
44
+ failed: number;
45
+ }>;
46
+ excerpts: Array<{
47
+ toolName: string;
48
+ params: string;
49
+ resultText: string;
50
+ }>;
51
+ };
52
+ /**
53
+ * Run an isolated sub-agent: research pass with tools under the turn budget,
54
+ * extraction pass tools-off on its own timeout, structured recovery,
55
+ * delivery guarantee, abort chaining, events, and (when `options.leg` is
56
+ * set) leashed legs with a TTL'd resume handle.
57
+ */
58
+ export declare function runIsolatedAgent(host: NeuroLink, definition: IsolatedAgentDefinition, input: string | Record<string, unknown>, options?: AgentRunOptions): Promise<AgentRunOutcome>;
59
+ /**
60
+ * Resume a leashed run. `guidance`, when provided, is appended as a user
61
+ * turn before the next leg — this is how a supervisor re-steers a drifting
62
+ * worker. An expired handle returns its tombstoned final outcome once.
63
+ * Handles are owned by the host that created them; a handle with a leg
64
+ * already in flight refuses a second continuation instead of racing it.
65
+ */
66
+ export declare function continueIsolatedAgent(host: NeuroLink, handle: string, guidance?: string): Promise<AgentRunOutcome>;
67
+ /**
68
+ * Stop a leashed run: dispose the worker and return the final outcome
69
+ * (mechanical digest over everything gathered so far). Refuses while a leg
70
+ * is in flight — cancel an in-flight leg via the run's `abortSignal` instead
71
+ * of disposing its worker mid-generate.
72
+ */
73
+ export declare function stopIsolatedAgent(host: NeuroLink, handle: string): Promise<AgentRunOutcome>;