Skip to content
Changelog

Report a bug

Run Code

A code automation is a managed agent automation that you write in TypeScript. You deploy it with Type CLI, and Type runs it on a schedule or when an event comes. You do not manage servers.

With code automations, you can:

  • React to events from Slack, GitHub, or any service that sends webhooks.
  • Run on a schedule, from every minute to once a year.
  • Read and write data in connected apps, with the Space’s connections.
  • Give work to the managed agent only when a step needs judgment.

Code is fast, costs less than AI, and gives the same result each time. Use code for the fixed steps, and AI for the rest.

Event responders

Reply in a Slack thread when a message reports a failed deploy.

GitHub workflows

Post in a Space when a pull request is merged, or when CI fails on main.

Scheduled checks

Read a service every 15 minutes and report only what changed.

Webhook receivers

Verify webhooks from any service, then process each event in code.

A code automation is one TypeScript file with two exports:

src/main.ts
import type {
AutomationContext,
AutomationDeployment,
RecurringEvent,
} from "@type-dot-com/sdk/automations";
// When to run
export const deployment = {
subscriptions: {
hourly: {
title: "Hourly check",
description: "Record the scheduled time",
source: { kind: "recurring", schedule: { kind: "interval", everySeconds: 3600 } },
},
},
} satisfies AutomationDeployment;
// What to do: one method for each subscription
export default class {
hourly(ctx: AutomationContext, event: RecurringEvent) {
return ctx.setOutput({ checkedAt: event.scheduledAt });
}
}

After you deploy, Type does the rest:

  • Schedules run the method at the time that you set.
  • Events from Slack, GitHub, and webhooks run the method when they come. Matchers filter events before your code starts.
  • Each run starts in a new, isolated VM. Your code calls connected apps through ctx. It has no direct network access.
  • Run history shows the output, the steps, and any errors of each run.
ConceptMeaning
SubscriptionA trigger and the method that it runs. An automation has one or more.
SourceWhat starts a run: a schedule (recurring) or an event (integration).
MatcherA filter that Type runs on the server before your code.
ctxThe object that your method uses to read, write, save state, and give work to the managed agent.
CheckpointState that a subscription saves for its next run.
FixtureA test case that Type runs at each deploy.
Webhook adapterCode that connects a service’s webhooks to Type.
  1. Make a project. A folder with type.json and src/main.ts.
  2. Write the code. Add subscriptions and methods. Add fixtures to test them.
  3. Deploy. Run type-cli automations deploy . --space <space>. Type typechecks the code, runs the fixtures, and enables the automation.
  4. Watch and change. Read the run history. Change the code and deploy again.

You can also ask Type AI in a Space to write and deploy a code automation for you. See Create and Manage Automations.

A code automation is not limited to code. In the same run, your code can:

See Managed Agent Automations to compare code automations with instruction automations.