Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

DetachableRunCapability.md

28 lines1.2 KB

1---
2id: DetachableRunCapability
3title: DetachableRunCapability
4---
5​
6```ts
7const DetachableRunCapability: Capability<true, "detachable-run">;
8```
9​
10Defined in: packages/ai/src/activities/chat/middleware/run-store.ts:375
11​
12Whether the current run can be DETACHED rather than destroyed when its client
13disconnects — `true` only when some middleware has both a [RunStore](../interfaces/RunStore.md) and
14a durable event log wired (`withSandbox`'s `runs` + `durability.adapter`).
15​
16Lives in core for the same reason `LockStore` does: it is a coordination fact
17that two consumer packages must agree on, and neither may depend on the other.
18`@tanstack/ai-sandbox` provides it; `@tanstack/ai-persistence` reads it to
19decide whether an abort is terminal (`'aborted'`) or a detach (write nothing).
20A persistence → sandbox import would be a layering inversion.
21​
22Consumers read it with `{ optional: true }`: absent means "not detachable",
23which is every app that has not wired durability.
24​
25Typed `true`, not `boolean`: ABSENCE is the negative, so a published `false`
26has no meaning — and a consumer that tests PRESENCE rather than the value
27would read one as "detachable". Narrowing the payload makes that
28unrepresentable instead of merely undocumented.