@midscene/shared 1.12.4-beta-20260904065253.0 → 1.12.4

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.
@@ -1,13 +1,19 @@
1
1
  import { z } from "zod";
2
+ import { AGENT_AI_CONTEXT_KEYS, isAgentAIContextKey } from "./agent-context.mjs";
2
3
  const agentBehaviorInitArgShape = {
3
- aiActContext: z.string().optional().describe('Background knowledge passed to aiAct. Default: no extra context.'),
4
+ aiContexts: z.record(z["enum"](AGENT_AI_CONTEXT_KEYS), z.string()).optional().describe('Additional AI guidance such as business facts, rules, constraints, or output requirements. aiContexts.default is used only when neither the call nor its API key provides a context. Values override rather than automatically merge.'),
5
+ aiActContext: z.string().optional().describe('Deprecated compatibility alias for aiContexts.aiAct. aiContexts.aiAct takes precedence when both are provided.'),
4
6
  replanningCycleLimit: z.number().int().nonnegative().optional().describe('Maximum number of replanning cycles for aiAct. Default: model adapter default.'),
5
7
  waitAfterAction: z.number().nonnegative().optional().describe('Wait time in milliseconds after each action execution. Default: 300ms.'),
6
8
  screenshotShrinkFactor: z.number().min(1).optional().describe('Screenshot shrink factor before sending images to AI. Default: 1; high values may reduce recognition quality, especially on mobile.')
7
9
  };
8
10
  function extractAgentBehaviorInitArgs(extracted) {
9
11
  if (!extracted) return;
12
+ const aiContexts = Object.fromEntries(Object.entries(extracted.aiContexts ?? {}).filter(([key, value])=>isAgentAIContextKey(key) && 'string' == typeof value));
10
13
  const agentOptions = {
14
+ ...Object.keys(aiContexts).length > 0 ? {
15
+ aiContexts
16
+ } : {},
11
17
  ...'string' == typeof extracted.aiActContext ? {
12
18
  aiActContext: extracted.aiActContext
13
19
  } : {},
@@ -0,0 +1,27 @@
1
+ const AI_API_NAMES = [
2
+ 'aiAct',
3
+ 'aiTap',
4
+ 'aiRightClick',
5
+ 'aiDoubleClick',
6
+ 'aiHover',
7
+ 'aiInput',
8
+ 'aiKeyboardPress',
9
+ 'aiScroll',
10
+ 'aiPinch',
11
+ 'aiLongPress',
12
+ 'aiClearInput',
13
+ 'aiLocate',
14
+ 'aiQuery',
15
+ 'aiBoolean',
16
+ 'aiNumber',
17
+ 'aiString',
18
+ 'aiAsk',
19
+ 'aiAssert',
20
+ 'aiWaitFor'
21
+ ];
22
+ const AGENT_AI_CONTEXT_KEYS = [
23
+ 'default',
24
+ ...AI_API_NAMES
25
+ ];
26
+ const isAgentAIContextKey = (value)=>'string' == typeof value && AGENT_AI_CONTEXT_KEYS.includes(value);
27
+ export { AGENT_AI_CONTEXT_KEYS, AI_API_NAMES, isAgentAIContextKey };
@@ -1,6 +1,7 @@
1
1
  export * from "./base-tools.mjs";
2
2
  export * from "./tool-defaults.mjs";
3
3
  export * from "./agent-behavior-init-args.mjs";
4
+ export * from "./agent-context.mjs";
4
5
  export * from "./init-arg-utils.mjs";
5
6
  export * from "./error-formatter.mjs";
6
7
  export * from "./tool-generator.mjs";
@@ -5,7 +5,7 @@ import { assert } from "../utils.mjs";
5
5
  import { maskConfig, parseJson } from "./helper.mjs";
6
6
  import { initDebugConfig } from "./init-debug.mjs";
7
7
  const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-common-config.html';
8
- const getCurrentVersion = ()=>"1.12.4-beta-20260904065253.0";
8
+ const getCurrentVersion = ()=>"1.12.4";
9
9
  const getInvalidModelFamilyMessage = (modelFamily)=>`Invalid MIDSCENE_MODEL_FAMILY value: ${modelFamily}. Current version v${getCurrentVersion()} accepts the following model families: ${MODEL_FAMILY_VALUES.join(', ')}. You can also visit ${MODEL_CONFIG_DOC_URL} for the latest configuration information.`;
10
10
  const KEYS_MAP = {
11
11
  insight: INSIGHT_MODEL_CONFIG_KEYS,
@@ -30,15 +30,21 @@ __webpack_require__.d(__webpack_exports__, {
30
30
  shouldRebuildAgentForInitArgs: ()=>shouldRebuildAgentForInitArgs
31
31
  });
32
32
  const external_zod_namespaceObject = require("zod");
33
+ const external_agent_context_js_namespaceObject = require("./agent-context.js");
33
34
  const agentBehaviorInitArgShape = {
34
- aiActContext: external_zod_namespaceObject.z.string().optional().describe('Background knowledge passed to aiAct. Default: no extra context.'),
35
+ aiContexts: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z["enum"](external_agent_context_js_namespaceObject.AGENT_AI_CONTEXT_KEYS), external_zod_namespaceObject.z.string()).optional().describe('Additional AI guidance such as business facts, rules, constraints, or output requirements. aiContexts.default is used only when neither the call nor its API key provides a context. Values override rather than automatically merge.'),
36
+ aiActContext: external_zod_namespaceObject.z.string().optional().describe('Deprecated compatibility alias for aiContexts.aiAct. aiContexts.aiAct takes precedence when both are provided.'),
35
37
  replanningCycleLimit: external_zod_namespaceObject.z.number().int().nonnegative().optional().describe('Maximum number of replanning cycles for aiAct. Default: model adapter default.'),
36
38
  waitAfterAction: external_zod_namespaceObject.z.number().nonnegative().optional().describe('Wait time in milliseconds after each action execution. Default: 300ms.'),
37
39
  screenshotShrinkFactor: external_zod_namespaceObject.z.number().min(1).optional().describe('Screenshot shrink factor before sending images to AI. Default: 1; high values may reduce recognition quality, especially on mobile.')
38
40
  };
39
41
  function extractAgentBehaviorInitArgs(extracted) {
40
42
  if (!extracted) return;
43
+ const aiContexts = Object.fromEntries(Object.entries(extracted.aiContexts ?? {}).filter(([key, value])=>(0, external_agent_context_js_namespaceObject.isAgentAIContextKey)(key) && 'string' == typeof value));
41
44
  const agentOptions = {
45
+ ...Object.keys(aiContexts).length > 0 ? {
46
+ aiContexts
47
+ } : {},
42
48
  ...'string' == typeof extracted.aiActContext ? {
43
49
  aiActContext: extracted.aiActContext
44
50
  } : {},
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ AGENT_AI_CONTEXT_KEYS: ()=>AGENT_AI_CONTEXT_KEYS,
28
+ AI_API_NAMES: ()=>AI_API_NAMES,
29
+ isAgentAIContextKey: ()=>isAgentAIContextKey
30
+ });
31
+ const AI_API_NAMES = [
32
+ 'aiAct',
33
+ 'aiTap',
34
+ 'aiRightClick',
35
+ 'aiDoubleClick',
36
+ 'aiHover',
37
+ 'aiInput',
38
+ 'aiKeyboardPress',
39
+ 'aiScroll',
40
+ 'aiPinch',
41
+ 'aiLongPress',
42
+ 'aiClearInput',
43
+ 'aiLocate',
44
+ 'aiQuery',
45
+ 'aiBoolean',
46
+ 'aiNumber',
47
+ 'aiString',
48
+ 'aiAsk',
49
+ 'aiAssert',
50
+ 'aiWaitFor'
51
+ ];
52
+ const AGENT_AI_CONTEXT_KEYS = [
53
+ 'default',
54
+ ...AI_API_NAMES
55
+ ];
56
+ const isAgentAIContextKey = (value)=>'string' == typeof value && AGENT_AI_CONTEXT_KEYS.includes(value);
57
+ exports.AGENT_AI_CONTEXT_KEYS = __webpack_exports__.AGENT_AI_CONTEXT_KEYS;
58
+ exports.AI_API_NAMES = __webpack_exports__.AI_API_NAMES;
59
+ exports.isAgentAIContextKey = __webpack_exports__.isAgentAIContextKey;
60
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
61
+ "AGENT_AI_CONTEXT_KEYS",
62
+ "AI_API_NAMES",
63
+ "isAgentAIContextKey"
64
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
65
+ Object.defineProperty(exports, '__esModule', {
66
+ value: true
67
+ });
@@ -3,6 +3,9 @@ var __webpack_modules__ = {
3
3
  "./agent-behavior-init-args" (module) {
4
4
  module.exports = require("./agent-behavior-init-args.js");
5
5
  },
6
+ "./agent-context" (module) {
7
+ module.exports = require("./agent-context.js");
8
+ },
6
9
  "./base-tools" (module) {
7
10
  module.exports = require("./base-tools.js");
8
11
  },
@@ -83,29 +86,33 @@ var __webpack_exports__ = {};
83
86
  var __rspack_reexport = {};
84
87
  for(const __rspack_import_key in _agent_behavior_init_args__rspack_import_2)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_agent_behavior_init_args__rspack_import_2[__rspack_import_key];
85
88
  __webpack_require__.d(__webpack_exports__, __rspack_reexport);
86
- var _init_arg_utils__rspack_import_3 = __webpack_require__("./init-arg-utils");
89
+ var _agent_context__rspack_import_3 = __webpack_require__("./agent-context");
90
+ var __rspack_reexport = {};
91
+ for(const __rspack_import_key in _agent_context__rspack_import_3)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_agent_context__rspack_import_3[__rspack_import_key];
92
+ __webpack_require__.d(__webpack_exports__, __rspack_reexport);
93
+ var _init_arg_utils__rspack_import_4 = __webpack_require__("./init-arg-utils");
87
94
  var __rspack_reexport = {};
88
- for(const __rspack_import_key in _init_arg_utils__rspack_import_3)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_init_arg_utils__rspack_import_3[__rspack_import_key];
95
+ for(const __rspack_import_key in _init_arg_utils__rspack_import_4)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_init_arg_utils__rspack_import_4[__rspack_import_key];
89
96
  __webpack_require__.d(__webpack_exports__, __rspack_reexport);
90
- var _error_formatter__rspack_import_4 = __webpack_require__("./error-formatter");
97
+ var _error_formatter__rspack_import_5 = __webpack_require__("./error-formatter");
91
98
  var __rspack_reexport = {};
92
- for(const __rspack_import_key in _error_formatter__rspack_import_4)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_error_formatter__rspack_import_4[__rspack_import_key];
99
+ for(const __rspack_import_key in _error_formatter__rspack_import_5)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_error_formatter__rspack_import_5[__rspack_import_key];
93
100
  __webpack_require__.d(__webpack_exports__, __rspack_reexport);
94
- var _tool_generator__rspack_import_5 = __webpack_require__("./tool-generator");
101
+ var _tool_generator__rspack_import_6 = __webpack_require__("./tool-generator");
95
102
  var __rspack_reexport = {};
96
- for(const __rspack_import_key in _tool_generator__rspack_import_5)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_tool_generator__rspack_import_5[__rspack_import_key];
103
+ for(const __rspack_import_key in _tool_generator__rspack_import_6)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_tool_generator__rspack_import_6[__rspack_import_key];
97
104
  __webpack_require__.d(__webpack_exports__, __rspack_reexport);
98
- var _types__rspack_import_6 = __webpack_require__("./types");
105
+ var _types__rspack_import_7 = __webpack_require__("./types");
99
106
  var __rspack_reexport = {};
100
- for(const __rspack_import_key in _types__rspack_import_6)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_types__rspack_import_6[__rspack_import_key];
107
+ for(const __rspack_import_key in _types__rspack_import_7)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_types__rspack_import_7[__rspack_import_key];
101
108
  __webpack_require__.d(__webpack_exports__, __rspack_reexport);
102
- var _chrome_path__rspack_import_7 = __webpack_require__("./chrome-path");
109
+ var _chrome_path__rspack_import_8 = __webpack_require__("./chrome-path");
103
110
  var __rspack_reexport = {};
104
- for(const __rspack_import_key in _chrome_path__rspack_import_7)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_chrome_path__rspack_import_7[__rspack_import_key];
111
+ for(const __rspack_import_key in _chrome_path__rspack_import_8)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_chrome_path__rspack_import_8[__rspack_import_key];
105
112
  __webpack_require__.d(__webpack_exports__, __rspack_reexport);
106
- var _observation_record__rspack_import_8 = __webpack_require__("./observation-record");
113
+ var _observation_record__rspack_import_9 = __webpack_require__("./observation-record");
107
114
  var __rspack_reexport = {};
108
- for(const __rspack_import_key in _observation_record__rspack_import_8)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_observation_record__rspack_import_8[__rspack_import_key];
115
+ for(const __rspack_import_key in _observation_record__rspack_import_9)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_observation_record__rspack_import_9[__rspack_import_key];
109
116
  __webpack_require__.d(__webpack_exports__, __rspack_reexport);
110
117
  })();
111
118
  for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
@@ -37,7 +37,7 @@ const external_utils_js_namespaceObject = require("../utils.js");
37
37
  const external_helper_js_namespaceObject = require("./helper.js");
38
38
  const external_init_debug_js_namespaceObject = require("./init-debug.js");
39
39
  const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-common-config.html';
40
- const getCurrentVersion = ()=>"1.12.4-beta-20260904065253.0";
40
+ const getCurrentVersion = ()=>"1.12.4";
41
41
  const getInvalidModelFamilyMessage = (modelFamily)=>`Invalid MIDSCENE_MODEL_FAMILY value: ${modelFamily}. Current version v${getCurrentVersion()} accepts the following model families: ${external_types_js_namespaceObject.MODEL_FAMILY_VALUES.join(', ')}. You can also visit ${MODEL_CONFIG_DOC_URL} for the latest configuration information.`;
42
42
  const KEYS_MAP = {
43
43
  insight: external_constants_js_namespaceObject.INSIGHT_MODEL_CONFIG_KEYS,
@@ -1,12 +1,29 @@
1
1
  import { z } from 'zod';
2
+ import { type AgentAIContexts } from './agent-context';
2
3
  export interface AgentBehaviorInitArgs {
4
+ /**
5
+ * Agent-level AI guidance. `default` is used only when neither the current
6
+ * call nor its API key provides a context. Values override rather than
7
+ * automatically merge.
8
+ */
9
+ aiContexts?: AgentAIContexts;
10
+ /**
11
+ * Compatibility alias for `aiContexts.aiAct`; that field wins when both
12
+ * exist.
13
+ * @deprecated Use `aiContexts.aiAct` instead.
14
+ */
3
15
  aiActContext?: string;
16
+ /**
17
+ * Older compatibility alias for `aiContexts.aiAct`.
18
+ * @deprecated Use `aiContexts.aiAct` instead.
19
+ */
4
20
  aiActionContext?: string;
5
21
  replanningCycleLimit?: number;
6
22
  waitAfterAction?: number;
7
23
  screenshotShrinkFactor?: number;
8
24
  }
9
25
  export declare const agentBehaviorInitArgShape: {
26
+ aiContexts: z.ZodOptional<z.ZodRecord<z.ZodEnum<["default", "aiAct", "aiTap", "aiRightClick", "aiDoubleClick", "aiHover", "aiInput", "aiKeyboardPress", "aiScroll", "aiPinch", "aiLongPress", "aiClearInput", "aiLocate", "aiQuery", "aiBoolean", "aiNumber", "aiString", "aiAsk", "aiAssert", "aiWaitFor"]>, z.ZodString>>;
10
27
  aiActContext: z.ZodOptional<z.ZodString>;
11
28
  replanningCycleLimit: z.ZodOptional<z.ZodNumber>;
12
29
  waitAfterAction: z.ZodOptional<z.ZodNumber>;
@@ -0,0 +1,18 @@
1
+ export declare const AI_API_NAMES: readonly ["aiAct", "aiTap", "aiRightClick", "aiDoubleClick", "aiHover", "aiInput", "aiKeyboardPress", "aiScroll", "aiPinch", "aiLongPress", "aiClearInput", "aiLocate", "aiQuery", "aiBoolean", "aiNumber", "aiString", "aiAsk", "aiAssert", "aiWaitFor"];
2
+ export type AiApiName = (typeof AI_API_NAMES)[number];
3
+ export declare const AGENT_AI_CONTEXT_KEYS: readonly ["default", "aiAct", "aiTap", "aiRightClick", "aiDoubleClick", "aiHover", "aiInput", "aiKeyboardPress", "aiScroll", "aiPinch", "aiLongPress", "aiClearInput", "aiLocate", "aiQuery", "aiBoolean", "aiNumber", "aiString", "aiAsk", "aiAssert", "aiWaitFor"];
4
+ export type AgentAIContextKey = (typeof AGENT_AI_CONTEXT_KEYS)[number];
5
+ /**
6
+ * Additional AI guidance configured at Agent level. Values may contain
7
+ * business facts, decision or interaction rules, constraints, and output
8
+ * requirements. An API-specific value overrides `default`; values are not
9
+ * automatically merged.
10
+ */
11
+ export type AgentAIContexts = {
12
+ /**
13
+ * Shared fallback for every AI-powered API. It is used only when neither
14
+ * the current call nor the matching API key provides a context.
15
+ */
16
+ default?: string;
17
+ } & Partial<Record<AiApiName, string | undefined>>;
18
+ export declare const isAgentAIContextKey: (value: unknown) => value is AgentAIContextKey;
@@ -1,6 +1,7 @@
1
1
  export * from './base-tools';
2
2
  export * from './tool-defaults';
3
3
  export * from './agent-behavior-init-args';
4
+ export * from './agent-context';
4
5
  export * from './init-arg-utils';
5
6
  export * from './error-formatter';
6
7
  export * from './tool-generator';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/shared",
3
- "version": "1.12.4-beta-20260904065253.0",
3
+ "version": "1.12.4",
4
4
  "repository": "https://github.com/web-infra-dev/midscene",
5
5
  "homepage": "https://midscenejs.com/",
6
6
  "types": "./dist/types/index.d.ts",
@@ -1,7 +1,27 @@
1
1
  import { z } from 'zod';
2
+ import {
3
+ AGENT_AI_CONTEXT_KEYS,
4
+ type AgentAIContexts,
5
+ isAgentAIContextKey,
6
+ } from './agent-context';
2
7
 
3
8
  export interface AgentBehaviorInitArgs {
9
+ /**
10
+ * Agent-level AI guidance. `default` is used only when neither the current
11
+ * call nor its API key provides a context. Values override rather than
12
+ * automatically merge.
13
+ */
14
+ aiContexts?: AgentAIContexts;
15
+ /**
16
+ * Compatibility alias for `aiContexts.aiAct`; that field wins when both
17
+ * exist.
18
+ * @deprecated Use `aiContexts.aiAct` instead.
19
+ */
4
20
  aiActContext?: string;
21
+ /**
22
+ * Older compatibility alias for `aiContexts.aiAct`.
23
+ * @deprecated Use `aiContexts.aiAct` instead.
24
+ */
5
25
  aiActionContext?: string;
6
26
  replanningCycleLimit?: number;
7
27
  waitAfterAction?: number;
@@ -14,11 +34,17 @@ type ExposedAgentBehaviorInitArgKey = Exclude<
14
34
  >;
15
35
 
16
36
  export const agentBehaviorInitArgShape = {
37
+ aiContexts: z
38
+ .record(z.enum(AGENT_AI_CONTEXT_KEYS), z.string())
39
+ .optional()
40
+ .describe(
41
+ 'Additional AI guidance such as business facts, rules, constraints, or output requirements. aiContexts.default is used only when neither the call nor its API key provides a context. Values override rather than automatically merge.',
42
+ ),
17
43
  aiActContext: z
18
44
  .string()
19
45
  .optional()
20
46
  .describe(
21
- 'Background knowledge passed to aiAct. Default: no extra context.',
47
+ 'Deprecated compatibility alias for aiContexts.aiAct. aiContexts.aiAct takes precedence when both are provided.',
22
48
  ),
23
49
  replanningCycleLimit: z
24
50
  .number()
@@ -51,7 +77,14 @@ export function extractAgentBehaviorInitArgs(
51
77
  return undefined;
52
78
  }
53
79
 
80
+ const aiContexts = Object.fromEntries(
81
+ Object.entries(extracted.aiContexts ?? {}).filter(
82
+ ([key, value]) => isAgentAIContextKey(key) && typeof value === 'string',
83
+ ),
84
+ ) as AgentAIContexts;
85
+
54
86
  const agentOptions: AgentBehaviorInitArgs = {
87
+ ...(Object.keys(aiContexts).length > 0 ? { aiContexts } : {}),
55
88
  ...(typeof extracted.aiActContext === 'string'
56
89
  ? { aiActContext: extracted.aiActContext }
57
90
  : {}),
@@ -0,0 +1,47 @@
1
+ export const AI_API_NAMES = [
2
+ 'aiAct',
3
+ 'aiTap',
4
+ 'aiRightClick',
5
+ 'aiDoubleClick',
6
+ 'aiHover',
7
+ 'aiInput',
8
+ 'aiKeyboardPress',
9
+ 'aiScroll',
10
+ 'aiPinch',
11
+ 'aiLongPress',
12
+ 'aiClearInput',
13
+ 'aiLocate',
14
+ 'aiQuery',
15
+ 'aiBoolean',
16
+ 'aiNumber',
17
+ 'aiString',
18
+ 'aiAsk',
19
+ 'aiAssert',
20
+ 'aiWaitFor',
21
+ ] as const;
22
+
23
+ export type AiApiName = (typeof AI_API_NAMES)[number];
24
+
25
+ export const AGENT_AI_CONTEXT_KEYS = ['default', ...AI_API_NAMES] as const;
26
+
27
+ export type AgentAIContextKey = (typeof AGENT_AI_CONTEXT_KEYS)[number];
28
+
29
+ /**
30
+ * Additional AI guidance configured at Agent level. Values may contain
31
+ * business facts, decision or interaction rules, constraints, and output
32
+ * requirements. An API-specific value overrides `default`; values are not
33
+ * automatically merged.
34
+ */
35
+ export type AgentAIContexts = {
36
+ /**
37
+ * Shared fallback for every AI-powered API. It is used only when neither
38
+ * the current call nor the matching API key provides a context.
39
+ */
40
+ default?: string;
41
+ } & Partial<Record<AiApiName, string | undefined>>;
42
+
43
+ export const isAgentAIContextKey = (
44
+ value: unknown,
45
+ ): value is AgentAIContextKey =>
46
+ typeof value === 'string' &&
47
+ (AGENT_AI_CONTEXT_KEYS as readonly string[]).includes(value);
@@ -1,6 +1,7 @@
1
1
  export * from './base-tools';
2
2
  export * from './tool-defaults';
3
3
  export * from './agent-behavior-init-args';
4
+ export * from './agent-context';
4
5
  export * from './init-arg-utils';
5
6
  export * from './error-formatter';
6
7
  export * from './tool-generator';