hareai 0.1.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 +202 -0
- package/dist/chunk-KTWGHY3T.js +102 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +96 -0
- package/dist/tools.d.ts +1 -0
- package/dist/tools.js +2 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.js +2 -0
- package/dist/workers.d.ts +4 -0
- package/dist/workers.js +101 -0
- package/package.json +91 -0
package/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# hareai
|
|
2
|
+
|
|
3
|
+
Build AI agents on Cloudflare's edge network.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install hareai
|
|
9
|
+
# or
|
|
10
|
+
bun add hareai
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Peer Dependencies
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install ai zod agents
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
### 1. Create a Simple Agent
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { createSimpleAgent, createWorkersAIModel } from 'hareai'
|
|
25
|
+
import { getSystemTools } from 'hareai/tools'
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
async fetch(request: Request, env: Env) {
|
|
29
|
+
const tools = getSystemTools({
|
|
30
|
+
env,
|
|
31
|
+
workspaceId: 'my-workspace',
|
|
32
|
+
userId: 'user-123'
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const agent = createSimpleAgent({
|
|
36
|
+
model: createWorkersAIModel({
|
|
37
|
+
modelId: '@cf/meta/llama-3.3-70b-instruct-fp8-fast',
|
|
38
|
+
ai: env.AI
|
|
39
|
+
}),
|
|
40
|
+
tools,
|
|
41
|
+
systemPrompt: 'You are a helpful assistant.'
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const response = await agent.chat('Hello!')
|
|
45
|
+
return new Response(response.text)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2. Use Durable Object Agents (Stateful)
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { HareAgent, routeToHareAgent } from 'hareai/workers'
|
|
54
|
+
|
|
55
|
+
// Export the Durable Object class
|
|
56
|
+
export { HareAgent }
|
|
57
|
+
|
|
58
|
+
export default {
|
|
59
|
+
async fetch(request: Request, env: Env) {
|
|
60
|
+
return routeToHareAgent({
|
|
61
|
+
request,
|
|
62
|
+
env,
|
|
63
|
+
agentId: 'my-agent'
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 3. Create Custom Tools
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { createTool, success, failure } from 'hareai/tools'
|
|
73
|
+
import { z } from 'zod'
|
|
74
|
+
|
|
75
|
+
const weatherTool = createTool({
|
|
76
|
+
id: 'get_weather',
|
|
77
|
+
description: 'Get current weather for a location',
|
|
78
|
+
inputSchema: z.object({
|
|
79
|
+
city: z.string().describe('City name'),
|
|
80
|
+
units: z.enum(['celsius', 'fahrenheit']).default('celsius')
|
|
81
|
+
}),
|
|
82
|
+
execute: async (params, context) => {
|
|
83
|
+
try {
|
|
84
|
+
const weather = await fetchWeather(params.city, params.units)
|
|
85
|
+
return success({ temperature: weather.temp, conditions: weather.conditions })
|
|
86
|
+
} catch (error) {
|
|
87
|
+
return failure(`Failed to fetch weather: ${error.message}`)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Entry Points
|
|
94
|
+
|
|
95
|
+
| Import Path | Description |
|
|
96
|
+
|-------------|-------------|
|
|
97
|
+
| `hareai` | Main entry - universal exports (HareEdgeAgent, tools, types) |
|
|
98
|
+
| `hareai/workers` | Workers-only exports (HareAgent, HareMcpAgent with Durable Objects) |
|
|
99
|
+
| `hareai/tools` | All 59+ tools organized by category |
|
|
100
|
+
| `hareai/types` | Complete type definitions |
|
|
101
|
+
|
|
102
|
+
## Available Tools (59+)
|
|
103
|
+
|
|
104
|
+
### Cloudflare Native (17)
|
|
105
|
+
- **KV**: `kv_get`, `kv_put`, `kv_delete`, `kv_list`
|
|
106
|
+
- **R2**: `r2_get`, `r2_put`, `r2_delete`, `r2_list`, `r2_head`
|
|
107
|
+
- **SQL**: `sql_query`, `sql_execute`, `sql_batch`
|
|
108
|
+
- **HTTP**: `http_request`, `http_get`, `http_post`
|
|
109
|
+
- **Search**: `ai_search`, `ai_search_answer`
|
|
110
|
+
|
|
111
|
+
### AI Tools (8)
|
|
112
|
+
`sentiment`, `summarize`, `translate`, `image_generate`, `classify`, `ner`, `embedding`, `question_answer`
|
|
113
|
+
|
|
114
|
+
### Utility Tools (9)
|
|
115
|
+
`datetime`, `json`, `text`, `math`, `uuid`, `hash`, `base64`, `url`, `delay`
|
|
116
|
+
|
|
117
|
+
### Data Tools (7)
|
|
118
|
+
`rss`, `scrape`, `regex`, `crypto`, `json_schema`, `csv`, `template`
|
|
119
|
+
|
|
120
|
+
### Validation Tools (6)
|
|
121
|
+
`validate_email`, `validate_phone`, `validate_url`, `validate_credit_card`, `validate_ip`, `validate_json`
|
|
122
|
+
|
|
123
|
+
### Transform Tools (5)
|
|
124
|
+
`markdown`, `diff`, `qrcode`, `compression`, `color`
|
|
125
|
+
|
|
126
|
+
### Sandbox Tools (3)
|
|
127
|
+
`code_execute`, `code_validate`, `sandbox_file`
|
|
128
|
+
|
|
129
|
+
### Memory Tools (2)
|
|
130
|
+
`store_memory`, `recall_memory` (Vectorize)
|
|
131
|
+
|
|
132
|
+
### Integration Tools (2)
|
|
133
|
+
`zapier`, `webhook`
|
|
134
|
+
|
|
135
|
+
## Wrangler Configuration
|
|
136
|
+
|
|
137
|
+
```toml
|
|
138
|
+
# wrangler.toml
|
|
139
|
+
name = "my-agent"
|
|
140
|
+
main = "src/index.ts"
|
|
141
|
+
|
|
142
|
+
[durable_objects]
|
|
143
|
+
bindings = [
|
|
144
|
+
{ name = "HARE_AGENT", class_name = "HareAgent" }
|
|
145
|
+
]
|
|
146
|
+
|
|
147
|
+
[[migrations]]
|
|
148
|
+
tag = "v1"
|
|
149
|
+
new_classes = ["HareAgent"]
|
|
150
|
+
|
|
151
|
+
[ai]
|
|
152
|
+
binding = "AI"
|
|
153
|
+
|
|
154
|
+
[[kv_namespaces]]
|
|
155
|
+
binding = "KV"
|
|
156
|
+
id = "your-kv-id"
|
|
157
|
+
|
|
158
|
+
[[d1_databases]]
|
|
159
|
+
binding = "DB"
|
|
160
|
+
database_name = "hare"
|
|
161
|
+
database_id = "your-d1-id"
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## TypeScript Types
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
import type {
|
|
168
|
+
HareAgentState,
|
|
169
|
+
ToolContext,
|
|
170
|
+
Tool,
|
|
171
|
+
AnyTool,
|
|
172
|
+
AgentConfig
|
|
173
|
+
} from 'hareai/types'
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## API Reference
|
|
177
|
+
|
|
178
|
+
### Agent Classes
|
|
179
|
+
|
|
180
|
+
- **`HareEdgeAgent`** - Universal agent (works anywhere)
|
|
181
|
+
- **`HareAgent`** - Cloudflare Durable Object agent with state persistence
|
|
182
|
+
- **`HareMcpAgent`** - MCP server agent for external AI clients
|
|
183
|
+
|
|
184
|
+
### Tool Factories
|
|
185
|
+
|
|
186
|
+
- **`createTool(config)`** - Create a type-safe tool
|
|
187
|
+
- **`getSystemTools(context)`** - Get all 59+ built-in tools
|
|
188
|
+
- **`getToolsByCategory({ category, context })`** - Get tools by category
|
|
189
|
+
|
|
190
|
+
### AI Model Providers
|
|
191
|
+
|
|
192
|
+
- **`createWorkersAIModel({ modelId, ai })`** - Create Workers AI model
|
|
193
|
+
- **`generateEmbedding({ text, model, ai })`** - Generate embeddings
|
|
194
|
+
|
|
195
|
+
### Memory Store
|
|
196
|
+
|
|
197
|
+
- **`createMemoryStore({ db })`** - Create D1-backed conversation memory
|
|
198
|
+
- **`D1MemoryStore`** - Direct memory store class
|
|
199
|
+
|
|
200
|
+
## License
|
|
201
|
+
|
|
202
|
+
MIT
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
createAgentFromConfig,
|
|
4
|
+
createAgentHeaders,
|
|
5
|
+
createEdgeAgent,
|
|
6
|
+
createHareEdgeAgent,
|
|
7
|
+
createMemoryStore,
|
|
8
|
+
createSimpleAgent,
|
|
9
|
+
createWorkersAIModel,
|
|
10
|
+
D1MemoryStore,
|
|
11
|
+
DEFAULT_HARE_AGENT_STATE,
|
|
12
|
+
DEFAULT_MCP_AGENT_STATE,
|
|
13
|
+
EdgeAgent,
|
|
14
|
+
EMBEDDING_MODELS,
|
|
15
|
+
generateEmbedding,
|
|
16
|
+
generateEmbeddings,
|
|
17
|
+
getAgentIdFromRequest,
|
|
18
|
+
getAvailableModels,
|
|
19
|
+
getWorkersAIModelId,
|
|
20
|
+
HareEdgeAgent,
|
|
21
|
+
isWebSocketRequest,
|
|
22
|
+
loadAgentTools,
|
|
23
|
+
routeHttpToAgent,
|
|
24
|
+
routeToHareAgent,
|
|
25
|
+
routeToMcpAgent,
|
|
26
|
+
routeWebSocketToAgent,
|
|
27
|
+
toAgentMessages,
|
|
28
|
+
WORKERS_AI_MODELS
|
|
29
|
+
} from "@hare/agent";
|
|
30
|
+
import {
|
|
31
|
+
createRegistry,
|
|
32
|
+
createTool,
|
|
33
|
+
delegateTo,
|
|
34
|
+
delegateToWithValidation,
|
|
35
|
+
failure,
|
|
36
|
+
getSystemTools,
|
|
37
|
+
getSystemToolsMap,
|
|
38
|
+
getToolsByCategory,
|
|
39
|
+
isSystemTool,
|
|
40
|
+
SYSTEM_TOOL_IDS,
|
|
41
|
+
success,
|
|
42
|
+
TOOL_COUNTS,
|
|
43
|
+
ToolRegistry
|
|
44
|
+
} from "@hare/tools";
|
|
45
|
+
import {
|
|
46
|
+
AgentConfigSchema,
|
|
47
|
+
AgentSchema,
|
|
48
|
+
AgentStatusSchema,
|
|
49
|
+
ApiErrorSchema,
|
|
50
|
+
ApiSuccessSchema,
|
|
51
|
+
ToolConfigSchema,
|
|
52
|
+
ToolTypeSchema
|
|
53
|
+
} from "@hare/types";
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
createAgentFromConfig,
|
|
57
|
+
createAgentHeaders,
|
|
58
|
+
createEdgeAgent,
|
|
59
|
+
createHareEdgeAgent,
|
|
60
|
+
createMemoryStore,
|
|
61
|
+
createSimpleAgent,
|
|
62
|
+
createWorkersAIModel,
|
|
63
|
+
D1MemoryStore,
|
|
64
|
+
DEFAULT_HARE_AGENT_STATE,
|
|
65
|
+
DEFAULT_MCP_AGENT_STATE,
|
|
66
|
+
EdgeAgent,
|
|
67
|
+
EMBEDDING_MODELS,
|
|
68
|
+
generateEmbedding,
|
|
69
|
+
generateEmbeddings,
|
|
70
|
+
getAgentIdFromRequest,
|
|
71
|
+
getAvailableModels,
|
|
72
|
+
getWorkersAIModelId,
|
|
73
|
+
HareEdgeAgent,
|
|
74
|
+
isWebSocketRequest,
|
|
75
|
+
loadAgentTools,
|
|
76
|
+
routeHttpToAgent,
|
|
77
|
+
routeToHareAgent,
|
|
78
|
+
routeToMcpAgent,
|
|
79
|
+
routeWebSocketToAgent,
|
|
80
|
+
toAgentMessages,
|
|
81
|
+
WORKERS_AI_MODELS,
|
|
82
|
+
createRegistry,
|
|
83
|
+
createTool,
|
|
84
|
+
delegateTo,
|
|
85
|
+
delegateToWithValidation,
|
|
86
|
+
failure,
|
|
87
|
+
getSystemTools,
|
|
88
|
+
getSystemToolsMap,
|
|
89
|
+
getToolsByCategory,
|
|
90
|
+
isSystemTool,
|
|
91
|
+
SYSTEM_TOOL_IDS,
|
|
92
|
+
success,
|
|
93
|
+
TOOL_COUNTS,
|
|
94
|
+
ToolRegistry,
|
|
95
|
+
AgentConfigSchema,
|
|
96
|
+
AgentSchema,
|
|
97
|
+
AgentStatusSchema,
|
|
98
|
+
ApiErrorSchema,
|
|
99
|
+
ApiSuccessSchema,
|
|
100
|
+
ToolConfigSchema,
|
|
101
|
+
ToolTypeSchema
|
|
102
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AgentConfig, AgentOptions, AgentRouteConfig, AgentStreamResponse, AgentTool, ChatPayload, ClientMessage, ConversationMessage, CreateAgentFromConfigInput, CreateSimpleAgentInput, CreateWorkersAIModelInput, D1MemoryStore, DEFAULT_HARE_AGENT_STATE, DEFAULT_MCP_AGENT_STATE, EMBEDDING_MODELS, EdgeAgent, EmbeddingModelId, GenerateEmbeddingInput, GenerateEmbeddingsInput, GetMessagesInput, GetOrCreateConversationInput, HareAgentEnv, HareAgentState, HareEdgeAgent, LoadAgentToolsInput, McpAgentState, MemoryStore, MessageRole, RouteHttpToAgentInput, RouteToHareAgentInput, RouteToMcpAgentInput, RouteWebSocketToAgentInput, SaveMessageInput, SchedulePayload, ScheduledTask, SearchMessagesInput, ServerMessage, ToolExecutePayload, WORKERS_AI_MODELS, WorkersAIModelId, createAgentFromConfig, createAgentHeaders, createEdgeAgent, createHareEdgeAgent, createMemoryStore, createSimpleAgent, createWorkersAIModel, generateEmbedding, generateEmbeddings, getAgentIdFromRequest, getAvailableModels, getWorkersAIModelId, isWebSocketRequest, loadAgentTools, routeHttpToAgent, routeToHareAgent, routeToMcpAgent, routeWebSocketToAgent, toAgentMessages } from '@hare/agent';
|
|
2
|
+
export { AnyTool, HareEnv, SYSTEM_TOOL_IDS, SystemToolId, TOOL_COUNTS, Tool, ToolCategory, ToolContext, ToolDefinition, ToolRegistry, ToolResult, createRegistry, createTool, delegateTo, delegateToWithValidation, failure, getSystemTools, getSystemToolsMap, getToolsByCategory, isSystemTool, success } from '@hare/tools';
|
|
3
|
+
export { Agent, AgentConfigSchema, AgentConfig as AgentConfigType, AgentSchema, AgentStatus, AgentStatusSchema, ApiError, ApiErrorSchema, ApiSuccess, ApiSuccessSchema, ToolConfig, ToolConfigSchema, ToolType, ToolTypeSchema } from '@hare/types';
|
|
4
|
+
import '@hare/agent/workers';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentConfigSchema,
|
|
3
|
+
AgentSchema,
|
|
4
|
+
AgentStatusSchema,
|
|
5
|
+
ApiErrorSchema,
|
|
6
|
+
ApiSuccessSchema,
|
|
7
|
+
D1MemoryStore,
|
|
8
|
+
DEFAULT_HARE_AGENT_STATE,
|
|
9
|
+
DEFAULT_MCP_AGENT_STATE,
|
|
10
|
+
EMBEDDING_MODELS,
|
|
11
|
+
EdgeAgent,
|
|
12
|
+
HareEdgeAgent,
|
|
13
|
+
SYSTEM_TOOL_IDS,
|
|
14
|
+
TOOL_COUNTS,
|
|
15
|
+
ToolConfigSchema,
|
|
16
|
+
ToolRegistry,
|
|
17
|
+
ToolTypeSchema,
|
|
18
|
+
WORKERS_AI_MODELS,
|
|
19
|
+
createAgentFromConfig,
|
|
20
|
+
createAgentHeaders,
|
|
21
|
+
createEdgeAgent,
|
|
22
|
+
createHareEdgeAgent,
|
|
23
|
+
createMemoryStore,
|
|
24
|
+
createRegistry,
|
|
25
|
+
createSimpleAgent,
|
|
26
|
+
createTool,
|
|
27
|
+
createWorkersAIModel,
|
|
28
|
+
delegateTo,
|
|
29
|
+
delegateToWithValidation,
|
|
30
|
+
failure,
|
|
31
|
+
generateEmbedding,
|
|
32
|
+
generateEmbeddings,
|
|
33
|
+
getAgentIdFromRequest,
|
|
34
|
+
getAvailableModels,
|
|
35
|
+
getSystemTools,
|
|
36
|
+
getSystemToolsMap,
|
|
37
|
+
getToolsByCategory,
|
|
38
|
+
getWorkersAIModelId,
|
|
39
|
+
isSystemTool,
|
|
40
|
+
isWebSocketRequest,
|
|
41
|
+
loadAgentTools,
|
|
42
|
+
routeHttpToAgent,
|
|
43
|
+
routeToHareAgent,
|
|
44
|
+
routeToMcpAgent,
|
|
45
|
+
routeWebSocketToAgent,
|
|
46
|
+
success,
|
|
47
|
+
toAgentMessages
|
|
48
|
+
} from "./chunk-KTWGHY3T.js";
|
|
49
|
+
export {
|
|
50
|
+
AgentConfigSchema,
|
|
51
|
+
AgentSchema,
|
|
52
|
+
AgentStatusSchema,
|
|
53
|
+
ApiErrorSchema,
|
|
54
|
+
ApiSuccessSchema,
|
|
55
|
+
D1MemoryStore,
|
|
56
|
+
DEFAULT_HARE_AGENT_STATE,
|
|
57
|
+
DEFAULT_MCP_AGENT_STATE,
|
|
58
|
+
EMBEDDING_MODELS,
|
|
59
|
+
EdgeAgent,
|
|
60
|
+
HareEdgeAgent,
|
|
61
|
+
SYSTEM_TOOL_IDS,
|
|
62
|
+
TOOL_COUNTS,
|
|
63
|
+
ToolConfigSchema,
|
|
64
|
+
ToolRegistry,
|
|
65
|
+
ToolTypeSchema,
|
|
66
|
+
WORKERS_AI_MODELS,
|
|
67
|
+
createAgentFromConfig,
|
|
68
|
+
createAgentHeaders,
|
|
69
|
+
createEdgeAgent,
|
|
70
|
+
createHareEdgeAgent,
|
|
71
|
+
createMemoryStore,
|
|
72
|
+
createRegistry,
|
|
73
|
+
createSimpleAgent,
|
|
74
|
+
createTool,
|
|
75
|
+
createWorkersAIModel,
|
|
76
|
+
delegateTo,
|
|
77
|
+
delegateToWithValidation,
|
|
78
|
+
failure,
|
|
79
|
+
generateEmbedding,
|
|
80
|
+
generateEmbeddings,
|
|
81
|
+
getAgentIdFromRequest,
|
|
82
|
+
getAvailableModels,
|
|
83
|
+
getSystemTools,
|
|
84
|
+
getSystemToolsMap,
|
|
85
|
+
getToolsByCategory,
|
|
86
|
+
getWorkersAIModelId,
|
|
87
|
+
isSystemTool,
|
|
88
|
+
isWebSocketRequest,
|
|
89
|
+
loadAgentTools,
|
|
90
|
+
routeHttpToAgent,
|
|
91
|
+
routeToHareAgent,
|
|
92
|
+
routeToMcpAgent,
|
|
93
|
+
routeWebSocketToAgent,
|
|
94
|
+
success,
|
|
95
|
+
toAgentMessages
|
|
96
|
+
};
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@hare/tools';
|
package/dist/tools.js
ADDED
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ChatPayload, ClientMessage, HareAgentState, McpAgentState, SchedulePayload, ScheduledTask, ServerMessage, ToolExecutePayload } from '@hare/agent';
|
|
2
|
+
export { AnyTool, ExecutableTool, HareEnv, SystemToolId, Tool, ToolCategory, ToolContext, ToolDefinition, ToolResult } from '@hare/tools';
|
|
3
|
+
export * from '@hare/types';
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { HareAgent, HareAgentEnv, HareMcpAgent, McpAgentEnv } from '@hare/agent/workers';
|
|
2
|
+
export { AgentConfig, AgentOptions, AgentRouteConfig, AgentStreamResponse, AgentTool, ChatPayload, ClientMessage, ConversationMessage, CreateAgentFromConfigInput, CreateSimpleAgentInput, CreateWorkersAIModelInput, D1MemoryStore, DEFAULT_HARE_AGENT_STATE, DEFAULT_MCP_AGENT_STATE, EMBEDDING_MODELS, EdgeAgent, EmbeddingModelId, GenerateEmbeddingInput, GenerateEmbeddingsInput, GetMessagesInput, GetOrCreateConversationInput, HareAgentState, HareEdgeAgent, LoadAgentToolsInput, McpAgentState, MemoryStore, MessageRole, RouteHttpToAgentInput, RouteToHareAgentInput, RouteToMcpAgentInput, RouteWebSocketToAgentInput, SaveMessageInput, SchedulePayload, ScheduledTask, SearchMessagesInput, ServerMessage, ToolExecutePayload, WORKERS_AI_MODELS, WorkersAIModelId, createAgentFromConfig, createAgentHeaders, createEdgeAgent, createHareEdgeAgent, createMemoryStore, createSimpleAgent, createWorkersAIModel, generateEmbedding, generateEmbeddings, getAgentIdFromRequest, getAvailableModels, getWorkersAIModelId, isWebSocketRequest, loadAgentTools, routeHttpToAgent, routeToHareAgent, routeToMcpAgent, routeWebSocketToAgent, toAgentMessages } from '@hare/agent';
|
|
3
|
+
export { AnyTool, HareEnv, SYSTEM_TOOL_IDS, SystemToolId, TOOL_COUNTS, Tool, ToolCategory, ToolContext, ToolDefinition, ToolRegistry, ToolResult, createRegistry, createTool, delegateTo, delegateToWithValidation, failure, getSystemTools, getSystemToolsMap, getToolsByCategory, isSystemTool, success } from '@hare/tools';
|
|
4
|
+
export { Agent, AgentConfigSchema, AgentConfig as AgentConfigType, AgentSchema, AgentStatus, AgentStatusSchema, ApiError, ApiErrorSchema, ApiSuccess, ApiSuccessSchema, ToolConfig, ToolConfigSchema, ToolType, ToolTypeSchema } from '@hare/types';
|
package/dist/workers.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentConfigSchema,
|
|
3
|
+
AgentSchema,
|
|
4
|
+
AgentStatusSchema,
|
|
5
|
+
ApiErrorSchema,
|
|
6
|
+
ApiSuccessSchema,
|
|
7
|
+
D1MemoryStore,
|
|
8
|
+
DEFAULT_HARE_AGENT_STATE,
|
|
9
|
+
DEFAULT_MCP_AGENT_STATE,
|
|
10
|
+
EMBEDDING_MODELS,
|
|
11
|
+
EdgeAgent,
|
|
12
|
+
HareEdgeAgent,
|
|
13
|
+
SYSTEM_TOOL_IDS,
|
|
14
|
+
TOOL_COUNTS,
|
|
15
|
+
ToolConfigSchema,
|
|
16
|
+
ToolRegistry,
|
|
17
|
+
ToolTypeSchema,
|
|
18
|
+
WORKERS_AI_MODELS,
|
|
19
|
+
createAgentFromConfig,
|
|
20
|
+
createAgentHeaders,
|
|
21
|
+
createEdgeAgent,
|
|
22
|
+
createHareEdgeAgent,
|
|
23
|
+
createMemoryStore,
|
|
24
|
+
createRegistry,
|
|
25
|
+
createSimpleAgent,
|
|
26
|
+
createTool,
|
|
27
|
+
createWorkersAIModel,
|
|
28
|
+
delegateTo,
|
|
29
|
+
delegateToWithValidation,
|
|
30
|
+
failure,
|
|
31
|
+
generateEmbedding,
|
|
32
|
+
generateEmbeddings,
|
|
33
|
+
getAgentIdFromRequest,
|
|
34
|
+
getAvailableModels,
|
|
35
|
+
getSystemTools,
|
|
36
|
+
getSystemToolsMap,
|
|
37
|
+
getToolsByCategory,
|
|
38
|
+
getWorkersAIModelId,
|
|
39
|
+
isSystemTool,
|
|
40
|
+
isWebSocketRequest,
|
|
41
|
+
loadAgentTools,
|
|
42
|
+
routeHttpToAgent,
|
|
43
|
+
routeToHareAgent,
|
|
44
|
+
routeToMcpAgent,
|
|
45
|
+
routeWebSocketToAgent,
|
|
46
|
+
success,
|
|
47
|
+
toAgentMessages
|
|
48
|
+
} from "./chunk-KTWGHY3T.js";
|
|
49
|
+
|
|
50
|
+
// src/workers.ts
|
|
51
|
+
import { HareAgent, HareMcpAgent } from "@hare/agent/workers";
|
|
52
|
+
export {
|
|
53
|
+
AgentConfigSchema,
|
|
54
|
+
AgentSchema,
|
|
55
|
+
AgentStatusSchema,
|
|
56
|
+
ApiErrorSchema,
|
|
57
|
+
ApiSuccessSchema,
|
|
58
|
+
D1MemoryStore,
|
|
59
|
+
DEFAULT_HARE_AGENT_STATE,
|
|
60
|
+
DEFAULT_MCP_AGENT_STATE,
|
|
61
|
+
EMBEDDING_MODELS,
|
|
62
|
+
EdgeAgent,
|
|
63
|
+
HareAgent,
|
|
64
|
+
HareEdgeAgent,
|
|
65
|
+
HareMcpAgent,
|
|
66
|
+
SYSTEM_TOOL_IDS,
|
|
67
|
+
TOOL_COUNTS,
|
|
68
|
+
ToolConfigSchema,
|
|
69
|
+
ToolRegistry,
|
|
70
|
+
ToolTypeSchema,
|
|
71
|
+
WORKERS_AI_MODELS,
|
|
72
|
+
createAgentFromConfig,
|
|
73
|
+
createAgentHeaders,
|
|
74
|
+
createEdgeAgent,
|
|
75
|
+
createHareEdgeAgent,
|
|
76
|
+
createMemoryStore,
|
|
77
|
+
createRegistry,
|
|
78
|
+
createSimpleAgent,
|
|
79
|
+
createTool,
|
|
80
|
+
createWorkersAIModel,
|
|
81
|
+
delegateTo,
|
|
82
|
+
delegateToWithValidation,
|
|
83
|
+
failure,
|
|
84
|
+
generateEmbedding,
|
|
85
|
+
generateEmbeddings,
|
|
86
|
+
getAgentIdFromRequest,
|
|
87
|
+
getAvailableModels,
|
|
88
|
+
getSystemTools,
|
|
89
|
+
getSystemToolsMap,
|
|
90
|
+
getToolsByCategory,
|
|
91
|
+
getWorkersAIModelId,
|
|
92
|
+
isSystemTool,
|
|
93
|
+
isWebSocketRequest,
|
|
94
|
+
loadAgentTools,
|
|
95
|
+
routeHttpToAgent,
|
|
96
|
+
routeToHareAgent,
|
|
97
|
+
routeToMcpAgent,
|
|
98
|
+
routeWebSocketToAgent,
|
|
99
|
+
success,
|
|
100
|
+
toAgentMessages
|
|
101
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hareai",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Hare SDK - Build AI agents on Cloudflare's edge network",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cloudflare",
|
|
7
|
+
"workers",
|
|
8
|
+
"ai",
|
|
9
|
+
"agent",
|
|
10
|
+
"sdk",
|
|
11
|
+
"llm",
|
|
12
|
+
"tools",
|
|
13
|
+
"mcp"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"./tools": {
|
|
23
|
+
"import": "./dist/tools.js",
|
|
24
|
+
"types": "./dist/tools.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./types": {
|
|
27
|
+
"import": "./dist/types.js",
|
|
28
|
+
"types": "./dist/types.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./workers": {
|
|
31
|
+
"import": "./dist/workers.js",
|
|
32
|
+
"types": "./dist/workers.d.ts"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"main": "./dist/index.js",
|
|
36
|
+
"module": "./dist/index.js",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"README.md"
|
|
41
|
+
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsup",
|
|
44
|
+
"prepublishOnly": "bun run build",
|
|
45
|
+
"lint": "biome check .",
|
|
46
|
+
"typecheck": "tsc --noEmit"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@hare/agent": "workspace:*",
|
|
50
|
+
"@hare/tools": "workspace:*",
|
|
51
|
+
"@hare/types": "workspace:*"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@cloudflare/workers-types": "^4.20251224.0",
|
|
55
|
+
"@hare/typescript-config": "workspace:*",
|
|
56
|
+
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
57
|
+
"agents": "^0.3.0",
|
|
58
|
+
"ai": "^6.0.3",
|
|
59
|
+
"drizzle-orm": "^0.45.1",
|
|
60
|
+
"tsup": "^8",
|
|
61
|
+
"typescript": "^5",
|
|
62
|
+
"zod": "^4.2.1"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"@modelcontextprotocol/sdk": "^1.23.0",
|
|
66
|
+
"agents": "^0.3.0",
|
|
67
|
+
"ai": "^6.0.0",
|
|
68
|
+
"drizzle-orm": "^0.45.1",
|
|
69
|
+
"zod": "^4.0.0"
|
|
70
|
+
},
|
|
71
|
+
"peerDependenciesMeta": {
|
|
72
|
+
"@modelcontextprotocol/sdk": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"drizzle-orm": {
|
|
76
|
+
"optional": true
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"publishConfig": {
|
|
80
|
+
"access": "public"
|
|
81
|
+
},
|
|
82
|
+
"repository": {
|
|
83
|
+
"type": "git",
|
|
84
|
+
"url": "https://github.com/andrew-bierman/hare.git",
|
|
85
|
+
"directory": "packages/sdk"
|
|
86
|
+
},
|
|
87
|
+
"homepage": "https://github.com/andrew-bierman/hare",
|
|
88
|
+
"bugs": {
|
|
89
|
+
"url": "https://github.com/andrew-bierman/hare/issues"
|
|
90
|
+
}
|
|
91
|
+
}
|