@cogitator-ai/next 0.6.1 → 0.6.2
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/README.md +13 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -164,7 +164,7 @@ Response format:
|
|
|
164
164
|
}
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
-
A run waiting for [approvals](#approvals) answers `"status": "paused"` with its `pendingApprovals`. A
|
|
167
|
+
A run waiting for [approvals](#approvals) answers `"status": "paused"` with its `pendingApprovals`. A run that fails with a `CogitatorError` answers `{ "error": message, "code": code }` with that error's status (for example `429 LLM_RATE_LIMITED`). Any other error is logged on the server and answered as `500 { "error": "Internal server error", "code": "INTERNAL_ERROR" }`, so its text (connection strings, file paths) never reaches the client. The same applies when `afterRun` throws.
|
|
168
168
|
|
|
169
169
|
### Multiple users
|
|
170
170
|
|
|
@@ -410,7 +410,7 @@ An agent with `reasoning: { summary: true }` also streams its reasoning summary
|
|
|
410
410
|
|
|
411
411
|
A run that pauses for [approvals](#approvals) sends `{"type":"approval-required","threadId":"…","approvals":[…]}` after the open block is closed and before `finish`.
|
|
412
412
|
|
|
413
|
-
If the run fails, the open text or reasoning block is closed and an `{"type":"error","message":"..."}` event is sent instead of `finish`.
|
|
413
|
+
If the run fails, the open text or reasoning block is closed and an `{"type":"error","message":"...","code":"..."}` event is sent instead of `finish`. A `CogitatorError` keeps its message and code; any other error is logged on the server and sent as `"message":"Internal server error","code":"INTERNAL_ERROR"`.
|
|
414
414
|
|
|
415
415
|
The server-side building blocks are exported for custom handlers:
|
|
416
416
|
|
|
@@ -426,6 +426,7 @@ interface ChatMessage {
|
|
|
426
426
|
id: string;
|
|
427
427
|
role: 'user' | 'assistant' | 'system';
|
|
428
428
|
content: string;
|
|
429
|
+
reasoning?: string; // reasoning summary of an assistant message
|
|
429
430
|
toolCalls?: ToolCall[];
|
|
430
431
|
metadata?: Record<string, unknown>;
|
|
431
432
|
createdAt?: Date;
|
|
@@ -444,6 +445,9 @@ interface AgentResponse {
|
|
|
444
445
|
inputTokens: number;
|
|
445
446
|
outputTokens: number;
|
|
446
447
|
totalTokens: number;
|
|
448
|
+
reasoningTokens?: number;
|
|
449
|
+
cachedInputTokens?: number;
|
|
450
|
+
cacheWriteTokens?: number;
|
|
447
451
|
};
|
|
448
452
|
toolCalls: ToolCall[];
|
|
449
453
|
trace?: { traceId: string; spans: unknown[] };
|
|
@@ -489,7 +493,9 @@ if (error) {
|
|
|
489
493
|
}
|
|
490
494
|
```
|
|
491
495
|
|
|
492
|
-
HTTP failures are thrown as `HttpError` (exported from `@cogitator-ai/next/client`) with a `status` property and a message like `Request failed: 400 - No user message provided`. Stream-level `error` events call `onError`
|
|
496
|
+
HTTP failures are thrown as `HttpError` (exported from `@cogitator-ai/next/client`) with a `status` property and a message like `Request failed: 400 - No user message provided`. Stream-level `error` events call `onError` with the event's `message` and skip `onFinish`.
|
|
497
|
+
|
|
498
|
+
On the server, a `beforeRun` that throws answers with its message and the error's `status` property (default `401`); a `parseInput` that throws answers `400`. Run failures follow the rule above: a `CogitatorError` keeps its message and `code`, anything else becomes `Internal server error` with `code: "INTERNAL_ERROR"`.
|
|
493
499
|
|
|
494
500
|
With retry enabled, transient errors (network failures, 408/429/502/503/504) are automatically retried; the backoff wait is cancelled by `stop()`:
|
|
495
501
|
|
|
@@ -517,6 +523,10 @@ if (isLoading) {
|
|
|
517
523
|
}
|
|
518
524
|
```
|
|
519
525
|
|
|
526
|
+
## Documentation
|
|
527
|
+
|
|
528
|
+
Full guide: [cogitator.app/docs/integrations/nextjs](https://cogitator.app/docs/integrations/nextjs)
|
|
529
|
+
|
|
520
530
|
## License
|
|
521
531
|
|
|
522
532
|
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cogitator-ai/next",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Next.js integration for Cogitator AI runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"node": ">=22.12.0"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@cogitator-ai/core": "0.
|
|
27
|
-
"@cogitator-ai/types": "0.
|
|
26
|
+
"@cogitator-ai/core": "0.26.0",
|
|
27
|
+
"@cogitator-ai/types": "0.29.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"next": "^14.0.0 || ^15.0.0 || ^16.0.0",
|