@juspay/neurolink 12.1.0 → 12.2.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 (41) hide show
  1. package/CHANGELOG.md +3 -3
  2. package/dist/agent/agentToolRegistrar.d.ts +30 -0
  3. package/dist/agent/agentToolRegistrar.js +72 -18
  4. package/dist/agent/backgroundCommands.d.ts +110 -0
  5. package/dist/agent/backgroundCommands.js +914 -0
  6. package/dist/agent/backgroundDelegation.d.ts +87 -0
  7. package/dist/agent/backgroundDelegation.js +753 -0
  8. package/dist/agent/gitTools.d.ts +43 -0
  9. package/dist/agent/gitTools.js +618 -0
  10. package/dist/agent/taskChecklist.d.ts +58 -0
  11. package/dist/agent/taskChecklist.js +322 -0
  12. package/dist/artifacts/artifactBanking.d.ts +57 -0
  13. package/dist/artifacts/artifactBanking.js +123 -0
  14. package/dist/artifacts/artifactStore.d.ts +36 -8
  15. package/dist/artifacts/artifactStore.js +164 -13
  16. package/dist/browser/neurolink.min.js +442 -414
  17. package/dist/constants/enums.d.ts +7 -11
  18. package/dist/constants/enums.js +6 -10
  19. package/dist/factories/providerDescriptors.js +1 -1
  20. package/dist/neurolink.d.ts +294 -3
  21. package/dist/neurolink.js +447 -4
  22. package/dist/providers/openaiChatCompletionsClient.js +6 -1
  23. package/dist/providers/openaiCompatCatalog.js +4 -9
  24. package/dist/types/artifact.d.ts +54 -0
  25. package/dist/types/backgroundCommand.d.ts +174 -0
  26. package/dist/types/backgroundCommand.js +22 -0
  27. package/dist/types/delegation.d.ts +178 -0
  28. package/dist/types/delegation.js +18 -0
  29. package/dist/types/gitTools.d.ts +69 -0
  30. package/dist/types/gitTools.js +22 -0
  31. package/dist/types/index.d.ts +5 -0
  32. package/dist/types/index.js +8 -0
  33. package/dist/types/pathSandbox.d.ts +23 -0
  34. package/dist/types/pathSandbox.js +12 -0
  35. package/dist/types/tasks.d.ts +85 -0
  36. package/dist/types/tasks.js +14 -0
  37. package/dist/types/tools.d.ts +11 -0
  38. package/dist/utils/modelChoices.js +4 -9
  39. package/dist/utils/pathSandbox.d.ts +49 -0
  40. package/dist/utils/pathSandbox.js +127 -0
  41. package/package.json +5 -1
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Async delegation (N2) — spawn a background worker, collect it later, in any
3
+ * order.
4
+ *
5
+ * Delegation through `registerAgentTool` is synchronous: the supervising
6
+ * agent's loop blocks on the worker, so four investigations cost four times
7
+ * one investigation and the supervisor sits idle while each runs. This module
8
+ * keeps the same worker machinery and changes only WHEN the caller waits.
9
+ * `spawnDelegate` records the job and returns a `workerId` immediately;
10
+ * `collectDelegates` hands back whichever worker finished FIRST, which has
11
+ * nothing to do with which was spawned first.
12
+ *
13
+ * Everything underneath already existed and is reused, not re-implemented:
14
+ *
15
+ * - `runIsolatedAgent` gives the worker a fresh session on a worker instance
16
+ * that SHARES the host's tool registry (so live MCP connections are reused),
17
+ * plus waste detection, honest stop reasons and continuation handles;
18
+ * - the process-wide delegation pool in `agentToolRegistrar` bounds
19
+ * concurrency — one pool, not a second one competing with the first;
20
+ * - `bankArtifact` (N3) writes each worker's FULL report to a file, so the
21
+ * conversation carries a bounded summary and a read-back call rather than
22
+ * a report that has been truncated into uselessness;
23
+ * - the checklist's `delegatesPending` / `delegatesReady` counters (N1) are
24
+ * fed from here, which is how the model learns "a worker finished" from any
25
+ * `tasks_list` — no polling loop, and no change to the core generate loop.
26
+ *
27
+ * @module agent/backgroundDelegation
28
+ */
29
+ import type { NeuroLink } from "../neurolink.js";
30
+ import type { ChecklistDelegateCounts, DelegateCollectRequest, DelegateCollectResult, DelegateHandle, DelegateRegistrationOptions, DelegateRuntimeSettings, DelegateSpawnOptions, MCPExecutableTool } from "../types/index.js";
31
+ /**
32
+ * Apply registration options for one host: depth ceiling, queue wait, and a
33
+ * raise (never a lowering) of the shared delegation pool.
34
+ */
35
+ export declare function configureDelegation(host: NeuroLink, options?: DelegateRegistrationOptions): DelegateRuntimeSettings;
36
+ /**
37
+ * Outstanding workers for a host's session: `pending` are still running or
38
+ * queued, `ready` finished and are waiting to be claimed. This is what feeds
39
+ * every `ChecklistToolResult`, so the model learns a worker landed from any
40
+ * `tasks_list` call.
41
+ */
42
+ export declare function delegateCounts(host: NeuroLink, sessionId?: string): ChecklistDelegateCounts;
43
+ /**
44
+ * Start a background worker and return its handle immediately — before the
45
+ * pool is waited on, and long before the worker finishes.
46
+ *
47
+ * The worker runs through `runIsolatedAgent`, so it gets a fresh session on a
48
+ * worker instance sharing this host's tool registry (live MCP connections
49
+ * included), waste detection, and an honest stop reason. Its full report is
50
+ * banked to a file when it settles; `collectDelegates` hands back the bounded
51
+ * summary and the pointer.
52
+ *
53
+ * @throws when the task is empty or the caller is already at the depth ceiling
54
+ */
55
+ export declare function spawnDelegate(host: NeuroLink, options: DelegateSpawnOptions): Promise<DelegateHandle>;
56
+ /**
57
+ * Claim finished workers.
58
+ *
59
+ * `{ mode: "any" }` returns the first worker to FINISH — spawn order is
60
+ * irrelevant. `{ mode: "all" }` returns every outstanding worker in completion
61
+ * order. `{ workerId }` waits for one named worker. Each outcome is claimed
62
+ * exactly once and then dropped, so two collects never report the same work
63
+ * twice.
64
+ *
65
+ * `waitMs: 0` polls (whatever is ready right now); omitting it waits up to the
66
+ * runtime default. `timedOut` says work was still outstanding when the call
67
+ * returned — the signal to come back later, not an error.
68
+ *
69
+ * @throws when a named workerId is unknown to this host and session
70
+ */
71
+ export declare function collectDelegates(host: NeuroLink, request: DelegateCollectRequest): Promise<DelegateCollectResult>;
72
+ /**
73
+ * Cancel background workers: one by id, or every outstanding worker this host
74
+ * spawned. Cancelled workers still settle into a claimable outcome saying they
75
+ * were cancelled — silence would leave the supervisor waiting on a worker that
76
+ * is never coming back.
77
+ *
78
+ * @returns how many workers were cancelled
79
+ */
80
+ export declare function cancelDelegates(host: NeuroLink, workerId?: string): Promise<number>;
81
+ /**
82
+ * `delegate_task` and `collect_results`, bound to `host`. Register them with
83
+ * `host.registerTool()` (see `NeuroLink.registerDelegationTools()`), never on
84
+ * the tool registry directly: only the "user-defined" category reaches the
85
+ * LLM's tool schema.
86
+ */
87
+ export declare function createDelegationTools(host: NeuroLink): Record<string, MCPExecutableTool>;