kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feat: refactor stdlib packages to their own folder with MIT license
rodzic
b865682bdb
commit
74156b8e1f
6
license
6
license
|
@ -2,6 +2,12 @@ Agentic is open source licensed under the [GNU AGPL 3.0 license](https://choosea
|
|||
|
||||
Some of Agentic's public packages are licensed under the more permissive [MIT license](https://choosealicense.com/licenses/mit/). If a directory includes an MIT license file, that overrides the default. If it doesn't, then that code and all code under that subdirectory defaults to Agentic's general [GNU AGPL 3.0 license](https://choosealicense.com/licenses/agpl-3.0/).
|
||||
|
||||
All Agentic packages under the `apps/`, `examples/`, `docs/`, and `packages/` folders are AGPL-3.0 licensed.
|
||||
|
||||
All Agentic packages under the `stdlib/` folder are MIT licensed.
|
||||
|
||||
---
|
||||
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
import { EchoAITool } from '@agentic/core'
|
||||
import { describe, expect, test } from 'vitest'
|
||||
|
||||
import { createAISDKTools } from './ai-sdk'
|
||||
|
||||
describe('ai-sdk', () => {
|
||||
test('createAISDKTools', () => {
|
||||
expect(createAISDKTools(new EchoAITool())).toHaveProperty('echo')
|
||||
})
|
||||
})
|
|
@ -1,12 +0,0 @@
|
|||
import { EchoAITool } from '@agentic/core'
|
||||
import { Genkit } from 'genkit'
|
||||
import { describe, expect, test } from 'vitest'
|
||||
|
||||
import { createGenkitTools } from './genkit'
|
||||
|
||||
describe('genkit', () => {
|
||||
test('createGenkitTools', () => {
|
||||
const genkit = new Genkit()
|
||||
expect(createGenkitTools(genkit, new EchoAITool())).toHaveLength(1)
|
||||
})
|
||||
})
|
|
@ -1,35 +0,0 @@
|
|||
import type { Genkit } from 'genkit'
|
||||
import {
|
||||
type AIFunctionLike,
|
||||
AIFunctionSet,
|
||||
asZodOrJsonSchema,
|
||||
isZodSchema
|
||||
} from '@agentic/core'
|
||||
import { z } from 'zod'
|
||||
|
||||
/**
|
||||
* Converts a set of Agentic stdlib AI functions to an array of Genkit-
|
||||
* compatible tools.
|
||||
*/
|
||||
export function createGenkitTools(
|
||||
genkit: Genkit,
|
||||
...aiFunctionLikeTools: AIFunctionLike[]
|
||||
) {
|
||||
const fns = new AIFunctionSet(aiFunctionLikeTools)
|
||||
|
||||
return fns.map((fn) => {
|
||||
const inputSchemaKey = isZodSchema(fn.inputSchema)
|
||||
? ('inputSchema' as const)
|
||||
: ('inputJsonSchema' as const)
|
||||
|
||||
return genkit.defineTool(
|
||||
{
|
||||
name: fn.spec.name,
|
||||
description: fn.spec.description,
|
||||
[inputSchemaKey]: asZodOrJsonSchema(fn.inputSchema),
|
||||
outputSchema: z.any()
|
||||
},
|
||||
fn.execute
|
||||
)
|
||||
})
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
import { EchoAITool } from '@agentic/core'
|
||||
import { describe, expect, test } from 'vitest'
|
||||
|
||||
import { createLangChainTools } from './langchain'
|
||||
|
||||
describe('langchain', () => {
|
||||
test('createLangChainTools', () => {
|
||||
expect(createLangChainTools(new EchoAITool())).toHaveLength(1)
|
||||
})
|
||||
})
|
|
@ -1,29 +0,0 @@
|
|||
import {
|
||||
type AIFunctionLike,
|
||||
AIFunctionSet,
|
||||
asZodOrJsonSchema,
|
||||
stringifyForModel
|
||||
} from '@agentic/core'
|
||||
import { DynamicStructuredTool } from '@langchain/core/tools'
|
||||
|
||||
/**
|
||||
* Converts a set of Agentic stdlib AI functions to an array of LangChain-
|
||||
* compatible tools.
|
||||
*/
|
||||
export function createLangChainTools(...aiFunctionLikeTools: AIFunctionLike[]) {
|
||||
const fns = new AIFunctionSet(aiFunctionLikeTools)
|
||||
|
||||
return fns.map(
|
||||
(fn) =>
|
||||
new DynamicStructuredTool({
|
||||
name: fn.spec.name,
|
||||
description: fn.spec.description,
|
||||
schema: asZodOrJsonSchema(fn.inputSchema),
|
||||
func: async (input) => {
|
||||
const result = await Promise.resolve(fn.execute(input))
|
||||
// LangChain tools require the output to be a string
|
||||
return stringifyForModel(result)
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
import { EchoAITool } from '@agentic/core'
|
||||
import { describe, expect, test } from 'vitest'
|
||||
|
||||
import { createLlamaIndexTools } from './llamaindex'
|
||||
|
||||
describe('llamaindex', () => {
|
||||
test('createLlamaIndexTools', () => {
|
||||
expect(createLlamaIndexTools(new EchoAITool())).toHaveLength(1)
|
||||
})
|
||||
})
|
|
@ -1,25 +0,0 @@
|
|||
import {
|
||||
type AIFunctionLike,
|
||||
AIFunctionSet,
|
||||
asZodOrJsonSchema
|
||||
} from '@agentic/core'
|
||||
import { FunctionTool } from 'llamaindex'
|
||||
|
||||
/**
|
||||
* Converts a set of Agentic stdlib AI functions to an array of LlamaIndex-
|
||||
* compatible tools.
|
||||
*/
|
||||
export function createLlamaIndexTools(
|
||||
...aiFunctionLikeTools: AIFunctionLike[]
|
||||
) {
|
||||
const fns = new AIFunctionSet(aiFunctionLikeTools)
|
||||
|
||||
return fns.map((fn) =>
|
||||
FunctionTool.from(fn.execute, {
|
||||
name: fn.spec.name,
|
||||
description: fn.spec.description,
|
||||
// TODO: Investigate types here
|
||||
parameters: asZodOrJsonSchema(fn.inputSchema) as any
|
||||
})
|
||||
)
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
import { EchoAITool } from '@agentic/core'
|
||||
import { describe, expect, test } from 'vitest'
|
||||
|
||||
import { createMastraTools } from './mastra'
|
||||
|
||||
describe('mastra', () => {
|
||||
test('createMastraTools', () => {
|
||||
expect(createMastraTools(new EchoAITool())).toHaveProperty('echo')
|
||||
})
|
||||
})
|
|
@ -1,30 +0,0 @@
|
|||
import { type AIFunctionLike, AIFunctionSet, isZodSchema } from '@agentic/core'
|
||||
import { createTool } from '@mastra/core/tools'
|
||||
|
||||
/**
|
||||
* Converts a set of Agentic stdlib AI functions to an object compatible with
|
||||
* the Mastra Agent `tools` format.
|
||||
*/
|
||||
export function createMastraTools(...aiFunctionLikeTools: AIFunctionLike[]) {
|
||||
const fns = new AIFunctionSet(aiFunctionLikeTools)
|
||||
|
||||
return Object.fromEntries(
|
||||
fns.map((fn) => {
|
||||
if (!isZodSchema(fn.inputSchema)) {
|
||||
throw new Error(
|
||||
`Mastra tools only support Zod schemas: ${fn.spec.name} tool uses a custom JSON Schema, which is currently not supported.`
|
||||
)
|
||||
}
|
||||
|
||||
return [
|
||||
fn.spec.name,
|
||||
createTool({
|
||||
id: fn.spec.name,
|
||||
description: fn.spec.description,
|
||||
inputSchema: fn.inputSchema,
|
||||
execute: (ctx) => fn.execute(ctx.context)
|
||||
})
|
||||
]
|
||||
})
|
||||
)
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
import { EchoAITool } from '@agentic/core'
|
||||
import { describe, expect, test } from 'vitest'
|
||||
|
||||
import { createXSAITools } from './xsai'
|
||||
|
||||
describe('xsai', () => {
|
||||
test('createXSAITools', async () => {
|
||||
const tools = await createXSAITools(new EchoAITool())
|
||||
expect(tools).toHaveLength(1)
|
||||
expect(tools[0]!.function.name).toBe('echo')
|
||||
})
|
||||
})
|
|
@ -1,31 +0,0 @@
|
|||
import { type AIFunctionLike, AIFunctionSet, isZodSchema } from '@agentic/core'
|
||||
import { tool } from '@xsai/tool'
|
||||
|
||||
export type Tool = Awaited<ReturnType<typeof tool>>
|
||||
|
||||
/**
|
||||
* Converts a set of Agentic stdlib AI functions to an object compatible with
|
||||
* the [xsAI SDK's](https://github.com/moeru-ai/xsai) `tools` parameter.
|
||||
*/
|
||||
export function createXSAITools(
|
||||
...aiFunctionLikeTools: AIFunctionLike[]
|
||||
): Promise<Tool[]> {
|
||||
const fns = new AIFunctionSet(aiFunctionLikeTools)
|
||||
|
||||
return Promise.all(
|
||||
fns.map((fn) => {
|
||||
if (!isZodSchema(fn.inputSchema)) {
|
||||
throw new Error(
|
||||
`xsAI tools only support Standard schemas like Zod: ${fn.spec.name} tool uses a custom JSON Schema, which is currently not supported.`
|
||||
)
|
||||
}
|
||||
|
||||
return tool({
|
||||
name: fn.spec.name,
|
||||
description: fn.spec.description,
|
||||
parameters: fn.inputSchema,
|
||||
execute: fn.execute
|
||||
})
|
||||
})
|
||||
)
|
||||
}
|
635
pnpm-lock.yaml
635
pnpm-lock.yaml
Plik diff jest za duży
Load Diff
|
@ -1,5 +1,6 @@
|
|||
packages:
|
||||
- packages/*
|
||||
- stdlib/*
|
||||
- apps/*
|
||||
- examples/*
|
||||
- packages/fixtures/valid/*
|
||||
|
@ -18,7 +19,7 @@ catalog:
|
|||
'@dicebear/core': ^9.2.3
|
||||
'@dotenvx/dotenvx': ^1.45.1
|
||||
'@edge-runtime/vm': ^5.0.0
|
||||
'@fisch0920/config': ^1.1.3
|
||||
'@fisch0920/config': ^1.1.4
|
||||
'@fisch0920/drizzle-orm': ^0.43.7
|
||||
'@fisch0920/drizzle-zod': ^0.7.9
|
||||
'@hono/mcp': ^0.1.0
|
||||
|
@ -106,7 +107,7 @@ catalog:
|
|||
is-obj: ^3.0.0
|
||||
is-relative-url: ^4.0.0
|
||||
jsonrepair: ^3.12.0
|
||||
knip: ^5.61.2
|
||||
knip: ^5.61.3
|
||||
ky: ^1.8.1
|
||||
langchain: ^0.3.29
|
||||
lint-staged: ^16.1.2
|
||||
|
@ -174,3 +175,5 @@ ignoredBuiltDependencies:
|
|||
|
||||
onlyBuiltDependencies:
|
||||
- '@sentry/cli'
|
||||
- protobufjs
|
||||
- tree-sitter
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/transitive-bullshit/agentic.git",
|
||||
"directory": "packages/ai-sdk"
|
||||
"directory": "stdlib/ai-sdk"
|
||||
},
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
|
@ -0,0 +1,14 @@
|
|||
import { EchoAITool } from '@agentic/core'
|
||||
import { expect, test } from 'vitest'
|
||||
|
||||
import { createAISDKTools, createAISDKToolsFromIdentifier } from './ai-sdk'
|
||||
|
||||
test('createAISDKTools', () => {
|
||||
expect(createAISDKTools(new EchoAITool())).toHaveProperty('echo')
|
||||
})
|
||||
|
||||
test('createAISDKToolsFromIdentifier', async () => {
|
||||
await expect(
|
||||
createAISDKToolsFromIdentifier('@agentic/search')
|
||||
).resolves.toHaveProperty('search')
|
||||
})
|
|
@ -10,16 +10,18 @@ import {
|
|||
} from '@agentic/platform-tool-client'
|
||||
import { jsonSchema, type Tool, tool } from 'ai'
|
||||
|
||||
export type AISDKTools = Record<
|
||||
string,
|
||||
Tool & { execute: (args: any, options: any) => PromiseLike<any> }
|
||||
>
|
||||
|
||||
/**
|
||||
* Converts a set of Agentic stdlib AI functions to an object compatible with
|
||||
* the Vercel AI SDK's `tools` parameter.
|
||||
*/
|
||||
export function createAISDKTools(
|
||||
...aiFunctionLikeTools: AIFunctionLike[]
|
||||
): Record<
|
||||
string,
|
||||
Tool & { execute: (args: any, options: any) => PromiseLike<any> }
|
||||
> {
|
||||
): AISDKTools {
|
||||
const fns = new AIFunctionSet(aiFunctionLikeTools)
|
||||
|
||||
return Object.fromEntries(
|
||||
|
@ -36,14 +38,28 @@ export function createAISDKTools(
|
|||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Vercel AI SDK's `tools` object from a hosted Agentic project or
|
||||
* deployment identifier.
|
||||
*
|
||||
* You'll generally use a project identifier, which will automatically use
|
||||
* that project's `latest` version, but if you want to target a specific
|
||||
* version or preview deployment, you can use a fully-qualified deployment
|
||||
* identifier.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const tools = await createAISDKToolsFromIdentifier('@agentic/search')
|
||||
* ```
|
||||
*/
|
||||
export async function createAISDKToolsFromIdentifier(
|
||||
projectOrDeploymentIdentifier: string,
|
||||
opts: AgenticToolClientOptions = {}
|
||||
) {
|
||||
const toolClient = await AgenticToolClient.fromIdentifier(
|
||||
): Promise<AISDKTools> {
|
||||
const agenticToolClient = await AgenticToolClient.fromIdentifier(
|
||||
projectOrDeploymentIdentifier,
|
||||
opts
|
||||
)
|
||||
|
||||
return createAISDKTools(toolClient)
|
||||
return createAISDKTools(agenticToolClient)
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/transitive-bullshit/agentic.git",
|
||||
"directory": "packages/core"
|
||||
"directory": "stdlib/core"
|
||||
},
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
|
@ -7,7 +7,7 @@
|
|||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/transitive-bullshit/agentic.git",
|
||||
"directory": "packages/genkit"
|
||||
"directory": "stdlib/genkit"
|
||||
},
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
|
@ -24,7 +24,8 @@
|
|||
"test:unit": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@agentic/core": "workspace:*"
|
||||
"@agentic/core": "workspace:*",
|
||||
"@agentic/platform-tool-client": "workspace:*"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"genkit": "catalog:"
|
|
@ -0,0 +1,17 @@
|
|||
import { EchoAITool } from '@agentic/core'
|
||||
import { Genkit } from 'genkit'
|
||||
import { expect, test } from 'vitest'
|
||||
|
||||
import { createGenkitTools, createGenkitToolsFromIdentifier } from './genkit'
|
||||
|
||||
test('createGenkitTools', () => {
|
||||
const genkit = new Genkit()
|
||||
expect(createGenkitTools(genkit, new EchoAITool())).toHaveLength(1)
|
||||
})
|
||||
|
||||
test('createGenkitToolsFromIdentifier', async () => {
|
||||
const genkit = new Genkit()
|
||||
const tools = await createGenkitToolsFromIdentifier(genkit, '@agentic/search')
|
||||
expect(tools).toHaveLength(1)
|
||||
expect(tools[0]!.name).toBe('search')
|
||||
})
|
|
@ -0,0 +1,68 @@
|
|||
import type { Genkit } from 'genkit'
|
||||
import {
|
||||
type AIFunctionLike,
|
||||
AIFunctionSet,
|
||||
asZodOrJsonSchema,
|
||||
isZodSchema
|
||||
} from '@agentic/core'
|
||||
import {
|
||||
AgenticToolClient,
|
||||
type AgenticToolClientOptions
|
||||
} from '@agentic/platform-tool-client'
|
||||
import { z } from 'zod'
|
||||
|
||||
export type GenkitTool = ReturnType<Genkit['defineTool']>
|
||||
|
||||
/**
|
||||
* Converts a set of Agentic stdlib AI functions to an array of Genkit tools.
|
||||
*/
|
||||
export function createGenkitTools(
|
||||
genkit: Genkit,
|
||||
...aiFunctionLikeTools: AIFunctionLike[]
|
||||
): GenkitTool[] {
|
||||
const fns = new AIFunctionSet(aiFunctionLikeTools)
|
||||
|
||||
return fns.map((fn) => {
|
||||
const inputSchemaKey = isZodSchema(fn.inputSchema)
|
||||
? ('inputSchema' as const)
|
||||
: ('inputJsonSchema' as const)
|
||||
|
||||
return genkit.defineTool(
|
||||
{
|
||||
name: fn.spec.name,
|
||||
description: fn.spec.description,
|
||||
[inputSchemaKey]: asZodOrJsonSchema(fn.inputSchema),
|
||||
outputSchema: z.any()
|
||||
},
|
||||
fn.execute
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array of Genkit tools from a hosted Agentic project or deployment
|
||||
* identifier.
|
||||
*
|
||||
* You'll generally use a project identifier, which will automatically use
|
||||
* that project's `latest` version, but if you want to target a specific
|
||||
* version or preview deployment, you can use a fully-qualified deployment
|
||||
* identifier.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const genkit = new Genkit()
|
||||
* const tools = await createGenkitToolsFromIdentifier(genkit, '@agentic/search')
|
||||
* ```
|
||||
*/
|
||||
export async function createGenkitToolsFromIdentifier(
|
||||
genkit: Genkit,
|
||||
projectOrDeploymentIdentifier: string,
|
||||
opts: AgenticToolClientOptions = {}
|
||||
): Promise<GenkitTool[]> {
|
||||
const agenticToolClient = await AgenticToolClient.fromIdentifier(
|
||||
projectOrDeploymentIdentifier,
|
||||
opts
|
||||
)
|
||||
|
||||
return createGenkitTools(genkit, agenticToolClient)
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/transitive-bullshit/agentic.git",
|
||||
"directory": "packages/langchain"
|
||||
"directory": "stdlib/langchain"
|
||||
},
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
|
@ -24,7 +24,8 @@
|
|||
"test:unit": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@agentic/core": "workspace:*"
|
||||
"@agentic/core": "workspace:*",
|
||||
"@agentic/platform-tool-client": "workspace:*"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@langchain/core": "catalog:"
|
|
@ -0,0 +1,17 @@
|
|||
import { EchoAITool } from '@agentic/core'
|
||||
import { expect, test } from 'vitest'
|
||||
|
||||
import {
|
||||
createLangChainTools,
|
||||
createLangChainToolsFromIdentifier
|
||||
} from './langchain'
|
||||
|
||||
test('createLangChainTools', () => {
|
||||
expect(createLangChainTools(new EchoAITool())).toHaveLength(1)
|
||||
})
|
||||
|
||||
test('createLangChainToolsFromIdentifier', async () => {
|
||||
const tools = await createLangChainToolsFromIdentifier('@agentic/search')
|
||||
expect(tools).toHaveLength(1)
|
||||
expect(tools[0]!.name).toBe('search')
|
||||
})
|
|
@ -0,0 +1,61 @@
|
|||
import {
|
||||
type AIFunctionLike,
|
||||
AIFunctionSet,
|
||||
asZodOrJsonSchema,
|
||||
stringifyForModel
|
||||
} from '@agentic/core'
|
||||
import {
|
||||
AgenticToolClient,
|
||||
type AgenticToolClientOptions
|
||||
} from '@agentic/platform-tool-client'
|
||||
import { DynamicStructuredTool } from '@langchain/core/tools'
|
||||
|
||||
/**
|
||||
* Converts a set of Agentic stdlib AI functions to an array of LangChain
|
||||
* tools (`DynamicStructuredTool[]`).
|
||||
*/
|
||||
export function createLangChainTools(
|
||||
...aiFunctionLikeTools: AIFunctionLike[]
|
||||
): DynamicStructuredTool[] {
|
||||
const fns = new AIFunctionSet(aiFunctionLikeTools)
|
||||
|
||||
return fns.map(
|
||||
(fn) =>
|
||||
new DynamicStructuredTool({
|
||||
name: fn.spec.name,
|
||||
description: fn.spec.description,
|
||||
schema: asZodOrJsonSchema(fn.inputSchema),
|
||||
func: async (input) => {
|
||||
const result = await Promise.resolve(fn.execute(input))
|
||||
// LangChain tools require the output to be a string
|
||||
return stringifyForModel(result)
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Vercel AI SDK's `tools` object from a hosted Agentic project or
|
||||
* deployment identifier.
|
||||
*
|
||||
* You'll generally use a project identifier, which will automatically use
|
||||
* that project's `latest` version, but if you want to target a specific
|
||||
* version or preview deployment, you can use a fully-qualified deployment
|
||||
* identifier.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const tools = await createLangChainToolsFromIdentifier('@agentic/search')
|
||||
* ```
|
||||
*/
|
||||
export async function createLangChainToolsFromIdentifier(
|
||||
projectOrDeploymentIdentifier: string,
|
||||
opts: AgenticToolClientOptions = {}
|
||||
): Promise<DynamicStructuredTool[]> {
|
||||
const agenticToolClient = await AgenticToolClient.fromIdentifier(
|
||||
projectOrDeploymentIdentifier,
|
||||
opts
|
||||
)
|
||||
|
||||
return createLangChainTools(agenticToolClient)
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
All Agentic packages under the `stdlib/` folder are MIT licensed.
|
||||
|
||||
---
|
||||
|
||||
**MIT License**
|
||||
|
||||
Copyright (c) 2025 Travis Fischer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -7,7 +7,7 @@
|
|||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/transitive-bullshit/agentic.git",
|
||||
"directory": "packages/llamaindex"
|
||||
"directory": "stdlib/llamaindex"
|
||||
},
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
|
@ -24,7 +24,8 @@
|
|||
"test:unit": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@agentic/core": "workspace:*"
|
||||
"@agentic/core": "workspace:*",
|
||||
"@agentic/platform-tool-client": "workspace:*"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"llamaindex": "catalog:"
|
|
@ -0,0 +1,17 @@
|
|||
import { EchoAITool } from '@agentic/core'
|
||||
import { expect, test } from 'vitest'
|
||||
|
||||
import {
|
||||
createLlamaIndexTools,
|
||||
createLlamaIndexToolsFromIdentifier
|
||||
} from './llamaindex'
|
||||
|
||||
test('createLlamaIndexTools', () => {
|
||||
expect(createLlamaIndexTools(new EchoAITool())).toHaveLength(1)
|
||||
})
|
||||
|
||||
test('createLlamaIndexToolsFromIdentifier', async () => {
|
||||
const tools = await createLlamaIndexToolsFromIdentifier('@agentic/search')
|
||||
expect(tools).toHaveLength(1)
|
||||
expect(tools[0]!.metadata.name).toBe('search')
|
||||
})
|
|
@ -0,0 +1,57 @@
|
|||
import {
|
||||
type AIFunctionLike,
|
||||
AIFunctionSet,
|
||||
asZodOrJsonSchema
|
||||
} from '@agentic/core'
|
||||
import {
|
||||
AgenticToolClient,
|
||||
type AgenticToolClientOptions
|
||||
} from '@agentic/platform-tool-client'
|
||||
import { FunctionTool, type JSONValue } from 'llamaindex'
|
||||
|
||||
export type LlamaIndexTool = FunctionTool<any, JSONValue | Promise<JSONValue>>
|
||||
|
||||
/**
|
||||
* Converts a set of Agentic stdlib AI functions to an array of LlamaIndex
|
||||
* tools (`FunctionTool[]`).
|
||||
*/
|
||||
export function createLlamaIndexTools(
|
||||
...aiFunctionLikeTools: AIFunctionLike[]
|
||||
): LlamaIndexTool[] {
|
||||
const fns = new AIFunctionSet(aiFunctionLikeTools)
|
||||
|
||||
return fns.map((fn) =>
|
||||
FunctionTool.from(fn.execute, {
|
||||
name: fn.spec.name,
|
||||
description: fn.spec.description,
|
||||
// TODO: Investigate types here
|
||||
parameters: asZodOrJsonSchema(fn.inputSchema) as any
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array of LlamaIndex tools from a hosted Agentic project or
|
||||
* deployment identifier.
|
||||
*
|
||||
* You'll generally use a project identifier, which will automatically use
|
||||
* that project's `latest` version, but if you want to target a specific
|
||||
* version or preview deployment, you can use a fully-qualified deployment
|
||||
* identifier.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const tools = await createLlamaIndexToolsFromIdentifier('@agentic/search')
|
||||
* ```
|
||||
*/
|
||||
export async function createLlamaIndexToolsFromIdentifier(
|
||||
projectOrDeploymentIdentifier: string,
|
||||
opts: AgenticToolClientOptions = {}
|
||||
): Promise<LlamaIndexTool[]> {
|
||||
const agenticToolClient = await AgenticToolClient.fromIdentifier(
|
||||
projectOrDeploymentIdentifier,
|
||||
opts
|
||||
)
|
||||
|
||||
return createLlamaIndexTools(agenticToolClient)
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/transitive-bullshit/agentic.git",
|
||||
"directory": "packages/mastra"
|
||||
"directory": "stdlib/mastra"
|
||||
},
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
|
@ -24,7 +24,8 @@
|
|||
"test:unit": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@agentic/core": "workspace:*"
|
||||
"@agentic/core": "workspace:*",
|
||||
"@agentic/platform-tool-client": "workspace:*"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mastra/core": "catalog:"
|
|
@ -0,0 +1,13 @@
|
|||
import { EchoAITool } from '@agentic/core'
|
||||
import { expect, test } from 'vitest'
|
||||
|
||||
import { createMastraTools, createMastraToolsFromIdentifier } from './mastra'
|
||||
|
||||
test('createMastraTools', () => {
|
||||
expect(createMastraTools(new EchoAITool())).toHaveProperty('echo')
|
||||
})
|
||||
|
||||
test('createMastraToolsFromIdentifier', async () => {
|
||||
const tools = await createMastraToolsFromIdentifier('@agentic/search')
|
||||
expect(tools).toHaveProperty('search')
|
||||
})
|
|
@ -0,0 +1,64 @@
|
|||
import { type AIFunctionLike, AIFunctionSet, isZodSchema } from '@agentic/core'
|
||||
import {
|
||||
AgenticToolClient,
|
||||
type AgenticToolClientOptions
|
||||
} from '@agentic/platform-tool-client'
|
||||
import { createTool } from '@mastra/core/tools'
|
||||
|
||||
export type MastraTool = ReturnType<typeof createTool>
|
||||
|
||||
/**
|
||||
* Converts a set of Agentic stdlib AI functions to an object compatible with
|
||||
* the Mastra Agent `tools` parameter.
|
||||
*/
|
||||
export function createMastraTools(
|
||||
...aiFunctionLikeTools: AIFunctionLike[]
|
||||
): Record<string, MastraTool> {
|
||||
const fns = new AIFunctionSet(aiFunctionLikeTools)
|
||||
|
||||
return Object.fromEntries(
|
||||
fns.map((fn) => {
|
||||
if (!isZodSchema(fn.inputSchema)) {
|
||||
throw new Error(
|
||||
`Mastra tools only support Zod schemas: ${fn.spec.name} tool uses a custom JSON Schema, which is currently not supported.`
|
||||
)
|
||||
}
|
||||
|
||||
return [
|
||||
fn.spec.name,
|
||||
createTool({
|
||||
id: fn.spec.name,
|
||||
description: fn.spec.description,
|
||||
inputSchema: fn.inputSchema,
|
||||
execute: (ctx) => fn.execute(ctx.context)
|
||||
})
|
||||
]
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Mastra Agent `tools` object from a hosted Agentic project or
|
||||
* deployment identifier.
|
||||
*
|
||||
* You'll generally use a project identifier, which will automatically use
|
||||
* that project's `latest` version, but if you want to target a specific
|
||||
* version or preview deployment, you can use a fully-qualified deployment
|
||||
* identifier.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const tools = await createMastraToolsFromIdentifier('@agentic/search')
|
||||
* ```
|
||||
*/
|
||||
export async function createMastraToolsFromIdentifier(
|
||||
projectOrDeploymentIdentifier: string,
|
||||
opts: AgenticToolClientOptions = {}
|
||||
): Promise<Record<string, MastraTool>> {
|
||||
const agenticToolClient = await AgenticToolClient.fromIdentifier(
|
||||
projectOrDeploymentIdentifier,
|
||||
opts
|
||||
)
|
||||
|
||||
return createMastraTools(agenticToolClient)
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/transitive-bullshit/agentic.git",
|
||||
"directory": "packages/mcp"
|
||||
"directory": "stdlib/mcp"
|
||||
},
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
|
@ -7,7 +7,7 @@
|
|||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/transitive-bullshit/agentic.git",
|
||||
"directory": "packages/xsai"
|
||||
"directory": "stdlib/xsai"
|
||||
},
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
|
@ -24,7 +24,8 @@
|
|||
"test:unit": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@agentic/core": "workspace:*"
|
||||
"@agentic/core": "workspace:*",
|
||||
"@agentic/platform-tool-client": "workspace:*"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@xsai/tool": "catalog:"
|
|
@ -0,0 +1,16 @@
|
|||
import { EchoAITool } from '@agentic/core'
|
||||
import { expect, test } from 'vitest'
|
||||
|
||||
import { createXSAITools, createXSAIToolsFromIdentifier } from './xsai'
|
||||
|
||||
test('createXSAITools', async () => {
|
||||
const tools = await createXSAITools(new EchoAITool())
|
||||
expect(tools).toHaveLength(1)
|
||||
expect(tools[0]!.function.name).toBe('echo')
|
||||
})
|
||||
|
||||
test('createXSAIToolsFromIdentifier', async () => {
|
||||
const tools = await createXSAIToolsFromIdentifier('@agentic/search')
|
||||
expect(tools).toHaveLength(1)
|
||||
expect(tools[0]!.function.name).toBe('search')
|
||||
})
|
|
@ -0,0 +1,61 @@
|
|||
import { type AIFunctionLike, AIFunctionSet, isZodSchema } from '@agentic/core'
|
||||
import {
|
||||
AgenticToolClient,
|
||||
type AgenticToolClientOptions
|
||||
} from '@agentic/platform-tool-client'
|
||||
import { tool } from '@xsai/tool'
|
||||
|
||||
export type XSAITool = Awaited<ReturnType<typeof tool>>
|
||||
|
||||
/**
|
||||
* Converts a set of Agentic stdlib AI functions to an object compatible with
|
||||
* the [xsAI SDK's](https://github.com/moeru-ai/xsai) `tools` parameter.
|
||||
*/
|
||||
export function createXSAITools(
|
||||
...aiFunctionLikeTools: AIFunctionLike[]
|
||||
): Promise<XSAITool[]> {
|
||||
const fns = new AIFunctionSet(aiFunctionLikeTools)
|
||||
|
||||
return Promise.all(
|
||||
fns.map((fn) => {
|
||||
if (!isZodSchema(fn.inputSchema)) {
|
||||
throw new Error(
|
||||
`xsAI tools only support Standard schemas like Zod: ${fn.spec.name} tool uses a custom JSON Schema, which is currently not supported.`
|
||||
)
|
||||
}
|
||||
|
||||
return tool({
|
||||
name: fn.spec.name,
|
||||
description: fn.spec.description,
|
||||
parameters: fn.inputSchema,
|
||||
execute: fn.execute
|
||||
})
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array of xsAI tools from a hosted Agentic project or deployment
|
||||
* identifier.
|
||||
*
|
||||
* You'll generally use a project identifier, which will automatically use
|
||||
* that project's `latest` version, but if you want to target a specific
|
||||
* version or preview deployment, you can use a fully-qualified deployment
|
||||
* identifier.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const tools = await createXSAIToolsFromIdentifier('@agentic/search')
|
||||
* ```
|
||||
*/
|
||||
export async function createXSAIToolsFromIdentifier(
|
||||
projectOrDeploymentIdentifier: string,
|
||||
opts: AgenticToolClientOptions = {}
|
||||
): Promise<XSAITool[]> {
|
||||
const agenticToolClient = await AgenticToolClient.fromIdentifier(
|
||||
projectOrDeploymentIdentifier,
|
||||
opts
|
||||
)
|
||||
|
||||
return createXSAITools(agenticToolClient)
|
||||
}
|
5
todo.md
5
todo.md
|
@ -17,14 +17,13 @@
|
|||
- hosted docs
|
||||
- social images
|
||||
- add really strict free rate-limits to `@agentic/search`
|
||||
- **simplify `AgenticToolClient` and only require one package per TS LLM SDK**
|
||||
- `createAISDKToolsFromIdentifier(projectIdentifier)`
|
||||
- **move legacy packages, examples, and docs over**
|
||||
- replace json project and components with actual designs
|
||||
- implement footer
|
||||
- finesse header (mobile)
|
||||
- create agentic products for legacy tools
|
||||
- add basic legal terms and privacy policy (and update links in stripe)
|
||||
- add caching to public projects api endpoints
|
||||
|
||||
## TODO: Post-MVP
|
||||
|
||||
|
@ -104,3 +103,5 @@
|
|||
- platform AGPL-3.0 private
|
||||
- platform AGPL-3.0 public; maybe this should be MIT?
|
||||
- stdlib MIT public
|
||||
- **simplify `AgenticToolClient` and only require one package per TS LLM SDK**
|
||||
- `createAISDKToolsFromIdentifier(projectIdentifier)`
|
||||
|
|
Ładowanie…
Reference in New Issue