@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.js
CHANGED
|
@@ -82,6 +82,7 @@ __export(src_exports, {
|
|
|
82
82
|
DEFAULT_SITE_TIMEZONE: () => DEFAULT_SITE_TIMEZONE,
|
|
83
83
|
DEMO_ADD_MAX: () => DEMO_ADD_MAX,
|
|
84
84
|
DEMO_BRAND: () => DEMO_BRAND,
|
|
85
|
+
DEMO_BRAND_DEFINITION: () => DEMO_BRAND_DEFINITION,
|
|
85
86
|
DEMO_CAPABILITIES: () => DEMO_CAPABILITIES,
|
|
86
87
|
DEMO_FAULT_ROBOT: () => DEMO_FAULT_ROBOT,
|
|
87
88
|
DEMO_ROUTES: () => DEMO_ROUTES,
|
|
@@ -247,23 +248,31 @@ __export(src_exports, {
|
|
|
247
248
|
ORG_OWNER_REPAIR_DEFAULT: () => ORG_OWNER_REPAIR_DEFAULT,
|
|
248
249
|
ORG_OWNER_REPAIR_OFF_REASON: () => ORG_OWNER_REPAIR_OFF_REASON,
|
|
249
250
|
OUNITECH_BRAND: () => OUNITECH_BRAND,
|
|
251
|
+
OUNITECH_BRAND_DEFINITION: () => OUNITECH_BRAND_DEFINITION,
|
|
250
252
|
OUNITECH_CAPABILITIES: () => OUNITECH_CAPABILITIES,
|
|
251
253
|
OUNITECH_PENDING_COMMANDS: () => OUNITECH_PENDING_COMMANDS,
|
|
254
|
+
OUNITECH_REGION_BASE_URLS: () => OUNITECH_REGION_BASE_URLS,
|
|
252
255
|
OUNITECH_TIMESTAMP_FORMAT: () => OUNITECH_TIMESTAMP_FORMAT,
|
|
256
|
+
OUNITECH_TIMESTAMP_ZONE: () => OUNITECH_TIMESTAMP_ZONE,
|
|
253
257
|
OpenRmfError: () => OpenRmfError,
|
|
254
258
|
OrgNature: () => OrgNature,
|
|
255
259
|
OvernightParkingRequestSort: () => OvernightParkingRequestSort,
|
|
256
260
|
OvernightParkingRequestStatus: () => OvernightParkingRequestStatus,
|
|
257
261
|
PADBOT_ACTION_TEXT: () => PADBOT_ACTION_TEXT,
|
|
262
|
+
PADBOT_ALARMS: () => PADBOT_ALARMS,
|
|
258
263
|
PADBOT_ALARM_POLL_MS: () => PADBOT_ALARM_POLL_MS,
|
|
259
264
|
PADBOT_ALARM_TEXT: () => PADBOT_ALARM_TEXT,
|
|
260
265
|
PADBOT_BRAND: () => PADBOT_BRAND,
|
|
266
|
+
PADBOT_BRAND_DEFINITION: () => PADBOT_BRAND_DEFINITION,
|
|
261
267
|
PADBOT_CAPABILITIES: () => PADBOT_CAPABILITIES,
|
|
262
268
|
PADBOT_DISPLAY_NAME: () => PADBOT_DISPLAY_NAME,
|
|
263
269
|
PADBOT_LIVE_POSE_MS: () => PADBOT_LIVE_POSE_MS,
|
|
270
|
+
PADBOT_MAKER_APP_ONLY: () => PADBOT_MAKER_APP_ONLY,
|
|
271
|
+
PADBOT_MODELS: () => PADBOT_MODELS,
|
|
264
272
|
PADBOT_MOTION: () => PADBOT_MOTION,
|
|
265
273
|
PADBOT_MQTT_SYNC_MS: () => PADBOT_MQTT_SYNC_MS,
|
|
266
274
|
PADBOT_ONLINE_WINDOW_MS: () => PADBOT_ONLINE_WINDOW_MS,
|
|
275
|
+
PADBOT_OTHER_MAP_TEXT: () => PADBOT_OTHER_MAP_TEXT,
|
|
267
276
|
PADBOT_PATHS: () => PADBOT_PATHS,
|
|
268
277
|
PATROL_CCTV_CAMERA_FILTER: () => PATROL_CCTV_CAMERA_FILTER,
|
|
269
278
|
PATROL_EMAIL_MAX_LOGS: () => PATROL_EMAIL_MAX_LOGS,
|
|
@@ -599,6 +608,7 @@ __export(src_exports, {
|
|
|
599
608
|
padbotAlarmPlace: () => padbotAlarmPlace,
|
|
600
609
|
padbotAlarmPollEnabled: () => padbotAlarmPollEnabled,
|
|
601
610
|
padbotBaseUrl: () => padbotBaseUrl,
|
|
611
|
+
padbotCanReachMap: () => padbotCanReachMap,
|
|
602
612
|
padbotCheckpointVisit: () => padbotCheckpointVisit,
|
|
603
613
|
padbotCommandLog: () => padbotCommandLog,
|
|
604
614
|
padbotDriveBlock: () => padbotDriveBlock,
|
|
@@ -688,6 +698,7 @@ __export(src_exports, {
|
|
|
688
698
|
robotCloudTimestamp: () => robotCloudTimestamp,
|
|
689
699
|
robotCredentialsKey: () => robotCredentialsKey,
|
|
690
700
|
robotFaultSweepConfig: () => robotFaultSweepConfig,
|
|
701
|
+
robotManifest: () => robotManifest,
|
|
691
702
|
robotMode: () => robotMode,
|
|
692
703
|
robotModeFromList: () => robotModeFromList,
|
|
693
704
|
robotSchema: () => robotSchema,
|
|
@@ -62456,7 +62467,9 @@ var ROBOT_CAPABILITIES = [
|
|
|
62456
62467
|
* watchdog. Lit only where the brand offers it AND the server switched it on
|
|
62457
62468
|
* (`PADBOT_MANUAL_DRIVE=on`); Manager-only (update-robot).
|
|
62458
62469
|
*/
|
|
62459
|
-
"manualDrive"
|
|
62470
|
+
"manualDrive",
|
|
62471
|
+
/** A heat camera: alarm and patrol photos carry a thermal picture and temperatures. Reporting only. */
|
|
62472
|
+
"thermalCamera"
|
|
62460
62473
|
];
|
|
62461
62474
|
var TIER_REQUIREMENTS = {
|
|
62462
62475
|
"full-control": [
|
|
@@ -62534,7 +62547,8 @@ function normalisePatrolPlan(raw) {
|
|
|
62534
62547
|
floorNo: Number.isInteger(route.floorNo) ? route.floorNo : null,
|
|
62535
62548
|
checkpoints: drawn,
|
|
62536
62549
|
currentCheckpoint: Number.isInteger(cur) && cur >= 0 && cur < drawn.length ? cur : null,
|
|
62537
|
-
...stops.length ? { stops } : {}
|
|
62550
|
+
...stops.length ? { stops } : {},
|
|
62551
|
+
...plainText(route.mapId, 80) ? { mapId: plainText(route.mapId, 80) } : {}
|
|
62538
62552
|
});
|
|
62539
62553
|
}
|
|
62540
62554
|
const schedule = [];
|
|
@@ -62584,6 +62598,28 @@ function commandSupported(capabilities, kind) {
|
|
|
62584
62598
|
return false;
|
|
62585
62599
|
return supports(capabilities, needed);
|
|
62586
62600
|
}
|
|
62601
|
+
var modelKey = (v) => typeof v === "string" ? v.toLowerCase().replace(/[^a-z0-9]/g, "") : "";
|
|
62602
|
+
function robotManifest(brand, reportedModel) {
|
|
62603
|
+
const b = robotBrandFor(brand);
|
|
62604
|
+
const reported = typeof reportedModel === "string" ? reportedModel.trim().slice(0, 60) : "";
|
|
62605
|
+
if (!b)
|
|
62606
|
+
return { capabilities: {}, profile: { model: reported, modelKnown: false, alarms: [], makerApp: "", makerAppOnly: [] } };
|
|
62607
|
+
const prefix = modelKey(b.brand);
|
|
62608
|
+
let key = modelKey(reported);
|
|
62609
|
+
if (prefix && key.startsWith(prefix) && key !== prefix)
|
|
62610
|
+
key = key.slice(prefix.length);
|
|
62611
|
+
const m = key ? b.models?.find((x) => x.codes.some((c) => modelKey(c) === key)) : void 0;
|
|
62612
|
+
return {
|
|
62613
|
+
capabilities: { ...b.capabilities, ...m?.capabilities ?? {} },
|
|
62614
|
+
profile: {
|
|
62615
|
+
model: m?.name ?? reported,
|
|
62616
|
+
modelKnown: Boolean(m),
|
|
62617
|
+
alarms: [...m?.alarms ?? b.info?.alarms ?? []],
|
|
62618
|
+
makerApp: m?.makerApp ?? b.info?.makerApp ?? "",
|
|
62619
|
+
makerAppOnly: [...m?.makerAppOnly ?? b.info?.makerAppOnly ?? []]
|
|
62620
|
+
}
|
|
62621
|
+
};
|
|
62622
|
+
}
|
|
62587
62623
|
var brands = /* @__PURE__ */ new Map();
|
|
62588
62624
|
function registerRobotBrand(brand) {
|
|
62589
62625
|
if (!brand?.brand)
|
|
@@ -62623,7 +62659,8 @@ function registeredRobotBrands() {
|
|
|
62623
62659
|
// brand can do ("Basic control - no battery, floor or spot clean"). The
|
|
62624
62660
|
// manifest is a property of this build, not of any client.
|
|
62625
62661
|
types: [...b.types ?? ["cleaning"]],
|
|
62626
|
-
capabilities: { ...b.capabilities }
|
|
62662
|
+
capabilities: { ...b.capabilities },
|
|
62663
|
+
models: (b.models ?? []).map((m) => ({ name: m.name, capabilities: robotManifest(b.brand, m.codes[0]).capabilities }))
|
|
62627
62664
|
}));
|
|
62628
62665
|
}
|
|
62629
62666
|
function clearRobotBrands() {
|
|
@@ -62652,10 +62689,25 @@ var ROBOT_CLOUD_TIMESTAMP_FORMATS = [
|
|
|
62652
62689
|
"unix-ms-number"
|
|
62653
62690
|
];
|
|
62654
62691
|
var OUNITECH_TIMESTAMP_FORMAT = "yyyyMMddHHmmss";
|
|
62655
|
-
|
|
62656
|
-
|
|
62657
|
-
const
|
|
62658
|
-
|
|
62692
|
+
var OUNITECH_TIMESTAMP_ZONE = "Asia/Shanghai";
|
|
62693
|
+
function zonedDateTime(now, zone) {
|
|
62694
|
+
const parts = new Intl.DateTimeFormat("en-GB", {
|
|
62695
|
+
timeZone: zone,
|
|
62696
|
+
year: "numeric",
|
|
62697
|
+
month: "2-digit",
|
|
62698
|
+
day: "2-digit",
|
|
62699
|
+
hour: "2-digit",
|
|
62700
|
+
minute: "2-digit",
|
|
62701
|
+
second: "2-digit",
|
|
62702
|
+
hourCycle: "h23"
|
|
62703
|
+
}).formatToParts(now);
|
|
62704
|
+
const get = (type) => parts.find((p) => p.type === type)?.value ?? "";
|
|
62705
|
+
return {
|
|
62706
|
+
date: `${get("year")}-${get("month")}-${get("day")}`,
|
|
62707
|
+
time: `${get("hour")}:${get("minute")}:${get("second")}`
|
|
62708
|
+
};
|
|
62709
|
+
}
|
|
62710
|
+
function robotCloudTimestamp(now = /* @__PURE__ */ new Date(), format2 = OUNITECH_TIMESTAMP_FORMAT, zone = OUNITECH_TIMESTAMP_ZONE) {
|
|
62659
62711
|
switch (format2) {
|
|
62660
62712
|
case "unix-s":
|
|
62661
62713
|
case "unix-s-number":
|
|
@@ -62663,12 +62715,18 @@ function robotCloudTimestamp(now = /* @__PURE__ */ new Date(), format2 = OUNITEC
|
|
|
62663
62715
|
case "unix-ms":
|
|
62664
62716
|
case "unix-ms-number":
|
|
62665
62717
|
return String(now.getTime());
|
|
62666
|
-
case "
|
|
62667
|
-
|
|
62668
|
-
case "iso8601":
|
|
62718
|
+
case "iso8601": {
|
|
62719
|
+
const { date, time } = zonedDateTime(now, "UTC");
|
|
62669
62720
|
return `${date}T${time}Z`;
|
|
62670
|
-
|
|
62721
|
+
}
|
|
62722
|
+
case "yyyy-MM-dd HH:mm:ss": {
|
|
62723
|
+
const { date, time } = zonedDateTime(now, zone);
|
|
62724
|
+
return `${date} ${time}`;
|
|
62725
|
+
}
|
|
62726
|
+
case "yyyyMMddHHmmss": {
|
|
62727
|
+
const { date, time } = zonedDateTime(now, zone);
|
|
62671
62728
|
return `${date}${time}`.replace(/[-:]/g, "");
|
|
62729
|
+
}
|
|
62672
62730
|
default:
|
|
62673
62731
|
throw new Error(`Robot cloud: unknown timestamp format "${format2}".`);
|
|
62674
62732
|
}
|
|
@@ -62683,8 +62741,8 @@ function robotCloudSign(appid, timestamp, path5, secret) {
|
|
|
62683
62741
|
}
|
|
62684
62742
|
return crypto10.createHash("sha1").update(robotCloudSigningString(appid, timestamp, path5, secret)).digest("hex");
|
|
62685
62743
|
}
|
|
62686
|
-
function robotCloudBody(appid, secret, path5, params = {}, now, format2 = OUNITECH_TIMESTAMP_FORMAT) {
|
|
62687
|
-
const timestamp = robotCloudTimestamp(now, format2);
|
|
62744
|
+
function robotCloudBody(appid, secret, path5, params = {}, now, format2 = OUNITECH_TIMESTAMP_FORMAT, zone = OUNITECH_TIMESTAMP_ZONE) {
|
|
62745
|
+
const timestamp = robotCloudTimestamp(now, format2, zone);
|
|
62688
62746
|
return {
|
|
62689
62747
|
appid,
|
|
62690
62748
|
timestamp: format2.endsWith("-number") ? Number(timestamp) : timestamp,
|
|
@@ -62816,9 +62874,9 @@ function planDayFromJsDay(jsDay) {
|
|
|
62816
62874
|
var ROBOT_CLOUD_DOC_CONFIRMATIONS = [
|
|
62817
62875
|
// ANSWERED 2026-09-26 (Ounitech Part 1): base URL, one appid/secret per
|
|
62818
62876
|
// company, sign = the formula with url = each endpoint's own path (the doc's
|
|
62819
|
-
// examples were a copy-paste), timestamp
|
|
62877
|
+
// examples were a copy-paste), timestamp zone proven Asia/Shanghai (UTC+8) in production. Removed from this list.
|
|
62820
62878
|
// Still open: the accepted clock-skew window.
|
|
62821
|
-
"Accepted clock-skew window for `timestamp` (UTC+
|
|
62879
|
+
"Accepted clock-skew window for `timestamp` (zone proven UTC+8 by probe; the window is not stated).",
|
|
62822
62880
|
// pixelToMetres assumes the image y-origin is top-left.
|
|
62823
62881
|
"Pixel y-origin: top-left (assumed) or bottom-left.",
|
|
62824
62882
|
// The doc labels modeFlag "1 vacuum / 2 washing / 3 dry dust mop" on the
|
|
@@ -63046,7 +63104,8 @@ function useRobotCloudService(credentials, options = {}) {
|
|
|
63046
63104
|
path5,
|
|
63047
63105
|
params,
|
|
63048
63106
|
options.now?.(),
|
|
63049
|
-
options.timestampFormat
|
|
63107
|
+
options.timestampFormat,
|
|
63108
|
+
options.timestampZone
|
|
63050
63109
|
);
|
|
63051
63110
|
const step = robotCloudStepName(path5);
|
|
63052
63111
|
let data;
|
|
@@ -63126,6 +63185,9 @@ function useRobotCloudService(credentials, options = {}) {
|
|
|
63126
63185
|
);
|
|
63127
63186
|
return data.robotList ?? [];
|
|
63128
63187
|
}
|
|
63188
|
+
async function getRobotListReply() {
|
|
63189
|
+
return post(ROBOT_CLOUD_PATHS.robotList, {}, "robotList");
|
|
63190
|
+
}
|
|
63129
63191
|
async function getMaps(robotSn) {
|
|
63130
63192
|
const data = await post(
|
|
63131
63193
|
ROBOT_CLOUD_PATHS.mapList,
|
|
@@ -63198,6 +63260,7 @@ function useRobotCloudService(credentials, options = {}) {
|
|
|
63198
63260
|
}
|
|
63199
63261
|
return {
|
|
63200
63262
|
getRobots,
|
|
63263
|
+
getRobotListReply,
|
|
63201
63264
|
getMaps,
|
|
63202
63265
|
getFileUrls,
|
|
63203
63266
|
getPlans,
|
|
@@ -63329,14 +63392,18 @@ function createOunitechAdapter(credentials, options) {
|
|
|
63329
63392
|
}
|
|
63330
63393
|
};
|
|
63331
63394
|
}
|
|
63395
|
+
var OUNITECH_BRAND_DEFINITION = {
|
|
63396
|
+
brand: OUNITECH_BRAND,
|
|
63397
|
+
displayName: "Ounitech (Q3-G / Q3-W)",
|
|
63398
|
+
capabilities: OUNITECH_CAPABILITIES,
|
|
63399
|
+
pendingCommands: OUNITECH_PENDING_COMMANDS,
|
|
63400
|
+
// The robot list carries no model, so Q3-G and Q3-W share these defaults
|
|
63401
|
+
// (their API is the same); add `models` when Ounitech reports one.
|
|
63402
|
+
info: { makerApp: "the Ounitech app", makerAppOnly: ["pausing or stopping a job", "cleaning across floors"] },
|
|
63403
|
+
create: (credentials) => createOunitechAdapter(credentials)
|
|
63404
|
+
};
|
|
63332
63405
|
function registerOunitechBrand() {
|
|
63333
|
-
registerRobotBrand(
|
|
63334
|
-
brand: OUNITECH_BRAND,
|
|
63335
|
-
displayName: "Ounitech (Q3-G / Q3-W)",
|
|
63336
|
-
capabilities: OUNITECH_CAPABILITIES,
|
|
63337
|
-
pendingCommands: OUNITECH_PENDING_COMMANDS,
|
|
63338
|
-
create: (credentials) => createOunitechAdapter(credentials)
|
|
63339
|
-
});
|
|
63406
|
+
registerRobotBrand(OUNITECH_BRAND_DEFINITION);
|
|
63340
63407
|
}
|
|
63341
63408
|
registerOunitechBrand();
|
|
63342
63409
|
|
|
@@ -63818,15 +63885,22 @@ function startDemoTracking(adapter, robotSn, onEvent, everyMs = 1200, skip) {
|
|
|
63818
63885
|
}
|
|
63819
63886
|
};
|
|
63820
63887
|
}
|
|
63888
|
+
var DEMO_BRAND_DEFINITION = {
|
|
63889
|
+
brand: DEMO_BRAND,
|
|
63890
|
+
displayName: "Demo robots (simulated)",
|
|
63891
|
+
capabilities: DEMO_CAPABILITIES,
|
|
63892
|
+
// Serial-derived demo robots are cleaning (DEMO-C-###) AND security (DEMO-S-###).
|
|
63893
|
+
types: ["cleaning", "security"],
|
|
63894
|
+
// Simulated models, so a demo fleet shows a mixed fleet's controls: the
|
|
63895
|
+
// compact CX-1 takes jobs but no point commands; the SP-1 patroller cleans nothing.
|
|
63896
|
+
models: [
|
|
63897
|
+
{ name: "Demo CX-1", codes: ["CX-1"], capabilities: { spotClean: false, navigateToPoint: false, relocalize: false } },
|
|
63898
|
+
{ name: "Demo SP-1", codes: ["SP-1"], capabilities: { spotClean: false } }
|
|
63899
|
+
],
|
|
63900
|
+
create: () => createDemoAdapter()
|
|
63901
|
+
};
|
|
63821
63902
|
function registerDemoBrand() {
|
|
63822
|
-
registerRobotBrand(
|
|
63823
|
-
brand: DEMO_BRAND,
|
|
63824
|
-
displayName: "Demo robots (simulated)",
|
|
63825
|
-
capabilities: DEMO_CAPABILITIES,
|
|
63826
|
-
// Serial-derived demo robots are cleaning (DEMO-C-###) AND security (DEMO-S-###).
|
|
63827
|
-
types: ["cleaning", "security"],
|
|
63828
|
-
create: () => createDemoAdapter()
|
|
63829
|
-
});
|
|
63903
|
+
registerRobotBrand(DEMO_BRAND_DEFINITION);
|
|
63830
63904
|
}
|
|
63831
63905
|
registerDemoBrand();
|
|
63832
63906
|
|
|
@@ -65092,11 +65166,44 @@ var PADBOT_CAPABILITIES = {
|
|
|
65092
65166
|
// §6.7 / §6.8
|
|
65093
65167
|
resolveAlerts: true,
|
|
65094
65168
|
// §6.6
|
|
65095
|
-
//
|
|
65096
|
-
|
|
65097
|
-
|
|
65098
|
-
|
|
65169
|
+
// Model-specific (see PADBOT_MODELS): the drive limits are the S2's head range,
|
|
65170
|
+
// and a heat camera is the S2's - another PadBot patrol model gets neither.
|
|
65171
|
+
manualDrive: false,
|
|
65172
|
+
thermalCamera: false
|
|
65099
65173
|
};
|
|
65174
|
+
var PADBOT_ALARMS = [
|
|
65175
|
+
"person",
|
|
65176
|
+
"high temperature",
|
|
65177
|
+
"smoke",
|
|
65178
|
+
"debris",
|
|
65179
|
+
"noise",
|
|
65180
|
+
"water on the floor",
|
|
65181
|
+
"person falling",
|
|
65182
|
+
"door open",
|
|
65183
|
+
"window open",
|
|
65184
|
+
"fire-fighting equipment"
|
|
65185
|
+
];
|
|
65186
|
+
var PADBOT_MAKER_APP_ONLY = [
|
|
65187
|
+
"patrol schedules",
|
|
65188
|
+
"maps, points and routes",
|
|
65189
|
+
"alarm thresholds and AI recognition",
|
|
65190
|
+
"lights and voice announcements",
|
|
65191
|
+
"recorded video"
|
|
65192
|
+
];
|
|
65193
|
+
var PADBOT_MODELS = [
|
|
65194
|
+
{
|
|
65195
|
+
name: "PadBot S2",
|
|
65196
|
+
codes: ["S2"],
|
|
65197
|
+
makerAppOnly: [...PADBOT_MAKER_APP_ONLY, "live thermal view"],
|
|
65198
|
+
capabilities: {
|
|
65199
|
+
thermalCamera: true,
|
|
65200
|
+
// §8.1 over MQTT, behind the server's drive watchdog; only with PADBOT_MANUAL_DRIVE=on.
|
|
65201
|
+
get manualDrive() {
|
|
65202
|
+
return padbotManualDriveEnabled();
|
|
65203
|
+
}
|
|
65204
|
+
}
|
|
65205
|
+
}
|
|
65206
|
+
];
|
|
65100
65207
|
var PADBOT_PATHS = {
|
|
65101
65208
|
robots: "/api/v1/robots/list",
|
|
65102
65209
|
states: "/api/v1/robots/states/list",
|
|
@@ -65232,6 +65339,19 @@ function padbotPlanShare(frame2, x, y) {
|
|
|
65232
65339
|
return null;
|
|
65233
65340
|
return { x: Math.round(sx * 100) / 100, y: Math.round(sy * 100) / 100 };
|
|
65234
65341
|
}
|
|
65342
|
+
function padbotCanReachMap(maps, fromMapId, toMapId) {
|
|
65343
|
+
if (typeof toMapId !== "string" || !toMapId || typeof fromMapId !== "string" || !fromMapId)
|
|
65344
|
+
return false;
|
|
65345
|
+
if (fromMapId === toMapId)
|
|
65346
|
+
return true;
|
|
65347
|
+
const list = Array.isArray(maps) ? maps : [];
|
|
65348
|
+
const group = (id) => {
|
|
65349
|
+
const g = list.find((m) => m?.mapId === id)?.mapGroup;
|
|
65350
|
+
return typeof g === "string" ? g.trim() : "";
|
|
65351
|
+
};
|
|
65352
|
+
return group(fromMapId) !== "" && group(fromMapId) === group(toMapId);
|
|
65353
|
+
}
|
|
65354
|
+
var PADBOT_OTHER_MAP_TEXT = "The robot must be on this map first.";
|
|
65235
65355
|
function padbotAlarmFault(alarm) {
|
|
65236
65356
|
if (!alarm?.alarmType)
|
|
65237
65357
|
return null;
|
|
@@ -65284,21 +65404,19 @@ function padbotPatrolPlan(paths, maps, states = {}) {
|
|
|
65284
65404
|
checkpoints: placed,
|
|
65285
65405
|
currentCheckpoint: null,
|
|
65286
65406
|
stops: placed.map((c) => c.name).filter(Boolean),
|
|
65287
|
-
|
|
65407
|
+
...typeof p?.mapId === "string" && p.mapId ? { mapId: p.mapId } : {},
|
|
65288
65408
|
_default: !!p?.isDefault
|
|
65289
65409
|
};
|
|
65290
65410
|
});
|
|
65291
65411
|
const next = walking ? nav.nextTargetPointName : null;
|
|
65292
|
-
const candidates = next ? routes.filter((r) => r.
|
|
65412
|
+
const candidates = next ? routes.filter((r) => r.mapId === currentMap && r.checkpoints.some((c) => c.name === next)) : [];
|
|
65293
65413
|
if (candidates.length === 1) {
|
|
65294
65414
|
const r = candidates[0];
|
|
65295
65415
|
r.currentCheckpoint = r.checkpoints.findIndex((c) => c.name === next);
|
|
65296
65416
|
}
|
|
65297
65417
|
routes.sort((a, b) => Number(b.currentCheckpoint !== null) - Number(a.currentCheckpoint !== null) || Number(b._default) - Number(a._default));
|
|
65298
|
-
for (const r of routes)
|
|
65299
|
-
delete r._mapId;
|
|
65418
|
+
for (const r of routes)
|
|
65300
65419
|
delete r._default;
|
|
65301
|
-
}
|
|
65302
65420
|
return { routes, schedule: [], scheduleShared: false };
|
|
65303
65421
|
}
|
|
65304
65422
|
function padbotPatrolRecord(r) {
|
|
@@ -65512,6 +65630,7 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65512
65630
|
batteryPercent: battery,
|
|
65513
65631
|
floorNo: Number.isInteger(floor) ? floor : null,
|
|
65514
65632
|
floorKnown: Number.isInteger(floor),
|
|
65633
|
+
mapId: typeof st["1007"]?.mapId === "string" && st["1007"].mapId ? st["1007"].mapId : null,
|
|
65515
65634
|
position: null,
|
|
65516
65635
|
planPosition: null,
|
|
65517
65636
|
fault: null
|
|
@@ -65532,6 +65651,8 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65532
65651
|
const ly = num(loc?.worldY ?? loc?.y);
|
|
65533
65652
|
if (lx !== null && ly !== null) {
|
|
65534
65653
|
robot.position = { x: lx, y: ly, theta: (num(loc.yaw ?? loc.r) ?? 0) * Math.PI / 180 };
|
|
65654
|
+
if (typeof loc.mapId === "string" && loc.mapId)
|
|
65655
|
+
robot.mapId = loc.mapId;
|
|
65535
65656
|
const map = await maps(robotSn).then((all) => (all ?? []).find((m) => m.mapId === (loc.mapId ?? st["1007"]?.mapId))).catch(() => null);
|
|
65536
65657
|
robot.planPosition = padbotPlanShare(map, lx, ly);
|
|
65537
65658
|
}
|
|
@@ -65591,9 +65712,13 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65591
65712
|
case "relocalize":
|
|
65592
65713
|
await call2(PADBOT_PATHS.relocate, { ...sn, worldX: command.x, worldY: command.y });
|
|
65593
65714
|
return;
|
|
65594
|
-
case "go-to-point":
|
|
65715
|
+
case "go-to-point": {
|
|
65716
|
+
const [st, all] = await Promise.all([states(robotSn), maps(robotSn).catch(() => [])]);
|
|
65717
|
+
if (!padbotCanReachMap(all, st?.["1007"]?.mapId, command.mapId))
|
|
65718
|
+
throw new import_node_server_utils162.BadRequestError(PADBOT_OTHER_MAP_TEXT);
|
|
65595
65719
|
await call2(PADBOT_PATHS.navigateTarget, { ...sn, mapId: command.mapId, targetPointId: command.targetPointId });
|
|
65596
65720
|
return;
|
|
65721
|
+
}
|
|
65597
65722
|
default:
|
|
65598
65723
|
throw new import_node_server_utils162.BadRequestError(`PadBot robots cannot "${command.kind}" through the PadBot API.`);
|
|
65599
65724
|
}
|
|
@@ -65698,18 +65823,26 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65698
65823
|
}
|
|
65699
65824
|
};
|
|
65700
65825
|
}
|
|
65826
|
+
var PADBOT_BRAND_DEFINITION = {
|
|
65827
|
+
brand: PADBOT_BRAND,
|
|
65828
|
+
displayName: PADBOT_DISPLAY_NAME,
|
|
65829
|
+
capabilities: PADBOT_CAPABILITIES,
|
|
65830
|
+
types: ["security"],
|
|
65831
|
+
info: { alarms: [...PADBOT_ALARMS], makerApp: "the PadBot app", makerAppOnly: [...PADBOT_MAKER_APP_ONLY] },
|
|
65832
|
+
models: PADBOT_MODELS,
|
|
65833
|
+
create: (credentials) => createPadbotAdapter(credentials)
|
|
65834
|
+
};
|
|
65701
65835
|
function registerPadbotBrand() {
|
|
65702
|
-
registerRobotBrand(
|
|
65703
|
-
brand: PADBOT_BRAND,
|
|
65704
|
-
displayName: PADBOT_DISPLAY_NAME,
|
|
65705
|
-
capabilities: PADBOT_CAPABILITIES,
|
|
65706
|
-
types: ["security"],
|
|
65707
|
-
create: (credentials) => createPadbotAdapter(credentials)
|
|
65708
|
-
});
|
|
65836
|
+
registerRobotBrand(PADBOT_BRAND_DEFINITION);
|
|
65709
65837
|
}
|
|
65710
65838
|
registerPadbotBrand();
|
|
65711
65839
|
|
|
65712
65840
|
// src/services/robot-fleet.service.ts
|
|
65841
|
+
var OUNITECH_REGION_BASE_URLS = [
|
|
65842
|
+
"https://app.frankfurt.robotcloud.top",
|
|
65843
|
+
"https://app.singapore.robotcloud.top",
|
|
65844
|
+
"https://app.robotcloud.top"
|
|
65845
|
+
];
|
|
65713
65846
|
var TIMESTAMP_OFFSET_CANDIDATES = [
|
|
65714
65847
|
{ offsetMinutes: 120, label: "UTC+2 (Frankfurt summer time)" },
|
|
65715
65848
|
{ offsetMinutes: 60, label: "UTC+1 (Frankfurt winter time)" },
|
|
@@ -65792,10 +65925,11 @@ function useRobotFleetService(deps) {
|
|
|
65792
65925
|
batteryPercent: null,
|
|
65793
65926
|
floorNo: null,
|
|
65794
65927
|
floorKnown: false,
|
|
65928
|
+
mapId: null,
|
|
65795
65929
|
position: null,
|
|
65796
65930
|
planPosition: null,
|
|
65797
65931
|
fault: null,
|
|
65798
|
-
|
|
65932
|
+
...robotManifest(brand)
|
|
65799
65933
|
};
|
|
65800
65934
|
}
|
|
65801
65935
|
const fault = found.fault?.code ? found.fault : null;
|
|
@@ -65806,6 +65940,7 @@ function useRobotFleetService(deps) {
|
|
|
65806
65940
|
}
|
|
65807
65941
|
}
|
|
65808
65942
|
const free = found.mode === "IDLE" || found.mode === "CHARGED";
|
|
65943
|
+
const manifest = robotManifest(brand, found.model);
|
|
65809
65944
|
return {
|
|
65810
65945
|
id,
|
|
65811
65946
|
name: robot.name,
|
|
@@ -65818,15 +65953,17 @@ function useRobotFleetService(deps) {
|
|
|
65818
65953
|
dispatchable: (
|
|
65819
65954
|
// A faulted robot is not given a job however idle its mode reads. An
|
|
65820
65955
|
// alarm (smoke seen, door open) is not a machine fault: the patrol goes on.
|
|
65821
|
-
found.online && free && (!fault || fault.alarm === true) && commandSupported(
|
|
65956
|
+
found.online && free && (!fault || fault.alarm === true) && commandSupported(manifest.capabilities, "full")
|
|
65822
65957
|
),
|
|
65823
65958
|
batteryPercent: found.batteryPercent ?? null,
|
|
65824
65959
|
floorNo: found.floorNo ?? null,
|
|
65825
65960
|
floorKnown: found.floorKnown === true,
|
|
65961
|
+
mapId: typeof found.mapId === "string" && found.mapId ? found.mapId : null,
|
|
65826
65962
|
position: found.position ?? null,
|
|
65827
65963
|
planPosition: found.planPosition ?? null,
|
|
65828
65964
|
fault,
|
|
65829
|
-
capabilities:
|
|
65965
|
+
capabilities: manifest.capabilities,
|
|
65966
|
+
profile: manifest.profile
|
|
65830
65967
|
};
|
|
65831
65968
|
}
|
|
65832
65969
|
async function getMaps(robot) {
|
|
@@ -65876,6 +66013,9 @@ function useRobotFleetService(deps) {
|
|
|
65876
66013
|
return adapter.sendCommand(robotSn, command);
|
|
65877
66014
|
}
|
|
65878
66015
|
const state = await getFleetRobot(robot);
|
|
66016
|
+
if (!commandSupported(state.capabilities, command.kind)) {
|
|
66017
|
+
throw new import_node_server_utils163.BadRequestError(`${state.profile.model || adapter.displayName} does not support "${command.kind}" through its API.`);
|
|
66018
|
+
}
|
|
65879
66019
|
if (command.kind === "pause" || command.kind === "resume" || command.kind === "cancel" || command.kind === "relocalize" || command.kind === "patrol-resume") {
|
|
65880
66020
|
const need = command.kind === "pause" ? "WORKING" : command.kind === "resume" ? "PAUSED" : null;
|
|
65881
66021
|
if (!state.online || need && state.mode !== need) {
|
|
@@ -66082,6 +66222,43 @@ function useRobotFleetService(deps) {
|
|
|
66082
66222
|
lastTimestampProbe.set(key, Date.now());
|
|
66083
66223
|
return { id, pair };
|
|
66084
66224
|
}
|
|
66225
|
+
async function probeRegions(robot) {
|
|
66226
|
+
const { id, pair } = probeGate(robot, "region");
|
|
66227
|
+
const hosts = [];
|
|
66228
|
+
for (const baseUrl of deps?.regionBaseUrls ?? OUNITECH_REGION_BASE_URLS) {
|
|
66229
|
+
try {
|
|
66230
|
+
const reply = await useRobotCloudService(pair, { ...deps?.cloudOptions, baseUrl }).getRobotListReply();
|
|
66231
|
+
const replyShape = {};
|
|
66232
|
+
for (const [k, v] of Object.entries(reply)) {
|
|
66233
|
+
replyShape[k] = Array.isArray(v) ? `list of ${v.length}` : v === null ? "null" : typeof v;
|
|
66234
|
+
}
|
|
66235
|
+
const list = Array.isArray(reply.robotList) ? reply.robotList : [];
|
|
66236
|
+
const robots = list.map((r) => ({
|
|
66237
|
+
robotSn: String(r?.robotSn ?? ""),
|
|
66238
|
+
robotName: String(r?.robotName ?? ""),
|
|
66239
|
+
online: r?.onlineFlag === true,
|
|
66240
|
+
statusName: String(r?.statusName ?? "")
|
|
66241
|
+
}));
|
|
66242
|
+
hosts.push({
|
|
66243
|
+
host: cloudHost(baseUrl),
|
|
66244
|
+
ok: true,
|
|
66245
|
+
detail: `Signed in. Lists ${robots.length} robot${robots.length === 1 ? "" : "s"}.`,
|
|
66246
|
+
replyShape,
|
|
66247
|
+
robots
|
|
66248
|
+
});
|
|
66249
|
+
} catch (e) {
|
|
66250
|
+
hosts.push({ host: cloudHost(baseUrl), ok: false, ...describeFailure(e) });
|
|
66251
|
+
}
|
|
66252
|
+
}
|
|
66253
|
+
const withRobots = hosts.filter((h) => h.robots?.length);
|
|
66254
|
+
return {
|
|
66255
|
+
robotId: id,
|
|
66256
|
+
configuredHost: cloudHost(deps?.cloudOptions?.baseUrl ?? ROBOT_CLOUD_BASE_URL),
|
|
66257
|
+
hosts,
|
|
66258
|
+
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.",
|
|
66259
|
+
checkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
66260
|
+
};
|
|
66261
|
+
}
|
|
66085
66262
|
async function probeTimestampOffset(robot) {
|
|
66086
66263
|
const { id, pair } = probeGate(robot, "offset");
|
|
66087
66264
|
const baseUrl = deps?.cloudOptions?.baseUrl ?? ROBOT_CLOUD_BASE_URL;
|
|
@@ -66095,9 +66272,9 @@ function useRobotFleetService(deps) {
|
|
|
66095
66272
|
let accepted = null;
|
|
66096
66273
|
for (const c of [{ offsetMinutes: 0, label: "UTC (current)" }, ...TIMESTAMP_OFFSET_CANDIDATES]) {
|
|
66097
66274
|
const now = () => new Date(Date.now() + (skewMs ?? 0) + c.offsetMinutes * 6e4);
|
|
66098
|
-
const sent = robotCloudTimestamp(now(), "yyyyMMddHHmmss");
|
|
66275
|
+
const sent = robotCloudTimestamp(now(), "yyyyMMddHHmmss", "UTC");
|
|
66099
66276
|
try {
|
|
66100
|
-
const robots = await useRobotCloudService(pair, { ...deps?.cloudOptions, timestampFormat: "yyyyMMddHHmmss", now, onReply }).getRobots();
|
|
66277
|
+
const robots = await useRobotCloudService(pair, { ...deps?.cloudOptions, timestampFormat: "yyyyMMddHHmmss", timestampZone: "UTC", now, onReply }).getRobots();
|
|
66101
66278
|
attempts.push({ ...c, sent, ok: true, detail: `Accepted. The account lists ${robots.length} robot${robots.length === 1 ? "" : "s"}.` });
|
|
66102
66279
|
accepted = c.offsetMinutes;
|
|
66103
66280
|
break;
|
|
@@ -66151,6 +66328,7 @@ function useRobotFleetService(deps) {
|
|
|
66151
66328
|
diagnose,
|
|
66152
66329
|
probeTimestampFormat,
|
|
66153
66330
|
probeTimestampOffset,
|
|
66331
|
+
probeRegions,
|
|
66154
66332
|
getLiveVideo,
|
|
66155
66333
|
resolveAlerts,
|
|
66156
66334
|
getPatrolHistory,
|
|
@@ -69060,7 +69238,7 @@ function useRobotFleetController(deps) {
|
|
|
69060
69238
|
return;
|
|
69061
69239
|
heardAt = Date.now();
|
|
69062
69240
|
void Promise.resolve(adapter.getMaps?.(robotSn) ?? []).then((maps) => padbotPlanShare((maps ?? []).find((m) => m?.mapId === e.mapId), e.x, e.y)).catch(() => null).then(
|
|
69063
|
-
(planPosition) => send2({ type: "pose", pose: { x: e.x, y: e.y, theta: (e.yawDeg ?? 0) * Math.PI / 180 }, planPosition, at: Date.now() })
|
|
69241
|
+
(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() })
|
|
69064
69242
|
);
|
|
69065
69243
|
});
|
|
69066
69244
|
}
|
|
@@ -69212,14 +69390,14 @@ function useRobotFleetController(deps) {
|
|
|
69212
69390
|
try {
|
|
69213
69391
|
await requirePlatformStaff(req, CROSS_CLIENT_GRANT);
|
|
69214
69392
|
const probe = req.query.probe;
|
|
69215
|
-
if (probe !== void 0 && probe !== "timestamp" && probe !== "timestamp-offset") {
|
|
69216
|
-
return fail(next, new import_node_server_utils169.BadRequestError('probe must be "timestamp"
|
|
69393
|
+
if (probe !== void 0 && probe !== "timestamp" && probe !== "timestamp-offset" && probe !== "region") {
|
|
69394
|
+
return fail(next, new import_node_server_utils169.BadRequestError('probe must be "timestamp", "timestamp-offset" or "region".'));
|
|
69217
69395
|
}
|
|
69218
69396
|
const robot = await entitleRobot(req, req.params.id);
|
|
69219
69397
|
res.set("Cache-Control", "no-store");
|
|
69220
69398
|
const fleet2 = getFleet2();
|
|
69221
69399
|
res.json(
|
|
69222
|
-
probe === "timestamp" ? await fleet2.probeTimestampFormat(robot) : probe === "timestamp-offset" ? await fleet2.probeTimestampOffset(robot) : await fleet2.diagnose(robot)
|
|
69400
|
+
probe === "timestamp" ? await fleet2.probeTimestampFormat(robot) : probe === "timestamp-offset" ? await fleet2.probeTimestampOffset(robot) : probe === "region" ? await fleet2.probeRegions(robot) : await fleet2.diagnose(robot)
|
|
69223
69401
|
);
|
|
69224
69402
|
} catch (error) {
|
|
69225
69403
|
fail(next, error);
|
|
@@ -70470,6 +70648,7 @@ async function readLiveItems(robots) {
|
|
|
70470
70648
|
planPosition: s.planPosition,
|
|
70471
70649
|
fault: s.fault,
|
|
70472
70650
|
capabilities: s.capabilities,
|
|
70651
|
+
profile: s.profile,
|
|
70473
70652
|
lastSeenAt: seen2 ? new Date(seen2) : null
|
|
70474
70653
|
});
|
|
70475
70654
|
} catch (e) {
|
|
@@ -104494,6 +104673,7 @@ function usePersonalEmergencyChainController() {
|
|
|
104494
104673
|
DEFAULT_SITE_TIMEZONE,
|
|
104495
104674
|
DEMO_ADD_MAX,
|
|
104496
104675
|
DEMO_BRAND,
|
|
104676
|
+
DEMO_BRAND_DEFINITION,
|
|
104497
104677
|
DEMO_CAPABILITIES,
|
|
104498
104678
|
DEMO_FAULT_ROBOT,
|
|
104499
104679
|
DEMO_ROUTES,
|
|
@@ -104659,23 +104839,31 @@ function usePersonalEmergencyChainController() {
|
|
|
104659
104839
|
ORG_OWNER_REPAIR_DEFAULT,
|
|
104660
104840
|
ORG_OWNER_REPAIR_OFF_REASON,
|
|
104661
104841
|
OUNITECH_BRAND,
|
|
104842
|
+
OUNITECH_BRAND_DEFINITION,
|
|
104662
104843
|
OUNITECH_CAPABILITIES,
|
|
104663
104844
|
OUNITECH_PENDING_COMMANDS,
|
|
104845
|
+
OUNITECH_REGION_BASE_URLS,
|
|
104664
104846
|
OUNITECH_TIMESTAMP_FORMAT,
|
|
104847
|
+
OUNITECH_TIMESTAMP_ZONE,
|
|
104665
104848
|
OpenRmfError,
|
|
104666
104849
|
OrgNature,
|
|
104667
104850
|
OvernightParkingRequestSort,
|
|
104668
104851
|
OvernightParkingRequestStatus,
|
|
104669
104852
|
PADBOT_ACTION_TEXT,
|
|
104853
|
+
PADBOT_ALARMS,
|
|
104670
104854
|
PADBOT_ALARM_POLL_MS,
|
|
104671
104855
|
PADBOT_ALARM_TEXT,
|
|
104672
104856
|
PADBOT_BRAND,
|
|
104857
|
+
PADBOT_BRAND_DEFINITION,
|
|
104673
104858
|
PADBOT_CAPABILITIES,
|
|
104674
104859
|
PADBOT_DISPLAY_NAME,
|
|
104675
104860
|
PADBOT_LIVE_POSE_MS,
|
|
104861
|
+
PADBOT_MAKER_APP_ONLY,
|
|
104862
|
+
PADBOT_MODELS,
|
|
104676
104863
|
PADBOT_MOTION,
|
|
104677
104864
|
PADBOT_MQTT_SYNC_MS,
|
|
104678
104865
|
PADBOT_ONLINE_WINDOW_MS,
|
|
104866
|
+
PADBOT_OTHER_MAP_TEXT,
|
|
104679
104867
|
PADBOT_PATHS,
|
|
104680
104868
|
PATROL_CCTV_CAMERA_FILTER,
|
|
104681
104869
|
PATROL_EMAIL_MAX_LOGS,
|
|
@@ -105011,6 +105199,7 @@ function usePersonalEmergencyChainController() {
|
|
|
105011
105199
|
padbotAlarmPlace,
|
|
105012
105200
|
padbotAlarmPollEnabled,
|
|
105013
105201
|
padbotBaseUrl,
|
|
105202
|
+
padbotCanReachMap,
|
|
105014
105203
|
padbotCheckpointVisit,
|
|
105015
105204
|
padbotCommandLog,
|
|
105016
105205
|
padbotDriveBlock,
|
|
@@ -105100,6 +105289,7 @@ function usePersonalEmergencyChainController() {
|
|
|
105100
105289
|
robotCloudTimestamp,
|
|
105101
105290
|
robotCredentialsKey,
|
|
105102
105291
|
robotFaultSweepConfig,
|
|
105292
|
+
robotManifest,
|
|
105103
105293
|
robotMode,
|
|
105104
105294
|
robotModeFromList,
|
|
105105
105295
|
robotSchema,
|