bruce-models 6.9.0 → 6.9.2
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 +79 -6
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +79 -6
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/mcp/navigator-chat.js +78 -5
- package/dist/lib/mcp/navigator-chat.js.map +1 -1
- package/dist/types/bruce-models.d.ts +1 -1
- package/dist/types/mcp/navigator-chat.d.ts +17 -0
- package/package.json +1 -1
package/dist/bruce-models.es5.js
CHANGED
|
@@ -16470,6 +16470,8 @@ var Tracking;
|
|
|
16470
16470
|
Tracking.GetData = GetData;
|
|
16471
16471
|
})(Tracking || (Tracking = {}));
|
|
16472
16472
|
|
|
16473
|
+
const DEFAULT_JOB_POLL_INTERVAL_MS = 1000;
|
|
16474
|
+
const DEFAULT_JOB_POLL_TIMEOUT_MS = 4 * 60 * 1000; // match server timeout (4 minutes)
|
|
16473
16475
|
const DEFAULT_BASE_URL = "http://localhost:8888";
|
|
16474
16476
|
/**
|
|
16475
16477
|
* Lightweight client for the Navigator MCP chat HTTP endpoints.
|
|
@@ -16478,10 +16480,12 @@ const DEFAULT_BASE_URL = "http://localhost:8888";
|
|
|
16478
16480
|
*/
|
|
16479
16481
|
class NavigatorChatClient {
|
|
16480
16482
|
constructor(options = {}) {
|
|
16481
|
-
var _a, _b;
|
|
16483
|
+
var _a, _b, _c, _d;
|
|
16482
16484
|
this.baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_BASE_URL;
|
|
16483
16485
|
this.fetchImpl = options.fetchImpl;
|
|
16484
16486
|
this.defaultHeaders = (_b = options.defaultHeaders) !== null && _b !== void 0 ? _b : {};
|
|
16487
|
+
this.jobPollIntervalMs = (_c = options.jobPollIntervalMs) !== null && _c !== void 0 ? _c : DEFAULT_JOB_POLL_INTERVAL_MS;
|
|
16488
|
+
this.jobPollTimeoutMs = (_d = options.jobPollTimeoutMs) !== null && _d !== void 0 ? _d : DEFAULT_JOB_POLL_TIMEOUT_MS;
|
|
16485
16489
|
}
|
|
16486
16490
|
/**
|
|
16487
16491
|
* Ask a question via the MCP chat endpoint.
|
|
@@ -16504,11 +16508,13 @@ class NavigatorChatClient {
|
|
|
16504
16508
|
}
|
|
16505
16509
|
}, auth);
|
|
16506
16510
|
const data = yield this.parseJson(response);
|
|
16511
|
+
// New async job flow (HTTP 202)
|
|
16512
|
+
if (data && data.jobId && data.status && response.status === 202) {
|
|
16513
|
+
return yield this.waitForJobCompletion(data, auth);
|
|
16514
|
+
}
|
|
16515
|
+
// Legacy synchronous flow fallback
|
|
16507
16516
|
const text = (_b = (_a = data === null || data === void 0 ? void 0 : data.Text) !== null && _a !== void 0 ? _a : data === null || data === void 0 ? void 0 : data.text) !== null && _b !== void 0 ? _b : "";
|
|
16508
|
-
const
|
|
16509
|
-
const steps = rawSteps
|
|
16510
|
-
.filter((step) => step)
|
|
16511
|
-
.map((step, idx) => (Object.assign(Object.assign({}, step), { index: typeof (step === null || step === void 0 ? void 0 : step.index) === "number" ? step.index : idx })));
|
|
16517
|
+
const steps = this.normalizeSteps(data === null || data === void 0 ? void 0 : data.steps);
|
|
16512
16518
|
return {
|
|
16513
16519
|
text,
|
|
16514
16520
|
steps,
|
|
@@ -16539,6 +16545,73 @@ class NavigatorChatClient {
|
|
|
16539
16545
|
// Use URL constructor to properly handle path joining and avoid double slashes
|
|
16540
16546
|
return new URL(path, this.baseUrl).toString();
|
|
16541
16547
|
}
|
|
16548
|
+
normalizeSteps(rawSteps) {
|
|
16549
|
+
if (!Array.isArray(rawSteps)) {
|
|
16550
|
+
return [];
|
|
16551
|
+
}
|
|
16552
|
+
return rawSteps
|
|
16553
|
+
.filter((step) => Boolean(step))
|
|
16554
|
+
.map((step, idx) => (Object.assign(Object.assign({}, step), { index: typeof (step === null || step === void 0 ? void 0 : step.index) === "number" ? step.index : idx })));
|
|
16555
|
+
}
|
|
16556
|
+
waitForJobCompletion(envelope, auth) {
|
|
16557
|
+
var _a, _b, _c, _d, _e;
|
|
16558
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16559
|
+
if (!envelope.jobId) {
|
|
16560
|
+
throw new Error("Chat job response did not include a jobId.");
|
|
16561
|
+
}
|
|
16562
|
+
const pollPath = (_a = envelope.pollUrl) !== null && _a !== void 0 ? _a : `/chat/jobs/${envelope.jobId}`;
|
|
16563
|
+
const startedAt = Date.now();
|
|
16564
|
+
while (Date.now() - startedAt < this.jobPollTimeoutMs) {
|
|
16565
|
+
const statusPayload = yield this.fetchJobStatus(pollPath, auth);
|
|
16566
|
+
const status = statusPayload === null || statusPayload === void 0 ? void 0 : statusPayload.status;
|
|
16567
|
+
if (!status) {
|
|
16568
|
+
yield this.delay(this.jobPollIntervalMs);
|
|
16569
|
+
continue;
|
|
16570
|
+
}
|
|
16571
|
+
const combinedSteps = [
|
|
16572
|
+
...(Array.isArray(statusPayload.steps) ? statusPayload.steps : []),
|
|
16573
|
+
...(Array.isArray((_b = statusPayload.result) === null || _b === void 0 ? void 0 : _b.steps) ? statusPayload.result.steps : [])
|
|
16574
|
+
];
|
|
16575
|
+
const normalizedSteps = this.normalizeSteps(combinedSteps);
|
|
16576
|
+
if (status === "COMPLETED") {
|
|
16577
|
+
const result = (_c = statusPayload.result) !== null && _c !== void 0 ? _c : {};
|
|
16578
|
+
const text = (_d = result === null || result === void 0 ? void 0 : result.text) !== null && _d !== void 0 ? _d : "";
|
|
16579
|
+
return {
|
|
16580
|
+
text,
|
|
16581
|
+
steps: normalizedSteps,
|
|
16582
|
+
raw: statusPayload,
|
|
16583
|
+
jobId: envelope.jobId,
|
|
16584
|
+
status,
|
|
16585
|
+
anonymous: Boolean((_e = result === null || result === void 0 ? void 0 : result.anonymous) !== null && _e !== void 0 ? _e : statusPayload.anonymous)
|
|
16586
|
+
};
|
|
16587
|
+
}
|
|
16588
|
+
if (status === "FAILED") {
|
|
16589
|
+
const message = statusPayload.error || "Chat job failed";
|
|
16590
|
+
const error = message.trim() || "Chat job failed";
|
|
16591
|
+
throw new Error(error);
|
|
16592
|
+
}
|
|
16593
|
+
yield this.delay(this.jobPollIntervalMs);
|
|
16594
|
+
}
|
|
16595
|
+
throw new Error("Chat job polling timed out. Please try again later.");
|
|
16596
|
+
});
|
|
16597
|
+
}
|
|
16598
|
+
fetchJobStatus(path, auth) {
|
|
16599
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16600
|
+
const response = yield this.fetchFromEndpoint(path, {
|
|
16601
|
+
method: "GET"
|
|
16602
|
+
}, auth);
|
|
16603
|
+
const payload = yield this.parseJson(response);
|
|
16604
|
+
if (!payload || !payload.jobId) {
|
|
16605
|
+
throw new Error("Failed to retrieve chat job status.");
|
|
16606
|
+
}
|
|
16607
|
+
return payload;
|
|
16608
|
+
});
|
|
16609
|
+
}
|
|
16610
|
+
delay(ms) {
|
|
16611
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16612
|
+
yield new Promise(resolve => setTimeout(resolve, ms));
|
|
16613
|
+
});
|
|
16614
|
+
}
|
|
16542
16615
|
fetchFromEndpoint(path, init, auth) {
|
|
16543
16616
|
var _a;
|
|
16544
16617
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -16761,7 +16834,7 @@ class NavigatorMcpWebSocketClient {
|
|
|
16761
16834
|
}
|
|
16762
16835
|
|
|
16763
16836
|
// This is updated with the package.json version on build.
|
|
16764
|
-
const VERSION = "6.9.
|
|
16837
|
+
const VERSION = "6.9.2";
|
|
16765
16838
|
|
|
16766
16839
|
export { VERSION, Assembly, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, GeoJson, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityAttribute, EntityHistoricData, EntityTableView, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, ProjectViewBookmarkGroup, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, UserMfaMethod, Account, AccountInvite, AccountFeatures, AccountLimits, AccountTemplate, AccountType, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, DataLabGroup, ImportAssembly, ImportCad, ImportCsv, ImportJson, ImportGeoJson, ImportKml, ImportedFile, ExportBrz, ExportUsd, Markup, Uploader, Plugin, ENVIRONMENT, DataSource, Scenario, Tracking, NavigatorChatClient, NavigatorMcpWebSocketClient };
|
|
16767
16840
|
//# sourceMappingURL=bruce-models.es5.js.map
|