@tanstack/ai 0.12.0 → 0.14.0
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.
- package/dist/esm/activities/chat/adapter.d.ts +6 -1
- package/dist/esm/activities/chat/adapter.js.map +1 -1
- package/dist/esm/activities/chat/index.d.ts +8 -0
- package/dist/esm/activities/chat/index.js +78 -17
- package/dist/esm/activities/chat/index.js.map +1 -1
- package/dist/esm/activities/chat/middleware/compose.d.ts +3 -1
- package/dist/esm/activities/chat/middleware/compose.js +79 -1
- package/dist/esm/activities/chat/middleware/compose.js.map +1 -1
- package/dist/esm/activities/error-payload.d.ts +12 -0
- package/dist/esm/activities/error-payload.js +25 -0
- package/dist/esm/activities/error-payload.js.map +1 -0
- package/dist/esm/activities/generateAudio/adapter.d.ts +62 -0
- package/dist/esm/activities/generateAudio/adapter.js +14 -0
- package/dist/esm/activities/generateAudio/adapter.js.map +1 -0
- package/dist/esm/activities/generateAudio/index.d.ts +74 -0
- package/dist/esm/activities/generateAudio/index.js +80 -0
- package/dist/esm/activities/generateAudio/index.js.map +1 -0
- package/dist/esm/activities/generateImage/adapter.d.ts +1 -1
- package/dist/esm/activities/generateImage/adapter.js +1 -1
- package/dist/esm/activities/generateImage/adapter.js.map +1 -1
- package/dist/esm/activities/generateImage/index.d.ts +7 -0
- package/dist/esm/activities/generateImage/index.js +19 -3
- package/dist/esm/activities/generateImage/index.js.map +1 -1
- package/dist/esm/activities/generateSpeech/adapter.d.ts +1 -1
- package/dist/esm/activities/generateSpeech/adapter.js +1 -1
- package/dist/esm/activities/generateSpeech/adapter.js.map +1 -1
- package/dist/esm/activities/generateSpeech/index.d.ts +10 -3
- package/dist/esm/activities/generateSpeech/index.js +32 -3
- package/dist/esm/activities/generateSpeech/index.js.map +1 -1
- package/dist/esm/activities/generateTranscription/adapter.d.ts +1 -1
- package/dist/esm/activities/generateTranscription/adapter.js +1 -1
- package/dist/esm/activities/generateTranscription/adapter.js.map +1 -1
- package/dist/esm/activities/generateTranscription/index.d.ts +10 -3
- package/dist/esm/activities/generateTranscription/index.js +43 -13
- package/dist/esm/activities/generateTranscription/index.js.map +1 -1
- package/dist/esm/activities/generateVideo/index.d.ts +7 -0
- package/dist/esm/activities/generateVideo/index.js +55 -13
- package/dist/esm/activities/generateVideo/index.js.map +1 -1
- package/dist/esm/activities/index.d.ts +5 -2
- package/dist/esm/activities/index.js +11 -6
- package/dist/esm/activities/index.js.map +1 -1
- package/dist/esm/activities/stream-generation-result.js +5 -6
- package/dist/esm/activities/stream-generation-result.js.map +1 -1
- package/dist/esm/activities/summarize/index.d.ts +7 -0
- package/dist/esm/activities/summarize/index.js +54 -19
- package/dist/esm/activities/summarize/index.js.map +1 -1
- package/dist/esm/adapter-internals.d.ts +4 -0
- package/dist/esm/adapter-internals.js +9 -0
- package/dist/esm/adapter-internals.js.map +1 -0
- package/dist/esm/index.d.ts +5 -2
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/logger/console-logger.d.ts +11 -0
- package/dist/esm/logger/console-logger.js +27 -0
- package/dist/esm/logger/console-logger.js.map +1 -0
- package/dist/esm/logger/internal-logger.d.ts +33 -0
- package/dist/esm/logger/internal-logger.js +69 -0
- package/dist/esm/logger/internal-logger.js.map +1 -0
- package/dist/esm/logger/resolve.d.ts +14 -0
- package/dist/esm/logger/resolve.js +54 -0
- package/dist/esm/logger/resolve.js.map +1 -0
- package/dist/esm/logger/types.d.ts +75 -0
- package/dist/esm/stream-to-response.js +3 -8
- package/dist/esm/stream-to-response.js.map +1 -1
- package/dist/esm/types.d.ts +97 -6
- package/package.json +6 -2
- package/skills/ai-core/SKILL.md +5 -3
- package/skills/ai-core/debug-logging/SKILL.md +263 -0
- package/skills/ai-core/media-generation/SKILL.md +154 -10
- package/src/activities/chat/adapter.ts +6 -1
- package/src/activities/chat/index.ts +104 -22
- package/src/activities/chat/middleware/compose.ts +84 -1
- package/src/activities/error-payload.ts +35 -0
- package/src/activities/generateAudio/adapter.ts +89 -0
- package/src/activities/generateAudio/index.ts +224 -0
- package/src/activities/generateImage/adapter.ts +1 -1
- package/src/activities/generateImage/index.ts +29 -3
- package/src/activities/generateSpeech/adapter.ts +1 -1
- package/src/activities/generateSpeech/index.ts +51 -9
- package/src/activities/generateTranscription/adapter.ts +1 -1
- package/src/activities/generateTranscription/index.ts +72 -17
- package/src/activities/generateVideo/index.ts +72 -13
- package/src/activities/index.ts +22 -0
- package/src/activities/stream-generation-result.ts +6 -7
- package/src/activities/summarize/index.ts +66 -20
- package/src/adapter-internals.ts +8 -0
- package/src/index.ts +13 -0
- package/src/logger/console-logger.ts +49 -0
- package/src/logger/internal-logger.ts +107 -0
- package/src/logger/resolve.ts +72 -0
- package/src/logger/types.ts +78 -0
- package/src/stream-to-response.ts +5 -10
- package/src/types.ts +110 -5
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { DebugCategories, Logger } from './types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Fully-resolved categories map. Every flag is a definite boolean (never
|
|
5
|
+
* undefined), produced by `resolveDebugOption` from a `DebugOption`.
|
|
6
|
+
*/
|
|
7
|
+
export type ResolvedCategories = Required<DebugCategories>
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Package-internal logger wrapper used by every activity and adapter in
|
|
11
|
+
* `@tanstack/ai`. Wraps a user-supplied (or default `ConsoleLogger`) `Logger`
|
|
12
|
+
* plus a fully-resolved per-category map. Each category has a dedicated
|
|
13
|
+
* method that no-ops when its flag is `false`, or prepends a
|
|
14
|
+
* `[tanstack-ai:<category>] ` prefix and calls the underlying logger's
|
|
15
|
+
* `error` (for the `errors` category) or `debug` (for everything else).
|
|
16
|
+
*
|
|
17
|
+
* Not exported from the package root. Adapter packages consume it via the
|
|
18
|
+
* `@tanstack/ai/adapter-internals` subpath export.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Emoji marker per category — bracketing the `[tanstack-ai:<cat>]` tag on
|
|
22
|
+
* both sides makes it trivial to visually pick out a category when scanning
|
|
23
|
+
* dense streaming logs.
|
|
24
|
+
*/
|
|
25
|
+
const CATEGORY_EMOJI: Record<keyof ResolvedCategories, string> = {
|
|
26
|
+
request: '📤',
|
|
27
|
+
provider: '📥',
|
|
28
|
+
output: '📨',
|
|
29
|
+
middleware: '🧩',
|
|
30
|
+
tools: '🔧',
|
|
31
|
+
agentLoop: '🔁',
|
|
32
|
+
config: '⚙️',
|
|
33
|
+
errors: '❌',
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class InternalLogger {
|
|
37
|
+
constructor(
|
|
38
|
+
private readonly logger: Logger,
|
|
39
|
+
private readonly categories: ResolvedCategories,
|
|
40
|
+
) {}
|
|
41
|
+
|
|
42
|
+
/** Whether a category is enabled. Cheap, safe to call on hot paths. */
|
|
43
|
+
isEnabled(category: keyof ResolvedCategories): boolean {
|
|
44
|
+
return this.categories[category]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private emit(
|
|
48
|
+
level: 'debug' | 'error',
|
|
49
|
+
category: keyof ResolvedCategories,
|
|
50
|
+
message: string,
|
|
51
|
+
meta?: Record<string, unknown>,
|
|
52
|
+
): void {
|
|
53
|
+
if (!this.categories[category]) return
|
|
54
|
+
const emoji = CATEGORY_EMOJI[category]
|
|
55
|
+
const prefixed = `${emoji} [tanstack-ai:${category}] ${emoji} ${message}`
|
|
56
|
+
try {
|
|
57
|
+
if (level === 'error') this.logger.error(prefixed, meta)
|
|
58
|
+
else this.logger.debug(prefixed, meta)
|
|
59
|
+
} catch {
|
|
60
|
+
// User-supplied logger threw; swallow so we never mask the original
|
|
61
|
+
// error that triggered this log call.
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Log a raw chunk/frame received from a provider SDK. */
|
|
66
|
+
provider(message: string, meta?: Record<string, unknown>): void {
|
|
67
|
+
this.emit('debug', 'provider', message, meta)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Log a chunk/result yielded to the consumer after middleware. */
|
|
71
|
+
output(message: string, meta?: Record<string, unknown>): void {
|
|
72
|
+
this.emit('debug', 'output', message, meta)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Log inputs/outputs around a middleware hook invocation. Chat-only. */
|
|
76
|
+
middleware(message: string, meta?: Record<string, unknown>): void {
|
|
77
|
+
this.emit('debug', 'middleware', message, meta)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Log before/after a tool-call execution. Chat-only. */
|
|
81
|
+
tools(message: string, meta?: Record<string, unknown>): void {
|
|
82
|
+
this.emit('debug', 'tools', message, meta)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Log an agent-loop iteration marker or phase transition. Chat-only. */
|
|
86
|
+
agentLoop(message: string, meta?: Record<string, unknown>): void {
|
|
87
|
+
this.emit('debug', 'agentLoop', message, meta)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Log a config transform returned by a middleware `onConfig` hook. Chat-only. */
|
|
91
|
+
config(message: string, meta?: Record<string, unknown>): void {
|
|
92
|
+
this.emit('debug', 'config', message, meta)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Log a caught error. Defaults to on even when `debug` is unspecified.
|
|
97
|
+
* Uses the underlying logger's `error` level.
|
|
98
|
+
*/
|
|
99
|
+
errors(message: string, meta?: Record<string, unknown>): void {
|
|
100
|
+
this.emit('error', 'errors', message, meta)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Log outgoing request metadata before an adapter SDK call. */
|
|
104
|
+
request(message: string, meta?: Record<string, unknown>): void {
|
|
105
|
+
this.emit('debug', 'request', message, meta)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ConsoleLogger } from './console-logger'
|
|
2
|
+
import { InternalLogger } from './internal-logger'
|
|
3
|
+
import type { ResolvedCategories } from './internal-logger'
|
|
4
|
+
import type { DebugCategories, DebugConfig, DebugOption, Logger } from './types'
|
|
5
|
+
|
|
6
|
+
const ALL_OFF: ResolvedCategories = {
|
|
7
|
+
provider: false,
|
|
8
|
+
output: false,
|
|
9
|
+
middleware: false,
|
|
10
|
+
tools: false,
|
|
11
|
+
agentLoop: false,
|
|
12
|
+
config: false,
|
|
13
|
+
errors: false,
|
|
14
|
+
request: false,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const ALL_ON: ResolvedCategories = {
|
|
18
|
+
provider: true,
|
|
19
|
+
output: true,
|
|
20
|
+
middleware: true,
|
|
21
|
+
tools: true,
|
|
22
|
+
agentLoop: true,
|
|
23
|
+
config: true,
|
|
24
|
+
errors: true,
|
|
25
|
+
request: true,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const errorsOnlyCategories = (): ResolvedCategories => ({
|
|
29
|
+
...ALL_OFF,
|
|
30
|
+
errors: true,
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const resolveCategoriesFromPartial = (
|
|
34
|
+
partial: DebugCategories,
|
|
35
|
+
): ResolvedCategories => ({
|
|
36
|
+
provider: partial.provider ?? true,
|
|
37
|
+
output: partial.output ?? true,
|
|
38
|
+
middleware: partial.middleware ?? true,
|
|
39
|
+
tools: partial.tools ?? true,
|
|
40
|
+
agentLoop: partial.agentLoop ?? true,
|
|
41
|
+
config: partial.config ?? true,
|
|
42
|
+
errors: partial.errors ?? true,
|
|
43
|
+
request: partial.request ?? true,
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Normalize a `DebugOption` into an `InternalLogger` ready to be threaded
|
|
48
|
+
* through the library's activities and adapters. See the `DebugOption`
|
|
49
|
+
* resolution table in the spec for the complete rules.
|
|
50
|
+
*
|
|
51
|
+
* - `undefined`: only the `errors` category is enabled; default `ConsoleLogger`.
|
|
52
|
+
* - `true`: all categories enabled; default `ConsoleLogger`.
|
|
53
|
+
* - `false`: all categories disabled (including `errors`); default `ConsoleLogger`.
|
|
54
|
+
* - `DebugConfig`: each unspecified category defaults to `true`; an optional
|
|
55
|
+
* `logger` replaces the default `ConsoleLogger`.
|
|
56
|
+
*/
|
|
57
|
+
export function resolveDebugOption(
|
|
58
|
+
debug: DebugOption | undefined,
|
|
59
|
+
): InternalLogger {
|
|
60
|
+
if (debug === undefined) {
|
|
61
|
+
return new InternalLogger(new ConsoleLogger(), errorsOnlyCategories())
|
|
62
|
+
}
|
|
63
|
+
if (debug === true) {
|
|
64
|
+
return new InternalLogger(new ConsoleLogger(), ALL_ON)
|
|
65
|
+
}
|
|
66
|
+
if (debug === false) {
|
|
67
|
+
return new InternalLogger(new ConsoleLogger(), ALL_OFF)
|
|
68
|
+
}
|
|
69
|
+
const { logger, ...cats }: DebugConfig = debug
|
|
70
|
+
const userLogger: Logger = logger ?? new ConsoleLogger()
|
|
71
|
+
return new InternalLogger(userLogger, resolveCategoriesFromPartial(cats))
|
|
72
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable logger interface consumed by every `@tanstack/ai` activity when `debug` is enabled. Supply a custom implementation via `debug: { logger }` on `chat()`, `summarize()`, `generateImage()`, etc. The four methods correspond to log levels: use `debug` for chunk-level diagnostic output, `info`/`warn` for notable events, `error` for caught exceptions.
|
|
3
|
+
*/
|
|
4
|
+
export interface Logger {
|
|
5
|
+
/**
|
|
6
|
+
* Called for chunk-level diagnostic output (raw provider chunks, per-chunk output, agent-loop iteration markers).
|
|
7
|
+
* @param meta Structured data forwarded to the underlying logger. Loggers like pino will preserve this as a structured record; console-based loggers pass it as the second argument to `console.<level>`.
|
|
8
|
+
*/
|
|
9
|
+
debug: (message: string, meta?: Record<string, unknown>) => void
|
|
10
|
+
/**
|
|
11
|
+
* Called for notable informational events (outgoing requests, tool invocations, middleware transitions).
|
|
12
|
+
* @param meta Structured data forwarded to the underlying logger. Loggers like pino will preserve this as a structured record; console-based loggers pass it as the second argument to `console.<level>`.
|
|
13
|
+
*/
|
|
14
|
+
info: (message: string, meta?: Record<string, unknown>) => void
|
|
15
|
+
/**
|
|
16
|
+
* Called for notable warnings that don't halt execution (deprecations, recoverable anomalies).
|
|
17
|
+
* @param meta Structured data forwarded to the underlying logger. Loggers like pino will preserve this as a structured record; console-based loggers pass it as the second argument to `console.<level>`.
|
|
18
|
+
*/
|
|
19
|
+
warn: (message: string, meta?: Record<string, unknown>) => void
|
|
20
|
+
/**
|
|
21
|
+
* Called for caught exceptions throughout the pipeline.
|
|
22
|
+
* @param meta Structured data forwarded to the underlying logger. Loggers like pino will preserve this as a structured record; console-based loggers pass it as the second argument to `console.<level>`.
|
|
23
|
+
*/
|
|
24
|
+
error: (message: string, meta?: Record<string, unknown>) => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Per-category toggles for debug logging. Each flag enables or disables one class of log message. Unspecified flags default to `true` when `DebugConfig` is partially specified; `undefined` on the `debug` option defaults all flags to `false` except `errors`.
|
|
29
|
+
*/
|
|
30
|
+
export interface DebugCategories {
|
|
31
|
+
/**
|
|
32
|
+
* Raw chunks/frames received from a provider SDK (OpenAI, Anthropic, Gemini, Ollama, Grok, Groq, OpenRouter, fal, ElevenLabs). Emitted inside every streaming adapter's chunk loop.
|
|
33
|
+
*/
|
|
34
|
+
provider?: boolean
|
|
35
|
+
/**
|
|
36
|
+
* Chunks/results yielded to the consumer after all middleware. For streaming activities this fires per chunk; for non-streaming activities it fires once per result.
|
|
37
|
+
*/
|
|
38
|
+
output?: boolean
|
|
39
|
+
/**
|
|
40
|
+
* Inputs and outputs around each middleware hook invocation. Chat-only.
|
|
41
|
+
*/
|
|
42
|
+
middleware?: boolean
|
|
43
|
+
/**
|
|
44
|
+
* Before/after tool-call execution in the chat agent loop. Chat-only.
|
|
45
|
+
*/
|
|
46
|
+
tools?: boolean
|
|
47
|
+
/**
|
|
48
|
+
* Iteration markers and phase transitions in the chat agent loop. Chat-only.
|
|
49
|
+
*/
|
|
50
|
+
agentLoop?: boolean
|
|
51
|
+
/**
|
|
52
|
+
* Config transforms returned by middleware `onConfig` hooks. Chat-only.
|
|
53
|
+
*/
|
|
54
|
+
config?: boolean
|
|
55
|
+
/**
|
|
56
|
+
* Caught errors throughout the pipeline. Unlike other categories, defaults to `true` even when `debug` is unspecified. Explicitly set `errors: false` or `debug: false` to silence.
|
|
57
|
+
*/
|
|
58
|
+
errors?: boolean
|
|
59
|
+
/**
|
|
60
|
+
* Outgoing call metadata (provider, model, message/tool counts) emitted before each adapter SDK call.
|
|
61
|
+
*/
|
|
62
|
+
request?: boolean
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Granular debug configuration combining per-category toggles with an optional custom logger. Any unspecified category flag defaults to `true`.
|
|
67
|
+
*/
|
|
68
|
+
export interface DebugConfig extends DebugCategories {
|
|
69
|
+
/**
|
|
70
|
+
* Custom `Logger` implementation. When omitted, a default `ConsoleLogger` routes output to `console.debug`/`info`/`warn`/`error`.
|
|
71
|
+
*/
|
|
72
|
+
logger?: Logger
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The shape accepted by the `debug` option on every `@tanstack/ai` activity. Pass `true` to enable all categories with the default console logger; `false` to silence everything including errors; an object for granular control.
|
|
77
|
+
*/
|
|
78
|
+
export type DebugOption = boolean | DebugConfig
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toRunErrorPayload } from './activities/error-payload'
|
|
1
2
|
import type { StreamChunk } from './types'
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -68,7 +69,7 @@ export function toServerSentEventsStream(
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
controller.close()
|
|
71
|
-
} catch (error:
|
|
72
|
+
} catch (error: unknown) {
|
|
72
73
|
// Don't send error if aborted
|
|
73
74
|
if (abortController?.signal.aborted) {
|
|
74
75
|
controller.close()
|
|
@@ -81,10 +82,7 @@ export function toServerSentEventsStream(
|
|
|
81
82
|
`data: ${JSON.stringify({
|
|
82
83
|
type: 'RUN_ERROR',
|
|
83
84
|
timestamp: Date.now(),
|
|
84
|
-
error:
|
|
85
|
-
message: error.message || 'Unknown error occurred',
|
|
86
|
-
code: error.code,
|
|
87
|
-
},
|
|
85
|
+
error: toRunErrorPayload(error),
|
|
88
86
|
})}\n\n`,
|
|
89
87
|
),
|
|
90
88
|
)
|
|
@@ -190,7 +188,7 @@ export function toHttpStream(
|
|
|
190
188
|
}
|
|
191
189
|
|
|
192
190
|
controller.close()
|
|
193
|
-
} catch (error:
|
|
191
|
+
} catch (error: unknown) {
|
|
194
192
|
// Don't send error if aborted
|
|
195
193
|
if (abortController?.signal.aborted) {
|
|
196
194
|
controller.close()
|
|
@@ -203,10 +201,7 @@ export function toHttpStream(
|
|
|
203
201
|
`${JSON.stringify({
|
|
204
202
|
type: 'RUN_ERROR',
|
|
205
203
|
timestamp: Date.now(),
|
|
206
|
-
error:
|
|
207
|
-
message: error.message || 'Unknown error occurred',
|
|
208
|
-
code: error.code,
|
|
209
|
-
},
|
|
204
|
+
error: toRunErrorPayload(error),
|
|
210
205
|
})}\n`,
|
|
211
206
|
),
|
|
212
207
|
)
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { StandardJSONSchemaV1 } from '@standard-schema/spec'
|
|
2
|
+
import type { InternalLogger } from './logger/internal-logger'
|
|
2
3
|
import type {
|
|
3
4
|
BaseEvent as AGUIBaseEvent,
|
|
4
5
|
CustomEvent as AGUICustomEvent,
|
|
@@ -738,6 +739,14 @@ export interface TextOptions<
|
|
|
738
739
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/AbortController
|
|
739
740
|
*/
|
|
740
741
|
abortController?: AbortController
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* Internal logger threaded from the chat entry point. Adapter implementations
|
|
745
|
+
* must call `logger.request()` before SDK calls, `logger.provider()` for each
|
|
746
|
+
* chunk received, and `logger.errors()` in catch blocks.
|
|
747
|
+
*/
|
|
748
|
+
logger: InternalLogger
|
|
749
|
+
|
|
741
750
|
/**
|
|
742
751
|
* Thread ID for AG-UI protocol run correlation.
|
|
743
752
|
* When provided, this will be used in RunStartedEvent and RunFinishedEvent.
|
|
@@ -1163,6 +1172,11 @@ export interface SummarizationOptions {
|
|
|
1163
1172
|
maxLength?: number
|
|
1164
1173
|
style?: 'bullet-points' | 'paragraph' | 'concise'
|
|
1165
1174
|
focus?: Array<string>
|
|
1175
|
+
/**
|
|
1176
|
+
* Internal logger threaded from the summarize() entry point. Adapters must
|
|
1177
|
+
* call logger.request() before the SDK call and logger.errors() in catch blocks.
|
|
1178
|
+
*/
|
|
1179
|
+
logger: InternalLogger
|
|
1166
1180
|
}
|
|
1167
1181
|
|
|
1168
1182
|
export interface SummarizationResult {
|
|
@@ -1198,16 +1212,35 @@ export interface ImageGenerationOptions<
|
|
|
1198
1212
|
size?: TSize
|
|
1199
1213
|
/** Model-specific options for image generation */
|
|
1200
1214
|
modelOptions?: TProviderOptions
|
|
1215
|
+
/**
|
|
1216
|
+
* Internal logger threaded from the generateImage() entry point. Adapters must
|
|
1217
|
+
* call logger.request() before the SDK call and logger.errors() in catch blocks.
|
|
1218
|
+
*/
|
|
1219
|
+
logger: InternalLogger
|
|
1201
1220
|
}
|
|
1202
1221
|
|
|
1222
|
+
/**
|
|
1223
|
+
* Source of a generated media asset. Exactly one of `url` or `b64Json` is
|
|
1224
|
+
* present; the other is absent. Modeled as a mutually-exclusive union so the
|
|
1225
|
+
* type rejects `{}` and `{ url, b64Json }` together at compile time while
|
|
1226
|
+
* preserving the flat `.url` / `.b64Json` access patterns.
|
|
1227
|
+
*/
|
|
1228
|
+
export type GeneratedMediaSource =
|
|
1229
|
+
| {
|
|
1230
|
+
/** URL to the generated asset (may be temporary) */
|
|
1231
|
+
url: string
|
|
1232
|
+
b64Json?: never
|
|
1233
|
+
}
|
|
1234
|
+
| {
|
|
1235
|
+
/** Base64-encoded asset data */
|
|
1236
|
+
b64Json: string
|
|
1237
|
+
url?: never
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1203
1240
|
/**
|
|
1204
1241
|
* A single generated image
|
|
1205
1242
|
*/
|
|
1206
|
-
export
|
|
1207
|
-
/** Base64-encoded image data */
|
|
1208
|
-
b64Json?: string
|
|
1209
|
-
/** URL to the generated image (may be temporary) */
|
|
1210
|
-
url?: string
|
|
1243
|
+
export type GeneratedImage = GeneratedMediaSource & {
|
|
1211
1244
|
/** Revised prompt used by the model (if applicable) */
|
|
1212
1245
|
revisedPrompt?: string
|
|
1213
1246
|
}
|
|
@@ -1230,6 +1263,61 @@ export interface ImageGenerationResult {
|
|
|
1230
1263
|
}
|
|
1231
1264
|
}
|
|
1232
1265
|
|
|
1266
|
+
// ============================================================================
|
|
1267
|
+
// Audio Generation Types
|
|
1268
|
+
// ============================================================================
|
|
1269
|
+
|
|
1270
|
+
/**
|
|
1271
|
+
* Options for audio generation (music, sound effects, etc.).
|
|
1272
|
+
* These are the common options supported across providers.
|
|
1273
|
+
*/
|
|
1274
|
+
export interface AudioGenerationOptions<
|
|
1275
|
+
TProviderOptions extends object = object,
|
|
1276
|
+
> {
|
|
1277
|
+
/** The model to use for audio generation */
|
|
1278
|
+
model: string
|
|
1279
|
+
/** Text description of the desired audio */
|
|
1280
|
+
prompt: string
|
|
1281
|
+
/** Desired duration in seconds */
|
|
1282
|
+
duration?: number
|
|
1283
|
+
/** Model-specific options for audio generation */
|
|
1284
|
+
modelOptions?: TProviderOptions
|
|
1285
|
+
/**
|
|
1286
|
+
* Internal logger threaded from the generateAudio() entry point. Adapters
|
|
1287
|
+
* must call logger.request() before the SDK call and logger.errors() in
|
|
1288
|
+
* catch blocks.
|
|
1289
|
+
*/
|
|
1290
|
+
logger: InternalLogger
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* A single generated audio output
|
|
1295
|
+
*/
|
|
1296
|
+
export type GeneratedAudio = GeneratedMediaSource & {
|
|
1297
|
+
/** Content type of the audio (e.g., 'audio/wav', 'audio/mp3') */
|
|
1298
|
+
contentType?: string
|
|
1299
|
+
/** Duration of the generated audio in seconds */
|
|
1300
|
+
duration?: number
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
/**
|
|
1304
|
+
* Result of audio generation
|
|
1305
|
+
*/
|
|
1306
|
+
export interface AudioGenerationResult {
|
|
1307
|
+
/** Unique identifier for the generation */
|
|
1308
|
+
id: string
|
|
1309
|
+
/** Model used for generation */
|
|
1310
|
+
model: string
|
|
1311
|
+
/** The generated audio */
|
|
1312
|
+
audio: GeneratedAudio
|
|
1313
|
+
/** Token usage information (if available) */
|
|
1314
|
+
usage?: {
|
|
1315
|
+
inputTokens?: number
|
|
1316
|
+
outputTokens?: number
|
|
1317
|
+
totalTokens?: number
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1233
1321
|
// ============================================================================
|
|
1234
1322
|
// Video Generation Types (Experimental)
|
|
1235
1323
|
// ============================================================================
|
|
@@ -1254,6 +1342,11 @@ export interface VideoGenerationOptions<
|
|
|
1254
1342
|
duration?: number
|
|
1255
1343
|
/** Model-specific options for video generation */
|
|
1256
1344
|
modelOptions?: TProviderOptions
|
|
1345
|
+
/**
|
|
1346
|
+
* Internal logger threaded from the generateVideo() entry point. Adapters must
|
|
1347
|
+
* call logger.request() before the SDK call and logger.errors() in catch blocks.
|
|
1348
|
+
*/
|
|
1349
|
+
logger: InternalLogger
|
|
1257
1350
|
}
|
|
1258
1351
|
|
|
1259
1352
|
/**
|
|
@@ -1319,6 +1412,12 @@ export interface TTSOptions<TProviderOptions extends object = object> {
|
|
|
1319
1412
|
speed?: number
|
|
1320
1413
|
/** Model-specific options for TTS generation */
|
|
1321
1414
|
modelOptions?: TProviderOptions
|
|
1415
|
+
/**
|
|
1416
|
+
* Internal logger threaded from the generateSpeech() entry point. Adapters
|
|
1417
|
+
* must call logger.request() before the SDK call and logger.errors() in
|
|
1418
|
+
* catch blocks.
|
|
1419
|
+
*/
|
|
1420
|
+
logger: InternalLogger
|
|
1322
1421
|
}
|
|
1323
1422
|
|
|
1324
1423
|
/**
|
|
@@ -1362,6 +1461,12 @@ export interface TranscriptionOptions<
|
|
|
1362
1461
|
responseFormat?: 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt'
|
|
1363
1462
|
/** Model-specific options for transcription */
|
|
1364
1463
|
modelOptions?: TProviderOptions
|
|
1464
|
+
/**
|
|
1465
|
+
* Internal logger threaded from the generateTranscription() entry point.
|
|
1466
|
+
* Adapters must call logger.request() before the SDK call and logger.errors()
|
|
1467
|
+
* in catch blocks.
|
|
1468
|
+
*/
|
|
1469
|
+
logger: InternalLogger
|
|
1365
1470
|
}
|
|
1366
1471
|
|
|
1367
1472
|
/**
|