@octavus/core 0.2.0 → 2.0.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/README.md +101 -0
- package/dist/index.d.ts +1028 -761
- package/dist/index.js +223 -10
- package/dist/index.js.map +1 -1
- package/package.json +17 -5
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# @octavus/core
|
|
2
|
+
|
|
3
|
+
Shared types and utilities for Octavus SDK communication.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @octavus/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
This package provides the foundational types and utilities shared between `@octavus/server-sdk` and `@octavus/client-sdk`. Most users won't need to install this package directly—it's automatically included as a dependency of the SDK packages.
|
|
14
|
+
|
|
15
|
+
## What's Included
|
|
16
|
+
|
|
17
|
+
### Stream Event Types
|
|
18
|
+
|
|
19
|
+
Types for all streaming events in Octavus agent communication:
|
|
20
|
+
|
|
21
|
+
- **Lifecycle events**: `StartEvent`, `FinishEvent`, `ErrorEvent`
|
|
22
|
+
- **Text events**: `TextStartEvent`, `TextDeltaEvent`, `TextEndEvent`
|
|
23
|
+
- **Reasoning events**: `ReasoningStartEvent`, `ReasoningDeltaEvent`, `ReasoningEndEvent`
|
|
24
|
+
- **Tool events**: `ToolInputStartEvent`, `ToolInputAvailableEvent`, `ToolOutputAvailableEvent`, etc.
|
|
25
|
+
- **Source events**: `SourceUrlEvent`, `SourceDocumentEvent`
|
|
26
|
+
- **Octavus events**: `BlockStartEvent`, `BlockEndEvent`, `ResourceUpdateEvent`, `ToolRequestEvent`, `FileAvailableEvent`
|
|
27
|
+
|
|
28
|
+
### UI Message Types
|
|
29
|
+
|
|
30
|
+
Types for rendering agent messages in your application:
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import type { UIMessage, UIMessagePart, UITextPart, UIToolCallPart } from '@octavus/core';
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Error Handling
|
|
37
|
+
|
|
38
|
+
Structured error types with classification for proper UI handling:
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import {
|
|
42
|
+
OctavusError,
|
|
43
|
+
isRateLimitError,
|
|
44
|
+
isAuthenticationError,
|
|
45
|
+
isProviderError,
|
|
46
|
+
isToolError,
|
|
47
|
+
isRetryableError,
|
|
48
|
+
isValidationError,
|
|
49
|
+
} from '@octavus/core';
|
|
50
|
+
|
|
51
|
+
// Handle errors based on type
|
|
52
|
+
if (isRateLimitError(error)) {
|
|
53
|
+
showRetryUI(error.retryAfter);
|
|
54
|
+
} else if (isAuthenticationError(error)) {
|
|
55
|
+
redirectToLogin();
|
|
56
|
+
} else if (isValidationError(error)) {
|
|
57
|
+
showValidationError(error.message);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Utilities
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { generateId, isAbortError, isOtherThread } from '@octavus/core';
|
|
65
|
+
|
|
66
|
+
// Generate unique IDs
|
|
67
|
+
const id = generateId(); // "1702345678901-abc123def"
|
|
68
|
+
|
|
69
|
+
// Check if error is from abort signal
|
|
70
|
+
if (isAbortError(error)) {
|
|
71
|
+
// User cancelled the request
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Check if message part belongs to a non-main thread
|
|
75
|
+
if (isOtherThread(part)) {
|
|
76
|
+
// Render differently for secondary threads
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Zod Schemas
|
|
81
|
+
|
|
82
|
+
Validation schemas for runtime type checking:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { safeParseStreamEvent, safeParseUIMessage } from '@octavus/core';
|
|
86
|
+
|
|
87
|
+
const result = safeParseStreamEvent(data);
|
|
88
|
+
if (result.success) {
|
|
89
|
+
handleEvent(result.data);
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Related Packages
|
|
94
|
+
|
|
95
|
+
- [`@octavus/server-sdk`](https://www.npmjs.com/package/@octavus/server-sdk) - Server-side SDK
|
|
96
|
+
- [`@octavus/client-sdk`](https://www.npmjs.com/package/@octavus/client-sdk) - Client-side SDK
|
|
97
|
+
- [`@octavus/react`](https://www.npmjs.com/package/@octavus/react) - React hooks and bindings
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
MIT
|