@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,104 @@
1
+ import { MacfError } from '../errors.js';
2
+ export class GitHubApiError extends MacfError {
3
+ status;
4
+ constructor(status, message) {
5
+ super('GITHUB_API_ERROR', `GitHub API ${status}: ${message}`);
6
+ this.name = 'GitHubApiError';
7
+ this.status = status;
8
+ }
9
+ }
10
+ const API_BASE = 'https://api.github.com';
11
+ function headers(token) {
12
+ return {
13
+ 'Accept': 'application/vnd.github+json',
14
+ 'Authorization': `Bearer ${token}`,
15
+ 'X-GitHub-Api-Version': '2022-11-28',
16
+ };
17
+ }
18
+ /**
19
+ * Creates a GitHub Variables API client for a given URL path prefix.
20
+ *
21
+ * @param pathPrefix - e.g. "/orgs/my-org" or "/repos/owner/repo"
22
+ * @param token - GitHub API token
23
+ */
24
+ export function createGitHubClient(pathPrefix, token) {
25
+ const baseUrl = `${API_BASE}${pathPrefix}/actions/variables`;
26
+ // Belt-and-suspenders: every caller currently runs names through
27
+ // toVariableSegment (uppercase + underscores + digits, URL-safe),
28
+ // but encoding here defends against a future caller forgetting the
29
+ // sanitizer — raw interpolation would silently produce a malformed
30
+ // URL or hit an adjacent variable. (#109 H2)
31
+ const encodeName = (name) => encodeURIComponent(name);
32
+ return {
33
+ async writeVariable(name, value) {
34
+ // Try PATCH (update) first
35
+ const patchRes = await fetch(`${baseUrl}/${encodeName(name)}`, {
36
+ method: 'PATCH',
37
+ headers: { ...headers(token), 'Content-Type': 'application/json' },
38
+ body: JSON.stringify({ value }),
39
+ });
40
+ if (patchRes.ok)
41
+ return;
42
+ // Variable doesn't exist yet — create with POST
43
+ if (patchRes.status === 404) {
44
+ const postRes = await fetch(baseUrl, {
45
+ method: 'POST',
46
+ headers: { ...headers(token), 'Content-Type': 'application/json' },
47
+ body: JSON.stringify({ name, value }),
48
+ });
49
+ if (postRes.ok)
50
+ return;
51
+ throw new GitHubApiError(postRes.status, `Failed to create variable ${name}: ${await postRes.text()}`);
52
+ }
53
+ throw new GitHubApiError(patchRes.status, `Failed to update variable ${name}: ${await patchRes.text()}`);
54
+ },
55
+ async readVariable(name) {
56
+ const res = await fetch(`${baseUrl}/${encodeName(name)}`, {
57
+ method: 'GET',
58
+ headers: headers(token),
59
+ });
60
+ if (res.status === 404)
61
+ return null;
62
+ if (!res.ok) {
63
+ throw new GitHubApiError(res.status, `Failed to read variable ${name}: ${await res.text()}`);
64
+ }
65
+ const data = await res.json();
66
+ return data.value;
67
+ },
68
+ async listVariables() {
69
+ const results = [];
70
+ let page = 1;
71
+ const perPage = 30;
72
+ // Paginate through all variables
73
+ for (;;) {
74
+ const res = await fetch(`${baseUrl}?per_page=${perPage}&page=${page}`, {
75
+ method: 'GET',
76
+ headers: headers(token),
77
+ });
78
+ if (!res.ok) {
79
+ throw new GitHubApiError(res.status, `Failed to list variables: ${await res.text()}`);
80
+ }
81
+ const data = await res.json();
82
+ for (const v of data.variables) {
83
+ results.push({ name: v.name, value: v.value });
84
+ }
85
+ if (results.length >= data.total_count || data.variables.length < perPage) {
86
+ break;
87
+ }
88
+ page++;
89
+ }
90
+ return results;
91
+ },
92
+ async deleteVariable(name) {
93
+ const res = await fetch(`${baseUrl}/${encodeName(name)}`, {
94
+ method: 'DELETE',
95
+ headers: headers(token),
96
+ });
97
+ // 204 = deleted, 404 = already gone — both OK
98
+ if (res.status === 204 || res.status === 404)
99
+ return;
100
+ throw new GitHubApiError(res.status, `Failed to delete variable ${name}: ${await res.text()}`);
101
+ },
102
+ };
103
+ }
104
+ //# sourceMappingURL=github-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-client.js","sourceRoot":"","sources":["../../src/registry/github-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,OAAO,cAAe,SAAQ,SAAS;IAClC,MAAM,CAAS;IAExB,YAAY,MAAc,EAAE,OAAe;QACzC,KAAK,CAAC,kBAAkB,EAAE,cAAc,MAAM,KAAK,OAAO,EAAE,CAAC,CAAC;QAC9D,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,wBAAwB,CAAC;AAE1C,SAAS,OAAO,CAAC,KAAa;IAC5B,OAAO;QACL,QAAQ,EAAE,6BAA6B;QACvC,eAAe,EAAE,U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MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,CAChD,CAAC;gBACJ,CAAC;gBAED,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAwB,CAAC;gBACpD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;oBAC/B,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;gBACjD,CAAC;gBAED,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,OAAO,EAAE,CAAC;oBAC1E,MAAM;gBACR,CAAC;gBACD,IAAI,EAAE,CAAC;YACT,CAAC;YAED,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,KAAK,CAAC,cAAc,CAAC,IAAY;YAC/B,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE;gBACxD,MAAM,EAAE,QAAQ;gBAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC;aACxB,CAAC,CAAC;YAEH,8CAA8C;YAC9C,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;gBAAE,OAAO;YAErD,MAAM,IAAI,cAAc,CACtB,GAAG,CAAC,MAAM,EACV,6BAA6B,IAAI,KAAK,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,CACzD,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { AgentInfoSchema, RegistryConfigSchema, OrgRegistryConfigSchema, ProfileRegistryConfigSchema, RepoRegistryConfigSchema } from './types.js';
2
+ export type { AgentInfo, Registry, RegistryConfig, GitHubVariablesClient } from './types.js';
3
+ export { createGitHubClient, GitHubApiError } from './github-client.js';
4
+ export { createRegistry } from './registry.js';
5
+ export { createRegistryFromConfig } from './factory.js';
6
+ export { toVariableSegment } from './variable-name.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACnJ,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC7F,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { AgentInfoSchema, RegistryConfigSchema, OrgRegistryConfigSchema, ProfileRegistryConfigSchema, RepoRegistryConfigSchema } from './types.js';
2
+ export { createGitHubClient, GitHubApiError } from './github-client.js';
3
+ export { createRegistry } from './registry.js';
4
+ export { createRegistryFromConfig } from './factory.js';
5
+ export { toVariableSegment } from './variable-name.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEnJ,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Registry, GitHubVariablesClient } from './types.js';
2
+ /**
3
+ * Creates a Registry backed by a GitHubVariablesClient.
4
+ * All three backends (org, profile, repo) share this implementation —
5
+ * the only difference is the URL path prefix baked into the client.
6
+ */
7
+ export declare function createRegistry(client: GitHubVariablesClient, project: string): Registry;
8
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry/registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,QAAQ,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE7E;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,MAAM,GACd,QAAQ,CAgEV"}
@@ -0,0 +1,65 @@
1
+ import { AgentInfoSchema } from './types.js';
2
+ import { toVariableSegment } from './variable-name.js';
3
+ /**
4
+ * Creates a Registry backed by a GitHubVariablesClient.
5
+ * All three backends (org, profile, repo) share this implementation —
6
+ * the only difference is the URL path prefix baked into the client.
7
+ */
8
+ export function createRegistry(client, project) {
9
+ // GitHub Actions variable names only accept [A-Z0-9_]. Hyphens in the
10
+ // project or agent name become underscores; names are uppercased.
11
+ const prefix = `${toVariableSegment(project)}_AGENT_`;
12
+ function variableName(agentName) {
13
+ return `${prefix}${toVariableSegment(agentName)}`;
14
+ }
15
+ return {
16
+ async register(name, info) {
17
+ const value = JSON.stringify(info);
18
+ await client.writeVariable(variableName(name), value);
19
+ },
20
+ async get(name) {
21
+ const value = await client.readVariable(variableName(name));
22
+ if (value === null)
23
+ return null;
24
+ let parsed;
25
+ try {
26
+ parsed = JSON.parse(value);
27
+ }
28
+ catch {
29
+ return null;
30
+ }
31
+ const result = AgentInfoSchema.safeParse(parsed);
32
+ if (!result.success)
33
+ return null;
34
+ return result.data;
35
+ },
36
+ async list(filterPrefix) {
37
+ const allVars = await client.listVariables();
38
+ // Sanitize filter side with the same transform used at write time so
39
+ // a filterPrefix like 'cv-' matches stored 'CV_ARCHITECT'.
40
+ const fullPrefix = `${prefix}${filterPrefix ? toVariableSegment(filterPrefix) : ''}`;
41
+ const results = [];
42
+ for (const v of allVars) {
43
+ if (!v.name.startsWith(fullPrefix))
44
+ continue;
45
+ let parsed;
46
+ try {
47
+ parsed = JSON.parse(v.value);
48
+ }
49
+ catch {
50
+ continue;
51
+ }
52
+ const result = AgentInfoSchema.safeParse(parsed);
53
+ if (!result.success)
54
+ continue;
55
+ const agentName = v.name.slice(prefix.length);
56
+ results.push({ name: agentName, info: result.data });
57
+ }
58
+ return results;
59
+ },
60
+ async remove(name) {
61
+ await client.deleteVariable(variableName(name));
62
+ },
63
+ };
64
+ }
65
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/registry/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGvD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,MAA6B,EAC7B,OAAe;IAEf,sEAAsE;IACtE,kEAAkE;IAClE,MAAM,MAAM,GAAG,GAAG,iBAAiB,CAAC,OAAO,CAAC,SAAS,CAAC;IAEtD,SAAS,YAAY,CAAC,SAAiB;QACrC,OAAO,GAAG,MAAM,GAAG,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC;IACpD,CAAC;IAED,OAAO;QACL,KAAK,CAAC,QAAQ,CAAC,IAAY,EAAE,IAAe;YAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YACnC,MAAM,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;QACxD,CAAC;QAED,KAAK,CAAC,GAA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AM,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC9C,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YACvD,CAAC;YAED,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,KAAK,CAAC,MAAM,CAAC,IAAY;YACvB,MAAM,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QAClD,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { z } from 'zod';
2
+ export declare const AgentInfoSchema: z.ZodObject<{
3
+ host: z.ZodString;
4
+ port: z.ZodNumber;
5
+ type: z.ZodEnum<{
6
+ permanent: "permanent";
7
+ worker: "worker";
8
+ }>;
9
+ instance_id: z.ZodString;
10
+ started: z.ZodString;
11
+ }, z.core.$strip>;
12
+ export type AgentInfo = z.infer<typeof AgentInfoSchema>;
13
+ export interface Registry {
14
+ readonly register: (name: string, info: AgentInfo) => Promise<void>;
15
+ readonly get: (name: string) => Promise<AgentInfo | null>;
16
+ readonly list: (prefix: string) => Promise<ReadonlyArray<{
17
+ readonly name: string;
18
+ readonly info: AgentInfo;
19
+ }>>;
20
+ readonly remove: (name: string) => Promise<void>;
21
+ }
22
+ export declare const OrgRegistryConfigSchema: z.ZodObject<{
23
+ type: z.ZodLiteral<"org">;
24
+ org: z.ZodString;
25
+ }, z.core.$strip>;
26
+ export declare const ProfileRegistryConfigSchema: z.ZodObject<{
27
+ type: z.ZodLiteral<"profile">;
28
+ user: z.ZodString;
29
+ }, z.core.$strip>;
30
+ export declare const RepoRegistryConfigSchema: z.ZodObject<{
31
+ type: z.ZodLiteral<"repo">;
32
+ owner: z.ZodString;
33
+ repo: z.ZodString;
34
+ }, z.core.$strip>;
35
+ export declare const RegistryConfigSchema: z.ZodUnion<readonly [z.ZodObject<{
36
+ type: z.ZodLiteral<"org">;
37
+ org: z.ZodString;
38
+ }, z.core.$strip>, z.ZodObject<{
39
+ type: z.ZodLiteral<"profile">;
40
+ user: z.ZodString;
41
+ }, z.core.$strip>, z.ZodObject<{
42
+ type: z.ZodLiteral<"repo">;
43
+ owner: z.ZodString;
44
+ repo: z.ZodString;
45
+ }, z.core.$strip>]>;
46
+ export type RegistryConfig = z.infer<typeof RegistryConfigSchema>;
47
+ export interface GitHubVariablesClient {
48
+ readonly writeVariable: (name: string, value: string) => Promise<void>;
49
+ readonly readVariable: (name: string) => Promise<string | null>;
50
+ readonly listVariables: () => Promise<ReadonlyArray<{
51
+ readonly name: string;
52
+ readonly value: string;
53
+ }>>;
54
+ readonly deleteVariable: (name: string) => Promise<void>;
55
+ }
56
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,eAAe;;;;;;;;;iBAM1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAIxD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IAC1D,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC,CAAC;IAC/G,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAClD;AAID,eAAO,MAAM,uBAAuB;;;iBAGlC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;iBAGtC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;iBAInC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;mBAI/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAIlE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvE,QAAQ,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAChE,QAAQ,CAAC,aAAa,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IACxG,QAAQ,CAAC,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D"}
@@ -0,0 +1,29 @@
1
+ import { z } from 'zod';
2
+ // --- Agent registration info stored in GitHub variable ---
3
+ export const AgentInfoSchema = z.object({
4
+ host: z.string(),
5
+ port: z.number().int().positive(),
6
+ type: z.enum(['permanent', 'worker']),
7
+ instance_id: z.string(),
8
+ started: z.string(),
9
+ });
10
+ // --- Registry configuration ---
11
+ export const OrgRegistryConfigSchema = z.object({
12
+ type: z.literal('org'),
13
+ org: z.string().min(1),
14
+ });
15
+ export const ProfileRegistryConfigSchema = z.object({
16
+ type: z.literal('profile'),
17
+ user: z.string().min(1),
18
+ });
19
+ export const RepoRegistryConfigSchema = z.object({
20
+ type: z.literal('repo'),
21
+ owner: z.string().min(1),
22
+ repo: z.string().min(1),
23
+ });
24
+ export const RegistryConfigSchema = z.union([
25
+ OrgRegistryConfigSchema,
26
+ ProfileRegistryConfigSchema,
27
+ RepoRegistryConfigSchema,
28
+ ]);
29
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,4DAA4D;AAE5D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACjC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACrC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AAaH,iCAAiC;AAEjC,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IACtB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACvB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IAC1B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACxB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACvB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACxB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC;IAC1C,uBAAuB;IACvB,2BAA2B;IAC3B,wBAAwB;CACzB,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Convert a project or agent name to the form used in GitHub Actions variable names.
3
+ *
4
+ * GitHub Actions variable names only accept [A-Z0-9_]. Hyphens (valid in
5
+ * project/repo/agent names) must be converted to underscores. Names are
6
+ * also uppercased by convention — see DR-005 for the registration schema.
7
+ *
8
+ * Examples:
9
+ * toVariableSegment('macf') → 'MACF'
10
+ * toVariableSegment('academic-resume') → 'ACADEMIC_RESUME'
11
+ * toVariableSegment('cv-architect') → 'CV_ARCHITECT'
12
+ * toVariableSegment('with_underscore') → 'WITH_UNDERSCORE'
13
+ */
14
+ export declare function toVariableSegment(name: string): string;
15
+ //# sourceMappingURL=variable-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variable-name.d.ts","sourceRoot":"","sources":["../../src/registry/variable-name.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Convert a project or agent name to the form used in GitHub Actions variable names.
3
+ *
4
+ * GitHub Actions variable names only accept [A-Z0-9_]. Hyphens (valid in
5
+ * project/repo/agent names) must be converted to underscores. Names are
6
+ * also uppercased by convention — see DR-005 for the registration schema.
7
+ *
8
+ * Examples:
9
+ * toVariableSegment('macf') → 'MACF'
10
+ * toVariableSegment('academic-resume') → 'ACADEMIC_RESUME'
11
+ * toVariableSegment('cv-architect') → 'CV_ARCHITECT'
12
+ * toVariableSegment('with_underscore') → 'WITH_UNDERSCORE'
13
+ */
14
+ export function toVariableSegment(name) {
15
+ return name.toUpperCase().replace(/-/g, '_');
16
+ }
17
+ //# sourceMappingURL=variable-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variable-name.js","sourceRoot":"","sources":["../../src/registry/variable-name.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Explicit credentials to use instead of env vars. Callers that have loaded
3
+ * macf-agent.json pass this so the user doesn't need APP_ID/INSTALL_ID/KEY_PATH
4
+ * in the environment.
5
+ */
6
+ export interface TokenSource {
7
+ readonly appId: string;
8
+ readonly installId: string;
9
+ /** Absolute path to the App private key. Callers should resolve relative
10
+ * paths (e.g. from macf-agent.json) before passing. */
11
+ readonly keyPath: string;
12
+ }
13
+ /**
14
+ * Generate a GitHub App installation token.
15
+ *
16
+ * Precedence:
17
+ * 1. GH_TOKEN env var (if set, returned as-is — user override wins)
18
+ * 2. Explicit TokenSource argument (from macf-agent.json config)
19
+ * 3. APP_ID / INSTALL_ID / KEY_PATH env vars (legacy fallback for scripts)
20
+ *
21
+ * When both GH_TOKEN and an explicit TokenSource are present,
22
+ * emit a debug warn (#111 C1). This is the quieter cousin of the
23
+ * attribution trap: running an agent in a terminal with a stale
24
+ * GH_TOKEN from another workspace silently operates under that
25
+ * identity instead of the configured App. In debug mode, surface
26
+ * the override so the user can spot the mismatch.
27
+ */
28
+ export declare function generateToken(source?: TokenSource): Promise<string>;
29
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;4DACwD;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAgCzE"}
package/dist/token.js ADDED
@@ -0,0 +1,44 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+ const execFileAsync = promisify(execFile);
4
+ /**
5
+ * Generate a GitHub App installation token.
6
+ *
7
+ * Precedence:
8
+ * 1. GH_TOKEN env var (if set, returned as-is — user override wins)
9
+ * 2. Explicit TokenSource argument (from macf-agent.json config)
10
+ * 3. APP_ID / INSTALL_ID / KEY_PATH env vars (legacy fallback for scripts)
11
+ *
12
+ * When both GH_TOKEN and an explicit TokenSource are present,
13
+ * emit a debug warn (#111 C1). This is the quieter cousin of the
14
+ * attribution trap: running an agent in a terminal with a stale
15
+ * GH_TOKEN from another workspace silently operates under that
16
+ * identity instead of the configured App. In debug mode, surface
17
+ * the override so the user can spot the mismatch.
18
+ */
19
+ export async function generateToken(source) {
20
+ const envToken = process.env['GH_TOKEN'];
21
+ if (envToken) {
22
+ if (source && process.env['MACF_DEBUG'] === 'true') {
23
+ process.stderr.write('warn: GH_TOKEN env is set and overrides the configured TokenSource. ' +
24
+ 'Unset GH_TOKEN if you want to use the App token; set MACF_DEBUG=false ' +
25
+ 'to silence this warning.\n');
26
+ }
27
+ return envToken;
28
+ }
29
+ const appId = source?.appId ?? process.env['APP_ID'];
30
+ const installId = source?.installId ?? process.env['INSTALL_ID'];
31
+ const keyPath = source?.keyPath ?? process.env['KEY_PATH'];
32
+ if (!appId || !installId || !keyPath) {
33
+ throw new Error('No GH_TOKEN, no TokenSource provided, and missing APP_ID/INSTALL_ID/KEY_PATH env vars');
34
+ }
35
+ const { stdout } = await execFileAsync('gh', [
36
+ 'token', 'generate',
37
+ '--app-id', appId,
38
+ '--installation-id', installId,
39
+ '--key', keyPath,
40
+ ], { encoding: 'utf-8' });
41
+ const parsed = JSON.parse(stdout);
42
+ return parsed.token;
43
+ }
44
+ //# sourceMappingURL=token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.js","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAe1C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAoB;IACtD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACzC,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,MAAM,EAAE,CAAC;YACnD,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,sEAAsE;gBACtE,wEAAwE;gBACxE,4BAA4B,CAC7B,CAAC;QACJ,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACjE,MAAM,OAAO,GAAG,MAAM,EAAE,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAE3D,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,uFAAuF,CACxF,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE;QAC3C,OAAO,EAAE,UAAU;QACnB,UAAU,EAAE,KAAK;QACjB,mBAAmB,EAAE,SAAS;QAC9B,OAAO,EAAE,OAAO;KACjB,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IAE1B,MAAM,MAAM,GAAsB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACrD,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB,CAAC"}
@@ -0,0 +1,151 @@
1
+ import { z } from 'zod';
2
+ export declare const NotifyTypeSchema: z.ZodEnum<{
3
+ issue_routed: "issue_routed";
4
+ mention: "mention";
5
+ startup_check: "startup_check";
6
+ ci_completion: "ci_completion";
7
+ }>;
8
+ export type NotifyType = z.infer<typeof NotifyTypeSchema>;
9
+ export declare const CheckSuiteConclusionSchema: z.ZodEnum<{
10
+ success: "success";
11
+ failure: "failure";
12
+ timed_out: "timed_out";
13
+ action_required: "action_required";
14
+ }>;
15
+ export type CheckSuiteConclusion = z.infer<typeof CheckSuiteConclusionSchema>;
16
+ export declare const NotifyPayloadSchema: z.ZodObject<{
17
+ type: z.ZodEnum<{
18
+ issue_routed: "issue_routed";
19
+ mention: "mention";
20
+ startup_check: "startup_check";
21
+ ci_completion: "ci_completion";
22
+ }>;
23
+ issue_number: z.ZodOptional<z.ZodNumber>;
24
+ title: z.ZodOptional<z.ZodString>;
25
+ source: z.ZodOptional<z.ZodString>;
26
+ message: z.ZodOptional<z.ZodString>;
27
+ pr_number: z.ZodOptional<z.ZodNumber>;
28
+ pr_title: z.ZodOptional<z.ZodString>;
29
+ pr_url: z.ZodOptional<z.ZodString>;
30
+ conclusion: z.ZodOptional<z.ZodEnum<{
31
+ success: "success";
32
+ failure: "failure";
33
+ timed_out: "timed_out";
34
+ action_required: "action_required";
35
+ }>>;
36
+ failing_check_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
37
+ }, z.core.$strip>;
38
+ export type NotifyPayload = z.infer<typeof NotifyPayloadSchema>;
39
+ /**
40
+ * Narrower schema for `ci_completion` payloads (#122). Producers
41
+ * (notably the macf-actions route-by-ci-completion job, v2.0.1+)
42
+ * should construct-and-validate against this schema for type-level
43
+ * clarity, then send over the wire. The receiver parses against the
44
+ * wider `NotifyPayloadSchema` (backward-compat across variants) and
45
+ * narrows via the `type === 'ci_completion'` discriminator.
46
+ *
47
+ * Required fields: everything the receiver needs to render the
48
+ * notification WITHOUT falling back to free-form `message` parsing.
49
+ * `failing_check_name` is null when conclusion is 'success'; string
50
+ * otherwise.
51
+ */
52
+ export declare const CiCompletionPayloadSchema: z.ZodObject<{
53
+ type: z.ZodLiteral<"ci_completion">;
54
+ source: z.ZodLiteral<"ci_completion">;
55
+ pr_number: z.ZodNumber;
56
+ pr_title: z.ZodString;
57
+ pr_url: z.ZodString;
58
+ conclusion: z.ZodEnum<{
59
+ success: "success";
60
+ failure: "failure";
61
+ timed_out: "timed_out";
62
+ action_required: "action_required";
63
+ }>;
64
+ failing_check_name: z.ZodNullable<z.ZodString>;
65
+ message: z.ZodString;
66
+ }, z.core.$strip>;
67
+ export type CiCompletionPayload = z.infer<typeof CiCompletionPayloadSchema>;
68
+ export declare const HealthResponseSchema: z.ZodObject<{
69
+ agent: z.ZodString;
70
+ status: z.ZodLiteral<"online">;
71
+ type: z.ZodString;
72
+ uptime_seconds: z.ZodNumber;
73
+ current_issue: z.ZodNullable<z.ZodNumber>;
74
+ version: z.ZodString;
75
+ last_notification: z.ZodNullable<z.ZodString>;
76
+ }, z.core.$strip>;
77
+ export type HealthResponse = z.infer<typeof HealthResponseSchema>;
78
+ export interface AgentConfig {
79
+ readonly agentName: string;
80
+ readonly agentType: string;
81
+ readonly agentRole: string;
82
+ readonly host: string;
83
+ readonly advertiseHost: string;
84
+ readonly port: number;
85
+ readonly caCertPath: string;
86
+ readonly caKeyPath: string;
87
+ readonly agentCertPath: string;
88
+ readonly agentKeyPath: string;
89
+ readonly debug: boolean;
90
+ readonly logPath: string | undefined;
91
+ readonly project: string;
92
+ readonly instanceId: string;
93
+ readonly registry: import('./registry/types.js').RegistryConfig;
94
+ /**
95
+ * Workspace root directory. Used to locate helper scripts
96
+ * (.claude/scripts/tmux-send-to-claude.sh) for the on-notify tmux
97
+ * wake path (macf#185). Sourced from the `MACF_WORKSPACE_DIR` env
98
+ * that claude.sh exports.
99
+ */
100
+ readonly workspaceDir: string | undefined;
101
+ /**
102
+ * Tmux session:window target for on-notify wake via
103
+ * `tmux-send-to-claude.sh`. Optional — when unset, the wake path
104
+ * auto-detects from `$TMUX` + `tmux display-message`, and no-ops
105
+ * outside tmux entirely. See macf#185 + `src/tmux-wake.ts`.
106
+ */
107
+ readonly tmuxSession: string | undefined;
108
+ readonly tmuxWindow: string | undefined;
109
+ }
110
+ export declare const SignRequestSchema: z.ZodObject<{
111
+ csr: z.ZodString;
112
+ agent_name: z.ZodString;
113
+ project: z.ZodOptional<z.ZodString>;
114
+ challenge_done: z.ZodOptional<z.ZodBoolean>;
115
+ challenge_id: z.ZodOptional<z.ZodString>;
116
+ }, z.core.$strip>;
117
+ export type SignRequest = z.infer<typeof SignRequestSchema>;
118
+ export declare const SignChallengeResponseSchema: z.ZodObject<{
119
+ challenge_id: z.ZodString;
120
+ instruction: z.ZodString;
121
+ }, z.core.$strip>;
122
+ export declare const SignCertResponseSchema: z.ZodObject<{
123
+ cert: z.ZodString;
124
+ }, z.core.$strip>;
125
+ export declare const NotifyResponseSchema: z.ZodObject<{
126
+ status: z.ZodLiteral<"received">;
127
+ }, z.core.$strip>;
128
+ export declare const ErrorResponseSchema: z.ZodObject<{
129
+ error: z.ZodString;
130
+ }, z.core.$strip>;
131
+ export interface Logger {
132
+ readonly info: (event: string, data?: Record<string, unknown>) => void;
133
+ readonly warn: (event: string, data?: Record<string, unknown>) => void;
134
+ readonly error: (event: string, data?: Record<string, unknown>) => void;
135
+ }
136
+ export interface McpChannel {
137
+ readonly connect: () => Promise<void>;
138
+ readonly pushNotification: (content: string, meta: Record<string, string>) => Promise<void>;
139
+ }
140
+ export interface HttpsServer {
141
+ readonly start: (port: number, host: string) => Promise<{
142
+ readonly actualPort: number;
143
+ }>;
144
+ readonly stop: () => Promise<void>;
145
+ }
146
+ export interface HealthState {
147
+ readonly getHealth: () => HealthResponse;
148
+ readonly setCurrentIssue: (issueNumber: number | null) => void;
149
+ readonly recordNotification: () => void;
150
+ }
151
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,gBAAgB;;;;;EAU3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAK1D,eAAO,MAAM,0BAA0B;;;;;EAErC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;iBAgB9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;iBASpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAI5E,eAAO,MAAM,oBAAoB;;;;;;;;iBAQ/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAIlE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,SAAS,EA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