Skip to content

Applies to Cowork 0.1.41 · For everyone who uses Cowork

Entry and Registration ​

activate(api) ​

The function your entry file exports. Cowork calls it once each time it starts the Extension's process.

js
export function activate(api) {
  api.registerService({ id: 'sync', start: 'auto', async run(ctx) { /* ... */ } });
  return () => { /* optional cleanup */ };
}

Parameters ​

NameTypeDescription
apiDozinAPIThe registration functions below

Returns ​

Nothing, or a cleanup function (it may be async), or a promise of either. The cleanup function runs when the process stops and must be safe to call more than once.

Limits ​

  • activate has 5 seconds. Start timers and connections in a Connector's start or a task's run, not here.
  • If it throws or times out, the Extension shows as failed in Settings › Extensions.

api.registerConnector(definition) ​

Registers a Connector: the part that carries messages between an outside channel and Cowork's Gateway.

Parameters ​

NameTypeRequiredDescription
definitionConnectorDefinitionYesSee Connector

Returns ​

Nothing.

Throws ​

ErrorWhen
TypeErrorstart, stop or send missing; id not lowercase letters, digits and hyphens; systemPrompt over 4000 characters; invalid chat
CapabilityDeniedErrorCalled after activate has returned; dozin.connectors lists ids and this id is not one of them; the same id twice; more than 16 Connectors when dozin.connectors is not given

In 0.1.41 the id must be listed in dozin.connectors (an empty list refuses every Connector), and systemPrompt and chat do not exist yet.

Example ​

js
api.registerConnector({ id: 'demo', start(ctx) {}, stop() {}, async send() { return { ok: true }; } });

api.registerService(definition) Not yet released ​

Registers a background task. It shows under the Extension in Settings › Extensions, where the person (or the AI with local_service) can start and stop it.

Parameters ​

NameTypeRequiredDescription
definitionServiceDefinitionYesSee Background Tasks

Returns ​

Nothing.

Throws ​

ErrorWhen
TypeErrorNo run function, or a field of the definition is invalid (the message says which)
CapabilityDeniedErrorCalled after activate has returned; service is not in dozin.capabilities; the same id twice; more than 8 tasks

Example ​

js
api.registerService({ id: 'sync', name: 'Sync', start: 'auto', async run(ctx) { /* ... */ } });

api.log(text) ​

Writes one line to the Extension's log, which the person opens from Settings › Extensions.

NameTypeRequiredDescription
textstringYesThe line

Returns nothing.

js
api.log('activated');

For Micromeet Cowork 0.1.41 · build 261111110020