@camstack/develop 0.1.52 → 0.1.54

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 CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.54] - 2026-11-16
11
+
12
+ ### Changed
13
+
14
+ - Shared hub downloader and logs-export helpers for the MCP servers
15
+ - The capability skill asks you to audit the device card, the device row and the viewer accessory row a device capability change reaches, and records it in the done-gate
16
+
17
+ ## [0.1.53] - 2026-11-12
18
+
19
+ ### Changed
20
+
21
+ - The exporter scaffold implements setExposedName.
22
+
10
23
  ## [0.1.52] - 2026-11-10
11
24
 
12
25
  ### Added
@@ -0,0 +1,14 @@
1
+ import { type HubTlsConfig } from './hub-tls.js';
2
+ /** Streams one hub data-plane path to a local file. */
3
+ export type HubDownloader = (urlPath: string, destFile: string, maxBytes: number) => Promise<{
4
+ readonly bytes: number;
5
+ }>;
6
+ export declare const DOWNLOAD_TIMEOUT_MS: number;
7
+ export interface DownloaderOptions {
8
+ readonly baseUrl: string;
9
+ readonly token: string;
10
+ readonly tls: HubTlsConfig;
11
+ readonly timeoutMs?: number;
12
+ }
13
+ export declare function createHubDownloader(options: DownloaderOptions): HubDownloader;
14
+ //# sourceMappingURL=hub-download.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hub-download.d.ts","sourceRoot":"","sources":["../../src/hub/hub-download.ts"],"names":[],"mappings":"AAYA,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhE,uDAAuD;AACvD,MAAM,MAAM,aAAa,GAAG,CAC1B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,KACb,OAAO,CAAC;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAExC,eAAO,MAAM,mBAAmB,EAAE,MAAoB,CAAA;AAEtD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAA;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,GAAG,aAAa,CA2D7E"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Streams one hub data-plane path into a local file (the retrain export tar).
3
+ *
4
+ * GET only, bearer from the credential chain, TLS from the shared trust
5
+ * config. The bytes go to `<dest>.part` and are renamed on success, so a cut
6
+ * connection never leaves a plausible-looking truncated archive. A size cap
7
+ * and a timeout bound it; the export is generated on the fly, so there is no
8
+ * resume (the handler sends no `Accept-Ranges` on purpose).
9
+ */
10
+ import * as fs from 'node:fs';
11
+ import * as http from 'node:http';
12
+ import * as https from 'node:https';
13
+ import { createHubAgent } from './hub-tls.js';
14
+ export const DOWNLOAD_TIMEOUT_MS = 30 * 60_000;
15
+ export function createHubDownloader(options) {
16
+ return (urlPath, destFile, maxBytes) => new Promise((resolve, reject) => {
17
+ const parsed = new URL(urlPath, options.baseUrl);
18
+ const isHttps = parsed.protocol === 'https:';
19
+ const part = `${destFile}.part`;
20
+ const out = fs.createWriteStream(part, { mode: 0o600 });
21
+ let bytes = 0;
22
+ const fail = (err) => {
23
+ out.destroy();
24
+ fs.rmSync(part, { force: true });
25
+ reject(err);
26
+ };
27
+ const requestOptions = {
28
+ protocol: parsed.protocol,
29
+ hostname: parsed.hostname,
30
+ port: parsed.port || (isHttps ? 443 : 80),
31
+ path: `${parsed.pathname}${parsed.search}`,
32
+ method: 'GET',
33
+ headers: { Authorization: `Bearer ${options.token}` },
34
+ timeout: options.timeoutMs ?? DOWNLOAD_TIMEOUT_MS,
35
+ ...(isHttps ? { agent: createHubAgent(options.tls) } : {}),
36
+ };
37
+ const onResponse = (res) => {
38
+ if (res.statusCode !== 200) {
39
+ res.resume();
40
+ fail(new Error(`hub answered HTTP ${res.statusCode ?? 0} for the export download`));
41
+ return;
42
+ }
43
+ res.on('data', (chunk) => {
44
+ bytes += chunk.length;
45
+ if (bytes > maxBytes) {
46
+ res.destroy(new Error(`export larger than ${maxBytes} bytes — narrow the filter`));
47
+ return;
48
+ }
49
+ if (!out.write(chunk)) {
50
+ res.pause();
51
+ out.once('drain', () => res.resume());
52
+ }
53
+ });
54
+ res.on('error', fail);
55
+ res.on('end', () => {
56
+ out.end(() => {
57
+ try {
58
+ fs.renameSync(part, destFile);
59
+ resolve({ bytes });
60
+ }
61
+ catch (err) {
62
+ fail(err instanceof Error ? err : new Error(String(err)));
63
+ }
64
+ });
65
+ });
66
+ };
67
+ const request = isHttps
68
+ ? https.request(requestOptions, onResponse)
69
+ : http.request(requestOptions, onResponse);
70
+ request.on('error', fail);
71
+ request.on('timeout', () => request.destroy(new Error('export download timed out')));
72
+ request.end();
73
+ });
74
+ }
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+ import type { HubDownloader } from './hub-download.js';
3
+ export declare const LOGS_EXPORT_URL_PATH = "/api/logs/export";
4
+ export declare const DEFAULT_LOGS_EXPORT_MAX_MB = 512;
5
+ export declare const HARD_LOGS_EXPORT_MAX_MB = 4096;
6
+ export declare const LogsExportArgsSchema: z.ZodObject<{
7
+ components: z.ZodOptional<z.ZodArray<z.ZodString>>;
8
+ deviceIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
9
+ sinceMinutes: z.ZodOptional<z.ZodNumber>;
10
+ since: z.ZodOptional<z.ZodNumber>;
11
+ until: z.ZodOptional<z.ZodNumber>;
12
+ level: z.ZodOptional<z.ZodEnum<{
13
+ error: "error";
14
+ warn: "warn";
15
+ info: "info";
16
+ debug: "debug";
17
+ }>>;
18
+ provider: z.ZodOptional<z.ZodString>;
19
+ name: z.ZodOptional<z.ZodString>;
20
+ maxMegabytes: z.ZodOptional<z.ZodNumber>;
21
+ }, z.core.$strip>;
22
+ export type LogsExportArgs = z.infer<typeof LogsExportArgsSchema>;
23
+ /** The query string the hub route reads (`core/logging/log-export.ts`). */
24
+ export declare function logsExportUrl(args: LogsExportArgs, now: number): string;
25
+ export interface LogsExportSummary {
26
+ readonly path: string;
27
+ readonly bytes: number;
28
+ readonly lines: number;
29
+ readonly newest: string | null;
30
+ readonly oldest: string | null;
31
+ readonly levels: Record<string, number>;
32
+ /** The busiest devices, `deviceId → lines`, at most 20. */
33
+ readonly devices: Record<string, number>;
34
+ /** The busiest components, `addonId → lines`, at most 20. */
35
+ readonly components: Record<string, number>;
36
+ /** The hub stopped at its line cap; narrow the filter or the range. */
37
+ readonly truncated: boolean;
38
+ readonly next: string;
39
+ }
40
+ /** Read the downloaded NDJSON once, line by line, into a bounded summary. */
41
+ export declare function summarizeLogsExport(file: string): Promise<Omit<LogsExportSummary, 'path' | 'bytes' | 'next'>>;
42
+ export interface LogsExportDownload extends Omit<LogsExportSummary, 'path' | 'next'> {
43
+ readonly bytes: number;
44
+ }
45
+ /** Download the export to `dest` and summarise it. The caller picks the file and words `path`/`next`. */
46
+ export declare function downloadLogsExport(download: HubDownloader, dest: string, args: LogsExportArgs, at: Date): Promise<LogsExportDownload>;
47
+ //# sourceMappingURL=logs-export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logs-export.d.ts","sourceRoot":"","sources":["../../src/hub/logs-export.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEtD,eAAO,MAAM,oBAAoB,qBAAqB,CAAA;AACtD,eAAO,MAAM,0BAA0B,MAAM,CAAA;AAC7C,eAAO,MAAM,uBAAuB,OAAO,CAAA;AAI3C,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;iBAoB/B,CAAA;AAEF,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P,OAAO,CAAC,kBAAkB,CAAC,CAI7B"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * The Logs page's export (#570): URL builder, args and the NDJSON summary, shared by
3
+ * the operator MCP (`hub_logs_export`) and the public `camstack mcp` (`ops_logs_export`).
4
+ *
5
+ * It downloads the hub's `GET /api/logs/export` — the same route, the same
6
+ * filters and the same default (everything over the last six hours, applied
7
+ * by the hub when no `since` is sent) — into a file, then answers with a
8
+ * bounded summary of the file: how many lines, the time span, the devices and
9
+ * components seen, and whether the hub capped it. Read-only on the cluster;
10
+ * admin credential required (the route is admin-only).
11
+ */
12
+ import * as fs from 'node:fs';
13
+ import * as readline from 'node:readline';
14
+ import { z } from 'zod';
15
+ export const LOGS_EXPORT_URL_PATH = '/api/logs/export';
16
+ export const DEFAULT_LOGS_EXPORT_MAX_MB = 512;
17
+ export const HARD_LOGS_EXPORT_MAX_MB = 4096;
18
+ /** How many distinct devices / components the summary names. */
19
+ const SUMMARY_TOP = 20;
20
+ export const LogsExportArgsSchema = z.object({
21
+ /** addonIds (OR). Omit for every component. */
22
+ components: z.array(z.string().min(1).max(200)).max(100).optional(),
23
+ /** Numeric device ids (OR). Omit for every device. */
24
+ deviceIds: z.array(z.number().int().nonnegative()).max(200).optional(),
25
+ /** Minutes back from `until` (or now). Omit for the hub's default: six hours. */
26
+ sinceMinutes: z.number().positive().max(43_200).optional(),
27
+ /** Epoch ms; overrides sinceMinutes. */
28
+ since: z.number().int().nonnegative().optional(),
29
+ /** Epoch ms; default now. */
30
+ until: z.number().int().nonnegative().optional(),
31
+ level: z.enum(['debug', 'info', 'warn', 'error']).optional(),
32
+ /** A read-capable log-destination addonId, or `ring`. Default the hub's files. */
33
+ provider: z.string().min(1).max(200).optional(),
34
+ /** File name stem under scratchpad/logs-export/; defaults to a timestamp. */
35
+ name: z
36
+ .string()
37
+ .regex(/^[A-Za-z0-9._-]{1,80}$/)
38
+ .optional(),
39
+ maxMegabytes: z.number().int().positive().max(HARD_LOGS_EXPORT_MAX_MB).optional(),
40
+ });
41
+ /** The query string the hub route reads (`core/logging/log-export.ts`). */
42
+ export function logsExportUrl(args, now) {
43
+ const params = new URLSearchParams();
44
+ if (args.components && args.components.length > 0)
45
+ params.set('components', args.components.join(','));
46
+ if (args.deviceIds && args.deviceIds.length > 0)
47
+ params.set('deviceIds', args.deviceIds.join(','));
48
+ const until = args.until;
49
+ const since = args.since ??
50
+ (args.sinceMinutes !== undefined ? (until ?? now) - args.sinceMinutes * 60_000 : undefined);
51
+ if (since !== undefined)
52
+ params.set('since', String(Math.floor(since)));
53
+ if (until !== undefined)
54
+ params.set('until', String(until));
55
+ if (args.level)
56
+ params.set('level', args.level);
57
+ if (args.provider)
58
+ params.set('source', args.provider);
59
+ const query = params.toString();
60
+ return query.length > 0 ? `${LOGS_EXPORT_URL_PATH}?${query}` : LOGS_EXPORT_URL_PATH;
61
+ }
62
+ const ExportedLineSchema = z.looseObject({
63
+ timestamp: z.string().optional(),
64
+ level: z.string().optional(),
65
+ tags: z.record(z.string(), z.string()).optional(),
66
+ truncated: z.boolean().optional(),
67
+ });
68
+ function top(counts) {
69
+ return Object.fromEntries([...counts.entries()].toSorted((a, b) => b[1] - a[1]).slice(0, SUMMARY_TOP));
70
+ }
71
+ function bump(counts, key) {
72
+ if (key === undefined)
73
+ return;
74
+ counts.set(key, (counts.get(key) ?? 0) + 1);
75
+ }
76
+ /** Read the downloaded NDJSON once, line by line, into a bounded summary. */
77
+ export async function summarizeLogsExport(file) {
78
+ const levels = new Map();
79
+ const devices = new Map();
80
+ const components = new Map();
81
+ let lines = 0;
82
+ let newest = null;
83
+ let oldest = null;
84
+ let truncated = false;
85
+ const reader = readline.createInterface({ input: fs.createReadStream(file), crlfDelay: Infinity });
86
+ for await (const text of reader) {
87
+ if (text.trim().length === 0)
88
+ continue;
89
+ const parsed = ExportedLineSchema.safeParse(JSON.parse(text));
90
+ if (!parsed.success)
91
+ continue;
92
+ if (parsed.data.truncated === true) {
93
+ truncated = true;
94
+ continue;
95
+ }
96
+ lines += 1;
97
+ const ts = parsed.data.timestamp ?? null;
98
+ if (ts !== null) {
99
+ newest ??= ts;
100
+ oldest = ts;
101
+ }
102
+ bump(levels, parsed.data.level);
103
+ bump(devices, parsed.data.tags?.['deviceId']);
104
+ bump(components, parsed.data.tags?.['addonId']);
105
+ }
106
+ return {
107
+ lines,
108
+ newest,
109
+ oldest,
110
+ levels: Object.fromEntries(levels),
111
+ devices: top(devices),
112
+ components: top(components),
113
+ truncated,
114
+ };
115
+ }
116
+ /** Download the export to `dest` and summarise it. The caller picks the file and words `path`/`next`. */
117
+ export async function downloadLogsExport(download, dest, args, at) {
118
+ const maxBytes = (args.maxMegabytes ?? DEFAULT_LOGS_EXPORT_MAX_MB) * 1024 * 1024;
119
+ const { bytes } = await download(logsExportUrl(args, at.getTime()), dest, maxBytes);
120
+ return { bytes, ...(await summarizeLogsExport(dest)) };
121
+ }
package/dist/index.d.ts CHANGED
@@ -36,4 +36,8 @@ export { gateQuery, isSecretBearing, type GateDecision, } from './mcp/query-gate
36
36
  export { CONFIRM_TTL_MS, MAX_OUTSTANDING_TOKENS, MUTATIONS_DISABLED_REASON, MutationGate, canonicalJson, digestArgs, runGated, stderrAudit, type AuditPhase, type AuditRecord, type AuditSink, type ConfirmDecision, type DryRunOutcome, type GatedResult, type GatedToolSpec, type IssuedToken, type MutationGateOptions, } from './mcp/mutation-gate.js';
37
37
  export * from './mcp/ops/wire.js';
38
38
  export * from './mcp/ops/track-findings.js';
39
+ export { createHubDownloader, DOWNLOAD_TIMEOUT_MS } from './hub/hub-download.js';
40
+ export type { DownloaderOptions, HubDownloader } from './hub/hub-download.js';
41
+ export { DEFAULT_LOGS_EXPORT_MAX_MB, downloadLogsExport, HARD_LOGS_EXPORT_MAX_MB, LOGS_EXPORT_URL_PATH, LogsExportArgsSchema, logsExportUrl, summarizeLogsExport, } from './hub/logs-export.js';
42
+ export type { LogsExportArgs, LogsExportDownload, LogsExportSummary } from './hub/logs-export.js';
39
43
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAElE,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE3D,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EACL,WAAW,EACX,eAAe,EACf,WAAW,EACX,UAAU,GACX,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,GACZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAE7E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAElD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAIrE,OAAO,EACL,gBAAgB,EAChB,cAA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,EACnB,oBAAoB,GACrB,MAAM,qBAAqB,CAAA;AAK5B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EACL,QAAQ,EACR,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,UAAU,GAChB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,UAAU,EACV,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,gBAAgB,GACtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,SAAS,EACT,eAAe,EACf,KAAK,YAAY,GAClB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,yBAAyB,EACzB,YAAY,EACZ,aAAa,EACb,UAAU,EACV,QAAQ,EACR,WAAW,EACX,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,mBAAmB,GACzB,MAAM,wBAAwB,CAAA;AAG/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,6BAA6B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAElE,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,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B,YAAY,EACZ,aAAa,EACb,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,UAAU,GAChB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,UAAU,EACV,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,gBAAgB,GACtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,SAAS,EACT,eAAe,EACf,KAAK,YAAY,GAClB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,yBAAyB,EACzB,YAAY,EACZ,aAAa,EACb,UAAU,EACV,QAAQ,EACR,WAAW,EACX,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,mBAAmB,GACzB,MAAM,wBAAwB,CAAA;AAG/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,6BAA6B,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAChF,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,mBAAmB,GACpB,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA"}
package/dist/index.js CHANGED
@@ -36,3 +36,5 @@ export { CONFIRM_TTL_MS, MAX_OUTSTANDING_TOKENS, MUTATIONS_DISABLED_REASON, Muta
36
36
  // (ops toolset) and the private operator MCP.
37
37
  export * from './mcp/ops/wire.js';
38
38
  export * from './mcp/ops/track-findings.js';
39
+ export { createHubDownloader, DOWNLOAD_TIMEOUT_MS } from './hub/hub-download.js';
40
+ export { DEFAULT_LOGS_EXPORT_MAX_MB, downloadLogsExport, HARD_LOGS_EXPORT_MAX_MB, LOGS_EXPORT_URL_PATH, LogsExportArgsSchema, logsExportUrl, summarizeLogsExport, } from './hub/logs-export.js';
@@ -5,5 +5,5 @@
5
5
  * fields of its own form. Pattern: the Home Assistant export targets.
6
6
  */
7
7
  export declare const EXPORTER_INSTANCES_TS = "/**\n * <%= displayName %> export targets as `integration-instances` (D1009): one `targets` record per\n * target, with a MINTED id (`<%= fileName %>_001`, ...). The devices exported to a target are the\n * `devices` list of ITS record, so deleting the target deletes the exposure and two targets never\n * share one.\n */\nimport {\n type ConfigUISchema,\n defineEntryKind,\n entryBody,\n type IntegrationTestConnectionResult,\n RecordIntegrationInstances,\n type RecordsAccess,\n isInstanceEnabled,\n} from '@camstack/types'\nimport { z } from 'zod'\n\nexport const <%= className %>_TARGET_KIND = '<%= fileName %>-target'\nexport const <%= className %>_ID_PREFIX = '<%= fileName %>_'\n\nexport const <%= className %>TargetsKind = defineEntryKind('targets', {\n title: '<%= displayName %> export targets',\n schema: entryBody({\n endpoint: z.string().optional(),\n token: z.string().optional().meta({ secret: true }),\n devices: z.array(z.string()).optional(),\n /** The target's own switch (D996). Absent means on. */\n enabled: z.boolean().optional(),\n }),\n writeTrigger: 'an operator adds, edits, switches or deletes a target, or exports a device to it',\n})\nexport type <%= className %>TargetBody = z.infer<typeof <%= className %>TargetsKind.schema>\n\n/** Every record kind this addon declares, keyed by its name. */\nexport const <%= className %>RecordKinds = { targets: <%= className %>TargetsKind } as const\n\n/** The next free minted id given the ids that exist (`<%= fileName %>_001`, `<%= fileName %>_002`, ...). */\nexport function next<%= className %>TargetId(existing: Iterable<string>): string {\n let highest = 0\n for (const id of existing) {\n if (!id.startsWith(<%= className %>_ID_PREFIX)) continue\n const n = Number(id.slice(<%= className %>_ID_PREFIX.length))\n if (Number.isInteger(n) && n > highest) highest = n\n }\n return <%= className %>_ID_PREFIX + String(highest + 1).padStart(3, '0')\n}\n\nexport function build<%= className %>TargetForm(addonId: string): ConfigUISchema {\n return {\n sections: [\n {\n id: 'target',\n title: 'Target',\n columns: 1,\n fields: [\n { type: 'text', key: 'name', label: 'Name' },\n { type: 'text', key: 'endpoint', label: 'Endpoint' },\n { type: 'password', key: 'token', label: 'Token', showToggle: true },\n {\n type: 'addon-action-button',\n addonId,\n key: '__resync',\n label: 'Re-announce',\n buttonLabel: 'Push every exposed device now',\n action: 'resync',\n paramsFromForm: { endpoint: 'endpoint' },\n },\n ],\n },\n ],\n }\n}\n\nexport interface <%= className %>TargetDeps {\n /** The ids of the targets that exist now; read per call, a minted id never reuses one. */\n readonly ids: () => readonly string[]\n /** Runs after every change; reload the exposure from the records. */\n readonly onChanged: (id: string) => Promise<void>\n readonly probe: (values: Readonly<Record<string, unknown>>) => Promise<IntegrationTestConnectionResult>\n}\n\nexport function open<%= className %>Targets(\n records: Pick<RecordsAccess, 'kind' | 'owner'>,\n deps: <%= className %>TargetDeps,\n): RecordIntegrationInstances<<%= className %>TargetBody> {\n return new RecordIntegrationInstances<<%= className %>TargetBody>(\n records,\n <%= className %>TargetsKind,\n {\n description: {\n role: 'services',\n instanceMode: 'multiple',\n kind: 'target',\n canTest: true,\n // The one kind this provider serves; kindOf below stamps it on every instance.\n kinds: [{ id: <%= className %>_TARGET_KIND, label: '<%= displayName %>', functionCap: 'device-export', role: 'services' }],\n },\n formSchema: () => build<%= className %>TargetForm('<%= fileName %>'),\n initialBody: (name): <%= className %>TargetBody => ({ name, devices: [] }),\n mintId: () => next<%= className %>TargetId(deps.ids()),\n kindOf: () => <%= className %>_TARGET_KIND,\n // A target without an endpoint is unconfigured: it pushes nothing and KEEPS its devices.\n configured: (body) => (body.endpoint ?? '').length > 0,\n onChanged: (id) => deps.onChanged(id),\n test: ({ values }) => deps.probe(values),\n },\n )\n}\n";
8
- export declare const EXPORTER_ADDON_TS = "/**\n * <%= displayName %> - an exporter (`device-export` + `integration-instances`, D1009). Every\n * exporter is multi-instance: each target is an instance with a minted id, and a membership change\n * ALWAYS names the target it changes. Exposure is the `devices` list of the target's record, keyed\n * by the instance id; an id this addon does not serve is refused by name, never answered empty.\n */\nimport {\n type AddonInitResult,\n BaseAddon,\n customAction,\n defineCustomActions,\n deviceExportCapability,\n deviceExportStatusInstanceOf,\n ExportInstanceUnknownError,\n type IDeviceExportProvider,\n type IntegrationTestConnectionResult,\n integrationInstancesCapability,\n type RecordKindHandle,\n} from '@camstack/types'\nimport { z } from 'zod'\nimport {\n open<%= className %>Targets,\n <%= className %>_TARGET_KIND,\n <%= className %>RecordKinds,\n <%= className %>TargetsKind,\n type <%= className %>TargetBody,\n} from './<%= fileName %>-instances.js'\n\nconst <%= className %>Actions = defineCustomActions({\n resync: customAction(\n z.object({ endpoint: z.string().optional() }),\n z.object({ summary: z.string() }),\n { kind: 'mutation', auth: 'admin' },\n ),\n})\n\n/** The device kinds this exporter can carry; the device picker filters on it. */\nconst SUPPORTED_DEVICE_KINDS: readonly string[] = ['sensor', 'switch', 'light']\n\nexport class <%= className %>Addon extends BaseAddon<Readonly<Record<string, never>>> {\n private targets: RecordKindHandle<<%= className %>TargetBody> | null = null\n /** Target id to its record body; reloaded from the records after every change. */\n private book = new Map<string, <%= className %>TargetBody>()\n\n constructor() {\n super({})\n }\n\n protected override async onInitialize(): Promise<AddonInitResult> {\n const records = this.ctx.records\n if (records === undefined) {\n throw new Error('<%= fileName %>: ctx.records is required (hub-only addon)')\n }\n await records.declare(<%= className %>RecordKinds)\n this.targets = records.kind(<%= className %>TargetsKind)\n const instances = open<%= className %>Targets(records, {\n ids: () => [...this.book.keys()],\n onChanged: () => this.reload(),\n probe: (values) => this.probe(values),\n })\n await this.reload()\n return {\n providers: [\n { capability: deviceExportCapability, provider: this.buildExportProvider() },\n { capability: integrationInstancesCapability, provider: instances.toProvider() },\n ],\n customActions: <%= className %>Actions,\n actionHandlers: {\n resync: async () => {\n await this.reload()\n return { summary: 'Re-announced ' + this.book.size + ' target(s).' }\n },\n },\n }\n }\n\n /** Reload every target from the records; the synchronous read the event path needs. */\n private async reload(): Promise<void> {\n const targets = this.targets\n if (targets === null) return\n const page = await targets.query({ limit: 1000 })\n this.book = new Map(page.records.map((row) => [row.id, row.data]))\n }\n\n /** The body of a target this addon serves, or the named refusal. */\n private target(instanceId: string): <%= className %>TargetBody {\n const body = this.book.get(instanceId)\n if (body === undefined) throw new ExportInstanceUnknownError(this.ctx.id, instanceId)\n return body\n }\n\n private async setMembership(\n instanceId: string,\n deviceId: string,\n exposed: boolean,\n ): Promise<void> {\n const body = this.target(instanceId)\n const current = new Set(body.devices ?? [])\n if (exposed) current.add(deviceId)\n else current.delete(deviceId)\n await this.targets?.patch(instanceId, { devices: [...current] })\n await this.reload()\n }\n\n private buildExportProvider(): IDeviceExportProvider {\n return {\n getStatus: async (input) => {\n const instanceId = deviceExportStatusInstanceOf(input)\n const bodies =\n instanceId === undefined ? [...this.book.values()] : [this.target(instanceId)]\n return {\n linkState: bodies.some((b) => (b.endpoint ?? '').length > 0) ? 'linked' : 'unlinked',\n exposedDeviceCount: new Set(bodies.flatMap((b) => b.devices ?? [])).size,\n }\n },\n listInstances: async () =>\n [...this.book.entries()].map(([instanceId, body]) => ({\n instanceId,\n name: body.name,\n enabled: isInstanceEnabled(body),\n kind: <%= className %>_TARGET_KIND,\n })),\n listSupportedDeviceKinds: async ({ instanceId }) => {\n if (instanceId !== undefined) this.target(instanceId)\n return [...SUPPORTED_DEVICE_KINDS]\n },\n listExposedDevices: async ({ instanceId }) => {\n const bodies =\n instanceId === undefined ? [...this.book.values()] : [this.target(instanceId)]\n return bodies.flatMap((b) => (b.devices ?? []).map((deviceId) => ({ deviceId })))\n },\n exposeDevice: async ({ instanceId, deviceId }) =>\n this.setMembership(instanceId, deviceId, true),\n unexposeDevice: async ({ instanceId, deviceId }) =>\n this.setMembership(instanceId, deviceId, false),\n }\n }\n\n /** Replace with a real call to the remote; `rejected` is a definite no, `inconclusive` is \"could not tell\". */\n private async probe(\n values: Readonly<Record<string, unknown>>,\n ): Promise<IntegrationTestConnectionResult> {\n const endpoint = values['endpoint']\n if (typeof endpoint !== 'string' || endpoint.length === 0) {\n return { success: false, status: 'rejected', error: 'Endpoint is required' }\n }\n return { success: true, status: 'validated' }\n }\n}\n\nexport default <%= className %>Addon\n";
8
+ export declare const EXPORTER_ADDON_TS = "/**\n * <%= displayName %> - an exporter (`device-export` + `integration-instances`, D1009). Every\n * exporter is multi-instance: each target is an instance with a minted id, and a membership change\n * ALWAYS names the target it changes. Exposure is the `devices` list of the target's record, keyed\n * by the instance id; an id this addon does not serve is refused by name, never answered empty.\n */\nimport {\n type AddonInitResult,\n BaseAddon,\n customAction,\n defineCustomActions,\n deviceExportCapability,\n deviceExportStatusInstanceOf,\n ExportInstanceUnknownError,\n exposedNameStoreOf,\n freeTextNameValidator,\n type IDeviceExportProvider,\n type IntegrationTestConnectionResult,\n integrationInstancesCapability,\n type RecordKindHandle,\n saveExposedName,\n} from '@camstack/types'\nimport { z } from 'zod'\nimport {\n open<%= className %>Targets,\n <%= className %>_TARGET_KIND,\n <%= className %>RecordKinds,\n <%= className %>TargetsKind,\n type <%= className %>TargetBody,\n} from './<%= fileName %>-instances.js'\n\nconst <%= className %>Actions = defineCustomActions({\n resync: customAction(\n z.object({ endpoint: z.string().optional() }),\n z.object({ summary: z.string() }),\n { kind: 'mutation', auth: 'admin' },\n ),\n})\n\n/** The device kinds this exporter can carry; the device picker filters on it. */\nconst SUPPORTED_DEVICE_KINDS: readonly string[] = ['sensor', 'switch', 'light']\n\nexport class <%= className %>Addon extends BaseAddon<Readonly<Record<string, never>>> {\n private targets: RecordKindHandle<<%= className %>TargetBody> | null = null\n /** Target id to its record body; reloaded from the records after every change. */\n private book = new Map<string, <%= className %>TargetBody>()\n\n constructor() {\n super({})\n }\n\n protected override async onInitialize(): Promise<AddonInitResult> {\n const records = this.ctx.records\n if (records === undefined) {\n throw new Error('<%= fileName %>: ctx.records is required (hub-only addon)')\n }\n await records.declare(<%= className %>RecordKinds)\n this.targets = records.kind(<%= className %>TargetsKind)\n const instances = open<%= className %>Targets(records, {\n ids: () => [...this.book.keys()],\n onChanged: () => this.reload(),\n probe: (values) => this.probe(values),\n })\n await this.reload()\n return {\n providers: [\n { capability: deviceExportCapability, provider: this.buildExportProvider() },\n { capability: integrationInstancesCapability, provider: instances.toProvider() },\n ],\n customActions: <%= className %>Actions,\n actionHandlers: {\n resync: async () => {\n await this.reload()\n return { summary: 'Re-announced ' + this.book.size + ' target(s).' }\n },\n },\n }\n }\n\n /** Reload every target from the records; the synchronous read the event path needs. */\n private async reload(): Promise<void> {\n const targets = this.targets\n if (targets === null) return\n const page = await targets.query({ limit: 1000 })\n this.book = new Map(page.records.map((row) => [row.id, row.data]))\n }\n\n /** The body of a target this addon serves, or the named refusal. */\n private target(instanceId: string): <%= className %>TargetBody {\n const body = this.book.get(instanceId)\n if (body === undefined) throw new ExportInstanceUnknownError(this.ctx.id, instanceId)\n return body\n }\n\n private async setMembership(\n instanceId: string,\n deviceId: string,\n exposed: boolean,\n ): Promise<void> {\n const body = this.target(instanceId)\n const current = new Set(body.devices ?? [])\n if (exposed) current.add(deviceId)\n else current.delete(deviceId)\n await this.targets?.patch(instanceId, { devices: [...current] })\n await this.reload()\n }\n\n private buildExportProvider(): IDeviceExportProvider {\n return {\n getStatus: async (input) => {\n const instanceId = deviceExportStatusInstanceOf(input)\n const bodies =\n instanceId === undefined ? [...this.book.values()] : [this.target(instanceId)]\n return {\n linkState: bodies.some((b) => (b.endpoint ?? '').length > 0) ? 'linked' : 'unlinked',\n exposedDeviceCount: new Set(bodies.flatMap((b) => b.devices ?? [])).size,\n }\n },\n listInstances: async () =>\n [...this.book.entries()].map(([instanceId, body]) => ({\n instanceId,\n name: body.name,\n enabled: isInstanceEnabled(body),\n kind: <%= className %>_TARGET_KIND,\n })),\n listSupportedDeviceKinds: async ({ instanceId }) => {\n if (instanceId !== undefined) this.target(instanceId)\n return [...SUPPORTED_DEVICE_KINDS]\n },\n listExposedDevices: async ({ instanceId }) => {\n const bodies =\n instanceId === undefined ? [...this.book.values()] : [this.target(instanceId)]\n return bodies.flatMap((b) => (b.devices ?? []).map((deviceId) => ({ deviceId })))\n },\n exposeDevice: async ({ instanceId, deviceId }) =>\n this.setMembership(instanceId, deviceId, true),\n unexposeDevice: async ({ instanceId, deviceId }) =>\n this.setMembership(instanceId, deviceId, false),\n // The device's name on this target (D1049): stored per instance in this addon's per-device\n // store, never part of the exported id. Replace the validator with the platform's rule.\n setExposedName: async ({ instanceId, deviceId, name }) => {\n this.target(instanceId)\n await saveExposedName({\n store: exposedNameStoreOf(this.ctx.settings, this.ctx.id),\n deviceId: Number(deviceId),\n instanceId,\n raw: name,\n validate: freeTextNameValidator('<%= displayName %>', 100),\n })\n },\n }\n }\n\n /** Replace with a real call to the remote; `rejected` is a definite no, `inconclusive` is \"could not tell\". */\n private async probe(\n values: Readonly<Record<string, unknown>>,\n ): Promise<IntegrationTestConnectionResult> {\n const endpoint = values['endpoint']\n if (typeof endpoint !== 'string' || endpoint.length === 0) {\n return { success: false, status: 'rejected', error: 'Endpoint is required' }\n }\n return { success: true, status: 'validated' }\n }\n}\n\nexport default <%= className %>Addon\n";
9
9
  //# sourceMappingURL=integration-exporter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"integration-exporter.d.ts","sourceRoot":"","sources":["../../src/scaffold/integration-exporter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,qBAAqB,wxIA4GjC,CAAA;AAED,eAAO,MAAM,iBAAiB,mrLAuJ7B,CAAA"}
1
+ {"version":3,"file":"integration-exporter.d.ts","sourceRoot":"","sources":["../../src/scaffold/integration-exporter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,qBAAqB,wxIA4GjC,CAAA;AAED,eAAO,MAAM,iBAAiB,uzMAsK7B,CAAA"}
@@ -127,10 +127,13 @@ import {
127
127
  deviceExportCapability,
128
128
  deviceExportStatusInstanceOf,
129
129
  ExportInstanceUnknownError,
130
+ exposedNameStoreOf,
131
+ freeTextNameValidator,
130
132
  type IDeviceExportProvider,
131
133
  type IntegrationTestConnectionResult,
132
134
  integrationInstancesCapability,
133
135
  type RecordKindHandle,
136
+ saveExposedName,
134
137
  } from '@camstack/types'
135
138
  import { z } from 'zod'
136
139
  import {
@@ -248,6 +251,18 @@ export class <%= className %>Addon extends BaseAddon<Readonly<Record<string, nev
248
251
  this.setMembership(instanceId, deviceId, true),
249
252
  unexposeDevice: async ({ instanceId, deviceId }) =>
250
253
  this.setMembership(instanceId, deviceId, false),
254
+ // The device's name on this target (D1049): stored per instance in this addon's per-device
255
+ // store, never part of the exported id. Replace the validator with the platform's rule.
256
+ setExposedName: async ({ instanceId, deviceId, name }) => {
257
+ this.target(instanceId)
258
+ await saveExposedName({
259
+ store: exposedNameStoreOf(this.ctx.settings, this.ctx.id),
260
+ deviceId: Number(deviceId),
261
+ instanceId,
262
+ raw: name,
263
+ validate: freeTextNameValidator('<%= displayName %>', 100),
264
+ })
265
+ },
251
266
  }
252
267
  }
253
268
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/develop",
3
- "version": "0.1.52",
3
+ "version": "0.1.54",
4
4
  "description": "CamStack developer tooling — catalogue, scaffold, validate, and example lookup shared by the CLI and MCP server.",
5
5
  "keywords": [
6
6
  "camstack",
@@ -163,6 +163,25 @@ arrives `undefined` on the addon path. Prefer top-level defaults.
163
163
  `deviceConfig` (generic cap) or `exposesDeviceSettings` with the three
164
164
  injected methods (owned cap) — never a parallel tab system. Decision rule and
165
165
  traps: the `camstack-addon` skill, "A UI surface on a DEVICE page".
166
+ - **A device cap changes what the device LOOKS like — audit every surface it
167
+ reaches, in the same piece of work.** A new or changed `deviceNative` /
168
+ device cap (a method, a state field, a new mode) is not done until each
169
+ surface that draws that device answers it or is consciously left as is:
170
+ - **device details** — the device card (`ui-library` `composites/device-card`:
171
+ `connected/cap-card-kinds.ts` maps a device type or role to a card kind,
172
+ `connected/Connected<Kind>Card.tsx` reads the slice, `scenes/<kind>/`
173
+ draws it; `device-controls/panel-controls.tsx` picks the panel) and the
174
+ device page's derived sections (`deviceConfig` / `exposesDeviceSettings`);
175
+ - **device rows** — the inline row in device lists (`device-controls`
176
+ `control-registry.tsx` / `*-inline.tsx`, `device-list/group.ts`) and the
177
+ viewer's accessory rows and panel controls (`camstack/src/accessories/`,
178
+ `camstack/src/components/camera/accessory-controls/`);
179
+ - shared cards render in the viewer too, so a card change is a viewer change.
180
+ List the surfaces in the plan with "changed" / "unchanged: why". A new state
181
+ field no surface reads (a countdown, a mode, `activeUntil`) is a feature the
182
+ operator cannot see; a field a card draws but the cap no longer sends is a
183
+ card that lies. Viewer layout is co-designed with the operator before it is
184
+ built (`camstack-ui-viewer`); the card/row are UI work (`camstack-ui`).
166
185
  - **"Absent" only from an answered query** (D315): ask
167
186
  `capabilities.getCapability` / `useCapabilityPresence`, never infer absence
168
187
  from `(data ?? [])`, and never throw the literal "provider not available"
@@ -212,6 +231,7 @@ hand-edits: index.ts re-export + AnyCapability union — yes
212
231
  codegen: npm run codegen — clean; method tiers / export coverage — <accepted diff | unchanged>
213
232
  manifest: declared in <package>/package.json (+ agent main.ts array: <yes|n/a>)
214
233
  spec: <spec file> — <result>
234
+ surfaces: device card <changed|unchanged: why>; device row <changed|unchanged: why>; viewer accessory row/panel <changed|unchanged: why>
215
235
  shipped: <"not shipped" | published system+server X.Y.Z, applied on <nodes>, addon deployed>
216
236
  verified: <the call and its answer, or "not deployed">
217
237
  docs: camstack-docs gate — <files | none needed: reason>