@agentxm/extension-lifecycle 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.
Files changed (84) hide show
  1. package/LICENSE +110 -0
  2. package/dist/src/configured-entry-resolution.d.ts +110 -0
  3. package/dist/src/configured-entry-resolution.js +723 -0
  4. package/dist/src/errors.d.ts +39 -0
  5. package/dist/src/errors.js +45 -0
  6. package/dist/src/failure-adapter.d.ts +35 -0
  7. package/dist/src/failure-adapter.js +23 -0
  8. package/dist/src/hooks/configured-agent-outcomes-provider.d.ts +18 -0
  9. package/dist/src/hooks/configured-agent-outcomes-provider.js +39 -0
  10. package/dist/src/hooks/manager.d.ts +15 -0
  11. package/dist/src/hooks/manager.js +751 -0
  12. package/dist/src/index.d.ts +38 -0
  13. package/dist/src/index.js +41 -0
  14. package/dist/src/internal/fs-helpers.d.ts +12 -0
  15. package/dist/src/internal/fs-helpers.js +13 -0
  16. package/dist/src/internal/integrity.d.ts +13 -0
  17. package/dist/src/internal/integrity.js +17 -0
  18. package/dist/src/knowledge/manager.d.ts +11 -0
  19. package/dist/src/knowledge/manager.js +655 -0
  20. package/dist/src/live.d.ts +18 -0
  21. package/dist/src/live.js +18 -0
  22. package/dist/src/mcps/manager.d.ts +16 -0
  23. package/dist/src/mcps/manager.js +213 -0
  24. package/dist/src/mcps/operations/artifact.d.ts +24 -0
  25. package/dist/src/mcps/operations/artifact.js +74 -0
  26. package/dist/src/mcps/operations/disable.d.ts +18 -0
  27. package/dist/src/mcps/operations/disable.js +113 -0
  28. package/dist/src/mcps/operations/enable.d.ts +18 -0
  29. package/dist/src/mcps/operations/enable.js +218 -0
  30. package/dist/src/mcps/operations/install.d.ts +59 -0
  31. package/dist/src/mcps/operations/install.js +566 -0
  32. package/dist/src/mcps/operations/sync-outcome.d.ts +10 -0
  33. package/dist/src/mcps/operations/sync-outcome.js +27 -0
  34. package/dist/src/mcps/operations/uninstall.d.ts +41 -0
  35. package/dist/src/mcps/operations/uninstall.js +189 -0
  36. package/dist/src/packs/dependency-resolution.d.ts +65 -0
  37. package/dist/src/packs/dependency-resolution.js +414 -0
  38. package/dist/src/packs/expansion.d.ts +59 -0
  39. package/dist/src/packs/expansion.js +44 -0
  40. package/dist/src/packs/manager.d.ts +16 -0
  41. package/dist/src/packs/manager.js +181 -0
  42. package/dist/src/packs/operations/install.d.ts +67 -0
  43. package/dist/src/packs/operations/install.js +156 -0
  44. package/dist/src/packs/resolved-dependency.d.ts +29 -0
  45. package/dist/src/packs/resolved-dependency.js +28 -0
  46. package/dist/src/registry-materialization.d.ts +52 -0
  47. package/dist/src/registry-materialization.js +67 -0
  48. package/dist/src/resolution-progress.d.ts +18 -0
  49. package/dist/src/resolution-progress.js +11 -0
  50. package/dist/src/resolution-timeout.d.ts +5 -0
  51. package/dist/src/resolution-timeout.js +11 -0
  52. package/dist/src/rules/manager.d.ts +20 -0
  53. package/dist/src/rules/manager.js +475 -0
  54. package/dist/src/skills/manager.d.ts +18 -0
  55. package/dist/src/skills/manager.js +346 -0
  56. package/dist/src/skills/materialization.d.ts +54 -0
  57. package/dist/src/skills/materialization.js +158 -0
  58. package/dist/src/skills/operations/disable.d.ts +31 -0
  59. package/dist/src/skills/operations/disable.js +110 -0
  60. package/dist/src/skills/operations/enable.d.ts +31 -0
  61. package/dist/src/skills/operations/enable.js +113 -0
  62. package/dist/src/skills/operations/install-result.d.ts +33 -0
  63. package/dist/src/skills/operations/install-result.js +10 -0
  64. package/dist/src/skills/operations/install.d.ts +67 -0
  65. package/dist/src/skills/operations/install.js +590 -0
  66. package/dist/src/skills/operations/source-hash.d.ts +2 -0
  67. package/dist/src/skills/operations/source-hash.js +6 -0
  68. package/dist/src/skills/operations/uninstall.d.ts +40 -0
  69. package/dist/src/skills/operations/uninstall.js +157 -0
  70. package/dist/src/skills/utils.d.ts +11 -0
  71. package/dist/src/skills/utils.js +29 -0
  72. package/dist/src/subagents/manager.d.ts +18 -0
  73. package/dist/src/subagents/manager.js +677 -0
  74. package/dist/src/subagents/operations/artifact.d.ts +18 -0
  75. package/dist/src/subagents/operations/artifact.js +43 -0
  76. package/dist/src/subagents/operations/disable.d.ts +32 -0
  77. package/dist/src/subagents/operations/disable.js +116 -0
  78. package/dist/src/subagents/operations/enable.d.ts +30 -0
  79. package/dist/src/subagents/operations/enable.js +160 -0
  80. package/dist/src/workflows/install-command/workflow.d.ts +57 -0
  81. package/dist/src/workflows/install-command/workflow.js +41 -0
  82. package/dist/src/workflows/uninstall-command/workflow.d.ts +42 -0
  83. package/dist/src/workflows/uninstall-command/workflow.js +29 -0
  84. package/package.json +62 -0
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Disable skill executor — removes agent symlinks but preserves canonical files.
3
+ *
4
+ * Materialized artifacts are observed directly. Accepted-resolution rows identify
5
+ * source content but do not prove that canonical or projected files exist.
6
+ *
7
+ * @experimental This API is unstable and may change without notice.
8
+ */
9
+ import * as FileSystem from "effect/FileSystem";
10
+ import * as Path from "effect/Path";
11
+ import * as Array from "effect/Array";
12
+ import * as Effect from "effect/Effect";
13
+ import * as Option from "effect/Option";
14
+ import * as Layer from "effect/Layer";
15
+ import { DefaultCodingAgentRepository } from "@agentxm/extension-workspace";
16
+ import { ExtensionLifecycleFailed } from "../../errors.js";
17
+ import { LifecycleFailureAdapter, withAdaptedStepFailures } from "../../failure-adapter.js";
18
+ import { WorkspaceMutations } from "@agentxm/workspace-state";
19
+ import { sanitizeName } from "@agentxm/workspace-state";
20
+ import { skillArtifactFromTargets, } from "@agentxm/extension-workspace";
21
+ import { installedRowsByName } from "@agentxm/workspace-state";
22
+ import { removeSkillAgentArtifact } from "../materialization.js";
23
+ // -----------------------------------------------------------------------------
24
+ // Public API
25
+ // -----------------------------------------------------------------------------
26
+ /**
27
+ * Disable-skill operation handler.
28
+ *
29
+ * Determines lifecycle from the workspace read model, removes observable
30
+ * materialized targets, and promotes implicit pack members to a direct disabled
31
+ * preference. Canonical files are preserved for later re-enablement.
32
+ */
33
+ export const disableSkill = (op) => Effect.gen(function* () {
34
+ const fs = yield* FileSystem.FileSystem;
35
+ const path = yield* Path.Path;
36
+ const ws = yield* WorkspaceMutations;
37
+ const base = ws.baseDir;
38
+ const fsPathLayer = Layer.mergeAll(Layer.succeed(FileSystem.FileSystem, fs), Layer.succeed(Path.Path, path));
39
+ // Read lifecycle to determine promotion needs
40
+ const installedSkills = yield* ws.records.rows("skill").pipe(Effect.map(installedRowsByName));
41
+ const installed = installedSkills[op.args.skillName];
42
+ const isImplicit = installed !== undefined && installed.lifecycle === "implicit";
43
+ const graph = yield* ws.getDesiredStateGraph();
44
+ if (!graph.complete) {
45
+ return yield* new ExtensionLifecycleFailed({
46
+ category: "conflict",
47
+ detail: "Cannot disable the skill while pack-derived desired state is unresolved.",
48
+ });
49
+ }
50
+ const desiredBeforeDisable = graph.nodes.find((node) => node.type === "skill" && node.name === op.args.skillName);
51
+ const sanitizedName = sanitizeName(op.args.skillName);
52
+ const materializationAgents = yield* DefaultCodingAgentRepository.getMaterializationAgents().pipe(Effect.provideService(WorkspaceMutations, ws));
53
+ const installableTargetOptions = yield* ws.runTransaction({
54
+ transition: Effect.gen(function* () {
55
+ if (isImplicit) {
56
+ const source = desiredBeforeDisable?.source ?? Option.getOrElse(installed.source, () => undefined);
57
+ if (source === undefined) {
58
+ return yield* new ExtensionLifecycleFailed({
59
+ category: "internal",
60
+ detail: `Cannot determine source for implicit skill "${op.args.skillName}"`,
61
+ suggestions: [{ description: "Provide a source when disabling this skill" }],
62
+ });
63
+ }
64
+ yield* ws.setSkillEntry(op.args.skillName, { source, enabled: false });
65
+ }
66
+ else {
67
+ yield* ws.updateSkillEntry(op.args.skillName, (entry) => ({
68
+ ...entry,
69
+ enabled: false,
70
+ }));
71
+ }
72
+ return yield* Effect.forEach(materializationAgents, (agent) => agent.resolveEffectiveSkillsDir({ workspaceRoot: base }).pipe(Effect.provide(fsPathLayer), Effect.flatMap((outcome) => outcome._tag === "supported"
73
+ ? Effect.gen(function* () {
74
+ const targetDir = path.normalize(outcome.dir);
75
+ yield* removeSkillAgentArtifact({
76
+ fs,
77
+ pathService: path,
78
+ targetDir,
79
+ sanitizedName,
80
+ });
81
+ return Option.some({
82
+ agentId: agent.id,
83
+ targetDir,
84
+ });
85
+ })
86
+ : Effect.succeed(Option.none()))), { concurrency: "unbounded" });
87
+ }).pipe(Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path)),
88
+ validate: () => Effect.void,
89
+ });
90
+ const installableTargets = Array.getSomes(installableTargetOptions);
91
+ const artifact = yield* skillArtifactFromTargets({
92
+ targets: installableTargets,
93
+ workspaceRoot: base,
94
+ sanitizedName,
95
+ scope: ws.scope,
96
+ change: "removed",
97
+ workspaceTargets: [
98
+ {
99
+ path: ws.scope === "project" ? "axm.json" : ".axm/workspace/axm.json",
100
+ change: "updated",
101
+ },
102
+ ],
103
+ }).pipe(Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path));
104
+ return {
105
+ result: "success",
106
+ message: `Disabled ${op.args.skillName}`,
107
+ artifact,
108
+ };
109
+ }).pipe(withAdaptedStepFailures);
110
+ //# sourceMappingURL=disable.js.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Enable skill executor — re-creates agent symlinks for a previously disabled skill.
3
+ *
4
+ * Enabling requires desired canonical content aligned with its accepted
5
+ * external resolution when one is required.
6
+ *
7
+ * @experimental This API is unstable and may change without notice.
8
+ */
9
+ import * as FileSystem from "effect/FileSystem";
10
+ import * as Path from "effect/Path";
11
+ import { LifecycleFailureAdapter } from "../../failure-adapter.js";
12
+ import type { OperationHandler } from "@agentxm/workspace-operations";
13
+ import type { Operation } from "@agentxm/workspace-operations";
14
+ import { WorkspaceMutations } from "@agentxm/workspace-state";
15
+ /**
16
+ * Enable a previously disabled skill (re-install files and update state).
17
+ *
18
+ * @experimental This API is unstable and may change without notice.
19
+ */
20
+ export type EnableSkillOperation = Operation<"enable-skill", {
21
+ readonly skillName: string;
22
+ }>;
23
+ /**
24
+ * Enable-skill operation handler.
25
+ *
26
+ * 1. Resolve usable canonical content from desired state, accepted resolution, and observation.
27
+ * 2. Create agent artifacts.
28
+ * 3. Update settings to set enabled: true.
29
+ */
30
+ export declare const enableSkill: OperationHandler<EnableSkillOperation, FileSystem.FileSystem | Path.Path | WorkspaceMutations | LifecycleFailureAdapter>;
31
+ //# sourceMappingURL=enable.d.ts.map
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Enable skill executor — re-creates agent symlinks for a previously disabled skill.
3
+ *
4
+ * Enabling requires desired canonical content aligned with its accepted
5
+ * external resolution when one is required.
6
+ *
7
+ * @experimental This API is unstable and may change without notice.
8
+ */
9
+ import * as FileSystem from "effect/FileSystem";
10
+ import * as Path from "effect/Path";
11
+ import * as Effect from "effect/Effect";
12
+ import * as Option from "effect/Option";
13
+ import * as Layer from "effect/Layer";
14
+ import { DefaultCodingAgentRepository } from "@agentxm/extension-workspace";
15
+ import { ExtensionLifecycleFailed } from "../../errors.js";
16
+ import { LifecycleFailureAdapter, withAdaptedStepFailures } from "../../failure-adapter.js";
17
+ import { WorkspaceMutations } from "@agentxm/workspace-state";
18
+ import { sanitizeName } from "@agentxm/workspace-state";
19
+ import { ensureSkillAgentArtifact } from "../materialization.js";
20
+ import { skillArtifactFromTargets, } from "@agentxm/extension-workspace";
21
+ import { usableAcceptedCanonicalObservation } from "@agentxm/workspace-state";
22
+ // -----------------------------------------------------------------------------
23
+ // Public API
24
+ // -----------------------------------------------------------------------------
25
+ /**
26
+ * Enable-skill operation handler.
27
+ *
28
+ * 1. Resolve usable canonical content from desired state, accepted resolution, and observation.
29
+ * 2. Create agent artifacts.
30
+ * 3. Update settings to set enabled: true.
31
+ */
32
+ export const enableSkill = (op) => Effect.gen(function* () {
33
+ const fs = yield* FileSystem.FileSystem;
34
+ const path = yield* Path.Path;
35
+ const ws = yield* WorkspaceMutations;
36
+ const base = ws.baseDir;
37
+ const fsPathLayer = Layer.mergeAll(Layer.succeed(FileSystem.FileSystem, fs), Layer.succeed(Path.Path, path));
38
+ const provide = (effect) => Effect.provide(effect, fsPathLayer);
39
+ const canonical = yield* usableAcceptedCanonicalObservation({
40
+ workspace: ws,
41
+ type: "skill",
42
+ name: op.args.skillName,
43
+ });
44
+ if (Option.isNone(canonical)) {
45
+ return yield* new ExtensionLifecycleFailed({
46
+ category: "not_found",
47
+ detail: `Accepted skill content for "${op.args.skillName}" is not usable`,
48
+ suggestions: [
49
+ {
50
+ description: "Try reinstalling the skill.",
51
+ cmd: "axm skills install <source>",
52
+ },
53
+ ],
54
+ });
55
+ }
56
+ const sanitizedName = sanitizeName(op.args.skillName);
57
+ const materializationAgents = yield* DefaultCodingAgentRepository.getMaterializationAgents().pipe(Effect.provideService(WorkspaceMutations, ws));
58
+ const skillSrcPath = canonical.value.observation.path;
59
+ const installableTargets = yield* ws.runTransaction({
60
+ transition: Effect.gen(function* () {
61
+ const resolvedTargets = yield* Effect.forEach(materializationAgents, (agent) => agent.resolveEffectiveSkillsDir({ workspaceRoot: base }).pipe(Effect.provide(fsPathLayer), Effect.map((outcome) => ({ agent, outcome }))), { concurrency: "unbounded" });
62
+ const targets = resolvedTargets.flatMap(({ agent, outcome }) => outcome._tag === "supported"
63
+ ? [{ agentId: agent.id, targetDir: path.normalize(outcome.dir) }]
64
+ : []);
65
+ const locations = new Map();
66
+ for (const target of targets) {
67
+ const current = locations.get(target.targetDir);
68
+ if (current === undefined) {
69
+ locations.set(target.targetDir, {
70
+ targetDir: target.targetDir,
71
+ agentIds: [target.agentId],
72
+ });
73
+ }
74
+ else if (!current.agentIds.includes(target.agentId)) {
75
+ current.agentIds.push(target.agentId);
76
+ }
77
+ }
78
+ yield* Effect.forEach([...locations.values()], (location) => ensureSkillAgentArtifact({
79
+ canonicalSkillSrcPath: skillSrcPath,
80
+ targetDir: location.targetDir,
81
+ sanitizedName,
82
+ pathService: path,
83
+ baseDir: base,
84
+ provide,
85
+ }), { concurrency: "unbounded" });
86
+ yield* ws.updateSkillEntry(op.args.skillName, (entry) => ({
87
+ ...entry,
88
+ enabled: true,
89
+ }));
90
+ return targets;
91
+ }).pipe(Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path)),
92
+ validate: () => Effect.void,
93
+ });
94
+ const artifact = yield* skillArtifactFromTargets({
95
+ targets: installableTargets,
96
+ workspaceRoot: base,
97
+ sanitizedName,
98
+ scope: ws.scope,
99
+ change: "created",
100
+ workspaceTargets: [
101
+ {
102
+ path: ws.scope === "project" ? "axm.json" : ".axm/workspace/axm.json",
103
+ change: "updated",
104
+ },
105
+ ],
106
+ }).pipe(Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path));
107
+ return {
108
+ result: "success",
109
+ message: `Enabled ${op.args.skillName}`,
110
+ artifact,
111
+ };
112
+ }).pipe(withAdaptedStepFailures);
113
+ //# sourceMappingURL=enable.js.map
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Structured per-agent installation result.
3
+ *
4
+ * Captures the outcome of installing a skill for a single agent,
5
+ * including success/failure state and symlink fallback information.
6
+ *
7
+ * @experimental This API is unstable and may change without notice.
8
+ */
9
+ import type * as Option from "effect/Option";
10
+ /**
11
+ * Result of installing a skill for a single agent.
12
+ *
13
+ * - `success: true, mode: "symlink"` — installed via symlink
14
+ * - `success: true, mode: "copy"` — symlink failed, fell back to copy
15
+ * - `success: false` — installation failed
16
+ */
17
+ export interface InstallResult {
18
+ /** Whether the installation succeeded for this agent. */
19
+ readonly success: boolean;
20
+ /** Installation mode used ("symlink" or "copy"). */
21
+ readonly mode: "symlink" | "copy";
22
+ /** Whether symlink creation was attempted and failed (triggering copy fallback). */
23
+ readonly symlinkFailed: boolean;
24
+ /** Error message if installation failed. */
25
+ readonly error: Option.Option<string>;
26
+ /** Agent-specific skill directory path. */
27
+ readonly path: string;
28
+ /** Exact source-qualified canonical skill location. */
29
+ readonly canonicalPath: string;
30
+ /** User-visible change at the agent-specific skill path. */
31
+ readonly change?: "created" | "updated" | "unchanged";
32
+ }
33
+ //# sourceMappingURL=install-result.d.ts.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Structured per-agent installation result.
3
+ *
4
+ * Captures the outcome of installing a skill for a single agent,
5
+ * including success/failure state and symlink fallback information.
6
+ *
7
+ * @experimental This API is unstable and may change without notice.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=install-result.js.map
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Install skill executor — orchestrates the full per-skill installation pipeline.
3
+ *
4
+ * Dispatches to a per-refType install function via `switch(ref.refType)`, then
5
+ * runs shared post-install steps (agent symlinks, lockfile/settings writes).
6
+ *
7
+ * @experimental This API is unstable and may change without notice.
8
+ */
9
+ import * as FileSystem from "effect/FileSystem";
10
+ import type * as HttpClient from "effect/unstable/http/HttpClient";
11
+ import * as Path from "effect/Path";
12
+ import * as Option from "effect/Option";
13
+ import type { AgentId } from "@agentxm/extension-model/unstable/agents/types";
14
+ import { type RenderedFilesMap } from "@agentxm/workspace-state";
15
+ import type { SkillExtensionRef } from "@agentxm/extension-model/unstable/extensions/refs/skill";
16
+ import { SourceHostProviders } from "@agentxm/extension-sources";
17
+ import { CodingAgentRepository } from "@agentxm/extension-workspace";
18
+ import { LifecycleFailureAdapter } from "../../failure-adapter.js";
19
+ import type { OperationHandler } from "@agentxm/workspace-operations";
20
+ import type { Operation } from "@agentxm/workspace-operations";
21
+ import type { JobStepArtifactSource } from "@agentxm/workspace-operations";
22
+ import { WorkspaceMutations } from "@agentxm/workspace-state";
23
+ import type { InstallResult } from "./install-result.js";
24
+ /**
25
+ * Args for the install-skill operation.
26
+ */
27
+ export type InstallSkillOperationArgs = {
28
+ readonly ref: SkillExtensionRef;
29
+ readonly force: boolean;
30
+ /** Version constraint from the original input when available. */
31
+ readonly versionRange: Option.Option<string>;
32
+ /** When true, write to lockfile only (skip settings). Used for pack dependencies. */
33
+ readonly skipSettings: Option.Option<boolean>;
34
+ /** When true, fail on unknown configured agents instead of warning+skip. */
35
+ readonly strictUnknownAgents: Option.Option<boolean>;
36
+ /** Named registry source that provided the ref (written to lockfile for registry skills). */
37
+ readonly sourceName: Option.Option<string>;
38
+ };
39
+ /**
40
+ * Add a skill to the workspace.
41
+ *
42
+ * @experimental This API is unstable and may change without notice.
43
+ */
44
+ export type InstallSkillOperation = Operation<"install-skill", InstallSkillOperationArgs>;
45
+ export declare const gitHostedSkillArtifactSource: (ref: SkillExtensionRef) => JobStepArtifactSource | undefined;
46
+ export { computeSkillSourceHash } from "./source-hash.js";
47
+ /**
48
+ * Build a RenderedFilesMap from per-agent copy-mode install results.
49
+ * Only includes agents where mode === "copy" and success === true.
50
+ *
51
+ * @internal Exported for testing only.
52
+ */
53
+ export declare const buildRenderedFilesFromResults: (installableTargets: ReadonlyArray<{
54
+ agentId: AgentId;
55
+ targetDir: string;
56
+ }>, agentResults: ReadonlyArray<InstallResult>, toWorkspaceRelativePath: (path: string) => string) => RenderedFilesMap;
57
+ /**
58
+ * Install-skill operation handler.
59
+ *
60
+ * Dispatches to a per-refType install function producing a MaterializedSkill,
61
+ * then runs shared post-install steps:
62
+ * 1. Create symlinks from each agent's skills dir (concurrent)
63
+ * 2. Update lockfile/settings entry (failures logged as warnings)
64
+ * 3. Compute and return overall result
65
+ */
66
+ export declare const installSkill: OperationHandler<InstallSkillOperation, FileSystem.FileSystem | HttpClient.HttpClient | Path.Path | WorkspaceMutations | SourceHostProviders | CodingAgentRepository | LifecycleFailureAdapter>;
67
+ //# sourceMappingURL=install.d.ts.map