Skip to Content
DocsPluginsComparisonChangelog
0
DocsChangelog

More

Discussionsllms.txtllms-full.txt
Getting startedWhat is concivComparisonRequirementsPlaygroundExamplesAPI reference

Engine and widgetSessionsHarnessesTools and code modeAgents and permissionsSkills

Use conciv
Bundlers
Agents
PluginsBuild your first plugin
Add a toolAsk for permissionAdd a skillShare an RPC methodCall from a terminalAdd a panelSlot or pillAdd settingsTest your plugin
Plugin API reference
PluginsGuides

Add a tool

Give the agent a tool that runs your code, choose how the agent calls it, and draw its calls as your own card.

A tool is a function in your plugin's engine part that the agent can call. This guide builds ticket_read, which reads a ticket from your tracker by its id.

Copy this prompt into your agent. It builds this in your project from this page.

Prompt
Build this in my project with conciv. conciv is a dev-only AI agent widget, and it already runs in my app.

1. Read https://conciv.dev/docs/plugins/guides/tool.md and follow it. It is the source of truth for the API.
2. If the project has the conciv-develop skill (conciv init installs it with the @conciv/skills docs pack), load it too.
3. Add a tool to my plugin in conciv/plugins.
4. If I did not say what it should do, ask me before you write code.
5. Give it a zod input, and fail with a clear message when it cannot do its job, as the page shows.
6. Install only the packages the page lists, with the package manager this project uses.
7. Check that the engine sees it: run `npx @conciv/cli tools --help` while the dev server runs. The new tool must be listed.
8. When you are done, tell me what you changed and how to see it.

Write the tool

Add tools inside ctx.tool.transform. Each tools.add call adds one:

conciv/plugins/tickets/server.ts
import {} from 'zod'
import {Plugin, } from '@conciv/backend-plugin-api'

const  = .({: .(), : .()})

export default Plugin.({
  : 'tickets',
  async () {
    await ..(() => {
      .({
        : 'ticket_read', // <- letters, digits and _
        : 'Read a ticket from the tracker by its id, such as OPS-42.',
        : .({: .().(/^OPS-[0-9]+$/)}), // <- checked before your code runs
        : ,
        : {: false},
        : async ({}, ) => {
          try {
            const  = await (`https://tickets.example.com/api/${}`, {: .})
            return {: .(await .())}
          } catch {
            throw .({: `The tracker did not answer for ${}.`})
          }
        },
      })
    })
  },
})
conciv/plugins/tickets/server.ts
import {} from 'effect'
import {} from 'zod'
import {Plugin} from '@conciv/backend-plugin-api/effect'
import * as  from '@conciv/protocol/schema/tool'

const  = .

export default Plugin.({
  : 'tickets',
  : () =>
    ..(() => {
      .
        : 'ticket_read', // <- letters, digits and _
        : 'Read a ticket from the tracker by its id, such as OPS-42.',
        : .
        : 
        : {: false},
        : ({
          .
            : async () => {
              const  = await (`https://tickets.example.com/api/${
              return .(
            },




Ask the agent "What is the status of OPS-42?". It calls ticket_read and answers from the ticket.

A few things to notice:

  • description is how the agent decides when to call the tool. Say what it does and what input it expects.
  • What you return as output is what the agent reads. It must match the output schema.
  • A network error and a bad shape both fail the call with the same message, in both tabs.
  • The signal aborts when the user stops the turn. Pass it to fetch so the request stops too.

Direct or code mode

A tool is a code-mode tool unless you set codemode: false. In code mode the agent writes a short TypeScript program that calls your tool as external_ticket_read. The call shows inside its code card. The agent calls a direct tool by its name. Each call gets its own card.

A tool called directly, then from code mode

A scripted session in the real panel. It plays in your browser, with no server.

conciv / transcript

A tool called directly, then from code mode

  1. You: Which version is this project?

    The agent calls project_version

    Called directly: vite-project 0.0.0.

  2. You: Read it again from code mode.

    The agent calls project_version

    From a code mode program.

    Same answer. In code mode the call runs inside a TypeScript program, and its card sits inside the program card.

Add an instruction…

The same tool in code mode, then as a direct tool

Pick direct when the user should see each call, or when you draw a card for it. Learn more in Tools and code mode.

Group tools under a namespace

A namespace puts related tools under one name and one description:

conciv/plugins/tickets/server.ts
import {} from 'zod'
import {Plugin} from '@conciv/backend-plugin-api'

export default Plugin.













The agent reads the namespace's description to decide which group to look at. content is plain text for the agent, in place of an output. A result can carry both.

Fail a call

Fail a call when the tool cannot do what was asked. The agent reads the message and can try something else:

conciv/plugins/tickets/server.ts
import {} from 'zod'
import {Plugin, } from '@conciv/backend-plugin-api'

















Tool.toolError makes the error. Its message is what the agent sees. In the Promise tab, any other thrown error also fails the call, with that error's message. In the Effect tab the failure type is Tool.Error.

Errors of your own come from one evlog error catalog, in your plugin's errors.ts. Each entry has a message, and why and fix where someone can act on it:

conciv/plugins/tickets/errors.ts
import {defineErrorCatalog} from 'evlog'

export const ticketErrors = defineErrorCatalog('tickets', {
  TRACKER_DOWN: {
    message: ({id}: {id: string}) =>








Fail with Effect.fail(ticketErrors.TRACKER_DOWN({id})). Turn it into a Tool.Error once, at the edge, and branch on error.code, never on a tag:

Effect.catchIf(
  (error) => error.code === ticketErrors.TRACKER_DOWN.code,
  (error) => Effect.fail(Tool.toolError({message: error.message, error})),
)

Draw a card

Each call of a direct tool shows as a card in the chat. Your plugin's browser part can draw its own. You write the browser part in Solid, React, Preact or plain DOM:

conciv/plugins/tickets/plugin-experimental.tsx

A few things to notice:

  • render draws one call. It runs again as the call moves on. props.input is the input the agent sent.
  • A denied or cancelled call reaches render too, with text that is not JSON. The guarded parse keeps the card up.
  • errorComponent draws a failed call, with the message in props.error. Without it the widget shows its error card.
  • A card that pulls in a large library can load on its first call: give render a component made with Solid's lazy(). Learn more in Load a part lazily.

Build or wire it as in Build or wire the browser part, then reload.

Next steps

  • Ask for permission: make the user approve a call before it runs.
  • Test your plugin: call your tool on a real engine in a test.
  • Plugin API reference: every field of a tool and its context.

Build your first plugin

Build a plugin from an empty folder to a tool the agent calls and a card you see in the chat.

Ask for permission

Make the user approve a tool call before it does something they would want to check.

On this page

Write the toolDirect or code modeGroup tools under a namespaceFail a callDraw a cardNext steps
Edit on GitHubView .mdOpen in ClaudeOpen in ChatGPT
: () => .
}).
})
}),
})
({
: 'tickets',
async () {
await ..(() => {
.({: 'ticket', : 'The team tracker: read and search tickets.'})
.({
: 'read',
: 'Read a ticket by its id, such as OPS-42.',
: .
: {: 'ticket'}, // <- the full name becomes ticket_read
: async ({}) => ({
})
})
},
})
conciv/plugins/tickets/server.ts
import {} from 'effect'
import {} from 'zod'
import {Plugin














export default Plugin.({
: 'tickets',
async () {
await ..(() => {
.({
: 'ticket_close',
: 'Close a ticket by its id.',
: .
: async ({})
if (.('SEC-'))
throw .
return {: `${} is closed.`}
},
})
})
},
})
conciv/plugins/tickets/server.ts
import {} from 'effect'
import {} from 'zod'
import {Plugin
















`The tracker did not answer for ${
id
}.`
,
fix: 'Check that the tracker is up, then ask again.',
},
})
declare module 'evlog' {
interface RegisteredErrorCatalogs {
tickets: typeof ticketErrors
}
}
import {Plugin,

The card lives in your app. Give it to <ConcivWidget> as in Build your first plugin.

src/conciv/tickets.tsx

The card lives in your app. Give it to <ConcivWidget> as in Build your first plugin.

src/conciv/tickets.tsx
conciv/plugins/tickets/plugin-experimental.ts
import {


































({
:
.
(),
:
.
()})
({
({
:
.
().
(
/
^
OPS-
[0-9]
+$
/
)}),
// <- checked before your code runs
,
})
=>
({
}`
, {
})
await
.
())
({
:
`The tracker did not answer for ${
}.`
}),
(
.
((
)
=>
({
:
}))),
({
:
.
()}),
:
`${
} is open.`
}),
}
from
'@conciv/backend-plugin-api/effect'
export default Plugin.({
: 'tickets',
: () =>
..(() => {
.({: 'ticket', : 'The team tracker: read and search tickets.'})
.({
: 'read',
: 'Read a ticket by its id, such as OPS-42.',
: .
: {: 'ticket'}, // <- the full name becomes ticket_read
: ({}) =>
})
}),
})
({
:
.
()}),
=>
{
({
:
'Security tickets are closed by the security team.'
})
}
from
'@conciv/backend-plugin-api/effect'
import * as from '@conciv/protocol/schema/tool'
export default Plugin.({
: 'tickets',
: () =>
..(() => {
.({
: 'ticket_close',
: 'Close a ticket by its id.',
: .
: ({}) =>
.('SEC-')
? .(
: .({
})
}),
})
}
from
'@conciv/frontend-plugin-api'
import {} from 'zod'
const = .
function (: string | undefined) {
try {
return .
} catch {
return
}
}
export default Plugin.
() {
.
: 'ticket_read',
: () => {
const = () =>
return (
<>
{()
? `${()?.}: ${
: . ===
? 'Reading the ticket'
: 'No ticket to show'}
</>
)
},
: () => <>The ticket could not be read: {.
})
},
})
import {
import {
,
Plugin
,
,
type
ToolProps
}
from
'@conciv/frontend-plugin-api'
import {} from 'zod'
const = .
function (: string | undefined) {
try {
const =
return `${.}: ${
} catch {
return === ? 'Reading the ticket' : 'No ticket to show'
}
}
function (: (
return
const = .(.
const = .(() => {
. = (.
})
return () => {
()
.()
}
})
}
export default Plugin.
() {
.
: 'ticket_read',
: (() =>
: (() => `The ticket could not be read: ${
})
},
})
({
:
.
()}),
.
({
:
`${
} is open.`
}),
({
:
.
()}),
.
({
:
'Security tickets are closed by the security team.'
}))
:
`${
} is closed.`
}),
({
:
.
(),
:
.
()})
(
.
(
??
''
)).
({
(
, {
(
.
)
// <- output is JSON text once the call ends
()?.
}`
}</
>,
// <- a failed call
,
type
Plugin
,
type
ToolProps
}
from
'@conciv/frontend-plugin-api'
import {} from '@conciv/react'
import {} from 'zod'
const = .
function (: string | undefined) {
try {
return .
} catch {
return
}
}
function (: ToolProps) {
const =
if () return <>{`${
return <>{. === ? 'Reading the ticket' : 'No ticket to show'}</>
}
function (: ToolProps) {
return <>The ticket could not be read: {.}</>
}
export const : Plugin.
.
: 'ticket_read',
: (
: (
})
}
,
type
Plugin
,
type
ToolProps
}
from
'@conciv/frontend-plugin-api'
import {} from '@conciv/preact'
import {} from 'zod'
const = .
function (: string | undefined) {
try {
return .
} catch {
return
}
}
function (: ToolProps) {
const =
if () return <>{`${
return <>{. === ? 'Reading the ticket' : 'No ticket to show'}</>
}
function (: ToolProps) {
return <>The ticket could not be read: {.}</>
}
export const : Plugin.
.
: 'ticket_read',
: (
: (
})
}
({
:
.
(),
:
.
()})
.
(
.
(
??
''
))
// <- output is JSON text once the call ends
.
}`
:
ToolProps
)
=>
string
) {
<
ToolProps
>((
,
)
=>
{
(
'p'
))
())
({
(
, {
(
.
)),
.
}`
),
// <- a failed call
({
:
.
(),
:
.
()})
(
.
(
??
''
)).
(
.
)
// <- output is JSON text once the call ends
.
}: ${
.
}`
}</
>
=
(
)
=>
{
(
, {
),
),
// <- a failed call
({
:
.
(),
:
.
()})
(
.
(
??
''
)).
(
.
)
// <- output is JSON text once the call ends
.
}: ${
.
}`
}</
>
=
(
)
=>
{
(
, {
),
),
// <- a failed call