onActivate is an optional (ctx) => Promise<void> hook that runs server-side after an activation is first persisted, and again whenever the activation data is updated. Use it to seed caches and sanity-check configuration early.
Basic hook
When it runs
- Once after activation is first persisted
- Again after the user updates their activation data (e.g., re-enters the API key)
ctx, same enforcement as schedules and tools.
Error handling
v1 errors are non-fatal. A throw is logged and shown to the user as a warning — the activation stays connected. This hook is for cache seeding and eager validation, not a connect gate: it cannot reject a connection. Do not repurpose it as a credential validator that must fail the connect.Cache invalidation with fingerprints
When cache depends on activation data, store a fingerprint. On read, treat a mismatch as a cache miss:.optional(): a required field throws StorageValidationError on every pre-existing row, which for a clientReadable key reaches the widget.
Testing
UseinvokeActivate():
invokeActivate() throws if onActivate is not declared, and lets a handler’s throw propagate — it is a bare invoker. The non-fatal handling is applied by whatever calls the hook (the host, or the harness’s activation surface), so a test of that behavior should catch the rejection itself.
Next steps
- Capability context — use ctx in hooks
- Testing — test with invokeActivate()