Skip to content

Applies to Cowork 0.1.41 · For everyone who uses Cowork

Connector ​

A Connector carries messages between one outside channel (a chat platform, a live room) and Cowork's Gateway. Register it with api.registerConnector(definition).

ConnectorDefinition ​

FieldTypeRequiredDescription
idstringYes in 0.1.41; No Not yet releasedLowercase letters, digits and hyphens. When dozin.connectors lists ids, it must be one of them; without that list any valid id works, up to 16 Connectors. In 0.1.41 it is required and must be listed. From the next version it defaults to the package name
systemPrompt Not yet releasedstringNoRules every chat of this Connector follows, at most 4000 characters; the person cannot edit them
chat Not yet released{ title, roles?, maxLength?, maxPerMinute? }NoMessages go into one chat that replies with gateway_send. title 1–80 characters; roles up to 16 entries, id lowercase (host, viewer, self) → label of 1–24 characters; maxLength 1–4000 (default 500); maxPerMinute 1–30 (default 6). An invalid chat is refused whole
start(ctx)functionYesSee below
stop()functionYesSee below
send(reply)functionYesSee below

start(ctx) ​

Called when the Connector starts. Open connections, timers and page observers here.

NameTypeDescription
ctxConnectorContextemit, log, and browser with that capability

Returns void or a promise. Limit: 5 seconds.

stop() ​

Called when the Connector stops. Close everything start opened. Must be safe to call more than once. Limit: 5 seconds.

send(reply) ​

Delivers one reply from Cowork to the channel.

NameTypeDescription
reply.textstringThe reply
reply.channelKeystringWhere it goes, as given by emit
reply.idempotencyKeystringThe same key is sent at most once
reply.replyTo Not yet released{ id, senderId, senderName, role }With chat: the message this answers

Returns Promise<{ ok: boolean, error?: string, externalKey?: string, verified?: boolean }>. externalKey is the platform's own key for this conversation. verified Not yet released means the reply was seen on the other side (defaults to ok).

Result errorWhen
send_timeoutsend took more than 30 seconds
unknown_connectorNo Connector with that id is registered
invalid_replyThe reply Cowork passed could not be read
invalid_send_resultsend returned something without a boolean ok
The thrown messagesend threw

ctx.emit(message) ​

Hands one incoming message to Cowork.

FieldTypeRequiredDescription
textstringYesWhat the chat shows
channelKeystringNo<connectorId>/<kind>/<channelId>; default <connectorId>/group/default
senderIdstringNoThe platform's fixed id of the sender
senderNamestringNoDisplay name
msgIdstringNoUsed to drop duplicates
atnumberNoPlatform time in milliseconds
triggerbooleanNofalse: context only, sent along with the next message that gets a reply
contextTextstringNoWhat the model reads instead of text
role Not yet releasedstringNoWith chat: who spoke (host, viewer, self); self is context only
modality Not yet released'text' | 'voice'Novoice: transcribed from speech

Returns nothing.

ctx.log(text) ​

Writes one line to the Extension's log. Returns nothing.

js
ctx.log('connected to room 42');

Example ​

js
export function activate(api) {
  let timer;
  api.registerConnector({
    id: 'demo',
    start(ctx) { timer = setInterval(() => ctx.emit({ text: 'ping', senderId: 'bot' }), 60000); },
    stop() { clearInterval(timer); },
    async send(reply) { return { ok: true }; }
  });
}

For Micromeet Cowork 0.1.41 · build 261111110020