@sentropic/cluster-mesh 0.1.0 → 0.8.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.
Files changed (74) hide show
  1. package/README.md +42 -7
  2. package/dist/config.d.ts +19 -0
  3. package/dist/config.d.ts.map +1 -0
  4. package/dist/config.js +20 -0
  5. package/dist/config.js.map +1 -0
  6. package/dist/hono/cli-router.d.ts +36 -0
  7. package/dist/hono/cli-router.d.ts.map +1 -0
  8. package/dist/hono/cli-router.js +116 -0
  9. package/dist/hono/cli-router.js.map +1 -0
  10. package/dist/hono/health-router.d.ts +41 -0
  11. package/dist/hono/health-router.d.ts.map +1 -0
  12. package/dist/hono/health-router.js +46 -0
  13. package/dist/hono/health-router.js.map +1 -0
  14. package/dist/hono/plugin.d.ts +12 -0
  15. package/dist/hono/plugin.d.ts.map +1 -0
  16. package/dist/hono/plugin.js +15 -0
  17. package/dist/hono/plugin.js.map +1 -0
  18. package/dist/hono/session-contracts.d.ts +38 -0
  19. package/dist/hono/session-contracts.d.ts.map +1 -0
  20. package/dist/hono/session-contracts.js +2 -0
  21. package/dist/hono/session-contracts.js.map +1 -0
  22. package/dist/hono/session-router.d.ts +11 -0
  23. package/dist/hono/session-router.d.ts.map +1 -0
  24. package/dist/hono/session-router.js +142 -0
  25. package/dist/hono/session-router.js.map +1 -0
  26. package/dist/hono/workspaces-router.d.ts +32 -0
  27. package/dist/hono/workspaces-router.d.ts.map +1 -0
  28. package/dist/hono/workspaces-router.js +50 -0
  29. package/dist/hono/workspaces-router.js.map +1 -0
  30. package/dist/index.d.ts +15 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +15 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/memory.d.ts +57 -0
  35. package/dist/memory.d.ts.map +1 -1
  36. package/dist/memory.js +70 -0
  37. package/dist/memory.js.map +1 -1
  38. package/dist/mesh.d.ts +1 -0
  39. package/dist/mesh.d.ts.map +1 -1
  40. package/dist/mesh.js +1 -0
  41. package/dist/mesh.js.map +1 -1
  42. package/dist/persistence/ports.d.ts +101 -0
  43. package/dist/persistence/ports.d.ts.map +1 -0
  44. package/dist/persistence/ports.js +4 -0
  45. package/dist/persistence/ports.js.map +1 -0
  46. package/dist/runtime/admission.d.ts +32 -0
  47. package/dist/runtime/admission.d.ts.map +1 -0
  48. package/dist/runtime/admission.js +33 -0
  49. package/dist/runtime/admission.js.map +1 -0
  50. package/dist/runtime/generation.d.ts +29 -0
  51. package/dist/runtime/generation.d.ts.map +1 -0
  52. package/dist/runtime/generation.js +30 -0
  53. package/dist/runtime/generation.js.map +1 -0
  54. package/dist/runtime/mcp-supervisor.d.ts +51 -0
  55. package/dist/runtime/mcp-supervisor.d.ts.map +1 -0
  56. package/dist/runtime/mcp-supervisor.js +56 -0
  57. package/dist/runtime/mcp-supervisor.js.map +1 -0
  58. package/dist/runtime/namespace-registry.d.ts +12 -0
  59. package/dist/runtime/namespace-registry.d.ts.map +1 -0
  60. package/dist/runtime/namespace-registry.js +27 -0
  61. package/dist/runtime/namespace-registry.js.map +1 -0
  62. package/dist/runtime/receipts.d.ts +20 -0
  63. package/dist/runtime/receipts.d.ts.map +1 -0
  64. package/dist/runtime/receipts.js +40 -0
  65. package/dist/runtime/receipts.js.map +1 -0
  66. package/dist/runtime/registration.d.ts +63 -0
  67. package/dist/runtime/registration.d.ts.map +1 -0
  68. package/dist/runtime/registration.js +58 -0
  69. package/dist/runtime/registration.js.map +1 -0
  70. package/dist/runtime/session-cutover.d.ts +37 -0
  71. package/dist/runtime/session-cutover.d.ts.map +1 -0
  72. package/dist/runtime/session-cutover.js +56 -0
  73. package/dist/runtime/session-cutover.js.map +1 -0
  74. package/package.json +7 -2
package/README.md CHANGED
@@ -1,10 +1,14 @@
1
1
  # @sentropic/cluster-mesh
2
2
 
3
- Federal-shaped cluster contracts with a functional single-instance runtime.
3
+ Injectable Cluster Mesh control-plane contracts and a functional single-instance
4
+ runtime.
4
5
 
5
- Version 0.1 ships the degenerate topology: one Sentropic server, its attached local
6
- workstations, local signed projections, and the existing device-code lifecycle. It does
7
- not implement server-to-server federation.
6
+ Version 0.8 adds the central generation, namespace, registration, admission,
7
+ receipt, persistence-port, MCP-supervisor, and Hono plugin contracts used by the
8
+ Sentropic product and standalone IdP composition roots. It retains the degenerate
9
+ topology introduced in 0.1: one Sentropic server, its attached local workstations,
10
+ local signed projections, and the existing device-code lifecycle. It does not
11
+ implement server-to-server federation.
8
12
 
9
13
  ## Available in v1
10
14
 
@@ -16,11 +20,41 @@ not implement server-to-server federation.
16
20
  command execution.
17
21
  - Tenant residence resolved only through an approved-membership port.
18
22
  - Deterministic workspace references in the form `ws:sha256:<digest>`.
23
+ - One active generation and one selected author per registered namespace.
24
+ - Durable registration, capacity-lease, lifecycle, and acted-receipt ports whose
25
+ concrete storage remains host-owned.
26
+ - A reusable Hono plugin plus injectable `/session`, `/cli`, `/health`, and
27
+ `/workspaces` namespace transports.
28
+ - One logical MCP supervisor authority per generation, expressed through an
29
+ injected runtime port rather than a per-session server.
19
30
 
20
31
  Tenant identity and workspace identity are intentionally distinct. `tid` is returned by
21
32
  the authoritative membership resolver; it is never copied from a request workspace id.
22
33
  An unresolved membership throws `TenantBoundaryError`.
23
34
 
35
+ ## Central control plane
36
+
37
+ `createClusterMeshPlugin` mounts independently constructed namespace modules.
38
+ The package owns selection and fail-closed author checks; product domains,
39
+ databases, provider credentials, and concrete transports stay behind injected
40
+ ports. A host may disable a module without importing its provider implementation.
41
+
42
+ The public runtime contracts model real terminal actuation and external MCP
43
+ qualification, but this package does not fabricate those integrations. A host
44
+ must provide and qualify them before claiming PTY wake/relaunch, LOST detection,
45
+ or multi-session MCP acceptance.
46
+
47
+ Production invocation verification uses a dedicated Ed25519 key ring configured
48
+ through `CLUSTER_MESH_ED25519_PUBLIC_KEYS_JSON`. Its JSON shape is
49
+ `[{"kid":"...","alg":"EdDSA","crv":"Ed25519","publicKeyBase64Url":"..."}]`,
50
+ where `publicKeyBase64Url` is base64url-encoded SPKI DER. Malformed JSON or keys
51
+ abort startup; an absent or empty ring remains fail-closed. The audience defaults
52
+ to the local session-control URL, can be set with `CLUSTER_MESH_EVIDENCE_AUDIENCE`,
53
+ and accepts only explicit comma-separated additions from
54
+ `CLUSTER_MESH_LEGACY_AUDIENCES`. Signed evidence has a maximum lifetime of 300
55
+ seconds. Shared-secret A1 evidence is restricted to explicit non-production
56
+ qualification and is rejected in production.
57
+
24
58
  ## Gated seams
25
59
 
26
60
  The public surface already defines the future federal ports, but the v1 runtime fails
@@ -36,9 +70,10 @@ HTTP route, trusted-issuer store, inter-server directory, or replication runtime
36
70
 
37
71
  ## Construction
38
72
 
39
- `createDegenerateClusterMesh` composes the membership, trust, wrap, device, and tenant
40
- boundary domains. Every effectful operation is supplied through a typed port, so the
41
- package owns no application persistence or transport.
73
+ `createDegenerateClusterMesh` composes the membership, trust, wrap, device, and
74
+ tenant-boundary domains. `createClusterMeshPlugin` composes the central namespace
75
+ surface. Every effectful operation is supplied through a typed port, so the
76
+ package owns no application persistence or provider transport.
42
77
 
43
78
  ```ts
44
79
  import { createDegenerateClusterMesh } from '@sentropic/cluster-mesh';
@@ -0,0 +1,19 @@
1
+ export declare const DEFAULT_CLUSTER_MESH_MAX_CONCURRENT = 12;
2
+ export interface ClusterMeshConfigInput {
3
+ readonly capacity: {
4
+ readonly poolSize: number;
5
+ readonly maxConcurrent?: number;
6
+ };
7
+ }
8
+ export interface ClusterMeshConfig {
9
+ readonly capacity: {
10
+ readonly poolSize: number;
11
+ readonly maxConcurrent: number;
12
+ };
13
+ }
14
+ export declare class ClusterMeshConfigError extends Error {
15
+ readonly code = "invalid_cluster_mesh_config";
16
+ constructor(message: string);
17
+ }
18
+ export declare function resolveClusterMeshConfig(input: ClusterMeshConfigInput): ClusterMeshConfig;
19
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mCAAmC,KAAK,CAAC;AAEtD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,QAAQ,EAAE;QACjB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;KACjC,CAAC;CACH;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE;QACjB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;KAChC,CAAC;CACH;AAED,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,IAAI,iCAAiC;gBAElC,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,sBAAsB,GAAG,iBAAiB,CAYzF"}
package/dist/config.js ADDED
@@ -0,0 +1,20 @@
1
+ export const DEFAULT_CLUSTER_MESH_MAX_CONCURRENT = 12;
2
+ export class ClusterMeshConfigError extends Error {
3
+ code = 'invalid_cluster_mesh_config';
4
+ constructor(message) {
5
+ super(message);
6
+ this.name = 'ClusterMeshConfigError';
7
+ }
8
+ }
9
+ export function resolveClusterMeshConfig(input) {
10
+ const maxConcurrent = input.capacity.maxConcurrent ?? DEFAULT_CLUSTER_MESH_MAX_CONCURRENT;
11
+ const poolSize = input.capacity.poolSize;
12
+ if (!Number.isInteger(maxConcurrent) || maxConcurrent <= 0) {
13
+ throw new ClusterMeshConfigError('clusterMesh.capacity.maxConcurrent must be a positive integer');
14
+ }
15
+ if (!Number.isInteger(poolSize) || poolSize <= 0 || poolSize > maxConcurrent) {
16
+ throw new ClusterMeshConfigError('clusterMesh.capacity.poolSize must be a positive integer not greater than maxConcurrent');
17
+ }
18
+ return { capacity: { maxConcurrent, poolSize } };
19
+ }
20
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mCAAmC,GAAG,EAAE,CAAC;AAgBtD,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IACtC,IAAI,GAAG,6BAA6B,CAAC;IAE9C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,MAAM,UAAU,wBAAwB,CAAC,KAA6B;IACpE,MAAM,aAAa,GAAG,KAAK,CAAC,QAAQ,CAAC,aAAa,IAAI,mCAAmC,CAAC;IAC1F,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC;IACzC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,aAAa,IAAI,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,sBAAsB,CAAC,+DAA+D,CAAC,CAAC;IACpG,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,IAAI,CAAC,IAAI,QAAQ,GAAG,aAAa,EAAE,CAAC;QAC7E,MAAM,IAAI,sBAAsB,CAC9B,yFAAyF,CAC1F,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE,CAAC;AACnD,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { type MiddlewareHandler } from 'hono';
2
+ import type { ClusterMeshHonoNamespaceModule } from './plugin.js';
3
+ export declare const CLI_PATHS: readonly ["/intents", "/delegations/:action"];
4
+ export declare const CLI_CONTROL_ACTIONS: readonly ["drive", "wake", "relaunch"];
5
+ export type CliControlAction = (typeof CLI_CONTROL_ACTIONS)[number];
6
+ export interface CliCommandIntent {
7
+ readonly runnerId: string;
8
+ readonly source: string;
9
+ readonly argv: readonly string[];
10
+ }
11
+ export interface CliCommandIntentAdapter {
12
+ readonly runnerId: string;
13
+ readonly source: string;
14
+ parseIntent(argv: readonly string[]): CliCommandIntent | null;
15
+ }
16
+ export interface CliSessionDelegatePort {
17
+ readonly kind: 'session-control-http';
18
+ delegate(input: {
19
+ readonly method: 'POST';
20
+ readonly path: `/auth/session/control/${CliControlAction}`;
21
+ readonly headers: Readonly<Record<string, string>>;
22
+ readonly body: {
23
+ readonly commandId: string;
24
+ readonly targetRegistrationId: string;
25
+ readonly idempotencyKey: string;
26
+ };
27
+ }): Promise<Response>;
28
+ }
29
+ export declare function createCliNamespaceModule(options?: {
30
+ readonly enabled?: boolean;
31
+ readonly generationId?: string;
32
+ readonly authenticate?: MiddlewareHandler;
33
+ readonly adapters?: readonly CliCommandIntentAdapter[];
34
+ readonly session?: CliSessionDelegatePort;
35
+ }): ClusterMeshHonoNamespaceModule;
36
+ //# sourceMappingURL=cli-router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-router.d.ts","sourceRoot":"","sources":["../../src/hono/cli-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAElE,eAAO,MAAM,SAAS,+CAAgD,CAAC;AACvE,eAAO,MAAM,mBAAmB,wCAAyC,CAAC;AAC1E,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,gBAAgB,GAAG,IAAI,CAAC;CAC/D;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,IAAI,EAAE,yBAAyB,gBAAgB,EAAE,CAAC;QAC3D,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACnD,QAAQ,CAAC,IAAI,EAAE;YACb,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;YAC3B,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;YACtC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;SACjC,CAAC;KACH,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CACvB;AA6BD,wBAAgB,wBAAwB,CAAC,OAAO,GAAE;IAChD,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,YAAY,CAAC,EAAE,iBAAiB,CAAC;IAC1C,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,uBAAuB,EAAE,CAAC;IACvD,QAAQ,CAAC,OAAO,CAAC,EAAE,sBAAsB,CAAC;CACtC,GAAG,8BAA8B,CAmFtC"}
@@ -0,0 +1,116 @@
1
+ import { Hono } from 'hono';
2
+ export const CLI_PATHS = ['/intents', '/delegations/:action'];
3
+ export const CLI_CONTROL_ACTIONS = ['drive', 'wake', 'relaunch'];
4
+ const forbiddenAuthority = ['process', 'pty', 'session', 'spawn', 'execute'];
5
+ const parseEnvelope = (value) => {
6
+ if (!value || typeof value !== 'object')
7
+ return null;
8
+ const body = value;
9
+ if (forbiddenAuthority.some((key) => key in body))
10
+ return null;
11
+ if (typeof body.runnerId !== 'string' || !body.runnerId)
12
+ return null;
13
+ if (!Array.isArray(body.argv) || body.argv.some((arg) => typeof arg !== 'string' || arg.includes('\0'))) {
14
+ return null;
15
+ }
16
+ for (const key of ['commandId', 'targetRegistrationId', 'idempotencyKey']) {
17
+ if (body[key] !== undefined && (typeof body[key] !== 'string' || !body[key]))
18
+ return null;
19
+ }
20
+ return body;
21
+ };
22
+ const controlAction = (value) => CLI_CONTROL_ACTIONS.includes(value) ? value : null;
23
+ export function createCliNamespaceModule(options = {}) {
24
+ const adapters = new Map();
25
+ for (const adapter of options.adapters ?? []) {
26
+ if (adapters.has(adapter.runnerId))
27
+ throw new Error(`duplicate CLI runner: ${adapter.runnerId}`);
28
+ adapters.set(adapter.runnerId, adapter);
29
+ }
30
+ return {
31
+ namespace: '/cli',
32
+ enabled: options.enabled ?? false,
33
+ createRouter(ports) {
34
+ const router = new Hono();
35
+ for (const path of CLI_PATHS)
36
+ router.use(path, options.authenticate ?? (async (_c, next) => next()));
37
+ const prepare = async (c) => {
38
+ if (!options.generationId)
39
+ return { error: c.json({ error: 'cli_runtime_unavailable' }, 503) };
40
+ const invocationId = c.req.header('x-cluster-mesh-invocation-id');
41
+ if (!invocationId)
42
+ return { error: c.json({ error: 'cli_invocation_reference_required' }, 400) };
43
+ let verified;
44
+ try {
45
+ verified = await ports.context.verify({
46
+ invocationId,
47
+ correlationId: c.req.header('x-correlation-id') ?? invocationId,
48
+ generationId: options.generationId,
49
+ method: c.req.method,
50
+ path: c.req.path,
51
+ authorizationEvidenceRef: c.req.header('x-cluster-mesh-evidence'),
52
+ });
53
+ }
54
+ catch {
55
+ return { error: c.json({ error: 'cli_invocation_unverified' }, 401) };
56
+ }
57
+ if (!verified.registration)
58
+ return { error: c.json({ error: 'missing_registration' }, 409) };
59
+ const envelope = parseEnvelope(await c.req.json().catch(() => null));
60
+ if (!envelope)
61
+ return { error: c.json({ error: 'invalid_cli_command_intent' }, 400) };
62
+ const adapter = adapters.get(envelope.runnerId);
63
+ if (!adapter)
64
+ return { error: c.json({ error: 'cli_runner_unavailable' }, 503) };
65
+ const intent = adapter.parseIntent(envelope.argv);
66
+ if (!intent || intent.runnerId !== adapter.runnerId || intent.source !== adapter.source) {
67
+ return { error: c.json({ error: 'invalid_cli_command_intent' }, 400) };
68
+ }
69
+ return { envelope, intent, verified };
70
+ };
71
+ router.post('/intents', async (c) => {
72
+ const prepared = await prepare(c);
73
+ if ('error' in prepared)
74
+ return prepared.error;
75
+ return c.json({ status: 'shadow', intent: prepared.intent, effectsDuplicated: false });
76
+ });
77
+ router.post('/delegations/:action', async (c) => {
78
+ const action = controlAction(c.req.param('action'));
79
+ if (!action)
80
+ return c.json({ error: 'unsupported_session_action' }, 400);
81
+ const prepared = await prepare(c);
82
+ if ('error' in prepared)
83
+ return prepared.error;
84
+ const { envelope, verified } = prepared;
85
+ if (!envelope.commandId || !envelope.targetRegistrationId || !envelope.idempotencyKey) {
86
+ return c.json({ error: 'invalid_session_control_intent' }, 400);
87
+ }
88
+ if (envelope.targetRegistrationId !== verified.registration.registrationId) {
89
+ return c.json({ error: 'registration_mismatch' }, 409);
90
+ }
91
+ if (!options.session)
92
+ return c.json({ error: 'cli_session_delegate_unavailable' }, 503);
93
+ const headers = {
94
+ 'content-type': 'application/json',
95
+ 'x-cluster-mesh-invocation-id': verified.invocationId,
96
+ 'x-correlation-id': verified.correlationId,
97
+ };
98
+ const evidence = c.req.header('x-cluster-mesh-evidence');
99
+ if (evidence)
100
+ headers['x-cluster-mesh-evidence'] = evidence;
101
+ return options.session.delegate({
102
+ method: 'POST',
103
+ path: `/auth/session/control/${action}`,
104
+ headers,
105
+ body: {
106
+ commandId: envelope.commandId,
107
+ targetRegistrationId: envelope.targetRegistrationId,
108
+ idempotencyKey: envelope.idempotencyKey,
109
+ },
110
+ });
111
+ });
112
+ return router;
113
+ },
114
+ };
115
+ }
116
+ //# sourceMappingURL=cli-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-router.js","sourceRoot":"","sources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M,EAAE;oBACvC,OAAO;oBACP,IAAI,EAAE;wBACJ,SAAS,EAAE,QAAQ,CAAC,SAAS;wBAC7B,oBAAoB,EAAE,QAAQ,CAAC,oBAAoB;wBACnD,cAAc,EAAE,QAAQ,CAAC,cAAc;qBACxC;iBACF,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YACH,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { ClusterMeshNamespace } from '@sentropic/contracts';
2
+ import { Hono, type MiddlewareHandler } from 'hono';
3
+ import type { ClusterMeshHonoNamespaceModule } from './plugin.js';
4
+ export declare const HEALTH_ROUTES: readonly [readonly ["GET", "/health"]];
5
+ export declare const HEALTH_PATHS: readonly ["/health"];
6
+ export type HealthProbeStatus = 'ok' | 'degraded' | 'unavailable';
7
+ export type HealthServiceValue = string | number | boolean | null | readonly HealthServiceValue[] | {
8
+ readonly [key: string]: HealthServiceValue;
9
+ };
10
+ export interface HealthProbeResult {
11
+ readonly status: HealthProbeStatus;
12
+ readonly reason?: string;
13
+ readonly services?: Readonly<Record<string, HealthServiceValue>>;
14
+ }
15
+ export interface HealthProbePort {
16
+ readonly name: string;
17
+ check(): Promise<HealthProbeResult>;
18
+ }
19
+ export interface HealthStatePort {
20
+ snapshot(): {
21
+ readonly generation: {
22
+ readonly generationId: string;
23
+ readonly status: string;
24
+ };
25
+ readonly modules: readonly {
26
+ readonly namespace: ClusterMeshNamespace;
27
+ readonly enabled: boolean;
28
+ }[];
29
+ };
30
+ }
31
+ export interface HealthRouterOptions {
32
+ readonly probes: readonly HealthProbePort[];
33
+ readonly state: HealthStatePort;
34
+ readonly beforeProbe?: MiddlewareHandler;
35
+ readonly now?: () => Date;
36
+ }
37
+ export declare const createHealthRouter: (options: HealthRouterOptions) => Hono;
38
+ export declare const createHealthNamespaceModule: (options: HealthRouterOptions & {
39
+ readonly enabled?: boolean;
40
+ }) => ClusterMeshHonoNamespaceModule;
41
+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CAAC;YACzC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;SAC3B,EAAE,CAAC;KACL,CAAC;CACH;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;IAC5C,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,WAAW,CAAC,EAAE,iBAAiB,CAAC;IACzC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAUD,eAAO,MAAM,kBAAkB,YAAa,mBAAmB,KAAG,IA2BjE,CAAC;AAEF,eAAO,MAAM,2BAA2B,YAC7B,mBAAmB,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,KAC5D,8BAID,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { Hono } from 'hono';
2
+ export const HEALTH_ROUTES = [['GET', '/health']];
3
+ export const HEALTH_PATHS = ['/health'];
4
+ const runProbe = async (probe) => {
5
+ try {
6
+ return await probe.check();
7
+ }
8
+ catch {
9
+ return { status: 'unavailable', reason: `${probe.name}_probe_failed` };
10
+ }
11
+ };
12
+ export const createHealthRouter = (options) => {
13
+ if (!options.probes.length || !options.state?.snapshot) {
14
+ throw new Error('health probes and state are unavailable');
15
+ }
16
+ const router = new Hono();
17
+ if (options.beforeProbe)
18
+ router.get('/health', options.beforeProbe);
19
+ router.get('/health', async (context) => {
20
+ const results = await Promise.all(options.probes.map(async (probe) => ({
21
+ name: probe.name,
22
+ result: await runProbe(probe),
23
+ })));
24
+ const reasons = results
25
+ .filter(({ result }) => result.status !== 'ok')
26
+ .map(({ name, result }) => result.reason ?? `${name}_${result.status}`);
27
+ const readiness = results.some(({ result }) => result.status === 'unavailable')
28
+ ? 'unavailable'
29
+ : results.some(({ result }) => result.status === 'degraded') ? 'degraded' : 'ready';
30
+ const services = Object.assign({}, ...results.map(({ result }) => result.services ?? {}));
31
+ return context.json({
32
+ status: readiness === 'unavailable' ? 'error' : 'ok',
33
+ timestamp: (options.now ?? (() => new Date()))().toISOString(),
34
+ services,
35
+ clusterMesh: options.state.snapshot(),
36
+ readiness: { status: readiness, reasons },
37
+ }, readiness === 'unavailable' ? 503 : 200);
38
+ });
39
+ return router;
40
+ };
41
+ export const createHealthNamespaceModule = (options) => ({
42
+ namespace: '/health',
43
+ enabled: options.enabled ?? true,
44
+ createRouter: () => createHealthRouter(options),
45
+ });
46
+ //# sourceMappingURL=health-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health-router.js","sourceRoot":"","sources":["../../src/hono/health-router.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAA0B,MAAM,MAAM,CAAC;AAIpD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,EAAE,SAAS,CAAC,CAAU,CAAC;AAC3D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,SAAS,CAAU,CAAC;AAuCjD,MAAM,QAAQ,GAAG,KAAK,EAAE,KAAsB,EAA8B,EAAE;IAC5E,IAAI,CAAC;QACH,OAAO,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,eAAe,EAAE,CAAC;IACzE,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAA4B,EAAQ,EAAE;IACvE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;IAC1B,IAAI,OAAO,CAAC,WAAW;QAAE,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,OA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CAAC,CAAC,CAAC,IAAI;YACpD,SAAS,EAAE,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE;YAC9D,QAAQ;YACR,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE;YACrC,SAAS,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE;SAC1C,EAAE,SAAS,KAAK,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,OAA6D,EAC7B,EAAE,CAAC,CAAC;IACpC,SAAS,EAAE,SAAS;IACpB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,IAAI;IAChC,YAAY,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC;CAChD,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ClusterMeshNamespace, ClusterMeshNamespaceModule, VerifiedInvocationContextPort } from '@sentropic/contracts';
2
+ import type { InvocationReceiptPort } from '@sentropic/events';
3
+ import { Hono } from 'hono';
4
+ import type { ClusterMeshRuntime } from '../runtime/generation.js';
5
+ export type ClusterMeshHonoNamespaceModule = ClusterMeshNamespaceModule<Hono, VerifiedInvocationContextPort, InvocationReceiptPort>;
6
+ export interface ClusterMeshPluginOptions {
7
+ readonly runtime: ClusterMeshRuntime;
8
+ readonly namespaces: readonly ClusterMeshHonoNamespaceModule[];
9
+ readonly mounts?: Partial<Record<ClusterMeshNamespace, string>>;
10
+ }
11
+ export declare function createClusterMeshPlugin(options: ClusterMeshPluginOptions): Hono;
12
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/hono/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,6BAA6B,EAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAGnE,MAAM,MAAM,8BAA8B,GAAG,0BAA0B,CACrE,IAAI,EACJ,6BAA6B,EAC7B,qBAAqB,CACtB,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,SAAS,8BAA8B,EAAE,CAAC;IAC/D,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC,CAAC;CACjE;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,IAAI,CAW/E"}
@@ -0,0 +1,15 @@
1
+ import { Hono } from 'hono';
2
+ import { createNamespaceRegistry } from '../runtime/namespace-registry.js';
3
+ export function createClusterMeshPlugin(options) {
4
+ const plugin = new Hono();
5
+ const registry = createNamespaceRegistry(options.namespaces);
6
+ for (const module of registry.enabled()) {
7
+ const router = module.createRouter({
8
+ context: options.runtime.context,
9
+ receipts: options.runtime.receiptPort,
10
+ });
11
+ plugin.route(options.mounts?.[module.namespace] ?? module.namespace, router);
12
+ }
13
+ return plugin;
14
+ }
15
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/hono/plugin.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAc3E,MAAM,UAAU,uBAAuB,CAAC,OAAiC;IACvE,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;IAC1B,MAAM,QAAQ,GAAG,uBAAuB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7D,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC;YACjC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO;YAChC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW;SACtC,CAAC,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { Handler } from 'hono';
2
+ import type { ClusterMeshRuntimeStore } from '../persistence/ports.js';
3
+ import type { ClusterMeshRuntime } from '../runtime/generation.js';
4
+ export interface SessionRouteHandlers {
5
+ readonly current: Handler;
6
+ readonly refresh: Handler;
7
+ readonly extensionToken: Handler;
8
+ readonly logout: Handler;
9
+ readonly logoutAll: Handler;
10
+ readonly list: Handler;
11
+ }
12
+ export interface DeviceRouteHandlers {
13
+ readonly issue: Handler;
14
+ readonly poll: Handler;
15
+ readonly approve: Handler;
16
+ }
17
+ export interface SessionPathProjection {
18
+ readonly session: string;
19
+ readonly device: string;
20
+ readonly control: string;
21
+ }
22
+ export interface SessionAuthorSelectionPort {
23
+ ensureAuthor(): Promise<{
24
+ readonly ok: boolean;
25
+ readonly reason?: 'cutover_unavailable' | 'wrong_author';
26
+ }>;
27
+ }
28
+ export interface SessionTargetStatePort {
29
+ inspect(actuatorRef: string): Promise<'alive' | 'dead' | 'parked' | 'unknown'>;
30
+ }
31
+ export interface SessionControlPorts {
32
+ readonly runtime: ClusterMeshRuntime;
33
+ readonly store: Pick<ClusterMeshRuntimeStore, 'enqueueCommand' | 'markRegistrationLost' | 'updateCommand'>;
34
+ readonly targets: SessionTargetStatePort;
35
+ readonly author: SessionAuthorSelectionPort;
36
+ readonly now?: () => Date;
37
+ }
38
+ //# sourceMappingURL=session-contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-contracts.d.ts","sourceRoot":"","sources":["../../src/hono/session-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,0BAA0B;IACzC,YAAY,IAAI,OAAO,CAAC;QACtB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;QACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,qBAAqB,GAAG,cAAc,CAAC;KAC1D,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAC;CAChF;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAClB,uBAAuB,EACvB,gBAAgB,GAAG,sBAAsB,GAAG,eAAe,CAC5D,CAAC;IACF,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,0BAA0B,CAAC;IAC5C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=session-contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-contracts.js","sourceRoot":"","sources":["../../src/hono/session-contracts.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import type { ClusterMeshHonoNamespaceModule } from './plugin.js';
2
+ import type { DeviceRouteHandlers, SessionControlPorts, SessionPathProjection, SessionRouteHandlers } from './session-contracts.js';
3
+ export declare const isValidSessionControlIntent: (value: unknown) => boolean;
4
+ export declare function createSessionNamespaceModule(input: {
5
+ readonly handlers: SessionRouteHandlers;
6
+ readonly devices: DeviceRouteHandlers;
7
+ readonly projection: SessionPathProjection;
8
+ readonly control: SessionControlPorts;
9
+ readonly enabled?: boolean;
10
+ }): ClusterMeshHonoNamespaceModule;
11
+ //# sourceMappingURL=session-router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-router.d.ts","sourceRoot":"","sources":["../../src/hono/session-router.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAsBhC,eAAO,MAAM,2BAA2B,UAAW,OAAO,KAAG,OAAsC,CAAC;AAEpG,wBAAgB,4BAA4B,CAAC,KAAK,EAAE;IAClD,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;IAC3C,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B,GAAG,8BAA8B,CA2HjC"}