@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.
- package/dist/certs/agent-cert.d.ts +91 -0
- package/dist/certs/agent-cert.d.ts.map +1 -0
- package/dist/certs/agent-cert.js +263 -0
- package/dist/certs/agent-cert.js.map +1 -0
- package/dist/certs/ca.d.ts +103 -0
- package/dist/certs/ca.d.ts.map +1 -0
- package/dist/certs/ca.js +306 -0
- package/dist/certs/ca.js.map +1 -0
- package/dist/certs/challenge-store.d.ts +28 -0
- package/dist/certs/challenge-store.d.ts.map +1 -0
- package/dist/certs/challenge-store.js +94 -0
- package/dist/certs/challenge-store.js.map +1 -0
- package/dist/certs/challenge.d.ts +70 -0
- package/dist/certs/challenge.d.ts.map +1 -0
- package/dist/certs/challenge.js +54 -0
- package/dist/certs/challenge.js.map +1 -0
- package/dist/certs/crypto-provider.d.ts +14 -0
- package/dist/certs/crypto-provider.d.ts.map +1 -0
- package/dist/certs/crypto-provider.js +18 -0
- package/dist/certs/crypto-provider.js.map +1 -0
- package/dist/certs/index.d.ts +7 -0
- package/dist/certs/index.d.ts.map +1 -0
- package/dist/certs/index.js +5 -0
- package/dist/certs/index.js.map +1 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +131 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +51 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +78 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +6 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +39 -0
- package/dist/logger.js.map +1 -0
- package/dist/mtls-health-ping.d.ts +26 -0
- package/dist/mtls-health-ping.d.ts.map +1 -0
- package/dist/mtls-health-ping.js +53 -0
- package/dist/mtls-health-ping.js.map +1 -0
- package/dist/registry/factory.d.ts +10 -0
- package/dist/registry/factory.d.ts.map +1 -0
- package/dist/registry/factory.js +26 -0
- package/dist/registry/factory.js.map +1 -0
- package/dist/registry/github-client.d.ts +14 -0
- package/dist/registry/github-client.d.ts.map +1 -0
- package/dist/registry/github-client.js +104 -0
- package/dist/registry/github-client.js.map +1 -0
- package/dist/registry/index.d.ts +7 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +6 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/registry.d.ts +8 -0
- package/dist/registry/registry.d.ts.map +1 -0
- package/dist/registry/registry.js +65 -0
- package/dist/registry/registry.js.map +1 -0
- package/dist/registry/types.d.ts +56 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +29 -0
- package/dist/registry/types.js.map +1 -0
- package/dist/registry/variable-name.d.ts +15 -0
- package/dist/registry/variable-name.d.ts.map +1 -0
- package/dist/registry/variable-name.js +17 -0
- package/dist/registry/variable-name.js.map +1 -0
- package/dist/token.d.ts +29 -0
- package/dist/token.d.ts.map +1 -0
- package/dist/token.js +44 -0
- package/dist/token.js.map +1 -0
- package/dist/types.d.ts +151 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +102 -0
- package/dist/types.js.map +1 -0
- package/package.json +37 -0
package/dist/types.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// --- Notify payload (POST /notify body) ---
|
|
3
|
+
export const NotifyTypeSchema = z.enum([
|
|
4
|
+
'issue_routed',
|
|
5
|
+
'mention',
|
|
6
|
+
'startup_check',
|
|
7
|
+
// `ci_completion` landed with macf-actions v2.0.1 / #122 — routed
|
|
8
|
+
// by the macf-actions route-by-ci-completion job when a check_suite
|
|
9
|
+
// completes on an agent-authored PR. Prior to this variant, the job
|
|
10
|
+
// shoehorned the notification into `type: 'mention'` with
|
|
11
|
+
// `source: 'ci_completion'` as a discriminator.
|
|
12
|
+
'ci_completion',
|
|
13
|
+
]);
|
|
14
|
+
// Check suite conclusions reaching the receiver — match GitHub's
|
|
15
|
+
// terminal check_suite states that macf-actions treats as actionable
|
|
16
|
+
// (see macf-actions#6 and agent-router.yml).
|
|
17
|
+
export const CheckSuiteConclusionSchema = z.enum([
|
|
18
|
+
'success', 'failure', 'timed_out', 'action_required',
|
|
19
|
+
]);
|
|
20
|
+
export const NotifyPayloadSchema = z.object({
|
|
21
|
+
type: NotifyTypeSchema,
|
|
22
|
+
issue_number: z.number().int().positive().optional(),
|
|
23
|
+
title: z.string().optional(),
|
|
24
|
+
source: z.string().optional(),
|
|
25
|
+
message: z.string().optional(),
|
|
26
|
+
// CI-completion variant fields (#122). All optional at the top
|
|
27
|
+
// level to preserve backward compat with producers that only send
|
|
28
|
+
// the base shape. Producers that want a type-narrowed shape for
|
|
29
|
+
// ci_completion can validate against CiCompletionPayloadSchema
|
|
30
|
+
// below before POST.
|
|
31
|
+
pr_number: z.number().int().positive().optional(),
|
|
32
|
+
pr_title: z.string().optional(),
|
|
33
|
+
pr_url: z.string().url().optional(),
|
|
34
|
+
conclusion: CheckSuiteConclusionSchema.optional(),
|
|
35
|
+
failing_check_name: z.string().nullable().optional(),
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Narrower schema for `ci_completion` payloads (#122). Producers
|
|
39
|
+
* (notably the macf-actions route-by-ci-completion job, v2.0.1+)
|
|
40
|
+
* should construct-and-validate against this schema for type-level
|
|
41
|
+
* clarity, then send over the wire. The receiver parses against the
|
|
42
|
+
* wider `NotifyPayloadSchema` (backward-compat across variants) and
|
|
43
|
+
* narrows via the `type === 'ci_completion'` discriminator.
|
|
44
|
+
*
|
|
45
|
+
* Required fields: everything the receiver needs to render the
|
|
46
|
+
* notification WITHOUT falling back to free-form `message` parsing.
|
|
47
|
+
* `failing_check_name` is null when conclusion is 'success'; string
|
|
48
|
+
* otherwise.
|
|
49
|
+
*/
|
|
50
|
+
export const CiCompletionPayloadSchema = z.object({
|
|
51
|
+
type: z.literal('ci_completion'),
|
|
52
|
+
source: z.literal('ci_completion'),
|
|
53
|
+
pr_number: z.number().int().positive(),
|
|
54
|
+
pr_title: z.string(),
|
|
55
|
+
pr_url: z.string().url(),
|
|
56
|
+
conclusion: CheckSuiteConclusionSchema,
|
|
57
|
+
failing_check_name: z.string().nullable(),
|
|
58
|
+
message: z.string(),
|
|
59
|
+
});
|
|
60
|
+
// --- Health response (GET /health body) ---
|
|
61
|
+
export const HealthResponseSchema = z.object({
|
|
62
|
+
agent: z.string(),
|
|
63
|
+
status: z.literal('online'),
|
|
64
|
+
type: z.string(),
|
|
65
|
+
uptime_seconds: z.number().int().nonnegative(),
|
|
66
|
+
current_issue: z.number().int().positive().nullable(),
|
|
67
|
+
version: z.string(),
|
|
68
|
+
last_notification: z.string().nullable(),
|
|
69
|
+
});
|
|
70
|
+
// --- Sign request (POST /sign body) ---
|
|
71
|
+
//
|
|
72
|
+
// Two-step challenge-response (DR-010, security fix per #80).
|
|
73
|
+
// Step 1: `{csr, agent_name, project?}` (no challenge_done, no challenge_id).
|
|
74
|
+
// Step 2: `{csr, agent_name, project?, challenge_done: true, challenge_id}`.
|
|
75
|
+
//
|
|
76
|
+
// Step 2 MUST include the `challenge_id` the server returned in step 1,
|
|
77
|
+
// and the client MUST have written the expected value to the registry
|
|
78
|
+
// using its own token. See src/certs/challenge.ts for the full protocol.
|
|
79
|
+
export const SignRequestSchema = z.object({
|
|
80
|
+
csr: z.string().min(1),
|
|
81
|
+
agent_name: z.string().min(1),
|
|
82
|
+
project: z.string().optional(),
|
|
83
|
+
challenge_done: z.boolean().optional(),
|
|
84
|
+
challenge_id: z.string().uuid().optional(),
|
|
85
|
+
}).refine((req) => !req.challenge_done || !!req.challenge_id, { message: 'challenge_id is required when challenge_done is true' });
|
|
86
|
+
// --- Sign responses ---
|
|
87
|
+
export const SignChallengeResponseSchema = z.object({
|
|
88
|
+
challenge_id: z.string(),
|
|
89
|
+
instruction: z.string(),
|
|
90
|
+
});
|
|
91
|
+
export const SignCertResponseSchema = z.object({
|
|
92
|
+
cert: z.string(),
|
|
93
|
+
});
|
|
94
|
+
// --- Notify endpoint response ---
|
|
95
|
+
export const NotifyResponseSchema = z.object({
|
|
96
|
+
status: z.literal('received'),
|
|
97
|
+
});
|
|
98
|
+
// --- Error response ---
|
|
99
|
+
export const ErrorResponseSchema = z.object({
|
|
100
|
+
error: z.string(),
|
|
101
|
+
});
|
|
102
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,6CAA6C;AAE7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC;IACrC,cAAc;IACd,SAAS;IACT,eAAe;IACf,kEAAkE;IAClE,oEAAoE;IACpE,oEAAoE;IACpE,0DAA0D;IAC1D,gDAAgD;IAChD,eAAe;CAChB,CAAC,CAAC;AAIH,iEAAiE;AACjE,qEAAqE;AACrE,6CAA6C;AAC7C,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,IAAI,CAAC;IAC/C,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB;CACrD,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,IAAI,EAAE,gBAAgB;IACtB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACpD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,+DAA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IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;CACjB,CAAC,CAAC;AAEH,mCAAmC;AAEnC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;CAC9B,CAAC,CAAC;AAEH,yBAAyB;AAEzB,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;CAClB,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@groundnuty/macf-core",
|
|
3
|
+
"version": "0.2.0-rc.0",
|
|
4
|
+
"description": "Shared internals consumed by the MACF CLI and channel-server packages. Not intended for direct external use — will be marked deprecated-internal on first npm publish per DR-022 Amendment A.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/groundnuty/macf.git",
|
|
14
|
+
"directory": "packages/macf-core"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/groundnuty/macf#readme",
|
|
17
|
+
"bugs": "https://github.com/groundnuty/macf/issues",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=22"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"check": "tsc --noEmit && eslint src/ && vitest run",
|
|
26
|
+
"lint": "eslint src/",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@opentelemetry/api": "1.9.1",
|
|
32
|
+
"@peculiar/webcrypto": "^1.5.0",
|
|
33
|
+
"@peculiar/x509": "^2.0.0",
|
|
34
|
+
"reflect-metadata": "^0.2.2",
|
|
35
|
+
"zod": "^4.0.0"
|
|
36
|
+
}
|
|
37
|
+
}
|