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.
@@ -14824,6 +14824,23 @@
14824
14824
  }
14825
14825
  })(exports.ExportCsv || (exports.ExportCsv = {}));
14826
14826
 
14827
+ (function (ExportNsx) {
14828
+ /**
14829
+ * Starts a whole-account NSX backup export job.
14830
+ * The generated NSX file is stored in the account's configured backup file store.
14831
+ */
14832
+ function AccountBackup(params) {
14833
+ return __awaiter(this, void 0, void 0, function* () {
14834
+ let { api, req: reqParams } = params !== null && params !== void 0 ? params : {};
14835
+ if (!api) {
14836
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
14837
+ }
14838
+ return api.POST("export/nsx/accountBackup", {}, exports.Api.PrepReqParams(reqParams));
14839
+ });
14840
+ }
14841
+ ExportNsx.AccountBackup = AccountBackup;
14842
+ })(exports.ExportNsx || (exports.ExportNsx = {}));
14843
+
14827
14844
  (function (ExportUsd) {
14828
14845
  function Export(params) {
14829
14846
  return __awaiter(this, void 0, void 0, function* () {
@@ -16214,27 +16231,19 @@
16214
16231
  }
16215
16232
  Plugin.Upload = Upload;
16216
16233
  /**
16217
- * Returns a run function to call that'll load a plugin within your provided container element.
16218
- * The run function will return a dispose function to call to remove the plugin.
16234
+ * Resolves a plugin record and returns its unwrapped source.
16219
16235
  * @param params
16220
16236
  * @returns
16221
16237
  */
16222
- function GetRunFunction(params) {
16238
+ function LoadPluginSource(params) {
16223
16239
  return __awaiter(this, void 0, void 0, function* () {
16224
- let { containerId, container, pluginParams, pluginId, plugin, api, req } = params;
16240
+ let { api, pluginId, plugin, req } = params;
16225
16241
  if (!api) {
16226
16242
  api = exports.ENVIRONMENT.Api().GetBruceApi({
16227
16243
  loadConfig: true
16228
16244
  });
16229
16245
  }
16230
16246
  yield api.Loading;
16231
- if (!containerId && container) {
16232
- containerId = container.id;
16233
- if (!containerId) {
16234
- containerId = exports.ObjectUtils.UId();
16235
- container.id = containerId;
16236
- }
16237
- }
16238
16247
  if (!plugin && pluginId) {
16239
16248
  plugin = (yield Plugin.Get({
16240
16249
  pluginId,
@@ -16276,6 +16285,39 @@
16276
16285
  const start = fileContent.indexOf("{");
16277
16286
  const end = fileContent.lastIndexOf("}");
16278
16287
  fileContent = fileContent.substring(start + 1, end);
16288
+ return {
16289
+ api,
16290
+ pluginId,
16291
+ plugin,
16292
+ fileContent
16293
+ };
16294
+ });
16295
+ }
16296
+ /**
16297
+ * Returns a run function to call that'll load a plugin within your provided container element.
16298
+ * The run function will return a dispose function to call to remove the plugin.
16299
+ * @param params
16300
+ * @returns
16301
+ */
16302
+ function GetRunFunction(params) {
16303
+ return __awaiter(this, void 0, void 0, function* () {
16304
+ let { containerId, container, pluginParams, pluginId, plugin, api, req } = params;
16305
+ if (!containerId && container) {
16306
+ containerId = container.id;
16307
+ if (!containerId) {
16308
+ containerId = exports.ObjectUtils.UId();
16309
+ container.id = containerId;
16310
+ }
16311
+ }
16312
+ const loaded = yield LoadPluginSource({
16313
+ api,
16314
+ pluginId,
16315
+ plugin,
16316
+ req
16317
+ });
16318
+ pluginId = loaded.pluginId;
16319
+ plugin = loaded.plugin;
16320
+ const fileContent = loaded.fileContent;
16279
16321
  const paramsId = exports.ObjectUtils.UId();
16280
16322
  window[paramsId] = pluginParams ? pluginParams : {};
16281
16323
  window["PLUGIN_" + pluginId] = plugin;
@@ -16350,6 +16392,64 @@
16350
16392
  });
16351
16393
  }
16352
16394
  Plugin.GetRunFunction = GetRunFunction;
16395
+ /**
16396
+ * Returns an invoke function that calls an AI_TOOL plugin headlessly.
16397
+ * @param params
16398
+ * @returns
16399
+ */
16400
+ function GetInvokeFunction(params) {
16401
+ return __awaiter(this, void 0, void 0, function* () {
16402
+ const { api, pluginId, plugin, req } = params;
16403
+ const loaded = yield LoadPluginSource({
16404
+ api,
16405
+ pluginId,
16406
+ plugin,
16407
+ req
16408
+ });
16409
+ return {
16410
+ invoke: (args, context) => {
16411
+ const callId = exports.ObjectUtils.UId();
16412
+ const argsId = "PLUGIN_ARGS_" + callId;
16413
+ const contextId = "PLUGIN_CONTEXT_" + callId;
16414
+ const resultId = "PLUGIN_RESULT_" + callId;
16415
+ window[argsId] = args ? args : {};
16416
+ window[contextId] = Object.assign({ config: loaded.plugin.Settings ? loaded.plugin.Settings.config : undefined, plugin: loaded.plugin }, (context ? context : {}));
16417
+ const script = `
16418
+ function invoke() {
16419
+ "use strict";
16420
+ var Invoke;
16421
+
16422
+ ${loaded.fileContent}
16423
+
16424
+ if (typeof Invoke !== "function") {
16425
+ throw new Error("Plugin " + ${JSON.stringify(loaded.pluginId)}
16426
+ + " does not declare an Invoke function.");
16427
+ }
16428
+
16429
+ window["${resultId}"] = Invoke(window["${argsId}"], window["${contextId}"]);
16430
+ }
16431
+ invoke();
16432
+ `;
16433
+ try {
16434
+ // 'eval2 = eval' stops the linter from complaining about using eval.
16435
+ const eval2 = eval;
16436
+ eval2(script);
16437
+ // Invoke may hand back a plain value or a promise; normalise both.
16438
+ return Promise.resolve(window[resultId]);
16439
+ }
16440
+ catch (e) {
16441
+ return Promise.reject(e);
16442
+ }
16443
+ finally {
16444
+ delete window[argsId];
16445
+ delete window[contextId];
16446
+ delete window[resultId];
16447
+ }
16448
+ }
16449
+ };
16450
+ });
16451
+ }
16452
+ Plugin.GetInvokeFunction = GetInvokeFunction;
16353
16453
  /**
16354
16454
  * Returns cache identifier for a plugin.
16355
16455
  * Example: {
@@ -16389,6 +16489,133 @@
16389
16489
  Plugin.GetIndexFileCacheKey = GetIndexFileCacheKey;
16390
16490
  })(exports.Plugin || (exports.Plugin = {}));
16391
16491
 
16492
+ /**
16493
+ * Validation for AI_TOOL plugins.
16494
+ */
16495
+ (function (PluginAiTool) {
16496
+ /** Location value that exposes a plugin as an AI Tool. */
16497
+ PluginAiTool.LOCATION = "AI_TOOL";
16498
+ /** Prefix that turns a plugin ID into its tool name. */
16499
+ const TOOL_NAME_PREFIX = "plugin_";
16500
+ /** Provider limit on a tool name, prefix included. */
16501
+ const MAX_TOOL_NAME_LENGTH = 64;
16502
+ /** Longest plugin ID that still fits inside the tool name limit. */
16503
+ PluginAiTool.MAX_PLUGIN_ID_LENGTH = MAX_TOOL_NAME_LENGTH - TOOL_NAME_PREFIX.length;
16504
+ /**
16505
+ * Schema keywords that silently drop a tool out of strict mode instead of
16506
+ * failing. The tool still works, but stops being structurally guaranteed,
16507
+ * and nothing downstream reports that it happened.
16508
+ */
16509
+ const STRICT_INCOMPATIBLE_KEYWORDS = ["$ref", "$defs", "allOf", "not"];
16510
+ /**
16511
+ * Side effects an AI Tool may declare.
16512
+ *
16513
+ */
16514
+ const ALLOWED_SIDE_EFFECTS = ["none", "external"];
16515
+ function isPlainObject(value) {
16516
+ return !!value && typeof value === "object" && !Array.isArray(value);
16517
+ }
16518
+ /**
16519
+ * Walks a schema for a keyword that would disable strict mode.
16520
+ * @param node
16521
+ * @param depth bounded so a pathological schema cannot hang the save
16522
+ * @returns the offending keyword, or null
16523
+ */
16524
+ function findStrictModeViolation(node, depth = 0) {
16525
+ if (!node || typeof node !== "object" || depth > 32) {
16526
+ return null;
16527
+ }
16528
+ if (Array.isArray(node)) {
16529
+ for (const child of node) {
16530
+ const nested = findStrictModeViolation(child, depth + 1);
16531
+ if (nested) {
16532
+ return nested;
16533
+ }
16534
+ }
16535
+ return null;
16536
+ }
16537
+ for (const key of Object.keys(node)) {
16538
+ if (STRICT_INCOMPATIBLE_KEYWORDS.includes(key)) {
16539
+ return key;
16540
+ }
16541
+ const nested = findStrictModeViolation(node[key], depth + 1);
16542
+ if (nested) {
16543
+ return nested;
16544
+ }
16545
+ }
16546
+ return null;
16547
+ }
16548
+ /**
16549
+ * Returns why an AI Tool plugin cannot be saved, or null when it is valid.
16550
+ *
16551
+ * Messages are written for the administrator authoring the plugin, and say
16552
+ * what to change rather than what failed.
16553
+ * @param plugin
16554
+ * @returns
16555
+ */
16556
+ function Validate(plugin) {
16557
+ var _a, _b, _c, _d;
16558
+ if (!plugin || plugin.Location !== PluginAiTool.LOCATION) {
16559
+ return null;
16560
+ }
16561
+ const id = ((_a = plugin.ID) !== null && _a !== void 0 ? _a : "").trim();
16562
+ if (!id) {
16563
+ return "An AI Tool needs an ID: it becomes the tool name the agent calls.";
16564
+ }
16565
+ if (!/^[a-zA-Z0-9_-]+$/.test(id)) {
16566
+ return `The ID "${id}" contains characters that are not allowed in a tool name. `
16567
+ + "Use letters, numbers, hyphens and underscores only.";
16568
+ }
16569
+ if (TOOL_NAME_PREFIX.length + id.length > MAX_TOOL_NAME_LENGTH) {
16570
+ return `The ID is ${id.length} characters, which makes the tool name too long. `
16571
+ + `The maximum is ${PluginAiTool.MAX_PLUGIN_ID_LENGTH} characters.`;
16572
+ }
16573
+ const tool = (_b = plugin.Settings) === null || _b === void 0 ? void 0 : _b.tool;
16574
+ if (!isPlainObject(tool)) {
16575
+ return "An AI Tool must declare Settings.tool with an inputSchema the agent can call it with.";
16576
+ }
16577
+ // The tool name is an opaque ID, so it carries no signal about what the
16578
+ // tool does. The description is the only thing the agent can select on:
16579
+ // without one it is registered but never chosen, and nothing reports that.
16580
+ const description = typeof tool.description === "string" ? tool.description.trim() : "";
16581
+ if (!description && !((_c = plugin.Name) !== null && _c !== void 0 ? _c : "").trim()) {
16582
+ return "An AI Tool needs a description. Set Settings.tool.description, or fill in the plugin's "
16583
+ + "Name and Description — the agent has nothing else to choose the tool on.";
16584
+ }
16585
+ if (!isPlainObject(tool.inputSchema)) {
16586
+ return "Settings.tool.inputSchema is missing or is not an object.";
16587
+ }
16588
+ if (tool.inputSchema.type && tool.inputSchema.type !== "object") {
16589
+ return `Settings.tool.inputSchema.type is "${tool.inputSchema.type}"; it must be "object".`;
16590
+ }
16591
+ const strictViolation = findStrictModeViolation(tool.inputSchema);
16592
+ if (strictViolation) {
16593
+ return `Settings.tool.inputSchema uses "${strictViolation}", which silently turns off strict mode `
16594
+ + "for this tool. Inline the schema instead.";
16595
+ }
16596
+ if (tool.annotations !== undefined && !isPlainObject(tool.annotations)) {
16597
+ return "Settings.tool.annotations must be an object.";
16598
+ }
16599
+ const annotations = (_d = tool.annotations) !== null && _d !== void 0 ? _d : {};
16600
+ if (annotations.sideEffect !== undefined) {
16601
+ const sideEffect = String(annotations.sideEffect).trim().toLowerCase();
16602
+ if (!ALLOWED_SIDE_EFFECTS.includes(sideEffect)) {
16603
+ return `sideEffect "${annotations.sideEffect}" is not allowed. AI Tools are read-only in this `
16604
+ + "release: use \"none\", or \"external\" for a reviewed read-only external request.";
16605
+ }
16606
+ }
16607
+ if (annotations.timeoutMs !== undefined) {
16608
+ if (typeof annotations.timeoutMs !== "number"
16609
+ || !isFinite(annotations.timeoutMs)
16610
+ || annotations.timeoutMs <= 0) {
16611
+ return "timeoutMs must be a positive number of milliseconds.";
16612
+ }
16613
+ }
16614
+ return null;
16615
+ }
16616
+ PluginAiTool.Validate = Validate;
16617
+ })(exports.PluginAiTool || (exports.PluginAiTool = {}));
16618
+
16392
16619
  (function (ProgramKey) {
16393
16620
  /**
16394
16621
  * Known program IDs that Nextspace applications will reference.
@@ -20381,7 +20608,7 @@
20381
20608
  })(exports.UrlUtils || (exports.UrlUtils = {}));
20382
20609
 
20383
20610
  // This is updated with the package.json version on build.
20384
- const VERSION = "7.1.86";
20611
+ const VERSION = "7.1.88";
20385
20612
 
20386
20613
  exports.VERSION = VERSION;
20387
20614
  exports.AbstractApi = AbstractApi;