Add connector tools
Turn typed external API actions into agent tools.
Use connectors when you want reusable actions over external services.
See Connectors catalog for built-in modules and action ids.
Build an integration
import { makeCredentialBinding, makeIntegration } from '@yolk-sdk/connectors'
import { TelegramBotTokenSlot } from '@yolk-sdk/connectors/telegram'
const integration = makeIntegration({
connectorId: 'telegram',
config: { chatId: '123456' },
credentialBindings: [
makeCredentialBinding({
slotId: TelegramBotTokenSlot.id,
credentialRef: 'telegram-bot-token'
})
]
})Expose connector actions as tools
import { makeConnectorToolModule } from '@yolk-sdk/connectors/agent'
import { TelegramConnector } from '@yolk-sdk/connectors/telegram'
const telegramTools = makeConnectorToolModule(TelegramConnector, {
integration,
layer: HostConnectorLayer,
access: action => (action === 'telegram.send_message' ? 'write' : 'read')
})Your HostConnectorLayer provides credentials and HTTP execution. When access is omitted, the
adapter uses the action's declared read, write, or destructive access and falls back to read
for legacy actions without metadata. A host-provided value or resolver overrides action metadata.
Microsoft and Google Drive actions declare write/destructive access where applicable. Generic email
declares reads as read, IMAP draft/read-state/restore actions as write, and trash/SMTP submission
as destructive. Its mailbox-state actions require optional host adapter methods; keep
explicit host classification for other connectors until their actions do.
The module's description is the connector's description (override it with the description
option); code mode shows it under the module's heading. Each tool declares the action's
outputSchema, and a successful call returns its JSON encoding (Schema.toCodecJson) as both
structuredContent and the text content: Chunks become arrays and dates ISO strings. Fields not
declared in outputSchema are not returned (Effect toCodecJson encoding drops undeclared keys and
requires JSON values for Schema.Unknown). A value that does not encode fails the call with an
execution error. Provider failures return an error result
whose structuredContent is the JSON-encoded ProviderFailure (a non-JSON underlying is dropped).
Use directly without an agent
import { Effect } from 'effect'
const result = await Effect.runPromise(
TelegramConnector.invoke({
integration,
action: 'telegram.send_message',
input: { message: 'Hello from Yolk' }
}).pipe(Effect.provide(HostConnectorLayer))
)