@groundnuty/macf-core 0.2.11 → 0.2.13
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/config.js +15 -1
- package/dist/config.js.map +1 -1
- package/dist/registry/factory.d.ts +16 -5
- package/dist/registry/factory.d.ts.map +1 -1
- package/dist/registry/factory.js +31 -17
- package/dist/registry/factory.js.map +1 -1
- package/dist/registry/index.d.ts +3 -1
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +2 -1
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/local-client.d.ts +60 -0
- package/dist/registry/local-client.d.ts.map +1 -0
- package/dist/registry/local-client.js +296 -0
- package/dist/registry/local-client.js.map +1 -0
- package/dist/registry/types.d.ts +15 -0
- package/dist/registry/types.d.ts.map +1 -1
- package/dist/registry/types.js +13 -0
- package/dist/registry/types.js.map +1 -1
- package/package.json +5 -1
package/dist/config.js
CHANGED
|
@@ -124,8 +124,22 @@ function parseRegistryConfig(registryType) {
|
|
|
124
124
|
}
|
|
125
125
|
return { type: 'repo', owner: parts[0], repo: parts[1] };
|
|
126
126
|
}
|
|
127
|
+
case 'local': {
|
|
128
|
+
// DR-024 ships local-registry mode. The path is resolved at
|
|
129
|
+
// `macf init --local` time (default: `~/.macf/registry/<project>.json`)
|
|
130
|
+
// and exported into the channel-server env so this layer never
|
|
131
|
+
// needs to expand `~` or guess the project. Fail-loud if absent —
|
|
132
|
+
// DR-024 §"Decision rule for future PRs" 3 explicitly forbids
|
|
133
|
+
// silent fallback to GitHub mode when local is requested.
|
|
134
|
+
const filePath = process.env['MACF_REGISTRY_PATH'];
|
|
135
|
+
if (!filePath) {
|
|
136
|
+
throw new ConfigError('MACF_REGISTRY_PATH is required when MACF_REGISTRY_TYPE=local. ' +
|
|
137
|
+
'Run `macf init --local` to bootstrap, or set the env var explicitly.');
|
|
138
|
+
}
|
|
139
|
+
return { type: 'local', path: filePath };
|
|
140
|
+
}
|
|
127
141
|
default:
|
|
128
|
-
throw new ConfigError(`MACF_REGISTRY_TYPE must be "org", "profile", or "
|
|
142
|
+
throw new ConfigError(`MACF_REGISTRY_TYPE must be "org", "profile", "repo", or "local", got "${registryType}"`);
|
|
129
143
|
}
|
|
130
144
|
}
|
|
131
145
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +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,GAAG,eAAe,CAAC,iBAAiB,CAAC,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AC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,CAAC;QACD,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,4DAA4D;YAC5D,wEAAwE;YACxE,+DAA+D;YAC/D,kEAAkE;YAClE,8DAA8D;YAC9D,0DAA0D;YAC1D,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;YACnD,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,MAAM,IAAI,WAAW,CACnB,gEAAgE;oBAC9D,sEAAsE,CACzE,CAAC;YACJ,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC3C,CAAC;QACD;YACE,MAAM,IAAI,WAAW,CACnB,yEAAyE,YAAY,GAAG,CACzF,CAAC;IACN,CAAC;AACH,CAAC"}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import type { Registry, RegistryConfig } from './types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Creates a Registry from config. The registry type determines
|
|
4
|
-
*
|
|
5
|
-
* - org: /orgs/{org}
|
|
6
|
-
* - profile: /repos/{user}/{user}
|
|
7
|
-
* - repo: /repos/{owner}/{repo}
|
|
3
|
+
* Creates a Registry from config. The registry type determines the
|
|
4
|
+
* backend:
|
|
5
|
+
* - org: GitHub Variables under /orgs/{org}
|
|
6
|
+
* - profile: GitHub Variables under /repos/{user}/{user}
|
|
7
|
+
* - repo: GitHub Variables under /repos/{owner}/{repo}
|
|
8
|
+
* - local: Single-file JSON registry on the local filesystem (DR-024)
|
|
9
|
+
*
|
|
10
|
+
* The exhaustive `switch` on `config.type` is the structural-defense
|
|
11
|
+
* pattern from DR-024 §"Decision rule for future PRs" — adding a fifth
|
|
12
|
+
* variant in the future will fail compile here unless every consumer
|
|
13
|
+
* site adds the new arm.
|
|
14
|
+
*
|
|
15
|
+
* `token` is unused for `local` mode; callers in local-mode contexts
|
|
16
|
+
* pass an empty string. The argument is kept positional so the call
|
|
17
|
+
* surface is identical across all four variants — one fewer per-site
|
|
18
|
+
* dispatch decision for consumers.
|
|
8
19
|
*/
|
|
9
20
|
export declare function createRegistryFromConfig(config: RegistryConfig, project: string, token: string): Registry;
|
|
10
21
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +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;
|
|
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;AAK3D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,QAAQ,CAiBV"}
|
package/dist/registry/factory.js
CHANGED
|
@@ -1,26 +1,40 @@
|
|
|
1
1
|
import { createGitHubClient } from './github-client.js';
|
|
2
2
|
import { createRegistry } from './registry.js';
|
|
3
|
+
import { createLocalRegistry } from './local-client.js';
|
|
3
4
|
/**
|
|
4
|
-
* Creates a Registry from config. The registry type determines
|
|
5
|
-
*
|
|
6
|
-
* - org: /orgs/{org}
|
|
7
|
-
* - profile: /repos/{user}/{user}
|
|
8
|
-
* - repo: /repos/{owner}/{repo}
|
|
5
|
+
* Creates a Registry from config. The registry type determines the
|
|
6
|
+
* backend:
|
|
7
|
+
* - org: GitHub Variables under /orgs/{org}
|
|
8
|
+
* - profile: GitHub Variables under /repos/{user}/{user}
|
|
9
|
+
* - repo: GitHub Variables under /repos/{owner}/{repo}
|
|
10
|
+
* - local: Single-file JSON registry on the local filesystem (DR-024)
|
|
11
|
+
*
|
|
12
|
+
* The exhaustive `switch` on `config.type` is the structural-defense
|
|
13
|
+
* pattern from DR-024 §"Decision rule for future PRs" — adding a fifth
|
|
14
|
+
* variant in the future will fail compile here unless every consumer
|
|
15
|
+
* site adds the new arm.
|
|
16
|
+
*
|
|
17
|
+
* `token` is unused for `local` mode; callers in local-mode contexts
|
|
18
|
+
* pass an empty string. The argument is kept positional so the call
|
|
19
|
+
* surface is identical across all four variants — one fewer per-site
|
|
20
|
+
* dispatch decision for consumers.
|
|
9
21
|
*/
|
|
10
22
|
export function createRegistryFromConfig(config, project, token) {
|
|
11
|
-
let pathPrefix;
|
|
12
23
|
switch (config.type) {
|
|
13
|
-
case 'org':
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
case 'org': {
|
|
25
|
+
const client = createGitHubClient(`/orgs/${config.org}`, token);
|
|
26
|
+
return createRegistry(client, project);
|
|
27
|
+
}
|
|
28
|
+
case 'profile': {
|
|
29
|
+
const client = createGitHubClient(`/repos/${config.user}/${config.user}`, token);
|
|
30
|
+
return createRegistry(client, project);
|
|
31
|
+
}
|
|
32
|
+
case 'repo': {
|
|
33
|
+
const client = createGitHubClient(`/repos/${config.owner}/${config.repo}`, token);
|
|
34
|
+
return createRegistry(client, project);
|
|
35
|
+
}
|
|
36
|
+
case 'local':
|
|
37
|
+
return createLocalRegistry({ path: config.path, project });
|
|
22
38
|
}
|
|
23
|
-
const client = createGitHubClient(pathPrefix, token);
|
|
24
|
-
return createRegistry(client, project);
|
|
25
39
|
}
|
|
26
40
|
//# sourceMappingURL=factory.js.map
|
|
@@ -1 +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;
|
|
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;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAAsB,EACtB,OAAe,EACf,KAAa;IAEb,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,KAAK,CAAC,CAAC,CAAC;YACX,MAAM,MAAM,GAAG,kBAAkB,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;YAChE,OAAO,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;QACD,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,MAAM,MAAM,GAAG,kBAAkB,CAAC,UAAU,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;YACjF,OAAO,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;QACD,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,MAAM,MAAM,GAAG,kBAAkB,CAAC,UAAU,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;YAClF,OAAO,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;QACD,KAAK,OAAO;YACV,OAAO,mBAAmB,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC"}
|
package/dist/registry/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export { AgentInfoSchema, RegistryConfigSchema, OrgRegistryConfigSchema, ProfileRegistryConfigSchema, RepoRegistryConfigSchema } from './types.js';
|
|
1
|
+
export { AgentInfoSchema, RegistryConfigSchema, OrgRegistryConfigSchema, ProfileRegistryConfigSchema, RepoRegistryConfigSchema, LocalRegistryConfigSchema } from './types.js';
|
|
2
2
|
export type { AgentInfo, Registry, RegistryConfig, GitHubVariablesClient } from './types.js';
|
|
3
3
|
export { createGitHubClient, GitHubApiError } from './github-client.js';
|
|
4
4
|
export { createRegistry } from './registry.js';
|
|
5
5
|
export { createRegistryFromConfig } from './factory.js';
|
|
6
|
+
export { createLocalRegistry, LocalRegistryError, RegistryFileSchema, REGISTRY_SCHEMA_VERSION } from './local-client.js';
|
|
7
|
+
export type { LocalRegistryOptions, RegistryFile } from './local-client.js';
|
|
6
8
|
export { toVariableSegment } from './variable-name.js';
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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;
|
|
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,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAC9K,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,mBAAmB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACzH,YAAY,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/registry/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { AgentInfoSchema, RegistryConfigSchema, OrgRegistryConfigSchema, ProfileRegistryConfigSchema, RepoRegistryConfigSchema } from './types.js';
|
|
1
|
+
export { AgentInfoSchema, RegistryConfigSchema, OrgRegistryConfigSchema, ProfileRegistryConfigSchema, RepoRegistryConfigSchema, LocalRegistryConfigSchema } from './types.js';
|
|
2
2
|
export { createGitHubClient, GitHubApiError } from './github-client.js';
|
|
3
3
|
export { createRegistry } from './registry.js';
|
|
4
4
|
export { createRegistryFromConfig } from './factory.js';
|
|
5
|
+
export { createLocalRegistry, LocalRegistryError, RegistryFileSchema, REGISTRY_SCHEMA_VERSION } from './local-client.js';
|
|
5
6
|
export { toVariableSegment } from './variable-name.js';
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +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;
|
|
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,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE9K,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,mBAAmB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAEzH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { MacfError } from '../errors.js';
|
|
3
|
+
import type { Registry } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Local registry implementation per DR-024.
|
|
6
|
+
*
|
|
7
|
+
* Single-file JSON store at the operator-supplied absolute path
|
|
8
|
+
* (typically `~/.macf/registry/<project>.json`). Reads/writes go through
|
|
9
|
+
* a temp-file-then-rename atomic write and a `proper-lockfile` advisory
|
|
10
|
+
* lock so concurrent channel-servers in the same project don't corrupt
|
|
11
|
+
* the file or lose registrations.
|
|
12
|
+
*
|
|
13
|
+
* Filesystem permissions are the trust boundary: the parent directory
|
|
14
|
+
* must be `0700` and (if the file exists) the file must be `0600`. The
|
|
15
|
+
* client fails loud if either is wrong rather than auto-fixing — the
|
|
16
|
+
* operator decides whether to chmod or move the project, per DR-024
|
|
17
|
+
* "Out of Scope" (no auto-repair).
|
|
18
|
+
*/
|
|
19
|
+
export declare const REGISTRY_SCHEMA_VERSION = 1;
|
|
20
|
+
/**
|
|
21
|
+
* Wire format of the on-disk JSON file. The envelope (`schema_version`,
|
|
22
|
+
* `project`, `agents`) is local-mode-specific; per-agent records use the
|
|
23
|
+
* shared `AgentInfoSchema` so consumers see the same shape regardless
|
|
24
|
+
* of which `Registry` implementation produced them.
|
|
25
|
+
*/
|
|
26
|
+
export declare const RegistryFileSchema: z.ZodObject<{
|
|
27
|
+
schema_version: z.ZodLiteral<1>;
|
|
28
|
+
project: z.ZodString;
|
|
29
|
+
agents: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
30
|
+
host: z.ZodString;
|
|
31
|
+
port: z.ZodNumber;
|
|
32
|
+
type: z.ZodEnum<{
|
|
33
|
+
permanent: "permanent";
|
|
34
|
+
worker: "worker";
|
|
35
|
+
}>;
|
|
36
|
+
instance_id: z.ZodString;
|
|
37
|
+
started: z.ZodString;
|
|
38
|
+
}, z.core.$strip>>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export type RegistryFile = z.infer<typeof RegistryFileSchema>;
|
|
41
|
+
export declare class LocalRegistryError extends MacfError {
|
|
42
|
+
constructor(code: string, message: string);
|
|
43
|
+
}
|
|
44
|
+
export interface LocalRegistryOptions {
|
|
45
|
+
/** Absolute path to the registry JSON file. */
|
|
46
|
+
readonly path: string;
|
|
47
|
+
/** Project name; recorded in the JSON envelope. */
|
|
48
|
+
readonly project: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Create a `Registry` backed by a single JSON file on the local
|
|
52
|
+
* filesystem. Validates filesystem permissions at construction time per
|
|
53
|
+
* DR-024 trust-boundary requirements.
|
|
54
|
+
*
|
|
55
|
+
* The returned object implements the same `Registry` interface as
|
|
56
|
+
* `createRegistry()` (the GitHub-backed variant), so consumer sites
|
|
57
|
+
* dispatching on `RegistryConfig.type` get a uniform call surface.
|
|
58
|
+
*/
|
|
59
|
+
export declare function createLocalRegistry(options: LocalRegistryOptions): Registry;
|
|
60
|
+
//# sourceMappingURL=local-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-client.d.ts","sourceRoot":"","sources":["../../src/registry/local-client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtD;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;iBAI7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAI1C;AAuLD,MAAM,WAAW,oBAAoB;IACnC,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AA6CD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,oBAAoB,GAC5B,QAAQ,CA2EV"}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { promises as fs, statSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { randomBytes } from 'node:crypto';
|
|
4
|
+
import lockfile from 'proper-lockfile';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { MacfError } from '../errors.js';
|
|
7
|
+
import { AgentInfoSchema } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Local registry implementation per DR-024.
|
|
10
|
+
*
|
|
11
|
+
* Single-file JSON store at the operator-supplied absolute path
|
|
12
|
+
* (typically `~/.macf/registry/<project>.json`). Reads/writes go through
|
|
13
|
+
* a temp-file-then-rename atomic write and a `proper-lockfile` advisory
|
|
14
|
+
* lock so concurrent channel-servers in the same project don't corrupt
|
|
15
|
+
* the file or lose registrations.
|
|
16
|
+
*
|
|
17
|
+
* Filesystem permissions are the trust boundary: the parent directory
|
|
18
|
+
* must be `0700` and (if the file exists) the file must be `0600`. The
|
|
19
|
+
* client fails loud if either is wrong rather than auto-fixing — the
|
|
20
|
+
* operator decides whether to chmod or move the project, per DR-024
|
|
21
|
+
* "Out of Scope" (no auto-repair).
|
|
22
|
+
*/
|
|
23
|
+
export const REGISTRY_SCHEMA_VERSION = 1;
|
|
24
|
+
/**
|
|
25
|
+
* Wire format of the on-disk JSON file. The envelope (`schema_version`,
|
|
26
|
+
* `project`, `agents`) is local-mode-specific; per-agent records use the
|
|
27
|
+
* shared `AgentInfoSchema` so consumers see the same shape regardless
|
|
28
|
+
* of which `Registry` implementation produced them.
|
|
29
|
+
*/
|
|
30
|
+
export const RegistryFileSchema = z.object({
|
|
31
|
+
schema_version: z.literal(REGISTRY_SCHEMA_VERSION),
|
|
32
|
+
project: z.string().min(1),
|
|
33
|
+
agents: z.record(z.string().min(1), AgentInfoSchema),
|
|
34
|
+
});
|
|
35
|
+
export class LocalRegistryError extends MacfError {
|
|
36
|
+
constructor(code, message) {
|
|
37
|
+
super(code, message);
|
|
38
|
+
this.name = 'LocalRegistryError';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Verify directory + file permissions match the DR-024 trust boundary.
|
|
43
|
+
* The parent dir must be `0700`; if the file already exists it must be
|
|
44
|
+
* `0600`. Throws on mismatch with an actionable diagnostic.
|
|
45
|
+
*
|
|
46
|
+
* On non-POSIX platforms (Windows) `mode & 0o777` semantics differ — we
|
|
47
|
+
* still call the check but don't throw on mode mismatch there. DR-024's
|
|
48
|
+
* threat model is filesystem-permission-based and POSIX-shaped; Windows
|
|
49
|
+
* deployments inherit the same trust assumptions but enforcement is
|
|
50
|
+
* platform-best-effort.
|
|
51
|
+
*/
|
|
52
|
+
function verifyPermissions(filePath) {
|
|
53
|
+
const dir = path.dirname(filePath);
|
|
54
|
+
let dirStat;
|
|
55
|
+
try {
|
|
56
|
+
dirStat = statSync(dir);
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
const cause = err.code === 'ENOENT'
|
|
60
|
+
? `Directory does not exist: ${dir}. Run \`macf init --local\` to bootstrap.`
|
|
61
|
+
: `Failed to stat directory ${dir}: ${err.message}`;
|
|
62
|
+
throw new LocalRegistryError('LOCAL_REGISTRY_DIR_MISSING', cause);
|
|
63
|
+
}
|
|
64
|
+
if (!dirStat.isDirectory()) {
|
|
65
|
+
throw new LocalRegistryError('LOCAL_REGISTRY_DIR_NOT_DIRECTORY', `Registry parent path is not a directory: ${dir}`);
|
|
66
|
+
}
|
|
67
|
+
// POSIX-only enforcement; Windows mode bits are not 0700-shaped.
|
|
68
|
+
if (process.platform !== 'win32') {
|
|
69
|
+
const dirMode = dirStat.mode & 0o777;
|
|
70
|
+
if (dirMode !== 0o700) {
|
|
71
|
+
throw new LocalRegistryError('LOCAL_REGISTRY_DIR_PERMS', `Registry directory ${dir} has mode ${dirMode.toString(8).padStart(3, '0')}; ` +
|
|
72
|
+
`expected 700 per DR-024. Fix with: chmod 700 ${dir}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// File may or may not exist yet — only check perms if present.
|
|
76
|
+
let fileStat;
|
|
77
|
+
try {
|
|
78
|
+
fileStat = statSync(filePath);
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
if (err.code === 'ENOENT')
|
|
82
|
+
return;
|
|
83
|
+
throw new LocalRegistryError('LOCAL_REGISTRY_FILE_STAT_FAILED', `Failed to stat registry file ${filePath}: ${err.message}`);
|
|
84
|
+
}
|
|
85
|
+
if (!fileStat.isFile()) {
|
|
86
|
+
throw new LocalRegistryError('LOCAL_REGISTRY_FILE_NOT_REGULAR', `Registry path is not a regular file: ${filePath}`);
|
|
87
|
+
}
|
|
88
|
+
if (process.platform !== 'win32') {
|
|
89
|
+
const fileMode = fileStat.mode & 0o777;
|
|
90
|
+
if (fileMode !== 0o600) {
|
|
91
|
+
throw new LocalRegistryError('LOCAL_REGISTRY_FILE_PERMS', `Registry file ${filePath} has mode ${fileMode.toString(8).padStart(3, '0')}; ` +
|
|
92
|
+
`expected 600 per DR-024. Fix with: chmod 600 ${filePath}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Read the registry file. Returns `null` if the file doesn't exist —
|
|
98
|
+
* register-on-empty creates it. Throws `LocalRegistryError` on malformed
|
|
99
|
+
* JSON or unsupported `schema_version` so the operator sees a
|
|
100
|
+
* diagnostic rather than silent partial state (DR-024 §"Out of Scope").
|
|
101
|
+
*/
|
|
102
|
+
async function readRegistryFile(filePath) {
|
|
103
|
+
let raw;
|
|
104
|
+
try {
|
|
105
|
+
raw = await fs.readFile(filePath, 'utf8');
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
if (err.code === 'ENOENT')
|
|
109
|
+
return null;
|
|
110
|
+
throw new LocalRegistryError('LOCAL_REGISTRY_READ_FAILED', `Failed to read registry file ${filePath}: ${err.message}`);
|
|
111
|
+
}
|
|
112
|
+
let parsed;
|
|
113
|
+
try {
|
|
114
|
+
parsed = JSON.parse(raw);
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
throw new LocalRegistryError('LOCAL_REGISTRY_MALFORMED_JSON', `Registry file ${filePath} is not valid JSON: ${err.message}. ` +
|
|
118
|
+
'Inspect the file and either repair manually or remove + re-init.');
|
|
119
|
+
}
|
|
120
|
+
// Pre-validate `schema_version` so the diagnostic is specific to a
|
|
121
|
+
// version mismatch (vs. a generic Zod failure listing every issue).
|
|
122
|
+
if (typeof parsed === 'object' &&
|
|
123
|
+
parsed !== null &&
|
|
124
|
+
'schema_version' in parsed &&
|
|
125
|
+
typeof parsed.schema_version === 'number' &&
|
|
126
|
+
parsed.schema_version !== REGISTRY_SCHEMA_VERSION) {
|
|
127
|
+
const got = parsed.schema_version;
|
|
128
|
+
throw new LocalRegistryError('LOCAL_REGISTRY_SCHEMA_MISMATCH', `Registry file ${filePath} has schema_version ${got}; ` +
|
|
129
|
+
`this build expects ${REGISTRY_SCHEMA_VERSION}. Migration tooling has not shipped yet.`);
|
|
130
|
+
}
|
|
131
|
+
const result = RegistryFileSchema.safeParse(parsed);
|
|
132
|
+
if (!result.success) {
|
|
133
|
+
throw new LocalRegistryError('LOCAL_REGISTRY_INVALID_SHAPE', `Registry file ${filePath} does not match expected shape: ${result.error.message}`);
|
|
134
|
+
}
|
|
135
|
+
return result.data;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Atomic write: serialize, write to a temp sibling, fsync, rename. The
|
|
139
|
+
* rename onto the final path is atomic on POSIX so concurrent readers
|
|
140
|
+
* never observe a partial file.
|
|
141
|
+
*/
|
|
142
|
+
async function writeRegistryFileAtomic(filePath, data) {
|
|
143
|
+
const dir = path.dirname(filePath);
|
|
144
|
+
// Random suffix prevents collisions if multiple writers somehow get
|
|
145
|
+
// past the lock (defense-in-depth — `proper-lockfile` already
|
|
146
|
+
// serializes us).
|
|
147
|
+
const suffix = `${process.pid}.${randomBytes(4).toString('hex')}`;
|
|
148
|
+
const tempPath = path.join(dir, `${path.basename(filePath)}.tmp.${suffix}`);
|
|
149
|
+
const json = `${JSON.stringify(data, null, 2)}\n`;
|
|
150
|
+
let handle;
|
|
151
|
+
try {
|
|
152
|
+
handle = await fs.open(tempPath, 'w', 0o600);
|
|
153
|
+
await handle.writeFile(json, 'utf8');
|
|
154
|
+
await handle.sync();
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
if (handle !== undefined)
|
|
158
|
+
await handle.close();
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
await fs.rename(tempPath, filePath);
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
// Clean up the temp on rename failure so we don't leave debris.
|
|
165
|
+
await fs.unlink(tempPath).catch(() => undefined);
|
|
166
|
+
throw new LocalRegistryError('LOCAL_REGISTRY_WRITE_FAILED', `Failed to rename ${tempPath} → ${filePath}: ${err.message}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Construct an empty registry file shape for first-write bootstrap.
|
|
171
|
+
*/
|
|
172
|
+
function emptyRegistry(project) {
|
|
173
|
+
return {
|
|
174
|
+
schema_version: REGISTRY_SCHEMA_VERSION,
|
|
175
|
+
project,
|
|
176
|
+
agents: {},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Run `fn` while holding an exclusive lock on the registry's parent
|
|
181
|
+
* directory.
|
|
182
|
+
*
|
|
183
|
+
* Locking the parent dir (rather than the file) keeps the lock target
|
|
184
|
+
* stable across the file's existence boundary — `proper-lockfile`
|
|
185
|
+
* keys lock identity on the inode of the target, so locking the file
|
|
186
|
+
* before vs. after creation would yield two different lock identities
|
|
187
|
+
* and concurrent first-time registrations could race. The dir is the
|
|
188
|
+
* DR-024 trust boundary anyway (`0700`) and is always present
|
|
189
|
+
* (verified at construct time).
|
|
190
|
+
*/
|
|
191
|
+
async function withLock(filePath, fn) {
|
|
192
|
+
const lockTarget = path.dirname(filePath);
|
|
193
|
+
let release;
|
|
194
|
+
try {
|
|
195
|
+
release = await lockfile.lock(lockTarget, {
|
|
196
|
+
// Generous retry count + tight intervals for high-concurrency
|
|
197
|
+
// bursts (e.g. ~10 concurrent registers on one host). Lock holds
|
|
198
|
+
// are typically <50ms (read + JSON write), so 30 retries × 100ms
|
|
199
|
+
// covers ~3s of contention even in pathological cases.
|
|
200
|
+
retries: { retries: 30, minTimeout: 20, maxTimeout: 100, factor: 1.2 },
|
|
201
|
+
stale: 30_000,
|
|
202
|
+
realpath: false,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
catch (err) {
|
|
206
|
+
throw new LocalRegistryError('LOCAL_REGISTRY_LOCK_FAILED', `Failed to acquire registry lock on ${lockTarget}: ${err.message}. ` +
|
|
207
|
+
'Another channel-server may be holding it; retry shortly or check for stale processes.');
|
|
208
|
+
}
|
|
209
|
+
try {
|
|
210
|
+
return await fn();
|
|
211
|
+
}
|
|
212
|
+
finally {
|
|
213
|
+
if (release !== undefined) {
|
|
214
|
+
await release().catch(() => undefined);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Create a `Registry` backed by a single JSON file on the local
|
|
220
|
+
* filesystem. Validates filesystem permissions at construction time per
|
|
221
|
+
* DR-024 trust-boundary requirements.
|
|
222
|
+
*
|
|
223
|
+
* The returned object implements the same `Registry` interface as
|
|
224
|
+
* `createRegistry()` (the GitHub-backed variant), so consumer sites
|
|
225
|
+
* dispatching on `RegistryConfig.type` get a uniform call surface.
|
|
226
|
+
*/
|
|
227
|
+
export function createLocalRegistry(options) {
|
|
228
|
+
if (!path.isAbsolute(options.path)) {
|
|
229
|
+
throw new LocalRegistryError('LOCAL_REGISTRY_PATH_NOT_ABSOLUTE', `Local registry path must be absolute: ${options.path}`);
|
|
230
|
+
}
|
|
231
|
+
// Fail-loud at construct-time if the trust-boundary perms are wrong.
|
|
232
|
+
// Operators see a diagnostic with the exact chmod command to run. Sync
|
|
233
|
+
// stat keeps the factory function synchronous so all four
|
|
234
|
+
// `RegistryConfig` variants share the same call surface (see
|
|
235
|
+
// `factory.ts`).
|
|
236
|
+
verifyPermissions(options.path);
|
|
237
|
+
return {
|
|
238
|
+
async register(name, info) {
|
|
239
|
+
// Validate the input ourselves — the GitHub-backed registry does
|
|
240
|
+
// this implicitly via the wire JSON path; here we want the same
|
|
241
|
+
// contract enforced before we start mutating the file.
|
|
242
|
+
const validated = AgentInfoSchema.parse(info);
|
|
243
|
+
await withLock(options.path, async () => {
|
|
244
|
+
const existing = await readRegistryFile(options.path);
|
|
245
|
+
const file = existing ?? emptyRegistry(options.project);
|
|
246
|
+
const next = {
|
|
247
|
+
schema_version: REGISTRY_SCHEMA_VERSION,
|
|
248
|
+
project: options.project,
|
|
249
|
+
agents: { ...file.agents, [name]: validated },
|
|
250
|
+
};
|
|
251
|
+
await writeRegistryFileAtomic(options.path, next);
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
async get(name) {
|
|
255
|
+
const file = await readRegistryFile(options.path);
|
|
256
|
+
if (file === null)
|
|
257
|
+
return null;
|
|
258
|
+
return file.agents[name] ?? null;
|
|
259
|
+
},
|
|
260
|
+
async list(filterPrefix) {
|
|
261
|
+
const file = await readRegistryFile(options.path);
|
|
262
|
+
if (file === null)
|
|
263
|
+
return [];
|
|
264
|
+
const results = [];
|
|
265
|
+
for (const [agentName, info] of Object.entries(file.agents)) {
|
|
266
|
+
if (filterPrefix !== '' && !agentName.startsWith(filterPrefix))
|
|
267
|
+
continue;
|
|
268
|
+
results.push({ name: agentName, info });
|
|
269
|
+
}
|
|
270
|
+
return results;
|
|
271
|
+
},
|
|
272
|
+
async remove(name) {
|
|
273
|
+
await withLock(options.path, async () => {
|
|
274
|
+
const existing = await readRegistryFile(options.path);
|
|
275
|
+
// Match GitHub-backed semantics: removing a missing agent is a
|
|
276
|
+
// no-op (DELETE returns 204 or 404 — both treated as success).
|
|
277
|
+
if (existing === null)
|
|
278
|
+
return;
|
|
279
|
+
if (!(name in existing.agents))
|
|
280
|
+
return;
|
|
281
|
+
const nextAgents = {};
|
|
282
|
+
for (const [k, v] of Object.entries(existing.agents)) {
|
|
283
|
+
if (k !== name)
|
|
284
|
+
nextAgents[k] = v;
|
|
285
|
+
}
|
|
286
|
+
const next = {
|
|
287
|
+
schema_version: REGISTRY_SCHEMA_VERSION,
|
|
288
|
+
project: options.project,
|
|
289
|
+
agents: nextAgents,
|
|
290
|
+
};
|
|
291
|
+
await writeRegistryFileAtomic(options.path, next);
|
|
292
|
+
});
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
//# sourceMappingURL=local-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-client.js","sourceRoot":"","sources":["../../src/registry/local-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OA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AAE,CAAC;oBACrD,IAAI,CAAC,KAAK,IAAI;wBAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBACpC,CAAC;gBACD,MAAM,IAAI,GAAiB;oBACzB,cAAc,EAAE,uBAAuB;oBACvC,OAAO,EAAE,OAAO,CAAC,OAAO;oBACxB,MAAM,EAAE,UAAU;iBACnB,CAAC;gBACF,MAAM,uBAAuB,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/registry/types.d.ts
CHANGED
|
@@ -32,6 +32,18 @@ export declare const RepoRegistryConfigSchema: z.ZodObject<{
|
|
|
32
32
|
owner: z.ZodString;
|
|
33
33
|
repo: z.ZodString;
|
|
34
34
|
}, z.core.$strip>;
|
|
35
|
+
/**
|
|
36
|
+
* Local-registry mode (DR-024). The `path` field is the absolute filesystem
|
|
37
|
+
* path to the project's registry JSON file (e.g.
|
|
38
|
+
* `~/.macf/registry/<project>.json` after operator-side `~` expansion). The
|
|
39
|
+
* config schema is intentionally minimal — init-time concerns (default
|
|
40
|
+
* path resolution, `--local` flag aliasing, CA generation) live in the
|
|
41
|
+
* `macf` CLI package, not here.
|
|
42
|
+
*/
|
|
43
|
+
export declare const LocalRegistryConfigSchema: z.ZodObject<{
|
|
44
|
+
type: z.ZodLiteral<"local">;
|
|
45
|
+
path: z.ZodString;
|
|
46
|
+
}, z.core.$strip>;
|
|
35
47
|
export declare const RegistryConfigSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
36
48
|
type: z.ZodLiteral<"org">;
|
|
37
49
|
org: z.ZodString;
|
|
@@ -42,6 +54,9 @@ export declare const RegistryConfigSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
42
54
|
type: z.ZodLiteral<"repo">;
|
|
43
55
|
owner: z.ZodString;
|
|
44
56
|
repo: z.ZodString;
|
|
57
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
58
|
+
type: z.ZodLiteral<"local">;
|
|
59
|
+
path: z.ZodString;
|
|
45
60
|
}, z.core.$strip>]>;
|
|
46
61
|
export type RegistryConfig = z.infer<typeof RegistryConfigSchema>;
|
|
47
62
|
export interface GitHubVariablesClient {
|
|
@@ -1 +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
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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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"}
|
package/dist/registry/types.js
CHANGED
|
@@ -21,9 +21,22 @@ export const RepoRegistryConfigSchema = z.object({
|
|
|
21
21
|
owner: z.string().min(1),
|
|
22
22
|
repo: z.string().min(1),
|
|
23
23
|
});
|
|
24
|
+
/**
|
|
25
|
+
* Local-registry mode (DR-024). The `path` field is the absolute filesystem
|
|
26
|
+
* path to the project's registry JSON file (e.g.
|
|
27
|
+
* `~/.macf/registry/<project>.json` after operator-side `~` expansion). The
|
|
28
|
+
* config schema is intentionally minimal — init-time concerns (default
|
|
29
|
+
* path resolution, `--local` flag aliasing, CA generation) live in the
|
|
30
|
+
* `macf` CLI package, not here.
|
|
31
|
+
*/
|
|
32
|
+
export const LocalRegistryConfigSchema = z.object({
|
|
33
|
+
type: z.literal('local'),
|
|
34
|
+
path: z.string().min(1),
|
|
35
|
+
});
|
|
24
36
|
export const RegistryConfigSchema = z.union([
|
|
25
37
|
OrgRegistryConfigSchema,
|
|
26
38
|
ProfileRegistryConfigSchema,
|
|
27
39
|
RepoRegistryConfigSchema,
|
|
40
|
+
LocalRegistryConfigSchema,
|
|
28
41
|
]);
|
|
29
42
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +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,CAA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AAC,OAAO,CAAC,OAAO,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;IACxB,yBAAyB;CAC1B,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@groundnuty/macf-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
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
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,7 +31,11 @@
|
|
|
31
31
|
"@opentelemetry/api": "1.9.1",
|
|
32
32
|
"@peculiar/webcrypto": "^1.5.0",
|
|
33
33
|
"@peculiar/x509": "^2.0.0",
|
|
34
|
+
"proper-lockfile": "^4.1.2",
|
|
34
35
|
"reflect-metadata": "^0.2.2",
|
|
35
36
|
"zod": "^4.0.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/proper-lockfile": "^4.1.4"
|
|
36
40
|
}
|
|
37
41
|
}
|