@agentxm/extension-sources 0.28.4-bootstrap.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/LICENSE +110 -0
- package/README.md +9 -0
- package/dist/src/axm-skill-gate.d.ts +64 -0
- package/dist/src/axm-skill-gate.js +25 -0
- package/dist/src/errors.d.ts +116 -0
- package/dist/src/errors.js +98 -0
- package/dist/src/failure-category.d.ts +10 -0
- package/dist/src/failure-category.js +2 -0
- package/dist/src/file-url.d.ts +9 -0
- package/dist/src/file-url.js +12 -0
- package/dist/src/git/detect.d.ts +7 -0
- package/dist/src/git/detect.js +23 -0
- package/dist/src/git/operations.d.ts +37 -0
- package/dist/src/git/operations.js +101 -0
- package/dist/src/glob.d.ts +39 -0
- package/dist/src/glob.js +79 -0
- package/dist/src/hook-package-discovery.d.ts +19 -0
- package/dist/src/hook-package-discovery.js +14 -0
- package/dist/src/index.d.ts +30 -0
- package/dist/src/index.js +35 -0
- package/dist/src/integrity.d.ts +13 -0
- package/dist/src/integrity.js +17 -0
- package/dist/src/live.d.ts +29 -0
- package/dist/src/live.js +131 -0
- package/dist/src/manifest-package-discovery.d.ts +28 -0
- package/dist/src/manifest-package-discovery.js +96 -0
- package/dist/src/package-discovery.d.ts +19 -0
- package/dist/src/package-discovery.js +137 -0
- package/dist/src/package-sources.d.ts +25 -0
- package/dist/src/package-sources.js +102 -0
- package/dist/src/providers/azurerepos/index.d.ts +11 -0
- package/dist/src/providers/azurerepos/index.js +11 -0
- package/dist/src/providers/azurerepos/repo-exists.d.ts +5 -0
- package/dist/src/providers/azurerepos/repo-exists.js +21 -0
- package/dist/src/providers/azurerepos/scp.d.ts +12 -0
- package/dist/src/providers/azurerepos/scp.js +29 -0
- package/dist/src/providers/azurerepos/shorthand.d.ts +12 -0
- package/dist/src/providers/azurerepos/shorthand.js +45 -0
- package/dist/src/providers/azurerepos/url.d.ts +14 -0
- package/dist/src/providers/azurerepos/url.js +38 -0
- package/dist/src/providers/bitbucket/index.d.ts +11 -0
- package/dist/src/providers/bitbucket/index.js +11 -0
- package/dist/src/providers/bitbucket/resolve-repo.d.ts +11 -0
- package/dist/src/providers/bitbucket/resolve-repo.js +33 -0
- package/dist/src/providers/bitbucket/scp.d.ts +11 -0
- package/dist/src/providers/bitbucket/scp.js +28 -0
- package/dist/src/providers/bitbucket/shorthand.d.ts +10 -0
- package/dist/src/providers/bitbucket/shorthand.js +11 -0
- package/dist/src/providers/bitbucket/url.d.ts +13 -0
- package/dist/src/providers/bitbucket/url.js +42 -0
- package/dist/src/providers/convention-discovery.d.ts +11 -0
- package/dist/src/providers/convention-discovery.js +473 -0
- package/dist/src/providers/git-hosting.d.ts +31 -0
- package/dist/src/providers/git-hosting.js +73 -0
- package/dist/src/providers/git.d.ts +22 -0
- package/dist/src/providers/git.js +46 -0
- package/dist/src/providers/github/index.d.ts +11 -0
- package/dist/src/providers/github/index.js +11 -0
- package/dist/src/providers/github/resolve-repo.d.ts +11 -0
- package/dist/src/providers/github/resolve-repo.js +34 -0
- package/dist/src/providers/github/scp.d.ts +11 -0
- package/dist/src/providers/github/scp.js +28 -0
- package/dist/src/providers/github/shorthand.d.ts +10 -0
- package/dist/src/providers/github/shorthand.js +11 -0
- package/dist/src/providers/github/url.d.ts +13 -0
- package/dist/src/providers/github/url.js +42 -0
- package/dist/src/providers/gitlab/index.d.ts +11 -0
- package/dist/src/providers/gitlab/index.js +11 -0
- package/dist/src/providers/gitlab/resolve-repo.d.ts +11 -0
- package/dist/src/providers/gitlab/resolve-repo.js +33 -0
- package/dist/src/providers/gitlab/scp.d.ts +11 -0
- package/dist/src/providers/gitlab/scp.js +28 -0
- package/dist/src/providers/gitlab/shorthand.d.ts +10 -0
- package/dist/src/providers/gitlab/shorthand.js +11 -0
- package/dist/src/providers/gitlab/url.d.ts +13 -0
- package/dist/src/providers/gitlab/url.js +42 -0
- package/dist/src/providers/local-parser/index.d.ts +8 -0
- package/dist/src/providers/local-parser/index.js +8 -0
- package/dist/src/providers/local-parser/parser.d.ts +13 -0
- package/dist/src/providers/local-parser/parser.js +14 -0
- package/dist/src/providers/local.d.ts +23 -0
- package/dist/src/providers/local.js +39 -0
- package/dist/src/providers/parse-provider-shorthand.d.ts +18 -0
- package/dist/src/providers/parse-provider-shorthand.js +74 -0
- package/dist/src/providers/registry/host-provider.d.ts +47 -0
- package/dist/src/providers/registry/host-provider.js +584 -0
- package/dist/src/resolve-identifier.d.ts +73 -0
- package/dist/src/resolve-identifier.js +273 -0
- package/dist/src/resolve-source-pattern.d.ts +29 -0
- package/dist/src/resolve-source-pattern.js +77 -0
- package/dist/src/resolve-source.d.ts +79 -0
- package/dist/src/resolve-source.js +503 -0
- package/dist/src/rule-package-discovery.d.ts +19 -0
- package/dist/src/rule-package-discovery.js +14 -0
- package/dist/src/service.d.ts +72 -0
- package/dist/src/service.js +109 -0
- package/dist/src/url-fragment.d.ts +5 -0
- package/dist/src/url-fragment.js +19 -0
- package/dist/src/workspace-catalog.d.ts +79 -0
- package/dist/src/workspace-catalog.js +26 -0
- package/package.json +57 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Glob expansion for extension names.
|
|
3
|
+
*
|
|
4
|
+
* Expands `*` wildcards against a list of names. Only `*` is supported
|
|
5
|
+
* as a wildcard — all other characters are treated as literals.
|
|
6
|
+
*
|
|
7
|
+
* Deliberately duplicated from the CLI-destined glob module: the
|
|
8
|
+
* integration may not depend on application utilities, and this helper is
|
|
9
|
+
* within the sanctioned duplication budget for small pure functions.
|
|
10
|
+
*
|
|
11
|
+
* @experimental This API is unstable and may change without notice.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Expand a glob pattern against a list of names.
|
|
15
|
+
*
|
|
16
|
+
* Only `*` wildcards are supported. All other characters (including `?`, `[`, `]`)
|
|
17
|
+
* are treated as literals. Matching is case-sensitive.
|
|
18
|
+
*
|
|
19
|
+
* @param pattern - The pattern to match (may contain `*`)
|
|
20
|
+
* @param names - Available names to match against
|
|
21
|
+
* @returns Matching names in their original order
|
|
22
|
+
*/
|
|
23
|
+
export declare const expandGlob: (pattern: string, names: ReadonlyArray<string>) => ReadonlyArray<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Expand multiple glob patterns against a list of skill names.
|
|
26
|
+
*
|
|
27
|
+
* Returns the union of all matches, deduplicated, preserving the original
|
|
28
|
+
* order of `names`.
|
|
29
|
+
*
|
|
30
|
+
* @param patterns - Patterns to match (may contain `*`)
|
|
31
|
+
* @param names - Available names to match against
|
|
32
|
+
* @returns Matching names in their original order, deduplicated
|
|
33
|
+
*/
|
|
34
|
+
export declare const expandGlobs: (patterns: ReadonlyArray<string>, names: ReadonlyArray<string>) => ReadonlyArray<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Returns true when an input should be treated as a glob pattern.
|
|
37
|
+
*/
|
|
38
|
+
export declare const isGlobPattern: (input: string) => boolean;
|
|
39
|
+
//# sourceMappingURL=glob.d.ts.map
|
package/dist/src/glob.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Glob expansion for extension names.
|
|
3
|
+
*
|
|
4
|
+
* Expands `*` wildcards against a list of names. Only `*` is supported
|
|
5
|
+
* as a wildcard — all other characters are treated as literals.
|
|
6
|
+
*
|
|
7
|
+
* Deliberately duplicated from the CLI-destined glob module: the
|
|
8
|
+
* integration may not depend on application utilities, and this helper is
|
|
9
|
+
* within the sanctioned duplication budget for small pure functions.
|
|
10
|
+
*
|
|
11
|
+
* @experimental This API is unstable and may change without notice.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Expand a glob pattern against a list of names.
|
|
15
|
+
*
|
|
16
|
+
* Only `*` wildcards are supported. All other characters (including `?`, `[`, `]`)
|
|
17
|
+
* are treated as literals. Matching is case-sensitive.
|
|
18
|
+
*
|
|
19
|
+
* @param pattern - The pattern to match (may contain `*`)
|
|
20
|
+
* @param names - Available names to match against
|
|
21
|
+
* @returns Matching names in their original order
|
|
22
|
+
*/
|
|
23
|
+
export const expandGlob = (pattern, names) => {
|
|
24
|
+
const matches = (name) => {
|
|
25
|
+
let patternIndex = 0;
|
|
26
|
+
let nameIndex = 0;
|
|
27
|
+
let wildcardIndex = -1;
|
|
28
|
+
let wildcardNameIndex = 0;
|
|
29
|
+
while (nameIndex < name.length) {
|
|
30
|
+
const token = pattern[patternIndex];
|
|
31
|
+
if (token !== undefined && token !== "*" && token === name[nameIndex]) {
|
|
32
|
+
patternIndex += 1;
|
|
33
|
+
nameIndex += 1;
|
|
34
|
+
}
|
|
35
|
+
else if (token === "*") {
|
|
36
|
+
wildcardIndex = patternIndex;
|
|
37
|
+
wildcardNameIndex = nameIndex;
|
|
38
|
+
patternIndex += 1;
|
|
39
|
+
}
|
|
40
|
+
else if (wildcardIndex >= 0) {
|
|
41
|
+
patternIndex = wildcardIndex + 1;
|
|
42
|
+
wildcardNameIndex += 1;
|
|
43
|
+
nameIndex = wildcardNameIndex;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
while (pattern[patternIndex] === "*") {
|
|
50
|
+
patternIndex += 1;
|
|
51
|
+
}
|
|
52
|
+
return patternIndex === pattern.length;
|
|
53
|
+
};
|
|
54
|
+
return names.filter(matches);
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Expand multiple glob patterns against a list of skill names.
|
|
58
|
+
*
|
|
59
|
+
* Returns the union of all matches, deduplicated, preserving the original
|
|
60
|
+
* order of `names`.
|
|
61
|
+
*
|
|
62
|
+
* @param patterns - Patterns to match (may contain `*`)
|
|
63
|
+
* @param names - Available names to match against
|
|
64
|
+
* @returns Matching names in their original order, deduplicated
|
|
65
|
+
*/
|
|
66
|
+
export const expandGlobs = (patterns, names) => {
|
|
67
|
+
const matched = new Set();
|
|
68
|
+
for (const pattern of patterns) {
|
|
69
|
+
for (const name of expandGlob(pattern, names)) {
|
|
70
|
+
matched.add(name);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return names.filter((n) => matched.has(n));
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Returns true when an input should be treated as a glob pattern.
|
|
77
|
+
*/
|
|
78
|
+
export const isGlobPattern = (input) => input.includes("*");
|
|
79
|
+
//# sourceMappingURL=glob.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook package discovery for local and git sources.
|
|
3
|
+
*
|
|
4
|
+
* @experimental This API is unstable and may change without notice.
|
|
5
|
+
*/
|
|
6
|
+
import type * as Effect from "effect/Effect";
|
|
7
|
+
import type * as FileSystem from "effect/FileSystem";
|
|
8
|
+
import type * as Path from "effect/Path";
|
|
9
|
+
import { type HookManifest } from "@agentxm/extension-model/unstable/hooks/manifest-schema";
|
|
10
|
+
export interface DiscoveredHookPackage {
|
|
11
|
+
readonly type: "hook";
|
|
12
|
+
readonly manifest: HookManifest;
|
|
13
|
+
readonly location: string;
|
|
14
|
+
}
|
|
15
|
+
export interface HookPackageDiscoveryOptions {
|
|
16
|
+
readonly fullDepth: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const hookPackagesInDir: (searchPath: string, options: HookPackageDiscoveryOptions) => Effect.Effect<ReadonlyArray<DiscoveredHookPackage>, never, FileSystem.FileSystem | Path.Path>;
|
|
19
|
+
//# sourceMappingURL=hook-package-discovery.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook package discovery for local and git sources.
|
|
3
|
+
*
|
|
4
|
+
* @experimental This API is unstable and may change without notice.
|
|
5
|
+
*/
|
|
6
|
+
import { discoverManifestPackagesInDir } from "./manifest-package-discovery.js";
|
|
7
|
+
import { HOOK_MANIFEST_FILENAME, HookManifestSchema, } from "@agentxm/extension-model/unstable/hooks/manifest-schema";
|
|
8
|
+
const discoverHookPackagesInDir = discoverManifestPackagesInDir({
|
|
9
|
+
type: "hook",
|
|
10
|
+
manifestFilename: HOOK_MANIFEST_FILENAME,
|
|
11
|
+
manifestSchema: HookManifestSchema,
|
|
12
|
+
});
|
|
13
|
+
export const hookPackagesInDir = (searchPath, options) => discoverHookPackagesInDir(searchPath, options);
|
|
14
|
+
//# sourceMappingURL=hook-package-discovery.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AXM extension-source integration.
|
|
3
|
+
*
|
|
4
|
+
* Provides source host providers, source resolution, identifier resolution,
|
|
5
|
+
* package discovery, multi-source pattern resolution, and git acquisition.
|
|
6
|
+
* The environment-backed `SourceHostProvidersLive` layer ships separately
|
|
7
|
+
* through the `./live` export.
|
|
8
|
+
*
|
|
9
|
+
* @experimental All exports from this module are unstable and may change without notice.
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
export { GitOperationFailed, SOURCE_ERROR_CATEGORIES, SourceHostNotConfigured, SourceNetworkFailure, SourceNotResolvable, SourceSyntaxInvalid, isSourceError, isSourceResolutionFailure, sourceResolutionFailureCategory, type GitOperation, type SourceError, type SourceErrorCategory, type SourceResolutionFailure, } from "./errors.js";
|
|
13
|
+
export type { CarriedFailureCategory } from "./failure-category.js";
|
|
14
|
+
export { createGitSourceHostProvider } from "./providers/git.js";
|
|
15
|
+
export { createGitHostingSourceHostProvider } from "./providers/git-hosting.js";
|
|
16
|
+
export { createLocalSourceHostProvider } from "./providers/local.js";
|
|
17
|
+
export { createLocalRegistrySourceHostProvider, createRegistrySourceHostProviderFromHost, createRemoteRegistrySourceHostProvider, } from "./providers/registry/host-provider.js";
|
|
18
|
+
export type { SourceHostProvidersService } from "./service.js";
|
|
19
|
+
export { SourceHostProviders, createRegistryMetaProvider } from "./service.js";
|
|
20
|
+
export { WorkspaceCatalog, WorkspaceCatalogUnavailable, type ConfiguredSourceHost, type DesiredExtensionGraphView, type DesiredExtensionNodeView, type SkillCandidates, type WorkspaceCatalogService, } from "./workspace-catalog.js";
|
|
21
|
+
export { AxmSkillCandidateGate, AxmSkillGateUnavailable, type AxmSkillCandidate, type AxmSkillCandidateGateService, type AxmSkillCandidateVerdict, } from "./axm-skill-gate.js";
|
|
22
|
+
export { resolveSource, resolveShorthandInputSource, resolveSlashInputSource, routeUrlInput, routeScpInput, routeNameInput, routeRegistryInput, } from "./resolve-source.js";
|
|
23
|
+
export { resolveIdentifier, resolveInstalledIdentifier, resolveInstalledIdentifierNameOrInput, type IdentifierResolutionScope, type IdentifierResourceType, type ResolveIdentifierArgs, type ResolvedIdentifier, } from "./resolve-identifier.js";
|
|
24
|
+
export { resolveSourcePattern } from "./resolve-source-pattern.js";
|
|
25
|
+
export { discoverExtensionPackages, inspectExtensionPackage, type DiscoveredExtensionPackage, type ExtensionPackageFilter, } from "./package-discovery.js";
|
|
26
|
+
export { acquireExternalSource, findExtensionPackagesFromSource, type AcquiredExternalSource, type ResolvedExtensionPackage, } from "./package-sources.js";
|
|
27
|
+
export { fileUrlToPath } from "./file-url.js";
|
|
28
|
+
export { findGitRoot, isGitManaged } from "./git/detect.js";
|
|
29
|
+
export { getCommitSha, getTreeSha, shallowClone } from "./git/operations.js";
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AXM extension-source integration.
|
|
3
|
+
*
|
|
4
|
+
* Provides source host providers, source resolution, identifier resolution,
|
|
5
|
+
* package discovery, multi-source pattern resolution, and git acquisition.
|
|
6
|
+
* The environment-backed `SourceHostProvidersLive` layer ships separately
|
|
7
|
+
* through the `./live` export.
|
|
8
|
+
*
|
|
9
|
+
* @experimental All exports from this module are unstable and may change without notice.
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
// Failure vocabulary
|
|
13
|
+
export { GitOperationFailed, SOURCE_ERROR_CATEGORIES, SourceHostNotConfigured, SourceNetworkFailure, SourceNotResolvable, SourceSyntaxInvalid, isSourceError, isSourceResolutionFailure, sourceResolutionFailureCategory, } from "./errors.js";
|
|
14
|
+
// Provider implementations
|
|
15
|
+
export { createGitSourceHostProvider } from "./providers/git.js";
|
|
16
|
+
export { createGitHostingSourceHostProvider } from "./providers/git-hosting.js";
|
|
17
|
+
export { createLocalSourceHostProvider } from "./providers/local.js";
|
|
18
|
+
export { createLocalRegistrySourceHostProvider, createRegistrySourceHostProviderFromHost, createRemoteRegistrySourceHostProvider, } from "./providers/registry/host-provider.js";
|
|
19
|
+
export { SourceHostProviders, createRegistryMetaProvider } from "./service.js";
|
|
20
|
+
// Workspace catalog port (implemented by the composition root)
|
|
21
|
+
export { WorkspaceCatalog, WorkspaceCatalogUnavailable, } from "./workspace-catalog.js";
|
|
22
|
+
// Official AXM skill candidate gate port (implemented by the composition root)
|
|
23
|
+
export { AxmSkillCandidateGate, AxmSkillGateUnavailable, } from "./axm-skill-gate.js";
|
|
24
|
+
// Source resolver
|
|
25
|
+
export { resolveSource, resolveShorthandInputSource, resolveSlashInputSource, routeUrlInput, routeScpInput, routeNameInput, routeRegistryInput, } from "./resolve-source.js";
|
|
26
|
+
export { resolveIdentifier, resolveInstalledIdentifier, resolveInstalledIdentifierNameOrInput, } from "./resolve-identifier.js";
|
|
27
|
+
export { resolveSourcePattern } from "./resolve-source-pattern.js";
|
|
28
|
+
export { discoverExtensionPackages, inspectExtensionPackage, } from "./package-discovery.js";
|
|
29
|
+
export { acquireExternalSource, findExtensionPackagesFromSource, } from "./package-sources.js";
|
|
30
|
+
// Locator utilities
|
|
31
|
+
export { fileUrlToPath } from "./file-url.js";
|
|
32
|
+
// Git acquisition
|
|
33
|
+
export { findGitRoot, isGitManaged } from "./git/detect.js";
|
|
34
|
+
export { getCommitSha, getTreeSha, shallowClone } from "./git/operations.js";
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHA-512 integrity utility.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately duplicated from the CLI-destined integrity module: the
|
|
5
|
+
* integration may not depend on application utilities, and this helper is
|
|
6
|
+
* within the sanctioned duplication budget for small pure functions.
|
|
7
|
+
*
|
|
8
|
+
* @experimental This API is unstable and may change without notice.
|
|
9
|
+
*/
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
/** Compute SHA-512 integrity in `sha512-<base64>` SRI format. */
|
|
12
|
+
export declare const computeIntegrity: (data: Uint8Array) => Effect.Effect<string>;
|
|
13
|
+
//# sourceMappingURL=integrity.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHA-512 integrity utility.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately duplicated from the CLI-destined integrity module: the
|
|
5
|
+
* integration may not depend on application utilities, and this helper is
|
|
6
|
+
* within the sanctioned duplication budget for small pure functions.
|
|
7
|
+
*
|
|
8
|
+
* @experimental This API is unstable and may change without notice.
|
|
9
|
+
*/
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import { createHash } from "node:crypto";
|
|
12
|
+
/** Compute SHA-512 integrity in `sha512-<base64>` SRI format. */
|
|
13
|
+
export const computeIntegrity = (data) => Effect.sync(() => {
|
|
14
|
+
const base64 = createHash("sha512").update(data).digest("base64");
|
|
15
|
+
return `sha512-${base64}`;
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=integrity.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment-backed Live layer for `SourceHostProviders`.
|
|
3
|
+
*
|
|
4
|
+
* Composed only at the application composition root: the layer captures the
|
|
5
|
+
* platform services and the two composition-root ports (workspace catalog,
|
|
6
|
+
* official AXM skill gate) once and hides them behind the service interface.
|
|
7
|
+
*
|
|
8
|
+
* @experimental This API is unstable and may change without notice.
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import * as FileSystem from "effect/FileSystem";
|
|
12
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
13
|
+
import * as Path from "effect/Path";
|
|
14
|
+
import * as Layer from "effect/Layer";
|
|
15
|
+
import { AxmSkillCandidateGate } from "./axm-skill-gate.js";
|
|
16
|
+
import { SourceHostProviders } from "./service.js";
|
|
17
|
+
import { WorkspaceCatalog } from "./workspace-catalog.js";
|
|
18
|
+
/**
|
|
19
|
+
* Live layer for SourceHostProviders.
|
|
20
|
+
*
|
|
21
|
+
* Constructs the provider registry with all source type providers.
|
|
22
|
+
* Captures FileSystem, Path, HttpClient, the WorkspaceCatalog port, and the
|
|
23
|
+
* AxmSkillCandidateGate port at creation time so the service interface
|
|
24
|
+
* doesn't leak these dependencies.
|
|
25
|
+
*
|
|
26
|
+
* @experimental This API is unstable and may change without notice.
|
|
27
|
+
*/
|
|
28
|
+
export declare const SourceHostProvidersLive: Layer.Layer<SourceHostProviders, never, FileSystem.FileSystem | HttpClient.HttpClient | Path.Path | WorkspaceCatalog | AxmSkillCandidateGate>;
|
|
29
|
+
//# sourceMappingURL=live.d.ts.map
|
package/dist/src/live.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment-backed Live layer for `SourceHostProviders`.
|
|
3
|
+
*
|
|
4
|
+
* Composed only at the application composition root: the layer captures the
|
|
5
|
+
* platform services and the two composition-root ports (workspace catalog,
|
|
6
|
+
* official AXM skill gate) once and hides them behind the service interface.
|
|
7
|
+
*
|
|
8
|
+
* @experimental This API is unstable and may change without notice.
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import * as FileSystem from "effect/FileSystem";
|
|
12
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
13
|
+
import * as Path from "effect/Path";
|
|
14
|
+
import * as Effect from "effect/Effect";
|
|
15
|
+
import * as Layer from "effect/Layer";
|
|
16
|
+
import * as Option from "effect/Option";
|
|
17
|
+
import { makeWorkspaceRelativeSourcePath } from "@agentxm/extension-model/unstable/path-types";
|
|
18
|
+
import { AxmSkillCandidateGate } from "./axm-skill-gate.js";
|
|
19
|
+
import { SourceNotResolvable } from "./errors.js";
|
|
20
|
+
import { fileUrlToPath } from "./file-url.js";
|
|
21
|
+
import { createGitSourceHostProvider } from "./providers/git.js";
|
|
22
|
+
import { createGitHostingSourceHostProvider } from "./providers/git-hosting.js";
|
|
23
|
+
import { createLocalSourceHostProvider } from "./providers/local.js";
|
|
24
|
+
import { buildCloneUrlFromSource, createRegistryMetaProvider, getOriginFromSource, SourceHostProviders, } from "./service.js";
|
|
25
|
+
import { WorkspaceCatalog } from "./workspace-catalog.js";
|
|
26
|
+
// -----------------------------------------------------------------------------
|
|
27
|
+
// Layer
|
|
28
|
+
// -----------------------------------------------------------------------------
|
|
29
|
+
/**
|
|
30
|
+
* Live layer for SourceHostProviders.
|
|
31
|
+
*
|
|
32
|
+
* Constructs the provider registry with all source type providers.
|
|
33
|
+
* Captures FileSystem, Path, HttpClient, the WorkspaceCatalog port, and the
|
|
34
|
+
* AxmSkillCandidateGate port at creation time so the service interface
|
|
35
|
+
* doesn't leak these dependencies.
|
|
36
|
+
*
|
|
37
|
+
* @experimental This API is unstable and may change without notice.
|
|
38
|
+
*/
|
|
39
|
+
export const SourceHostProvidersLive = Layer.effect(SourceHostProviders, Effect.gen(function* () {
|
|
40
|
+
const fs = yield* FileSystem.FileSystem;
|
|
41
|
+
const httpClient = yield* HttpClient.HttpClient;
|
|
42
|
+
const path = yield* Path.Path;
|
|
43
|
+
const catalog = yield* WorkspaceCatalog;
|
|
44
|
+
const axmSkillGate = yield* AxmSkillCandidateGate;
|
|
45
|
+
const localProvider = createLocalSourceHostProvider();
|
|
46
|
+
const gitProvider = createGitSourceHostProvider();
|
|
47
|
+
const registryMetaProvider = createRegistryMetaProvider();
|
|
48
|
+
// Captured layer for providing to provider operations
|
|
49
|
+
const depLayer = Layer.mergeAll(Layer.succeed(FileSystem.FileSystem, fs), Layer.succeed(HttpClient.HttpClient, httpClient), Layer.succeed(Path.Path, path), Layer.succeed(AxmSkillCandidateGate, axmSkillGate));
|
|
50
|
+
const findGitHosting = (source, options) => {
|
|
51
|
+
const provider = createGitHostingSourceHostProvider(source);
|
|
52
|
+
return provider.find(source, options).pipe(Effect.provide(depLayer));
|
|
53
|
+
};
|
|
54
|
+
const fetchGitHosting = (source, ref) => {
|
|
55
|
+
const provider = createGitHostingSourceHostProvider(source);
|
|
56
|
+
return provider.fetch(source, ref).pipe(Effect.provide(depLayer));
|
|
57
|
+
};
|
|
58
|
+
const localSourceForWorkspace = (source) => ({
|
|
59
|
+
...source,
|
|
60
|
+
path: path.isAbsolute(source.path)
|
|
61
|
+
? source.path
|
|
62
|
+
: path.resolve(catalog.workspaceRoot, source.path),
|
|
63
|
+
});
|
|
64
|
+
const normalizeLocalRefSourcePath = (ref) => {
|
|
65
|
+
if (ref.refType !== "local")
|
|
66
|
+
return Effect.succeed(ref);
|
|
67
|
+
const selectedPath = fileUrlToPath(ref.location);
|
|
68
|
+
const relative = makeWorkspaceRelativeSourcePath(path, catalog.workspaceRoot, selectedPath);
|
|
69
|
+
if (Option.isNone(relative)) {
|
|
70
|
+
return Effect.fail(new SourceNotResolvable({
|
|
71
|
+
category: "validation",
|
|
72
|
+
detail: `Local extension source path cannot be represented relative to the workspace: ${selectedPath}`,
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
return Effect.succeed({ ...ref, sourcePath: relative.value });
|
|
76
|
+
};
|
|
77
|
+
const findImpl = (source, options) => {
|
|
78
|
+
switch (source.type) {
|
|
79
|
+
case "github":
|
|
80
|
+
case "gitlab":
|
|
81
|
+
case "bitbucket":
|
|
82
|
+
case "azurerepos":
|
|
83
|
+
return findGitHosting(source, options);
|
|
84
|
+
case "local":
|
|
85
|
+
return localProvider.find(localSourceForWorkspace(source), options).pipe(Effect.provide(depLayer), Effect.flatMap((refs) => Effect.forEach(refs, normalizeLocalRefSourcePath)));
|
|
86
|
+
case "git":
|
|
87
|
+
return gitProvider.find(source, options).pipe(Effect.provide(depLayer));
|
|
88
|
+
case "registry":
|
|
89
|
+
return registryMetaProvider.find(source, options).pipe(Effect.provide(depLayer));
|
|
90
|
+
case "workspace":
|
|
91
|
+
return Effect.fail(new SourceNotResolvable({
|
|
92
|
+
category: "validation",
|
|
93
|
+
detail: "Workspace sources resolve from their canonical package through the workspace configured-entry resolver",
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const fetchImpl = (source, ref) => {
|
|
98
|
+
switch (source.type) {
|
|
99
|
+
case "github":
|
|
100
|
+
case "gitlab":
|
|
101
|
+
case "bitbucket":
|
|
102
|
+
case "azurerepos":
|
|
103
|
+
return fetchGitHosting(source, ref);
|
|
104
|
+
case "local":
|
|
105
|
+
return localProvider.fetch(source, ref).pipe(Effect.provide(depLayer));
|
|
106
|
+
case "git":
|
|
107
|
+
return gitProvider.fetch(source, ref).pipe(Effect.provide(depLayer));
|
|
108
|
+
case "registry":
|
|
109
|
+
return registryMetaProvider.fetch(source, ref).pipe(Effect.provide(depLayer));
|
|
110
|
+
case "workspace":
|
|
111
|
+
return Effect.fail(new SourceNotResolvable({
|
|
112
|
+
category: "validation",
|
|
113
|
+
detail: "Workspace source files are read directly from their canonical package and are not fetched through a source host provider",
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const service = {
|
|
118
|
+
find: (source, options) => findImpl(source, options).pipe(Effect.withSpan("SourceHostProviders.find")),
|
|
119
|
+
resolveNamedRegistry: (source, options) => registryMetaProvider
|
|
120
|
+
.resolveNamed(source, options)
|
|
121
|
+
.pipe(Effect.provide(depLayer), Effect.withSpan("SourceHostProviders.resolveNamedRegistry")),
|
|
122
|
+
fetch: (ref) => {
|
|
123
|
+
const source = ref.source;
|
|
124
|
+
return fetchImpl(source, ref).pipe(Effect.withSpan("SourceHostProviders.fetch"));
|
|
125
|
+
},
|
|
126
|
+
cloneUrl: buildCloneUrlFromSource,
|
|
127
|
+
origin: getOriginFromSource,
|
|
128
|
+
};
|
|
129
|
+
return service;
|
|
130
|
+
}));
|
|
131
|
+
//# sourceMappingURL=live.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared manifest package discovery for local and git sources.
|
|
3
|
+
*
|
|
4
|
+
* @experimental This API is unstable and may change without notice.
|
|
5
|
+
*/
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as FileSystem from "effect/FileSystem";
|
|
8
|
+
import * as Path from "effect/Path";
|
|
9
|
+
import * as Schema from "effect/Schema";
|
|
10
|
+
interface ManifestWithName {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
}
|
|
13
|
+
export interface DiscoveredManifestPackage<Type extends string, Manifest extends ManifestWithName> {
|
|
14
|
+
readonly type: Type;
|
|
15
|
+
readonly manifest: Manifest;
|
|
16
|
+
readonly location: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ManifestPackageDiscoveryOptions {
|
|
19
|
+
readonly fullDepth: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface ManifestPackageDiscoveryConfig<Type extends string, Manifest extends ManifestWithName> {
|
|
22
|
+
readonly type: Type;
|
|
23
|
+
readonly manifestFilename: string;
|
|
24
|
+
readonly manifestSchema: Schema.Decoder<Manifest>;
|
|
25
|
+
}
|
|
26
|
+
export declare const discoverManifestPackagesInDir: <Type extends string, Manifest extends ManifestWithName>(config: ManifestPackageDiscoveryConfig<Type, Manifest>) => (searchPath: string, options: ManifestPackageDiscoveryOptions) => Effect.Effect<ReadonlyArray<DiscoveredManifestPackage<Type, Manifest>>, never, FileSystem.FileSystem | Path.Path>;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=manifest-package-discovery.d.ts.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared manifest package discovery for local and git sources.
|
|
3
|
+
*
|
|
4
|
+
* @experimental This API is unstable and may change without notice.
|
|
5
|
+
*/
|
|
6
|
+
import * as Array from "effect/Array";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as FileSystem from "effect/FileSystem";
|
|
9
|
+
import * as Option from "effect/Option";
|
|
10
|
+
import * as Path from "effect/Path";
|
|
11
|
+
import * as Schema from "effect/Schema";
|
|
12
|
+
import { DISCOVERY_MAX_DEPTH, DISCOVERY_SKIPPED_DIRECTORIES, } from "@agentxm/extension-model/unstable/discovery-walk";
|
|
13
|
+
export const discoverManifestPackagesInDir = (config) => (searchPath, options) => {
|
|
14
|
+
const tryParsePackageInDir = (dir) => Effect.gen(function* () {
|
|
15
|
+
const fs = yield* FileSystem.FileSystem;
|
|
16
|
+
const path = yield* Path.Path;
|
|
17
|
+
const manifestPath = path.join(dir, config.manifestFilename);
|
|
18
|
+
const exists = yield* fs
|
|
19
|
+
.exists(manifestPath)
|
|
20
|
+
.pipe(Effect.catch(() => Effect.succeed(false)));
|
|
21
|
+
if (!exists)
|
|
22
|
+
return Option.none();
|
|
23
|
+
const raw = yield* fs.readFileString(manifestPath).pipe(Effect.option);
|
|
24
|
+
if (Option.isNone(raw))
|
|
25
|
+
return Option.none();
|
|
26
|
+
const json = yield* Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown))(raw.value).pipe(Effect.option);
|
|
27
|
+
if (Option.isNone(json))
|
|
28
|
+
return Option.none();
|
|
29
|
+
const manifest = yield* Schema.decodeUnknownEffect(config.manifestSchema)(json.value).pipe(Effect.option);
|
|
30
|
+
if (Option.isNone(manifest))
|
|
31
|
+
return Option.none();
|
|
32
|
+
return Option.some({
|
|
33
|
+
type: config.type,
|
|
34
|
+
manifest: manifest.value,
|
|
35
|
+
location: `file://${dir}`,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
const scanChildren = (dir) => Effect.gen(function* () {
|
|
39
|
+
const fs = yield* FileSystem.FileSystem;
|
|
40
|
+
const path = yield* Path.Path;
|
|
41
|
+
const entries = yield* fs.readDirectory(dir).pipe(Effect.option);
|
|
42
|
+
if (Option.isNone(entries))
|
|
43
|
+
return [];
|
|
44
|
+
return yield* Effect.forEach(entries.value, (entry) => Effect.gen(function* () {
|
|
45
|
+
const fullPath = path.join(dir, entry);
|
|
46
|
+
const stat = yield* fs.stat(fullPath).pipe(Effect.option);
|
|
47
|
+
if (Option.isNone(stat) || stat.value.type !== "Directory") {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
const discovered = yield* tryParsePackageInDir(fullPath);
|
|
51
|
+
return Option.isSome(discovered) ? [discovered.value] : [];
|
|
52
|
+
}), { concurrency: "unbounded" }).pipe(Effect.map((results) => Array.flatten(results)));
|
|
53
|
+
});
|
|
54
|
+
const recursiveScan = (dir, depth) => Effect.gen(function* () {
|
|
55
|
+
if (depth > DISCOVERY_MAX_DEPTH)
|
|
56
|
+
return [];
|
|
57
|
+
const fs = yield* FileSystem.FileSystem;
|
|
58
|
+
const path = yield* Path.Path;
|
|
59
|
+
const entries = yield* fs.readDirectory(dir).pipe(Effect.option);
|
|
60
|
+
if (Option.isNone(entries))
|
|
61
|
+
return [];
|
|
62
|
+
return yield* Effect.forEach(entries.value, (entry) => Effect.gen(function* () {
|
|
63
|
+
if (DISCOVERY_SKIPPED_DIRECTORIES.has(entry))
|
|
64
|
+
return [];
|
|
65
|
+
const fullPath = path.join(dir, entry);
|
|
66
|
+
const stat = yield* fs.stat(fullPath).pipe(Effect.option);
|
|
67
|
+
if (Option.isNone(stat) || stat.value.type !== "Directory") {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
const discovered = yield* tryParsePackageInDir(fullPath);
|
|
71
|
+
const current = Option.isSome(discovered) ? [discovered.value] : [];
|
|
72
|
+
const nested = yield* recursiveScan(fullPath, depth + 1);
|
|
73
|
+
return [...current, ...nested];
|
|
74
|
+
}), { concurrency: "unbounded" }).pipe(Effect.map((results) => Array.flatten(results)));
|
|
75
|
+
});
|
|
76
|
+
return Effect.gen(function* () {
|
|
77
|
+
const direct = yield* tryParsePackageInDir(searchPath);
|
|
78
|
+
const directPackages = Option.isSome(direct) ? [direct.value] : [];
|
|
79
|
+
if (directPackages.length > 0 && !options.fullDepth)
|
|
80
|
+
return directPackages;
|
|
81
|
+
const childPackages = yield* scanChildren(searchPath);
|
|
82
|
+
if ((directPackages.length > 0 || childPackages.length > 0) && !options.fullDepth) {
|
|
83
|
+
return [...directPackages, ...childPackages];
|
|
84
|
+
}
|
|
85
|
+
const recursivePackages = yield* recursiveScan(searchPath, 0);
|
|
86
|
+
const all = [...directPackages, ...childPackages, ...recursivePackages];
|
|
87
|
+
const seen = new Set();
|
|
88
|
+
return all.filter((pkg) => {
|
|
89
|
+
if (seen.has(pkg.manifest.name))
|
|
90
|
+
return false;
|
|
91
|
+
seen.add(pkg.manifest.name);
|
|
92
|
+
return true;
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=manifest-package-discovery.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as FileSystem from "effect/FileSystem";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
import * as Path from "effect/Path";
|
|
5
|
+
import { SourceNotResolvable } from "./errors.js";
|
|
6
|
+
import type { ExtensionType, Handle } from "@agentxm/extension-model/unstable/extensions";
|
|
7
|
+
import { type ManifestIdentity } from "@agentxm/registry-protocol/unstable/publish/manifest-policy";
|
|
8
|
+
export interface ExtensionPackageFilter {
|
|
9
|
+
readonly names: ReadonlyArray<string>;
|
|
10
|
+
readonly owner: Option.Option<Handle>;
|
|
11
|
+
readonly type: ExtensionType | "*";
|
|
12
|
+
}
|
|
13
|
+
export interface DiscoveredExtensionPackage {
|
|
14
|
+
readonly directory: string;
|
|
15
|
+
readonly identity: ManifestIdentity;
|
|
16
|
+
}
|
|
17
|
+
export declare const inspectExtensionPackage: (directory: string) => Effect.Effect<DiscoveredExtensionPackage, SourceNotResolvable, FileSystem.FileSystem | Path.Path>;
|
|
18
|
+
export declare const discoverExtensionPackages: (root: string, filter: ExtensionPackageFilter) => Effect.Effect<ReadonlyArray<DiscoveredExtensionPackage>, SourceNotResolvable, FileSystem.FileSystem | Path.Path>;
|
|
19
|
+
//# sourceMappingURL=package-discovery.d.ts.map
|