@gedatou/cadenza-ai 0.7.1

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.
Files changed (57) hide show
  1. package/README.md +71 -0
  2. package/dist/anthropic-DdrANeO1.mjs +236 -0
  3. package/dist/bedrock-534H9yfk.mjs +75 -0
  4. package/dist/catalog-CvvS2JaW.mjs +32 -0
  5. package/dist/deepseek-C1b74T2F.mjs +55 -0
  6. package/dist/gemini-DcJ5Kr3h.mjs +229 -0
  7. package/dist/grok-CffQuBd6.mjs +77 -0
  8. package/dist/groq-Ba6TTYLp.mjs +98 -0
  9. package/dist/index.d.mts +1056 -0
  10. package/dist/index.mjs +2809 -0
  11. package/dist/llmgateway-Pt5CS6aQ.mjs +211 -0
  12. package/dist/mistral-BGMwwbU9.mjs +107 -0
  13. package/dist/mock/index.d.mts +168 -0
  14. package/dist/mock/index.mjs +467 -0
  15. package/dist/ollama-BBJs-3mK.mjs +80 -0
  16. package/dist/openai--FIeahIH.mjs +153 -0
  17. package/dist/openrouter-q-lx-2Cb.mjs +167 -0
  18. package/dist/preset-CEyIPxfS.mjs +157 -0
  19. package/dist/preset-DRT0T14q.d.mts +19 -0
  20. package/dist/providers/anthropic.d.mts +6 -0
  21. package/dist/providers/anthropic.mjs +11 -0
  22. package/dist/providers/bedrock.d.mts +6 -0
  23. package/dist/providers/bedrock.mjs +11 -0
  24. package/dist/providers/byteplus.d.mts +6 -0
  25. package/dist/providers/byteplus.mjs +21 -0
  26. package/dist/providers/deepseek.d.mts +35 -0
  27. package/dist/providers/deepseek.mjs +283 -0
  28. package/dist/providers/gemini.d.mts +6 -0
  29. package/dist/providers/gemini.mjs +11 -0
  30. package/dist/providers/grok.d.mts +6 -0
  31. package/dist/providers/grok.mjs +11 -0
  32. package/dist/providers/groq.d.mts +6 -0
  33. package/dist/providers/groq.mjs +11 -0
  34. package/dist/providers/llmgateway.d.mts +6 -0
  35. package/dist/providers/llmgateway.mjs +11 -0
  36. package/dist/providers/mistral.d.mts +6 -0
  37. package/dist/providers/mistral.mjs +11 -0
  38. package/dist/providers/ollama.d.mts +9 -0
  39. package/dist/providers/ollama.mjs +28 -0
  40. package/dist/providers/openai-compatible.d.mts +32 -0
  41. package/dist/providers/openai-compatible.mjs +45 -0
  42. package/dist/providers/openai.d.mts +6 -0
  43. package/dist/providers/openai.mjs +11 -0
  44. package/dist/providers/openrouter.d.mts +6 -0
  45. package/dist/providers/openrouter.mjs +11 -0
  46. package/dist/providers/vercel-gateway.d.mts +6 -0
  47. package/dist/providers/vercel-gateway.mjs +11 -0
  48. package/dist/providers/vertex.d.mts +6 -0
  49. package/dist/providers/vertex.mjs +11 -0
  50. package/dist/server/index.d.mts +173 -0
  51. package/dist/server/index.mjs +440 -0
  52. package/dist/thinking-CH2uL1dr.mjs +26 -0
  53. package/dist/types-56Hn7Qq2.d.mts +46 -0
  54. package/dist/vercel-gateway-DW3Z0Os1.mjs +109 -0
  55. package/dist/vertex-hg4Dt54O.mjs +20 -0
  56. package/package.json +114 -0
  57. package/styles.css +3 -0
@@ -0,0 +1,211 @@
1
+ import { defineByokProvider } from "@tanstack/ai/byok";
2
+ //#region src/catalog/providers/llmgateway.ts
3
+ const llmgateway = {
4
+ id: "llmgateway",
5
+ label: "LLM Gateway",
6
+ byok: defineByokProvider({
7
+ id: "llmgateway",
8
+ label: "LLM Gateway",
9
+ env: "LLM_GATEWAY_API_KEY"
10
+ }),
11
+ keyRequired: true,
12
+ runtime: "node",
13
+ models: [
14
+ {
15
+ id: "gpt-5.6-terra",
16
+ name: "GPT-5.6 Terra",
17
+ provider: "llmgateway",
18
+ input: ["text", "image"],
19
+ reasoning: true,
20
+ contextWindow: 105e4,
21
+ maxOutputTokens: 128e3,
22
+ cost: {
23
+ input: 2.5,
24
+ output: 15,
25
+ cacheRead: .25
26
+ }
27
+ },
28
+ {
29
+ id: "gpt-5.5",
30
+ name: "GPT-5.5",
31
+ provider: "llmgateway",
32
+ input: ["text", "image"],
33
+ reasoning: true,
34
+ contextWindow: 105e4,
35
+ maxOutputTokens: 128e3,
36
+ cost: {
37
+ input: 5,
38
+ output: 30,
39
+ cacheRead: .5
40
+ }
41
+ },
42
+ {
43
+ id: "gpt-5.4-mini",
44
+ name: "GPT-5.4 mini",
45
+ provider: "llmgateway",
46
+ input: ["text", "image"],
47
+ reasoning: true,
48
+ contextWindow: 4e5,
49
+ maxOutputTokens: 128e3,
50
+ cost: {
51
+ input: .75,
52
+ output: 4.5,
53
+ cacheRead: .075
54
+ }
55
+ },
56
+ {
57
+ id: "claude-opus-5",
58
+ name: "Claude Opus 5",
59
+ provider: "llmgateway",
60
+ input: ["text", "image"],
61
+ reasoning: true,
62
+ contextWindow: 1e6,
63
+ maxOutputTokens: 128e3,
64
+ cost: {
65
+ input: 5,
66
+ output: 25,
67
+ cacheRead: .5
68
+ }
69
+ },
70
+ {
71
+ id: "claude-sonnet-5",
72
+ name: "Claude Sonnet 5",
73
+ provider: "llmgateway",
74
+ input: ["text", "image"],
75
+ reasoning: true,
76
+ contextWindow: 1e6,
77
+ maxOutputTokens: 128e3,
78
+ cost: {
79
+ input: 2,
80
+ output: 10,
81
+ cacheRead: .2
82
+ }
83
+ },
84
+ {
85
+ id: "claude-haiku-4-5",
86
+ name: "Claude Haiku 4.5",
87
+ provider: "llmgateway",
88
+ input: ["text", "image"],
89
+ reasoning: true,
90
+ contextWindow: 2e5,
91
+ maxOutputTokens: 64e3,
92
+ cost: {
93
+ input: 1,
94
+ output: 5,
95
+ cacheRead: .1
96
+ }
97
+ },
98
+ {
99
+ id: "gemini-pro-latest",
100
+ name: "Gemini Pro (latest)",
101
+ provider: "llmgateway",
102
+ input: ["text", "image"],
103
+ reasoning: true,
104
+ contextWindow: 1048576,
105
+ maxOutputTokens: 65536,
106
+ cost: {
107
+ input: 2,
108
+ output: 12,
109
+ cacheRead: .2
110
+ }
111
+ },
112
+ {
113
+ id: "gemini-3.6-flash",
114
+ name: "Gemini 3.6 Flash",
115
+ provider: "llmgateway",
116
+ input: ["text", "image"],
117
+ reasoning: true,
118
+ contextWindow: 1048576,
119
+ maxOutputTokens: 65536,
120
+ cost: {
121
+ input: 1.5,
122
+ output: 7.5,
123
+ cacheRead: .15
124
+ }
125
+ },
126
+ {
127
+ id: "kimi-k3",
128
+ name: "Kimi K3",
129
+ provider: "llmgateway",
130
+ input: ["text", "image"],
131
+ reasoning: true,
132
+ contextWindow: 1048576,
133
+ maxOutputTokens: 1048576,
134
+ cost: {
135
+ input: 3,
136
+ output: 15,
137
+ cacheRead: .3
138
+ }
139
+ },
140
+ {
141
+ id: "glm-5.2",
142
+ name: "GLM 5.2",
143
+ provider: "llmgateway",
144
+ input: ["text"],
145
+ reasoning: true,
146
+ contextWindow: 1e6,
147
+ maxOutputTokens: 128e3,
148
+ cost: {
149
+ input: 1.4,
150
+ output: 4.4,
151
+ cacheRead: .26
152
+ }
153
+ },
154
+ {
155
+ id: "deepseek-v4-pro",
156
+ name: "DeepSeek V4 Pro",
157
+ provider: "llmgateway",
158
+ input: ["text"],
159
+ reasoning: true,
160
+ contextWindow: 105e4,
161
+ maxOutputTokens: 393216,
162
+ cost: {
163
+ input: .435,
164
+ output: .87
165
+ }
166
+ },
167
+ {
168
+ id: "qwen3.7-max",
169
+ name: "Qwen3.7 Max",
170
+ provider: "llmgateway",
171
+ input: ["text"],
172
+ reasoning: true,
173
+ contextWindow: 1e6,
174
+ maxOutputTokens: 65536,
175
+ cost: {
176
+ input: 2.5,
177
+ output: 7.5,
178
+ cacheRead: .5
179
+ }
180
+ },
181
+ {
182
+ id: "minimax-m2.5",
183
+ name: "MiniMax M2.5",
184
+ provider: "llmgateway",
185
+ input: ["text"],
186
+ reasoning: true,
187
+ contextWindow: 204800,
188
+ maxOutputTokens: 131100,
189
+ cost: {
190
+ input: .3,
191
+ output: 1.2,
192
+ cacheRead: .03
193
+ }
194
+ },
195
+ {
196
+ id: "grok-4-5",
197
+ name: "Grok 4.5",
198
+ provider: "llmgateway",
199
+ input: ["text", "image"],
200
+ reasoning: true,
201
+ contextWindow: 5e5,
202
+ cost: {
203
+ input: 2,
204
+ output: 6,
205
+ cacheRead: .5
206
+ }
207
+ }
208
+ ]
209
+ };
210
+ //#endregion
211
+ export { llmgateway as t };
@@ -0,0 +1,107 @@
1
+ import { defineByokProvider } from "@tanstack/ai/byok";
2
+ //#region src/catalog/providers/mistral.ts
3
+ const mistral = {
4
+ id: "mistral",
5
+ label: "Mistral",
6
+ byok: defineByokProvider({
7
+ id: "mistral",
8
+ label: "Mistral",
9
+ env: "MISTRAL_API_KEY"
10
+ }),
11
+ keyRequired: true,
12
+ runtime: "node",
13
+ models: [
14
+ {
15
+ id: "mistral-large-latest",
16
+ name: "Mistral Large",
17
+ provider: "mistral",
18
+ input: ["text"],
19
+ reasoning: false,
20
+ contextWindow: 131072,
21
+ maxOutputTokens: 8192,
22
+ cost: {
23
+ input: .5,
24
+ output: 1.5
25
+ }
26
+ },
27
+ {
28
+ id: "mistral-medium-latest",
29
+ name: "Mistral Medium",
30
+ provider: "mistral",
31
+ input: [
32
+ "text",
33
+ "image",
34
+ "document"
35
+ ],
36
+ reasoning: false,
37
+ contextWindow: 131072,
38
+ maxOutputTokens: 8192,
39
+ cost: {
40
+ input: .4,
41
+ output: 2
42
+ }
43
+ },
44
+ {
45
+ id: "mistral-small-latest",
46
+ name: "Mistral Small",
47
+ provider: "mistral",
48
+ input: [
49
+ "text",
50
+ "image",
51
+ "document"
52
+ ],
53
+ reasoning: false,
54
+ contextWindow: 131072,
55
+ maxOutputTokens: 8192,
56
+ cost: {
57
+ input: .1,
58
+ output: .3
59
+ }
60
+ },
61
+ {
62
+ id: "magistral-medium-latest",
63
+ name: "Magistral Medium",
64
+ provider: "mistral",
65
+ input: ["text"],
66
+ reasoning: false,
67
+ contextWindow: 4e4,
68
+ maxOutputTokens: 4e4,
69
+ cost: {
70
+ input: 2,
71
+ output: 5
72
+ }
73
+ },
74
+ {
75
+ id: "magistral-small-latest",
76
+ name: "Magistral Small",
77
+ provider: "mistral",
78
+ input: ["text"],
79
+ reasoning: false,
80
+ contextWindow: 4e4,
81
+ maxOutputTokens: 4e4,
82
+ cost: {
83
+ input: .5,
84
+ output: 1.5
85
+ }
86
+ },
87
+ {
88
+ id: "pixtral-large-latest",
89
+ name: "Pixtral Large",
90
+ provider: "mistral",
91
+ input: [
92
+ "text",
93
+ "image",
94
+ "document"
95
+ ],
96
+ reasoning: false,
97
+ contextWindow: 131072,
98
+ maxOutputTokens: 8192,
99
+ cost: {
100
+ input: 2,
101
+ output: 6
102
+ }
103
+ }
104
+ ]
105
+ };
106
+ //#endregion
107
+ export { mistral as t };
@@ -0,0 +1,168 @@
1
+ import { RunAgentResumeItem, UIMessage } from "@tanstack/ai/client";
2
+ import { ChatFetcher } from "@tanstack/ai-client";
3
+ //#region src/mock/steps.d.ts
4
+ /**
5
+ * Step DSL for the scripted transport — pure data, no runtime behaviour.
6
+ * `run.ts` translates a list of steps into AG-UI events.
7
+ */
8
+ /**
9
+ * The half of `TokenUsage` that has no AG-UI spec field, carried the way the
10
+ * real transport carries it — `toSpecTokenUsage` puts these in `leftover`, the
11
+ * server hangs them on `metadata.tanstack.usage`, and `fromSpecTokenUsage`
12
+ * rebuilds them on the client. A script that wants to show cache writes or the
13
+ * modality breakdown has to travel the same road, or it is proving nothing.
14
+ */
15
+ interface UsageLeftover {
16
+ promptTokensDetails?: Record<string, number>;
17
+ completionTokensDetails?: Record<string, number>;
18
+ cost?: number;
19
+ }
20
+ type Step = {
21
+ kind: 'text';
22
+ content: string;
23
+ chunk?: 'word' | 'char' | number;
24
+ pace?: number;
25
+ } | {
26
+ kind: 'reasoning';
27
+ content: string;
28
+ chunk?: 'word' | 'char' | number;
29
+ pace?: number;
30
+ signature?: string;
31
+ } | {
32
+ kind: 'tool';
33
+ name: string;
34
+ input: unknown;
35
+ output?: unknown;
36
+ error?: string;
37
+ argsChunk?: number;
38
+ approval?: boolean;
39
+ client?: boolean;
40
+ providerExecuted?: boolean;
41
+ metadata?: Record<string, unknown>;
42
+ toolCallId?: string;
43
+ } | {
44
+ kind: 'tool-result';
45
+ toolCallId: string;
46
+ output: unknown;
47
+ error?: boolean;
48
+ } | {
49
+ kind: 'custom';
50
+ name: string;
51
+ value: unknown;
52
+ } | {
53
+ kind: 'structured';
54
+ object: unknown;
55
+ chunk?: number;
56
+ } | {
57
+ kind: 'usage';
58
+ usage: {
59
+ inputTokens: number;
60
+ outputTokens: number;
61
+ reasoningTokens?: number;
62
+ cachedInputTokens?: number;
63
+ };
64
+ details?: UsageLeftover;
65
+ } | {
66
+ kind: 'error';
67
+ message: string;
68
+ code?: string;
69
+ } | {
70
+ kind: 'sleep';
71
+ ms: number;
72
+ } | {
73
+ kind: 'finish';
74
+ finishReason?: 'stop' | 'length' | 'content_filter' | 'tool_calls';
75
+ };
76
+ /** Assistant text. Several `text` steps in one run share a single assistant message. */
77
+ declare const text: (content: string, o?: Omit<Extract<Step, {
78
+ kind: "text";
79
+ }>, "kind" | "content">) => Step;
80
+ /** A thinking block; `signature` is attached via `STEP_FINISHED` the way the engine does it. */
81
+ declare const reasoning: (content: string, o?: Omit<Extract<Step, {
82
+ kind: "reasoning";
83
+ }>, "kind" | "content">) => Step;
84
+ /**
85
+ * A tool call. Without `approval` / `client` the result follows immediately;
86
+ * with either, the run finishes on an interrupt and `tool.result` continues it next turn.
87
+ */
88
+ declare const tool: ((name: string, input: unknown, o?: Omit<Extract<Step, {
89
+ kind: "tool";
90
+ }>, "kind" | "name" | "input">) => Step) & {
91
+ result: (toolCallId: string, output: unknown, o?: {
92
+ error?: boolean;
93
+ }) => Step;
94
+ };
95
+ declare const custom: (name: string, value: unknown) => Step;
96
+ declare const structured: (object: unknown, o?: {
97
+ chunk?: number;
98
+ }) => Step;
99
+ /** Token usage for the run. `details` carries the fields with no spec slot, through the same leftover channel the real transport uses. */
100
+ declare const usage: (u: Extract<Step, {
101
+ kind: "usage";
102
+ }>["usage"], details?: UsageLeftover) => Step;
103
+ declare const error: (message: string, code?: string) => Step;
104
+ declare const sleep: (ms: number) => Step;
105
+ declare const finish: (o?: {
106
+ finishReason?: Extract<Step, {
107
+ kind: "finish";
108
+ }>["finishReason"];
109
+ }) => Step;
110
+ //#endregion
111
+ //#region src/mock/run.d.ts
112
+ interface ScriptContext {
113
+ messages: UIMessage[];
114
+ lastUser?: UIMessage;
115
+ lastUserText: string;
116
+ /** Merged body: `forwardedProps` plus the per-call `sendMessage` body. */
117
+ data: Record<string, unknown>;
118
+ threadId: string;
119
+ runId: string;
120
+ parentRunId?: string;
121
+ /** Resolutions of the previous run's interrupts; read with `approvalOf` / `clientResultOf`. */
122
+ resume?: RunAgentResumeItem[];
123
+ /** How many times this fetcher instance has been called before (starts at 0). */
124
+ turn: number;
125
+ /** Fires on `stop()`. */
126
+ signal: AbortSignal;
127
+ }
128
+ type Script = (ctx: ScriptContext) => Step[] | Iterable<Step> | AsyncIterable<Step> | Promise<Step[]> | Response;
129
+ interface ScriptedOptions {
130
+ /** Delay between chunks in ms; `'instant'` skips the timers. Default 24. */
131
+ pace?: number | 'instant';
132
+ /** Default slicing for `text` / `reasoning`. Default `'word'`. */
133
+ chunk?: 'word' | 'char' | number;
134
+ /** Default slicing of tool arguments (characters per `TOOL_CALL_ARGS`); a `tool` step's own `argsChunk` wins. Default: whole. */
135
+ argsChunk?: number;
136
+ /**
137
+ * Answer as a `text/event-stream` `Response` (`data: <chunk>` lines) instead
138
+ * of an `AsyncIterable<StreamChunk>`, so the client runs its real SSE parser
139
+ * — the same path `/api/ai/chat` takes. Default false.
140
+ */
141
+ sse?: boolean;
142
+ messageId?: () => string;
143
+ toolCallId?: () => string;
144
+ }
145
+ /** Turn a step script into a `ChatFetcher` for `useChat({ fetcher })`. */
146
+ declare function scripted(script: Script, options?: ScriptedOptions): ChatFetcher;
147
+ /** Turn n answers with `turns[n]`; past the end the last entry repeats. */
148
+ declare function sequence(turns: Array<Step[] | Script>): Script;
149
+ type RespondRule = [match: RegExp | string | ((ctx: ScriptContext) => boolean), reply: Step[] | Script];
150
+ /** Pick the first rule whose matcher hits `lastUserText`; otherwise `fallback` (default: `echo()`). */
151
+ declare function respond(rules: RespondRule[], fallback?: Step[] | Script): Script;
152
+ /** Repeat the last user message, listing attachment MIME types and `data.model` when present. */
153
+ declare function echo(options?: Pick<Extract<Step, {
154
+ kind: 'text';
155
+ }>, 'chunk' | 'pace'>): Script;
156
+ /** A 401 the client turns into `byok.request(provider, 'missing')`. Return it from a script. */
157
+ declare function byokMissing(provider: string): Response;
158
+ interface ApprovalDecision {
159
+ approved: boolean;
160
+ editedArgs?: unknown;
161
+ payload?: unknown;
162
+ }
163
+ /** The user's decision for `tool(name, input, { approval: true })` from the previous run, if resolved. */
164
+ declare function approvalOf(ctx: ScriptContext, toolCallId: string): ApprovalDecision | undefined;
165
+ /** The client-side output for `tool(name, input, { client: true })` from the previous run, if resolved. */
166
+ declare function clientResultOf(ctx: ScriptContext, toolCallId: string): unknown;
167
+ //#endregion
168
+ export { type ApprovalDecision, type RespondRule, type Script, type ScriptContext, type ScriptedOptions, type Step, approvalOf, byokMissing, clientResultOf, custom, echo, error, finish, reasoning, respond, scripted, sequence, sleep, structured, text, tool, usage };