bruce-models 7.1.85 → 7.1.87
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/dist/bruce-models.es5.js +231 -16
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +229 -15
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/bruce-models.js +2 -1
- package/dist/lib/bruce-models.js.map +1 -1
- package/dist/lib/change-set/change-set.js +7 -3
- package/dist/lib/change-set/change-set.js.map +1 -1
- package/dist/lib/plugin/ai-tool-validation.js +131 -0
- package/dist/lib/plugin/ai-tool-validation.js.map +1 -0
- package/dist/lib/plugin/plugin.js +94 -11
- package/dist/lib/plugin/plugin.js.map +1 -1
- package/dist/types/bruce-models.d.ts +2 -1
- package/dist/types/change-set/change-set.d.ts +12 -0
- package/dist/types/plugin/ai-tool-validation.d.ts +19 -0
- package/dist/types/plugin/plugin.d.ts +23 -0
- package/package.json +1 -1
package/dist/bruce-models.es5.js
CHANGED
|
@@ -8544,11 +8544,12 @@ var ChangeSet;
|
|
|
8544
8544
|
*/
|
|
8545
8545
|
function Get(params) {
|
|
8546
8546
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8547
|
-
let { id, api, req: reqParams } = params;
|
|
8547
|
+
let { id, expandCount, api, req: reqParams } = params;
|
|
8548
8548
|
if (!api) {
|
|
8549
8549
|
api = ENVIRONMENT.Api().GetBruceApi();
|
|
8550
8550
|
}
|
|
8551
|
-
|
|
8551
|
+
const query = expandCount ? "?Expand=Count" : "";
|
|
8552
|
+
return yield api.GET(`v3/change/${id}${query}`, Api.PrepReqParams(reqParams));
|
|
8552
8553
|
});
|
|
8553
8554
|
}
|
|
8554
8555
|
ChangeSet.Get = Get;
|
|
@@ -8558,7 +8559,7 @@ var ChangeSet;
|
|
|
8558
8559
|
*/
|
|
8559
8560
|
function GetList(params) {
|
|
8560
8561
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8561
|
-
let { api, req: reqParams, pageSize, pageIndex } = params;
|
|
8562
|
+
let { api, req: reqParams, pageSize, pageIndex, expandCount } = params;
|
|
8562
8563
|
if (!api) {
|
|
8563
8564
|
api = ENVIRONMENT.Api().GetBruceApi();
|
|
8564
8565
|
}
|
|
@@ -8569,6 +8570,9 @@ var ChangeSet;
|
|
|
8569
8570
|
if (pageIndex != null) {
|
|
8570
8571
|
urlParams.append("PageIndex", String(pageIndex));
|
|
8571
8572
|
}
|
|
8573
|
+
if (expandCount) {
|
|
8574
|
+
urlParams.append("Expand", "Count");
|
|
8575
|
+
}
|
|
8572
8576
|
const query = urlParams.toString();
|
|
8573
8577
|
return api.GET(query ? `v3/changes?${query}` : "v3/changes", Api.PrepReqParams(reqParams));
|
|
8574
8578
|
});
|
|
@@ -16477,27 +16481,19 @@ var Plugin;
|
|
|
16477
16481
|
}
|
|
16478
16482
|
Plugin.Upload = Upload;
|
|
16479
16483
|
/**
|
|
16480
|
-
*
|
|
16481
|
-
* The run function will return a dispose function to call to remove the plugin.
|
|
16484
|
+
* Resolves a plugin record and returns its unwrapped source.
|
|
16482
16485
|
* @param params
|
|
16483
16486
|
* @returns
|
|
16484
16487
|
*/
|
|
16485
|
-
function
|
|
16488
|
+
function LoadPluginSource(params) {
|
|
16486
16489
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16487
|
-
let {
|
|
16490
|
+
let { api, pluginId, plugin, req } = params;
|
|
16488
16491
|
if (!api) {
|
|
16489
16492
|
api = ENVIRONMENT.Api().GetBruceApi({
|
|
16490
16493
|
loadConfig: true
|
|
16491
16494
|
});
|
|
16492
16495
|
}
|
|
16493
16496
|
yield api.Loading;
|
|
16494
|
-
if (!containerId && container) {
|
|
16495
|
-
containerId = container.id;
|
|
16496
|
-
if (!containerId) {
|
|
16497
|
-
containerId = ObjectUtils.UId();
|
|
16498
|
-
container.id = containerId;
|
|
16499
|
-
}
|
|
16500
|
-
}
|
|
16501
16497
|
if (!plugin && pluginId) {
|
|
16502
16498
|
plugin = (yield Plugin.Get({
|
|
16503
16499
|
pluginId,
|
|
@@ -16539,6 +16535,39 @@ var Plugin;
|
|
|
16539
16535
|
const start = fileContent.indexOf("{");
|
|
16540
16536
|
const end = fileContent.lastIndexOf("}");
|
|
16541
16537
|
fileContent = fileContent.substring(start + 1, end);
|
|
16538
|
+
return {
|
|
16539
|
+
api,
|
|
16540
|
+
pluginId,
|
|
16541
|
+
plugin,
|
|
16542
|
+
fileContent
|
|
16543
|
+
};
|
|
16544
|
+
});
|
|
16545
|
+
}
|
|
16546
|
+
/**
|
|
16547
|
+
* Returns a run function to call that'll load a plugin within your provided container element.
|
|
16548
|
+
* The run function will return a dispose function to call to remove the plugin.
|
|
16549
|
+
* @param params
|
|
16550
|
+
* @returns
|
|
16551
|
+
*/
|
|
16552
|
+
function GetRunFunction(params) {
|
|
16553
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16554
|
+
let { containerId, container, pluginParams, pluginId, plugin, api, req } = params;
|
|
16555
|
+
if (!containerId && container) {
|
|
16556
|
+
containerId = container.id;
|
|
16557
|
+
if (!containerId) {
|
|
16558
|
+
containerId = ObjectUtils.UId();
|
|
16559
|
+
container.id = containerId;
|
|
16560
|
+
}
|
|
16561
|
+
}
|
|
16562
|
+
const loaded = yield LoadPluginSource({
|
|
16563
|
+
api,
|
|
16564
|
+
pluginId,
|
|
16565
|
+
plugin,
|
|
16566
|
+
req
|
|
16567
|
+
});
|
|
16568
|
+
pluginId = loaded.pluginId;
|
|
16569
|
+
plugin = loaded.plugin;
|
|
16570
|
+
const fileContent = loaded.fileContent;
|
|
16542
16571
|
const paramsId = ObjectUtils.UId();
|
|
16543
16572
|
window[paramsId] = pluginParams ? pluginParams : {};
|
|
16544
16573
|
window["PLUGIN_" + pluginId] = plugin;
|
|
@@ -16613,6 +16642,64 @@ var Plugin;
|
|
|
16613
16642
|
});
|
|
16614
16643
|
}
|
|
16615
16644
|
Plugin.GetRunFunction = GetRunFunction;
|
|
16645
|
+
/**
|
|
16646
|
+
* Returns an invoke function that calls an AI_TOOL plugin headlessly.
|
|
16647
|
+
* @param params
|
|
16648
|
+
* @returns
|
|
16649
|
+
*/
|
|
16650
|
+
function GetInvokeFunction(params) {
|
|
16651
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16652
|
+
const { api, pluginId, plugin, req } = params;
|
|
16653
|
+
const loaded = yield LoadPluginSource({
|
|
16654
|
+
api,
|
|
16655
|
+
pluginId,
|
|
16656
|
+
plugin,
|
|
16657
|
+
req
|
|
16658
|
+
});
|
|
16659
|
+
return {
|
|
16660
|
+
invoke: (args, context) => {
|
|
16661
|
+
const callId = ObjectUtils.UId();
|
|
16662
|
+
const argsId = "PLUGIN_ARGS_" + callId;
|
|
16663
|
+
const contextId = "PLUGIN_CONTEXT_" + callId;
|
|
16664
|
+
const resultId = "PLUGIN_RESULT_" + callId;
|
|
16665
|
+
window[argsId] = args ? args : {};
|
|
16666
|
+
window[contextId] = Object.assign({ config: loaded.plugin.Settings ? loaded.plugin.Settings.config : undefined, plugin: loaded.plugin }, (context ? context : {}));
|
|
16667
|
+
const script = `
|
|
16668
|
+
function invoke() {
|
|
16669
|
+
"use strict";
|
|
16670
|
+
var Invoke;
|
|
16671
|
+
|
|
16672
|
+
${loaded.fileContent}
|
|
16673
|
+
|
|
16674
|
+
if (typeof Invoke !== "function") {
|
|
16675
|
+
throw new Error("Plugin " + ${JSON.stringify(loaded.pluginId)}
|
|
16676
|
+
+ " does not declare an Invoke function.");
|
|
16677
|
+
}
|
|
16678
|
+
|
|
16679
|
+
window["${resultId}"] = Invoke(window["${argsId}"], window["${contextId}"]);
|
|
16680
|
+
}
|
|
16681
|
+
invoke();
|
|
16682
|
+
`;
|
|
16683
|
+
try {
|
|
16684
|
+
// 'eval2 = eval' stops the linter from complaining about using eval.
|
|
16685
|
+
const eval2 = eval;
|
|
16686
|
+
eval2(script);
|
|
16687
|
+
// Invoke may hand back a plain value or a promise; normalise both.
|
|
16688
|
+
return Promise.resolve(window[resultId]);
|
|
16689
|
+
}
|
|
16690
|
+
catch (e) {
|
|
16691
|
+
return Promise.reject(e);
|
|
16692
|
+
}
|
|
16693
|
+
finally {
|
|
16694
|
+
delete window[argsId];
|
|
16695
|
+
delete window[contextId];
|
|
16696
|
+
delete window[resultId];
|
|
16697
|
+
}
|
|
16698
|
+
}
|
|
16699
|
+
};
|
|
16700
|
+
});
|
|
16701
|
+
}
|
|
16702
|
+
Plugin.GetInvokeFunction = GetInvokeFunction;
|
|
16616
16703
|
/**
|
|
16617
16704
|
* Returns cache identifier for a plugin.
|
|
16618
16705
|
* Example: {
|
|
@@ -16652,6 +16739,134 @@ var Plugin;
|
|
|
16652
16739
|
Plugin.GetIndexFileCacheKey = GetIndexFileCacheKey;
|
|
16653
16740
|
})(Plugin || (Plugin = {}));
|
|
16654
16741
|
|
|
16742
|
+
/**
|
|
16743
|
+
* Validation for AI_TOOL plugins.
|
|
16744
|
+
*/
|
|
16745
|
+
var PluginAiTool;
|
|
16746
|
+
(function (PluginAiTool) {
|
|
16747
|
+
/** Location value that exposes a plugin as an AI Tool. */
|
|
16748
|
+
PluginAiTool.LOCATION = "AI_TOOL";
|
|
16749
|
+
/** Prefix that turns a plugin ID into its tool name. */
|
|
16750
|
+
const TOOL_NAME_PREFIX = "plugin_";
|
|
16751
|
+
/** Provider limit on a tool name, prefix included. */
|
|
16752
|
+
const MAX_TOOL_NAME_LENGTH = 64;
|
|
16753
|
+
/** Longest plugin ID that still fits inside the tool name limit. */
|
|
16754
|
+
PluginAiTool.MAX_PLUGIN_ID_LENGTH = MAX_TOOL_NAME_LENGTH - TOOL_NAME_PREFIX.length;
|
|
16755
|
+
/**
|
|
16756
|
+
* Schema keywords that silently drop a tool out of strict mode instead of
|
|
16757
|
+
* failing. The tool still works, but stops being structurally guaranteed,
|
|
16758
|
+
* and nothing downstream reports that it happened.
|
|
16759
|
+
*/
|
|
16760
|
+
const STRICT_INCOMPATIBLE_KEYWORDS = ["$ref", "$defs", "allOf", "not"];
|
|
16761
|
+
/**
|
|
16762
|
+
* Side effects an AI Tool may declare.
|
|
16763
|
+
*
|
|
16764
|
+
*/
|
|
16765
|
+
const ALLOWED_SIDE_EFFECTS = ["none", "external"];
|
|
16766
|
+
function isPlainObject(value) {
|
|
16767
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
16768
|
+
}
|
|
16769
|
+
/**
|
|
16770
|
+
* Walks a schema for a keyword that would disable strict mode.
|
|
16771
|
+
* @param node
|
|
16772
|
+
* @param depth bounded so a pathological schema cannot hang the save
|
|
16773
|
+
* @returns the offending keyword, or null
|
|
16774
|
+
*/
|
|
16775
|
+
function findStrictModeViolation(node, depth = 0) {
|
|
16776
|
+
if (!node || typeof node !== "object" || depth > 32) {
|
|
16777
|
+
return null;
|
|
16778
|
+
}
|
|
16779
|
+
if (Array.isArray(node)) {
|
|
16780
|
+
for (const child of node) {
|
|
16781
|
+
const nested = findStrictModeViolation(child, depth + 1);
|
|
16782
|
+
if (nested) {
|
|
16783
|
+
return nested;
|
|
16784
|
+
}
|
|
16785
|
+
}
|
|
16786
|
+
return null;
|
|
16787
|
+
}
|
|
16788
|
+
for (const key of Object.keys(node)) {
|
|
16789
|
+
if (STRICT_INCOMPATIBLE_KEYWORDS.includes(key)) {
|
|
16790
|
+
return key;
|
|
16791
|
+
}
|
|
16792
|
+
const nested = findStrictModeViolation(node[key], depth + 1);
|
|
16793
|
+
if (nested) {
|
|
16794
|
+
return nested;
|
|
16795
|
+
}
|
|
16796
|
+
}
|
|
16797
|
+
return null;
|
|
16798
|
+
}
|
|
16799
|
+
/**
|
|
16800
|
+
* Returns why an AI Tool plugin cannot be saved, or null when it is valid.
|
|
16801
|
+
*
|
|
16802
|
+
* Messages are written for the administrator authoring the plugin, and say
|
|
16803
|
+
* what to change rather than what failed.
|
|
16804
|
+
* @param plugin
|
|
16805
|
+
* @returns
|
|
16806
|
+
*/
|
|
16807
|
+
function Validate(plugin) {
|
|
16808
|
+
var _a, _b, _c, _d;
|
|
16809
|
+
if (!plugin || plugin.Location !== PluginAiTool.LOCATION) {
|
|
16810
|
+
return null;
|
|
16811
|
+
}
|
|
16812
|
+
const id = ((_a = plugin.ID) !== null && _a !== void 0 ? _a : "").trim();
|
|
16813
|
+
if (!id) {
|
|
16814
|
+
return "An AI Tool needs an ID: it becomes the tool name the agent calls.";
|
|
16815
|
+
}
|
|
16816
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(id)) {
|
|
16817
|
+
return `The ID "${id}" contains characters that are not allowed in a tool name. `
|
|
16818
|
+
+ "Use letters, numbers, hyphens and underscores only.";
|
|
16819
|
+
}
|
|
16820
|
+
if (TOOL_NAME_PREFIX.length + id.length > MAX_TOOL_NAME_LENGTH) {
|
|
16821
|
+
return `The ID is ${id.length} characters, which makes the tool name too long. `
|
|
16822
|
+
+ `The maximum is ${PluginAiTool.MAX_PLUGIN_ID_LENGTH} characters.`;
|
|
16823
|
+
}
|
|
16824
|
+
const tool = (_b = plugin.Settings) === null || _b === void 0 ? void 0 : _b.tool;
|
|
16825
|
+
if (!isPlainObject(tool)) {
|
|
16826
|
+
return "An AI Tool must declare Settings.tool with an inputSchema the agent can call it with.";
|
|
16827
|
+
}
|
|
16828
|
+
// The tool name is an opaque ID, so it carries no signal about what the
|
|
16829
|
+
// tool does. The description is the only thing the agent can select on:
|
|
16830
|
+
// without one it is registered but never chosen, and nothing reports that.
|
|
16831
|
+
const description = typeof tool.description === "string" ? tool.description.trim() : "";
|
|
16832
|
+
if (!description && !((_c = plugin.Name) !== null && _c !== void 0 ? _c : "").trim()) {
|
|
16833
|
+
return "An AI Tool needs a description. Set Settings.tool.description, or fill in the plugin's "
|
|
16834
|
+
+ "Name and Description — the agent has nothing else to choose the tool on.";
|
|
16835
|
+
}
|
|
16836
|
+
if (!isPlainObject(tool.inputSchema)) {
|
|
16837
|
+
return "Settings.tool.inputSchema is missing or is not an object.";
|
|
16838
|
+
}
|
|
16839
|
+
if (tool.inputSchema.type && tool.inputSchema.type !== "object") {
|
|
16840
|
+
return `Settings.tool.inputSchema.type is "${tool.inputSchema.type}"; it must be "object".`;
|
|
16841
|
+
}
|
|
16842
|
+
const strictViolation = findStrictModeViolation(tool.inputSchema);
|
|
16843
|
+
if (strictViolation) {
|
|
16844
|
+
return `Settings.tool.inputSchema uses "${strictViolation}", which silently turns off strict mode `
|
|
16845
|
+
+ "for this tool. Inline the schema instead.";
|
|
16846
|
+
}
|
|
16847
|
+
if (tool.annotations !== undefined && !isPlainObject(tool.annotations)) {
|
|
16848
|
+
return "Settings.tool.annotations must be an object.";
|
|
16849
|
+
}
|
|
16850
|
+
const annotations = (_d = tool.annotations) !== null && _d !== void 0 ? _d : {};
|
|
16851
|
+
if (annotations.sideEffect !== undefined) {
|
|
16852
|
+
const sideEffect = String(annotations.sideEffect).trim().toLowerCase();
|
|
16853
|
+
if (!ALLOWED_SIDE_EFFECTS.includes(sideEffect)) {
|
|
16854
|
+
return `sideEffect "${annotations.sideEffect}" is not allowed. AI Tools are read-only in this `
|
|
16855
|
+
+ "release: use \"none\", or \"external\" for a reviewed read-only external request.";
|
|
16856
|
+
}
|
|
16857
|
+
}
|
|
16858
|
+
if (annotations.timeoutMs !== undefined) {
|
|
16859
|
+
if (typeof annotations.timeoutMs !== "number"
|
|
16860
|
+
|| !isFinite(annotations.timeoutMs)
|
|
16861
|
+
|| annotations.timeoutMs <= 0) {
|
|
16862
|
+
return "timeoutMs must be a positive number of milliseconds.";
|
|
16863
|
+
}
|
|
16864
|
+
}
|
|
16865
|
+
return null;
|
|
16866
|
+
}
|
|
16867
|
+
PluginAiTool.Validate = Validate;
|
|
16868
|
+
})(PluginAiTool || (PluginAiTool = {}));
|
|
16869
|
+
|
|
16655
16870
|
/**
|
|
16656
16871
|
* Describes the "Program Key" concept within Nextspace.
|
|
16657
16872
|
* A program key is an access token for an arbitrary software.
|
|
@@ -20740,7 +20955,7 @@ var UrlUtils;
|
|
|
20740
20955
|
})(UrlUtils || (UrlUtils = {}));
|
|
20741
20956
|
|
|
20742
20957
|
// This is updated with the package.json version on build.
|
|
20743
|
-
const VERSION = "7.1.
|
|
20958
|
+
const VERSION = "7.1.87";
|
|
20744
20959
|
|
|
20745
|
-
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 };
|
|
20960
|
+
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, 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 };
|
|
20746
20961
|
//# sourceMappingURL=bruce-models.es5.js.map
|