@dicamo/flint-ai-bridge 1.0.6 → 1.0.7
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/README.md +3 -3
- package/dist/cli.js +30 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ Stop the running bridge before changing these URLs.
|
|
|
38
38
|
### 2. Start the bridge
|
|
39
39
|
|
|
40
40
|
```sh
|
|
41
|
-
npx @dicamo/flint-ai-bridge@
|
|
41
|
+
npx @dicamo/flint-ai-bridge@latest start --enable-chat
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
When chat is requested, startup checks Claude Code in a temporary directory and stops it after inspecting its initialization event. No CMS credentials or data are passed to this check. If the check fails, the bridge stays available for pairing and displays the reason chat is disabled. Retry by stopping and starting the bridge after resolving the issue.
|
|
@@ -71,8 +71,8 @@ The bridge does not reconnect automatically or save pairing credentials in the b
|
|
|
71
71
|
Check the bridge status or stop it:
|
|
72
72
|
|
|
73
73
|
```sh
|
|
74
|
-
npx @dicamo/flint-ai-bridge@
|
|
75
|
-
npx @dicamo/flint-ai-bridge@
|
|
74
|
+
npx @dicamo/flint-ai-bridge@latest status
|
|
75
|
+
npx @dicamo/flint-ai-bridge@latest stop
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
Run `start --enable-chat` again after restarting your computer. The bridge does not register itself to start at login. Runtime errors and fallback pairing codes are written to `~/.flint-ai-bridge/bridge.log`. To view output directly in a terminal, use `serve --enable-chat` and press `Ctrl+C` to stop.
|
package/dist/cli.js
CHANGED
|
@@ -386,7 +386,7 @@ async function authenticate(options) {
|
|
|
386
386
|
import { z as z4 } from "zod";
|
|
387
387
|
var dataset = (name, label, resource, table, fields, scope, order = ["id"]) => ({ name, label, resource, table, fields: fields.split(","), ...scope, order });
|
|
388
388
|
var CMS_DATASETS = [
|
|
389
|
-
dataset("devices", "Device details", "devices", "v_devices", "id,name,company_id,store_id,online,created_at,updated_at,keep_alive,width,height,network,cpu_usage,memory_usage,service_version,service_version_code,player_app_version,player_app_version_code,supported_32bit_abis,supported_64bit_abis,density,ip,mac,ssid,ssaid,vpn_status,remote_count,uptime,runtime,screen_on,foreground_app,battery,os_time,device_snapshots", { company: "company_id", store: "store_id" }),
|
|
389
|
+
dataset("devices", "Device details", "devices", "v_devices", "id,name,company_id,store_id,online,created_at,updated_at,keep_alive,width,height,network,cpu_usage,memory_usage,service_version,service_version_code,player_app_version,player_app_version_code,supported_32bit_abis,supported_64bit_abis,density,ip,mac,ssid,ssaid,vpn_status,remote_count,uptime,runtime,screen_on,foreground_app,battery,os_time,device_snapshots,snapshot_url", { company: "company_id", store: "store_id" }),
|
|
390
390
|
dataset("companies", "Companies", "companies", "companies", "id,encrypted_id,parent_id,name,contact,logo,created_at,updated_at", { company: "id" }),
|
|
391
391
|
dataset("stores", "Stores", "companies", "stores", "id,encrypted_id,company_id,name,address,tz,tz_offset,open_time,close_time,reboot_time,contact,touch_log,media_log,enable_sleep,lat,lng,created_at", { company: "company_id", store: "id" }),
|
|
392
392
|
dataset("media", "Media", "media", "media", "id,name,folder_id,mime,width,height,size,duration,created_at,created_by,company_id,encode_status,encode_progress,original_size,encoded_at,source_media_id,encode_preset", { company: "company_id" }),
|
|
@@ -404,7 +404,7 @@ var CMS_DATASETS = [
|
|
|
404
404
|
dataset("holidays", "Store holidays", "holidays", "store_holiday", "store_id,date", { parent: { dataset: "stores", field: "store_id" } }, ["date", "store_id"]),
|
|
405
405
|
dataset("holiday_overrides", "Store opening exceptions", "holidays", "store_holiday_override", "store_id,date", { parent: { dataset: "stores", field: "store_id" } }, ["date", "store_id"]),
|
|
406
406
|
dataset("device_apps", "Installed apps across devices", "devices", "rpc/device_app_inventory", "id,device_id,name,package_name,version,version_code,installed_at,updated_at,device_name,company_id,store_id,online,service_version,service_version_code,player_app_version,player_app_version_code", { schema: "ai", company: "company_id", store: "store_id" }),
|
|
407
|
-
dataset("device_snapshots", "Snapshot brightness analysis", "devices", "rpc/device_snapshot_status", "device_id,device_name,company_id,store_id,online,snapshot_path,captured_at,analysis_status,black_pixel_ratio,mean_luminance,black_screen_candidate,analyzed_at,sample_width,sample_height,algorithm,error_code", { schema: "ai", company: "company_id", store: "store_id" }, ["device_id"]),
|
|
407
|
+
dataset("device_snapshots", "Snapshot brightness analysis", "devices", "rpc/device_snapshot_status", "device_id,device_name,company_id,store_id,online,snapshot_path,captured_at,analysis_status,black_pixel_ratio,mean_luminance,black_screen_candidate,analyzed_at,sample_width,sample_height,algorithm,error_code,snapshot_url", { schema: "ai", company: "company_id", store: "store_id" }, ["device_id"]),
|
|
408
408
|
dataset("device_snapshot_vectors", "Snapshot vector generation status", "devices", "rpc/device_snapshot_vectors", "device_id,device_name,company_id,store_id,online,captured_at,embedding_status,embedding_model,embedded_at", { schema: "ai", company: "company_id", store: "store_id" }, ["device_id"]),
|
|
409
409
|
dataset("device_notes", "Device notes", "devices", "device_notes", "id,device_id,body,created_by,created_at,updated_at", { parent: { dataset: "devices", field: "device_id" } }),
|
|
410
410
|
dataset("scene_history", "Scene history", "studio", "scene_histories", "id,scene_id,action,name,description,changed_by,changed_at", { parent: { dataset: "scenes", field: "scene_id" } }),
|
|
@@ -421,7 +421,7 @@ var queryArgs = z4.object({
|
|
|
421
421
|
offset: z4.number().int().min(0).max(1e5).default(0),
|
|
422
422
|
countOnly: z4.boolean().default(false)
|
|
423
423
|
}).strict();
|
|
424
|
-
var DEVICE_QUERY_GUIDANCE = "For device information, prefer the devices dataset backed by public.v_devices. service_version and service_version_code describe the service app; player_app_version and player_app_version_code describe the player app. Filter these fields together with query_cms to search all accessible devices in bulk; do not fetch device_apps once per device for these questions. Use ilike with 3.* for the 3.x family or 3.0.* for the 3.0.x family, and eq for an exact reported version. Use countOnly for the total and paginate matching devices only. Use device_apps for installed-app details not available in v_devices. This dataset joins public.device_apps with public.v_devices and supports bulk queries without a required device_id. Combine app filters (name, package_name, version) and device filters (service_version, player_app_version, company_id, store_id, online) in the same query. device_name is the device name; name is the app name. Its total/countOnly counts matching app records, not distinct devices. Do not claim a distinct device count from app record counts or a partial page. Summary version fields do not prove whether an additional old app is also installed. If the app or version relationship is ambiguous, clarify it instead of assuming service and player versions are interchangeable. For black-screen questions use device_snapshots, which supports bulk filtering by online, analysis_status, black_screen_candidate and captured_at. A completed analysis with black_pixel_ratio >= 0.98 is only a dark-snapshot candidate, not proof of a display or backlight failure. Ratios are 0 to 1; mean_luminance is encoded sRGB luma 0 to 255. Check capture age separately from current online status. Pending, failed, stale and not_analyzed are unknown, never healthy or black. Report unanalysed devices separately when answering about all devices. The devices.device_snapshots field contains source metadata; snapshot_path is relative to the public device_captures bucket. An image URL alone does not mean you have viewed or visually analysed it.";
|
|
424
|
+
var DEVICE_QUERY_GUIDANCE = "For device information, prefer the devices dataset backed by public.v_devices. service_version and service_version_code describe the service app; player_app_version and player_app_version_code describe the player app. Filter these fields together with query_cms to search all accessible devices in bulk; do not fetch device_apps once per device for these questions. Use ilike with 3.* for the 3.x family or 3.0.* for the 3.0.x family, and eq for an exact reported version. Use countOnly for the total and paginate matching devices only. Use device_apps for installed-app details not available in v_devices. This dataset joins public.device_apps with public.v_devices and supports bulk queries without a required device_id. Combine app filters (name, package_name, version) and device filters (service_version, player_app_version, company_id, store_id, online) in the same query. device_name is the device name; name is the app name. Its total/countOnly counts matching app records, not distinct devices. Do not claim a distinct device count from app record counts or a partial page. Summary version fields do not prove whether an additional old app is also installed. If the app or version relationship is ambiguous, clarify it instead of assuming service and player versions are interchangeable. For black-screen questions use device_snapshots, which supports bulk filtering by online, analysis_status, black_screen_candidate and captured_at. A completed analysis with black_pixel_ratio >= 0.98 is only a dark-snapshot candidate, not proof of a display or backlight failure. Ratios are 0 to 1; mean_luminance is encoded sRGB luma 0 to 255. Check capture age separately from current online status. Pending, failed, stale and not_analyzed are unknown, never healthy or black. Report unanalysed devices separately when answering about all devices. The devices.device_snapshots field contains source metadata; snapshot_path is relative to the public device_captures bucket. The devices and device_snapshots datasets provide a computed snapshot_url field. Select snapshot_url when the user asks to see a snapshot, together with the device name and capture time. It is a public CMS Storage URL with a capture-version query parameter; never filter or sort on this computed field. The chat UI can display images: use  with the exact returned URL, outside large tables. Do not say images cannot be displayed just because you cannot open image bytes yourself. Never invent a server address or derive a URL from a device ID; if snapshot_url is null, report that no valid snapshot URL is available. The storage path is overwritten: this URL points to the current object, not an immutable historical image. An image URL alone does not mean you have viewed or visually analysed it; describe measured brightness separately from visual inspection.";
|
|
425
425
|
var CATALOG_TOOLS = [
|
|
426
426
|
{ name: "describe_cms_queries", description: "Inspect CMS datasets, fields, filters, and required parent IDs available with the current permissions. Use this tool first if the basic device tools lack the information needed to answer the question.", inputSchema: { type: "object", properties: {}, additionalProperties: false } },
|
|
427
427
|
{ name: "query_cms", description: "Query CMS data and exact counts. Only use datasets and fields from describe_cms_queries. Use ISO dates, ilike with * patterns for name searches, and created_at desc for recent registrations. Filters are combined with AND. countOnly returns only the total matching the same filters. If hasMore is true, results are partial; continue with nextOffset. " + DEVICE_QUERY_GUIDANCE, inputSchema: { type: "object", properties: { dataset: { type: "string" }, fields: { type: "array", items: { type: "string" } }, filters: { type: "array", items: { type: "object", properties: { field: { type: "string" }, op: { type: "string", enum: ["eq", "neq", "gt", "gte", "lt", "lte", "ilike", "is"] }, value: { type: ["string", "number", "boolean", "null"] } }, required: ["field", "op", "value"], additionalProperties: false } }, order: { type: "array", items: { type: "object", properties: { field: { type: "string" }, direction: { type: "string", enum: ["asc", "desc"] } }, required: ["field", "direction"], additionalProperties: false } }, limit: { type: "integer", minimum: 1, maximum: 50 }, offset: { type: "integer", minimum: 0, maximum: 1e5 }, countOnly: { type: "boolean" } }, required: ["dataset"], additionalProperties: false } }
|
|
@@ -446,6 +446,19 @@ var CMS_TOOLS = [...LEGACY_TOOLS, ...CATALOG_TOOLS, REPORT_TOOL, SIMILAR_SNAPSHO
|
|
|
446
446
|
function toolResource(name) {
|
|
447
447
|
return name === "list_companies" ? "companies" : name === "list_devices" || name === "get_device_status" || name === "find_similar_snapshots" ? "devices" : null;
|
|
448
448
|
}
|
|
449
|
+
function snapshotUrl(server, path, capturedAt) {
|
|
450
|
+
if (typeof path !== "string" || !path || path.length > 2048 || /^[a-z][a-z0-9+.-]*:/i.test(path) || /[\\\u0000-\u001f\u007f]/.test(path)) return null;
|
|
451
|
+
const parts = path.split("/");
|
|
452
|
+
if (parts.some((part) => !part || part === "." || part === "..")) return null;
|
|
453
|
+
try {
|
|
454
|
+
const url = new URL(`/storage/v1/object/public/device_captures/${parts.map((part) => encodeURIComponent(part).replace(/[!'()*]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`)).join("/")}`, server);
|
|
455
|
+
if (!["https:", "http:"].includes(url.protocol) || url.username || url.password) return null;
|
|
456
|
+
if (typeof capturedAt === "string" && capturedAt.length <= 100 && Number.isFinite(Date.parse(capturedAt))) url.searchParams.set("v", capturedAt);
|
|
457
|
+
return url.href;
|
|
458
|
+
} catch {
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
449
462
|
var CmsReadTools = class {
|
|
450
463
|
options;
|
|
451
464
|
constructor(options) {
|
|
@@ -534,7 +547,7 @@ var CmsReadTools = class {
|
|
|
534
547
|
if (!d) throw new Error("cms_unknown_dataset");
|
|
535
548
|
if (!parentCheck && !this.canRead(user, d.resource)) throw new Error("cms_tool_forbidden");
|
|
536
549
|
const requested = input.fields ?? d.fields;
|
|
537
|
-
if (
|
|
550
|
+
if (requested.some((f) => !d.fields.includes(f)) || [...input.filters.map((f) => f.field), ...input.order.map((o) => o.field)].some((f) => f === "snapshot_url" || !d.fields.includes(f))) throw new Error("cms_invalid_field");
|
|
538
551
|
const allowed = await this.scope(user);
|
|
539
552
|
const stores = user.scope.super_user || user.scope.is_owner ? null : user.scope.store_ids;
|
|
540
553
|
const countUnit = d.name === "device_apps" ? { countUnit: "installed_app_records" } : {};
|
|
@@ -546,7 +559,10 @@ var CmsReadTools = class {
|
|
|
546
559
|
const parent = await this.queryDataset(queryArgs.parse({ dataset: d.parent.dataset, fields: ["id"], filters: [{ field: "id", op: "eq", value: filter.value }], limit: 1 }), user, true);
|
|
547
560
|
if (!parent.rows.length) throw new Error("cms_scope_forbidden");
|
|
548
561
|
}
|
|
549
|
-
const
|
|
562
|
+
const withSnapshotUrl = requested.includes("snapshot_url");
|
|
563
|
+
const sourceFields = requested.filter((field) => field !== "snapshot_url");
|
|
564
|
+
if (withSnapshotUrl) sourceFields.push(...d.name === "devices" ? ["device_snapshots"] : ["snapshot_path", "captured_at"]);
|
|
565
|
+
const checkedFields = [.../* @__PURE__ */ new Set([...sourceFields, ...d.schema ? [...d.order, ...input.order.map((o) => o.field)] : [], ...d.company ? [d.company] : [], ...d.store ? [d.store] : [], ...d.parent ? [d.parent.field] : [], ...input.filters.filter((f) => f.op === "eq").map((f) => f.field)])];
|
|
550
566
|
const order = [...input.order, ...d.order.filter((field) => !input.order.some((o) => o.field === field)).map((field) => ({ field, direction: "asc" }))];
|
|
551
567
|
const query = new URLSearchParams({ select: checkedFields.join(","), limit: String(input.countOnly ? 0 : input.limit + 1), offset: String(input.countOnly ? 0 : input.offset), order: order.map((o) => `${o.field}.${o.direction}.nullslast`).join(",") });
|
|
552
568
|
if (d.company && allowed !== null) query.append(d.company, `in.(${[...allowed].join(",")})`);
|
|
@@ -566,7 +582,14 @@ var CmsReadTools = class {
|
|
|
566
582
|
}
|
|
567
583
|
}
|
|
568
584
|
const hasMore = rows.length > input.limit;
|
|
569
|
-
return { rows: rows.slice(0, input.limit).map((row) =>
|
|
585
|
+
return { rows: rows.slice(0, input.limit).map((row) => {
|
|
586
|
+
if (withSnapshotUrl) {
|
|
587
|
+
const metadata = d.name === "devices" ? row.device_snapshots : null;
|
|
588
|
+
const snapshot = metadata && typeof metadata === "object" && !Array.isArray(metadata) ? metadata : null;
|
|
589
|
+
row.snapshot_url = snapshotUrl(this.options.credentials.url, d.name === "devices" ? snapshot?.path : row.snapshot_path, d.name === "devices" ? snapshot?.updated_at : row.captured_at);
|
|
590
|
+
}
|
|
591
|
+
return Object.fromEntries(requested.filter((f) => Object.hasOwn(row, f)).map((f) => [f, row[f]]));
|
|
592
|
+
}), total: page.total, hasMore, nextOffset: hasMore ? input.offset + input.limit : null, ...countUnit };
|
|
570
593
|
}
|
|
571
594
|
async similarSnapshots(input, user) {
|
|
572
595
|
if (!this.canRead(user, "devices")) throw new Error("cms_tool_forbidden");
|
|
@@ -1228,7 +1251,7 @@ async function startBridge(options) {
|
|
|
1228
1251
|
if (request.bridgeToken) throw new BridgeError("pair_required");
|
|
1229
1252
|
reply({
|
|
1230
1253
|
type: "hello.ok",
|
|
1231
|
-
bridgeVersion: "1.0.
|
|
1254
|
+
bridgeVersion: "1.0.7",
|
|
1232
1255
|
hostId: config.hostId,
|
|
1233
1256
|
streamId,
|
|
1234
1257
|
connectionId: peer.id,
|