@7365admin1/core 3.120.0 → 3.122.0
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 +13 -0
- package/dist/index.d.ts +144 -15
- package/dist/index.js +247 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +236 -57
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/robot-faults.e2e.test.mjs +3 -0
- package/test/e2e/robot-ounitech-company-creds.e2e.test.mjs +5 -4
- package/test/ounitech-part1.test.mjs +8 -7
- package/test/ounitech-timestamp-probe.test.mjs +64 -4
- package/test/padbot-mqtt.test.mjs +10 -4
- package/test/padbot-real-data.test.mjs +50 -0
- package/test/robot-cloud.test.mjs +4 -3
- package/test/robot-model-manifest.test.mjs +84 -0
package/dist/index.mjs
CHANGED
|
@@ -61815,7 +61815,9 @@ var ROBOT_CAPABILITIES = [
|
|
|
61815
61815
|
* watchdog. Lit only where the brand offers it AND the server switched it on
|
|
61816
61816
|
* (`PADBOT_MANUAL_DRIVE=on`); Manager-only (update-robot).
|
|
61817
61817
|
*/
|
|
61818
|
-
"manualDrive"
|
|
61818
|
+
"manualDrive",
|
|
61819
|
+
/** A heat camera: alarm and patrol photos carry a thermal picture and temperatures. Reporting only. */
|
|
61820
|
+
"thermalCamera"
|
|
61819
61821
|
];
|
|
61820
61822
|
var TIER_REQUIREMENTS = {
|
|
61821
61823
|
"full-control": [
|
|
@@ -61893,7 +61895,8 @@ function normalisePatrolPlan(raw) {
|
|
|
61893
61895
|
floorNo: Number.isInteger(route.floorNo) ? route.floorNo : null,
|
|
61894
61896
|
checkpoints: drawn,
|
|
61895
61897
|
currentCheckpoint: Number.isInteger(cur) && cur >= 0 && cur < drawn.length ? cur : null,
|
|
61896
|
-
...stops.length ? { stops } : {}
|
|
61898
|
+
...stops.length ? { stops } : {},
|
|
61899
|
+
...plainText(route.mapId, 80) ? { mapId: plainText(route.mapId, 80) } : {}
|
|
61897
61900
|
});
|
|
61898
61901
|
}
|
|
61899
61902
|
const schedule = [];
|
|
@@ -61943,6 +61946,28 @@ function commandSupported(capabilities, kind) {
|
|
|
61943
61946
|
return false;
|
|
61944
61947
|
return supports(capabilities, needed);
|
|
61945
61948
|
}
|
|
61949
|
+
var modelKey = (v) => typeof v === "string" ? v.toLowerCase().replace(/[^a-z0-9]/g, "") : "";
|
|
61950
|
+
function robotManifest(brand, reportedModel) {
|
|
61951
|
+
const b = robotBrandFor(brand);
|
|
61952
|
+
const reported = typeof reportedModel === "string" ? reportedModel.trim().slice(0, 60) : "";
|
|
61953
|
+
if (!b)
|
|
61954
|
+
return { capabilities: {}, profile: { model: reported, modelKnown: false, alarms: [], makerApp: "", makerAppOnly: [] } };
|
|
61955
|
+
const prefix = modelKey(b.brand);
|
|
61956
|
+
let key = modelKey(reported);
|
|
61957
|
+
if (prefix && key.startsWith(prefix) && key !== prefix)
|
|
61958
|
+
key = key.slice(prefix.length);
|
|
61959
|
+
const m = key ? b.models?.find((x) => x.codes.some((c) => modelKey(c) === key)) : void 0;
|
|
61960
|
+
return {
|
|
61961
|
+
capabilities: { ...b.capabilities, ...m?.capabilities ?? {} },
|
|
61962
|
+
profile: {
|
|
61963
|
+
model: m?.name ?? reported,
|
|
61964
|
+
modelKnown: Boolean(m),
|
|
61965
|
+
alarms: [...m?.alarms ?? b.info?.alarms ?? []],
|
|
61966
|
+
makerApp: m?.makerApp ?? b.info?.makerApp ?? "",
|
|
61967
|
+
makerAppOnly: [...m?.makerAppOnly ?? b.info?.makerAppOnly ?? []]
|
|
61968
|
+
}
|
|
61969
|
+
};
|
|
61970
|
+
}
|
|
61946
61971
|
var brands = /* @__PURE__ */ new Map();
|
|
61947
61972
|
function registerRobotBrand(brand) {
|
|
61948
61973
|
if (!brand?.brand)
|
|
@@ -61982,7 +62007,8 @@ function registeredRobotBrands() {
|
|
|
61982
62007
|
// brand can do ("Basic control - no battery, floor or spot clean"). The
|
|
61983
62008
|
// manifest is a property of this build, not of any client.
|
|
61984
62009
|
types: [...b.types ?? ["cleaning"]],
|
|
61985
|
-
capabilities: { ...b.capabilities }
|
|
62010
|
+
capabilities: { ...b.capabilities },
|
|
62011
|
+
models: (b.models ?? []).map((m) => ({ name: m.name, capabilities: robotManifest(b.brand, m.codes[0]).capabilities }))
|
|
61986
62012
|
}));
|
|
61987
62013
|
}
|
|
61988
62014
|
function clearRobotBrands() {
|
|
@@ -62011,10 +62037,25 @@ var ROBOT_CLOUD_TIMESTAMP_FORMATS = [
|
|
|
62011
62037
|
"unix-ms-number"
|
|
62012
62038
|
];
|
|
62013
62039
|
var OUNITECH_TIMESTAMP_FORMAT = "yyyyMMddHHmmss";
|
|
62014
|
-
|
|
62015
|
-
|
|
62016
|
-
const
|
|
62017
|
-
|
|
62040
|
+
var OUNITECH_TIMESTAMP_ZONE = "Asia/Shanghai";
|
|
62041
|
+
function zonedDateTime(now, zone) {
|
|
62042
|
+
const parts = new Intl.DateTimeFormat("en-GB", {
|
|
62043
|
+
timeZone: zone,
|
|
62044
|
+
year: "numeric",
|
|
62045
|
+
month: "2-digit",
|
|
62046
|
+
day: "2-digit",
|
|
62047
|
+
hour: "2-digit",
|
|
62048
|
+
minute: "2-digit",
|
|
62049
|
+
second: "2-digit",
|
|
62050
|
+
hourCycle: "h23"
|
|
62051
|
+
}).formatToParts(now);
|
|
62052
|
+
const get = (type) => parts.find((p) => p.type === type)?.value ?? "";
|
|
62053
|
+
return {
|
|
62054
|
+
date: `${get("year")}-${get("month")}-${get("day")}`,
|
|
62055
|
+
time: `${get("hour")}:${get("minute")}:${get("second")}`
|
|
62056
|
+
};
|
|
62057
|
+
}
|
|
62058
|
+
function robotCloudTimestamp(now = /* @__PURE__ */ new Date(), format2 = OUNITECH_TIMESTAMP_FORMAT, zone = OUNITECH_TIMESTAMP_ZONE) {
|
|
62018
62059
|
switch (format2) {
|
|
62019
62060
|
case "unix-s":
|
|
62020
62061
|
case "unix-s-number":
|
|
@@ -62022,12 +62063,18 @@ function robotCloudTimestamp(now = /* @__PURE__ */ new Date(), format2 = OUNITEC
|
|
|
62022
62063
|
case "unix-ms":
|
|
62023
62064
|
case "unix-ms-number":
|
|
62024
62065
|
return String(now.getTime());
|
|
62025
|
-
case "
|
|
62026
|
-
|
|
62027
|
-
case "iso8601":
|
|
62066
|
+
case "iso8601": {
|
|
62067
|
+
const { date, time } = zonedDateTime(now, "UTC");
|
|
62028
62068
|
return `${date}T${time}Z`;
|
|
62029
|
-
|
|
62069
|
+
}
|
|
62070
|
+
case "yyyy-MM-dd HH:mm:ss": {
|
|
62071
|
+
const { date, time } = zonedDateTime(now, zone);
|
|
62072
|
+
return `${date} ${time}`;
|
|
62073
|
+
}
|
|
62074
|
+
case "yyyyMMddHHmmss": {
|
|
62075
|
+
const { date, time } = zonedDateTime(now, zone);
|
|
62030
62076
|
return `${date}${time}`.replace(/[-:]/g, "");
|
|
62077
|
+
}
|
|
62031
62078
|
default:
|
|
62032
62079
|
throw new Error(`Robot cloud: unknown timestamp format "${format2}".`);
|
|
62033
62080
|
}
|
|
@@ -62042,8 +62089,8 @@ function robotCloudSign(appid, timestamp, path5, secret) {
|
|
|
62042
62089
|
}
|
|
62043
62090
|
return crypto10.createHash("sha1").update(robotCloudSigningString(appid, timestamp, path5, secret)).digest("hex");
|
|
62044
62091
|
}
|
|
62045
|
-
function robotCloudBody(appid, secret, path5, params = {}, now, format2 = OUNITECH_TIMESTAMP_FORMAT) {
|
|
62046
|
-
const timestamp = robotCloudTimestamp(now, format2);
|
|
62092
|
+
function robotCloudBody(appid, secret, path5, params = {}, now, format2 = OUNITECH_TIMESTAMP_FORMAT, zone = OUNITECH_TIMESTAMP_ZONE) {
|
|
62093
|
+
const timestamp = robotCloudTimestamp(now, format2, zone);
|
|
62047
62094
|
return {
|
|
62048
62095
|
appid,
|
|
62049
62096
|
timestamp: format2.endsWith("-number") ? Number(timestamp) : timestamp,
|
|
@@ -62175,9 +62222,9 @@ function planDayFromJsDay(jsDay) {
|
|
|
62175
62222
|
var ROBOT_CLOUD_DOC_CONFIRMATIONS = [
|
|
62176
62223
|
// ANSWERED 2026-09-26 (Ounitech Part 1): base URL, one appid/secret per
|
|
62177
62224
|
// company, sign = the formula with url = each endpoint's own path (the doc's
|
|
62178
|
-
// examples were a copy-paste), timestamp
|
|
62225
|
+
// examples were a copy-paste), timestamp zone proven Asia/Shanghai (UTC+8) in production. Removed from this list.
|
|
62179
62226
|
// Still open: the accepted clock-skew window.
|
|
62180
|
-
"Accepted clock-skew window for `timestamp` (UTC+
|
|
62227
|
+
"Accepted clock-skew window for `timestamp` (zone proven UTC+8 by probe; the window is not stated).",
|
|
62181
62228
|
// pixelToMetres assumes the image y-origin is top-left.
|
|
62182
62229
|
"Pixel y-origin: top-left (assumed) or bottom-left.",
|
|
62183
62230
|
// The doc labels modeFlag "1 vacuum / 2 washing / 3 dry dust mop" on the
|
|
@@ -62405,7 +62452,8 @@ function useRobotCloudService(credentials, options = {}) {
|
|
|
62405
62452
|
path5,
|
|
62406
62453
|
params,
|
|
62407
62454
|
options.now?.(),
|
|
62408
|
-
options.timestampFormat
|
|
62455
|
+
options.timestampFormat,
|
|
62456
|
+
options.timestampZone
|
|
62409
62457
|
);
|
|
62410
62458
|
const step = robotCloudStepName(path5);
|
|
62411
62459
|
let data;
|
|
@@ -62485,6 +62533,9 @@ function useRobotCloudService(credentials, options = {}) {
|
|
|
62485
62533
|
);
|
|
62486
62534
|
return data.robotList ?? [];
|
|
62487
62535
|
}
|
|
62536
|
+
async function getRobotListReply() {
|
|
62537
|
+
return post(ROBOT_CLOUD_PATHS.robotList, {}, "robotList");
|
|
62538
|
+
}
|
|
62488
62539
|
async function getMaps(robotSn) {
|
|
62489
62540
|
const data = await post(
|
|
62490
62541
|
ROBOT_CLOUD_PATHS.mapList,
|
|
@@ -62557,6 +62608,7 @@ function useRobotCloudService(credentials, options = {}) {
|
|
|
62557
62608
|
}
|
|
62558
62609
|
return {
|
|
62559
62610
|
getRobots,
|
|
62611
|
+
getRobotListReply,
|
|
62560
62612
|
getMaps,
|
|
62561
62613
|
getFileUrls,
|
|
62562
62614
|
getPlans,
|
|
@@ -62688,14 +62740,18 @@ function createOunitechAdapter(credentials, options) {
|
|
|
62688
62740
|
}
|
|
62689
62741
|
};
|
|
62690
62742
|
}
|
|
62743
|
+
var OUNITECH_BRAND_DEFINITION = {
|
|
62744
|
+
brand: OUNITECH_BRAND,
|
|
62745
|
+
displayName: "Ounitech (Q3-G / Q3-W)",
|
|
62746
|
+
capabilities: OUNITECH_CAPABILITIES,
|
|
62747
|
+
pendingCommands: OUNITECH_PENDING_COMMANDS,
|
|
62748
|
+
// The robot list carries no model, so Q3-G and Q3-W share these defaults
|
|
62749
|
+
// (their API is the same); add `models` when Ounitech reports one.
|
|
62750
|
+
info: { makerApp: "the Ounitech app", makerAppOnly: ["pausing or stopping a job", "cleaning across floors"] },
|
|
62751
|
+
create: (credentials) => createOunitechAdapter(credentials)
|
|
62752
|
+
};
|
|
62691
62753
|
function registerOunitechBrand() {
|
|
62692
|
-
registerRobotBrand(
|
|
62693
|
-
brand: OUNITECH_BRAND,
|
|
62694
|
-
displayName: "Ounitech (Q3-G / Q3-W)",
|
|
62695
|
-
capabilities: OUNITECH_CAPABILITIES,
|
|
62696
|
-
pendingCommands: OUNITECH_PENDING_COMMANDS,
|
|
62697
|
-
create: (credentials) => createOunitechAdapter(credentials)
|
|
62698
|
-
});
|
|
62754
|
+
registerRobotBrand(OUNITECH_BRAND_DEFINITION);
|
|
62699
62755
|
}
|
|
62700
62756
|
registerOunitechBrand();
|
|
62701
62757
|
|
|
@@ -63177,15 +63233,22 @@ function startDemoTracking(adapter, robotSn, onEvent, everyMs = 1200, skip) {
|
|
|
63177
63233
|
}
|
|
63178
63234
|
};
|
|
63179
63235
|
}
|
|
63236
|
+
var DEMO_BRAND_DEFINITION = {
|
|
63237
|
+
brand: DEMO_BRAND,
|
|
63238
|
+
displayName: "Demo robots (simulated)",
|
|
63239
|
+
capabilities: DEMO_CAPABILITIES,
|
|
63240
|
+
// Serial-derived demo robots are cleaning (DEMO-C-###) AND security (DEMO-S-###).
|
|
63241
|
+
types: ["cleaning", "security"],
|
|
63242
|
+
// Simulated models, so a demo fleet shows a mixed fleet's controls: the
|
|
63243
|
+
// compact CX-1 takes jobs but no point commands; the SP-1 patroller cleans nothing.
|
|
63244
|
+
models: [
|
|
63245
|
+
{ name: "Demo CX-1", codes: ["CX-1"], capabilities: { spotClean: false, navigateToPoint: false, relocalize: false } },
|
|
63246
|
+
{ name: "Demo SP-1", codes: ["SP-1"], capabilities: { spotClean: false } }
|
|
63247
|
+
],
|
|
63248
|
+
create: () => createDemoAdapter()
|
|
63249
|
+
};
|
|
63180
63250
|
function registerDemoBrand() {
|
|
63181
|
-
registerRobotBrand(
|
|
63182
|
-
brand: DEMO_BRAND,
|
|
63183
|
-
displayName: "Demo robots (simulated)",
|
|
63184
|
-
capabilities: DEMO_CAPABILITIES,
|
|
63185
|
-
// Serial-derived demo robots are cleaning (DEMO-C-###) AND security (DEMO-S-###).
|
|
63186
|
-
types: ["cleaning", "security"],
|
|
63187
|
-
create: () => createDemoAdapter()
|
|
63188
|
-
});
|
|
63251
|
+
registerRobotBrand(DEMO_BRAND_DEFINITION);
|
|
63189
63252
|
}
|
|
63190
63253
|
registerDemoBrand();
|
|
63191
63254
|
|
|
@@ -64451,11 +64514,44 @@ var PADBOT_CAPABILITIES = {
|
|
|
64451
64514
|
// §6.7 / §6.8
|
|
64452
64515
|
resolveAlerts: true,
|
|
64453
64516
|
// §6.6
|
|
64454
|
-
//
|
|
64455
|
-
|
|
64456
|
-
|
|
64457
|
-
|
|
64517
|
+
// Model-specific (see PADBOT_MODELS): the drive limits are the S2's head range,
|
|
64518
|
+
// and a heat camera is the S2's - another PadBot patrol model gets neither.
|
|
64519
|
+
manualDrive: false,
|
|
64520
|
+
thermalCamera: false
|
|
64458
64521
|
};
|
|
64522
|
+
var PADBOT_ALARMS = [
|
|
64523
|
+
"person",
|
|
64524
|
+
"high temperature",
|
|
64525
|
+
"smoke",
|
|
64526
|
+
"debris",
|
|
64527
|
+
"noise",
|
|
64528
|
+
"water on the floor",
|
|
64529
|
+
"person falling",
|
|
64530
|
+
"door open",
|
|
64531
|
+
"window open",
|
|
64532
|
+
"fire-fighting equipment"
|
|
64533
|
+
];
|
|
64534
|
+
var PADBOT_MAKER_APP_ONLY = [
|
|
64535
|
+
"patrol schedules",
|
|
64536
|
+
"maps, points and routes",
|
|
64537
|
+
"alarm thresholds and AI recognition",
|
|
64538
|
+
"lights and voice announcements",
|
|
64539
|
+
"recorded video"
|
|
64540
|
+
];
|
|
64541
|
+
var PADBOT_MODELS = [
|
|
64542
|
+
{
|
|
64543
|
+
name: "PadBot S2",
|
|
64544
|
+
codes: ["S2"],
|
|
64545
|
+
makerAppOnly: [...PADBOT_MAKER_APP_ONLY, "live thermal view"],
|
|
64546
|
+
capabilities: {
|
|
64547
|
+
thermalCamera: true,
|
|
64548
|
+
// §8.1 over MQTT, behind the server's drive watchdog; only with PADBOT_MANUAL_DRIVE=on.
|
|
64549
|
+
get manualDrive() {
|
|
64550
|
+
return padbotManualDriveEnabled();
|
|
64551
|
+
}
|
|
64552
|
+
}
|
|
64553
|
+
}
|
|
64554
|
+
];
|
|
64459
64555
|
var PADBOT_PATHS = {
|
|
64460
64556
|
robots: "/api/v1/robots/list",
|
|
64461
64557
|
states: "/api/v1/robots/states/list",
|
|
@@ -64591,6 +64687,19 @@ function padbotPlanShare(frame2, x, y) {
|
|
|
64591
64687
|
return null;
|
|
64592
64688
|
return { x: Math.round(sx * 100) / 100, y: Math.round(sy * 100) / 100 };
|
|
64593
64689
|
}
|
|
64690
|
+
function padbotCanReachMap(maps, fromMapId, toMapId) {
|
|
64691
|
+
if (typeof toMapId !== "string" || !toMapId || typeof fromMapId !== "string" || !fromMapId)
|
|
64692
|
+
return false;
|
|
64693
|
+
if (fromMapId === toMapId)
|
|
64694
|
+
return true;
|
|
64695
|
+
const list = Array.isArray(maps) ? maps : [];
|
|
64696
|
+
const group = (id) => {
|
|
64697
|
+
const g = list.find((m) => m?.mapId === id)?.mapGroup;
|
|
64698
|
+
return typeof g === "string" ? g.trim() : "";
|
|
64699
|
+
};
|
|
64700
|
+
return group(fromMapId) !== "" && group(fromMapId) === group(toMapId);
|
|
64701
|
+
}
|
|
64702
|
+
var PADBOT_OTHER_MAP_TEXT = "The robot must be on this map first.";
|
|
64594
64703
|
function padbotAlarmFault(alarm) {
|
|
64595
64704
|
if (!alarm?.alarmType)
|
|
64596
64705
|
return null;
|
|
@@ -64643,21 +64752,19 @@ function padbotPatrolPlan(paths, maps, states = {}) {
|
|
|
64643
64752
|
checkpoints: placed,
|
|
64644
64753
|
currentCheckpoint: null,
|
|
64645
64754
|
stops: placed.map((c) => c.name).filter(Boolean),
|
|
64646
|
-
|
|
64755
|
+
...typeof p?.mapId === "string" && p.mapId ? { mapId: p.mapId } : {},
|
|
64647
64756
|
_default: !!p?.isDefault
|
|
64648
64757
|
};
|
|
64649
64758
|
});
|
|
64650
64759
|
const next = walking ? nav.nextTargetPointName : null;
|
|
64651
|
-
const candidates = next ? routes.filter((r) => r.
|
|
64760
|
+
const candidates = next ? routes.filter((r) => r.mapId === currentMap && r.checkpoints.some((c) => c.name === next)) : [];
|
|
64652
64761
|
if (candidates.length === 1) {
|
|
64653
64762
|
const r = candidates[0];
|
|
64654
64763
|
r.currentCheckpoint = r.checkpoints.findIndex((c) => c.name === next);
|
|
64655
64764
|
}
|
|
64656
64765
|
routes.sort((a, b) => Number(b.currentCheckpoint !== null) - Number(a.currentCheckpoint !== null) || Number(b._default) - Number(a._default));
|
|
64657
|
-
for (const r of routes)
|
|
64658
|
-
delete r._mapId;
|
|
64766
|
+
for (const r of routes)
|
|
64659
64767
|
delete r._default;
|
|
64660
|
-
}
|
|
64661
64768
|
return { routes, schedule: [], scheduleShared: false };
|
|
64662
64769
|
}
|
|
64663
64770
|
function padbotPatrolRecord(r) {
|
|
@@ -64871,6 +64978,7 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
64871
64978
|
batteryPercent: battery,
|
|
64872
64979
|
floorNo: Number.isInteger(floor) ? floor : null,
|
|
64873
64980
|
floorKnown: Number.isInteger(floor),
|
|
64981
|
+
mapId: typeof st["1007"]?.mapId === "string" && st["1007"].mapId ? st["1007"].mapId : null,
|
|
64874
64982
|
position: null,
|
|
64875
64983
|
planPosition: null,
|
|
64876
64984
|
fault: null
|
|
@@ -64891,6 +64999,8 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
64891
64999
|
const ly = num(loc?.worldY ?? loc?.y);
|
|
64892
65000
|
if (lx !== null && ly !== null) {
|
|
64893
65001
|
robot.position = { x: lx, y: ly, theta: (num(loc.yaw ?? loc.r) ?? 0) * Math.PI / 180 };
|
|
65002
|
+
if (typeof loc.mapId === "string" && loc.mapId)
|
|
65003
|
+
robot.mapId = loc.mapId;
|
|
64894
65004
|
const map = await maps(robotSn).then((all) => (all ?? []).find((m) => m.mapId === (loc.mapId ?? st["1007"]?.mapId))).catch(() => null);
|
|
64895
65005
|
robot.planPosition = padbotPlanShare(map, lx, ly);
|
|
64896
65006
|
}
|
|
@@ -64950,9 +65060,13 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
64950
65060
|
case "relocalize":
|
|
64951
65061
|
await call2(PADBOT_PATHS.relocate, { ...sn, worldX: command.x, worldY: command.y });
|
|
64952
65062
|
return;
|
|
64953
|
-
case "go-to-point":
|
|
65063
|
+
case "go-to-point": {
|
|
65064
|
+
const [st, all] = await Promise.all([states(robotSn), maps(robotSn).catch(() => [])]);
|
|
65065
|
+
if (!padbotCanReachMap(all, st?.["1007"]?.mapId, command.mapId))
|
|
65066
|
+
throw new BadRequestError135(PADBOT_OTHER_MAP_TEXT);
|
|
64954
65067
|
await call2(PADBOT_PATHS.navigateTarget, { ...sn, mapId: command.mapId, targetPointId: command.targetPointId });
|
|
64955
65068
|
return;
|
|
65069
|
+
}
|
|
64956
65070
|
default:
|
|
64957
65071
|
throw new BadRequestError135(`PadBot robots cannot "${command.kind}" through the PadBot API.`);
|
|
64958
65072
|
}
|
|
@@ -65057,18 +65171,26 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65057
65171
|
}
|
|
65058
65172
|
};
|
|
65059
65173
|
}
|
|
65174
|
+
var PADBOT_BRAND_DEFINITION = {
|
|
65175
|
+
brand: PADBOT_BRAND,
|
|
65176
|
+
displayName: PADBOT_DISPLAY_NAME,
|
|
65177
|
+
capabilities: PADBOT_CAPABILITIES,
|
|
65178
|
+
types: ["security"],
|
|
65179
|
+
info: { alarms: [...PADBOT_ALARMS], makerApp: "the PadBot app", makerAppOnly: [...PADBOT_MAKER_APP_ONLY] },
|
|
65180
|
+
models: PADBOT_MODELS,
|
|
65181
|
+
create: (credentials) => createPadbotAdapter(credentials)
|
|
65182
|
+
};
|
|
65060
65183
|
function registerPadbotBrand() {
|
|
65061
|
-
registerRobotBrand(
|
|
65062
|
-
brand: PADBOT_BRAND,
|
|
65063
|
-
displayName: PADBOT_DISPLAY_NAME,
|
|
65064
|
-
capabilities: PADBOT_CAPABILITIES,
|
|
65065
|
-
types: ["security"],
|
|
65066
|
-
create: (credentials) => createPadbotAdapter(credentials)
|
|
65067
|
-
});
|
|
65184
|
+
registerRobotBrand(PADBOT_BRAND_DEFINITION);
|
|
65068
65185
|
}
|
|
65069
65186
|
registerPadbotBrand();
|
|
65070
65187
|
|
|
65071
65188
|
// src/services/robot-fleet.service.ts
|
|
65189
|
+
var OUNITECH_REGION_BASE_URLS = [
|
|
65190
|
+
"https://app.frankfurt.robotcloud.top",
|
|
65191
|
+
"https://app.singapore.robotcloud.top",
|
|
65192
|
+
"https://app.robotcloud.top"
|
|
65193
|
+
];
|
|
65072
65194
|
var TIMESTAMP_OFFSET_CANDIDATES = [
|
|
65073
65195
|
{ offsetMinutes: 120, label: "UTC+2 (Frankfurt summer time)" },
|
|
65074
65196
|
{ offsetMinutes: 60, label: "UTC+1 (Frankfurt winter time)" },
|
|
@@ -65151,10 +65273,11 @@ function useRobotFleetService(deps) {
|
|
|
65151
65273
|
batteryPercent: null,
|
|
65152
65274
|
floorNo: null,
|
|
65153
65275
|
floorKnown: false,
|
|
65276
|
+
mapId: null,
|
|
65154
65277
|
position: null,
|
|
65155
65278
|
planPosition: null,
|
|
65156
65279
|
fault: null,
|
|
65157
|
-
|
|
65280
|
+
...robotManifest(brand)
|
|
65158
65281
|
};
|
|
65159
65282
|
}
|
|
65160
65283
|
const fault = found.fault?.code ? found.fault : null;
|
|
@@ -65165,6 +65288,7 @@ function useRobotFleetService(deps) {
|
|
|
65165
65288
|
}
|
|
65166
65289
|
}
|
|
65167
65290
|
const free = found.mode === "IDLE" || found.mode === "CHARGED";
|
|
65291
|
+
const manifest = robotManifest(brand, found.model);
|
|
65168
65292
|
return {
|
|
65169
65293
|
id,
|
|
65170
65294
|
name: robot.name,
|
|
@@ -65177,15 +65301,17 @@ function useRobotFleetService(deps) {
|
|
|
65177
65301
|
dispatchable: (
|
|
65178
65302
|
// A faulted robot is not given a job however idle its mode reads. An
|
|
65179
65303
|
// alarm (smoke seen, door open) is not a machine fault: the patrol goes on.
|
|
65180
|
-
found.online && free && (!fault || fault.alarm === true) && commandSupported(
|
|
65304
|
+
found.online && free && (!fault || fault.alarm === true) && commandSupported(manifest.capabilities, "full")
|
|
65181
65305
|
),
|
|
65182
65306
|
batteryPercent: found.batteryPercent ?? null,
|
|
65183
65307
|
floorNo: found.floorNo ?? null,
|
|
65184
65308
|
floorKnown: found.floorKnown === true,
|
|
65309
|
+
mapId: typeof found.mapId === "string" && found.mapId ? found.mapId : null,
|
|
65185
65310
|
position: found.position ?? null,
|
|
65186
65311
|
planPosition: found.planPosition ?? null,
|
|
65187
65312
|
fault,
|
|
65188
|
-
capabilities:
|
|
65313
|
+
capabilities: manifest.capabilities,
|
|
65314
|
+
profile: manifest.profile
|
|
65189
65315
|
};
|
|
65190
65316
|
}
|
|
65191
65317
|
async function getMaps(robot) {
|
|
@@ -65235,6 +65361,9 @@ function useRobotFleetService(deps) {
|
|
|
65235
65361
|
return adapter.sendCommand(robotSn, command);
|
|
65236
65362
|
}
|
|
65237
65363
|
const state = await getFleetRobot(robot);
|
|
65364
|
+
if (!commandSupported(state.capabilities, command.kind)) {
|
|
65365
|
+
throw new BadRequestError136(`${state.profile.model || adapter.displayName} does not support "${command.kind}" through its API.`);
|
|
65366
|
+
}
|
|
65238
65367
|
if (command.kind === "pause" || command.kind === "resume" || command.kind === "cancel" || command.kind === "relocalize" || command.kind === "patrol-resume") {
|
|
65239
65368
|
const need = command.kind === "pause" ? "WORKING" : command.kind === "resume" ? "PAUSED" : null;
|
|
65240
65369
|
if (!state.online || need && state.mode !== need) {
|
|
@@ -65441,6 +65570,43 @@ function useRobotFleetService(deps) {
|
|
|
65441
65570
|
lastTimestampProbe.set(key, Date.now());
|
|
65442
65571
|
return { id, pair };
|
|
65443
65572
|
}
|
|
65573
|
+
async function probeRegions(robot) {
|
|
65574
|
+
const { id, pair } = probeGate(robot, "region");
|
|
65575
|
+
const hosts = [];
|
|
65576
|
+
for (const baseUrl of deps?.regionBaseUrls ?? OUNITECH_REGION_BASE_URLS) {
|
|
65577
|
+
try {
|
|
65578
|
+
const reply = await useRobotCloudService(pair, { ...deps?.cloudOptions, baseUrl }).getRobotListReply();
|
|
65579
|
+
const replyShape = {};
|
|
65580
|
+
for (const [k, v] of Object.entries(reply)) {
|
|
65581
|
+
replyShape[k] = Array.isArray(v) ? `list of ${v.length}` : v === null ? "null" : typeof v;
|
|
65582
|
+
}
|
|
65583
|
+
const list = Array.isArray(reply.robotList) ? reply.robotList : [];
|
|
65584
|
+
const robots = list.map((r) => ({
|
|
65585
|
+
robotSn: String(r?.robotSn ?? ""),
|
|
65586
|
+
robotName: String(r?.robotName ?? ""),
|
|
65587
|
+
online: r?.onlineFlag === true,
|
|
65588
|
+
statusName: String(r?.statusName ?? "")
|
|
65589
|
+
}));
|
|
65590
|
+
hosts.push({
|
|
65591
|
+
host: cloudHost(baseUrl),
|
|
65592
|
+
ok: true,
|
|
65593
|
+
detail: `Signed in. Lists ${robots.length} robot${robots.length === 1 ? "" : "s"}.`,
|
|
65594
|
+
replyShape,
|
|
65595
|
+
robots
|
|
65596
|
+
});
|
|
65597
|
+
} catch (e) {
|
|
65598
|
+
hosts.push({ host: cloudHost(baseUrl), ok: false, ...describeFailure(e) });
|
|
65599
|
+
}
|
|
65600
|
+
}
|
|
65601
|
+
const withRobots = hosts.filter((h) => h.robots?.length);
|
|
65602
|
+
return {
|
|
65603
|
+
robotId: id,
|
|
65604
|
+
configuredHost: cloudHost(deps?.cloudOptions?.baseUrl ?? ROBOT_CLOUD_BASE_URL),
|
|
65605
|
+
hosts,
|
|
65606
|
+
summary: withRobots.length ? `Robots found on ${withRobots.map((h) => `${h.host} (${h.robots.length})`).join(", ")}.` : hosts.some((h) => h.ok) ? "Signed in, but no region lists a robot for this AppID - Ounitech must bind the robot to this AppID's account." : "No region accepted this AppID.",
|
|
65607
|
+
checkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
65608
|
+
};
|
|
65609
|
+
}
|
|
65444
65610
|
async function probeTimestampOffset(robot) {
|
|
65445
65611
|
const { id, pair } = probeGate(robot, "offset");
|
|
65446
65612
|
const baseUrl = deps?.cloudOptions?.baseUrl ?? ROBOT_CLOUD_BASE_URL;
|
|
@@ -65454,9 +65620,9 @@ function useRobotFleetService(deps) {
|
|
|
65454
65620
|
let accepted = null;
|
|
65455
65621
|
for (const c of [{ offsetMinutes: 0, label: "UTC (current)" }, ...TIMESTAMP_OFFSET_CANDIDATES]) {
|
|
65456
65622
|
const now = () => new Date(Date.now() + (skewMs ?? 0) + c.offsetMinutes * 6e4);
|
|
65457
|
-
const sent = robotCloudTimestamp(now(), "yyyyMMddHHmmss");
|
|
65623
|
+
const sent = robotCloudTimestamp(now(), "yyyyMMddHHmmss", "UTC");
|
|
65458
65624
|
try {
|
|
65459
|
-
const robots = await useRobotCloudService(pair, { ...deps?.cloudOptions, timestampFormat: "yyyyMMddHHmmss", now, onReply }).getRobots();
|
|
65625
|
+
const robots = await useRobotCloudService(pair, { ...deps?.cloudOptions, timestampFormat: "yyyyMMddHHmmss", timestampZone: "UTC", now, onReply }).getRobots();
|
|
65460
65626
|
attempts.push({ ...c, sent, ok: true, detail: `Accepted. The account lists ${robots.length} robot${robots.length === 1 ? "" : "s"}.` });
|
|
65461
65627
|
accepted = c.offsetMinutes;
|
|
65462
65628
|
break;
|
|
@@ -65510,6 +65676,7 @@ function useRobotFleetService(deps) {
|
|
|
65510
65676
|
diagnose,
|
|
65511
65677
|
probeTimestampFormat,
|
|
65512
65678
|
probeTimestampOffset,
|
|
65679
|
+
probeRegions,
|
|
65513
65680
|
getLiveVideo,
|
|
65514
65681
|
resolveAlerts,
|
|
65515
65682
|
getPatrolHistory,
|
|
@@ -68419,7 +68586,7 @@ function useRobotFleetController(deps) {
|
|
|
68419
68586
|
return;
|
|
68420
68587
|
heardAt = Date.now();
|
|
68421
68588
|
void Promise.resolve(adapter.getMaps?.(robotSn) ?? []).then((maps) => padbotPlanShare((maps ?? []).find((m) => m?.mapId === e.mapId), e.x, e.y)).catch(() => null).then(
|
|
68422
|
-
(planPosition) => send2({ type: "pose", pose: { x: e.x, y: e.y, theta: (e.yawDeg ?? 0) * Math.PI / 180 }, planPosition, at: Date.now() })
|
|
68589
|
+
(planPosition) => send2({ type: "pose", pose: { x: e.x, y: e.y, theta: (e.yawDeg ?? 0) * Math.PI / 180 }, planPosition, mapId: e.mapId ?? null, at: Date.now() })
|
|
68423
68590
|
);
|
|
68424
68591
|
});
|
|
68425
68592
|
}
|
|
@@ -68571,14 +68738,14 @@ function useRobotFleetController(deps) {
|
|
|
68571
68738
|
try {
|
|
68572
68739
|
await requirePlatformStaff(req, CROSS_CLIENT_GRANT);
|
|
68573
68740
|
const probe = req.query.probe;
|
|
68574
|
-
if (probe !== void 0 && probe !== "timestamp" && probe !== "timestamp-offset") {
|
|
68575
|
-
return fail(next, new BadRequestError139('probe must be "timestamp"
|
|
68741
|
+
if (probe !== void 0 && probe !== "timestamp" && probe !== "timestamp-offset" && probe !== "region") {
|
|
68742
|
+
return fail(next, new BadRequestError139('probe must be "timestamp", "timestamp-offset" or "region".'));
|
|
68576
68743
|
}
|
|
68577
68744
|
const robot = await entitleRobot(req, req.params.id);
|
|
68578
68745
|
res.set("Cache-Control", "no-store");
|
|
68579
68746
|
const fleet2 = getFleet2();
|
|
68580
68747
|
res.json(
|
|
68581
|
-
probe === "timestamp" ? await fleet2.probeTimestampFormat(robot) : probe === "timestamp-offset" ? await fleet2.probeTimestampOffset(robot) : await fleet2.diagnose(robot)
|
|
68748
|
+
probe === "timestamp" ? await fleet2.probeTimestampFormat(robot) : probe === "timestamp-offset" ? await fleet2.probeTimestampOffset(robot) : probe === "region" ? await fleet2.probeRegions(robot) : await fleet2.diagnose(robot)
|
|
68582
68749
|
);
|
|
68583
68750
|
} catch (error) {
|
|
68584
68751
|
fail(next, error);
|
|
@@ -69836,6 +70003,7 @@ async function readLiveItems(robots) {
|
|
|
69836
70003
|
planPosition: s.planPosition,
|
|
69837
70004
|
fault: s.fault,
|
|
69838
70005
|
capabilities: s.capabilities,
|
|
70006
|
+
profile: s.profile,
|
|
69839
70007
|
lastSeenAt: seen2 ? new Date(seen2) : null
|
|
69840
70008
|
});
|
|
69841
70009
|
} catch (e) {
|
|
@@ -104341,6 +104509,7 @@ export {
|
|
|
104341
104509
|
DEFAULT_SITE_TIMEZONE,
|
|
104342
104510
|
DEMO_ADD_MAX,
|
|
104343
104511
|
DEMO_BRAND,
|
|
104512
|
+
DEMO_BRAND_DEFINITION,
|
|
104344
104513
|
DEMO_CAPABILITIES,
|
|
104345
104514
|
DEMO_FAULT_ROBOT,
|
|
104346
104515
|
DEMO_ROUTES,
|
|
@@ -104506,23 +104675,31 @@ export {
|
|
|
104506
104675
|
ORG_OWNER_REPAIR_DEFAULT,
|
|
104507
104676
|
ORG_OWNER_REPAIR_OFF_REASON,
|
|
104508
104677
|
OUNITECH_BRAND,
|
|
104678
|
+
OUNITECH_BRAND_DEFINITION,
|
|
104509
104679
|
OUNITECH_CAPABILITIES,
|
|
104510
104680
|
OUNITECH_PENDING_COMMANDS,
|
|
104681
|
+
OUNITECH_REGION_BASE_URLS,
|
|
104511
104682
|
OUNITECH_TIMESTAMP_FORMAT,
|
|
104683
|
+
OUNITECH_TIMESTAMP_ZONE,
|
|
104512
104684
|
OpenRmfError,
|
|
104513
104685
|
OrgNature,
|
|
104514
104686
|
OvernightParkingRequestSort,
|
|
104515
104687
|
OvernightParkingRequestStatus,
|
|
104516
104688
|
PADBOT_ACTION_TEXT,
|
|
104689
|
+
PADBOT_ALARMS,
|
|
104517
104690
|
PADBOT_ALARM_POLL_MS,
|
|
104518
104691
|
PADBOT_ALARM_TEXT,
|
|
104519
104692
|
PADBOT_BRAND,
|
|
104693
|
+
PADBOT_BRAND_DEFINITION,
|
|
104520
104694
|
PADBOT_CAPABILITIES,
|
|
104521
104695
|
PADBOT_DISPLAY_NAME,
|
|
104522
104696
|
PADBOT_LIVE_POSE_MS,
|
|
104697
|
+
PADBOT_MAKER_APP_ONLY,
|
|
104698
|
+
PADBOT_MODELS,
|
|
104523
104699
|
PADBOT_MOTION,
|
|
104524
104700
|
PADBOT_MQTT_SYNC_MS,
|
|
104525
104701
|
PADBOT_ONLINE_WINDOW_MS,
|
|
104702
|
+
PADBOT_OTHER_MAP_TEXT,
|
|
104526
104703
|
PADBOT_PATHS,
|
|
104527
104704
|
PATROL_CCTV_CAMERA_FILTER,
|
|
104528
104705
|
PATROL_EMAIL_MAX_LOGS,
|
|
@@ -104858,6 +105035,7 @@ export {
|
|
|
104858
105035
|
padbotAlarmPlace,
|
|
104859
105036
|
padbotAlarmPollEnabled,
|
|
104860
105037
|
padbotBaseUrl,
|
|
105038
|
+
padbotCanReachMap,
|
|
104861
105039
|
padbotCheckpointVisit,
|
|
104862
105040
|
padbotCommandLog,
|
|
104863
105041
|
padbotDriveBlock,
|
|
@@ -104947,6 +105125,7 @@ export {
|
|
|
104947
105125
|
robotCloudTimestamp,
|
|
104948
105126
|
robotCredentialsKey,
|
|
104949
105127
|
robotFaultSweepConfig,
|
|
105128
|
+
robotManifest,
|
|
104950
105129
|
robotMode,
|
|
104951
105130
|
robotModeFromList,
|
|
104952
105131
|
robotSchema,
|