@allem-sdk/agents 0.1.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 +117 -0
- package/dist/client.d.mts +57 -0
- package/dist/client.d.ts +57 -0
- package/dist/client.js +138 -0
- package/dist/client.mjs +110 -0
- package/dist/index.d.mts +98 -0
- package/dist/index.d.ts +98 -0
- package/dist/index.js +184 -0
- package/dist/index.mjs +156 -0
- package/dist/server.d.mts +44 -0
- package/dist/server.d.ts +44 -0
- package/dist/server.js +74 -0
- package/dist/server.mjs +49 -0
- package/package.json +77 -0
package/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/kingofmit/allem-sdk/main/.github/AllemSDK.png" alt="Allem SDK" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/@allem-sdk/agents"><img src="https://img.shields.io/npm/v/@allem-sdk/agents.svg" alt="npm version" /></a>
|
|
7
|
+
<a href="https://github.com/kingofmit/allem-sdk/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License" /></a>
|
|
8
|
+
<img src="https://img.shields.io/badge/react-19-61dafb" alt="React 19" />
|
|
9
|
+
<img src="https://img.shields.io/badge/typescript-strict-blue" alt="TypeScript" />
|
|
10
|
+
<img src="https://img.shields.io/badge/AI_SDK-v6-black" alt="AI SDK v6" />
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
# @allem-sdk/agents
|
|
14
|
+
|
|
15
|
+
Agentic AI hooks for React. Multi-step tool calling, agent status tracking, and typed tool definitions built on [Vercel AI SDK v6](https://sdk.vercel.ai).
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @allem-sdk/agents @allem-sdk/ai ai @ai-sdk/react
|
|
21
|
+
|
|
22
|
+
# Install at least one provider
|
|
23
|
+
npm install @ai-sdk/google # Google Gemini
|
|
24
|
+
npm install @ai-sdk/anthropic # Anthropic Claude
|
|
25
|
+
npm install @ai-sdk/openai # OpenAI GPT
|
|
26
|
+
|
|
27
|
+
# For defining tools with schemas
|
|
28
|
+
npm install zod
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Client Usage
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { AllemAIProvider } from "@allem-sdk/ai";
|
|
35
|
+
import { useAllemAgent } from "@allem-sdk/agents";
|
|
36
|
+
|
|
37
|
+
function App() {
|
|
38
|
+
return (
|
|
39
|
+
<AllemAIProvider api="/api/agent" provider="google">
|
|
40
|
+
<Agent />
|
|
41
|
+
</AllemAIProvider>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function Agent() {
|
|
46
|
+
const {
|
|
47
|
+
messages,
|
|
48
|
+
sendMessage,
|
|
49
|
+
agentStatus,
|
|
50
|
+
steps,
|
|
51
|
+
currentToolCalls,
|
|
52
|
+
isAgentRunning,
|
|
53
|
+
} = useAllemAgent();
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div>
|
|
57
|
+
{agentStatus === "calling-tool" && (
|
|
58
|
+
<p>Using tool: {currentToolCalls[0]?.toolName}</p>
|
|
59
|
+
)}
|
|
60
|
+
{messages.map((m) => (
|
|
61
|
+
<div key={m.id}>
|
|
62
|
+
{m.parts?.filter((p) => p.type === "text").map((p) => p.text).join("")}
|
|
63
|
+
</div>
|
|
64
|
+
))}
|
|
65
|
+
<p>Steps taken: {steps.length}</p>
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Server Usage
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
// app/api/agent/route.ts (Next.js)
|
|
75
|
+
import { createAllemAgentHandler, createAllemTool } from "@allem-sdk/agents";
|
|
76
|
+
import { google } from "@ai-sdk/google";
|
|
77
|
+
import { z } from "zod";
|
|
78
|
+
|
|
79
|
+
const weatherTool = createAllemTool({
|
|
80
|
+
description: "Get the current weather for a location",
|
|
81
|
+
parameters: z.object({ city: z.string() }),
|
|
82
|
+
execute: async ({ city }) => {
|
|
83
|
+
return { city, temperature: 72, condition: "sunny" };
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export const POST = createAllemAgentHandler({
|
|
88
|
+
providers: {
|
|
89
|
+
google: (model) => google(model ?? "gemini-2.0-flash"),
|
|
90
|
+
},
|
|
91
|
+
tools: { weather: weatherTool },
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Exports
|
|
96
|
+
|
|
97
|
+
| Export | Type | Description |
|
|
98
|
+
|--------|------|-------------|
|
|
99
|
+
| `useAllemAgent` | Hook | Agent hook with status tracking, step history, and tool call awareness |
|
|
100
|
+
| `AgentProvider` | Component | Optional context for registering tool metadata (names/descriptions) |
|
|
101
|
+
| `useAgentTools` | Hook | Read registered tool metadata from AgentProvider |
|
|
102
|
+
| `createAllemAgentHandler` | Server | Request handler with tool calling support for agentic workflows |
|
|
103
|
+
| `createAllemTool` | Server | Typed tool definition helper with zod schema validation |
|
|
104
|
+
|
|
105
|
+
## Part of [Allem SDK](https://github.com/kingofmit/allem-sdk)
|
|
106
|
+
|
|
107
|
+
This package can be used standalone or as part of the full SDK. Install `allem-sdk` to get all packages in one install.
|
|
108
|
+
|
|
109
|
+
## Support
|
|
110
|
+
|
|
111
|
+
If you find Allem SDK useful, consider supporting its development:
|
|
112
|
+
|
|
113
|
+
<a href="https://buymeacoffee.com/kingofmit" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="50" /></a>
|
|
114
|
+
|
|
115
|
+
## License
|
|
116
|
+
|
|
117
|
+
[MIT](https://github.com/kingofmit/allem-sdk/blob/main/LICENSE) - [Ahmed Allem](https://kingallem.com)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { UseChatHelpers } from '@ai-sdk/react';
|
|
2
|
+
import { ChatInit, UIMessage } from 'ai';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
type AgentStatus = "idle" | "thinking" | "calling-tool" | "done";
|
|
7
|
+
interface AgentToolCall {
|
|
8
|
+
toolCallId: string;
|
|
9
|
+
toolName: string;
|
|
10
|
+
args: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
interface AgentStep {
|
|
13
|
+
stepIndex: number;
|
|
14
|
+
toolCalls: AgentToolCall[];
|
|
15
|
+
startedAt: number;
|
|
16
|
+
}
|
|
17
|
+
interface AgentToolRegistration {
|
|
18
|
+
name: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type AllemProvider = "google" | "anthropic" | "openai";
|
|
23
|
+
interface UseAllemAgentOptions extends Omit<ChatInit<UIMessage>, "transport"> {
|
|
24
|
+
/** Override the API endpoint from AllemAIProvider. */
|
|
25
|
+
api?: string;
|
|
26
|
+
/** Model identifier sent in the request body. */
|
|
27
|
+
model?: string;
|
|
28
|
+
/** Provider name sent in the request body. */
|
|
29
|
+
provider?: AllemProvider;
|
|
30
|
+
/** System prompt sent in the request body. */
|
|
31
|
+
systemPrompt?: string;
|
|
32
|
+
/** Extra headers merged with AllemAIProvider headers. */
|
|
33
|
+
headers?: Record<string, string>;
|
|
34
|
+
/** Custom throttle wait in ms for updates. */
|
|
35
|
+
experimental_throttle?: number;
|
|
36
|
+
}
|
|
37
|
+
interface UseAllemAgentReturn extends UseChatHelpers<UIMessage> {
|
|
38
|
+
/** Current agent lifecycle status. */
|
|
39
|
+
agentStatus: AgentStatus;
|
|
40
|
+
/** Ordered list of steps taken in the current turn. */
|
|
41
|
+
steps: AgentStep[];
|
|
42
|
+
/** The tool calls from the most recent step, if any. */
|
|
43
|
+
currentToolCalls: AgentToolCall[];
|
|
44
|
+
/** Whether the agent is actively processing. */
|
|
45
|
+
isAgentRunning: boolean;
|
|
46
|
+
}
|
|
47
|
+
declare function useAllemAgent(options?: UseAllemAgentOptions): UseAllemAgentReturn;
|
|
48
|
+
|
|
49
|
+
interface AgentProviderProps {
|
|
50
|
+
/** Tool metadata for client-side display (names and descriptions). */
|
|
51
|
+
tools?: AgentToolRegistration[];
|
|
52
|
+
children: ReactNode;
|
|
53
|
+
}
|
|
54
|
+
declare function AgentProvider({ tools, children }: AgentProviderProps): react_jsx_runtime.JSX.Element;
|
|
55
|
+
declare function useAgentTools(): AgentToolRegistration[];
|
|
56
|
+
|
|
57
|
+
export { AgentProvider, type AgentProviderProps, type AgentStatus, type AgentStep, type AgentToolCall, type AgentToolRegistration, type AllemProvider, type UseAllemAgentOptions, type UseAllemAgentReturn, useAgentTools, useAllemAgent };
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { UseChatHelpers } from '@ai-sdk/react';
|
|
2
|
+
import { ChatInit, UIMessage } from 'ai';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
type AgentStatus = "idle" | "thinking" | "calling-tool" | "done";
|
|
7
|
+
interface AgentToolCall {
|
|
8
|
+
toolCallId: string;
|
|
9
|
+
toolName: string;
|
|
10
|
+
args: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
interface AgentStep {
|
|
13
|
+
stepIndex: number;
|
|
14
|
+
toolCalls: AgentToolCall[];
|
|
15
|
+
startedAt: number;
|
|
16
|
+
}
|
|
17
|
+
interface AgentToolRegistration {
|
|
18
|
+
name: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type AllemProvider = "google" | "anthropic" | "openai";
|
|
23
|
+
interface UseAllemAgentOptions extends Omit<ChatInit<UIMessage>, "transport"> {
|
|
24
|
+
/** Override the API endpoint from AllemAIProvider. */
|
|
25
|
+
api?: string;
|
|
26
|
+
/** Model identifier sent in the request body. */
|
|
27
|
+
model?: string;
|
|
28
|
+
/** Provider name sent in the request body. */
|
|
29
|
+
provider?: AllemProvider;
|
|
30
|
+
/** System prompt sent in the request body. */
|
|
31
|
+
systemPrompt?: string;
|
|
32
|
+
/** Extra headers merged with AllemAIProvider headers. */
|
|
33
|
+
headers?: Record<string, string>;
|
|
34
|
+
/** Custom throttle wait in ms for updates. */
|
|
35
|
+
experimental_throttle?: number;
|
|
36
|
+
}
|
|
37
|
+
interface UseAllemAgentReturn extends UseChatHelpers<UIMessage> {
|
|
38
|
+
/** Current agent lifecycle status. */
|
|
39
|
+
agentStatus: AgentStatus;
|
|
40
|
+
/** Ordered list of steps taken in the current turn. */
|
|
41
|
+
steps: AgentStep[];
|
|
42
|
+
/** The tool calls from the most recent step, if any. */
|
|
43
|
+
currentToolCalls: AgentToolCall[];
|
|
44
|
+
/** Whether the agent is actively processing. */
|
|
45
|
+
isAgentRunning: boolean;
|
|
46
|
+
}
|
|
47
|
+
declare function useAllemAgent(options?: UseAllemAgentOptions): UseAllemAgentReturn;
|
|
48
|
+
|
|
49
|
+
interface AgentProviderProps {
|
|
50
|
+
/** Tool metadata for client-side display (names and descriptions). */
|
|
51
|
+
tools?: AgentToolRegistration[];
|
|
52
|
+
children: ReactNode;
|
|
53
|
+
}
|
|
54
|
+
declare function AgentProvider({ tools, children }: AgentProviderProps): react_jsx_runtime.JSX.Element;
|
|
55
|
+
declare function useAgentTools(): AgentToolRegistration[];
|
|
56
|
+
|
|
57
|
+
export { AgentProvider, type AgentProviderProps, type AgentStatus, type AgentStep, type AgentToolCall, type AgentToolRegistration, type AllemProvider, type UseAllemAgentOptions, type UseAllemAgentReturn, useAgentTools, useAllemAgent };
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/client.ts
|
|
22
|
+
var client_exports = {};
|
|
23
|
+
__export(client_exports, {
|
|
24
|
+
AgentProvider: () => AgentProvider,
|
|
25
|
+
useAgentTools: () => useAgentTools,
|
|
26
|
+
useAllemAgent: () => useAllemAgent
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(client_exports);
|
|
29
|
+
|
|
30
|
+
// src/useAllemAgent.ts
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
var import_react2 = require("@ai-sdk/react");
|
|
33
|
+
var import_ai = require("ai");
|
|
34
|
+
var import_ai2 = require("@allem-sdk/ai");
|
|
35
|
+
function deriveAgentState(messages, chatStatus) {
|
|
36
|
+
const steps = [];
|
|
37
|
+
const allToolCalls = [];
|
|
38
|
+
let stepIndex = 0;
|
|
39
|
+
const isActive = chatStatus === "submitted" || chatStatus === "streaming";
|
|
40
|
+
for (const msg of messages) {
|
|
41
|
+
if (msg.role !== "assistant" || !msg.parts) continue;
|
|
42
|
+
const stepToolCalls = [];
|
|
43
|
+
for (const part of msg.parts) {
|
|
44
|
+
if (part.type === "tool-invocation") {
|
|
45
|
+
const invocation = part;
|
|
46
|
+
stepToolCalls.push({
|
|
47
|
+
toolCallId: invocation.toolInvocationId,
|
|
48
|
+
toolName: invocation.toolName,
|
|
49
|
+
args: invocation.args
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (stepToolCalls.length > 0) {
|
|
54
|
+
steps.push({
|
|
55
|
+
stepIndex,
|
|
56
|
+
toolCalls: stepToolCalls,
|
|
57
|
+
startedAt: Date.now()
|
|
58
|
+
});
|
|
59
|
+
stepIndex++;
|
|
60
|
+
allToolCalls.push(...stepToolCalls);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const lastMsg = messages[messages.length - 1];
|
|
64
|
+
const hasToolCalls = allToolCalls.length > 0;
|
|
65
|
+
const lastIsAssistantText = lastMsg?.role === "assistant" && lastMsg.parts?.some((p) => p.type === "text");
|
|
66
|
+
let agentStatus;
|
|
67
|
+
if (!isActive && messages.length === 0) {
|
|
68
|
+
agentStatus = "idle";
|
|
69
|
+
} else if (isActive && hasToolCalls && !lastIsAssistantText) {
|
|
70
|
+
agentStatus = "calling-tool";
|
|
71
|
+
} else if (isActive) {
|
|
72
|
+
agentStatus = "thinking";
|
|
73
|
+
} else if (messages.length > 0) {
|
|
74
|
+
agentStatus = "done";
|
|
75
|
+
} else {
|
|
76
|
+
agentStatus = "idle";
|
|
77
|
+
}
|
|
78
|
+
const currentToolCalls = steps.length > 0 ? steps[steps.length - 1].toolCalls : [];
|
|
79
|
+
return { agentStatus, steps, currentToolCalls, isAgentRunning: isActive };
|
|
80
|
+
}
|
|
81
|
+
function useAllemAgent(options = {}) {
|
|
82
|
+
const config = (0, import_ai2.useAllemAIConfig)();
|
|
83
|
+
const {
|
|
84
|
+
api,
|
|
85
|
+
model,
|
|
86
|
+
provider,
|
|
87
|
+
systemPrompt,
|
|
88
|
+
headers,
|
|
89
|
+
experimental_throttle,
|
|
90
|
+
...restOptions
|
|
91
|
+
} = options;
|
|
92
|
+
const resolvedApi = api ?? config.api;
|
|
93
|
+
const resolvedModel = model ?? config.model;
|
|
94
|
+
const resolvedProvider = provider ?? config.provider;
|
|
95
|
+
const resolvedHeaders = { ...config.headers, ...headers };
|
|
96
|
+
const transport = new import_ai.DefaultChatTransport({
|
|
97
|
+
api: resolvedApi,
|
|
98
|
+
headers: resolvedHeaders,
|
|
99
|
+
body: {
|
|
100
|
+
...resolvedModel && { model: resolvedModel },
|
|
101
|
+
...resolvedProvider && { provider: resolvedProvider },
|
|
102
|
+
...systemPrompt && { systemPrompt }
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
const chatHelpers = (0, import_react2.useChat)({
|
|
106
|
+
transport,
|
|
107
|
+
experimental_throttle,
|
|
108
|
+
...restOptions
|
|
109
|
+
});
|
|
110
|
+
const { agentStatus, steps, currentToolCalls, isAgentRunning } = (0, import_react.useMemo)(
|
|
111
|
+
() => deriveAgentState(chatHelpers.messages, chatHelpers.status),
|
|
112
|
+
[chatHelpers.messages, chatHelpers.status]
|
|
113
|
+
);
|
|
114
|
+
return {
|
|
115
|
+
...chatHelpers,
|
|
116
|
+
agentStatus,
|
|
117
|
+
steps,
|
|
118
|
+
currentToolCalls,
|
|
119
|
+
isAgentRunning
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/AgentProvider.tsx
|
|
124
|
+
var import_react3 = require("react");
|
|
125
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
126
|
+
var AgentContext = (0, import_react3.createContext)({ tools: [] });
|
|
127
|
+
function AgentProvider({ tools = [], children }) {
|
|
128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgentContext.Provider, { value: { tools }, children });
|
|
129
|
+
}
|
|
130
|
+
function useAgentTools() {
|
|
131
|
+
return (0, import_react3.useContext)(AgentContext).tools;
|
|
132
|
+
}
|
|
133
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
134
|
+
0 && (module.exports = {
|
|
135
|
+
AgentProvider,
|
|
136
|
+
useAgentTools,
|
|
137
|
+
useAllemAgent
|
|
138
|
+
});
|
package/dist/client.mjs
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/useAllemAgent.ts
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { useChat } from "@ai-sdk/react";
|
|
6
|
+
import { DefaultChatTransport } from "ai";
|
|
7
|
+
import { useAllemAIConfig } from "@allem-sdk/ai";
|
|
8
|
+
function deriveAgentState(messages, chatStatus) {
|
|
9
|
+
const steps = [];
|
|
10
|
+
const allToolCalls = [];
|
|
11
|
+
let stepIndex = 0;
|
|
12
|
+
const isActive = chatStatus === "submitted" || chatStatus === "streaming";
|
|
13
|
+
for (const msg of messages) {
|
|
14
|
+
if (msg.role !== "assistant" || !msg.parts) continue;
|
|
15
|
+
const stepToolCalls = [];
|
|
16
|
+
for (const part of msg.parts) {
|
|
17
|
+
if (part.type === "tool-invocation") {
|
|
18
|
+
const invocation = part;
|
|
19
|
+
stepToolCalls.push({
|
|
20
|
+
toolCallId: invocation.toolInvocationId,
|
|
21
|
+
toolName: invocation.toolName,
|
|
22
|
+
args: invocation.args
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (stepToolCalls.length > 0) {
|
|
27
|
+
steps.push({
|
|
28
|
+
stepIndex,
|
|
29
|
+
toolCalls: stepToolCalls,
|
|
30
|
+
startedAt: Date.now()
|
|
31
|
+
});
|
|
32
|
+
stepIndex++;
|
|
33
|
+
allToolCalls.push(...stepToolCalls);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const lastMsg = messages[messages.length - 1];
|
|
37
|
+
const hasToolCalls = allToolCalls.length > 0;
|
|
38
|
+
const lastIsAssistantText = lastMsg?.role === "assistant" && lastMsg.parts?.some((p) => p.type === "text");
|
|
39
|
+
let agentStatus;
|
|
40
|
+
if (!isActive && messages.length === 0) {
|
|
41
|
+
agentStatus = "idle";
|
|
42
|
+
} else if (isActive && hasToolCalls && !lastIsAssistantText) {
|
|
43
|
+
agentStatus = "calling-tool";
|
|
44
|
+
} else if (isActive) {
|
|
45
|
+
agentStatus = "thinking";
|
|
46
|
+
} else if (messages.length > 0) {
|
|
47
|
+
agentStatus = "done";
|
|
48
|
+
} else {
|
|
49
|
+
agentStatus = "idle";
|
|
50
|
+
}
|
|
51
|
+
const currentToolCalls = steps.length > 0 ? steps[steps.length - 1].toolCalls : [];
|
|
52
|
+
return { agentStatus, steps, currentToolCalls, isAgentRunning: isActive };
|
|
53
|
+
}
|
|
54
|
+
function useAllemAgent(options = {}) {
|
|
55
|
+
const config = useAllemAIConfig();
|
|
56
|
+
const {
|
|
57
|
+
api,
|
|
58
|
+
model,
|
|
59
|
+
provider,
|
|
60
|
+
systemPrompt,
|
|
61
|
+
headers,
|
|
62
|
+
experimental_throttle,
|
|
63
|
+
...restOptions
|
|
64
|
+
} = options;
|
|
65
|
+
const resolvedApi = api ?? config.api;
|
|
66
|
+
const resolvedModel = model ?? config.model;
|
|
67
|
+
const resolvedProvider = provider ?? config.provider;
|
|
68
|
+
const resolvedHeaders = { ...config.headers, ...headers };
|
|
69
|
+
const transport = new DefaultChatTransport({
|
|
70
|
+
api: resolvedApi,
|
|
71
|
+
headers: resolvedHeaders,
|
|
72
|
+
body: {
|
|
73
|
+
...resolvedModel && { model: resolvedModel },
|
|
74
|
+
...resolvedProvider && { provider: resolvedProvider },
|
|
75
|
+
...systemPrompt && { systemPrompt }
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const chatHelpers = useChat({
|
|
79
|
+
transport,
|
|
80
|
+
experimental_throttle,
|
|
81
|
+
...restOptions
|
|
82
|
+
});
|
|
83
|
+
const { agentStatus, steps, currentToolCalls, isAgentRunning } = useMemo(
|
|
84
|
+
() => deriveAgentState(chatHelpers.messages, chatHelpers.status),
|
|
85
|
+
[chatHelpers.messages, chatHelpers.status]
|
|
86
|
+
);
|
|
87
|
+
return {
|
|
88
|
+
...chatHelpers,
|
|
89
|
+
agentStatus,
|
|
90
|
+
steps,
|
|
91
|
+
currentToolCalls,
|
|
92
|
+
isAgentRunning
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/AgentProvider.tsx
|
|
97
|
+
import { createContext, useContext } from "react";
|
|
98
|
+
import { jsx } from "react/jsx-runtime";
|
|
99
|
+
var AgentContext = createContext({ tools: [] });
|
|
100
|
+
function AgentProvider({ tools = [], children }) {
|
|
101
|
+
return /* @__PURE__ */ jsx(AgentContext.Provider, { value: { tools }, children });
|
|
102
|
+
}
|
|
103
|
+
function useAgentTools() {
|
|
104
|
+
return useContext(AgentContext).tools;
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
AgentProvider,
|
|
108
|
+
useAgentTools,
|
|
109
|
+
useAllemAgent
|
|
110
|
+
};
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { UseChatHelpers } from '@ai-sdk/react';
|
|
2
|
+
import { ChatInit, UIMessage, LanguageModel, ToolSet } from 'ai';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
type AgentStatus = "idle" | "thinking" | "calling-tool" | "done";
|
|
8
|
+
interface AgentToolCall {
|
|
9
|
+
toolCallId: string;
|
|
10
|
+
toolName: string;
|
|
11
|
+
args: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
interface AgentStep {
|
|
14
|
+
stepIndex: number;
|
|
15
|
+
toolCalls: AgentToolCall[];
|
|
16
|
+
startedAt: number;
|
|
17
|
+
}
|
|
18
|
+
interface AgentToolRegistration {
|
|
19
|
+
name: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type AllemProvider = "google" | "anthropic" | "openai";
|
|
24
|
+
interface UseAllemAgentOptions extends Omit<ChatInit<UIMessage>, "transport"> {
|
|
25
|
+
/** Override the API endpoint from AllemAIProvider. */
|
|
26
|
+
api?: string;
|
|
27
|
+
/** Model identifier sent in the request body. */
|
|
28
|
+
model?: string;
|
|
29
|
+
/** Provider name sent in the request body. */
|
|
30
|
+
provider?: AllemProvider;
|
|
31
|
+
/** System prompt sent in the request body. */
|
|
32
|
+
systemPrompt?: string;
|
|
33
|
+
/** Extra headers merged with AllemAIProvider headers. */
|
|
34
|
+
headers?: Record<string, string>;
|
|
35
|
+
/** Custom throttle wait in ms for updates. */
|
|
36
|
+
experimental_throttle?: number;
|
|
37
|
+
}
|
|
38
|
+
interface UseAllemAgentReturn extends UseChatHelpers<UIMessage> {
|
|
39
|
+
/** Current agent lifecycle status. */
|
|
40
|
+
agentStatus: AgentStatus;
|
|
41
|
+
/** Ordered list of steps taken in the current turn. */
|
|
42
|
+
steps: AgentStep[];
|
|
43
|
+
/** The tool calls from the most recent step, if any. */
|
|
44
|
+
currentToolCalls: AgentToolCall[];
|
|
45
|
+
/** Whether the agent is actively processing. */
|
|
46
|
+
isAgentRunning: boolean;
|
|
47
|
+
}
|
|
48
|
+
declare function useAllemAgent(options?: UseAllemAgentOptions): UseAllemAgentReturn;
|
|
49
|
+
|
|
50
|
+
interface AgentProviderProps {
|
|
51
|
+
/** Tool metadata for client-side display (names and descriptions). */
|
|
52
|
+
tools?: AgentToolRegistration[];
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
}
|
|
55
|
+
declare function AgentProvider({ tools, children }: AgentProviderProps): react_jsx_runtime.JSX.Element;
|
|
56
|
+
declare function useAgentTools(): AgentToolRegistration[];
|
|
57
|
+
|
|
58
|
+
type AllemProviderName = "google" | "anthropic" | "openai";
|
|
59
|
+
interface AllemAgentHandlerConfig {
|
|
60
|
+
/** Map of provider name to a function that returns a LanguageModel for a given model ID. */
|
|
61
|
+
providers: Partial<Record<AllemProviderName, (modelId?: string) => LanguageModel>>;
|
|
62
|
+
/** Default provider when none is specified in the request. Default: "google". */
|
|
63
|
+
defaultProvider?: AllemProviderName;
|
|
64
|
+
/** Default model ID when none is specified in the request. */
|
|
65
|
+
defaultModel?: string;
|
|
66
|
+
/** Default system prompt. */
|
|
67
|
+
systemPrompt?: string;
|
|
68
|
+
/** Tools available to the agent. */
|
|
69
|
+
tools?: ToolSet;
|
|
70
|
+
}
|
|
71
|
+
declare function createAllemAgentHandler(config: AllemAgentHandlerConfig): (req: Request) => Promise<Response>;
|
|
72
|
+
|
|
73
|
+
interface AllemToolConfig<TParams extends z.ZodType> {
|
|
74
|
+
description: string;
|
|
75
|
+
parameters: TParams;
|
|
76
|
+
execute: (params: z.infer<TParams>) => Promise<unknown>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Creates a tool definition compatible with Vercel AI SDK's streamText tools.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const weather = createAllemTool({
|
|
84
|
+
* description: "Get the weather for a city",
|
|
85
|
+
* parameters: z.object({ city: z.string() }),
|
|
86
|
+
* execute: async ({ city }) => ({ temp: 72 }),
|
|
87
|
+
* });
|
|
88
|
+
*
|
|
89
|
+
* createAllemAgentHandler({ tools: { weather }, ... });
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare function createAllemTool<TParams extends z.ZodType>(config: AllemToolConfig<TParams>): {
|
|
93
|
+
description: string;
|
|
94
|
+
parameters: TParams;
|
|
95
|
+
execute: (params: z.core.output<TParams>) => Promise<unknown>;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export { AgentProvider, type AgentProviderProps, type AgentStatus, type AgentStep, type AgentToolCall, type AgentToolRegistration, type AllemAgentHandlerConfig, type AllemProvider, type AllemProviderName, type AllemToolConfig, type UseAllemAgentOptions, type UseAllemAgentReturn, createAllemAgentHandler, createAllemTool, useAgentTools, useAllemAgent };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { UseChatHelpers } from '@ai-sdk/react';
|
|
2
|
+
import { ChatInit, UIMessage, LanguageModel, ToolSet } from 'ai';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
type AgentStatus = "idle" | "thinking" | "calling-tool" | "done";
|
|
8
|
+
interface AgentToolCall {
|
|
9
|
+
toolCallId: string;
|
|
10
|
+
toolName: string;
|
|
11
|
+
args: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
interface AgentStep {
|
|
14
|
+
stepIndex: number;
|
|
15
|
+
toolCalls: AgentToolCall[];
|
|
16
|
+
startedAt: number;
|
|
17
|
+
}
|
|
18
|
+
interface AgentToolRegistration {
|
|
19
|
+
name: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type AllemProvider = "google" | "anthropic" | "openai";
|
|
24
|
+
interface UseAllemAgentOptions extends Omit<ChatInit<UIMessage>, "transport"> {
|
|
25
|
+
/** Override the API endpoint from AllemAIProvider. */
|
|
26
|
+
api?: string;
|
|
27
|
+
/** Model identifier sent in the request body. */
|
|
28
|
+
model?: string;
|
|
29
|
+
/** Provider name sent in the request body. */
|
|
30
|
+
provider?: AllemProvider;
|
|
31
|
+
/** System prompt sent in the request body. */
|
|
32
|
+
systemPrompt?: string;
|
|
33
|
+
/** Extra headers merged with AllemAIProvider headers. */
|
|
34
|
+
headers?: Record<string, string>;
|
|
35
|
+
/** Custom throttle wait in ms for updates. */
|
|
36
|
+
experimental_throttle?: number;
|
|
37
|
+
}
|
|
38
|
+
interface UseAllemAgentReturn extends UseChatHelpers<UIMessage> {
|
|
39
|
+
/** Current agent lifecycle status. */
|
|
40
|
+
agentStatus: AgentStatus;
|
|
41
|
+
/** Ordered list of steps taken in the current turn. */
|
|
42
|
+
steps: AgentStep[];
|
|
43
|
+
/** The tool calls from the most recent step, if any. */
|
|
44
|
+
currentToolCalls: AgentToolCall[];
|
|
45
|
+
/** Whether the agent is actively processing. */
|
|
46
|
+
isAgentRunning: boolean;
|
|
47
|
+
}
|
|
48
|
+
declare function useAllemAgent(options?: UseAllemAgentOptions): UseAllemAgentReturn;
|
|
49
|
+
|
|
50
|
+
interface AgentProviderProps {
|
|
51
|
+
/** Tool metadata for client-side display (names and descriptions). */
|
|
52
|
+
tools?: AgentToolRegistration[];
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
}
|
|
55
|
+
declare function AgentProvider({ tools, children }: AgentProviderProps): react_jsx_runtime.JSX.Element;
|
|
56
|
+
declare function useAgentTools(): AgentToolRegistration[];
|
|
57
|
+
|
|
58
|
+
type AllemProviderName = "google" | "anthropic" | "openai";
|
|
59
|
+
interface AllemAgentHandlerConfig {
|
|
60
|
+
/** Map of provider name to a function that returns a LanguageModel for a given model ID. */
|
|
61
|
+
providers: Partial<Record<AllemProviderName, (modelId?: string) => LanguageModel>>;
|
|
62
|
+
/** Default provider when none is specified in the request. Default: "google". */
|
|
63
|
+
defaultProvider?: AllemProviderName;
|
|
64
|
+
/** Default model ID when none is specified in the request. */
|
|
65
|
+
defaultModel?: string;
|
|
66
|
+
/** Default system prompt. */
|
|
67
|
+
systemPrompt?: string;
|
|
68
|
+
/** Tools available to the agent. */
|
|
69
|
+
tools?: ToolSet;
|
|
70
|
+
}
|
|
71
|
+
declare function createAllemAgentHandler(config: AllemAgentHandlerConfig): (req: Request) => Promise<Response>;
|
|
72
|
+
|
|
73
|
+
interface AllemToolConfig<TParams extends z.ZodType> {
|
|
74
|
+
description: string;
|
|
75
|
+
parameters: TParams;
|
|
76
|
+
execute: (params: z.infer<TParams>) => Promise<unknown>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Creates a tool definition compatible with Vercel AI SDK's streamText tools.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const weather = createAllemTool({
|
|
84
|
+
* description: "Get the weather for a city",
|
|
85
|
+
* parameters: z.object({ city: z.string() }),
|
|
86
|
+
* execute: async ({ city }) => ({ temp: 72 }),
|
|
87
|
+
* });
|
|
88
|
+
*
|
|
89
|
+
* createAllemAgentHandler({ tools: { weather }, ... });
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare function createAllemTool<TParams extends z.ZodType>(config: AllemToolConfig<TParams>): {
|
|
93
|
+
description: string;
|
|
94
|
+
parameters: TParams;
|
|
95
|
+
execute: (params: z.core.output<TParams>) => Promise<unknown>;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export { AgentProvider, type AgentProviderProps, type AgentStatus, type AgentStep, type AgentToolCall, type AgentToolRegistration, type AllemAgentHandlerConfig, type AllemProvider, type AllemProviderName, type AllemToolConfig, type UseAllemAgentOptions, type UseAllemAgentReturn, createAllemAgentHandler, createAllemTool, useAgentTools, useAllemAgent };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
AgentProvider: () => AgentProvider,
|
|
24
|
+
createAllemAgentHandler: () => createAllemAgentHandler,
|
|
25
|
+
createAllemTool: () => createAllemTool,
|
|
26
|
+
useAgentTools: () => useAgentTools,
|
|
27
|
+
useAllemAgent: () => useAllemAgent
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(src_exports);
|
|
30
|
+
|
|
31
|
+
// src/useAllemAgent.ts
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_react2 = require("@ai-sdk/react");
|
|
34
|
+
var import_ai = require("ai");
|
|
35
|
+
var import_ai2 = require("@allem-sdk/ai");
|
|
36
|
+
function deriveAgentState(messages, chatStatus) {
|
|
37
|
+
const steps = [];
|
|
38
|
+
const allToolCalls = [];
|
|
39
|
+
let stepIndex = 0;
|
|
40
|
+
const isActive = chatStatus === "submitted" || chatStatus === "streaming";
|
|
41
|
+
for (const msg of messages) {
|
|
42
|
+
if (msg.role !== "assistant" || !msg.parts) continue;
|
|
43
|
+
const stepToolCalls = [];
|
|
44
|
+
for (const part of msg.parts) {
|
|
45
|
+
if (part.type === "tool-invocation") {
|
|
46
|
+
const invocation = part;
|
|
47
|
+
stepToolCalls.push({
|
|
48
|
+
toolCallId: invocation.toolInvocationId,
|
|
49
|
+
toolName: invocation.toolName,
|
|
50
|
+
args: invocation.args
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (stepToolCalls.length > 0) {
|
|
55
|
+
steps.push({
|
|
56
|
+
stepIndex,
|
|
57
|
+
toolCalls: stepToolCalls,
|
|
58
|
+
startedAt: Date.now()
|
|
59
|
+
});
|
|
60
|
+
stepIndex++;
|
|
61
|
+
allToolCalls.push(...stepToolCalls);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const lastMsg = messages[messages.length - 1];
|
|
65
|
+
const hasToolCalls = allToolCalls.length > 0;
|
|
66
|
+
const lastIsAssistantText = lastMsg?.role === "assistant" && lastMsg.parts?.some((p) => p.type === "text");
|
|
67
|
+
let agentStatus;
|
|
68
|
+
if (!isActive && messages.length === 0) {
|
|
69
|
+
agentStatus = "idle";
|
|
70
|
+
} else if (isActive && hasToolCalls && !lastIsAssistantText) {
|
|
71
|
+
agentStatus = "calling-tool";
|
|
72
|
+
} else if (isActive) {
|
|
73
|
+
agentStatus = "thinking";
|
|
74
|
+
} else if (messages.length > 0) {
|
|
75
|
+
agentStatus = "done";
|
|
76
|
+
} else {
|
|
77
|
+
agentStatus = "idle";
|
|
78
|
+
}
|
|
79
|
+
const currentToolCalls = steps.length > 0 ? steps[steps.length - 1].toolCalls : [];
|
|
80
|
+
return { agentStatus, steps, currentToolCalls, isAgentRunning: isActive };
|
|
81
|
+
}
|
|
82
|
+
function useAllemAgent(options = {}) {
|
|
83
|
+
const config = (0, import_ai2.useAllemAIConfig)();
|
|
84
|
+
const {
|
|
85
|
+
api,
|
|
86
|
+
model,
|
|
87
|
+
provider,
|
|
88
|
+
systemPrompt,
|
|
89
|
+
headers,
|
|
90
|
+
experimental_throttle,
|
|
91
|
+
...restOptions
|
|
92
|
+
} = options;
|
|
93
|
+
const resolvedApi = api ?? config.api;
|
|
94
|
+
const resolvedModel = model ?? config.model;
|
|
95
|
+
const resolvedProvider = provider ?? config.provider;
|
|
96
|
+
const resolvedHeaders = { ...config.headers, ...headers };
|
|
97
|
+
const transport = new import_ai.DefaultChatTransport({
|
|
98
|
+
api: resolvedApi,
|
|
99
|
+
headers: resolvedHeaders,
|
|
100
|
+
body: {
|
|
101
|
+
...resolvedModel && { model: resolvedModel },
|
|
102
|
+
...resolvedProvider && { provider: resolvedProvider },
|
|
103
|
+
...systemPrompt && { systemPrompt }
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
const chatHelpers = (0, import_react2.useChat)({
|
|
107
|
+
transport,
|
|
108
|
+
experimental_throttle,
|
|
109
|
+
...restOptions
|
|
110
|
+
});
|
|
111
|
+
const { agentStatus, steps, currentToolCalls, isAgentRunning } = (0, import_react.useMemo)(
|
|
112
|
+
() => deriveAgentState(chatHelpers.messages, chatHelpers.status),
|
|
113
|
+
[chatHelpers.messages, chatHelpers.status]
|
|
114
|
+
);
|
|
115
|
+
return {
|
|
116
|
+
...chatHelpers,
|
|
117
|
+
agentStatus,
|
|
118
|
+
steps,
|
|
119
|
+
currentToolCalls,
|
|
120
|
+
isAgentRunning
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/AgentProvider.tsx
|
|
125
|
+
var import_react3 = require("react");
|
|
126
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
127
|
+
var AgentContext = (0, import_react3.createContext)({ tools: [] });
|
|
128
|
+
function AgentProvider({ tools = [], children }) {
|
|
129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgentContext.Provider, { value: { tools }, children });
|
|
130
|
+
}
|
|
131
|
+
function useAgentTools() {
|
|
132
|
+
return (0, import_react3.useContext)(AgentContext).tools;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// src/createAllemAgentHandler.ts
|
|
136
|
+
var import_ai3 = require("ai");
|
|
137
|
+
function createAllemAgentHandler(config) {
|
|
138
|
+
const {
|
|
139
|
+
providers,
|
|
140
|
+
defaultProvider = "google",
|
|
141
|
+
defaultModel,
|
|
142
|
+
systemPrompt: defaultSystemPrompt,
|
|
143
|
+
tools
|
|
144
|
+
} = config;
|
|
145
|
+
return async function handler(req) {
|
|
146
|
+
const body = await req.json();
|
|
147
|
+
const providerName = body.provider ?? defaultProvider;
|
|
148
|
+
const modelId = body.model ?? defaultModel;
|
|
149
|
+
const system = body.systemPrompt ?? defaultSystemPrompt;
|
|
150
|
+
const providerFactory = providers[providerName];
|
|
151
|
+
if (!providerFactory) {
|
|
152
|
+
return new Response(
|
|
153
|
+
JSON.stringify({ error: `Provider "${providerName}" is not configured.` }),
|
|
154
|
+
{ status: 400, headers: { "Content-Type": "application/json" } }
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
const model = providerFactory(modelId);
|
|
158
|
+
const modelMessages = await (0, import_ai3.convertToModelMessages)(body.messages);
|
|
159
|
+
const result = (0, import_ai3.streamText)({
|
|
160
|
+
model,
|
|
161
|
+
system,
|
|
162
|
+
messages: modelMessages,
|
|
163
|
+
tools
|
|
164
|
+
});
|
|
165
|
+
return result.toUIMessageStreamResponse();
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// src/createAllemTool.ts
|
|
170
|
+
function createAllemTool(config) {
|
|
171
|
+
return {
|
|
172
|
+
description: config.description,
|
|
173
|
+
parameters: config.parameters,
|
|
174
|
+
execute: config.execute
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
178
|
+
0 && (module.exports = {
|
|
179
|
+
AgentProvider,
|
|
180
|
+
createAllemAgentHandler,
|
|
181
|
+
createAllemTool,
|
|
182
|
+
useAgentTools,
|
|
183
|
+
useAllemAgent
|
|
184
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// src/useAllemAgent.ts
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { useChat } from "@ai-sdk/react";
|
|
4
|
+
import { DefaultChatTransport } from "ai";
|
|
5
|
+
import { useAllemAIConfig } from "@allem-sdk/ai";
|
|
6
|
+
function deriveAgentState(messages, chatStatus) {
|
|
7
|
+
const steps = [];
|
|
8
|
+
const allToolCalls = [];
|
|
9
|
+
let stepIndex = 0;
|
|
10
|
+
const isActive = chatStatus === "submitted" || chatStatus === "streaming";
|
|
11
|
+
for (const msg of messages) {
|
|
12
|
+
if (msg.role !== "assistant" || !msg.parts) continue;
|
|
13
|
+
const stepToolCalls = [];
|
|
14
|
+
for (const part of msg.parts) {
|
|
15
|
+
if (part.type === "tool-invocation") {
|
|
16
|
+
const invocation = part;
|
|
17
|
+
stepToolCalls.push({
|
|
18
|
+
toolCallId: invocation.toolInvocationId,
|
|
19
|
+
toolName: invocation.toolName,
|
|
20
|
+
args: invocation.args
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (stepToolCalls.length > 0) {
|
|
25
|
+
steps.push({
|
|
26
|
+
stepIndex,
|
|
27
|
+
toolCalls: stepToolCalls,
|
|
28
|
+
startedAt: Date.now()
|
|
29
|
+
});
|
|
30
|
+
stepIndex++;
|
|
31
|
+
allToolCalls.push(...stepToolCalls);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const lastMsg = messages[messages.length - 1];
|
|
35
|
+
const hasToolCalls = allToolCalls.length > 0;
|
|
36
|
+
const lastIsAssistantText = lastMsg?.role === "assistant" && lastMsg.parts?.some((p) => p.type === "text");
|
|
37
|
+
let agentStatus;
|
|
38
|
+
if (!isActive && messages.length === 0) {
|
|
39
|
+
agentStatus = "idle";
|
|
40
|
+
} else if (isActive && hasToolCalls && !lastIsAssistantText) {
|
|
41
|
+
agentStatus = "calling-tool";
|
|
42
|
+
} else if (isActive) {
|
|
43
|
+
agentStatus = "thinking";
|
|
44
|
+
} else if (messages.length > 0) {
|
|
45
|
+
agentStatus = "done";
|
|
46
|
+
} else {
|
|
47
|
+
agentStatus = "idle";
|
|
48
|
+
}
|
|
49
|
+
const currentToolCalls = steps.length > 0 ? steps[steps.length - 1].toolCalls : [];
|
|
50
|
+
return { agentStatus, steps, currentToolCalls, isAgentRunning: isActive };
|
|
51
|
+
}
|
|
52
|
+
function useAllemAgent(options = {}) {
|
|
53
|
+
const config = useAllemAIConfig();
|
|
54
|
+
const {
|
|
55
|
+
api,
|
|
56
|
+
model,
|
|
57
|
+
provider,
|
|
58
|
+
systemPrompt,
|
|
59
|
+
headers,
|
|
60
|
+
experimental_throttle,
|
|
61
|
+
...restOptions
|
|
62
|
+
} = options;
|
|
63
|
+
const resolvedApi = api ?? config.api;
|
|
64
|
+
const resolvedModel = model ?? config.model;
|
|
65
|
+
const resolvedProvider = provider ?? config.provider;
|
|
66
|
+
const resolvedHeaders = { ...config.headers, ...headers };
|
|
67
|
+
const transport = new DefaultChatTransport({
|
|
68
|
+
api: resolvedApi,
|
|
69
|
+
headers: resolvedHeaders,
|
|
70
|
+
body: {
|
|
71
|
+
...resolvedModel && { model: resolvedModel },
|
|
72
|
+
...resolvedProvider && { provider: resolvedProvider },
|
|
73
|
+
...systemPrompt && { systemPrompt }
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
const chatHelpers = useChat({
|
|
77
|
+
transport,
|
|
78
|
+
experimental_throttle,
|
|
79
|
+
...restOptions
|
|
80
|
+
});
|
|
81
|
+
const { agentStatus, steps, currentToolCalls, isAgentRunning } = useMemo(
|
|
82
|
+
() => deriveAgentState(chatHelpers.messages, chatHelpers.status),
|
|
83
|
+
[chatHelpers.messages, chatHelpers.status]
|
|
84
|
+
);
|
|
85
|
+
return {
|
|
86
|
+
...chatHelpers,
|
|
87
|
+
agentStatus,
|
|
88
|
+
steps,
|
|
89
|
+
currentToolCalls,
|
|
90
|
+
isAgentRunning
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/AgentProvider.tsx
|
|
95
|
+
import { createContext, useContext } from "react";
|
|
96
|
+
import { jsx } from "react/jsx-runtime";
|
|
97
|
+
var AgentContext = createContext({ tools: [] });
|
|
98
|
+
function AgentProvider({ tools = [], children }) {
|
|
99
|
+
return /* @__PURE__ */ jsx(AgentContext.Provider, { value: { tools }, children });
|
|
100
|
+
}
|
|
101
|
+
function useAgentTools() {
|
|
102
|
+
return useContext(AgentContext).tools;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/createAllemAgentHandler.ts
|
|
106
|
+
import {
|
|
107
|
+
streamText,
|
|
108
|
+
convertToModelMessages
|
|
109
|
+
} from "ai";
|
|
110
|
+
function createAllemAgentHandler(config) {
|
|
111
|
+
const {
|
|
112
|
+
providers,
|
|
113
|
+
defaultProvider = "google",
|
|
114
|
+
defaultModel,
|
|
115
|
+
systemPrompt: defaultSystemPrompt,
|
|
116
|
+
tools
|
|
117
|
+
} = config;
|
|
118
|
+
return async function handler(req) {
|
|
119
|
+
const body = await req.json();
|
|
120
|
+
const providerName = body.provider ?? defaultProvider;
|
|
121
|
+
const modelId = body.model ?? defaultModel;
|
|
122
|
+
const system = body.systemPrompt ?? defaultSystemPrompt;
|
|
123
|
+
const providerFactory = providers[providerName];
|
|
124
|
+
if (!providerFactory) {
|
|
125
|
+
return new Response(
|
|
126
|
+
JSON.stringify({ error: `Provider "${providerName}" is not configured.` }),
|
|
127
|
+
{ status: 400, headers: { "Content-Type": "application/json" } }
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
const model = providerFactory(modelId);
|
|
131
|
+
const modelMessages = await convertToModelMessages(body.messages);
|
|
132
|
+
const result = streamText({
|
|
133
|
+
model,
|
|
134
|
+
system,
|
|
135
|
+
messages: modelMessages,
|
|
136
|
+
tools
|
|
137
|
+
});
|
|
138
|
+
return result.toUIMessageStreamResponse();
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/createAllemTool.ts
|
|
143
|
+
function createAllemTool(config) {
|
|
144
|
+
return {
|
|
145
|
+
description: config.description,
|
|
146
|
+
parameters: config.parameters,
|
|
147
|
+
execute: config.execute
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
export {
|
|
151
|
+
AgentProvider,
|
|
152
|
+
createAllemAgentHandler,
|
|
153
|
+
createAllemTool,
|
|
154
|
+
useAgentTools,
|
|
155
|
+
useAllemAgent
|
|
156
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { LanguageModel, ToolSet } from 'ai';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
type AllemProviderName = "google" | "anthropic" | "openai";
|
|
5
|
+
interface AllemAgentHandlerConfig {
|
|
6
|
+
/** Map of provider name to a function that returns a LanguageModel for a given model ID. */
|
|
7
|
+
providers: Partial<Record<AllemProviderName, (modelId?: string) => LanguageModel>>;
|
|
8
|
+
/** Default provider when none is specified in the request. Default: "google". */
|
|
9
|
+
defaultProvider?: AllemProviderName;
|
|
10
|
+
/** Default model ID when none is specified in the request. */
|
|
11
|
+
defaultModel?: string;
|
|
12
|
+
/** Default system prompt. */
|
|
13
|
+
systemPrompt?: string;
|
|
14
|
+
/** Tools available to the agent. */
|
|
15
|
+
tools?: ToolSet;
|
|
16
|
+
}
|
|
17
|
+
declare function createAllemAgentHandler(config: AllemAgentHandlerConfig): (req: Request) => Promise<Response>;
|
|
18
|
+
|
|
19
|
+
interface AllemToolConfig<TParams extends z.ZodType> {
|
|
20
|
+
description: string;
|
|
21
|
+
parameters: TParams;
|
|
22
|
+
execute: (params: z.infer<TParams>) => Promise<unknown>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a tool definition compatible with Vercel AI SDK's streamText tools.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const weather = createAllemTool({
|
|
30
|
+
* description: "Get the weather for a city",
|
|
31
|
+
* parameters: z.object({ city: z.string() }),
|
|
32
|
+
* execute: async ({ city }) => ({ temp: 72 }),
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* createAllemAgentHandler({ tools: { weather }, ... });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare function createAllemTool<TParams extends z.ZodType>(config: AllemToolConfig<TParams>): {
|
|
39
|
+
description: string;
|
|
40
|
+
parameters: TParams;
|
|
41
|
+
execute: (params: z.core.output<TParams>) => Promise<unknown>;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { type AllemAgentHandlerConfig, type AllemProviderName, type AllemToolConfig, createAllemAgentHandler, createAllemTool };
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { LanguageModel, ToolSet } from 'ai';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
type AllemProviderName = "google" | "anthropic" | "openai";
|
|
5
|
+
interface AllemAgentHandlerConfig {
|
|
6
|
+
/** Map of provider name to a function that returns a LanguageModel for a given model ID. */
|
|
7
|
+
providers: Partial<Record<AllemProviderName, (modelId?: string) => LanguageModel>>;
|
|
8
|
+
/** Default provider when none is specified in the request. Default: "google". */
|
|
9
|
+
defaultProvider?: AllemProviderName;
|
|
10
|
+
/** Default model ID when none is specified in the request. */
|
|
11
|
+
defaultModel?: string;
|
|
12
|
+
/** Default system prompt. */
|
|
13
|
+
systemPrompt?: string;
|
|
14
|
+
/** Tools available to the agent. */
|
|
15
|
+
tools?: ToolSet;
|
|
16
|
+
}
|
|
17
|
+
declare function createAllemAgentHandler(config: AllemAgentHandlerConfig): (req: Request) => Promise<Response>;
|
|
18
|
+
|
|
19
|
+
interface AllemToolConfig<TParams extends z.ZodType> {
|
|
20
|
+
description: string;
|
|
21
|
+
parameters: TParams;
|
|
22
|
+
execute: (params: z.infer<TParams>) => Promise<unknown>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a tool definition compatible with Vercel AI SDK's streamText tools.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const weather = createAllemTool({
|
|
30
|
+
* description: "Get the weather for a city",
|
|
31
|
+
* parameters: z.object({ city: z.string() }),
|
|
32
|
+
* execute: async ({ city }) => ({ temp: 72 }),
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* createAllemAgentHandler({ tools: { weather }, ... });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare function createAllemTool<TParams extends z.ZodType>(config: AllemToolConfig<TParams>): {
|
|
39
|
+
description: string;
|
|
40
|
+
parameters: TParams;
|
|
41
|
+
execute: (params: z.core.output<TParams>) => Promise<unknown>;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { type AllemAgentHandlerConfig, type AllemProviderName, type AllemToolConfig, createAllemAgentHandler, createAllemTool };
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/server.ts
|
|
21
|
+
var server_exports = {};
|
|
22
|
+
__export(server_exports, {
|
|
23
|
+
createAllemAgentHandler: () => createAllemAgentHandler,
|
|
24
|
+
createAllemTool: () => createAllemTool
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(server_exports);
|
|
27
|
+
|
|
28
|
+
// src/createAllemAgentHandler.ts
|
|
29
|
+
var import_ai = require("ai");
|
|
30
|
+
function createAllemAgentHandler(config) {
|
|
31
|
+
const {
|
|
32
|
+
providers,
|
|
33
|
+
defaultProvider = "google",
|
|
34
|
+
defaultModel,
|
|
35
|
+
systemPrompt: defaultSystemPrompt,
|
|
36
|
+
tools
|
|
37
|
+
} = config;
|
|
38
|
+
return async function handler(req) {
|
|
39
|
+
const body = await req.json();
|
|
40
|
+
const providerName = body.provider ?? defaultProvider;
|
|
41
|
+
const modelId = body.model ?? defaultModel;
|
|
42
|
+
const system = body.systemPrompt ?? defaultSystemPrompt;
|
|
43
|
+
const providerFactory = providers[providerName];
|
|
44
|
+
if (!providerFactory) {
|
|
45
|
+
return new Response(
|
|
46
|
+
JSON.stringify({ error: `Provider "${providerName}" is not configured.` }),
|
|
47
|
+
{ status: 400, headers: { "Content-Type": "application/json" } }
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
const model = providerFactory(modelId);
|
|
51
|
+
const modelMessages = await (0, import_ai.convertToModelMessages)(body.messages);
|
|
52
|
+
const result = (0, import_ai.streamText)({
|
|
53
|
+
model,
|
|
54
|
+
system,
|
|
55
|
+
messages: modelMessages,
|
|
56
|
+
tools
|
|
57
|
+
});
|
|
58
|
+
return result.toUIMessageStreamResponse();
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/createAllemTool.ts
|
|
63
|
+
function createAllemTool(config) {
|
|
64
|
+
return {
|
|
65
|
+
description: config.description,
|
|
66
|
+
parameters: config.parameters,
|
|
67
|
+
execute: config.execute
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
createAllemAgentHandler,
|
|
73
|
+
createAllemTool
|
|
74
|
+
});
|
package/dist/server.mjs
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/createAllemAgentHandler.ts
|
|
2
|
+
import {
|
|
3
|
+
streamText,
|
|
4
|
+
convertToModelMessages
|
|
5
|
+
} from "ai";
|
|
6
|
+
function createAllemAgentHandler(config) {
|
|
7
|
+
const {
|
|
8
|
+
providers,
|
|
9
|
+
defaultProvider = "google",
|
|
10
|
+
defaultModel,
|
|
11
|
+
systemPrompt: defaultSystemPrompt,
|
|
12
|
+
tools
|
|
13
|
+
} = config;
|
|
14
|
+
return async function handler(req) {
|
|
15
|
+
const body = await req.json();
|
|
16
|
+
const providerName = body.provider ?? defaultProvider;
|
|
17
|
+
const modelId = body.model ?? defaultModel;
|
|
18
|
+
const system = body.systemPrompt ?? defaultSystemPrompt;
|
|
19
|
+
const providerFactory = providers[providerName];
|
|
20
|
+
if (!providerFactory) {
|
|
21
|
+
return new Response(
|
|
22
|
+
JSON.stringify({ error: `Provider "${providerName}" is not configured.` }),
|
|
23
|
+
{ status: 400, headers: { "Content-Type": "application/json" } }
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
const model = providerFactory(modelId);
|
|
27
|
+
const modelMessages = await convertToModelMessages(body.messages);
|
|
28
|
+
const result = streamText({
|
|
29
|
+
model,
|
|
30
|
+
system,
|
|
31
|
+
messages: modelMessages,
|
|
32
|
+
tools
|
|
33
|
+
});
|
|
34
|
+
return result.toUIMessageStreamResponse();
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/createAllemTool.ts
|
|
39
|
+
function createAllemTool(config) {
|
|
40
|
+
return {
|
|
41
|
+
description: config.description,
|
|
42
|
+
parameters: config.parameters,
|
|
43
|
+
execute: config.execute
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
createAllemAgentHandler,
|
|
48
|
+
createAllemTool
|
|
49
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@allem-sdk/agents",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Agentic AI hooks for React with multi-step tool calling, status tracking, and typed tool definitions. Built on Vercel AI SDK.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Ahmed Allem",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./client": {
|
|
17
|
+
"types": "./dist/client.d.ts",
|
|
18
|
+
"import": "./dist/client.mjs",
|
|
19
|
+
"require": "./dist/client.js"
|
|
20
|
+
},
|
|
21
|
+
"./server": {
|
|
22
|
+
"types": "./dist/server.d.ts",
|
|
23
|
+
"import": "./dist/server.mjs",
|
|
24
|
+
"require": "./dist/server.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsup",
|
|
33
|
+
"dev": "tsup --watch",
|
|
34
|
+
"clean": "rm -rf dist",
|
|
35
|
+
"test": "vitest run"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@ai-sdk/react": "^3.0.187",
|
|
39
|
+
"@allem-sdk/ai": "workspace:*",
|
|
40
|
+
"@types/react": "^19.0.0",
|
|
41
|
+
"ai": "^6.0.185",
|
|
42
|
+
"react": "^19.0.0",
|
|
43
|
+
"tsup": "^8.4.0",
|
|
44
|
+
"typescript": "^5.8.0",
|
|
45
|
+
"vitest": "^3.0.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@allem-sdk/ai": ">=0.1.0",
|
|
49
|
+
"@ai-sdk/react": ">=3.0.0",
|
|
50
|
+
"ai": ">=6.0.0",
|
|
51
|
+
"react": ">=18.0.0",
|
|
52
|
+
"zod": ">=3.0.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"zod": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"repository": {
|
|
60
|
+
"type": "git",
|
|
61
|
+
"url": "https://github.com/kingofmit/allem-sdk.git",
|
|
62
|
+
"directory": "packages/agents"
|
|
63
|
+
},
|
|
64
|
+
"keywords": [
|
|
65
|
+
"allem-sdk",
|
|
66
|
+
"agents",
|
|
67
|
+
"ai",
|
|
68
|
+
"react",
|
|
69
|
+
"hooks",
|
|
70
|
+
"tools",
|
|
71
|
+
"multi-step",
|
|
72
|
+
"vercel-ai-sdk"
|
|
73
|
+
],
|
|
74
|
+
"publishConfig": {
|
|
75
|
+
"access": "public"
|
|
76
|
+
}
|
|
77
|
+
}
|