ai 6.0.187 → 6.0.189

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/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.189
4
+
5
+ ### Patch Changes
6
+
7
+ - 356c3cf: fix(ai): make input optional on input-streaming UIMessagePart variants
8
+
9
+ ## 6.0.188
10
+
11
+ ### Patch Changes
12
+
13
+ - c98715a: Add `allowSystemInMessages` option to `ToolLoopAgent`.
14
+
15
+ This exposes the same option that exists on `streamText` and `generateText`, whether `role: "system"` messages are allowed in the `prompt` or `messages` fields. When unset, system messages are rejected because they can create a prompt injection attack risk. Ideally, use the `instructions` option instead. Set to `true` to allow system messages, or `false` to explicitly reject them.
16
+
17
+ ```ts
18
+ const agent = new ToolLoopAgent({
19
+ model,
20
+ allowSystemInMessages: true,
21
+ });
22
+
23
+ await agent.generate({
24
+ messages: [
25
+ { role: "system", content: "Server context" },
26
+ { role: "user", content: "Hello" },
27
+ ],
28
+ });
29
+ ```
30
+
31
+ The option can also be returned from `prepareCall` for dynamic per-call configuration.
32
+
3
33
  ## 6.0.187
4
34
 
5
35
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1709,7 +1709,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1709
1709
  providerExecuted?: boolean;
1710
1710
  } & ({
1711
1711
  state: 'input-streaming';
1712
- input: DeepPartial<asUITool<TOOL>['input']> | undefined;
1712
+ input?: DeepPartial<asUITool<TOOL>['input']> | undefined;
1713
1713
  output?: never;
1714
1714
  errorText?: never;
1715
1715
  callProviderMetadata?: ProviderMetadata;
@@ -1804,7 +1804,7 @@ type DynamicToolUIPart = {
1804
1804
  providerExecuted?: boolean;
1805
1805
  } & ({
1806
1806
  state: 'input-streaming';
1807
- input: unknown | undefined;
1807
+ input?: unknown;
1808
1808
  output?: never;
1809
1809
  errorText?: never;
1810
1810
  callProviderMetadata?: ProviderMetadata;
@@ -3342,6 +3342,15 @@ type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUT
3342
3342
  * It can be a string, or, if you need to pass additional provider options (e.g. for caching), a `SystemModelMessage`.
3343
3343
  */
3344
3344
  instructions?: string | SystemModelMessage | Array<SystemModelMessage>;
3345
+ /**
3346
+ * Whether system messages are allowed in the `prompt` or `messages` fields.
3347
+ *
3348
+ * When disabled, system messages must be provided through the `instructions`
3349
+ * option.
3350
+ *
3351
+ * @default false
3352
+ */
3353
+ allowSystemInMessages?: boolean;
3345
3354
  /**
3346
3355
  * The language model to use.
3347
3356
  */
@@ -3419,7 +3428,7 @@ type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUT
3419
3428
  *
3420
3429
  * You can use this to have templates based on call options.
3421
3430
  */
3422
- prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, NoInfer<TOOLS>>, 'onStepFinish'> & Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'>) => MaybePromiseLike<Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'> & Omit<Prompt, 'system'>>;
3431
+ prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, NoInfer<TOOLS>>, 'onStepFinish'> & Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'>) => MaybePromiseLike<Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'> & Omit<Prompt, 'system'>>;
3423
3432
  };
3424
3433
 
3425
3434
  /**
package/dist/index.d.ts CHANGED
@@ -1709,7 +1709,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1709
1709
  providerExecuted?: boolean;
1710
1710
  } & ({
1711
1711
  state: 'input-streaming';
1712
- input: DeepPartial<asUITool<TOOL>['input']> | undefined;
1712
+ input?: DeepPartial<asUITool<TOOL>['input']> | undefined;
1713
1713
  output?: never;
1714
1714
  errorText?: never;
1715
1715
  callProviderMetadata?: ProviderMetadata;
@@ -1804,7 +1804,7 @@ type DynamicToolUIPart = {
1804
1804
  providerExecuted?: boolean;
1805
1805
  } & ({
1806
1806
  state: 'input-streaming';
1807
- input: unknown | undefined;
1807
+ input?: unknown;
1808
1808
  output?: never;
1809
1809
  errorText?: never;
1810
1810
  callProviderMetadata?: ProviderMetadata;
@@ -3342,6 +3342,15 @@ type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUT
3342
3342
  * It can be a string, or, if you need to pass additional provider options (e.g. for caching), a `SystemModelMessage`.
3343
3343
  */
3344
3344
  instructions?: string | SystemModelMessage | Array<SystemModelMessage>;
3345
+ /**
3346
+ * Whether system messages are allowed in the `prompt` or `messages` fields.
3347
+ *
3348
+ * When disabled, system messages must be provided through the `instructions`
3349
+ * option.
3350
+ *
3351
+ * @default false
3352
+ */
3353
+ allowSystemInMessages?: boolean;
3345
3354
  /**
3346
3355
  * The language model to use.
3347
3356
  */
@@ -3419,7 +3428,7 @@ type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUT
3419
3428
  *
3420
3429
  * You can use this to have templates based on call options.
3421
3430
  */
3422
- prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, NoInfer<TOOLS>>, 'onStepFinish'> & Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'>) => MaybePromiseLike<Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'> & Omit<Prompt, 'system'>>;
3431
+ prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, NoInfer<TOOLS>>, 'onStepFinish'> & Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'>) => MaybePromiseLike<Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'> & Omit<Prompt, 'system'>>;
3423
3432
  };
3424
3433
 
3425
3434
  /**
package/dist/index.js CHANGED
@@ -1254,7 +1254,7 @@ function detectMediaType({
1254
1254
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
1255
1255
 
1256
1256
  // src/version.ts
1257
- var VERSION = true ? "6.0.187" : "0.0.0-test";
1257
+ var VERSION = true ? "6.0.189" : "0.0.0-test";
1258
1258
 
1259
1259
  // src/util/download/download.ts
1260
1260
  var download = async ({
@@ -8326,11 +8326,22 @@ var ToolLoopAgent = class {
8326
8326
  _b,
8327
8327
  baseCallArgs
8328
8328
  ))) != null ? _d : baseCallArgs;
8329
- const { instructions, messages, prompt, ...callArgs } = preparedCallArgs;
8329
+ const {
8330
+ instructions,
8331
+ allowSystemInMessages,
8332
+ messages,
8333
+ prompt,
8334
+ ...callArgs
8335
+ } = preparedCallArgs;
8330
8336
  return {
8331
8337
  ...callArgs,
8332
8338
  // restore prompt types
8333
- ...{ system: instructions, messages, prompt }
8339
+ ...{
8340
+ system: instructions,
8341
+ allowSystemInMessages,
8342
+ messages,
8343
+ prompt
8344
+ }
8334
8345
  };
8335
8346
  }
8336
8347
  mergeOnStepFinishCallbacks(methodCallback) {