@trackunit/iris-app-api 2.13.7-alpha-1872e1df7fb.0 → 2.13.8

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,3 +1,63 @@
1
+ ## 2.13.8 (2026-11-05)
2
+
3
+ This was a version bump only for iris-app-api to align it with other projects, there were no code changes.
4
+
5
+ ## 2.13.7 (2026-11-05)
6
+
7
+ This was a version bump only for iris-app-api to align it with other projects, there were no code changes.
8
+
9
+ ## 2.13.6 (2026-11-04)
10
+
11
+ This was a version bump only for iris-app-api to align it with other projects, there were no code changes.
12
+
13
+ ## 2.13.5 (2026-11-04)
14
+
15
+ This was a version bump only for iris-app-api to align it with other projects, there were no code changes.
16
+
17
+ ## 2.13.4 (2026-11-04)
18
+
19
+ This was a version bump only for iris-app-api to align it with other projects, there were no code changes.
20
+
21
+ ## 2.13.3 (2026-11-04)
22
+
23
+ ### 🚀 Features
24
+
25
+ - **iris-app-sdk:** guide apps to lazy pages for AI navigation and follow getParentRoute ([#27279](https://github.com/Trackunit/manager/pull/27279))
26
+
27
+ ### ❤️ Thank You
28
+
29
+ - Kasper Laursen @ghost-of-kla-trackunit
30
+
31
+ ## 2.13.2 (2026-11-04)
32
+
33
+ This was a version bump only for iris-app-api to align it with other projects, there were no code changes.
34
+
35
+ ## 2.13.1 (2026-11-03)
36
+
37
+ This was a version bump only for iris-app-api to align it with other projects, there were no code changes.
38
+
39
+ ## 2.13.0 (2026-11-03)
40
+
41
+ ### 🚀 Features
42
+
43
+ - **iris-app-api:** add organization.manage scope to vocabulary ([e87a78198c6](https://github.com/Trackunit/manager/commit/e87a78198c6))
44
+
45
+ ### ❤️ Thank You
46
+
47
+ - fhg @FemkeTrackunit
48
+
49
+ ## 2.12.28 (2026-11-03)
50
+
51
+ This was a version bump only for iris-app-api to align it with other projects, there were no code changes.
52
+
53
+ ## 2.12.27 (2026-11-03)
54
+
55
+ This was a version bump only for iris-app-api to align it with other projects, there were no code changes.
56
+
57
+ ## 2.12.26 (2026-11-03)
58
+
59
+ This was a version bump only for iris-app-api to align it with other projects, there were no code changes.
60
+
1
61
  ## 2.12.25 (2026-11-02)
2
62
 
3
63
  This was a version bump only for iris-app-api to align it with other projects, there were no code changes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/iris-app-api",
3
- "version": "2.13.7-alpha-1872e1df7fb.0",
3
+ "version": "2.13.8",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "repository": "https://github.com/Trackunit/manager",
6
6
  "engines": {
package/src/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from "./types/aiNavigableExtension";
2
2
  export * from "./types/defaultValidHosts";
3
3
  export * from "./types/extensions/adminExtensionManifest";
4
- export * from "./types/extensions/aiToolsExtensionManifest";
5
4
  export * from "./types/extensions/assetEventsActionsExtensionManifest";
6
5
  export * from "./types/extensions/assetHomeExtensionManifest";
7
6
  export * from "./types/extensions/customerHomeExtensionManifest";
@@ -18,8 +17,6 @@ export * from "./types/iconImage";
18
17
  export * from "./types/icons.generated";
19
18
  export * from "./types/irisAiNavigation";
20
19
  export * from "./types/irisAiNavigationValidation";
21
- export * from "./types/irisAiTools";
22
- export * from "./types/irisAiToolsValidation";
23
20
  export * from "./types/irisAppCspInput";
24
21
  export * from "./types/irisAppCustomFields";
25
22
  export * from "./types/irisAppExtensionManifest";
package/src/index.js CHANGED
@@ -4,7 +4,6 @@ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./types/aiNavigableExtension"), exports);
5
5
  tslib_1.__exportStar(require("./types/defaultValidHosts"), exports);
6
6
  tslib_1.__exportStar(require("./types/extensions/adminExtensionManifest"), exports);
7
- tslib_1.__exportStar(require("./types/extensions/aiToolsExtensionManifest"), exports);
8
7
  tslib_1.__exportStar(require("./types/extensions/assetEventsActionsExtensionManifest"), exports);
9
8
  tslib_1.__exportStar(require("./types/extensions/assetHomeExtensionManifest"), exports);
10
9
  tslib_1.__exportStar(require("./types/extensions/customerHomeExtensionManifest"), exports);
@@ -21,8 +20,6 @@ tslib_1.__exportStar(require("./types/iconImage"), exports);
21
20
  tslib_1.__exportStar(require("./types/icons.generated"), exports);
22
21
  tslib_1.__exportStar(require("./types/irisAiNavigation"), exports);
23
22
  tslib_1.__exportStar(require("./types/irisAiNavigationValidation"), exports);
24
- tslib_1.__exportStar(require("./types/irisAiTools"), exports);
25
- tslib_1.__exportStar(require("./types/irisAiToolsValidation"), exports);
26
23
  tslib_1.__exportStar(require("./types/irisAppCspInput"), exports);
27
24
  tslib_1.__exportStar(require("./types/irisAppCustomFields"), exports);
28
25
  tslib_1.__exportStar(require("./types/irisAppExtensionManifest"), exports);
@@ -9,6 +9,7 @@ import type { IrisAiNavigationRouteMetadata, IrisExtensionAiNavigation } from ".
9
9
  type TanstackRouteLike = {
10
10
  readonly options?: {
11
11
  readonly path?: string;
12
+ readonly getParentRoute?: () => unknown;
12
13
  readonly staticData?: {
13
14
  readonly aiNavigation?: IrisAiNavigationRouteMetadata;
14
15
  };
@@ -23,9 +24,31 @@ type TanstackRouteLike = {
23
24
  * Pass the `routeTree` itself rather than a router: the tree is inert, so no
24
25
  * router (and no browser environment) has to exist for this to run.
25
26
  *
27
+ * Load pages lazily. The manifest imports the route tree in Node at build
28
+ * time, so every page the tree imports directly runs there too, and a page
29
+ * that needs a browser fails the build. With lazy pages, only the route
30
+ * definitions run:
31
+ *
32
+ * ```tsx
33
+ * import { createRoute, lazyRouteComponent } from "@tanstack/react-router";
34
+ *
35
+ * const assetsRoute = createRoute({
36
+ * getParentRoute: () => rootRoute,
37
+ * path: "assets",
38
+ * // Before: `component: AssetsPage`, with AssetsPage imported at the top.
39
+ * component: lazyRouteComponent(() => import("./AssetsPage"), "AssetsPage"),
40
+ * staticData: { aiNavigation: { title: "Assets", description: "All assets." } },
41
+ * });
42
+ * ```
43
+ *
44
+ * The same goes for `errorComponent`, `pendingComponent` and
45
+ * `notFoundComponent`. Tanstack's `.lazy()` with `createLazyRoute` works too.
46
+ *
26
47
  * The manifest field is router-agnostic, so a `...FromReactRouter` counterpart
27
48
  * can be added alongside this without touching the manifest types.
28
49
  *
50
+ * @example
51
+ * aiNavigation: extractAiNavigationFromTanstackRouter(routeTree),
29
52
  * @param routeTree - The app's Tanstack route tree.
30
53
  * @returns {IrisExtensionAiNavigation} The AI navigation catalog for an extension manifest.
31
54
  */
@@ -5,6 +5,7 @@ const cleanPath = (path) => path.replace(/\/{2,}/g, "/");
5
5
  const trimPathLeft = (path) => (path === "/" ? path : path.replace(/^\/+/, ""));
6
6
  const joinPaths = (paths) => cleanPath(paths.filter((path) => path !== undefined).join("/"));
7
7
  const withoutTrailingSlash = (path) => (path !== "/" && path.endsWith("/") ? path.slice(0, -1) : path);
8
+ const isRouteLike = (value) => value !== null && typeof value === "object";
8
9
  const isRouteList = (children) => Array.isArray(children);
9
10
  const isRouteRecord = (children) => children !== null && typeof children === "object";
10
11
  const toChildRoutes = (children) => {
@@ -15,27 +16,34 @@ const toChildRoutes = (children) => {
15
16
  };
16
17
  /**
17
18
  * Mirrors how Tanstack Router derives `fullPath` in `BaseRoute.init`, so paths
18
- * match the running router without constructing one: a pathless layout route
19
- * (declared with `id` instead of `path`) contributes nothing to the path, and a
20
- * child `path` is joined onto the parent with duplicate slashes collapsed.
19
+ * match the running router without constructing one. The parent is the route
20
+ * `getParentRoute` returns, not the one whose `addChildren` lists the route: a
21
+ * tree may list nested routes flat under the root. Only the root has no
22
+ * parent. A pathless layout route (declared with `id` instead of `path`)
23
+ * contributes nothing to the path, and a child `path` is joined onto the
24
+ * parent with duplicate slashes collapsed.
21
25
  */
22
- const routeFullPath = ({ route, parentFullPath, }) => {
26
+ const fullPathOf = (route) => {
27
+ const parentRoute = route.options?.getParentRoute?.();
28
+ if (!isRouteLike(parentRoute)) {
29
+ return "/";
30
+ }
23
31
  const declaredPath = route.options?.path;
24
32
  const path = declaredPath !== undefined && declaredPath !== "/" ? trimPathLeft(declaredPath) : declaredPath;
25
- return joinPaths([parentFullPath, path]);
33
+ return joinPaths([fullPathOf(parentRoute), path]);
26
34
  };
27
- const collectRoutes = ({ route, fullPath, collected, }) => {
35
+ const collectRoutes = (route, collected) => {
28
36
  const aiNavigation = route.options?.staticData?.aiNavigation;
29
37
  if (aiNavigation !== undefined) {
30
38
  collected.push({
31
- path: withoutTrailingSlash(fullPath),
39
+ path: withoutTrailingSlash(fullPathOf(route)),
32
40
  title: aiNavigation.title,
33
41
  description: aiNavigation.description,
34
42
  ...(aiNavigation.params ? { params: aiNavigation.params } : {}),
35
43
  ...(aiNavigation.search ? { search: aiNavigation.search } : {}),
36
44
  });
37
45
  }
38
- toChildRoutes(route.children).forEach(child => collectRoutes({ route: child, fullPath: routeFullPath({ route: child, parentFullPath: fullPath }), collected }));
46
+ toChildRoutes(route.children).forEach(child => collectRoutes(child, collected));
39
47
  };
40
48
  /**
41
49
  * Harvests `staticData.aiNavigation` from a Tanstack `routeTree` into the plain
@@ -45,15 +53,37 @@ const collectRoutes = ({ route, fullPath, collected, }) => {
45
53
  * Pass the `routeTree` itself rather than a router: the tree is inert, so no
46
54
  * router (and no browser environment) has to exist for this to run.
47
55
  *
56
+ * Load pages lazily. The manifest imports the route tree in Node at build
57
+ * time, so every page the tree imports directly runs there too, and a page
58
+ * that needs a browser fails the build. With lazy pages, only the route
59
+ * definitions run:
60
+ *
61
+ * ```tsx
62
+ * import { createRoute, lazyRouteComponent } from "@tanstack/react-router";
63
+ *
64
+ * const assetsRoute = createRoute({
65
+ * getParentRoute: () => rootRoute,
66
+ * path: "assets",
67
+ * // Before: `component: AssetsPage`, with AssetsPage imported at the top.
68
+ * component: lazyRouteComponent(() => import("./AssetsPage"), "AssetsPage"),
69
+ * staticData: { aiNavigation: { title: "Assets", description: "All assets." } },
70
+ * });
71
+ * ```
72
+ *
73
+ * The same goes for `errorComponent`, `pendingComponent` and
74
+ * `notFoundComponent`. Tanstack's `.lazy()` with `createLazyRoute` works too.
75
+ *
48
76
  * The manifest field is router-agnostic, so a `...FromReactRouter` counterpart
49
77
  * can be added alongside this without touching the manifest types.
50
78
  *
79
+ * @example
80
+ * aiNavigation: extractAiNavigationFromTanstackRouter(routeTree),
51
81
  * @param routeTree - The app's Tanstack route tree.
52
82
  * @returns {IrisExtensionAiNavigation} The AI navigation catalog for an extension manifest.
53
83
  */
54
84
  const extractAiNavigationFromTanstackRouter = (routeTree) => {
55
85
  const collected = [];
56
- collectRoutes({ route: routeTree, fullPath: "/", collected });
86
+ collectRoutes(routeTree, collected);
57
87
  return { routes: collected };
58
88
  };
59
89
  exports.extractAiNavigationFromTanstackRouter = extractAiNavigationFromTanstackRouter;
@@ -1,4 +1,4 @@
1
- export declare const irisAppExtensionTypes: readonly ["REPORT_EXTENSION", "IRIS_APP_SETTINGS_EXTENSION", "ADMIN_EXTENSION", "FLEET_EXTENSION", "WIDGET_EXTENSION", "ASSET_HOME_EXTENSION", "ASSET_EVENTS_ACTIONS_EXTENSION", "CUSTOMER_HOME_EXTENSION", "SITE_HOME_EXTENSION", "LIFECYCLE_EXTENSION", "SERVERSIDE_API_EXTENSION", "AI_TOOLS_EXTENSION"];
1
+ export declare const irisAppExtensionTypes: readonly ["REPORT_EXTENSION", "IRIS_APP_SETTINGS_EXTENSION", "ADMIN_EXTENSION", "FLEET_EXTENSION", "WIDGET_EXTENSION", "ASSET_HOME_EXTENSION", "ASSET_EVENTS_ACTIONS_EXTENSION", "CUSTOMER_HOME_EXTENSION", "SITE_HOME_EXTENSION", "LIFECYCLE_EXTENSION", "SERVERSIDE_API_EXTENSION"];
2
2
  export type IrisAppExtensionType = (typeof irisAppExtensionTypes)[number];
3
3
  export declare const nonUiExtensionTypes: Array<IrisAppExtensionType>;
4
4
  export declare const serverSideExtensionTypes: Array<IrisAppExtensionType>;
@@ -13,18 +13,15 @@ exports.irisAppExtensionTypes = [
13
13
  "SITE_HOME_EXTENSION",
14
14
  "LIFECYCLE_EXTENSION",
15
15
  "SERVERSIDE_API_EXTENSION",
16
- "AI_TOOLS_EXTENSION",
17
16
  ];
18
17
  exports.nonUiExtensionTypes = [
19
18
  "REPORT_EXTENSION",
20
19
  "LIFECYCLE_EXTENSION",
21
20
  "SERVERSIDE_API_EXTENSION",
22
- "AI_TOOLS_EXTENSION",
23
21
  ];
24
22
  exports.serverSideExtensionTypes = [
25
23
  "LIFECYCLE_EXTENSION",
26
24
  "SERVERSIDE_API_EXTENSION",
27
- "AI_TOOLS_EXTENSION",
28
25
  ];
29
26
  exports.languageKeys = [
30
27
  "en",
@@ -1,5 +1,4 @@
1
1
  import { CSPDirectives } from "./cspDirectives";
2
- import { AiToolsExtensionManifest } from "./extensions/aiToolsExtensionManifest";
3
2
  import { AdminExtensionManifest } from "./extensions/adminExtensionManifest";
4
3
  import { AssetEventsActionsExtensionManifest } from "./extensions/assetEventsActionsExtensionManifest";
5
4
  import { AssetHomeExtensionManifest } from "./extensions/assetHomeExtensionManifest";
@@ -92,7 +91,7 @@ export type RequiredOrOptionalScope = {
92
91
  scope: Scope;
93
92
  optional?: boolean;
94
93
  };
95
- export declare type IrisAppExtension = AssetHomeExtensionManifest | IrisAppSettingsExtensionManifest | AdminExtensionManifest | FleetExtensionManifest | SiteHomeExtensionManifest | WidgetExtensionManifest | ReportExtensionManifest | CustomerHomeExtensionManifest | AssetEventsActionsExtensionManifest | LifecycleExtensionManifest | ServersideApiExtensionManifest | AiToolsExtensionManifest;
94
+ export declare type IrisAppExtension = AssetHomeExtensionManifest | IrisAppSettingsExtensionManifest | AdminExtensionManifest | FleetExtensionManifest | SiteHomeExtensionManifest | WidgetExtensionManifest | ReportExtensionManifest | CustomerHomeExtensionManifest | AssetEventsActionsExtensionManifest | LifecycleExtensionManifest | ServersideApiExtensionManifest;
96
95
  export declare type CustomFieldDefinition = BooleanFieldDefinition | DecimalNumberFieldDefinition | IntegerNumberFieldDefinition | DateFieldDefinition | DropDownFieldDefinition | StringFieldDefinition | StringListFieldDefinition | EmailFieldDefinition | PhoneNumberFieldDefinition | WebAddressFieldDefinition | JsonFieldDefinition | MonetaryFieldDefinition | FileFieldDefinition;
97
96
  /**
98
97
  * @deprecated
@@ -62,6 +62,7 @@ export declare const accountScope: {
62
62
  readonly CONNECTION_VIEW: "connection.view";
63
63
  readonly CONNECTION_MANAGE: "connection.manage";
64
64
  readonly ORGANIZATION_VIEW: "organization.view";
65
+ readonly ORGANIZATION_MANAGE: "organization.manage";
65
66
  readonly SSO_VIEW: "sso.view";
66
67
  readonly SSO_MANAGE: "sso.manage";
67
68
  };
@@ -141,6 +142,7 @@ export declare const allScopes: {
141
142
  CONNECTION_VIEW: "connection.view";
142
143
  CONNECTION_MANAGE: "connection.manage";
143
144
  ORGANIZATION_VIEW: "organization.view";
145
+ ORGANIZATION_MANAGE: "organization.manage";
144
146
  SSO_VIEW: "sso.view";
145
147
  SSO_MANAGE: "sso.manage";
146
148
  };
@@ -84,6 +84,7 @@ exports.accountScope = {
84
84
  CONNECTION_VIEW: "connection.view",
85
85
  CONNECTION_MANAGE: "connection.manage",
86
86
  ORGANIZATION_VIEW: "organization.view",
87
+ ORGANIZATION_MANAGE: "organization.manage",
87
88
  SSO_VIEW: "sso.view",
88
89
  SSO_MANAGE: "sso.manage",
89
90
  };
@@ -1,17 +0,0 @@
1
- import { IrisExtensionAiTools } from "../irisAiTools";
2
- import { AbstractExtensionManifest } from "../irisAppExtensionManifest";
3
- /**
4
- * Serves the app's AI tools on `POST /mcp`, built with `@trackunit/serverside-ai-tools`.
5
- * When the app version is approved, the platform makes the tools available to AI clients
6
- * for accounts that have the app. At most one per app.
7
- */
8
- export interface AiToolsExtensionManifest extends AbstractExtensionManifest {
9
- type: "AI_TOOLS_EXTENSION";
10
- runtime: "DENO";
11
- id: string;
12
- name: string;
13
- description?: string;
14
- main: `${string}.ts` | `${string}.js`;
15
- dependencyDefinitionFile: string;
16
- aiTools: IrisExtensionAiTools;
17
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=aiToolsExtensionManifest.js.map
@@ -1,32 +0,0 @@
1
- /**
2
- * MCP tool annotation hints. All four are required so the AI assistant never
3
- * has to guess whether a tool writes, overwrites, can be retried or leaves
4
- * Trackunit. A tool with `readOnlyHint: false` is shown to the user for approval.
5
- */
6
- export type IrisAiToolAnnotations = {
7
- readonly readOnlyHint: boolean;
8
- readonly destructiveHint: boolean;
9
- readonly idempotentHint: boolean;
10
- readonly openWorldHint: boolean;
11
- };
12
- /** A JSON Schema with `type: "object"`, as MCP requires for tool input and output. */
13
- export type IrisAiToolJsonSchema = Readonly<Record<string, unknown>> & {
14
- readonly type: "object";
15
- };
16
- export type IrisAiTool = {
17
- /** `verb_noun` in snake_case, e.g. `update_fault_priorities`. */
18
- readonly name: string;
19
- readonly title: string;
20
- readonly description: string;
21
- readonly inputSchema: IrisAiToolJsonSchema;
22
- readonly outputSchema?: IrisAiToolJsonSchema;
23
- readonly annotations: IrisAiToolAnnotations;
24
- };
25
- export type IrisExtensionAiTools = {
26
- /**
27
- * Kebab-case prefix of the tool names AI clients see (`<namespace>_<tool>`).
28
- * Must not be reserved or used by another app or service.
29
- */
30
- readonly namespace: string;
31
- readonly tools: ReadonlyArray<IrisAiTool>;
32
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=irisAiTools.js.map
@@ -1,23 +0,0 @@
1
- import { IrisAppExtensionType } from "./irisAppExtensionManifest";
2
- /** Clients see `<namespace>_<tool>`; the MCP Tool Guidelines cap that at 60 characters. */
3
- export declare const AI_TOOLS_MAX_EXPOSED_NAME_LENGTH = 60;
4
- export declare const AI_TOOLS_MAX_TOOLS = 50;
5
- export declare const AI_TOOLS_MAX_TITLE_LENGTH = 80;
6
- export declare const AI_TOOLS_MAX_DESCRIPTION_LENGTH = 2000;
7
- /** Keeps the registry entry well below Kafka's default 1 MB message limit. */
8
- export declare const AI_TOOLS_MAX_DECLARATION_BYTES: number;
9
- export type AiToolsValidationInput = {
10
- /** Untrusted at the server choke point: comes from a published manifest. */
11
- readonly extensions: ReadonlyArray<{
12
- readonly id: string;
13
- readonly type: IrisAppExtensionType;
14
- readonly aiTools: unknown;
15
- }>;
16
- };
17
- /**
18
- * Structural validation of `aiTools` across a manifest's extensions. Returns
19
- * human-readable errors; an empty array means valid. Shared by the build
20
- * (`updateExtensions`) and the server (`manifest-validator.ts`). Whether the
21
- * namespace is free is checked by the server only.
22
- */
23
- export declare const validateIrisAiTools: ({ extensions }: AiToolsValidationInput) => ReadonlyArray<string>;
@@ -1,124 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateIrisAiTools = exports.AI_TOOLS_MAX_DECLARATION_BYTES = exports.AI_TOOLS_MAX_DESCRIPTION_LENGTH = exports.AI_TOOLS_MAX_TITLE_LENGTH = exports.AI_TOOLS_MAX_TOOLS = exports.AI_TOOLS_MAX_EXPOSED_NAME_LENGTH = void 0;
4
- /** Clients see `<namespace>_<tool>`; the MCP Tool Guidelines cap that at 60 characters. */
5
- exports.AI_TOOLS_MAX_EXPOSED_NAME_LENGTH = 60;
6
- exports.AI_TOOLS_MAX_TOOLS = 50;
7
- exports.AI_TOOLS_MAX_TITLE_LENGTH = 80;
8
- exports.AI_TOOLS_MAX_DESCRIPTION_LENGTH = 2000;
9
- /** Keeps the registry entry well below Kafka's default 1 MB message limit. */
10
- exports.AI_TOOLS_MAX_DECLARATION_BYTES = 256 * 1024;
11
- const AI_TOOLS_EXTENSION_TYPE = "AI_TOOLS_EXTENSION";
12
- const NAMESPACE_PATTERN = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
13
- const TOOL_NAME_PATTERN = /^[a-z][a-z0-9]*(_[a-z0-9]+)+$/;
14
- const ANNOTATION_HINTS = ["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"];
15
- const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
16
- /** UTF-8 size of the JSON form, or `undefined` when the value cannot be serialized. */
17
- const serializedBytes = (value) => {
18
- try {
19
- return new TextEncoder().encode(JSON.stringify(value)).length;
20
- }
21
- catch {
22
- return undefined;
23
- }
24
- };
25
- const TEXT_MAX_LENGTH = { title: exports.AI_TOOLS_MAX_TITLE_LENGTH, description: exports.AI_TOOLS_MAX_DESCRIPTION_LENGTH };
26
- const validateText = (value, field, label, errors) => {
27
- if (typeof value !== "string" || value.trim().length === 0) {
28
- errors.push(`${label}: '${field}' is required and must be a non-empty string.`);
29
- }
30
- else if (value.length > TEXT_MAX_LENGTH[field]) {
31
- errors.push(`${label}: '${field}' must be at most ${TEXT_MAX_LENGTH[field]} characters.`);
32
- }
33
- };
34
- const validateSchema = (value, field, label, errors) => {
35
- if (!isRecord(value) || value.type !== "object") {
36
- errors.push(`${label}: '${field}' must be a JSON Schema object with type "object".`);
37
- }
38
- };
39
- const validateAnnotations = (value, label, errors) => {
40
- if (!isRecord(value)) {
41
- errors.push(`${label}: 'annotations' is required and must declare ${ANNOTATION_HINTS.join(", ")}.`);
42
- return;
43
- }
44
- ANNOTATION_HINTS.forEach(hint => {
45
- if (typeof value[hint] !== "boolean") {
46
- errors.push(`${label}: annotation '${hint}' is required and must be a boolean.`);
47
- }
48
- });
49
- };
50
- const validateTool = (tool, index, namespace, prefix, errors) => {
51
- if (!isRecord(tool)) {
52
- errors.push(`${prefix} tool #${index}: must be an object.`);
53
- return;
54
- }
55
- const label = `${prefix} tool #${index} (${typeof tool.name === "string" ? tool.name : "unknown name"})`;
56
- if (typeof tool.name !== "string" || !TOOL_NAME_PATTERN.test(tool.name)) {
57
- errors.push(`${label}: 'name' must be verb_noun in snake_case, e.g. 'update_fault_priorities'.`);
58
- }
59
- else if (namespace.length + 1 + tool.name.length > exports.AI_TOOLS_MAX_EXPOSED_NAME_LENGTH) {
60
- errors.push(`${label}: '${namespace}_${tool.name}' must be at most ${exports.AI_TOOLS_MAX_EXPOSED_NAME_LENGTH} characters.`);
61
- }
62
- validateText(tool.title, "title", label, errors);
63
- validateText(tool.description, "description", label, errors);
64
- validateSchema(tool.inputSchema, "inputSchema", label, errors);
65
- if (tool.outputSchema !== undefined) {
66
- validateSchema(tool.outputSchema, "outputSchema", label, errors);
67
- }
68
- validateAnnotations(tool.annotations, label, errors);
69
- };
70
- const validateExtensionAiTools = (extensionId, aiTools, errors) => {
71
- const prefix = `aiTools (extension '${extensionId}')`;
72
- if (!isRecord(aiTools)) {
73
- errors.push(`${prefix}: must be an object.`);
74
- return;
75
- }
76
- const bytes = serializedBytes(aiTools);
77
- if (bytes === undefined) {
78
- errors.push(`${prefix}: must be serializable.`);
79
- return;
80
- }
81
- if (bytes > exports.AI_TOOLS_MAX_DECLARATION_BYTES) {
82
- errors.push(`${prefix}: must be at most ${exports.AI_TOOLS_MAX_DECLARATION_BYTES} bytes as JSON, found ${bytes}.`);
83
- return;
84
- }
85
- const { namespace, tools } = aiTools;
86
- const validNamespace = typeof namespace === "string" && NAMESPACE_PATTERN.test(namespace);
87
- if (!validNamespace) {
88
- errors.push(`${prefix}: 'namespace' must be kebab-case (lowercase letters, digits, single dashes).`);
89
- }
90
- if (!Array.isArray(tools) || tools.length === 0) {
91
- errors.push(`${prefix}: 'tools' must declare at least one tool.`);
92
- return;
93
- }
94
- if (tools.length > exports.AI_TOOLS_MAX_TOOLS) {
95
- errors.push(`${prefix}: 'tools' must declare at most ${exports.AI_TOOLS_MAX_TOOLS} tools.`);
96
- return;
97
- }
98
- tools.forEach((tool, index) => validateTool(tool, index, validNamespace ? namespace : "", prefix, errors));
99
- const names = tools.map((tool) => (isRecord(tool) ? tool.name : undefined));
100
- const duplicates = names.filter((name, index) => typeof name === "string" && names.indexOf(name) !== index);
101
- if (duplicates.length > 0) {
102
- errors.push(`${prefix}: duplicate tool names: ${[...new Set(duplicates)].join(", ")}.`);
103
- }
104
- };
105
- /**
106
- * Structural validation of `aiTools` across a manifest's extensions. Returns
107
- * human-readable errors; an empty array means valid. Shared by the build
108
- * (`updateExtensions`) and the server (`manifest-validator.ts`). Whether the
109
- * namespace is free is checked by the server only.
110
- */
111
- const validateIrisAiTools = ({ extensions }) => {
112
- const aiToolsExtensions = extensions.filter(extension => extension.type === AI_TOOLS_EXTENSION_TYPE);
113
- const errors = [];
114
- if (aiToolsExtensions.length > 1) {
115
- errors.push(`aiTools: at most one ${AI_TOOLS_EXTENSION_TYPE} per app, found ${aiToolsExtensions.map(extension => extension.id).join(", ")}.`);
116
- }
117
- extensions
118
- .filter(extension => extension.type !== AI_TOOLS_EXTENSION_TYPE && extension.aiTools !== undefined)
119
- .forEach(extension => errors.push(`aiTools (extension '${extension.id}'): only ${AI_TOOLS_EXTENSION_TYPE} may declare aiTools, not '${extension.type}'.`));
120
- aiToolsExtensions.forEach(extension => validateExtensionAiTools(extension.id, extension.aiTools, errors));
121
- return errors;
122
- };
123
- exports.validateIrisAiTools = validateIrisAiTools;
124
- //# sourceMappingURL=irisAiToolsValidation.js.map