swarmdo 1.45.0 → 1.54.1
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/.claude/helpers/hook-handler.cjs +16 -0
- package/.claude/helpers/router.cjs +27 -1
- package/.claude/settings.local.json +7 -0
- package/README.md +6 -2
- package/package.json +1 -1
- package/v3/@swarmdo/cli/dist/src/agent-bridge/bridge.d.ts +104 -0
- package/v3/@swarmdo/cli/dist/src/agent-bridge/bridge.js +133 -0
- package/v3/@swarmdo/cli/dist/src/commands/agent.js +133 -1
- package/v3/@swarmdo/cli/dist/src/commands/config.js +32 -1
- package/v3/@swarmdo/cli/dist/src/commands/hidden-coupling.d.ts +19 -0
- package/v3/@swarmdo/cli/dist/src/commands/hidden-coupling.js +92 -0
- package/v3/@swarmdo/cli/dist/src/commands/index.js +14 -4
- package/v3/@swarmdo/cli/dist/src/commands/ownership.d.ts +18 -0
- package/v3/@swarmdo/cli/dist/src/commands/ownership.js +88 -0
- package/v3/@swarmdo/cli/dist/src/commands/pack.js +4 -4
- package/v3/@swarmdo/cli/dist/src/commands/standup.d.ts +18 -0
- package/v3/@swarmdo/cli/dist/src/commands/standup.js +116 -0
- package/v3/@swarmdo/cli/dist/src/commands/swarm.js +29 -0
- package/v3/@swarmdo/cli/dist/src/config-lint/commands-lint.d.ts +31 -0
- package/v3/@swarmdo/cli/dist/src/config-lint/commands-lint.js +127 -0
- package/v3/@swarmdo/cli/dist/src/config-lint/lint.d.ts +5 -0
- package/v3/@swarmdo/cli/dist/src/config-lint/lint.js +4 -0
- package/v3/@swarmdo/cli/dist/src/coupling/hidden.d.ts +45 -0
- package/v3/@swarmdo/cli/dist/src/coupling/hidden.js +66 -0
- package/v3/@swarmdo/cli/dist/src/init/helpers-generator.js +41 -1
- package/v3/@swarmdo/cli/dist/src/mcp-client.js +2 -0
- package/v3/@swarmdo/cli/dist/src/mcp-tools/agent-tools.js +166 -0
- package/v3/@swarmdo/cli/dist/src/mcp-tools/index.d.ts +1 -0
- package/v3/@swarmdo/cli/dist/src/mcp-tools/index.js +1 -0
- package/v3/@swarmdo/cli/dist/src/mcp-tools/ownership-tools.d.ts +14 -0
- package/v3/@swarmdo/cli/dist/src/mcp-tools/ownership-tools.js +51 -0
- package/v3/@swarmdo/cli/dist/src/mcp-tools/profiles.js +1 -0
- package/v3/@swarmdo/cli/dist/src/mcp-tools/swarm-tools.d.ts +33 -0
- package/v3/@swarmdo/cli/dist/src/mcp-tools/swarm-tools.js +73 -38
- package/v3/@swarmdo/cli/dist/src/ownership/ownership.d.ts +61 -0
- package/v3/@swarmdo/cli/dist/src/ownership/ownership.js +151 -0
- package/v3/@swarmdo/cli/dist/src/pack/pack.d.ts +1 -1
- package/v3/@swarmdo/cli/dist/src/pack/pack.js +12 -4
- package/v3/@swarmdo/cli/dist/src/redact/redact.js +28 -9
- package/v3/@swarmdo/cli/dist/src/standup/standup.d.ts +83 -0
- package/v3/@swarmdo/cli/dist/src/standup/standup.js +157 -0
- package/v3/@swarmdo/cli/package.json +1 -1
- package/v3/@swarmdo/cli-core/dist/src/index.js +1 -1
- package/v3/@swarmdo/codex/dist/cli.js +0 -0
- package/v3/@swarmdo/hooks/dist/cli/guidance-cli.js +0 -0
- package/v3/@swarmdo/hooks/dist/statusline/index.d.ts +3 -3
- package/v3/@swarmdo/hooks/dist/statusline/index.js +3 -3
- package/v3/@swarmdo/integration/dist/__tests__/agentic-flow-agent.test.js +1 -4
- package/v3/@swarmdo/neural/dist/flash-attention.d.ts +1 -1
- package/v3/@swarmdo/neural/dist/flash-attention.js +1 -1
- package/v3/@swarmdo/plugin-agent-federation/dist/plugin.js +1 -1
- package/v3/@swarmdo/plugin-agent-federation/dist/transport/midstream-aware-loader.js +2 -2
- package/v3/@swarmdo/plugin-iot-cognitum/dist/application/index.d.ts +2 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/application/index.js +2 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/application/iot-coordinator.d.ts +138 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/application/iot-coordinator.js +418 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/bin.d.ts +15 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/bin.js +240 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/cli-commands.d.ts +7 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/cli-commands.js +508 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-agent.d.ts +54 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-agent.js +2 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-fleet.d.ts +46 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-fleet.js +2 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-trust-level.d.ts +18 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/device-trust-level.js +28 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/index.d.ts +5 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/index.js +2 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/telemetry.d.ts +35 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/entities/telemetry.js +2 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/device-repository.d.ts +11 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/device-repository.js +2 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/fleet-repository.d.ts +9 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/fleet-repository.js +2 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/index.d.ts +5 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/index.js +2 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/telemetry-repository.d.ts +12 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/telemetry-repository.js +2 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/trust-history-repository.d.ts +19 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/repositories/trust-history-repository.js +2 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/anomaly-detection-service.d.ts +44 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/anomaly-detection-service.js +117 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/device-lifecycle-service.d.ts +70 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/device-lifecycle-service.js +194 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/firmware-orchestration-service.d.ts +69 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/firmware-orchestration-service.js +139 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/fleet-topology-service.d.ts +34 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/fleet-topology-service.js +101 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/index.d.ts +10 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/index.js +10 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/mesh-service.d.ts +64 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/mesh-service.js +70 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/sona-integration-service.d.ts +44 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/sona-integration-service.js +79 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/telemetry-ingestion-service.d.ts +37 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/telemetry-ingestion-service.js +39 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/telemetry-service.d.ts +67 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/telemetry-service.js +58 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/witness-verification-service.d.ts +45 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/domain/services/witness-verification-service.js +63 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/index.d.ts +26 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/index.js +17 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/agentdb-telemetry-repository.d.ts +51 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/agentdb-telemetry-repository.js +110 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-device-repository.d.ts +13 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-device-repository.js +25 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-fleet-repository.d.ts +11 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-fleet-repository.js +19 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-trust-history-repository.d.ts +11 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/in-memory-trust-history-repository.js +27 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/index.d.ts +6 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/index.js +6 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/seed-client-factory.d.ts +41 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/infrastructure/seed-client-factory.js +64 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/mcp-tools.d.ts +8 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/mcp-tools.js +703 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/plugin.d.ts +23 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/plugin.js +239 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/anomaly-scan-worker.d.ts +17 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/anomaly-scan-worker.js +42 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/firmware-watch-worker.d.ts +18 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/firmware-watch-worker.js +45 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/health-probe-worker.d.ts +19 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/health-probe-worker.js +50 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/mesh-sync-worker.d.ts +19 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/mesh-sync-worker.js +47 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/telemetry-ingest-worker.d.ts +17 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/telemetry-ingest-worker.js +40 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/witness-audit-worker.d.ts +18 -0
- package/v3/@swarmdo/plugin-iot-cognitum/dist/workers/witness-audit-worker.js +51 -0
- package/v3/@swarmdo/providers/dist/swarmvector-provider.d.ts +1 -1
- package/v3/@swarmdo/providers/dist/swarmvector-provider.js +1 -1
- package/v3/@swarmdo/security/dist/input-validator.d.ts +6 -6
- package/v3/@swarmdo/shared/dist/hooks/safety/git-commit.js +1 -1
- package/v3/@swarmdo/shared/dist/mcp/transport/http.js +1 -8
- package/v3/@swarmdo/testing/dist/fixtures/agent-fixtures.d.ts +214 -0
- package/v3/@swarmdo/testing/dist/fixtures/agent-fixtures.js +595 -0
- package/v3/@swarmdo/testing/dist/fixtures/agents.d.ts +76 -0
- package/v3/@swarmdo/testing/dist/fixtures/agents.js +158 -0
- package/v3/@swarmdo/testing/dist/fixtures/configurations.d.ts +157 -0
- package/v3/@swarmdo/testing/dist/fixtures/configurations.js +337 -0
- package/v3/@swarmdo/testing/dist/fixtures/index.d.ts +10 -0
- package/v3/@swarmdo/testing/dist/fixtures/index.js +17 -0
- package/v3/@swarmdo/testing/dist/fixtures/mcp-fixtures.d.ts +329 -0
- package/v3/@swarmdo/testing/dist/fixtures/mcp-fixtures.js +714 -0
- package/v3/@swarmdo/testing/dist/fixtures/memory-entries.d.ts +159 -0
- package/v3/@swarmdo/testing/dist/fixtures/memory-entries.js +262 -0
- package/v3/@swarmdo/testing/dist/fixtures/memory-fixtures.d.ts +290 -0
- package/v3/@swarmdo/testing/dist/fixtures/memory-fixtures.js +547 -0
- package/v3/@swarmdo/testing/dist/fixtures/swarm-fixtures.d.ts +289 -0
- package/v3/@swarmdo/testing/dist/fixtures/swarm-fixtures.js +534 -0
- package/v3/@swarmdo/testing/dist/fixtures/tasks.d.ts +106 -0
- package/v3/@swarmdo/testing/dist/fixtures/tasks.js +229 -0
- package/v3/@swarmdo/testing/dist/helpers/assertion-helpers.d.ts +213 -0
- package/v3/@swarmdo/testing/dist/helpers/assertion-helpers.js +435 -0
- package/v3/@swarmdo/testing/dist/helpers/assertions.d.ts +135 -0
- package/v3/@swarmdo/testing/dist/helpers/assertions.js +217 -0
- package/v3/@swarmdo/testing/dist/helpers/create-mock.d.ts +96 -0
- package/v3/@swarmdo/testing/dist/helpers/create-mock.js +164 -0
- package/v3/@swarmdo/testing/dist/helpers/index.d.ts +14 -0
- package/v3/@swarmdo/testing/dist/helpers/index.js +22 -0
- package/v3/@swarmdo/testing/dist/helpers/mock-factory.d.ts +323 -0
- package/v3/@swarmdo/testing/dist/helpers/mock-factory.js +350 -0
- package/v3/@swarmdo/testing/dist/helpers/setup-teardown.d.ts +271 -0
- package/v3/@swarmdo/testing/dist/helpers/setup-teardown.js +446 -0
- package/v3/@swarmdo/testing/dist/helpers/swarm-instance.d.ts +142 -0
- package/v3/@swarmdo/testing/dist/helpers/swarm-instance.js +205 -0
- package/v3/@swarmdo/testing/dist/helpers/test-application.d.ts +190 -0
- package/v3/@swarmdo/testing/dist/helpers/test-application.js +138 -0
- package/v3/@swarmdo/testing/dist/helpers/test-utils.d.ts +274 -0
- package/v3/@swarmdo/testing/dist/helpers/test-utils.js +456 -0
- package/v3/@swarmdo/testing/dist/index.d.ts +42 -0
- package/v3/@swarmdo/testing/dist/index.js +66 -0
- package/v3/@swarmdo/testing/dist/mocks/index.d.ts +8 -0
- package/v3/@swarmdo/testing/dist/mocks/index.js +10 -0
- package/v3/@swarmdo/testing/dist/mocks/mock-mcp-client.d.ts +206 -0
- package/v3/@swarmdo/testing/dist/mocks/mock-mcp-client.js +575 -0
- package/v3/@swarmdo/testing/dist/mocks/mock-services.d.ts +287 -0
- package/v3/@swarmdo/testing/dist/mocks/mock-services.js +563 -0
- package/v3/@swarmdo/testing/dist/regression/api-contract.d.ts +109 -0
- package/v3/@swarmdo/testing/dist/regression/api-contract.js +374 -0
- package/v3/@swarmdo/testing/dist/regression/index.d.ts +18 -0
- package/v3/@swarmdo/testing/dist/regression/index.js +18 -0
- package/v3/@swarmdo/testing/dist/regression/integration-regression.d.ts +67 -0
- package/v3/@swarmdo/testing/dist/regression/integration-regression.js +334 -0
- package/v3/@swarmdo/testing/dist/regression/performance-baseline.d.ts +106 -0
- package/v3/@swarmdo/testing/dist/regression/performance-baseline.js +268 -0
- package/v3/@swarmdo/testing/dist/regression/regression-runner.d.ts +124 -0
- package/v3/@swarmdo/testing/dist/regression/regression-runner.js +227 -0
- package/v3/@swarmdo/testing/dist/regression/security-regression.d.ts +73 -0
- package/v3/@swarmdo/testing/dist/regression/security-regression.js +258 -0
- package/v3/@swarmdo/testing/dist/setup.d.ts +43 -0
- package/v3/@swarmdo/testing/dist/setup.js +91 -0
- package/v3/@swarmdo/testing/dist/v2-compat/api-compat.test.d.ts +10 -0
- package/v3/@swarmdo/testing/dist/v2-compat/api-compat.test.js +433 -0
- package/v3/@swarmdo/testing/dist/v2-compat/cli-compat.test.d.ts +10 -0
- package/v3/@swarmdo/testing/dist/v2-compat/cli-compat.test.js +352 -0
- package/v3/@swarmdo/testing/dist/v2-compat/compatibility-validator.d.ts +206 -0
- package/v3/@swarmdo/testing/dist/v2-compat/compatibility-validator.js +839 -0
- package/v3/@swarmdo/testing/dist/v2-compat/hooks-compat.test.d.ts +10 -0
- package/v3/@swarmdo/testing/dist/v2-compat/hooks-compat.test.js +428 -0
- package/v3/@swarmdo/testing/dist/v2-compat/index.d.ts +38 -0
- package/v3/@swarmdo/testing/dist/v2-compat/index.js +41 -0
- package/v3/@swarmdo/testing/dist/v2-compat/mcp-compat.test.d.ts +10 -0
- package/v3/@swarmdo/testing/dist/v2-compat/mcp-compat.test.js +419 -0
- package/v3/@swarmdo/testing/dist/v2-compat/report-generator.d.ts +34 -0
- package/v3/@swarmdo/testing/dist/v2-compat/report-generator.js +372 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Standalone CLI shim for @swarmdo/plugin-iot-cognitum.
|
|
4
|
+
* Maps `cognitum-iot <subcommand> [args]` -> CLICommandDefinition handlers.
|
|
5
|
+
*
|
|
6
|
+
* Endpoint defaults:
|
|
7
|
+
* - http://169.254.42.1 (USB-C link-local, no auth — read-only paths)
|
|
8
|
+
* - https://169.254.42.1:8443 (LAN/HTTPS + bearer — full access including writes)
|
|
9
|
+
*
|
|
10
|
+
* Auth: COGNITUM_SEED_TOKEN is read from process.env (loaded from .env in CWD
|
|
11
|
+
* if present) and passed to register as the pairing/bearer token. When set,
|
|
12
|
+
* the default endpoint switches to the HTTPS LAN address.
|
|
13
|
+
*/
|
|
14
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
15
|
+
import { resolve } from 'node:path';
|
|
16
|
+
import { IoTCognitumPlugin } from './plugin.js';
|
|
17
|
+
const SEED_LINK_LOCAL = 'http://169.254.42.1';
|
|
18
|
+
const SEED_LAN_HTTPS = 'https://169.254.42.1:8443';
|
|
19
|
+
/**
|
|
20
|
+
* Tiny .env loader. Walks up from CWD looking for a .env, reads KEY=VALUE
|
|
21
|
+
* lines (ignoring blanks and # comments), and applies them to process.env
|
|
22
|
+
* WITHOUT overwriting variables already set in the real environment.
|
|
23
|
+
*/
|
|
24
|
+
function loadDotenv() {
|
|
25
|
+
let dir = process.cwd();
|
|
26
|
+
for (let i = 0; i < 8; i++) {
|
|
27
|
+
const candidate = resolve(dir, '.env');
|
|
28
|
+
if (existsSync(candidate)) {
|
|
29
|
+
const text = readFileSync(candidate, 'utf8');
|
|
30
|
+
let count = 0;
|
|
31
|
+
for (const rawLine of text.split('\n')) {
|
|
32
|
+
const line = rawLine.trim();
|
|
33
|
+
if (!line || line.startsWith('#'))
|
|
34
|
+
continue;
|
|
35
|
+
const eq = line.indexOf('=');
|
|
36
|
+
if (eq < 1)
|
|
37
|
+
continue;
|
|
38
|
+
const key = line.slice(0, eq).trim();
|
|
39
|
+
let val = line.slice(eq + 1).trim();
|
|
40
|
+
// Strip surrounding quotes
|
|
41
|
+
if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) {
|
|
42
|
+
val = val.slice(1, -1);
|
|
43
|
+
}
|
|
44
|
+
if (process.env[key] === undefined) {
|
|
45
|
+
process.env[key] = val;
|
|
46
|
+
count++;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return { loaded: candidate, count };
|
|
50
|
+
}
|
|
51
|
+
const parent = resolve(dir, '..');
|
|
52
|
+
if (parent === dir)
|
|
53
|
+
break;
|
|
54
|
+
dir = parent;
|
|
55
|
+
}
|
|
56
|
+
return { loaded: null, count: 0 };
|
|
57
|
+
}
|
|
58
|
+
loadDotenv();
|
|
59
|
+
const SEED_TOKEN = process.env.COGNITUM_SEED_TOKEN;
|
|
60
|
+
const SEED_DEFAULT_ENDPOINT = process.env.COGNITUM_SEED_ENDPOINT ?? (SEED_TOKEN ? SEED_LAN_HTTPS : SEED_LINK_LOCAL);
|
|
61
|
+
function makeContext() {
|
|
62
|
+
// Minimal in-memory context for standalone CLI use.
|
|
63
|
+
const noop = () => undefined;
|
|
64
|
+
return {
|
|
65
|
+
config: {
|
|
66
|
+
fleetId: process.env.IOT_FLEET_ID ?? 'default',
|
|
67
|
+
zoneId: process.env.IOT_ZONE_ID ?? 'zone-0',
|
|
68
|
+
tlsInsecure: process.env.IOT_TLS_INSECURE !== 'false',
|
|
69
|
+
},
|
|
70
|
+
eventBus: {
|
|
71
|
+
emit: noop,
|
|
72
|
+
on: noop,
|
|
73
|
+
off: noop,
|
|
74
|
+
once: noop,
|
|
75
|
+
},
|
|
76
|
+
logger: {
|
|
77
|
+
info: (...a) => console.log('[info]', ...a),
|
|
78
|
+
warn: (...a) => console.warn('[warn]', ...a),
|
|
79
|
+
error: (...a) => console.error('[error]', ...a),
|
|
80
|
+
debug: (...a) => process.env.DEBUG && console.error('[debug]', ...a),
|
|
81
|
+
},
|
|
82
|
+
services: {
|
|
83
|
+
get: () => undefined,
|
|
84
|
+
register: noop,
|
|
85
|
+
has: () => false,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Parse argv minimally: positional -> _, --flag value, --flag=value, --boolean,
|
|
91
|
+
* short -e value. Numeric values stay as strings (handlers coerce as needed).
|
|
92
|
+
*/
|
|
93
|
+
function parseArgs(argv) {
|
|
94
|
+
const out = { _: [] };
|
|
95
|
+
for (let i = 0; i < argv.length; i++) {
|
|
96
|
+
const a = argv[i];
|
|
97
|
+
if (a.startsWith('--')) {
|
|
98
|
+
const eq = a.indexOf('=');
|
|
99
|
+
if (eq > -1) {
|
|
100
|
+
out[a.slice(2, eq)] = a.slice(eq + 1);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const key = a.slice(2);
|
|
104
|
+
const next = argv[i + 1];
|
|
105
|
+
if (next === undefined || next.startsWith('-')) {
|
|
106
|
+
out[key] = true;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
out[key] = next;
|
|
110
|
+
i++;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (a.startsWith('-') && a.length > 1) {
|
|
115
|
+
const key = a.slice(1);
|
|
116
|
+
const next = argv[i + 1];
|
|
117
|
+
if (next === undefined || next.startsWith('-')) {
|
|
118
|
+
out[key] = true;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
out[key] = next;
|
|
122
|
+
i++;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
out._.push(a);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
function aliasShortToLong(args) {
|
|
132
|
+
// Most common short flags used across the iot commands.
|
|
133
|
+
const aliases = {
|
|
134
|
+
e: 'endpoint',
|
|
135
|
+
f: 'fleet-id',
|
|
136
|
+
z: 'zone-id',
|
|
137
|
+
d: 'device-id',
|
|
138
|
+
v: 'version',
|
|
139
|
+
k: 'k',
|
|
140
|
+
n: 'name',
|
|
141
|
+
t: 'token',
|
|
142
|
+
};
|
|
143
|
+
for (const [s, l] of Object.entries(aliases)) {
|
|
144
|
+
if (s in args && !(l in args)) {
|
|
145
|
+
args[l] = args[s];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return args;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Resolve a subcommand path against command definitions.
|
|
152
|
+
* Supports multi-word commands: `iot fleet add`, `iot firmware deploy`, etc.
|
|
153
|
+
* Tries longest match first.
|
|
154
|
+
*/
|
|
155
|
+
function resolveCommand(argv, commandNames) {
|
|
156
|
+
// Strip the leading "iot" prefix from each defined command for matching.
|
|
157
|
+
const tokens = argv.slice();
|
|
158
|
+
// Try longest match (3 tokens, then 2, then 1).
|
|
159
|
+
for (const len of [3, 2, 1]) {
|
|
160
|
+
if (tokens.length < len)
|
|
161
|
+
continue;
|
|
162
|
+
const probe = 'iot ' + tokens.slice(0, len).join(' ');
|
|
163
|
+
if (commandNames.includes(probe)) {
|
|
164
|
+
return { name: probe, rest: tokens.slice(len) };
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
function printHelp(commandNames) {
|
|
170
|
+
console.log('cognitum-iot — Cognitum Seed device-agent CLI');
|
|
171
|
+
console.log('');
|
|
172
|
+
console.log('Usage: cognitum-iot <subcommand> [options]');
|
|
173
|
+
console.log('');
|
|
174
|
+
console.log('Default endpoint: ' + SEED_DEFAULT_ENDPOINT);
|
|
175
|
+
console.log(' - http://169.254.42.1 (USB-C link-local, no auth, read-only)');
|
|
176
|
+
console.log(' - https://169.254.42.1:8443 (LAN/HTTPS, COGNITUM_SEED_TOKEN required, full access)');
|
|
177
|
+
console.log('');
|
|
178
|
+
console.log('Auth: set COGNITUM_SEED_TOKEN in .env or environment to use the bearer-protected');
|
|
179
|
+
console.log(' LAN endpoint and unlock writes (ingest, unpair, etc).');
|
|
180
|
+
console.log(' Status: ' + (SEED_TOKEN ? '✓ token loaded' : '✗ no token (link-local only)'));
|
|
181
|
+
console.log('');
|
|
182
|
+
console.log('Hardware: get a Seed at https://cognitum.one');
|
|
183
|
+
console.log('');
|
|
184
|
+
console.log('Subcommands:');
|
|
185
|
+
for (const n of commandNames) {
|
|
186
|
+
console.log(' ' + n.replace(/^iot /, ''));
|
|
187
|
+
}
|
|
188
|
+
console.log('');
|
|
189
|
+
console.log('Run "cognitum-iot <subcommand> --help" for command-specific options.');
|
|
190
|
+
}
|
|
191
|
+
async function main() {
|
|
192
|
+
const argv = process.argv.slice(2);
|
|
193
|
+
if (argv.length === 0 || argv[0] === '--help' || argv[0] === '-h') {
|
|
194
|
+
// Need to bootstrap to enumerate commands.
|
|
195
|
+
}
|
|
196
|
+
const plugin = new IoTCognitumPlugin();
|
|
197
|
+
const context = makeContext();
|
|
198
|
+
await plugin.initialize(context);
|
|
199
|
+
const commands = plugin.registerCLICommands();
|
|
200
|
+
const commandNames = commands.map((c) => c.name);
|
|
201
|
+
if (argv.length === 0 || argv[0] === '--help' || argv[0] === '-h') {
|
|
202
|
+
printHelp(commandNames);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const resolved = resolveCommand(argv, commandNames);
|
|
206
|
+
if (!resolved) {
|
|
207
|
+
console.error('Unknown subcommand: ' + argv.join(' '));
|
|
208
|
+
console.error('Run "cognitum-iot --help" to list available subcommands.');
|
|
209
|
+
process.exitCode = 1;
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const cmd = commands.find((c) => c.name === resolved.name);
|
|
213
|
+
const args = aliasShortToLong(parseArgs(resolved.rest));
|
|
214
|
+
// Endpoint + token defaults for `iot register`.
|
|
215
|
+
if (resolved.name === 'iot register') {
|
|
216
|
+
if (!args['endpoint']) {
|
|
217
|
+
args['endpoint'] = SEED_DEFAULT_ENDPOINT;
|
|
218
|
+
console.error(`[info] No --endpoint supplied; defaulting to ${SEED_DEFAULT_ENDPOINT}`);
|
|
219
|
+
}
|
|
220
|
+
if (!args['token'] && SEED_TOKEN) {
|
|
221
|
+
args['token'] = SEED_TOKEN;
|
|
222
|
+
console.error('[info] Using COGNITUM_SEED_TOKEN from environment');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
try {
|
|
226
|
+
await cmd.handler(args);
|
|
227
|
+
}
|
|
228
|
+
catch (err) {
|
|
229
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
230
|
+
console.error('Error: ' + msg);
|
|
231
|
+
process.exitCode = 1;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
main()
|
|
235
|
+
.then(() => process.exit(process.exitCode ?? 0))
|
|
236
|
+
.catch((err) => {
|
|
237
|
+
console.error('Fatal: ' + (err instanceof Error ? err.message : String(err)));
|
|
238
|
+
process.exit(1);
|
|
239
|
+
});
|
|
240
|
+
//# sourceMappingURL=bin.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CLICommandDefinition, PluginContext } from '@swarmdo/shared/src/plugin-interface.js';
|
|
2
|
+
import type { IoTCoordinator } from './application/iot-coordinator.js';
|
|
3
|
+
type CoordinatorGetter = () => IoTCoordinator | null;
|
|
4
|
+
type ContextGetter = () => PluginContext | null;
|
|
5
|
+
export declare function createCliCommands(getCoordinator: CoordinatorGetter, _getContext: ContextGetter): CLICommandDefinition[];
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=cli-commands.d.ts.map
|