@takeshape/schema 11.88.4 → 11.89.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.
@@ -1854,6 +1854,7 @@ export interface AgentAIStateInputTemplate {
1854
1854
  inputTemplate: string;
1855
1855
  }
1856
1856
  export interface AgentToolConfig {
1857
+ name: string;
1857
1858
  ref: string;
1858
1859
  description?: string;
1859
1860
  args?: AgentToolConfigArg[];
@@ -1993,6 +1994,7 @@ export interface ToolMap {
1993
1994
  * via the `patternProperty` "^[0-9A-Za-z_]+$".
1994
1995
  */
1995
1996
  export interface ToolJSON {
1997
+ name: string;
1996
1998
  ref: string;
1997
1999
  description?: string;
1998
2000
  args?: ToolArg[];
@@ -1702,6 +1702,7 @@ export interface AgentAIStateInputTemplateV3_48_0 {
1702
1702
  inputTemplate: string;
1703
1703
  }
1704
1704
  export interface AgentToolConfigV3_48_0 {
1705
+ name: string;
1705
1706
  ref: string;
1706
1707
  description?: string;
1707
1708
  args?: AgentToolConfigArgV3_48_0[];
@@ -1841,6 +1842,7 @@ export interface ToolMapV3_48_0 {
1841
1842
  * via the `patternProperty` "^[0-9A-Za-z_]+$".
1842
1843
  */
1843
1844
  export interface ToolJSONV3_48_0 {
1845
+ name: string;
1844
1846
  ref: string;
1845
1847
  description?: string;
1846
1848
  args?: ToolArgV3_48_0[];
@@ -1702,6 +1702,7 @@ export interface AgentAIStateInputTemplateV3_49_0 {
1702
1702
  inputTemplate: string;
1703
1703
  }
1704
1704
  export interface AgentToolConfigV3_49_0 {
1705
+ name: string;
1705
1706
  ref: string;
1706
1707
  description?: string;
1707
1708
  args?: AgentToolConfigArgV3_49_0[];
@@ -1841,6 +1842,7 @@ export interface ToolMapV3_49_0 {
1841
1842
  * via the `patternProperty` "^[0-9A-Za-z_]+$".
1842
1843
  */
1843
1844
  export interface ToolJSONV3_49_0 {
1845
+ name: string;
1844
1846
  ref: string;
1845
1847
  description?: string;
1846
1848
  args?: ToolArgV3_49_0[];
@@ -1754,6 +1754,7 @@ export interface AgentAIStateInputTemplateV3_50_0 {
1754
1754
  inputTemplate: string;
1755
1755
  }
1756
1756
  export interface AgentToolConfigV3_50_0 {
1757
+ name: string;
1757
1758
  ref: string;
1758
1759
  description?: string;
1759
1760
  args?: AgentToolConfigArgV3_50_0[];
@@ -1893,6 +1894,7 @@ export interface ToolMapV3_50_0 {
1893
1894
  * via the `patternProperty` "^[0-9A-Za-z_]+$".
1894
1895
  */
1895
1896
  export interface ToolJSONV3_50_0 {
1897
+ name: string;
1896
1898
  ref: string;
1897
1899
  description?: string;
1898
1900
  args?: ToolArgV3_50_0[];
@@ -1754,6 +1754,7 @@ export interface AgentAIStateInputTemplateV3_51_0 {
1754
1754
  inputTemplate: string;
1755
1755
  }
1756
1756
  export interface AgentToolConfigV3_51_0 {
1757
+ name: string;
1757
1758
  ref: string;
1758
1759
  description?: string;
1759
1760
  args?: AgentToolConfigArgV3_51_0[];
@@ -1893,6 +1894,7 @@ export interface ToolMapV3_51_0 {
1893
1894
  * via the `patternProperty` "^[0-9A-Za-z_]+$".
1894
1895
  */
1895
1896
  export interface ToolJSONV3_51_0 {
1897
+ name: string;
1896
1898
  ref: string;
1897
1899
  description?: string;
1898
1900
  args?: ToolArgV3_51_0[];
@@ -1754,6 +1754,7 @@ export interface AgentAIStateInputTemplateV3_52_0 {
1754
1754
  inputTemplate: string;
1755
1755
  }
1756
1756
  export interface AgentToolConfigV3_52_0 {
1757
+ name: string;
1757
1758
  ref: string;
1758
1759
  description?: string;
1759
1760
  args?: AgentToolConfigArgV3_52_0[];
@@ -1893,6 +1894,7 @@ export interface ToolMapV3_52_0 {
1893
1894
  * via the `patternProperty` "^[0-9A-Za-z_]+$".
1894
1895
  */
1895
1896
  export interface ToolJSONV3_52_0 {
1897
+ name: string;
1896
1898
  ref: string;
1897
1899
  description?: string;
1898
1900
  args?: ToolArgV3_52_0[];
@@ -1835,6 +1835,7 @@ export interface AgentAIStateInputTemplateV3_53_0 {
1835
1835
  inputTemplate: string;
1836
1836
  }
1837
1837
  export interface AgentToolConfigV3_53_0 {
1838
+ name: string;
1838
1839
  ref: string;
1839
1840
  description?: string;
1840
1841
  args?: AgentToolConfigArgV3_53_0[];
@@ -1974,6 +1975,7 @@ export interface ToolMapV3_53_0 {
1974
1975
  * via the `patternProperty` "^[0-9A-Za-z_]+$".
1975
1976
  */
1976
1977
  export interface ToolJSONV3_53_0 {
1978
+ name: string;
1977
1979
  ref: string;
1978
1980
  description?: string;
1979
1981
  args?: ToolArgV3_53_0[];
@@ -1854,6 +1854,7 @@ export interface AgentAIStateInputTemplateV3_54_0 {
1854
1854
  inputTemplate: string;
1855
1855
  }
1856
1856
  export interface AgentToolConfigV3_54_0 {
1857
+ name: string;
1857
1858
  ref: string;
1858
1859
  description?: string;
1859
1860
  args?: AgentToolConfigArgV3_54_0[];
@@ -1993,6 +1994,7 @@ export interface ToolMapV3_54_0 {
1993
1994
  * via the `patternProperty` "^[0-9A-Za-z_]+$".
1994
1995
  */
1995
1996
  export interface ToolJSONV3_54_0 {
1997
+ name: string;
1996
1998
  ref: string;
1997
1999
  description?: string;
1998
2000
  args?: ToolArgV3_54_0[];
@@ -1854,6 +1854,7 @@ export interface AgentAIStateInputTemplateV3_55_0 {
1854
1854
  inputTemplate: string;
1855
1855
  }
1856
1856
  export interface AgentToolConfigV3_55_0 {
1857
+ name: string;
1857
1858
  ref: string;
1858
1859
  description?: string;
1859
1860
  args?: AgentToolConfigArgV3_55_0[];
@@ -1993,6 +1994,7 @@ export interface ToolMapV3_55_0 {
1993
1994
  * via the `patternProperty` "^[0-9A-Za-z_]+$".
1994
1995
  */
1995
1996
  export interface ToolJSONV3_55_0 {
1997
+ name: string;
1996
1998
  ref: string;
1997
1999
  description?: string;
1998
2000
  args?: ToolArgV3_55_0[];
package/dist/refs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type Maybe } from '@takeshape/util';
2
- import type { Args, ObjectSchema, ProjectSchemaJSON, PropertySchema, QueryJSON, Ref, ReturnShape, ShapeJSON, ShapeSchema } from './project-schema/index.ts';
2
+ import type { AIToolConfig, Args, ObjectSchema, ProjectSchemaJSON, PropertySchema, QueryJSON, Ref, ReturnShape, ShapeJSON, ShapeSchema } from './project-schema/index.ts';
3
3
  import type { SchemaPath, SchemaWithRef } from './types/index.ts';
4
4
  export type ServicesContext = Pick<ProjectSchemaJSON, 'services'>;
5
5
  export type ServicesShapesContext = Pick<ProjectSchemaJSON, 'services' | 'shapes'>;
@@ -235,3 +235,4 @@ export declare function getReferencedShape(projectSchema: ProjectSchemaJSON, ref
235
235
  * Get a PropertySchema from a RefItem.
236
236
  */
237
237
  export declare function getReferencedShapeProperty(projectSchema: ProjectSchemaJSON, refItem: PropertyRefItem, namespace?: string): PropertySchema | undefined;
238
+ export declare function getToolRef(tool: Pick<AIToolConfig, 'ref'> | string): string;
package/dist/refs.js CHANGED
@@ -8,7 +8,6 @@ import isString from 'lodash/isString.js';
8
8
  import { isScalar } from "./scalars.js";
9
9
  import { getServiceNamespaces } from "./services/util.js";
10
10
  import { getRefType, isAllOfSchema, isExtendsSchema, isObjectSchema, isOneOfSchema, isRefSchema, isRefSchemaLegacy } from "./types/index.js";
11
- import { getToolRef } from "./util/ai-tools.js";
12
11
  import { mergeDeepObjectSchemas, mergeObjectSchemas } from "./util/merge.js";
13
12
  import { getShape } from "./util/shapes.js";
14
13
  /**
@@ -637,3 +636,6 @@ export function getReferencedShapeProperty(projectSchema, refItem, namespace) {
637
636
  return shape.schema.properties[refItem.propertyName];
638
637
  }
639
638
  }
639
+ export function getToolRef(tool) {
640
+ return typeof tool === 'string' ? tool : tool.ref;
641
+ }
@@ -39,6 +39,9 @@
39
39
  "title": "Tool JSON",
40
40
  "type": "object",
41
41
  "properties": {
42
+ "name": {
43
+ "type": "string"
44
+ },
42
45
  "ref": {
43
46
  "type": "string"
44
47
  },
@@ -55,7 +58,7 @@
55
58
  "type": "string"
56
59
  }
57
60
  },
58
- "required": ["ref"],
61
+ "required": ["name", "ref"],
59
62
  "additionalProperties": false
60
63
  },
61
64
  "toolArg": {
@@ -527,6 +530,9 @@
527
530
  "title": "AgentToolConfig",
528
531
  "type": "object",
529
532
  "properties": {
533
+ "name": {
534
+ "type": "string"
535
+ },
530
536
  "ref": {
531
537
  "type": "string"
532
538
  },
@@ -543,7 +549,7 @@
543
549
  "type": "string"
544
550
  }
545
551
  },
546
- "required": ["ref"],
552
+ "required": ["name", "ref"],
547
553
  "additionalProperties": false
548
554
  },
549
555
  "agentToolConfigArg": {
@@ -1,3 +1,2 @@
1
- import type { AgentToolConfig, AIToolConfig } from '../project-schema/latest.ts';
2
- export declare function getToolRef(tool: Pick<AIToolConfig, 'ref'> | string): string;
3
- export declare function normalizeToolConfig(tool: AIToolConfig | AgentToolConfig | string): AIToolConfig | AgentToolConfig;
1
+ import type { AgentToolConfig, AIToolConfig, ToolJSON } from '../project-schema/index.ts';
2
+ export declare function normalizeToolConfig(tool: AIToolConfig | AgentToolConfig | ToolJSON | string): AgentToolConfig;
@@ -1,6 +1,14 @@
1
- export function getToolRef(tool) {
2
- return typeof tool === 'string' ? tool : tool.ref;
3
- }
1
+ import { parsePropertyRef } from "../refs.js";
4
2
  export function normalizeToolConfig(tool) {
5
- return typeof tool === 'string' ? { ref: tool } : tool;
3
+ if (typeof tool === 'string') {
4
+ return {
5
+ name: parsePropertyRef(tool)?.propertyName ?? tool,
6
+ ref: tool
7
+ };
8
+ }
9
+ const name = 'name' in tool ? tool.name : (parsePropertyRef(tool.ref)?.propertyName ?? tool.ref);
10
+ return {
11
+ name,
12
+ ...tool
13
+ };
6
14
  }
@@ -19,7 +19,7 @@ import neq from 'semver/functions/neq.js';
19
19
  import { builtInShapes } from "../builtin-schema.js";
20
20
  import { isEnumLikeSchema } from "../enum.js";
21
21
  import { isLatestProjectSchemaJSON } from "../project-schema/index.js";
22
- import { atRefToRefItem, createGetNamespace, getRefShapeName, parsePropertyRef, propertyRefItemToPath, propertyRefItemToResolverPath, refItemToAtRef, refItemToNamespacedShapeName, refItemToShape } from "../refs.js";
22
+ import { atRefToRefItem, createGetNamespace, getRefShapeName, getToolRef, parsePropertyRef, propertyRefItemToPath, propertyRefItemToResolverPath, refItemToAtRef, refItemToNamespacedShapeName, refItemToShape } from "../refs.js";
23
23
  import { getRelationship } from "../relationships.js";
24
24
  import { scalars } from "../scalars.js";
25
25
  import { getAllRefs, isBuiltinMutation, isBuiltinQuery } from "../schema-util.js";
@@ -29,7 +29,6 @@ import { isValidTemplate } from "../template-shapes/index.js";
29
29
  import { legacyProjectSchemaImportOptionalProps, projectSchemaImportOptionalProps } from "../types/types.js";
30
30
  import { isAIResolver, isBasicResolver, isComposeResolver, isExtendsSchema, isObjectSchema } from "../types/utils.js";
31
31
  import { isUnionSchema } from "../unions.js";
32
- import { getToolRef } from "../util/ai-tools.js";
33
32
  import { validateExpression } from "../util/expressions.js";
34
33
  import { getShape } from "../util/shapes.js";
35
34
  import { CURRENT_SCHEMA_VERSION, LEGACY_API_VERSION, LEGACY_SCHEMA_VERSION } from "../versions.js";
@@ -74,6 +73,15 @@ function checkShapeNames(shapes) {
74
73
  message: `Shape.name "${shape.name}" must match key "${name}".`
75
74
  }));
76
75
  }
76
+ function checkToolNames(tools) {
77
+ return Object.entries(tools)
78
+ .filter(([name, tool]) => name !== tool.name)
79
+ .map(([name, tool]) => ({
80
+ path: ['ai-experimental', 'tools', name, 'name'],
81
+ type: 'conflict',
82
+ message: `Tool.name "${tool.name}" must match key "${name}".`
83
+ }));
84
+ }
77
85
  function checkWorkflowStepNames(workflows) {
78
86
  return Object.entries(workflows).flatMap(([name, workflow]) => {
79
87
  const items = workflow.steps.map((step, i) => ({
@@ -1018,6 +1026,9 @@ function validateSyntax(context, schema) {
1018
1026
  .concat(validateInterfaceImplementations(schema))
1019
1027
  .concat(validateAgents(schema))
1020
1028
  .concat(validateGuards(context, schema));
1029
+ if (schema['ai-experimental']?.tools) {
1030
+ errors = errors.concat(checkToolNames(schema['ai-experimental']?.tools ?? {}));
1031
+ }
1021
1032
  return formatValidationResult(context, errors, schema);
1022
1033
  }
1023
1034
  async function validateReferences(context, schema) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeshape/schema",
3
- "version": "11.88.4",
3
+ "version": "11.89.0",
4
4
  "description": "TakeShape Schema",
5
5
  "homepage": "https://www.takeshape.io",
6
6
  "repository": {
@@ -57,9 +57,9 @@
57
57
  "p-reduce": "^2.1.0",
58
58
  "semver": "^7.3.2",
59
59
  "tiny-invariant": "^1.2.0",
60
- "@takeshape/errors": "11.88.4",
61
- "@takeshape/json-schema": "11.88.4",
62
- "@takeshape/util": "11.88.4"
60
+ "@takeshape/errors": "11.89.0",
61
+ "@takeshape/json-schema": "11.89.0",
62
+ "@takeshape/util": "11.89.0"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@takeshape/json-schema-to-typescript": "^11.0.0",
@@ -76,7 +76,7 @@
76
76
  "json-schema-to-ts": "^3.1.1",
77
77
  "meow": "^9.0.0",
78
78
  "shortid": "^2.2.15",
79
- "@takeshape/infra": "11.88.4"
79
+ "@takeshape/infra": "11.89.0"
80
80
  },
81
81
  "engines": {
82
82
  "node": ">=20"