@tanstack/ai-client 0.17.0 → 0.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -17,7 +17,10 @@ export declare class NoOpChatDevtoolsBridge {
|
|
|
17
17
|
deactivate(): void;
|
|
18
18
|
supersede(): void;
|
|
19
19
|
dispose(): void;
|
|
20
|
+
mountWithTools(_initialMessageCount: number): void;
|
|
21
|
+
notifyToolsChanged(): void;
|
|
20
22
|
setCurrentStreamId(_streamId: string | null): void;
|
|
23
|
+
recordStreamId(_streamId: string): void;
|
|
21
24
|
getCurrentStreamId(): string | null;
|
|
22
25
|
getLastStreamId(): string | null;
|
|
23
26
|
resolveStreamId(): string;
|
|
@@ -26,8 +26,14 @@ class NoOpChatDevtoolsBridge {
|
|
|
26
26
|
dispose() {
|
|
27
27
|
}
|
|
28
28
|
// chat-specific surface
|
|
29
|
+
mountWithTools(_initialMessageCount) {
|
|
30
|
+
}
|
|
31
|
+
notifyToolsChanged() {
|
|
32
|
+
}
|
|
29
33
|
setCurrentStreamId(_streamId) {
|
|
30
34
|
}
|
|
35
|
+
recordStreamId(_streamId) {
|
|
36
|
+
}
|
|
31
37
|
getCurrentStreamId() {
|
|
32
38
|
return null;
|
|
33
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools-noop.js","sources":["../../src/devtools-noop.ts"],"sourcesContent":["// No-op devtools bridge implementations + factories. The chat / generation /\n// video clients import the real bridge classes as types only and accept a\n// factory in options; when no factory is supplied they fall back to the\n// no-op factories here, which never touch `aiEventClient` or any of the\n// heavy preview/fixture machinery in `./devtools`. This keeps `./devtools`\n// outside the main-entry import graph — consumers opt into functional\n// devtools via `@tanstack/ai-client/devtools` (see `package.json#exports`).\nimport { ChatClientEventEmitter } from './events'\nimport type {\n AIDevtoolsToolFixture,\n ChatDevtoolsBridge,\n ChatDevtoolsBridgeOptions,\n GenerationDevtoolsBridge,\n GenerationDevtoolsBridgeOptions,\n VideoDevtoolsBridge,\n VideoDevtoolsBridgeOptions,\n} from './devtools'\nimport type { StreamChunk } from '@tanstack/ai/client'\nimport type {\n ChatClientEventContext,\n ChatClientRunEventContext,\n} from './events'\n\nexport type ChatDevtoolsBridgeFactory = (\n options: ChatDevtoolsBridgeOptions,\n) => ChatDevtoolsBridge\n\nexport type GenerationDevtoolsBridgeFactory = <TOutput>(\n options: GenerationDevtoolsBridgeOptions<TOutput>,\n) => GenerationDevtoolsBridge<TOutput>\n\nexport type VideoDevtoolsBridgeFactory = <TOutput>(\n options: VideoDevtoolsBridgeOptions<TOutput>,\n) => VideoDevtoolsBridge<TOutput>\n\n// ===========================================================================\n// No-op event emitter — extends the abstract base so it satisfies the type\n// without dragging in any of the event-bus runtime cost.\n// ===========================================================================\n\nclass NoOpChatClientEventEmitter extends ChatClientEventEmitter {\n protected emitEvent(): void {\n // intentionally empty\n }\n}\n\n// ===========================================================================\n// No-op bridges. Methods exist to satisfy the structural shape of the real\n// classes; every emit/record call short-circuits.\n// ===========================================================================\n\nexport class NoOpChatDevtoolsBridge {\n readonly events: ChatClientEventEmitter\n\n constructor(options: ChatDevtoolsBridgeOptions) {\n this.events = new NoOpChatClientEventEmitter(options.clientId)\n }\n\n // base bridge surface\n emitRegistered(): void {}\n emitUpdated(): void {}\n emitSnapshot(): void {}\n emitToolsRegistered(): void {}\n emitRunLifecycle(\n _eventType: unknown,\n _runId: string,\n _status: unknown,\n _options?: { error?: string },\n ): void {}\n deactivate(): void {}\n supersede(): void {}\n dispose(): void {}\n\n // chat-specific surface\n setCurrentStreamId(_streamId: string | null): void {}\n getCurrentStreamId(): string | null {\n return null\n }\n getLastStreamId(): string | null {\n return null\n }\n resolveStreamId(): string {\n return ''\n }\n observeChunk(_chunk: StreamChunk): void {}\n beginRun(_runId: string, _threadId: string): void {}\n getCurrentRunEventContext(): ChatClientRunEventContext | undefined {\n return undefined\n }\n getCurrentOrLastRunEventContext(): ChatClientRunEventContext | undefined {\n return undefined\n }\n findToolCallContext(toolCallId: string): ChatClientEventContext {\n return { toolCallId }\n }\n async applyFixture(_fixture: AIDevtoolsToolFixture): Promise<void> {\n // intentionally empty\n }\n}\n\nexport class NoOpGenerationDevtoolsBridge<TOutput> {\n constructor(_options: GenerationDevtoolsBridgeOptions<TOutput>) {}\n\n // base bridge surface\n emitRegistered(): void {}\n emitUpdated(): void {}\n emitSnapshot(): void {}\n emitToolsRegistered(): void {}\n emitRunLifecycle(): void {}\n deactivate(): void {}\n supersede(): void {}\n dispose(): void {}\n\n // generation-specific surface\n beginRun(_input: unknown): string {\n // Real factories supply a stable id; the no-op still returns a\n // unique value because the generation client passes this run id to\n // the adapter's RunAgentInputContext.\n return `noop-run-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`\n }\n ensureRunStarted(_runId: string): void {}\n finishRun(\n _runId: string,\n _eventType: 'run:completed' | 'run:errored' | 'run:cancelled',\n _status: 'completed' | 'errored' | 'cancelled',\n _error?: string,\n ): void {}\n getActiveRunId(): string | null {\n return null\n }\n resetRuns(): void {}\n recordResultChange(): void {}\n recordLoadingChange(): void {}\n recordErrorChange(_error: Error | undefined): void {}\n recordStatusChange(): void {}\n recordProgressChange(): void {}\n emitState(): void {}\n}\n\nexport class NoOpVideoDevtoolsBridge<\n TOutput,\n> extends NoOpGenerationDevtoolsBridge<TOutput> {\n constructor(options: VideoDevtoolsBridgeOptions<TOutput>) {\n super(options)\n }\n\n recordJobIdChange(): void {}\n recordVideoStatusChange(): void {}\n}\n\n// Compile-time parity checks. If a public method is added to the real\n// bridge class without a matching stub on the no-op, the corresponding\n// `Exclude<...>`
|
|
1
|
+
{"version":3,"file":"devtools-noop.js","sources":["../../src/devtools-noop.ts"],"sourcesContent":["// No-op devtools bridge implementations + factories. The chat / generation /\n// video clients import the real bridge classes as types only and accept a\n// factory in options; when no factory is supplied they fall back to the\n// no-op factories here, which never touch `aiEventClient` or any of the\n// heavy preview/fixture machinery in `./devtools`. This keeps `./devtools`\n// outside the main-entry import graph — consumers opt into functional\n// devtools via `@tanstack/ai-client/devtools` (see `package.json#exports`).\nimport { ChatClientEventEmitter } from './events'\nimport type {\n AIDevtoolsToolFixture,\n ChatDevtoolsBridge,\n ChatDevtoolsBridgeOptions,\n GenerationDevtoolsBridge,\n GenerationDevtoolsBridgeOptions,\n VideoDevtoolsBridge,\n VideoDevtoolsBridgeOptions,\n} from './devtools'\nimport type { StreamChunk } from '@tanstack/ai/client'\nimport type {\n ChatClientEventContext,\n ChatClientRunEventContext,\n} from './events'\n\nexport type ChatDevtoolsBridgeFactory = (\n options: ChatDevtoolsBridgeOptions,\n) => ChatDevtoolsBridge\n\nexport type GenerationDevtoolsBridgeFactory = <TOutput>(\n options: GenerationDevtoolsBridgeOptions<TOutput>,\n) => GenerationDevtoolsBridge<TOutput>\n\nexport type VideoDevtoolsBridgeFactory = <TOutput>(\n options: VideoDevtoolsBridgeOptions<TOutput>,\n) => VideoDevtoolsBridge<TOutput>\n\n// ===========================================================================\n// No-op event emitter — extends the abstract base so it satisfies the type\n// without dragging in any of the event-bus runtime cost.\n// ===========================================================================\n\nclass NoOpChatClientEventEmitter extends ChatClientEventEmitter {\n protected emitEvent(): void {\n // intentionally empty\n }\n}\n\n// ===========================================================================\n// No-op bridges. Methods exist to satisfy the structural shape of the real\n// classes; every emit/record call short-circuits.\n// ===========================================================================\n\nexport class NoOpChatDevtoolsBridge {\n readonly events: ChatClientEventEmitter\n\n constructor(options: ChatDevtoolsBridgeOptions) {\n this.events = new NoOpChatClientEventEmitter(options.clientId)\n }\n\n // base bridge surface\n emitRegistered(): void {}\n emitUpdated(): void {}\n emitSnapshot(): void {}\n emitToolsRegistered(): void {}\n emitRunLifecycle(\n _eventType: unknown,\n _runId: string,\n _status: unknown,\n _options?: { error?: string },\n ): void {}\n deactivate(): void {}\n supersede(): void {}\n dispose(): void {}\n\n // chat-specific surface\n mountWithTools(_initialMessageCount: number): void {}\n notifyToolsChanged(): void {}\n setCurrentStreamId(_streamId: string | null): void {}\n recordStreamId(_streamId: string): void {}\n getCurrentStreamId(): string | null {\n return null\n }\n getLastStreamId(): string | null {\n return null\n }\n resolveStreamId(): string {\n return ''\n }\n observeChunk(_chunk: StreamChunk): void {}\n beginRun(_runId: string, _threadId: string): void {}\n getCurrentRunEventContext(): ChatClientRunEventContext | undefined {\n return undefined\n }\n getCurrentOrLastRunEventContext(): ChatClientRunEventContext | undefined {\n return undefined\n }\n findToolCallContext(toolCallId: string): ChatClientEventContext {\n return { toolCallId }\n }\n async applyFixture(_fixture: AIDevtoolsToolFixture): Promise<void> {\n // intentionally empty\n }\n}\n\nexport class NoOpGenerationDevtoolsBridge<TOutput> {\n constructor(_options: GenerationDevtoolsBridgeOptions<TOutput>) {}\n\n // base bridge surface\n emitRegistered(): void {}\n emitUpdated(): void {}\n emitSnapshot(): void {}\n emitToolsRegistered(): void {}\n emitRunLifecycle(): void {}\n deactivate(): void {}\n supersede(): void {}\n dispose(): void {}\n\n // generation-specific surface\n beginRun(_input: unknown): string {\n // Real factories supply a stable id; the no-op still returns a\n // unique value because the generation client passes this run id to\n // the adapter's RunAgentInputContext.\n return `noop-run-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`\n }\n ensureRunStarted(_runId: string): void {}\n finishRun(\n _runId: string,\n _eventType: 'run:completed' | 'run:errored' | 'run:cancelled',\n _status: 'completed' | 'errored' | 'cancelled',\n _error?: string,\n ): void {}\n getActiveRunId(): string | null {\n return null\n }\n resetRuns(): void {}\n recordResultChange(): void {}\n recordLoadingChange(): void {}\n recordErrorChange(_error: Error | undefined): void {}\n recordStatusChange(): void {}\n recordProgressChange(): void {}\n emitState(): void {}\n}\n\nexport class NoOpVideoDevtoolsBridge<\n TOutput,\n> extends NoOpGenerationDevtoolsBridge<TOutput> {\n constructor(options: VideoDevtoolsBridgeOptions<TOutput>) {\n super(options)\n }\n\n recordJobIdChange(): void {}\n recordVideoStatusChange(): void {}\n}\n\n// Compile-time parity checks. If a public method is added to the real\n// bridge class without a matching stub on the no-op, the corresponding\n// `Exclude<...>` resolves to a non-`never` union, which violates the\n// `extends never` constraint below and fails the build — surfacing the\n// drift at build time instead of as a runtime TypeError later.\ntype AssertBridgeParity<TMissing extends never> = TMissing\ntype _ChatBridgeMissing = Exclude<\n keyof ChatDevtoolsBridge,\n keyof NoOpChatDevtoolsBridge\n>\ntype _GenerationBridgeMissing = Exclude<\n keyof GenerationDevtoolsBridge<unknown>,\n keyof NoOpGenerationDevtoolsBridge<unknown>\n>\ntype _VideoBridgeMissing = Exclude<\n keyof VideoDevtoolsBridge<unknown>,\n keyof NoOpVideoDevtoolsBridge<unknown>\n>\nconst _bridgeParity:\n | [\n AssertBridgeParity<_ChatBridgeMissing>,\n AssertBridgeParity<_GenerationBridgeMissing>,\n AssertBridgeParity<_VideoBridgeMissing>,\n ]\n | undefined = undefined\nvoid _bridgeParity\n\n// ===========================================================================\n// Factories — these are what the clients call when no real factory was\n// supplied in options.\n// ===========================================================================\n\n// Casts use `unknown` because the no-op classes don't `extend` the real bridge\n// (that would pull the real implementation into the main-entry import graph).\n// Structural parity is enforced by the `_*BridgeMissing` checks above.\n\nexport const createNoOpChatDevtoolsBridge: ChatDevtoolsBridgeFactory = (\n options,\n) =>\n // eslint-disable-next-line no-restricted-syntax -- see comment above\n new NoOpChatDevtoolsBridge(options) as unknown as ChatDevtoolsBridge\n\nexport const createNoOpGenerationDevtoolsBridge: GenerationDevtoolsBridgeFactory =\n <TOutput>(options: GenerationDevtoolsBridgeOptions<TOutput>) =>\n // eslint-disable-next-line no-restricted-syntax -- see comment above\n new NoOpGenerationDevtoolsBridge<TOutput>(\n options,\n ) as unknown as GenerationDevtoolsBridge<TOutput>\n\nexport const createNoOpVideoDevtoolsBridge: VideoDevtoolsBridgeFactory = <\n TOutput,\n>(\n options: VideoDevtoolsBridgeOptions<TOutput>,\n) =>\n // eslint-disable-next-line no-restricted-syntax -- see comment above\n new NoOpVideoDevtoolsBridge<TOutput>(\n options,\n ) as unknown as VideoDevtoolsBridge<TO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EAAC;AAAA,EAC7B,mBAAyB;AAAA,EAAC;AAAA,EAC1B,aAAmB;AAAA,EAAC;AAAA,EACpB,YAAkB;AAAA,EAAC;AAAA,EACnB,UAAgB;AAAA,EAAC;AAAA;AAAA,EAGjB,SAAS,QAAyB;AAIhC,WAAO,YAAY,KAAK,IAAA,CAAK,IAAI,KAAK,OAAA,EAAS,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AAAA,EACzE;AAAA,EACA,iBAAiB,QAAsB;AAAA,EAAC;AAAA,EACxC,UACE,QACA,YACA,SACA,QACM;AAAA,EAAC;AAAA,EACT,iBAAgC;AAC9B,WAAO;AAAA,EACT;AAAA,EACA,YAAkB;AAAA,EAAC;AAAA,EACnB,qBAA2B;AAAA,EAAC;AAAA,EAC5B,sBAA4B;AAAA,EAAC;AAAA,EAC7B,kBAAkB,QAAiC;AAAA,EAAC;AAAA,EACpD,qBAA2B;AAAA,EAAC;AAAA,EAC5B,uBAA6B;AAAA,EAAC;AAAA,EAC9B,YAAkB;AAAA,EAAC;AACrB;AAEO,MAAM,gCAEH,6BAAsC;AAAA,EAC9C,YAAY,SAA8C;AACxD,UAAM,OAAO;AAAA,EACf;AAAA,EAEA,oBAA0B;AAAA,EAAC;AAAA,EAC3B,0BAAgC;AAAA,EAAC;AACnC;AAsCO,MAAM,+BAA0D,CACrE;AAAA;AAAA,EAGA,IAAI,uBAAuB,OAAO;AAAA;AAE7B,MAAM,qCACX,CAAU;AAAA;AAAA,EAER,IAAI;AAAA,IACF;AAAA,EAAA;AAAA;AAGC,MAAM,gCAA4D,CAGvE;AAAA;AAAA,EAGA,IAAI;AAAA,IACF;AAAA,EAAA;AAAA;"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/ai-client",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.3",
|
|
4
4
|
"description": "Framework-agnostic headless client for TanStack AI chat, realtime sessions, streaming transports, and media generations.",
|
|
5
|
-
"author": "",
|
|
5
|
+
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"homepage": "https://tanstack.com/ai",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
9
10
|
"url": "git+https://github.com/TanStack/ai.git",
|
|
10
11
|
"directory": "packages/ai-client"
|
|
11
12
|
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/TanStack/ai/issues"
|
|
15
|
+
},
|
|
16
|
+
"funding": {
|
|
17
|
+
"type": "github",
|
|
18
|
+
"url": "https://github.com/sponsors/tannerlinsley"
|
|
19
|
+
},
|
|
12
20
|
"keywords": [
|
|
13
21
|
"ai",
|
|
14
22
|
"ai-sdk",
|
|
@@ -41,8 +49,8 @@
|
|
|
41
49
|
"src"
|
|
42
50
|
],
|
|
43
51
|
"dependencies": {
|
|
44
|
-
"@tanstack/ai": "0.
|
|
45
|
-
"@tanstack/ai-event-client": "0.6.
|
|
52
|
+
"@tanstack/ai": "0.31.0",
|
|
53
|
+
"@tanstack/ai-event-client": "0.6.2"
|
|
46
54
|
},
|
|
47
55
|
"devDependencies": {
|
|
48
56
|
"@standard-schema/spec": "^1.1.0",
|
package/src/devtools-noop.ts
CHANGED
|
@@ -72,7 +72,10 @@ export class NoOpChatDevtoolsBridge {
|
|
|
72
72
|
dispose(): void {}
|
|
73
73
|
|
|
74
74
|
// chat-specific surface
|
|
75
|
+
mountWithTools(_initialMessageCount: number): void {}
|
|
76
|
+
notifyToolsChanged(): void {}
|
|
75
77
|
setCurrentStreamId(_streamId: string | null): void {}
|
|
78
|
+
recordStreamId(_streamId: string): void {}
|
|
76
79
|
getCurrentStreamId(): string | null {
|
|
77
80
|
return null
|
|
78
81
|
}
|
|
@@ -150,9 +153,10 @@ export class NoOpVideoDevtoolsBridge<
|
|
|
150
153
|
|
|
151
154
|
// Compile-time parity checks. If a public method is added to the real
|
|
152
155
|
// bridge class without a matching stub on the no-op, the corresponding
|
|
153
|
-
// `Exclude<...>`
|
|
154
|
-
//
|
|
155
|
-
// time instead of as a runtime TypeError later.
|
|
156
|
+
// `Exclude<...>` resolves to a non-`never` union, which violates the
|
|
157
|
+
// `extends never` constraint below and fails the build — surfacing the
|
|
158
|
+
// drift at build time instead of as a runtime TypeError later.
|
|
159
|
+
type AssertBridgeParity<TMissing extends never> = TMissing
|
|
156
160
|
type _ChatBridgeMissing = Exclude<
|
|
157
161
|
keyof ChatDevtoolsBridge,
|
|
158
162
|
keyof NoOpChatDevtoolsBridge
|
|
@@ -165,12 +169,14 @@ type _VideoBridgeMissing = Exclude<
|
|
|
165
169
|
keyof VideoDevtoolsBridge<unknown>,
|
|
166
170
|
keyof NoOpVideoDevtoolsBridge<unknown>
|
|
167
171
|
>
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
const _bridgeParity:
|
|
173
|
+
| [
|
|
174
|
+
AssertBridgeParity<_ChatBridgeMissing>,
|
|
175
|
+
AssertBridgeParity<_GenerationBridgeMissing>,
|
|
176
|
+
AssertBridgeParity<_VideoBridgeMissing>,
|
|
177
|
+
]
|
|
178
|
+
| undefined = undefined
|
|
179
|
+
void _bridgeParity
|
|
174
180
|
|
|
175
181
|
// ===========================================================================
|
|
176
182
|
// Factories — these are what the clients call when no real factory was
|