@groundnuty/macf-core 0.2.0-rc.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 (77) hide show
  1. package/dist/certs/agent-cert.d.ts +91 -0
  2. package/dist/certs/agent-cert.d.ts.map +1 -0
  3. package/dist/certs/agent-cert.js +263 -0
  4. package/dist/certs/agent-cert.js.map +1 -0
  5. package/dist/certs/ca.d.ts +103 -0
  6. package/dist/certs/ca.d.ts.map +1 -0
  7. package/dist/certs/ca.js +306 -0
  8. package/dist/certs/ca.js.map +1 -0
  9. package/dist/certs/challenge-store.d.ts +28 -0
  10. package/dist/certs/challenge-store.d.ts.map +1 -0
  11. package/dist/certs/challenge-store.js +94 -0
  12. package/dist/certs/challenge-store.js.map +1 -0
  13. package/dist/certs/challenge.d.ts +70 -0
  14. package/dist/certs/challenge.d.ts.map +1 -0
  15. package/dist/certs/challenge.js +54 -0
  16. package/dist/certs/challenge.js.map +1 -0
  17. package/dist/certs/crypto-provider.d.ts +14 -0
  18. package/dist/certs/crypto-provider.d.ts.map +1 -0
  19. package/dist/certs/crypto-provider.js +18 -0
  20. package/dist/certs/crypto-provider.js.map +1 -0
  21. package/dist/certs/index.d.ts +7 -0
  22. package/dist/certs/index.d.ts.map +1 -0
  23. package/dist/certs/index.js +5 -0
  24. package/dist/certs/index.js.map +1 -0
  25. package/dist/config.d.ts +3 -0
  26. package/dist/config.d.ts.map +1 -0
  27. package/dist/config.js +131 -0
  28. package/dist/config.js.map +1 -0
  29. package/dist/errors.d.ts +51 -0
  30. package/dist/errors.d.ts.map +1 -0
  31. package/dist/errors.js +78 -0
  32. package/dist/errors.js.map +1 -0
  33. package/dist/index.d.ts +24 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +25 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/logger.d.ts +6 -0
  38. package/dist/logger.d.ts.map +1 -0
  39. package/dist/logger.js +39 -0
  40. package/dist/logger.js.map +1 -0
  41. package/dist/mtls-health-ping.d.ts +26 -0
  42. package/dist/mtls-health-ping.d.ts.map +1 -0
  43. package/dist/mtls-health-ping.js +53 -0
  44. package/dist/mtls-health-ping.js.map +1 -0
  45. package/dist/registry/factory.d.ts +10 -0
  46. package/dist/registry/factory.d.ts.map +1 -0
  47. package/dist/registry/factory.js +26 -0
  48. package/dist/registry/factory.js.map +1 -0
  49. package/dist/registry/github-client.d.ts +14 -0
  50. package/dist/registry/github-client.d.ts.map +1 -0
  51. package/dist/registry/github-client.js +104 -0
  52. package/dist/registry/github-client.js.map +1 -0
  53. package/dist/registry/index.d.ts +7 -0
  54. package/dist/registry/index.d.ts.map +1 -0
  55. package/dist/registry/index.js +6 -0
  56. package/dist/registry/index.js.map +1 -0
  57. package/dist/registry/registry.d.ts +8 -0
  58. package/dist/registry/registry.d.ts.map +1 -0
  59. package/dist/registry/registry.js +65 -0
  60. package/dist/registry/registry.js.map +1 -0
  61. package/dist/registry/types.d.ts +56 -0
  62. package/dist/registry/types.d.ts.map +1 -0
  63. package/dist/registry/types.js +29 -0
  64. package/dist/registry/types.js.map +1 -0
  65. package/dist/registry/variable-name.d.ts +15 -0
  66. package/dist/registry/variable-name.d.ts.map +1 -0
  67. package/dist/registry/variable-name.js +17 -0
  68. package/dist/registry/variable-name.js.map +1 -0
  69. package/dist/token.d.ts +29 -0
  70. package/dist/token.d.ts.map +1 -0
  71. package/dist/token.js +44 -0
  72. package/dist/token.js.map +1 -0
  73. package/dist/types.d.ts +151 -0
  74. package/dist/types.d.ts.map +1 -0
  75. package/dist/types.js +102 -0
  76. package/dist/types.js.map +1 -0
  77. package/package.json +37 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/certs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEjI,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEhI,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AgentConfig } from './types.js';
2
+ export declare function loadConfig(): AgentConfig;
3
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAmB9C,wBAAgB,UAAU,IAAI,WAAW,CA+DxC"}
package/dist/config.js ADDED
@@ -0,0 +1,131 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { randomBytes } from 'node:crypto';
3
+ import { ConfigError } from './errors.js';
4
+ function requireEnv(name) {
5
+ const value = process.env[name];
6
+ if (value === undefined || value === '') {
7
+ throw new ConfigError(`Required environment variable ${name} is not set`);
8
+ }
9
+ return value;
10
+ }
11
+ function requireFilePath(name) {
12
+ const path = requireEnv(name);
13
+ if (!existsSync(path)) {
14
+ throw new ConfigError(`File not found for ${name}: ${path}`);
15
+ }
16
+ return path;
17
+ }
18
+ export function loadConfig() {
19
+ const agentName = requireEnv('MACF_AGENT_NAME');
20
+ const caCertPath = requireFilePath('MACF_CA_CERT');
21
+ const caKeyPath = resolveCaKeyPath(caCertPath);
22
+ const agentCertPath = requireFilePath('MACF_AGENT_CERT');
23
+ const agentKeyPath = requireFilePath('MACF_AGENT_KEY');
24
+ const agentType = process.env['MACF_AGENT_TYPE'] ?? 'permanent';
25
+ if (agentType !== 'permanent' && agentType !== 'worker') {
26
+ throw new ConfigError(`MACF_AGENT_TYPE must be "permanent" or "worker", got "${agentType}"`);
27
+ }
28
+ const portStr = process.env['MACF_PORT'] ?? '0';
29
+ const port = Number.parseInt(portStr, 10);
30
+ if (Number.isNaN(port) || port < 0 || port > 65535) {
31
+ throw new ConfigError(`MACF_PORT must be 0-65535, got "${portStr}"`);
32
+ }
33
+ const host = process.env['MACF_HOST'] ?? '0.0.0.0';
34
+ const advertiseHost = process.env['MACF_ADVERTISE_HOST'] ?? (host === '0.0.0.0' ? '127.0.0.1' : host);
35
+ const debugStr = process.env['MACF_DEBUG'] ?? 'false';
36
+ const debug = debugStr === 'true' || debugStr === '1';
37
+ const logPath = process.env['MACF_LOG_PATH'] || undefined;
38
+ // P2: Registry config
39
+ const project = process.env['MACF_PROJECT'] ?? 'MACF';
40
+ const agentRole = process.env['MACF_AGENT_ROLE'] ?? agentName;
41
+ const instanceId = randomBytes(3).toString('hex');
42
+ const registryType = process.env['MACF_REGISTRY_TYPE'] ?? 'repo';
43
+ const registryConfig = parseRegistryConfig(registryType);
44
+ // macf#185: workspace dir + tmux target for the on-notify wake path.
45
+ // All three are optional from the plugin's runtime perspective:
46
+ // - Missing workspaceDir → wake path no-ops (helper script can't be located).
47
+ // - Missing tmuxSession/Window + no $TMUX → wake path no-ops silently.
48
+ // - Any present → wake path uses explicit target, falls back to auto-detect.
49
+ const workspaceDir = process.env['MACF_WORKSPACE_DIR'] || undefined;
50
+ const tmuxSession = process.env['MACF_TMUX_SESSION'] || undefined;
51
+ const tmuxWindow = process.env['MACF_TMUX_WINDOW'] || undefined;
52
+ return {
53
+ agentName,
54
+ agentType,
55
+ agentRole,
56
+ host,
57
+ advertiseHost,
58
+ port,
59
+ caCertPath,
60
+ caKeyPath,
61
+ agentCertPath,
62
+ agentKeyPath,
63
+ debug,
64
+ logPath,
65
+ project,
66
+ instanceId,
67
+ registry: registryConfig,
68
+ workspaceDir,
69
+ tmuxSession,
70
+ tmuxWindow,
71
+ };
72
+ }
73
+ let warnedFallback = false;
74
+ /**
75
+ * Resolve the CA private-key path. Preferred source is the explicit
76
+ * MACF_CA_KEY env var (#103 R3); falls back to the historical
77
+ * `-cert.pem` → `-key.pem` swap on MACF_CA_CERT for workspaces that
78
+ * haven't re-run `macf update` yet (claude.sh now emits MACF_CA_KEY).
79
+ *
80
+ * Edge case: if caCertPath doesn't literally contain `-cert.pem`,
81
+ * `.replace()` silently returns the same string. That's the exact
82
+ * failure mode this issue fixes — the fallback preserves the old
83
+ * behavior for compat, but the explicit env is the only reliable
84
+ * path going forward.
85
+ */
86
+ function resolveCaKeyPath(caCertPath) {
87
+ const explicit = process.env['MACF_CA_KEY'];
88
+ if (explicit !== undefined && explicit !== '') {
89
+ if (!existsSync(explicit)) {
90
+ throw new ConfigError(`File not found for MACF_CA_KEY: ${explicit}`);
91
+ }
92
+ return explicit;
93
+ }
94
+ // Warn once per process so operators see their workspace is in legacy
95
+ // mode. The structured logger isn't available this early in startup
96
+ // (loadConfig runs before createLogger), so write directly to stderr.
97
+ if (!warnedFallback) {
98
+ warnedFallback = true;
99
+ process.stderr.write('Warning: MACF_CA_KEY not set; deriving from MACF_CA_CERT. ' +
100
+ 'This fallback is for legacy workspaces only — run `macf update` ' +
101
+ 'to regenerate claude.sh with the explicit MACF_CA_KEY export.\n');
102
+ }
103
+ return caCertPath.replace('-cert.pem', '-key.pem');
104
+ }
105
+ function parseRegistryConfig(registryType) {
106
+ switch (registryType) {
107
+ case 'org': {
108
+ const org = process.env['MACF_REGISTRY_ORG'];
109
+ if (!org)
110
+ throw new ConfigError('MACF_REGISTRY_ORG is required when MACF_REGISTRY_TYPE=org');
111
+ return { type: 'org', org };
112
+ }
113
+ case 'profile': {
114
+ const user = process.env['MACF_REGISTRY_USER'];
115
+ if (!user)
116
+ throw new ConfigError('MACF_REGISTRY_USER is required when MACF_REGISTRY_TYPE=profile');
117
+ return { type: 'profile', user };
118
+ }
119
+ case 'repo': {
120
+ const scope = process.env['MACF_REGISTRY_REPO'] ?? 'groundnuty/macf';
121
+ const parts = scope.split('/');
122
+ if (parts.length !== 2 || !parts[0] || !parts[1]) {
123
+ throw new ConfigError(`MACF_REGISTRY_REPO must be "owner/repo", got "${scope}"`);
124
+ }
125
+ return { type: 'repo', owner: parts[0], repo: parts[1] };
126
+ }
127
+ default:
128
+ throw new ConfigError(`MACF_REGISTRY_TYPE must be "org", "profile", or "repo", got "${registryType}"`);
129
+ }
130
+ }
131
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI1C,SAAS,UAAU,CAAC,IAAY;IAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QACxC,MAAM,IAAI,WAAW,CAAC,iCAAiC,IAAI,aAAa,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACnC,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,WAAW,CAAC,sBAAsB,IAAI,KAAK,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,MAAM,SAAS,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAChD,MAAM,UAAU,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC/C,MAAM,aAAa,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iDAAiD,KAAK,GAAG,CAAC,CAAC;YACnF,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,CAAC;QACD;YACE,MAAM,IAAI,WAAW,CACnB,gEAAgE,YAAY,GAAG,CAChF,CAAC;IACN,CAAC;AACH,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Base error class for all MACF errors.
3
+ * Each subclass provides a unique `code` string for programmatic handling.
4
+ */
5
+ export declare class MacfError extends Error {
6
+ readonly code: string;
7
+ constructor(code: string, message: string);
8
+ }
9
+ export declare class ConfigError extends MacfError {
10
+ constructor(message: string);
11
+ }
12
+ export declare class McpChannelError extends MacfError {
13
+ constructor(message: string);
14
+ }
15
+ export declare class HttpsServerError extends MacfError {
16
+ constructor(message: string);
17
+ }
18
+ export declare class PortUnavailableError extends MacfError {
19
+ readonly port: number;
20
+ constructor(port: number);
21
+ }
22
+ export declare class PortExhaustedError extends MacfError {
23
+ constructor();
24
+ }
25
+ export declare class ValidationError extends MacfError {
26
+ constructor(message: string);
27
+ }
28
+ /**
29
+ * Thrown by server-side handlers to request a specific HTTP status
30
+ * code on the response. The HTTPS request-handler catches instances
31
+ * of this error and maps `httpStatus` to the response code. Replaces
32
+ * the pre-ultrareview pattern:
33
+ *
34
+ * const err = new Error('message');
35
+ * (err as { status?: number }).status = 503;
36
+ * throw err;
37
+ *
38
+ * which relied on ad-hoc `as { status?: number }` casts at both throw
39
+ * and catch sites. With `HttpError`, the contract is type-level: the
40
+ * catch site narrows via `instanceof HttpError` and reads the typed
41
+ * `httpStatus` field.
42
+ *
43
+ * Use for intentional, operator-visible failures (e.g. "signing not
44
+ * available on this agent" → 503). Don't use for unexpected errors —
45
+ * those should bubble up to the generic 500 path.
46
+ */
47
+ export declare class HttpError extends MacfError {
48
+ readonly httpStatus: number;
49
+ constructor(httpStatus: number, message: string);
50
+ }
51
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK1C;AAED,qBAAa,WAAY,SAAQ,SAAS;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,gBAAiB,SAAQ,SAAS;gBACjC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,oBAAqB,SAAQ,SAAS;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM;CAKzB;AAED,qBAAa,kBAAmB,SAAQ,SAAS;;CAKhD;AAED,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,SAAU,SAAQ,SAAS;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAKhD"}
package/dist/errors.js ADDED
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Base error class for all MACF errors.
3
+ * Each subclass provides a unique `code` string for programmatic handling.
4
+ */
5
+ export class MacfError extends Error {
6
+ code;
7
+ constructor(code, message) {
8
+ super(message);
9
+ this.name = 'MacfError';
10
+ this.code = code;
11
+ }
12
+ }
13
+ export class ConfigError extends MacfError {
14
+ constructor(message) {
15
+ super('CONFIG_ERROR', message);
16
+ this.name = 'ConfigError';
17
+ }
18
+ }
19
+ export class McpChannelError extends MacfError {
20
+ constructor(message) {
21
+ super('MCP_CHANNEL_ERROR', message);
22
+ this.name = 'McpChannelError';
23
+ }
24
+ }
25
+ export class HttpsServerError extends MacfError {
26
+ constructor(message) {
27
+ super('HTTPS_SERVER_ERROR', message);
28
+ this.name = 'HttpsServerError';
29
+ }
30
+ }
31
+ export class PortUnavailableError extends MacfError {
32
+ port;
33
+ constructor(port) {
34
+ super('PORT_UNAVAILABLE', `Port ${port} is already in use`);
35
+ this.name = 'PortUnavailableError';
36
+ this.port = port;
37
+ }
38
+ }
39
+ export class PortExhaustedError extends MacfError {
40
+ constructor() {
41
+ super('PORT_EXHAUSTED', 'Failed to find available port after 10 attempts');
42
+ this.name = 'PortExhaustedError';
43
+ }
44
+ }
45
+ export class ValidationError extends MacfError {
46
+ constructor(message) {
47
+ super('VALIDATION_ERROR', message);
48
+ this.name = 'ValidationError';
49
+ }
50
+ }
51
+ /**
52
+ * Thrown by server-side handlers to request a specific HTTP status
53
+ * code on the response. The HTTPS request-handler catches instances
54
+ * of this error and maps `httpStatus` to the response code. Replaces
55
+ * the pre-ultrareview pattern:
56
+ *
57
+ * const err = new Error('message');
58
+ * (err as { status?: number }).status = 503;
59
+ * throw err;
60
+ *
61
+ * which relied on ad-hoc `as { status?: number }` casts at both throw
62
+ * and catch sites. With `HttpError`, the contract is type-level: the
63
+ * catch site narrows via `instanceof HttpError` and reads the typed
64
+ * `httpStatus` field.
65
+ *
66
+ * Use for intentional, operator-visible failures (e.g. "signing not
67
+ * available on this agent" → 503). Don't use for unexpected errors —
68
+ * those should bubble up to the generic 500 path.
69
+ */
70
+ export class HttpError extends MacfError {
71
+ httpStatus;
72
+ constructor(httpStatus, message) {
73
+ super('HTTP_ERROR', message);
74
+ this.name = 'HttpError';
75
+ this.httpStatus = httpStatus;
76
+ }
77
+ }
78
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IACzB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B,CAAC;IAChC,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,SAAU,SAAQ,SAAS;IAC7B,UAAU,CAAS;IAE5B,YAAY,UAAkB,EAAE,OAAe;QAC7C,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Barrel export for the macf-core package.
3
+ *
4
+ * Internal-shared-code package consumed by the MACF CLI and channel-
5
+ * server packages via npm workspaces. Not intended for direct
6
+ * external use (will be marked deprecated-internal on first npm
7
+ * publish per DR-022 Amendment A).
8
+ *
9
+ * Re-exports everything the consumers need so they can
10
+ * `import { X } from '@groundnuty/macf-core'` instead of reaching
11
+ * into subpaths. Subpath imports are still supported via normal
12
+ * node-resolution for consumers that need a specific module.
13
+ */
14
+ export * from './errors.js';
15
+ export * from './logger.js';
16
+ export * from './config.js';
17
+ export * from './token.js';
18
+ export * from './types.js';
19
+ export * from './mtls-health-ping.js';
20
+ export * from './certs/index.js';
21
+ export * from './registry/index.js';
22
+ export { createChallengeStore, DEFAULT_CHALLENGE_TTL_MS } from './certs/challenge-store.js';
23
+ export type { ChallengeRecord, ChallengeStore, Clock } from './certs/challenge-store.js';
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AAIpC,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC5F,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Barrel export for the macf-core package.
3
+ *
4
+ * Internal-shared-code package consumed by the MACF CLI and channel-
5
+ * server packages via npm workspaces. Not intended for direct
6
+ * external use (will be marked deprecated-internal on first npm
7
+ * publish per DR-022 Amendment A).
8
+ *
9
+ * Re-exports everything the consumers need so they can
10
+ * `import { X } from '@groundnuty/macf-core'` instead of reaching
11
+ * into subpaths. Subpath imports are still supported via normal
12
+ * node-resolution for consumers that need a specific module.
13
+ */
14
+ export * from './errors.js';
15
+ export * from './logger.js';
16
+ export * from './config.js';
17
+ export * from './token.js';
18
+ export * from './types.js';
19
+ export * from './mtls-health-ping.js';
20
+ export * from './certs/index.js';
21
+ export * from './registry/index.js';
22
+ // Subpath modules NOT re-exported from the subdir index.ts files;
23
+ // surface them here so consumers can use the flat barrel uniformly.
24
+ export { createChallengeStore, DEFAULT_CHALLENGE_TTL_MS } from './certs/challenge-store.js';
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AAEpC,kEAAkE;AAClE,oEAAoE;AACpE,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { Logger } from './types.js';
2
+ export declare function createLogger(config: {
3
+ readonly logPath?: string;
4
+ readonly debug?: boolean;
5
+ }): Logger;
6
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAkBzC,wBAAgB,YAAY,CAAC,MAAM,EAAE;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,MAAM,CA8BT"}
package/dist/logger.js ADDED
@@ -0,0 +1,39 @@
1
+ import { appendFileSync, writeFileSync, existsSync } from 'node:fs';
2
+ import { dirname } from 'node:path';
3
+ import { mkdirSync } from 'node:fs';
4
+ function formatEntry(level, event, data) {
5
+ const entry = {
6
+ ts: new Date().toISOString(),
7
+ level,
8
+ event,
9
+ ...data,
10
+ };
11
+ return JSON.stringify(entry);
12
+ }
13
+ export function createLogger(config) {
14
+ const { logPath, debug = false } = config;
15
+ if (logPath) {
16
+ const dir = dirname(logPath);
17
+ if (!existsSync(dir)) {
18
+ mkdirSync(dir, { recursive: true });
19
+ }
20
+ if (!existsSync(logPath)) {
21
+ writeFileSync(logPath, '');
22
+ }
23
+ }
24
+ function write(level, event, data) {
25
+ const line = formatEntry(level, event, data);
26
+ if (logPath) {
27
+ appendFileSync(logPath, line + '\n');
28
+ }
29
+ if (debug) {
30
+ process.stderr.write(line + '\n');
31
+ }
32
+ }
33
+ return {
34
+ info: (event, data) => write('info', event, data),
35
+ warn: (event, data) => write('warn', event, data),
36
+ error: (event, data) => write('error', event, data),
37
+ };
38
+ }
39
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACpE,O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K,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC;QACjD,IAAI,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC;QACjD,KAAK,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;KACpD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { HealthResponse } from './types.js';
2
+ /**
3
+ * Shared mTLS /health ping. Used by:
4
+ *
5
+ * - `src/cli/commands/status.ts` → `macf status` display
6
+ * - `src/plugin/lib/health.ts` → `/macf-ping` skill
7
+ *
8
+ * Returns the parsed HealthResponse on 2xx JSON, or `null` on any
9
+ * failure (missing cert files, network error, timeout, bad JSON).
10
+ * Null-on-failure matches both callers' expectations — they render
11
+ * "agent offline" at the UI layer.
12
+ *
13
+ * `src/collision.ts` has its own boolean-returning variant with
14
+ * different failure semantics (an in-process collision check, not a
15
+ * user-facing status fetch) — intentionally not folded into this
16
+ * shared helper. See ultrareview finding A3 for the dedup rationale.
17
+ */
18
+ export declare function pingAgentHealth(config: {
19
+ readonly host: string;
20
+ readonly port: number;
21
+ readonly caCertPem: string;
22
+ readonly certPath: string;
23
+ readonly keyPath: string;
24
+ readonly timeoutMs?: number;
25
+ }): Promise<HealthResponse | null>;
26
+ //# sourceMappingURL=mtls-health-ping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mtls-health-ping.d.ts","sourceRoot":"","sources":["../src/mtls-health-ping.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAmCjC"}
@@ -0,0 +1,53 @@
1
+ import { request } from 'node:https';
2
+ import { readFileSync, existsSync } from 'node:fs';
3
+ /**
4
+ * Shared mTLS /health ping. Used by:
5
+ *
6
+ * - `src/cli/commands/status.ts` → `macf status` display
7
+ * - `src/plugin/lib/health.ts` → `/macf-ping` skill
8
+ *
9
+ * Returns the parsed HealthResponse on 2xx JSON, or `null` on any
10
+ * failure (missing cert files, network error, timeout, bad JSON).
11
+ * Null-on-failure matches both callers' expectations — they render
12
+ * "agent offline" at the UI layer.
13
+ *
14
+ * `src/collision.ts` has its own boolean-returning variant with
15
+ * different failure semantics (an in-process collision check, not a
16
+ * user-facing status fetch) — intentionally not folded into this
17
+ * shared helper. See ultrareview finding A3 for the dedup rationale.
18
+ */
19
+ export async function pingAgentHealth(config) {
20
+ const { host, port, caCertPem, certPath, keyPath, timeoutMs = DEFAULT_TIMEOUT_MS } = config;
21
+ if (!existsSync(certPath) || !existsSync(keyPath))
22
+ return null;
23
+ return new Promise((resolve) => {
24
+ const req = request({
25
+ hostname: host,
26
+ port,
27
+ method: 'GET',
28
+ path: '/health',
29
+ ca: Buffer.from(caCertPem),
30
+ cert: readFileSync(certPath),
31
+ key: readFileSync(keyPath),
32
+ rejectUnauthorized: true,
33
+ timeout: timeoutMs,
34
+ }, (res) => {
35
+ const chunks = [];
36
+ res.on('data', (chunk) => chunks.push(chunk));
37
+ res.on('end', () => {
38
+ try {
39
+ const body = JSON.parse(Buffer.concat(chunks).toString('utf-8'));
40
+ resolve(body);
41
+ }
42
+ catch {
43
+ resolve(null);
44
+ }
45
+ });
46
+ });
47
+ req.on('error', () => resolve(null));
48
+ req.on('timeout', () => { req.destroy(); resolve(null); });
49
+ req.end();
50
+ });
51
+ }
52
+ const DEFAULT_TIMEOUT_MS = 5000;
53
+ //# sourceMappingURL=mtls-health-ping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mtls-health-ping.js","sourceRoot":"","sources":["../src/mtls-health-ping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGnD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAOrC;IACC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,GAAG,kBAAkB,EAAE,GAAG,MAAM,CAAC;IAE5F,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IAE/D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,GAAG,GAAG,OAAO,CACjB;YACE,QAAQ,EAAE,IAAI;YACd,IAAI;YACJ,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,SAAS;YACf,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;YAC1B,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC;YAC5B,GAAG,EAAE,YAAY,CAAC,OAAO,CAAC;YAC1B,kBAAkB,EAAE,IAAI;YACxB,OAAO,EAAE,SAAS;SACnB,EACD,CAAC,GAAG,EAAE,EAAE;YACN,MAAM,MAAM,GAAa,EAAE,CAAC;YAC5B,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YACtD,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;gBACjB,IAAI,CAAC;oBACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;oBACjE,OAAO,CAAC,IAAsB,CAAC,CAAC;gBAClC,CAAC;gBAAC,MAAM,CAAC;oBACP,OAAO,CAAC,IAAI,CAAC,CAAC;gBAChB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CACF,CAAC;QACF,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACrC,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3D,GAAG,CAAC,GAAG,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,kBAAkB,GAAG,IAAI,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Registry, RegistryConfig } from './types.js';
2
+ /**
3
+ * Creates a Registry from config. The registry type determines
4
+ * the GitHub API path prefix:
5
+ * - org: /orgs/{org}
6
+ * - profile: /repos/{user}/{user} (user's profile repo)
7
+ * - repo: /repos/{owner}/{repo}
8
+ */
9
+ export declare function createRegistryFromConfig(config: RegistryConfig, project: string, token: string): Registry;
10
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/registry/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAI3D;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,QAAQ,CAiBV"}
@@ -0,0 +1,26 @@
1
+ import { createGitHubClient } from './github-client.js';
2
+ import { createRegistry } from './registry.js';
3
+ /**
4
+ * Creates a Registry from config. The registry type determines
5
+ * the GitHub API path prefix:
6
+ * - org: /orgs/{org}
7
+ * - profile: /repos/{user}/{user} (user's profile repo)
8
+ * - repo: /repos/{owner}/{repo}
9
+ */
10
+ export function createRegistryFromConfig(config, project, token) {
11
+ let pathPrefix;
12
+ switch (config.type) {
13
+ case 'org':
14
+ pathPrefix = `/orgs/${config.org}`;
15
+ break;
16
+ case 'profile':
17
+ pathPrefix = `/repos/${config.user}/${config.user}`;
18
+ break;
19
+ case 'repo':
20
+ pathPrefix = `/repos/${config.owner}/${config.repo}`;
21
+ break;
22
+ }
23
+ const client = createGitHubClient(pathPrefix, token);
24
+ return createRegistry(client, project);
25
+ }
26
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/registry/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAAsB,EACtB,OAAe,EACf,KAAa;IAEb,IAAI,UAAkB,CAAC;IAEvB,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,KAAK;YACR,UAAU,GAAG,SAAS,MAAM,CAAC,GAAG,EAAE,CAAC;YACnC,MAAM;QACR,KAAK,SAAS;YACZ,UAAU,GAAG,UAAU,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YACpD,MAAM;QACR,KAAK,MAAM;YACT,UAAU,GAAG,UAAU,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YACrD,MAAM;IACV,CAAC;IAED,MAAM,MAAM,GAAG,kBAAkB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACrD,OAAO,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { GitHubVariablesClient } from './types.js';
2
+ import { MacfError } from '../errors.js';
3
+ export declare class GitHubApiError extends MacfError {
4
+ readonly status: number;
5
+ constructor(status: number, message: string);
6
+ }
7
+ /**
8
+ * Creates a GitHub Variables API client for a given URL path prefix.
9
+ *
10
+ * @param pathPrefix - e.g. "/orgs/my-org" or "/repos/owner/repo"
11
+ * @param token - GitHub API token
12
+ */
13
+ export declare function createGitHubClient(pathPrefix: string, token: string): GitHubVariablesClient;
14
+ //# sourceMappingURL=github-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-client.d.ts","sourceRoot":"","sources":["../../src/registry/github-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,qBAAa,cAAe,SAAQ,SAAS;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK5C;AAwBD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACZ,qBAAqB,CA8GvB"}