Skip to content

Commit 44f130e

Browse files
committed
chore: default local dev event store to ClickHouse in .env.example
Fresh clones left EVENT_REPOSITORY_DEFAULT_STORE unset, which falls back to the "postgres" store. The local stack is already ClickHouse-backed (run replication + CLICKHOUSE_URL), so dev run traces showed up empty even though the run itself appeared. Default it to clickhouse_v2.
1 parent a9f756b commit 44f130e

14 files changed

Lines changed: 917 additions & 28 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@trigger.dev/sdk": patch
3+
"@trigger.dev/core": patch
4+
---
5+
6+
The `chat.agent` / chat SDK surface (`@trigger.dev/sdk/ai`, `/chat`, `/chat/react`, `/chat-server`) no longer re-exports types from `ai` in its published type declarations. Shapes like `UIMessage`, `UIMessageChunk`, `ModelMessage`, `ToolSet`, and `ChatTransport` are now self-contained structural mirrors, so the SDK no longer pins your project to a single `ai` major version. You can use these subpaths against your own `ai` version without cross-version type conflicts.
7+
8+
The mirrors are exported from `@trigger.dev/core/v3/aiTypes` and stay structurally compatible with `ai`'s own types.

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ NODE_ENV=development
1717
CLICKHOUSE_URL=http://default:password@localhost:8123
1818
RUN_REPLICATION_CLICKHOUSE_URL=http://default:password@localhost:8123
1919
RUN_REPLICATION_ENABLED=1
20+
# Store task run spans/traces in ClickHouse so the dashboard trace view is
21+
# populated in local dev. The local stack is ClickHouse-backed (see above), so
22+
# leaving this unset falls back to the "postgres" store and dev run traces show
23+
# up empty even though the run itself appears.
24+
EVENT_REPOSITORY_DEFAULT_STORE=clickhouse_v2
2025

2126
# Set this to UTC because Node.js uses the system timezone
2227
TZ="UTC"

packages/core/package.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
"main": true,
2020
"module": true,
2121
"project": "./tsconfig.src.json",
22+
"exclude": [
23+
"src/**/*.assignability.ts"
24+
],
2225
"exports": {
2326
"./package.json": "./package.json",
2427
".": "./src/index.ts",
@@ -56,7 +59,8 @@
5659
"./v3/machines": "./src/v3/machines/index.ts",
5760
"./v3/serverOnly": "./src/v3/serverOnly/index.ts",
5861
"./v3/isomorphic": "./src/v3/isomorphic/index.ts",
59-
"./v3/sdk-scope-storage": "./src/v3/sdkScope/storage-node.ts"
62+
"./v3/sdk-scope-storage": "./src/v3/sdkScope/storage-node.ts",
63+
"./v3/aiTypes": "./src/v3/aiTypes/index.ts"
6064
},
6165
"sourceDialects": [
6266
"@triggerdotdev/source"
@@ -166,6 +170,9 @@
166170
"v3/sdk-scope-storage": [
167171
"dist/commonjs/v3/sdkScope/storage-node.d.ts"
168172
],
173+
"v3/aiTypes": [
174+
"dist/commonjs/v3/aiTypes/index.d.ts"
175+
],
169176
"v3/test": [
170177
"dist/commonjs/v3/test/index.d.ts"
171178
]
@@ -641,6 +648,17 @@
641648
"types": "./dist/commonjs/v3/sdkScope/storage-node.d.ts",
642649
"default": "./dist/commonjs/v3/sdkScope/storage-node.js"
643650
}
651+
},
652+
"./v3/aiTypes": {
653+
"import": {
654+
"@triggerdotdev/source": "./src/v3/aiTypes/index.ts",
655+
"types": "./dist/esm/v3/aiTypes/index.d.ts",
656+
"default": "./dist/esm/v3/aiTypes/index.js"
657+
},
658+
"require": {
659+
"types": "./dist/commonjs/v3/aiTypes/index.d.ts",
660+
"default": "./dist/commonjs/v3/aiTypes/index.js"
661+
}
644662
}
645663
},
646664
"type": "module",
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* Type-level drift guard for the structural `ai` mirrors in `./index.ts`.
3+
*
4+
* This file is NOT shipped (excluded from the tshy build via `tshy.exclude` in
5+
* `package.json`) and is NOT a runtime test (its name does not match vitest's
6+
* `*.test.ts` glob). It exists purely so `pnpm typecheck` (which compiles every
7+
* `.ts` file under `src`) fails if our structural mirrors ever stop being
8+
* assignable to the real `ai` types — e.g. after an `ai` version bump.
9+
*
10+
* It is the ONLY file in this package that imports `ai`. `ai` is a devDep, so
11+
* the import resolves during typecheck but never reaches the published surface.
12+
*
13+
* Each `const _x: A = {} as B` line asserts `B` is assignable to `A`. Two lines
14+
* (both directions) assert bidirectional assignability.
15+
*/
16+
import type * as ai from "ai";
17+
import type * as t from "./index.js";
18+
19+
// ---------------------------------------------------------------------------
20+
// Faithful wire types — bidirectionally assignable with `ai`.
21+
// ---------------------------------------------------------------------------
22+
23+
// UIMessage (default generics)
24+
const _uiMessageAiToOurs: t.UIMessage = {} as ai.UIMessage;
25+
const _uiMessageOursToAi: ai.UIMessage = {} as t.UIMessage;
26+
27+
// UIMessage with a metadata generic
28+
const _uiMessageMetaAiToOurs: t.UIMessage<{ foo: string }> = {} as ai.UIMessage<{ foo: string }>;
29+
const _uiMessageMetaOursToAi: ai.UIMessage<{ foo: string }> = {} as t.UIMessage<{ foo: string }>;
30+
31+
// UIMessageChunk
32+
const _chunkAiToOurs: t.UIMessageChunk = {} as ai.UIMessageChunk;
33+
const _chunkOursToAi: ai.UIMessageChunk = {} as t.UIMessageChunk;
34+
35+
// ModelMessage
36+
const _modelMessageAiToOurs: t.ModelMessage = {} as ai.ModelMessage;
37+
const _modelMessageOursToAi: ai.ModelMessage = {} as t.ModelMessage;
38+
39+
// FinishReason
40+
const _finishReasonAiToOurs: t.FinishReason = "stop" as ai.FinishReason;
41+
const _finishReasonOursToAi: ai.FinishReason = "stop" as t.FinishReason;
42+
43+
// LanguageModelUsage
44+
const _usageAiToOurs: t.LanguageModelUsage = {} as ai.LanguageModelUsage;
45+
const _usageOursToAi: ai.LanguageModelUsage = {} as t.LanguageModelUsage;
46+
47+
// ChatRequestOptions
48+
const _requestOptionsAiToOurs: t.ChatRequestOptions = {} as ai.ChatRequestOptions;
49+
const _requestOptionsOursToAi: ai.ChatRequestOptions = {} as t.ChatRequestOptions;
50+
51+
// ChatTransport — our implementation must be usable wherever `ai`'s is, and vice versa
52+
const _transportAiToOurs: t.ChatTransport<t.UIMessage> = {} as ai.ChatTransport<ai.UIMessage>;
53+
const _transportOursToAi: ai.ChatTransport<ai.UIMessage> = {} as t.ChatTransport<t.UIMessage>;
54+
55+
// ---------------------------------------------------------------------------
56+
// Structural-by-design types — one-directional guarantees we rely on.
57+
// ---------------------------------------------------------------------------
58+
59+
// ToolCallOptions: `ai`'s tool-execution options must be assignable to ours, so
60+
// an `execute` fn typed with our options is usable where `ai` expects its own.
61+
const _toolCallOptionsAiToOurs: t.ToolCallOptions = {} as ai.ToolCallOptions;
62+
63+
// Schema accept-position (core `types/tools.ts`): a real `ai` Schema flows into
64+
// our looser `AISchemaLike` (we only read `_type` / `validate`).
65+
const _schemaAiToOurs: t.AISchemaLike<{ a: number }> = {} as ai.Schema<{ a: number }>;
66+
67+
// ToolSet constraint: any concrete `ai` tool set satisfies `<T extends ToolSet>`.
68+
const _toolSetAiToOurs: t.ToolSet = {} as ai.ToolSet;
69+
const _aiToolSetSatisfiesConstraint = <T extends t.ToolSet>(_t: T): void => undefined;
70+
_aiToolSetSatisfiesConstraint({} as { search: ai.Tool<{ q: string }, { hits: number }> });
71+
72+
// Tool-typed UIMessage (via InferUITools): `ai` -> ours holds; the tool `input`
73+
// / `output` payloads degrade to `unknown` on our side. The reverse direction
74+
// for *typed* tools is intentionally NOT guaranteed — see the "Fidelity" note
75+
// in `./index.ts`. Default + metadata-typed UIMessages (asserted above) stay
76+
// fully faithful.
77+
type AiToolSet = { search: ai.Tool<{ q: string }, { hits: number }> };
78+
const _toolTypedAiToOurs: t.UIMessage<unknown, t.UIDataTypes, t.InferUITools<AiToolSet>> =
79+
{} as ai.UIMessage<unknown, ai.UIDataTypes, ai.InferUITools<AiToolSet>>;
80+
81+
export {};

0 commit comments

Comments
 (0)