Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2746,6 +2746,7 @@ console.log(result.content);
- [DataStreamWriter](type-aliases/DataStreamWriter.md)
- [WebSocketMessageType](type-aliases/WebSocketMessageType.md)
- [WebSocketMessage](type-aliases/WebSocketMessage.md)
- [WebSocketRequestId](type-aliases/WebSocketRequestId.md)
- [AuthenticatedUser](type-aliases/AuthenticatedUser.md)
- [WebSocketConnection](type-aliases/WebSocketConnection.md)
- [AuthStrategy](type-aliases/AuthStrategy.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/api/classes/WebSocketMessageRouter.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Register a message route

##### handler

(`connection`, `payload`) => `Promise`\<`unknown`\>
(`connection`, `payload`, `requestId?`) => `Promise`\<`unknown`\>

#### Returns

Expand Down
24 changes: 20 additions & 4 deletions docs/api/functions/createAgentWebSocketHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,32 @@

# Function: createAgentWebSocketHandler()

> **createAgentWebSocketHandler**(`_neurolink`): [`WebSocketHandler`](../type-aliases/WebSocketHandler.md)
> **createAgentWebSocketHandler**(`neurolink`): [`WebSocketHandler`](../type-aliases/WebSocketHandler.md)

Create a WebSocket handler for AI agent interactions
Server Adapters for exposing NeuroLink as HTTP APIs

Supports multiple frameworks: Hono, Express, Fastify, Koa

## Parameters

### \_neurolink
### neurolink

`unknown`
[`NeuroLink`](../classes/NeuroLink.md)

## Returns

[`WebSocketHandler`](../type-aliases/WebSocketHandler.md)

## Example

```typescript
import { NeuroLink } from "@juspay/neurolink";
import { createServer } from "@juspay/neurolink/server";

const neurolink = new NeuroLink({ provider: "openai" });
const server = await createServer(neurolink, {
framework: "hono",
config: { port: 3000 },
});
await server.start();
```
10 changes: 10 additions & 0 deletions docs/api/type-aliases/StreamLoopArgs.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,13 @@ Signals the channel that no further chunks will arrive (success or error path al
#### Returns

`void`

---

### responseFormat?

> `optional` **responseFormat?**: [`OpenAICompatResponseFormat`](OpenAICompatResponseFormat.md)

`response_format` for this turn's requests, computed once up front from
`options.schema` (see `suppressResponseFormatWithTools`). Absent when no
schema was requested, or when tools suppress it.
39 changes: 39 additions & 0 deletions docs/api/type-aliases/StreamResult.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,45 @@ Verbatim provider finish/stop reason for the turn's terminal model call.

> `optional` **stepsUsed?**: `number`

#### structuredData?

> `optional` **structuredData?**: `unknown`

Parsed structured output for a `stream({ schema })` turn, available
AFTER the stream has been drained.

Lives on metadata for the same reason `finishReason` above does: it is a
mutable reference the loop fills in, so result-object spreads in stream
wrappers cannot snapshot it before it resolves. A plain field rather than
a promise, deliberately — when a middleware short-circuits the request
and the loop never runs, an unresolved promise would hang every reader,
whereas an absent field is simply absent. Readers must tolerate that:
absence means the model never produced the object.

#### structuredDataUsage?

> `optional` **structuredDataUsage?**: `object`

Tokens spent by the tool-free re-ask that produced `structuredData`,
when one was needed.

That re-ask is a second, separately-billed model call, and the stream's
own `usage` has already resolved by the time it runs — so folding these
tokens into it would mutate a value a caller may have read, and leaving
them out entirely would under-report what the turn cost. Reported here
instead: same delivery as `structuredData`, filled at the same moment,
read at the same moment. Absent when no re-ask was needed, which is the
common case. The generate path accounts for its equivalent re-ask
inline, since there the usage has not been handed out yet.

##### structuredDataUsage.inputTokens

> **inputTokens**: `number`

##### structuredDataUsage.outputTokens

> **outputTokens**: `number`

#### thoughtSignature?

> `optional` **thoughtSignature?**: `string`
Expand Down
34 changes: 34 additions & 0 deletions docs/api/type-aliases/TextGenerationOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,40 @@ module's own default, unchanged unless a caller opts in here.

---

### videoOptions?

> `optional` **videoOptions?**: `object`

Video processing options (mirrors `GenerateOptions.videoOptions`). Never
declared here before, so `buildGenerateTextOptions` had nowhere to
forward the caller's setting even once the allowlist itself named it.

#### frames?

> `optional` **frames?**: `number`

Frames to extract. Unset lets VideoProcessor pick from the clip's duration; clamped to 100.

#### quality?

> `optional` **quality?**: `number`

Frame encoder quality, clamped to 1-100. Default 80.

#### format?

> `optional` **format?**: `"jpeg"` \| `"png"`

Frame encoding. Default jpeg.

#### transcribeAudio?

> `optional` **transcribeAudio?**: `boolean`

Not implemented yet (#433) — warns rather than silently doing nothing.

---

### enableSummarization?

> `optional` **enableSummarization?**: `boolean`
Expand Down
15 changes: 15 additions & 0 deletions docs/api/type-aliases/WebSocketRequestId.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[**NeuroLink API Reference**](../README.md)

---

[NeuroLink API Reference](../README.md) / WebSocketRequestId

# Type Alias: WebSocketRequestId

> **WebSocketRequestId** = `string` \| `number`

Client-supplied correlation id on an agent-protocol WebSocket message
(`{ type, payload, id }`). Echoed back on the matching response frame so a
caller with more than one in-flight message on a connection can tell which
frame answers which request; optional and ignored entirely by a client
that never sends one.
2 changes: 1 addition & 1 deletion docs/guides/server-adapters/websocket.md
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ ws.onmessage = (event) => {
console.log("Connected:", message.connectionId);
break;
case "response":
console.log("Response:", message.data);
console.log("Response:", message.content);
break;
case "stream_start":
console.log("Stream starting...");
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"test:middleware": "pnpm exec tsx test/continuous-test-suite-middleware.ts",
"test:stream-middleware": "pnpm exec tsx test/continuous-test-suite-stream-middleware.ts",
"test:stream-tool-telemetry": "pnpm exec tsx test/continuous-test-suite-stream-tool-telemetry.ts",
"test:stream-teardown-abort": "pnpm exec tsx test/continuous-test-suite-stream-teardown-abort.ts",
"test:observability": "pnpm exec tsx test/continuous-test-suite-observability.ts",
"test:ppt": "pnpm exec tsx test/continuous-test-suite-ppt.ts",
"test:vertex-loop-characterization": "tsx test/continuous-test-suite-vertex-loop-characterization.ts",
Expand All @@ -127,6 +128,7 @@
"test:mcp:infra": "pnpm exec tsx test/continuous-test-suite-mcp-infra.ts",
"test:vendor-recovery": "pnpm exec tsx test/continuous-test-suite-native-vendor-recovery.ts",
"test:anthropic-generate-guard": "pnpm exec tsx test/continuous-test-suite-anthropic-generate-guard.ts",
"test:stream-structured-output": "pnpm exec tsx test/continuous-test-suite-stream-structured-output.ts",
"test:browser-bundle": "pnpm exec tsx test/continuous-test-suite-browser-bundle.ts",
"test:providers-mocked": "pnpm exec tsx test/continuous-test-suite-providers-mocked.ts",
"scaffold:provider": "pnpm exec tsx tools/scaffold-provider.ts",
Expand All @@ -144,8 +146,10 @@
"test:decide": "pnpm exec tsx test/continuous-test-suite-decide.ts",
"test:agent-mode": "pnpm exec tsx test/continuous-test-suite-agent-mode.ts",
"test:servers": "pnpm exec tsx test/continuous-test-suite-servers.ts",
"test:websocket-agent-handler": "pnpm exec tsx test/continuous-test-suite-websocket-agent-handler.ts",
"test:tool-reliability": "pnpm exec tsx test/continuous-test-suite-tool-reliability.ts",
"test:video-abort": "pnpm exec tsx test/continuous-test-suite-video-abort.ts",
"test:video-options-allowlist": "pnpm exec tsx test/continuous-test-suite-video-options-allowlist.ts",
"test:tts": "pnpm exec tsx test/continuous-test-suite-tts.ts",
"test:tts:unit": "pnpm exec tsx test/continuous-test-suite-tts-unit.ts",
"test:stt:unit": "pnpm exec tsx test/continuous-test-suite-stt-unit.ts",
Expand Down
1 change: 1 addition & 0 deletions src/cli/loop/optionsSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const textGenerationOptionsSchema: Record<
| "csvOptions"
| "pdfOptions"
| "imageOptions"
| "videoOptions" // Complex object, not set via simple CLI commands
| "tts"
| "stt" // Complex object, set via --stt* flags
| "thinkingConfig" // Complex object, use thinking/thinkingBudget instead
Expand Down
Loading
Loading