bruce-models 7.1.86 → 7.1.88

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.
@@ -15062,6 +15062,24 @@ var ExportCsv;
15062
15062
  }
15063
15063
  })(ExportCsv || (ExportCsv = {}));
15064
15064
 
15065
+ var ExportNsx;
15066
+ (function (ExportNsx) {
15067
+ /**
15068
+ * Starts a whole-account NSX backup export job.
15069
+ * The generated NSX file is stored in the account's configured backup file store.
15070
+ */
15071
+ function AccountBackup(params) {
15072
+ return __awaiter(this, void 0, void 0, function* () {
15073
+ let { api, req: reqParams } = params !== null && params !== void 0 ? params : {};
15074
+ if (!api) {
15075
+ api = ENVIRONMENT.Api().GetBruceApi();
15076
+ }
15077
+ return api.POST("export/nsx/accountBackup", {}, Api.PrepReqParams(reqParams));
15078
+ });
15079
+ }
15080
+ ExportNsx.AccountBackup = AccountBackup;
15081
+ })(ExportNsx || (ExportNsx = {}));
15082
+
15065
15083
  var ExportUsd;
15066
15084
  (function (ExportUsd) {
15067
15085
  function Export(params) {
@@ -16481,27 +16499,19 @@ var Plugin;
16481
16499
  }
16482
16500
  Plugin.Upload = Upload;
16483
16501
  /**
16484
- * Returns a run function to call that'll load a plugin within your provided container element.
16485
- * The run function will return a dispose function to call to remove the plugin.
16502
+ * Resolves a plugin record and returns its unwrapped source.
16486
16503
  * @param params
16487
16504
  * @returns
16488
16505
  */
16489
- function GetRunFunction(params) {
16506
+ function LoadPluginSource(params) {
16490
16507
  return __awaiter(this, void 0, void 0, function* () {
16491
- let { containerId, container, pluginParams, pluginId, plugin, api, req } = params;
16508
+ let { api, pluginId, plugin, req } = params;
16492
16509
  if (!api) {
16493
16510
  api = ENVIRONMENT.Api().GetBruceApi({
16494
16511
  loadConfig: true
16495
16512
  });
16496
16513
  }
16497
16514
  yield api.Loading;
16498
- if (!containerId && container) {
16499
- containerId = container.id;
16500
- if (!containerId) {
16501
- containerId = ObjectUtils.UId();
16502
- container.id = containerId;
16503
- }
16504
- }
16505
16515
  if (!plugin && pluginId) {
16506
16516
  plugin = (yield Plugin.Get({
16507
16517
  pluginId,
@@ -16543,6 +16553,39 @@ var Plugin;
16543
16553
  const start = fileContent.indexOf("{");
16544
16554
  const end = fileContent.lastIndexOf("}");
16545
16555
  fileContent = fileContent.substring(start + 1, end);
16556
+ return {
16557
+ api,
16558
+ pluginId,
16559
+ plugin,
16560
+ fileContent
16561
+ };
16562
+ });
16563
+ }
16564
+ /**
16565
+ * Returns a run function to call that'll load a plugin within your provided container element.
16566
+ * The run function will return a dispose function to call to remove the plugin.
16567
+ * @param params
16568
+ * @returns
16569
+ */
16570
+ function GetRunFunction(params) {
16571
+ return __awaiter(this, void 0, void 0, function* () {
16572
+ let { containerId, container, pluginParams, pluginId, plugin, api, req } = params;
16573
+ if (!containerId && container) {
16574
+ containerId = container.id;
16575
+ if (!containerId) {
16576
+ containerId = ObjectUtils.UId();
16577
+ container.id = containerId;
16578
+ }
16579
+ }
16580
+ const loaded = yield LoadPluginSource({
16581
+ api,
16582
+ pluginId,
16583
+ plugin,
16584
+ req
16585
+ });
16586
+ pluginId = loaded.pluginId;
16587
+ plugin = loaded.plugin;
16588
+ const fileContent = loaded.fileContent;
16546
16589
  const paramsId = ObjectUtils.UId();
16547
16590
  window[paramsId] = pluginParams ? pluginParams : {};
16548
16591
  window["PLUGIN_" + pluginId] = plugin;
@@ -16617,6 +16660,64 @@ var Plugin;
16617
16660
  });
16618
16661
  }
16619
16662
  Plugin.GetRunFunction = GetRunFunction;
16663
+ /**
16664
+ * Returns an invoke function that calls an AI_TOOL plugin headlessly.
16665
+ * @param params
16666
+ * @returns
16667
+ */
16668
+ function GetInvokeFunction(params) {
16669
+ return __awaiter(this, void 0, void 0, function* () {
16670
+ const { api, pluginId, plugin, req } = params;
16671
+ const loaded = yield LoadPluginSource({
16672
+ api,
16673
+ pluginId,
16674
+ plugin,
16675
+ req
16676
+ });
16677
+ return {
16678
+ invoke: (args, context) => {
16679
+ const callId = ObjectUtils.UId();
16680
+ const argsId = "PLUGIN_ARGS_" + callId;
16681
+ const contextId = "PLUGIN_CONTEXT_" + callId;
16682
+ const resultId = "PLUGIN_RESULT_" + callId;
16683
+ window[argsId] = args ? args : {};
16684
+ window[contextId] = Object.assign({ config: loaded.plugin.Settings ? loaded.plugin.Settings.config : undefined, plugin: loaded.plugin }, (context ? context : {}));
16685
+ const script = `
16686
+ function invoke() {
16687
+ "use strict";
16688
+ var Invoke;
16689
+
16690
+ ${loaded.fileContent}
16691
+
16692
+ if (typeof Invoke !== "function") {
16693
+ throw new Error("Plugin " + ${JSON.stringify(loaded.pluginId)}
16694
+ + " does not declare an Invoke function.");
16695
+ }
16696
+
16697
+ window["${resultId}"] = Invoke(window["${argsId}"], window["${contextId}"]);
16698
+ }
16699
+ invoke();
16700
+ `;
16701
+ try {
16702
+ // 'eval2 = eval' stops the linter from complaining about using eval.
16703
+ const eval2 = eval;
16704
+ eval2(script);
16705
+ // Invoke may hand back a plain value or a promise; normalise both.
16706
+ return Promise.resolve(window[resultId]);
16707
+ }
16708
+ catch (e) {
16709
+ return Promise.reject(e);
16710
+ }
16711
+ finally {
16712
+ delete window[argsId];
16713
+ delete window[contextId];
16714
+ delete window[resultId];
16715
+ }
16716
+ }
16717
+ };
16718
+ });
16719
+ }
16720
+ Plugin.GetInvokeFunction = GetInvokeFunction;
16620
16721
  /**
16621
16722
  * Returns cache identifier for a plugin.
16622
16723
  * Example: {
@@ -16656,6 +16757,134 @@ var Plugin;
16656
16757
  Plugin.GetIndexFileCacheKey = GetIndexFileCacheKey;
16657
16758
  })(Plugin || (Plugin = {}));
16658
16759
 
16760
+ /**
16761
+ * Validation for AI_TOOL plugins.
16762
+ */
16763
+ var PluginAiTool;
16764
+ (function (PluginAiTool) {
16765
+ /** Location value that exposes a plugin as an AI Tool. */
16766
+ PluginAiTool.LOCATION = "AI_TOOL";
16767
+ /** Prefix that turns a plugin ID into its tool name. */
16768
+ const TOOL_NAME_PREFIX = "plugin_";
16769
+ /** Provider limit on a tool name, prefix included. */
16770
+ const MAX_TOOL_NAME_LENGTH = 64;
16771
+ /** Longest plugin ID that still fits inside the tool name limit. */
16772
+ PluginAiTool.MAX_PLUGIN_ID_LENGTH = MAX_TOOL_NAME_LENGTH - TOOL_NAME_PREFIX.length;
16773
+ /**
16774
+ * Schema keywords that silently drop a tool out of strict mode instead of
16775
+ * failing. The tool still works, but stops being structurally guaranteed,
16776
+ * and nothing downstream reports that it happened.
16777
+ */
16778
+ const STRICT_INCOMPATIBLE_KEYWORDS = ["$ref", "$defs", "allOf", "not"];
16779
+ /**
16780
+ * Side effects an AI Tool may declare.
16781
+ *
16782
+ */
16783
+ const ALLOWED_SIDE_EFFECTS = ["none", "external"];
16784
+ function isPlainObject(value) {
16785
+ return !!value && typeof value === "object" && !Array.isArray(value);
16786
+ }
16787
+ /**
16788
+ * Walks a schema for a keyword that would disable strict mode.
16789
+ * @param node
16790
+ * @param depth bounded so a pathological schema cannot hang the save
16791
+ * @returns the offending keyword, or null
16792
+ */
16793
+ function findStrictModeViolation(node, depth = 0) {
16794
+ if (!node || typeof node !== "object" || depth > 32) {
16795
+ return null;
16796
+ }
16797
+ if (Array.isArray(node)) {
16798
+ for (const child of node) {
16799
+ const nested = findStrictModeViolation(child, depth + 1);
16800
+ if (nested) {
16801
+ return nested;
16802
+ }
16803
+ }
16804
+ return null;
16805
+ }
16806
+ for (const key of Object.keys(node)) {
16807
+ if (STRICT_INCOMPATIBLE_KEYWORDS.includes(key)) {
16808
+ return key;
16809
+ }
16810
+ const nested = findStrictModeViolation(node[key], depth + 1);
16811
+ if (nested) {
16812
+ return nested;
16813
+ }
16814
+ }
16815
+ return null;
16816
+ }
16817
+ /**
16818
+ * Returns why an AI Tool plugin cannot be saved, or null when it is valid.
16819
+ *
16820
+ * Messages are written for the administrator authoring the plugin, and say
16821
+ * what to change rather than what failed.
16822
+ * @param plugin
16823
+ * @returns
16824
+ */
16825
+ function Validate(plugin) {
16826
+ var _a, _b, _c, _d;
16827
+ if (!plugin || plugin.Location !== PluginAiTool.LOCATION) {
16828
+ return null;
16829
+ }
16830
+ const id = ((_a = plugin.ID) !== null && _a !== void 0 ? _a : "").trim();
16831
+ if (!id) {
16832
+ return "An AI Tool needs an ID: it becomes the tool name the agent calls.";
16833
+ }
16834
+ if (!/^[a-zA-Z0-9_-]+$/.test(id)) {
16835
+ return `The ID "${id}" contains characters that are not allowed in a tool name. `
16836
+ + "Use letters, numbers, hyphens and underscores only.";
16837
+ }
16838
+ if (TOOL_NAME_PREFIX.length + id.length > MAX_TOOL_NAME_LENGTH) {
16839
+ return `The ID is ${id.length} characters, which makes the tool name too long. `
16840
+ + `The maximum is ${PluginAiTool.MAX_PLUGIN_ID_LENGTH} characters.`;
16841
+ }
16842
+ const tool = (_b = plugin.Settings) === null || _b === void 0 ? void 0 : _b.tool;
16843
+ if (!isPlainObject(tool)) {
16844
+ return "An AI Tool must declare Settings.tool with an inputSchema the agent can call it with.";
16845
+ }
16846
+ // The tool name is an opaque ID, so it carries no signal about what the
16847
+ // tool does. The description is the only thing the agent can select on:
16848
+ // without one it is registered but never chosen, and nothing reports that.
16849
+ const description = typeof tool.description === "string" ? tool.description.trim() : "";
16850
+ if (!description && !((_c = plugin.Name) !== null && _c !== void 0 ? _c : "").trim()) {
16851
+ return "An AI Tool needs a description. Set Settings.tool.description, or fill in the plugin's "
16852
+ + "Name and Description — the agent has nothing else to choose the tool on.";
16853
+ }
16854
+ if (!isPlainObject(tool.inputSchema)) {
16855
+ return "Settings.tool.inputSchema is missing or is not an object.";
16856
+ }
16857
+ if (tool.inputSchema.type && tool.inputSchema.type !== "object") {
16858
+ return `Settings.tool.inputSchema.type is "${tool.inputSchema.type}"; it must be "object".`;
16859
+ }
16860
+ const strictViolation = findStrictModeViolation(tool.inputSchema);
16861
+ if (strictViolation) {
16862
+ return `Settings.tool.inputSchema uses "${strictViolation}", which silently turns off strict mode `
16863
+ + "for this tool. Inline the schema instead.";
16864
+ }
16865
+ if (tool.annotations !== undefined && !isPlainObject(tool.annotations)) {
16866
+ return "Settings.tool.annotations must be an object.";
16867
+ }
16868
+ const annotations = (_d = tool.annotations) !== null && _d !== void 0 ? _d : {};
16869
+ if (annotations.sideEffect !== undefined) {
16870
+ const sideEffect = String(annotations.sideEffect).trim().toLowerCase();
16871
+ if (!ALLOWED_SIDE_EFFECTS.includes(sideEffect)) {
16872
+ return `sideEffect "${annotations.sideEffect}" is not allowed. AI Tools are read-only in this `
16873
+ + "release: use \"none\", or \"external\" for a reviewed read-only external request.";
16874
+ }
16875
+ }
16876
+ if (annotations.timeoutMs !== undefined) {
16877
+ if (typeof annotations.timeoutMs !== "number"
16878
+ || !isFinite(annotations.timeoutMs)
16879
+ || annotations.timeoutMs <= 0) {
16880
+ return "timeoutMs must be a positive number of milliseconds.";
16881
+ }
16882
+ }
16883
+ return null;
16884
+ }
16885
+ PluginAiTool.Validate = Validate;
16886
+ })(PluginAiTool || (PluginAiTool = {}));
16887
+
16659
16888
  /**
16660
16889
  * Describes the "Program Key" concept within Nextspace.
16661
16890
  * A program key is an access token for an arbitrary software.
@@ -20744,7 +20973,7 @@ var UrlUtils;
20744
20973
  })(UrlUtils || (UrlUtils = {}));
20745
20974
 
20746
20975
  // This is updated with the package.json version on build.
20747
- const VERSION = "7.1.86";
20976
+ const VERSION = "7.1.88";
20748
20977
 
20749
- export { VERSION, Account, AccountAudit, AccountConcept, AccountFeatures, AccountInvite, AccountLimits, AccountTemplate, AccountType, AnnDocument, AbstractApi, Api, ApiGetters, BruceApi, GlobalApi, GuardianApi, Assembly, Calculator, ChangeSet, ClientFile, Bounds, BruceEvent, BruceVariable, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, GeoJson, Geometry, LRUCache, UTC, CustomForm, DashboardView, DataFeed, DataLab, DataLabGroup, DataSource, DataTransform, Comment, Entity, EntityAttachment, EntityAttachmentType, EntityAttribute, EntityComment, EntityCoords, EntityHistoricData, EntityLink, EntityLod, EntityLodCategory, EntityRelation, EntityRelationType, EntitySource, EntityTableView, EntityTag, EntityType, EntityTypeRelation, EntityTypeTrigger, Ontology, OntologyDocument, ENVIRONMENT, ExportBrz, ExportCsv, ExportUsd, Hexbin, ImportAssembly, ImportCad, ImportCsv, ImportGeoJson, ImportJson, ImportKml, ImportLcc, ImportedFile, Uploader, Markup, UIMarkup, NAVIGATOR_CHAT_EVENT_ENTITY_HIGHLIGHT_APPLIED, NAVIGATOR_CHAT_EVENT_SCENE_CONTEXT_PREFETCHED, NavigatorChatClient, NavigatorMcpWebSocketClient, Plugin, ProgramKey, MenuItem, ProjectView, ProjectViewBookmark, ProjectViewBookmarkGroup, ProjectViewLegacy, ProjectViewLegacyBookmark, ProjectViewLegacyTile, ProjectViewTile, ZoomControl, Scenario, HostingLocation, MessageBroker, PendingAction, RecordChangeFeed, Style, Tileset, Tracking, Permission, Session, User, UserGroup, UserMfaMethod, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils };
20978
+ export { VERSION, Account, AccountAudit, AccountConcept, AccountFeatures, AccountInvite, AccountLimits, AccountTemplate, AccountType, AnnDocument, AbstractApi, Api, ApiGetters, BruceApi, GlobalApi, GuardianApi, Assembly, Calculator, ChangeSet, ClientFile, Bounds, BruceEvent, BruceVariable, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, GeoJson, Geometry, LRUCache, UTC, CustomForm, DashboardView, DataFeed, DataLab, DataLabGroup, DataSource, DataTransform, Comment, Entity, EntityAttachment, EntityAttachmentType, EntityAttribute, EntityComment, EntityCoords, EntityHistoricData, EntityLink, EntityLod, EntityLodCategory, EntityRelation, EntityRelationType, EntitySource, EntityTableView, EntityTag, EntityType, EntityTypeRelation, EntityTypeTrigger, Ontology, OntologyDocument, ENVIRONMENT, ExportBrz, ExportCsv, ExportNsx, ExportUsd, Hexbin, ImportAssembly, ImportCad, ImportCsv, ImportGeoJson, ImportJson, ImportKml, ImportLcc, ImportedFile, Uploader, Markup, UIMarkup, NAVIGATOR_CHAT_EVENT_ENTITY_HIGHLIGHT_APPLIED, NAVIGATOR_CHAT_EVENT_SCENE_CONTEXT_PREFETCHED, NavigatorChatClient, NavigatorMcpWebSocketClient, Plugin, PluginAiTool, ProgramKey, MenuItem, ProjectView, ProjectViewBookmark, ProjectViewBookmarkGroup, ProjectViewLegacy, ProjectViewLegacyBookmark, ProjectViewLegacyTile, ProjectViewTile, ZoomControl, Scenario, HostingLocation, MessageBroker, PendingAction, RecordChangeFeed, Style, Tileset, Tracking, Permission, Session, User, UserGroup, UserMfaMethod, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils };
20750
20979
  //# sourceMappingURL=bruce-models.es5.js.map