@serfab/cadre-host 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/auth/index.d.ts +2 -0
  2. package/dist/auth/index.js +1 -0
  3. package/dist/auth/index.js.map +1 -1
  4. package/dist/auth/self-label.d.ts +36 -0
  5. package/dist/auth/self-label.js +57 -0
  6. package/dist/auth/self-label.js.map +1 -0
  7. package/dist/auth/trust-circle.d.ts +32 -5
  8. package/dist/auth/trust-circle.js +31 -11
  9. package/dist/auth/trust-circle.js.map +1 -1
  10. package/dist/bin/host.js +41 -5
  11. package/dist/bin/host.js.map +1 -1
  12. package/dist/donation/__tests__/fake-orchestrator.d.ts +103 -0
  13. package/dist/donation/__tests__/fake-orchestrator.js +180 -0
  14. package/dist/donation/__tests__/fake-orchestrator.js.map +1 -0
  15. package/dist/donation/donation-service.d.ts +237 -12
  16. package/dist/donation/donation-service.js +491 -34
  17. package/dist/donation/donation-service.js.map +1 -1
  18. package/dist/donation/donation-store.d.ts +7 -0
  19. package/dist/donation/donation-store.js +7 -0
  20. package/dist/donation/donation-store.js.map +1 -1
  21. package/dist/donation/donation-supervisor.d.ts +167 -0
  22. package/dist/donation/donation-supervisor.js +341 -0
  23. package/dist/donation/donation-supervisor.js.map +1 -0
  24. package/dist/donation/index.d.ts +4 -2
  25. package/dist/donation/index.js +2 -1
  26. package/dist/donation/index.js.map +1 -1
  27. package/dist/donation/types.d.ts +26 -0
  28. package/dist/donation/types.js.map +1 -1
  29. package/dist/index.d.ts +3 -1
  30. package/dist/index.js +3 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/orchestrator/host-process-orchestrator.d.ts +109 -5
  33. package/dist/orchestrator/host-process-orchestrator.js +341 -98
  34. package/dist/orchestrator/host-process-orchestrator.js.map +1 -1
  35. package/dist/orchestrator/node-identity.d.ts +26 -0
  36. package/dist/orchestrator/node-identity.js +36 -0
  37. package/dist/orchestrator/node-identity.js.map +1 -0
  38. package/dist/orchestrator/port-allocator.d.ts +14 -0
  39. package/dist/orchestrator/port-allocator.js +45 -0
  40. package/dist/orchestrator/port-allocator.js.map +1 -1
  41. package/dist/owner/owner-node-client.d.ts +20 -5
  42. package/dist/owner/owner-node-client.js +21 -4
  43. package/dist/owner/owner-node-client.js.map +1 -1
  44. package/dist/server/error-handler.d.ts +7 -1
  45. package/dist/server/error-handler.js +23 -1
  46. package/dist/server/error-handler.js.map +1 -1
  47. package/dist/server/events/types.d.ts +3 -0
  48. package/dist/server/index.d.ts +7 -0
  49. package/dist/server/index.js +9 -3
  50. package/dist/server/index.js.map +1 -1
  51. package/dist/server/routes/grants.js +22 -3
  52. package/dist/server/routes/grants.js.map +1 -1
  53. package/dist/server/routes/strands.d.ts +20 -0
  54. package/dist/server/routes/strands.js +38 -0
  55. package/dist/server/routes/strands.js.map +1 -0
  56. package/dist/strands/index.d.ts +7 -0
  57. package/dist/strands/index.js +6 -0
  58. package/dist/strands/index.js.map +1 -0
  59. package/dist/strands/strand-service.d.ts +50 -0
  60. package/dist/strands/strand-service.js +103 -0
  61. package/dist/strands/strand-service.js.map +1 -0
  62. package/dist/strands/types.d.ts +93 -0
  63. package/dist/strands/types.js +23 -0
  64. package/dist/strands/types.js.map +1 -0
  65. package/dist/ui/assets/index-BVoqLjyX.css +1 -0
  66. package/dist/ui/assets/index-C-iks41M.js +17 -0
  67. package/dist/ui/assets/index-C-iks41M.js.map +1 -0
  68. package/dist/ui/index.html +2 -2
  69. package/dist/update/release-key.d.ts +1 -1
  70. package/dist/update/release-key.js +1 -1
  71. package/package.json +5 -5
  72. package/src/__tests__/build-targets.test.ts +26 -0
  73. package/src/__tests__/global-setup.ts +51 -0
  74. package/src/__tests__/orchestrator-env-scrub.test.ts +140 -0
  75. package/src/__tests__/orchestrator-node-identity.test.ts +204 -0
  76. package/src/__tests__/orchestrator.test.ts +387 -6
  77. package/src/auth/__tests__/self-label.test.ts +85 -0
  78. package/src/auth/__tests__/trust-circle-integration.test.ts +152 -147
  79. package/src/auth/__tests__/trust-circle.test.ts +45 -1
  80. package/src/auth/index.ts +2 -0
  81. package/src/auth/self-label.ts +74 -0
  82. package/src/auth/trust-circle.ts +45 -13
  83. package/src/bin/host.ts +1299 -1258
  84. package/src/donation/__tests__/donation-service.test.ts +836 -58
  85. package/src/donation/__tests__/donation-supervisor.test.ts +510 -0
  86. package/src/donation/__tests__/fake-orchestrator.test.ts +168 -0
  87. package/src/donation/__tests__/fake-orchestrator.ts +225 -0
  88. package/src/donation/donation-service.ts +611 -41
  89. package/src/donation/donation-store.ts +7 -0
  90. package/src/donation/donation-supervisor.ts +388 -0
  91. package/src/donation/index.ts +15 -0
  92. package/src/donation/types.ts +23 -0
  93. package/src/index.ts +14 -0
  94. package/src/orchestrator/__tests__/node-identity.test.ts +62 -0
  95. package/src/orchestrator/host-process-orchestrator.ts +336 -97
  96. package/src/orchestrator/node-identity.ts +40 -0
  97. package/src/orchestrator/port-allocator.ts +48 -0
  98. package/src/owner/owner-node-client.ts +31 -5
  99. package/src/server/__tests__/grants-route.test.ts +80 -6
  100. package/src/server/__tests__/strands-route.test.ts +233 -0
  101. package/src/server/error-handler.ts +24 -1
  102. package/src/server/events/types.ts +1 -0
  103. package/src/server/index.ts +16 -3
  104. package/src/server/routes/grants.ts +27 -3
  105. package/src/server/routes/strands.ts +54 -0
  106. package/src/strands/__tests__/strand-service.test.ts +165 -0
  107. package/src/strands/index.ts +14 -0
  108. package/src/strands/strand-service.ts +135 -0
  109. package/src/strands/types.ts +102 -0
  110. package/src/update/release-key.ts +1 -1
  111. package/dist/ui/assets/index-BlMXQPSw.js +0 -14
  112. package/dist/ui/assets/index-BlMXQPSw.js.map +0 -1
  113. package/dist/ui/assets/index-BwU5mJGF.css +0 -1
@@ -93,6 +93,12 @@ export function registerGrantsRoutes(app, opts) {
93
93
  if (!Array.isArray(body.ownerKeys) || body.ownerKeys.length === 0) {
94
94
  return errorResponse(reply, 'invalid_request', 'ownerKeys is required', 400);
95
95
  }
96
+ // Element types too, not just the array: `provision`'s shape check trims each
97
+ // entry, so a non-string reaches the caller as an internal `.trim is not a
98
+ // function` rather than as a message naming what is wrong with the request.
99
+ if (!body.ownerKeys.every(key => typeof key === 'string')) {
100
+ return errorResponse(reply, 'invalid_request', 'ownerKeys must be an array of strings', 400);
101
+ }
96
102
  if (body.profile !== undefined && body.profile !== 'storage' && body.profile !== 'transaction') {
97
103
  return errorResponse(reply, 'invalid_request', 'profile must be "storage" or "transaction"', 400);
98
104
  }
@@ -144,10 +150,23 @@ export function registerGrantsRoutes(app, opts) {
144
150
  return errorResponse(reply, 'invalid_request', 'seed is required', 400);
145
151
  }
146
152
  const result = await donations.applySeed(request.params.id, body.seed);
147
- if (!result.success) {
148
- return errorResponse(reply, 'seed_failed', result.error ?? 'Node rejected the seed', 502);
153
+ // NOTE: exhaustive over today's three outcomes, and nothing forces it to stay
154
+ // that way — an unhandled fourth would fall out of the handler as `undefined`
155
+ // and hang the request rather than fail to compile. If `DonationSeedResult`
156
+ // ever grows a variant, add a `default:` that 500s here.
157
+ switch (result.outcome) {
158
+ case 'rejected':
159
+ return errorResponse(reply, 'seed_failed', result.error ?? 'Node rejected the seed', 502);
160
+ // The loan ended while the seed was in flight. The ending won, so the
161
+ // caller is told the record it seeded is no longer seedable (409) — or is
162
+ // gone entirely (404) — rather than a 200 that implies a live node.
163
+ case 'abandoned':
164
+ return result.status
165
+ ? errorResponse(reply, 'invalid_state', `Donation ${request.params.id} ended (${result.status}) while the seed was in flight`, 409)
166
+ : errorResponse(reply, 'not_found', `No such donation: ${request.params.id}`, 404);
167
+ case 'seeded':
168
+ return reply.send({ ok: true, data: { peersAdded: result.peersAdded } });
149
169
  }
150
- return reply.send({ ok: true, data: { peersAdded: result.peersAdded ?? 0 } });
151
170
  });
152
171
  // DELETE /grants/:id — terminate the donated node.
153
172
  app.delete('/grants/:id', async (request, reply) => {
@@ -1 +1 @@
1
- {"version":3,"file":"grants.js","sourceRoot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,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Strand HTTP routes — thin adapters around `StrandHandlers`
3
+ * (`createStrandHandlers(service)`).
4
+ *
5
+ * Mount path: `/api/strands` — a UI-only surface with no CLI contract to
6
+ * preserve. (The `/auth/*` and `/nat/*` mounts sit outside `/api` only because
7
+ * the existing CLI already targets those URLs.) Envelope form therefore follows
8
+ * the other `/api/*` routes: `{ ok: true, data }`.
9
+ *
10
+ * A removal that actually issued a delete publishes `strands-changed` so other
11
+ * open tabs refresh. A call that found no row publishes nothing — nothing changed.
12
+ */
13
+ import type { FastifyInstance } from 'fastify';
14
+ import type { StrandHandlers } from '../../strands/types.js';
15
+ import type { EventBus } from '../events/bus.js';
16
+ export interface StrandRoutesOptions {
17
+ handlers: StrandHandlers;
18
+ events: EventBus;
19
+ }
20
+ export declare function registerStrandRoutes(app: FastifyInstance, opts: StrandRoutesOptions): void;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Strand HTTP routes — thin adapters around `StrandHandlers`
3
+ * (`createStrandHandlers(service)`).
4
+ *
5
+ * Mount path: `/api/strands` — a UI-only surface with no CLI contract to
6
+ * preserve. (The `/auth/*` and `/nat/*` mounts sit outside `/api` only because
7
+ * the existing CLI already targets those URLs.) Envelope form therefore follows
8
+ * the other `/api/*` routes: `{ ok: true, data }`.
9
+ *
10
+ * A removal that actually issued a delete publishes `strands-changed` so other
11
+ * open tabs refresh. A call that found no row publishes nothing — nothing changed.
12
+ */
13
+ /**
14
+ * The only accepted `confirm` values — the same strict pair the admin channel
15
+ * accepts. Not a general truthiness parser: `yes`, `on` and an empty value all
16
+ * count as NOT confirmed, because a guessy parser here would turn a typo into a
17
+ * destroyed membership key.
18
+ *
19
+ * NOTE: deliberately duplicated from cadre-cli's `admin-server.ts` rather than
20
+ * imported — cadre-host depends on cadre-cli for its bin path only, never its
21
+ * source. Keep the two in step by hand; do not DRY them into an import.
22
+ */
23
+ const CONFIRM_VALUES = new Set(['1', 'true']);
24
+ export function registerStrandRoutes(app, opts) {
25
+ const { handlers, events } = opts;
26
+ app.get('/api/strands', async () => {
27
+ return { ok: true, data: await handlers.listStrands() };
28
+ });
29
+ app.delete('/api/strands/:id', async (request) => {
30
+ const confirm = typeof request.query.confirm === 'string' && CONFIRM_VALUES.has(request.query.confirm);
31
+ const result = await handlers.removeStrand(request.params.id, { confirm });
32
+ if (result.removed) {
33
+ events.publish({ type: 'strands-changed', kind: 'removed' });
34
+ }
35
+ return { ok: true, data: result };
36
+ });
37
+ }
38
+ //# sourceMappingURL=strands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strands.js","sourceRoot":"","sources":["../../../src/server/routes/strands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAYH;;;;;;;;;GASG;AACH,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;AAE9C,MAAM,UAAU,oBAAoB,CAAC,GAAoB,EAAE,IAAyB;IAClF,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAElC,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,IAAI,EAAE;QACjC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,MAAM,CACR,kBAAkB,EAClB,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvG,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QAC3E,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACpC,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Strand management for cadre-host. See ./strand-service.ts and ./types.ts.
3
+ */
4
+ export { StrandService, createStrandHandlers } from './strand-service.js';
5
+ export type { StrandServiceOptions, CadreNodeLike } from './strand-service.js';
6
+ export { StrandError } from './types.js';
7
+ export type { StrandSummary, StrandListSnapshot, StrandRemovalResult, StrandHandlers, StrandErrorCode, } from './types.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Strand management for cadre-host. See ./strand-service.ts and ./types.ts.
3
+ */
4
+ export { StrandService, createStrandHandlers } from './strand-service.js';
5
+ export { StrandError } from './types.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/strands/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { StrandHandlers, StrandListSnapshot, StrandRemovalResult } from './types.js';
2
+ /**
3
+ * Minimal slice of the owner node that StrandService uses. Declared here (rather
4
+ * than reaching into `OwnerNodeClient`) so unit tests can inject a fake without
5
+ * standing up an admin channel — the third such trimmed interface the client
6
+ * satisfies, alongside the trust-circle and NAT ones.
7
+ */
8
+ export interface CadreNodeLike {
9
+ listStrands(): Promise<StrandListSnapshot>;
10
+ removeStrand(strandId: string, opts: {
11
+ confirm: boolean;
12
+ }): Promise<StrandRemovalResult>;
13
+ }
14
+ /** Constructor options. */
15
+ export interface StrandServiceOptions {
16
+ /** The owner node — provides listStrands / removeStrand over the admin channel. */
17
+ cadreNode: CadreNodeLike;
18
+ }
19
+ /**
20
+ * StrandService — validation and error translation over the owner node's strand
21
+ * admin routes.
22
+ *
23
+ * It owns no state and makes no policy. In particular it does NOT decide whether a
24
+ * closed strand needs confirmation: it never reads the row, so it could only guess.
25
+ * The node enforces that rule and answers `confirmation_required`; this layer
26
+ * forwards the caller's flag verbatim and surfaces the refusal as a distinct code
27
+ * so the UI can raise the right dialog.
28
+ */
29
+ export declare class StrandService {
30
+ private readonly cadreNode;
31
+ constructor(opts: StrandServiceOptions);
32
+ /** This party's strands, plus the node's current control-connection count. */
33
+ list(): Promise<StrandListSnapshot>;
34
+ /**
35
+ * Remove this party's participation in one strand.
36
+ *
37
+ * `confirm` is forwarded exactly as given — never defaulted to true, never
38
+ * re-sent as true after a refusal. A closed strand's row carries this party's
39
+ * membership key for that network and is stored nowhere else, so an automatic
40
+ * retry would destroy it on the caller's behalf.
41
+ */
42
+ remove(rawId: string, opts: {
43
+ confirm: boolean;
44
+ }): Promise<StrandRemovalResult>;
45
+ }
46
+ /**
47
+ * Wrap a StrandService into the typed handler shape the local UI server mounts.
48
+ * Errors propagate as StrandError; `server/error-handler.ts` maps `.code` → status.
49
+ */
50
+ export declare function createStrandHandlers(service: StrandService): StrandHandlers;
@@ -0,0 +1,103 @@
1
+ import debug from 'debug';
2
+ import { OwnerNodeUnavailableError } from '../owner/owner-node-client.js';
3
+ import { StrandError } from './types.js';
4
+ const log = debug('cadre:host:strands');
5
+ /**
6
+ * StrandService — validation and error translation over the owner node's strand
7
+ * admin routes.
8
+ *
9
+ * It owns no state and makes no policy. In particular it does NOT decide whether a
10
+ * closed strand needs confirmation: it never reads the row, so it could only guess.
11
+ * The node enforces that rule and answers `confirmation_required`; this layer
12
+ * forwards the caller's flag verbatim and surfaces the refusal as a distinct code
13
+ * so the UI can raise the right dialog.
14
+ */
15
+ export class StrandService {
16
+ constructor(opts) {
17
+ this.cadreNode = opts.cadreNode;
18
+ }
19
+ /** This party's strands, plus the node's current control-connection count. */
20
+ async list() {
21
+ return await this.cadreNode.listStrands().catch((err) => toDomainError(err));
22
+ }
23
+ /**
24
+ * Remove this party's participation in one strand.
25
+ *
26
+ * `confirm` is forwarded exactly as given — never defaulted to true, never
27
+ * re-sent as true after a refusal. A closed strand's row carries this party's
28
+ * membership key for that network and is stored nowhere else, so an automatic
29
+ * retry would destroy it on the caller's behalf.
30
+ */
31
+ async remove(rawId, opts) {
32
+ const strandId = validateStrandId(rawId);
33
+ log('remove %s (confirm=%s)', strandId, opts.confirm);
34
+ return await this.cadreNode
35
+ .removeStrand(strandId, { confirm: opts.confirm })
36
+ .catch((err) => toDomainError(err));
37
+ }
38
+ }
39
+ /**
40
+ * Trim and reject an id this surface cannot act on. Blank is the only such id.
41
+ *
42
+ * A `/` is deliberately NOT refused. `/api/strands/:id` is one path segment, but a
43
+ * caller that percent-encodes the id reaches this layer with the `/` restored
44
+ * (Fastify decodes `params`), `OwnerNodeClient` re-encodes it, and the admin channel
45
+ * splits on the still-encoded `%2F` and decodes it back — so the whole chain carries
46
+ * it. Refusing here would break the only form that works, while doing nothing about
47
+ * an UNencoded `/`, which never reaches this handler at all (the router 404s it).
48
+ */
49
+ function validateStrandId(rawId) {
50
+ const strandId = typeof rawId === 'string' ? rawId.trim() : '';
51
+ if (!strandId) {
52
+ throw new StrandError('invalid_id', 'A strand id is required');
53
+ }
54
+ return strandId;
55
+ }
56
+ /**
57
+ * Translate an owner-node failure into the strand error vocabulary.
58
+ *
59
+ * `OwnerNodeUnavailableError` is thrown for *every* non-ok admin response, not only
60
+ * for a node that is down — so read `nodeCode` first and fall back to
61
+ * `node_unavailable` only when nothing better fits. Reporting a 428 as "your node is
62
+ * down" would be actively misleading.
63
+ *
64
+ * Declared to return `never` so callers can `.catch((err) => toDomainError(err))`.
65
+ *
66
+ * NOTE: the trust-circle and NAT services translate the SAME error blanket-style —
67
+ * every `OwnerNodeUnavailableError` becomes `node_unavailable` — because neither has
68
+ * a code worth distinguishing yet. If a second surface ever needs a code-aware
69
+ * mapping, hoist this switch into a shared owner-error translator instead of growing
70
+ * a third copy.
71
+ */
72
+ function toDomainError(err) {
73
+ if (!(err instanceof OwnerNodeUnavailableError)) {
74
+ throw err instanceof Error ? err : new Error(String(err));
75
+ }
76
+ switch (err.nodeCode) {
77
+ case 'confirmation_required':
78
+ throw new StrandError('confirmation_required', err.message);
79
+ case 'bad_request':
80
+ throw new StrandError('invalid_id', err.message);
81
+ case undefined:
82
+ case 'not_ready':
83
+ case 'not_authorized':
84
+ throw new StrandError('node_unavailable', `Owner node unavailable: ${err.message}`);
85
+ default:
86
+ throw new StrandError('internal', err.message);
87
+ }
88
+ }
89
+ /**
90
+ * Wrap a StrandService into the typed handler shape the local UI server mounts.
91
+ * Errors propagate as StrandError; `server/error-handler.ts` maps `.code` → status.
92
+ */
93
+ export function createStrandHandlers(service) {
94
+ return {
95
+ async listStrands() {
96
+ return await service.list();
97
+ },
98
+ async removeStrand(strandId, opts) {
99
+ return await service.remove(strandId, { confirm: opts.confirm === true });
100
+ },
101
+ };
102
+ }
103
+ //# sourceMappingURL=strand-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strand-service.js","sourceRoot":"","sources":["../../src/strands/strand-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAO1E,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,GAAG,GAAG,KAAK,CAAC,oBAAoB,CAAC,CAAC;AAmBxC;;;;;;;;;GASG;AACH,MAAM,OAAO,aAAa;IAGxB,YAAY,IAA0B;QACpC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IAClC,CAAC;IAED,8EAA8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AuB;YAC1B,MAAM,IAAI,WAAW,CAAC,uBAAuB,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9D,KAAK,aAAa;YAChB,MAAM,IAAI,WAAW,CAAC,YAAY,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QACnD,KAAK,SAAS,CAAC;QACf,KAAK,WAAW,CAAC;QACjB,KAAK,gBAAgB;YACnB,MAAM,IAAI,WAAW,CAAC,kBAAkB,EAAE,2BAA2B,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACtF;YACE,MAAM,IAAI,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAsB;IACzD,OAAO;QACL,KAAK,CAAC,WAAW;YACf,OAAO,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;QAC9B,CAAC;QACD,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI;YAC/B,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC,CAAC;QAC5E,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Strand-management types for cadre-host.
3
+ *
4
+ * A *strand* is a shared data network this party participates in. Membership is
5
+ * canonical in the cadre control network's `Strand` table, reached over the owner
6
+ * node's loopback admin channel (`GET /admin/strands`,
7
+ * `DELETE /admin/strands/:id?confirm=1`).
8
+ *
9
+ * Unlike the trust circle — which layers host-local labels and pending invites on
10
+ * top of the node's state — this layer holds **no host-local state at all**. There
11
+ * is no `strands.json`. It exists for id validation, for translating the admin
12
+ * channel's error codes into a stable vocabulary the management API can map to HTTP
13
+ * statuses, and for nothing else. Keep it small.
14
+ */
15
+ /** One strand this party belongs to, as projected by the admin channel. */
16
+ export interface StrandSummary {
17
+ /** The `Strand` row id — what a removal takes. */
18
+ id: string;
19
+ /** `'o'` = open, `'c'` = closed (the row carries this party's membership key). */
20
+ type: 'o' | 'c';
21
+ /** Whether the owner node currently has a running instance for the id. */
22
+ running: boolean;
23
+ /**
24
+ * The instance's status when running, else `null`. Deliberately `string` rather
25
+ * than cadre-core's `StrandStatus`: this is a wire projection the manager only
26
+ * forwards, and widening it keeps cadre-host from tracking a cadre-core union it
27
+ * never inspects.
28
+ */
29
+ status: string | null;
30
+ }
31
+ /** The result of listing this party's strands. */
32
+ export interface StrandListSnapshot {
33
+ strands: StrandSummary[];
34
+ /**
35
+ * Open control-network connections on the owner node; 0 ⇒ writes commit
36
+ * local-only. A snapshot at read time, not a subscription — treat it as advisory.
37
+ */
38
+ controlConnections: number;
39
+ }
40
+ /** The result of removing this party's participation in one strand. */
41
+ export interface StrandRemovalResult {
42
+ /** The trimmed id the call was about. */
43
+ strandId: string;
44
+ /** Whether a row existed before the write. */
45
+ published: boolean;
46
+ /** The found row's type; `null` when no row was found. */
47
+ type: 'o' | 'c' | null;
48
+ /**
49
+ * Whether THIS call issued the delete — not that the row was observed to vanish.
50
+ * The node's read and write are not atomic, so a concurrent removal landing in
51
+ * between makes this a no-op that still reports `true`.
52
+ */
53
+ removed: boolean;
54
+ /**
55
+ * The node saw 0 control connections at the end of the call. Sampled on EVERY
56
+ * call, including one that found no row and wrote nothing — read it as "this
57
+ * machine currently sees no siblings", and only as "your delete may not have
58
+ * travelled" when `removed` is also true.
59
+ */
60
+ alone: boolean;
61
+ }
62
+ /** Error codes thrown by StrandService. */
63
+ export type StrandErrorCode =
64
+ /** The id was blank or whitespace-only, here or at the node. */
65
+ 'invalid_id'
66
+ /** The node refused a closed-strand removal that carried no confirmation. */
67
+ | 'confirmation_required'
68
+ /** The owner node's admin channel is unreachable / not ready. */
69
+ | 'node_unavailable'
70
+ /** The node answered with a code this layer has no better word for. */
71
+ | 'internal';
72
+ /** Typed error carrying a stable `code` for HTTP mapping. */
73
+ export declare class StrandError extends Error {
74
+ readonly code: StrandErrorCode;
75
+ constructor(code: StrandErrorCode, message: string);
76
+ }
77
+ /**
78
+ * Typed handlers exposed to the local UI server for Fastify wiring.
79
+ *
80
+ * Handlers either return typed results or throw a `StrandError` whose `.code`
81
+ * `server/error-handler.ts` maps to an HTTP status:
82
+ *
83
+ * - `invalid_id` → 400
84
+ * - `confirmation_required` → 428
85
+ * - `node_unavailable` → 503
86
+ * - `internal` → 500
87
+ */
88
+ export interface StrandHandlers {
89
+ listStrands(): Promise<StrandListSnapshot>;
90
+ removeStrand(strandId: string, opts: {
91
+ confirm: boolean;
92
+ }): Promise<StrandRemovalResult>;
93
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Strand-management types for cadre-host.
3
+ *
4
+ * A *strand* is a shared data network this party participates in. Membership is
5
+ * canonical in the cadre control network's `Strand` table, reached over the owner
6
+ * node's loopback admin channel (`GET /admin/strands`,
7
+ * `DELETE /admin/strands/:id?confirm=1`).
8
+ *
9
+ * Unlike the trust circle — which layers host-local labels and pending invites on
10
+ * top of the node's state — this layer holds **no host-local state at all**. There
11
+ * is no `strands.json`. It exists for id validation, for translating the admin
12
+ * channel's error codes into a stable vocabulary the management API can map to HTTP
13
+ * statuses, and for nothing else. Keep it small.
14
+ */
15
+ /** Typed error carrying a stable `code` for HTTP mapping. */
16
+ export class StrandError extends Error {
17
+ constructor(code, message) {
18
+ super(message);
19
+ this.name = 'StrandError';
20
+ this.code = code;
21
+ }
22
+ }
23
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/strands/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA+DH,6DAA6D;AAC7D,MAAM,OAAO,WAAY,SAAQ,KAAK;IAGpC,YAAY,IAAqB,EAAE,OAAe;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ .dot.svelte-1qa2kn2{display:inline-flex;align-items:center;gap:.5rem;font-weight:500}.bulb.svelte-1qa2kn2{display:inline-block;border-radius:999px;flex:0 0 auto;background:var(--color-text-soft);box-shadow:0 0 0 3px #0000000f}.dot-ok.svelte-1qa2kn2 .bulb:where(.svelte-1qa2kn2){background:var(--color-success);box-shadow:0 0 0 3px var(--color-success-bg)}.dot-warn.svelte-1qa2kn2 .bulb:where(.svelte-1qa2kn2){background:var(--color-warn);box-shadow:0 0 0 3px var(--color-warn-bg)}.dot-err.svelte-1qa2kn2 .bulb:where(.svelte-1qa2kn2){background:var(--color-danger);box-shadow:0 0 0 3px var(--color-danger-bg)}.dot-muted.svelte-1qa2kn2 .bulb:where(.svelte-1qa2kn2){background:var(--color-text-soft)}.dot-ok.svelte-1qa2kn2{color:var(--color-success)}.dot-warn.svelte-1qa2kn2{color:var(--color-warn)}.dot-err.svelte-1qa2kn2{color:var(--color-danger)}.row.svelte-lwwmgz{display:inline-flex;gap:.4rem;flex-wrap:wrap}.banner.svelte-15mtls8{display:flex;align-items:center;justify-content:space-between;gap:var(--space-3);padding:var(--space-3) var(--space-4);border-radius:var(--radius);background:var(--color-info-bg);color:var(--color-info);border:1px solid var(--color-info)}.summary.svelte-15mtls8{grid-template-columns:repeat(auto-fit,minmax(15rem,1fr))}.kv.svelte-15mtls8{margin:var(--space-3) 0 0 0;display:grid;grid-template-columns:max-content 1fr;gap:var(--space-1) var(--space-3);font-size:.9rem}.kv.svelte-15mtls8>div:where(.svelte-15mtls8){display:contents}.kv.svelte-15mtls8 dt:where(.svelte-15mtls8){color:var(--color-text-muted)}.kv.svelte-15mtls8 dd:where(.svelte-15mtls8){margin:0}.big.svelte-15mtls8{font-size:1.75rem;font-weight:600;margin:var(--space-2) 0}.big.svelte-15mtls8 .muted:where(.svelte-15mtls8){font-size:.95rem;font-weight:400}.link.svelte-15mtls8{display:inline-block;margin-top:var(--space-2);font-weight:500}.backdrop.svelte-80vbit{position:fixed;inset:0;background:#0f111673;z-index:1000}.dialog.svelte-80vbit{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-lg);box-shadow:var(--shadow-lg);padding:var(--space-5);min-width:min(24rem,calc(100vw - 2rem));max-width:min(32rem,calc(100vw - 2rem));overflow-wrap:anywhere;z-index:1010}.note.svelte-80vbit{background:var(--color-warn-bg);color:var(--color-warn);border-radius:var(--radius);padding:var(--space-2) var(--space-3);font-size:.9rem}.gate.svelte-80vbit{margin-top:var(--space-3);overflow-wrap:anywhere}.actions.svelte-80vbit{display:flex;justify-content:flex-end;gap:.5rem;margin-top:var(--space-4)}.qr.svelte-1uqetyj{background:#fff;border-radius:var(--radius);padding:.5rem;display:inline-block;line-height:0}.qr.svelte-1uqetyj svg{width:100%;height:100%;display:block}.placeholder.svelte-1uqetyj{background:var(--color-surface-alt)}.backdrop.svelte-1d46kin{position:fixed;inset:0;background:#0f111673;z-index:1000}.dialog.svelte-1d46kin{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-lg);box-shadow:var(--shadow-lg);padding:var(--space-5);width:min(28rem,calc(100vw - 2rem));max-height:calc(100vh - 2rem);overflow:auto;z-index:1010}.actions.svelte-1d46kin{display:flex;justify-content:flex-end;gap:.5rem;margin-top:var(--space-4)}.qr-wrap.svelte-1d46kin{display:flex;justify-content:center;margin:var(--space-3) 0}.token.svelte-1d46kin{display:flex;flex-direction:column;gap:.5rem}.token.svelte-1d46kin textarea:where(.svelte-1d46kin){font-family:var(--font-mono);font-size:.78rem;word-break:break-all;resize:vertical}.token.svelte-1d46kin button:where(.svelte-1d46kin){align-self:flex-end;display:inline-flex;align-items:center;gap:.375rem}.small.svelte-1d46kin{font-size:.85rem}.page-header.svelte-3alf51{display:flex;align-items:flex-end;justify-content:space-between;flex-wrap:wrap;gap:var(--space-3)}.list.svelte-3alf51{list-style:none;padding:0;margin:var(--space-3) 0 0 0;display:flex;flex-direction:column;gap:.5rem}.list.svelte-3alf51 li:where(.svelte-3alf51){display:flex;align-items:center;justify-content:space-between;gap:var(--space-3);padding:var(--space-3);border:1px solid var(--color-border);border-radius:var(--radius);background:var(--color-surface-alt)}.member-main.svelte-3alf51{display:flex;flex-direction:column;gap:.125rem;min-width:0}.member-label.svelte-3alf51{font-weight:500}.small.svelte-3alf51{font-size:.85rem}.grid.two.svelte-hh3bto{grid-template-columns:repeat(auto-fit,minmax(20rem,1fr))}.kv.svelte-hh3bto{margin:var(--space-3) 0;display:grid;grid-template-columns:max-content 1fr;gap:var(--space-1) var(--space-3);font-size:.9rem}.kv.svelte-hh3bto>div:where(.svelte-hh3bto){display:contents}.kv.svelte-hh3bto dt:where(.svelte-hh3bto){color:var(--color-text-muted)}.kv.svelte-hh3bto dd:where(.svelte-hh3bto){margin:0}.row.inline.svelte-hh3bto{gap:.5rem}.row.inline.svelte-hh3bto input[type=checkbox]:where(.svelte-hh3bto){width:auto}.warning.svelte-hh3bto{background:var(--color-warn-bg);border-color:var(--color-warn)}.warning.svelte-hh3bto ul:where(.svelte-hh3bto){margin:0;padding-left:1.25rem}.actions.svelte-hh3bto{display:flex;justify-content:flex-end;gap:.5rem}.small.svelte-hh3bto{font-size:.85rem}table.svelte-7tcksg{width:100%;border-collapse:collapse;font-size:.92rem}th.svelte-7tcksg,td.svelte-7tcksg{padding:.5rem .75rem;text-align:left;border-bottom:1px solid var(--color-border)}th.svelte-7tcksg{font-weight:600;font-size:.78rem;text-transform:uppercase;letter-spacing:.05em;color:var(--color-text-muted);border-bottom-color:var(--color-border-strong)}tr.svelte-7tcksg:last-child td:where(.svelte-7tcksg){border-bottom:none}.log-card.svelte-15ufwrh{display:flex;flex-direction:column;gap:var(--space-3)}.header.svelte-15ufwrh{display:flex;align-items:center;justify-content:space-between;gap:var(--space-3)}.logs.svelte-15ufwrh{max-height:24rem;font-size:.78rem;line-height:1.45;white-space:pre}.small.svelte-15ufwrh{font-size:.85rem}button.svelte-15ufwrh{display:inline-flex;align-items:center;gap:.375rem}.back.svelte-1eq4g96{font-size:.92rem}.page-header.svelte-1eq4g96{display:flex;align-items:flex-start;justify-content:space-between;flex-wrap:wrap;gap:var(--space-3)}.kv.svelte-1eq4g96{margin:var(--space-3) 0;display:grid;grid-template-columns:max-content 1fr;gap:var(--space-1) var(--space-3);font-size:.92rem}.kv.svelte-1eq4g96>div:where(.svelte-1eq4g96){display:contents}.kv.svelte-1eq4g96 dt:where(.svelte-1eq4g96){color:var(--color-text-muted)}.kv.svelte-1eq4g96 dd:where(.svelte-1eq4g96){margin:0}.actions.svelte-1eq4g96{display:flex;gap:.5rem;flex-wrap:wrap}.row.inline.svelte-1cl3wo6{gap:.5rem}.row.inline.svelte-1cl3wo6 input[type=checkbox]:where(.svelte-1cl3wo6){width:auto}.banner.svelte-1cl3wo6{display:flex;align-items:center;justify-content:space-between;gap:var(--space-3);padding:var(--space-3);border-radius:var(--radius);background:var(--color-info-bg);color:var(--color-info);border:1px solid var(--color-info);flex-wrap:wrap}.kv.svelte-1cl3wo6{margin:var(--space-3) 0;display:grid;grid-template-columns:max-content 1fr;gap:var(--space-1) var(--space-3);font-size:.92rem}.kv.svelte-1cl3wo6>div:where(.svelte-1cl3wo6){display:contents}.kv.svelte-1cl3wo6 dt:where(.svelte-1cl3wo6){color:var(--color-text-muted)}.kv.svelte-1cl3wo6 dd:where(.svelte-1cl3wo6){margin:0}.copy-row.svelte-1cl3wo6{display:flex;align-items:center;gap:.375rem}.actions.svelte-1cl3wo6{display:flex;justify-content:flex-end}.small.svelte-1cl3wo6{font-size:.85rem}.error.svelte-1cl3wo6{color:var(--color-danger)}.list.svelte-ngb3vw{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:.5rem}.list.svelte-ngb3vw li:where(.svelte-ngb3vw){display:flex;align-items:center;justify-content:space-between;gap:var(--space-3);padding:var(--space-3);border:1px solid var(--color-border);border-radius:var(--radius);background:var(--color-surface-alt)}.strand-main.svelte-ngb3vw{display:flex;flex-direction:column;gap:.25rem;min-width:0}.strand-id.svelte-ngb3vw{overflow-wrap:anywhere;user-select:text}.error.svelte-ngb3vw{color:var(--color-danger)}.meta.svelte-ngb3vw{gap:.5rem}.small.svelte-ngb3vw{font-size:.85rem}.warning.svelte-ngb3vw{background:var(--color-warn-bg);border-color:var(--color-warn)}.warning.svelte-ngb3vw code:where(.svelte-ngb3vw){overflow-wrap:anywhere}.actions.svelte-ngb3vw{display:flex;justify-content:flex-end;gap:.5rem}.toast-stack.svelte-g7yjw8{position:fixed;right:1rem;bottom:1rem;display:flex;flex-direction:column;gap:.5rem;max-width:min(30rem,calc(100vw - 2rem));z-index:1100}.toast.svelte-g7yjw8{background:var(--color-surface);color:var(--color-text);border:1px solid var(--color-border-strong);border-radius:var(--radius);padding:.625rem .75rem;display:flex;align-items:center;gap:.5rem;box-shadow:var(--shadow);font-size:.92rem}.toast-error.svelte-g7yjw8{border-color:var(--color-danger);background:var(--color-danger-bg);color:var(--color-danger)}.toast-success.svelte-g7yjw8{border-color:var(--color-success);background:var(--color-success-bg);color:var(--color-success)}.text.svelte-g7yjw8{flex:1 1 auto}button.svelte-g7yjw8{font-size:1.1rem;line-height:1;padding:.125rem .5rem;color:currentColor}.topbar.svelte-1r8vfx3{position:sticky;top:0;z-index:10;display:flex;align-items:center;justify-content:space-between;gap:var(--space-4);padding:var(--space-3) var(--space-5);background:var(--color-surface);border-bottom:1px solid var(--color-border);backdrop-filter:saturate(180%) blur(8px)}.brand.svelte-1r8vfx3{display:flex;align-items:center;gap:.6rem;font-weight:600}.logo.svelte-1r8vfx3{color:var(--color-accent);font-size:1.1rem}nav.svelte-1r8vfx3{display:flex;gap:.125rem}nav.svelte-1r8vfx3 a:where(.svelte-1r8vfx3){font-size:.92rem;color:var(--color-text-muted);padding:.375rem .75rem;border-radius:var(--radius);text-decoration:none}nav.svelte-1r8vfx3 a:where(.svelte-1r8vfx3):hover{background:var(--color-surface-alt);color:var(--color-text)}nav.svelte-1r8vfx3 a.active:where(.svelte-1r8vfx3){color:var(--color-accent-on);background:var(--color-accent)}main.svelte-1r8vfx3{flex:1 1 auto;width:min(64rem,100%);margin:0 auto;padding:var(--space-5)}@media(max-width:640px){.topbar.svelte-1r8vfx3{flex-direction:column;align-items:flex-start;gap:var(--space-2);padding:var(--space-2) var(--space-3)}nav.svelte-1r8vfx3{width:100%;overflow-x:auto}main.svelte-1r8vfx3{padding:var(--space-3)}}:root{color-scheme:light dark;--font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;--font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, monospace;--radius-sm: .25rem;--radius: .5rem;--radius-lg: .75rem;--space-1: .25rem;--space-2: .5rem;--space-3: .75rem;--space-4: 1rem;--space-5: 1.5rem;--space-6: 2rem;--space-7: 3rem;--color-bg: #f7f8fa;--color-surface: #ffffff;--color-surface-alt: #f0f2f6;--color-border: #d9dde3;--color-border-strong: #b8bec7;--color-text: #1d1f24;--color-text-muted: #5b626d;--color-text-soft: #8a8f99;--color-accent: #1d4ed8;--color-accent-strong: #1e3a8a;--color-accent-on: #ffffff;--color-accent-soft: #e0e7ff;--color-success: #15803d;--color-success-bg: #dcfce7;--color-warn: #b45309;--color-warn-bg: #fef3c7;--color-danger: #b91c1c;--color-danger-bg: #fee2e2;--color-info: #1d4ed8;--color-info-bg: #dbeafe;--shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);--shadow: 0 4px 12px rgba(15, 23, 42, .08);--shadow-lg: 0 12px 32px rgba(15, 23, 42, .16)}@media(prefers-color-scheme:dark){:root{--color-bg: #0f1116;--color-surface: #181b22;--color-surface-alt: #20242d;--color-border: #2c313c;--color-border-strong: #3b424f;--color-text: #e8eaf0;--color-text-muted: #a4abb8;--color-text-soft: #777e8b;--color-accent: #93c5fd;--color-accent-strong: #bfdbfe;--color-accent-on: #0f1116;--color-accent-soft: #1e293b;--color-success: #4ade80;--color-success-bg: #14532d;--color-warn: #fbbf24;--color-warn-bg: #78350f;--color-danger: #f87171;--color-danger-bg: #7f1d1d;--color-info: #93c5fd;--color-info-bg: #1e3a8a;--shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);--shadow: 0 4px 12px rgba(0, 0, 0, .45);--shadow-lg: 0 12px 32px rgba(0, 0, 0, .6)}}*,*:before,*:after{box-sizing:border-box}html,body{margin:0;padding:0;background:var(--color-bg);color:var(--color-text);font-family:var(--font-sans);font-size:15px;line-height:1.5;-webkit-font-smoothing:antialiased;min-height:100vh}#app{min-height:100vh;display:flex;flex-direction:column}h1,h2,h3,h4,h5,h6{margin:0 0 var(--space-2) 0;font-weight:600;line-height:1.25;letter-spacing:-.01em}h1{font-size:1.5rem}h2{font-size:1.25rem}h3{font-size:1.05rem}p{margin:0 0 var(--space-3) 0}a{color:var(--color-accent);text-decoration:none}a:hover{text-decoration:underline}button{font:inherit;cursor:pointer;border:1px solid var(--color-border-strong);background:var(--color-surface);color:var(--color-text);padding:var(--space-2) var(--space-3);border-radius:var(--radius);transition:background-color .12s ease,border-color .12s ease}button:hover:not(:disabled){background:var(--color-surface-alt);border-color:var(--color-text-muted)}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible{outline:2px solid var(--color-accent);outline-offset:2px}button:disabled{opacity:.55;cursor:not-allowed}button.primary{background:var(--color-accent);border-color:var(--color-accent);color:var(--color-accent-on)}button.primary:hover:not(:disabled){background:var(--color-accent-strong);border-color:var(--color-accent-strong)}button.danger{background:var(--color-danger);border-color:var(--color-danger);color:#fff}button.ghost{background:transparent;border-color:transparent;color:var(--color-text-muted);padding:var(--space-1) var(--space-2)}button.ghost:hover:not(:disabled){color:var(--color-text);background:var(--color-surface-alt)}input[type=text],input[type=url],input[type=number],input[type=password],select,textarea{font:inherit;color:var(--color-text);background:var(--color-surface);border:1px solid var(--color-border-strong);border-radius:var(--radius);padding:var(--space-2) var(--space-3);width:100%}label{display:block;font-size:.85rem;color:var(--color-text-muted);font-weight:500;margin-bottom:var(--space-1)}code,pre{font-family:var(--font-mono);font-size:.85rem}pre{background:var(--color-surface-alt);padding:var(--space-3);border-radius:var(--radius);overflow:auto;margin:0}hr{border:none;border-top:1px solid var(--color-border);margin:var(--space-5) 0}.card{background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-lg);padding:var(--space-5);box-shadow:var(--shadow-sm)}.muted{color:var(--color-text-muted)}.row{display:flex;gap:var(--space-3);align-items:center;flex-wrap:wrap}.stack{display:flex;flex-direction:column;gap:var(--space-3)}.grid{display:grid;gap:var(--space-4)}.badge{display:inline-flex;align-items:center;gap:var(--space-1);font-size:.78rem;font-weight:600;letter-spacing:.02em;text-transform:uppercase;padding:.125rem .5rem;border-radius:999px;background:var(--color-surface-alt);color:var(--color-text-muted)}.badge.ok{background:var(--color-success-bg);color:var(--color-success)}.badge.warn{background:var(--color-warn-bg);color:var(--color-warn)}.badge.err{background:var(--color-danger-bg);color:var(--color-danger)}.badge.info{background:var(--color-info-bg);color:var(--color-info)}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}