ai 6.0.187 → 6.0.188

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,29 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.188
4
+
5
+ ### Patch Changes
6
+
7
+ - c98715a: Add `allowSystemInMessages` option to `ToolLoopAgent`.
8
+
9
+ 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.
10
+
11
+ ```ts
12
+ const agent = new ToolLoopAgent({
13
+ model,
14
+ allowSystemInMessages: true,
15
+ });
16
+
17
+ await agent.generate({
18
+ messages: [
19
+ { role: "system", content: "Server context" },
20
+ { role: "user", content: "Hello" },
21
+ ],
22
+ });
23
+ ```
24
+
25
+ The option can also be returned from `prepareCall` for dynamic per-call configuration.
26
+
3
27
  ## 6.0.187
4
28
 
5
29
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -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
@@ -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.188" : "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) {