@agentxm/extension-lifecycle 0.28.11 → 0.28.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.
Files changed (207) hide show
  1. package/dist/src/activation/display-paths.d.ts +25 -0
  2. package/dist/src/activation/display-paths.js +25 -0
  3. package/dist/src/activation/errors.d.ts +16 -0
  4. package/dist/src/activation/errors.js +7 -0
  5. package/dist/src/activation/set-activation.d.ts +134 -0
  6. package/dist/src/activation/set-activation.js +772 -0
  7. package/dist/src/demote/demote-to-external-source.d.ts +82 -0
  8. package/dist/src/demote/demote-to-external-source.js +233 -0
  9. package/dist/src/errors.d.ts +0 -8
  10. package/dist/src/errors.js +0 -8
  11. package/dist/src/glob.d.ts +35 -0
  12. package/dist/src/glob.js +75 -0
  13. package/dist/src/hooks/configured-agent-outcomes-provider.d.ts +7 -3
  14. package/dist/src/hooks/configured-agent-outcomes-provider.js +11 -4
  15. package/dist/src/hooks/install/plan.d.ts +45 -0
  16. package/dist/src/hooks/install/plan.js +224 -0
  17. package/dist/src/hooks/uninstall/plan.d.ts +20 -0
  18. package/dist/src/hooks/uninstall/plan.js +77 -0
  19. package/dist/src/index.d.ts +48 -16
  20. package/dist/src/index.js +60 -17
  21. package/dist/src/install/aggregate-projection-step.d.ts +16 -0
  22. package/dist/src/install/aggregate-projection-step.js +49 -0
  23. package/dist/src/install/configured.d.ts +65 -0
  24. package/dist/src/install/configured.js +406 -0
  25. package/dist/src/install/inline-mcp-operation.d.ts +4 -0
  26. package/dist/src/install/inline-mcp-operation.js +25 -0
  27. package/dist/src/install/install-extensions.d.ts +110 -0
  28. package/dist/src/install/install-extensions.js +282 -0
  29. package/dist/src/install/per-type-install.d.ts +12 -0
  30. package/dist/src/install/per-type-install.js +12 -0
  31. package/dist/src/install/registry-install-target.d.ts +35 -0
  32. package/dist/src/install/registry-install-target.js +66 -0
  33. package/dist/src/install/registry-login-suggestion.d.ts +21 -0
  34. package/dist/src/install/registry-login-suggestion.js +34 -0
  35. package/dist/src/install/registry-source-resolution.d.ts +54 -0
  36. package/dist/src/install/registry-source-resolution.js +216 -0
  37. package/dist/src/install/root-intent.d.ts +19 -0
  38. package/dist/src/install/root-intent.js +122 -0
  39. package/dist/src/install/selection-interaction.d.ts +46 -0
  40. package/dist/src/install/selection-interaction.js +22 -0
  41. package/dist/src/install/vocabulary.d.ts +143 -0
  42. package/dist/src/install/vocabulary.js +29 -0
  43. package/dist/src/knowledge/install/plan.d.ts +35 -0
  44. package/dist/src/knowledge/install/plan.js +128 -0
  45. package/dist/src/knowledge/uninstall/plan.d.ts +23 -0
  46. package/dist/src/knowledge/uninstall/plan.js +140 -0
  47. package/dist/src/live.d.ts +4 -11
  48. package/dist/src/live.js +4 -11
  49. package/dist/src/mcps/install/plan.d.ts +65 -0
  50. package/dist/src/mcps/install/plan.js +301 -0
  51. package/dist/src/mcps/operations/disable.d.ts +5 -3
  52. package/dist/src/mcps/operations/disable.js +6 -4
  53. package/dist/src/mcps/operations/enable.d.ts +5 -3
  54. package/dist/src/mcps/operations/enable.js +8 -6
  55. package/dist/src/mcps/operations/sync-outcome.d.ts +1 -1
  56. package/dist/src/mcps/operations/uninstall.d.ts +5 -3
  57. package/dist/src/mcps/operations/uninstall.js +4 -4
  58. package/dist/src/mcps/uninstall/plan.d.ts +24 -0
  59. package/dist/src/mcps/uninstall/plan.js +109 -0
  60. package/dist/src/packs/artifact.d.ts +21 -0
  61. package/dist/src/packs/artifact.js +32 -0
  62. package/dist/src/packs/constraint-gate.d.ts +30 -0
  63. package/dist/src/packs/constraint-gate.js +76 -0
  64. package/dist/src/packs/expansion.d.ts +13 -14
  65. package/dist/src/packs/expansion.js +1 -2
  66. package/dist/src/packs/graph-transition.d.ts +64 -0
  67. package/dist/src/packs/graph-transition.js +219 -0
  68. package/dist/src/packs/install/plan.d.ts +95 -0
  69. package/dist/src/packs/install/plan.js +845 -0
  70. package/dist/src/packs/member-install-step.d.ts +29 -0
  71. package/dist/src/packs/member-install-step.js +156 -0
  72. package/dist/src/packs/operations/install.d.ts +3 -3
  73. package/dist/src/packs/operations/install.js +5 -5
  74. package/dist/src/packs/promote-authored-pack.d.ts +86 -0
  75. package/dist/src/packs/promote-authored-pack.js +239 -0
  76. package/dist/src/packs/resolved-dependency.d.ts +9 -26
  77. package/dist/src/packs/resolved-dependency.js +8 -20
  78. package/dist/src/packs/uninstall/plan.d.ts +66 -0
  79. package/dist/src/packs/uninstall/plan.js +344 -0
  80. package/dist/src/packs/uninstall/readiness.d.ts +50 -0
  81. package/dist/src/packs/uninstall/readiness.js +130 -0
  82. package/dist/src/publisher-binding.d.ts +8 -40
  83. package/dist/src/publisher-binding.js +8 -46
  84. package/dist/src/rules/install/plan.d.ts +35 -0
  85. package/dist/src/rules/install/plan.js +133 -0
  86. package/dist/src/rules/uninstall/plan.d.ts +19 -0
  87. package/dist/src/rules/uninstall/plan.js +54 -0
  88. package/dist/src/skills/install/bundled.d.ts +73 -0
  89. package/dist/src/skills/install/bundled.js +244 -0
  90. package/dist/src/skills/install/plan.d.ts +72 -0
  91. package/dist/src/skills/install/plan.js +429 -0
  92. package/dist/src/skills/install/selection.d.ts +26 -0
  93. package/dist/src/skills/install/selection.js +41 -0
  94. package/dist/src/skills/install/source.d.ts +21 -0
  95. package/dist/src/skills/install/source.js +76 -0
  96. package/dist/src/skills/operations/disable.d.ts +3 -2
  97. package/dist/src/skills/operations/disable.js +7 -11
  98. package/dist/src/skills/operations/enable.d.ts +3 -2
  99. package/dist/src/skills/operations/enable.js +6 -8
  100. package/dist/src/skills/operations/install.d.ts +4 -4
  101. package/dist/src/skills/operations/install.js +13 -12
  102. package/dist/src/skills/uninstall/plan.d.ts +23 -0
  103. package/dist/src/skills/uninstall/plan.js +165 -0
  104. package/dist/src/skills/utils.js +1 -1
  105. package/dist/src/step-failure-conversion.d.ts +44 -0
  106. package/dist/src/step-failure-conversion.js +26 -0
  107. package/dist/src/step-failure.d.ts +29 -0
  108. package/dist/src/step-failure.js +130 -0
  109. package/dist/src/subagents/install/plan.d.ts +49 -0
  110. package/dist/src/subagents/install/plan.js +270 -0
  111. package/dist/src/subagents/install/selection.d.ts +26 -0
  112. package/dist/src/subagents/install/selection.js +37 -0
  113. package/dist/src/subagents/install/source.d.ts +18 -0
  114. package/dist/src/subagents/install/source.js +72 -0
  115. package/dist/src/subagents/operations/disable.d.ts +5 -3
  116. package/dist/src/subagents/operations/disable.js +5 -3
  117. package/dist/src/subagents/operations/enable.d.ts +5 -3
  118. package/dist/src/subagents/operations/enable.js +17 -12
  119. package/dist/src/subagents/uninstall/plan.d.ts +20 -0
  120. package/dist/src/subagents/uninstall/plan.js +142 -0
  121. package/dist/src/test-packages.d.ts +34 -0
  122. package/dist/src/test-packages.js +111 -0
  123. package/dist/src/test-registry.d.ts +78 -0
  124. package/dist/src/test-registry.js +223 -0
  125. package/dist/src/testing.d.ts +108 -0
  126. package/dist/src/testing.js +241 -0
  127. package/dist/src/uninstall/retention-policy.d.ts +21 -0
  128. package/dist/src/uninstall/retention-policy.js +28 -0
  129. package/dist/src/uninstall/root-intent.d.ts +17 -0
  130. package/dist/src/uninstall/root-intent.js +101 -0
  131. package/dist/src/uninstall/uninstall-extensions.d.ts +61 -0
  132. package/dist/src/uninstall/uninstall-extensions.js +127 -0
  133. package/dist/src/uninstall/vocabulary.d.ts +40 -0
  134. package/dist/src/uninstall/vocabulary.js +14 -0
  135. package/dist/src/update/atomicity.d.ts +22 -0
  136. package/dist/src/update/atomicity.js +23 -0
  137. package/dist/src/update/blockers.d.ts +31 -0
  138. package/dist/src/update/blockers.js +78 -0
  139. package/dist/src/update/configured.d.ts +78 -0
  140. package/dist/src/update/configured.js +546 -0
  141. package/dist/src/update/root-request.d.ts +39 -0
  142. package/dist/src/update/root-request.js +117 -0
  143. package/dist/src/update/selective/plan.d.ts +45 -0
  144. package/dist/src/update/selective/plan.js +61 -0
  145. package/dist/src/update/selective/requirements.d.ts +17 -0
  146. package/dist/src/update/selective/requirements.js +14 -0
  147. package/dist/src/update/selective/selection.d.ts +63 -0
  148. package/dist/src/update/selective/selection.js +85 -0
  149. package/dist/src/update/selective/skills.d.ts +55 -0
  150. package/dist/src/update/selective/skills.js +596 -0
  151. package/dist/src/update/selective/subagents.d.ts +52 -0
  152. package/dist/src/update/selective/subagents.js +331 -0
  153. package/dist/src/update/selective/use-case.d.ts +121 -0
  154. package/dist/src/update/selective/use-case.js +28 -0
  155. package/dist/src/update/selective/vocabulary.d.ts +43 -0
  156. package/dist/src/update/selective/vocabulary.js +28 -0
  157. package/dist/src/update/selector.d.ts +72 -0
  158. package/dist/src/update/selector.js +120 -0
  159. package/dist/src/update/targeted-plan.d.ts +30 -0
  160. package/dist/src/update/targeted-plan.js +113 -0
  161. package/dist/src/update/update-extensions.d.ts +164 -0
  162. package/dist/src/update/update-extensions.js +579 -0
  163. package/dist/src/workspace-paths.d.ts +31 -0
  164. package/dist/src/workspace-paths.js +46 -0
  165. package/package.json +22 -12
  166. package/dist/src/configured-entry-resolution.d.ts +0 -111
  167. package/dist/src/configured-entry-resolution.js +0 -731
  168. package/dist/src/failure-adapter.d.ts +0 -35
  169. package/dist/src/failure-adapter.js +0 -23
  170. package/dist/src/hooks/manager.d.ts +0 -15
  171. package/dist/src/hooks/manager.js +0 -769
  172. package/dist/src/internal/fs-helpers.d.ts +0 -12
  173. package/dist/src/internal/fs-helpers.js +0 -13
  174. package/dist/src/internal/integrity.d.ts +0 -13
  175. package/dist/src/internal/integrity.js +0 -17
  176. package/dist/src/knowledge/manager.d.ts +0 -11
  177. package/dist/src/knowledge/manager.js +0 -711
  178. package/dist/src/mcps/manager.d.ts +0 -16
  179. package/dist/src/mcps/manager.js +0 -247
  180. package/dist/src/mcps/operations/artifact.d.ts +0 -24
  181. package/dist/src/mcps/operations/artifact.js +0 -74
  182. package/dist/src/mcps/operations/install.d.ts +0 -78
  183. package/dist/src/mcps/operations/install.js +0 -596
  184. package/dist/src/packs/dependency-resolution.d.ts +0 -65
  185. package/dist/src/packs/dependency-resolution.js +0 -414
  186. package/dist/src/packs/manager.d.ts +0 -16
  187. package/dist/src/packs/manager.js +0 -181
  188. package/dist/src/registry-materialization.d.ts +0 -52
  189. package/dist/src/registry-materialization.js +0 -72
  190. package/dist/src/release-age-posture.d.ts +0 -23
  191. package/dist/src/release-age-posture.js +0 -15
  192. package/dist/src/resolution-timeout.d.ts +0 -5
  193. package/dist/src/resolution-timeout.js +0 -11
  194. package/dist/src/rules/manager.d.ts +0 -20
  195. package/dist/src/rules/manager.js +0 -480
  196. package/dist/src/skills/manager.d.ts +0 -18
  197. package/dist/src/skills/manager.js +0 -346
  198. package/dist/src/skills/materialization.d.ts +0 -54
  199. package/dist/src/skills/materialization.js +0 -158
  200. package/dist/src/skills/operations/source-hash.d.ts +0 -2
  201. package/dist/src/skills/operations/source-hash.js +0 -6
  202. package/dist/src/subagents/manager.d.ts +0 -18
  203. package/dist/src/subagents/manager.js +0 -722
  204. package/dist/src/workflows/install-command/workflow.d.ts +0 -56
  205. package/dist/src/workflows/install-command/workflow.js +0 -46
  206. package/dist/src/workflows/uninstall-command/workflow.d.ts +0 -42
  207. package/dist/src/workflows/uninstall-command/workflow.js +0 -29
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Returning a workspace-authored package to an external source.
3
+ *
4
+ * Demotion is the one transition that deliberately gives up workspace source
5
+ * authority: the authored package stops being the thing the workspace edits
6
+ * and becomes a package the workspace acquires again from a Registry, Git, or
7
+ * local source. Because that replaces content a person wrote, it is a
8
+ * confirmable risk rather than an ordinary install, the replacement is refused
9
+ * unless the target really is workspace-sourced and the replacement source
10
+ * really is external, and an entry that was disabled stays disabled once the
11
+ * external package is in place.
12
+ *
13
+ * `prepare` settles all of that and writes nothing. `previewOrApply` resolves
14
+ * the same candidate, so the preview a person reads and the apply that follows
15
+ * describe one decision.
16
+ *
17
+ * @experimental This API is unstable and may change without notice.
18
+ */
19
+ import * as Effect from "effect/Effect";
20
+ import * as FileSystem from "effect/FileSystem";
21
+ import * as Path from "effect/Path";
22
+ import { ExtensionManagers } from "@agentxm/extension-materialization";
23
+ import { type ExtensionType } from "@agentxm/extension-model/unstable/extensions";
24
+ import { type ExecutionCandidate, type PlanExecution } from "@agentxm/workspace-operations";
25
+ import { WorkspaceMutations, type WorkspaceSettingsReadFailure } from "@agentxm/workspace-state";
26
+ import { ExtensionLifecycleFailed } from "../errors.js";
27
+ import type { InstallStepRequirements } from "../install/vocabulary.js";
28
+ /** What a person named: the authored package, and the source that replaces it. */
29
+ export interface DemoteRequest {
30
+ /** Owner-qualified identity of the workspace-authored package. */
31
+ readonly fqn: string;
32
+ /** The Registry, Git, or local source the package is acquired from next. */
33
+ readonly source: string;
34
+ }
35
+ /** The risk a demotion declares, which advance approval may satisfy. */
36
+ export declare const DEMOTE_RISK_CONDITION_ID = "replace-workspace-authority";
37
+ /** Everything a demotion step may require when it runs. */
38
+ export type DemoteRequirements = InstallStepRequirements;
39
+ /**
40
+ * A settled demotion: the replacement is resolved, the refusals are past, and
41
+ * nothing is written. The identity fields answer what the application renders
42
+ * around the frozen candidate.
43
+ */
44
+ export interface DemoteCandidate {
45
+ readonly type: ExtensionType;
46
+ readonly name: string;
47
+ /** Owner-qualified identity of the package being demoted. */
48
+ readonly fqn: string;
49
+ /** Workspace-relative authored directory the apply removes. */
50
+ readonly authoredPath: string;
51
+ readonly execution: ExecutionCandidate<DemoteRequirements>;
52
+ }
53
+ /**
54
+ * Every failure settling a demotion can surface before anything is written:
55
+ * the feature's own refusals, the identity grammar, and whatever resolving
56
+ * the replacement against its source surfaced.
57
+ */
58
+ export type DemoteFailure = Effect.Error<ReturnType<typeof settleDemotion>>;
59
+ /** Everything settling a demotion reads before it freezes a candidate. */
60
+ export type PrepareDemoteRequirements = Effect.Services<ReturnType<typeof settleDemotion>>;
61
+ /**
62
+ * Settle a demotion: parse the identity, refuse a replacement that is not
63
+ * external or a target that is not workspace-authored, resolve the
64
+ * replacement package, and freeze the execution candidate.
65
+ */
66
+ declare const settleDemotion: (request: DemoteRequest) => Effect.Effect<{
67
+ type: "mcp-server" | "skill" | "subagent" | "rule" | "hook" | "knowledge" | "pack";
68
+ name: string & import("effect/Brand").Brand<"ExtensionName">;
69
+ fqn: string;
70
+ authoredPath: string;
71
+ execution: ExecutionCandidate<InstallStepRequirements, never>;
72
+ }, ExtensionLifecycleFailed | import("@agentxm/workspace-state").PathTraversalDetected | import("@agentxm/extension-sources").SourceSyntaxInvalid | import("@agentxm/extension-sources").SourceHostNotConfigured | import("@agentxm/extension-sources").SourceNotResolvable | import("@agentxm/extension-sources").SourceNetworkFailure | import("@agentxm/extension-sources").GitOperationFailed | import("@agentxm/extension-sources").WorkspaceCatalogUnavailable | import("@agentxm/extension-sources").AxmSkillGateUnavailable | import("@agentxm/registry-client").RegistryProblem | import("@agentxm/registry-client").RegistryRequestFailed | import("@agentxm/registry-client").RegistryOperationFailed | import("@agentxm/workspace-state").LockfileIoError | import("@agentxm/workspace-state").LockfileParseError | import("@agentxm/workspace-state").LockfileDecodeError | import("@agentxm/workspace-state").LockfileVersionUnsupported | WorkspaceSettingsReadFailure | import("@agentxm/workspace-state").LockfileValidationError | import("@agentxm/workspace-state").LockEntrySourceMissing | import("@agentxm/workspace-state").LockEntryUrlInvalid | import("@agentxm/workspace-state").LockEntryNameInvalid | import("@agentxm/workspace-state").LockEntryEndpointConflict | import("@agentxm/workspace-state").LockEntrySourceTypeConflict | import("@agentxm/workspace-state").AcceptedResolutionMissing | import("@agentxm/workspace-state").InlineExtensionSourceMissing | import("@agentxm/workspace-state").PackageContentHashFailed | import("@agentxm/workspace-state").WorkspaceSourceInvalid | import("@agentxm/extension-model/unstable/extensions").FqnInvalidError | import("@agentxm/extension-resolution").ExtensionResolutionFailed | import("@agentxm/workspace-operations").CandidateFingerprintFailed, FileSystem.FileSystem | Path.Path | WorkspaceMutations | import("@agentxm/workspace-state").ConfiguredAgentOutcomesProvider | ExtensionManagers | import("effect/unstable/http/HttpClient").HttpClient | import("@agentxm/extension-resolution").ReleaseAgePosture | import("effect/Scope").Scope | import("@agentxm/extension-sources").SourceHostProviders | import("@agentxm/extension-sources").WorkspaceCatalog>;
73
+ export declare const prepareDemote: (request: DemoteRequest) => Effect.Effect<DemoteCandidate, DemoteFailure, PrepareDemoteRequirements>;
74
+ /** Preview or apply a settled demotion, resolving to one operation outcome. */
75
+ export declare const previewOrApplyDemote: (candidate: DemoteCandidate, execution: PlanExecution) => Effect.Effect<import("@agentxm/workspace-operations").OperationResolution<never>, WorkspaceSettingsReadFailure | import("@agentxm/workspace-operations").ApprovalRecoveryMissing | import("@agentxm/workspace-operations").PlanInteractionFailed | import("@agentxm/workspace-transactions").WorkspaceTransitionAcquireFailure, import("@agentxm/workspace-state").ConfiguredAgentOutcomesProvider | import("@agentxm/workspace-transactions").FootprintRecorder | import("@agentxm/workspace-operations").OperationJournal | import("@agentxm/workspace-operations").ResolvePlanInteraction | InstallStepRequirements>;
76
+ /** The demotion use case: settle a request, then preview or apply it. */
77
+ export declare const DemoteToExternalSource: {
78
+ readonly prepare: (request: DemoteRequest) => Effect.Effect<DemoteCandidate, DemoteFailure, PrepareDemoteRequirements>;
79
+ readonly previewOrApply: (candidate: DemoteCandidate, execution: PlanExecution) => Effect.Effect<import("@agentxm/workspace-operations").OperationResolution<never>, WorkspaceSettingsReadFailure | import("@agentxm/workspace-operations").ApprovalRecoveryMissing | import("@agentxm/workspace-operations").PlanInteractionFailed | import("@agentxm/workspace-transactions").WorkspaceTransitionAcquireFailure, import("@agentxm/workspace-state").ConfiguredAgentOutcomesProvider | import("@agentxm/workspace-transactions").FootprintRecorder | import("@agentxm/workspace-operations").OperationJournal | import("@agentxm/workspace-operations").ResolvePlanInteraction | InstallStepRequirements>;
80
+ };
81
+ export {};
82
+ //# sourceMappingURL=demote-to-external-source.d.ts.map
@@ -0,0 +1,233 @@
1
+ /**
2
+ * Returning a workspace-authored package to an external source.
3
+ *
4
+ * Demotion is the one transition that deliberately gives up workspace source
5
+ * authority: the authored package stops being the thing the workspace edits
6
+ * and becomes a package the workspace acquires again from a Registry, Git, or
7
+ * local source. Because that replaces content a person wrote, it is a
8
+ * confirmable risk rather than an ordinary install, the replacement is refused
9
+ * unless the target really is workspace-sourced and the replacement source
10
+ * really is external, and an entry that was disabled stays disabled once the
11
+ * external package is in place.
12
+ *
13
+ * `prepare` settles all of that and writes nothing. `previewOrApply` resolves
14
+ * the same candidate, so the preview a person reads and the apply that follows
15
+ * describe one decision.
16
+ *
17
+ * @experimental This API is unstable and may change without notice.
18
+ */
19
+ import * as Effect from "effect/Effect";
20
+ import * as FileSystem from "effect/FileSystem";
21
+ import * as Option from "effect/Option";
22
+ import * as Path from "effect/Path";
23
+ import { ExtensionManagers, buildInstallOperation } from "@agentxm/extension-materialization";
24
+ import { formatFqn, parseFqn, } from "@agentxm/extension-model/unstable/extensions";
25
+ import { isWorkspaceSourceLocator } from "@agentxm/extension-model/unstable/sources/workspace";
26
+ import { makeConfiguredReleaseAgeEvaluation, resolveConfiguredHook, resolveConfiguredKnowledge, resolveConfiguredMcpServer, resolveConfiguredPack, resolveConfiguredRule, resolveConfiguredSkill, resolveConfiguredSubagent, } from "@agentxm/extension-resolution";
27
+ import { operationPresentation, prepareExecutionCandidate, resolveExecutionCandidate, } from "@agentxm/workspace-operations";
28
+ import { WorkspaceMutations, } from "@agentxm/workspace-state";
29
+ import { ExtensionLifecycleFailed } from "../errors.js";
30
+ import { lifecycleStepFailure } from "../step-failure.js";
31
+ /** The risk a demotion declares, which advance approval may satisfy. */
32
+ export const DEMOTE_RISK_CONDITION_ID = "replace-workspace-authority";
33
+ // -----------------------------------------------------------------------------
34
+ // Configured entry facts
35
+ // -----------------------------------------------------------------------------
36
+ /** The configured declaration a demotion replaces, as settings recorded it. */
37
+ const configuredEntry = (ws, type, name) => {
38
+ switch (type) {
39
+ case "skill":
40
+ return ws.getConfiguredSkillEntries().pipe(Effect.map((entries) => entries[name]));
41
+ case "mcp-server":
42
+ return ws.getConfiguredMcpServerEntries().pipe(Effect.map((entries) => entries[name]));
43
+ case "subagent":
44
+ return ws.getConfiguredSubagentEntries().pipe(Effect.map((entries) => entries[name]));
45
+ case "rule":
46
+ return ws.getConfiguredRuleEntries().pipe(Effect.map((entries) => entries[name]));
47
+ case "hook":
48
+ return ws.getConfiguredHookEntries().pipe(Effect.map((entries) => entries[name]));
49
+ case "knowledge":
50
+ return ws.getConfiguredKnowledgeEntries().pipe(Effect.map((entries) => entries[name]));
51
+ case "pack":
52
+ return ws.getConfiguredPackEntries().pipe(Effect.map((entries) => entries[name]));
53
+ }
54
+ };
55
+ const entrySource = (entry) => {
56
+ if (typeof entry === "string")
57
+ return entry;
58
+ if (typeof entry !== "object" || entry === null || !("source" in entry))
59
+ return undefined;
60
+ return typeof entry.source === "string" ? entry.source : undefined;
61
+ };
62
+ const entryDisabled = (entry) => typeof entry === "object" && entry !== null && "enabled" in entry && entry.enabled === false;
63
+ const restoreDisabledState = (ws, type, name) => {
64
+ const disable = (entry) => ({
65
+ ...entry,
66
+ enabled: false,
67
+ });
68
+ switch (type) {
69
+ case "skill":
70
+ return ws.updateSkillEntry(name, disable);
71
+ case "mcp-server":
72
+ return ws.updateMcpServerEntry(name, disable);
73
+ case "subagent":
74
+ return ws.updateSubagentEntry(name, disable);
75
+ case "rule":
76
+ return ws.updateRuleEntry(name, disable);
77
+ case "hook":
78
+ return ws.updateHookEntry(name, disable);
79
+ case "knowledge":
80
+ return ws.updateKnowledgeEntry(name, disable);
81
+ // A Pack declaration carries no activation of its own; its members do.
82
+ case "pack":
83
+ return Effect.void;
84
+ }
85
+ };
86
+ // -----------------------------------------------------------------------------
87
+ // The replacement step
88
+ // -----------------------------------------------------------------------------
89
+ /**
90
+ * Resolve the replacement package from its new source and compose the install
91
+ * that replaces the authored content. `allowWorkspaceReplacement` is the one
92
+ * place source authority is deliberately overridden, and it is named here so
93
+ * no other route can reach it by accident.
94
+ */
95
+ const replacementStep = Effect.fn("Demote.replacementStep")(function* (type, name, source) {
96
+ const managers = yield* ExtensionManagers;
97
+ const evaluation = yield* makeConfiguredReleaseAgeEvaluation();
98
+ // The one place source authority is deliberately overridden.
99
+ const common = {
100
+ toStepFailure: lifecycleStepFailure,
101
+ allowWorkspaceReplacement: true,
102
+ };
103
+ switch (type) {
104
+ case "skill":
105
+ return buildInstallOperation(managers.skill, {
106
+ ...common,
107
+ ...(yield* resolveConfiguredSkill(name, source, evaluation)),
108
+ });
109
+ case "mcp-server":
110
+ return buildInstallOperation(managers["mcp-server"], {
111
+ ...common,
112
+ ...(yield* resolveConfiguredMcpServer(name, source, evaluation)),
113
+ });
114
+ case "subagent":
115
+ return buildInstallOperation(managers.subagent, {
116
+ ...common,
117
+ ...(yield* resolveConfiguredSubagent(name, source, evaluation)),
118
+ });
119
+ case "rule":
120
+ return buildInstallOperation(managers.rule, {
121
+ ...common,
122
+ ...(yield* resolveConfiguredRule(name, source, evaluation)),
123
+ });
124
+ case "hook":
125
+ return buildInstallOperation(managers.hook, {
126
+ ...common,
127
+ ...(yield* resolveConfiguredHook(name, source, evaluation)),
128
+ });
129
+ case "knowledge":
130
+ return buildInstallOperation(managers.knowledge, {
131
+ ...common,
132
+ ...(yield* resolveConfiguredKnowledge(name, source, evaluation)),
133
+ });
134
+ case "pack":
135
+ return buildInstallOperation(managers.pack, {
136
+ ...common,
137
+ ...(yield* resolveConfiguredPack(name, source, evaluation)),
138
+ });
139
+ }
140
+ });
141
+ // -----------------------------------------------------------------------------
142
+ // prepare
143
+ // -----------------------------------------------------------------------------
144
+ /**
145
+ * Settle a demotion: parse the identity, refuse a replacement that is not
146
+ * external or a target that is not workspace-authored, resolve the
147
+ * replacement package, and freeze the execution candidate.
148
+ */
149
+ const settleDemotion = Effect.fn("Demote.prepare")(function* (request) {
150
+ const ws = yield* WorkspaceMutations;
151
+ const path = yield* Path.Path;
152
+ const fs = yield* FileSystem.FileSystem;
153
+ const parsed = yield* Effect.fromResult(parseFqn(request.fqn));
154
+ if (isWorkspaceSourceLocator(request.source)) {
155
+ return yield* new ExtensionLifecycleFailed({
156
+ category: "usage",
157
+ detail: "Demotion target must be a registry, git, or local source",
158
+ });
159
+ }
160
+ const current = yield* configuredEntry(ws, parsed.type, parsed.name);
161
+ const currentSource = entrySource(current);
162
+ if (currentSource === undefined || !isWorkspaceSourceLocator(currentSource)) {
163
+ return yield* new ExtensionLifecycleFailed({
164
+ category: "conflict",
165
+ detail: `${formatFqn(parsed)} is not workspace-sourced`,
166
+ });
167
+ }
168
+ if (ws.layout.scope !== "project") {
169
+ return yield* new ExtensionLifecycleFailed({
170
+ category: "usage",
171
+ detail: "Demote requires project scope",
172
+ });
173
+ }
174
+ const authoredDir = path.join(ws.layout.authoredRoot(parsed.type), parsed.name);
175
+ const operation = yield* replacementStep(parsed.type, parsed.name, request.source);
176
+ const wasDisabled = entryDisabled(current);
177
+ const step = operation.readiness === "error"
178
+ ? operation
179
+ : {
180
+ readiness: "warn",
181
+ label: `Demote ${formatFqn(parsed)}`,
182
+ warnMessage: "Future updates may replace this package from its new source",
183
+ run: Effect.gen(function* () {
184
+ const result = yield* operation.run;
185
+ if (wasDisabled) {
186
+ yield* restoreDisabledState(ws, parsed.type, parsed.name).pipe(Effect.mapError(lifecycleStepFailure));
187
+ }
188
+ // The authored copy is what demotion gives up. Its absence is not
189
+ // a failure: the acquired package is already authoritative.
190
+ yield* fs
191
+ .remove(authoredDir, { recursive: true })
192
+ .pipe(Effect.catch(() => Effect.void));
193
+ return result;
194
+ }),
195
+ };
196
+ const plan = {
197
+ _tag: "Plan",
198
+ name: "Demote workspace extension",
199
+ description: Option.some("Remove workspace source protection; future updates may replace the package"),
200
+ presentation: operationPresentation({
201
+ imperative: "demote",
202
+ past: "Demoted",
203
+ gerund: "Demoting",
204
+ }),
205
+ jobs: [{ concurrency: 1, steps: [step] }],
206
+ riskConditions: [
207
+ {
208
+ level: "confirmable",
209
+ id: DEMOTE_RISK_CONDITION_ID,
210
+ detail: "The workspace-authored package will be replaced by an externally sourced package.",
211
+ },
212
+ ],
213
+ };
214
+ return {
215
+ type: parsed.type,
216
+ name: parsed.name,
217
+ fqn: formatFqn(parsed),
218
+ authoredPath: authoredDir,
219
+ execution: yield* prepareExecutionCandidate(plan),
220
+ };
221
+ });
222
+ export const prepareDemote = settleDemotion;
223
+ // -----------------------------------------------------------------------------
224
+ // previewOrApply
225
+ // -----------------------------------------------------------------------------
226
+ /** Preview or apply a settled demotion, resolving to one operation outcome. */
227
+ export const previewOrApplyDemote = (candidate, execution) => resolveExecutionCandidate(candidate.execution, execution);
228
+ /** The demotion use case: settle a request, then preview or apply it. */
229
+ export const DemoteToExternalSource = {
230
+ prepare: prepareDemote,
231
+ previewOrApply: previewOrApplyDemote,
232
+ };
233
+ //# sourceMappingURL=demote-to-external-source.js.map
@@ -6,7 +6,6 @@
6
6
  * @experimental This API is unstable and may change without notice.
7
7
  */
8
8
  import * as Schema from "effect/Schema";
9
- import { CoupledDependencyFailure } from "@agentxm/extension-workspace";
10
9
  declare const ExtensionLifecycleFailed_base: Schema.Class<ExtensionLifecycleFailed, Schema.TaggedStruct<"ExtensionLifecycleFailed", {
11
10
  readonly category: Schema.Literals<readonly ["conflict", "internal", "network", "not_found", "usage", "validation"]>;
12
11
  readonly title: Schema.optional<Schema.String>;
@@ -28,12 +27,5 @@ declare const ExtensionLifecycleFailed_base: Schema.Class<ExtensionLifecycleFail
28
27
  */
29
28
  export declare class ExtensionLifecycleFailed extends ExtensionLifecycleFailed_base {
30
29
  }
31
- /**
32
- * Carry a lifecycle dependency's failure opaquely through a kernel-typed
33
- * manager channel. The application boundary restores and converts the carried
34
- * failure, so rendering, exit codes, and machine output stay byte-identical
35
- * with the previous in-place conversion.
36
- */
37
- export declare const coupleLifecycleDependencyFailure: (failure: unknown) => CoupledDependencyFailure;
38
30
  export {};
39
31
  //# sourceMappingURL=errors.d.ts.map
@@ -6,7 +6,6 @@
6
6
  * @experimental This API is unstable and may change without notice.
7
7
  */
8
8
  import * as Schema from "effect/Schema";
9
- import { CoupledDependencyFailure } from "@agentxm/extension-workspace";
10
9
  const CarriedSuggestedActionSchema = Schema.Struct({
11
10
  description: Schema.String,
12
11
  cmd: Schema.optional(Schema.String),
@@ -35,11 +34,4 @@ export class ExtensionLifecycleFailed extends Schema.TaggedError()("ExtensionLif
35
34
  cause: Schema.optional(Schema.Unknown),
36
35
  }) {
37
36
  }
38
- /**
39
- * Carry a lifecycle dependency's failure opaquely through a kernel-typed
40
- * manager channel. The application boundary restores and converts the carried
41
- * failure, so rendering, exit codes, and machine output stay byte-identical
42
- * with the previous in-place conversion.
43
- */
44
- export const coupleLifecycleDependencyFailure = (failure) => new CoupledDependencyFailure({ failure });
45
37
  //# sourceMappingURL=errors.js.map
@@ -0,0 +1,35 @@
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
+ * @experimental This API is unstable and may change without notice.
8
+ */
9
+ /**
10
+ * Expand a glob pattern against a list of names.
11
+ *
12
+ * Only `*` wildcards are supported. All other characters (including `?`, `[`, `]`)
13
+ * are treated as literals. Matching is case-sensitive.
14
+ *
15
+ * @param pattern - The pattern to match (may contain `*`)
16
+ * @param names - Available names to match against
17
+ * @returns Matching names in their original order
18
+ */
19
+ export declare const expandGlob: (pattern: string, names: ReadonlyArray<string>) => ReadonlyArray<string>;
20
+ /**
21
+ * Expand multiple glob patterns against a list of skill names.
22
+ *
23
+ * Returns the union of all matches, deduplicated, preserving the original
24
+ * order of `names`.
25
+ *
26
+ * @param patterns - Patterns to match (may contain `*`)
27
+ * @param names - Available names to match against
28
+ * @returns Matching names in their original order, deduplicated
29
+ */
30
+ export declare const expandGlobs: (patterns: ReadonlyArray<string>, names: ReadonlyArray<string>) => ReadonlyArray<string>;
31
+ /**
32
+ * Returns true when an input should be treated as a glob pattern.
33
+ */
34
+ export declare const isGlobPattern: (input: string) => boolean;
35
+ //# sourceMappingURL=glob.d.ts.map
@@ -0,0 +1,75 @@
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
+ * @experimental This API is unstable and may change without notice.
8
+ */
9
+ /**
10
+ * Expand a glob pattern against a list of names.
11
+ *
12
+ * Only `*` wildcards are supported. All other characters (including `?`, `[`, `]`)
13
+ * are treated as literals. Matching is case-sensitive.
14
+ *
15
+ * @param pattern - The pattern to match (may contain `*`)
16
+ * @param names - Available names to match against
17
+ * @returns Matching names in their original order
18
+ */
19
+ export const expandGlob = (pattern, names) => {
20
+ const matches = (name) => {
21
+ let patternIndex = 0;
22
+ let nameIndex = 0;
23
+ let wildcardIndex = -1;
24
+ let wildcardNameIndex = 0;
25
+ while (nameIndex < name.length) {
26
+ const token = pattern[patternIndex];
27
+ if (token !== undefined && token !== "*" && token === name[nameIndex]) {
28
+ patternIndex += 1;
29
+ nameIndex += 1;
30
+ }
31
+ else if (token === "*") {
32
+ wildcardIndex = patternIndex;
33
+ wildcardNameIndex = nameIndex;
34
+ patternIndex += 1;
35
+ }
36
+ else if (wildcardIndex >= 0) {
37
+ patternIndex = wildcardIndex + 1;
38
+ wildcardNameIndex += 1;
39
+ nameIndex = wildcardNameIndex;
40
+ }
41
+ else {
42
+ return false;
43
+ }
44
+ }
45
+ while (pattern[patternIndex] === "*") {
46
+ patternIndex += 1;
47
+ }
48
+ return patternIndex === pattern.length;
49
+ };
50
+ return names.filter(matches);
51
+ };
52
+ /**
53
+ * Expand multiple glob patterns against a list of skill names.
54
+ *
55
+ * Returns the union of all matches, deduplicated, preserving the original
56
+ * order of `names`.
57
+ *
58
+ * @param patterns - Patterns to match (may contain `*`)
59
+ * @param names - Available names to match against
60
+ * @returns Matching names in their original order, deduplicated
61
+ */
62
+ export const expandGlobs = (patterns, names) => {
63
+ const matched = new Set();
64
+ for (const pattern of patterns) {
65
+ for (const name of expandGlob(pattern, names)) {
66
+ matched.add(name);
67
+ }
68
+ }
69
+ return names.filter((n) => matched.has(n));
70
+ };
71
+ /**
72
+ * Returns true when an input should be treated as a glob pattern.
73
+ */
74
+ export const isGlobPattern = (input) => input.includes("*");
75
+ //# sourceMappingURL=glob.js.map
@@ -10,9 +10,13 @@
10
10
  *
11
11
  * @experimental This API is unstable and may change without notice.
12
12
  */
13
+ import * as FileSystem from "effect/FileSystem";
13
14
  import * as Layer from "effect/Layer";
15
+ import * as Path from "effect/Path";
16
+ import * as HttpClient from "effect/unstable/http/HttpClient";
17
+ import { NativeWriteAuthority } from "@agentxm/agent-integration";
14
18
  import { ConfiguredAgentOutcomesProvider } from "@agentxm/workspace-state";
15
- import { LifecycleFailureAdapter } from "../failure-adapter.js";
16
- import { HookManager } from "@agentxm/extension-workspace";
17
- export declare const HookConfiguredAgentOutcomesProviderLive: Layer.Layer<ConfiguredAgentOutcomesProvider, never, LifecycleFailureAdapter | HookManager>;
19
+ import { StepFailureConversion } from "../step-failure-conversion.js";
20
+ import { HookManager } from "@agentxm/extension-materialization";
21
+ export declare const HookConfiguredAgentOutcomesProviderLive: Layer.Layer<ConfiguredAgentOutcomesProvider, never, StepFailureConversion | FileSystem.FileSystem | Path.Path | NativeWriteAuthority | HttpClient.HttpClient | HookManager>;
18
22
  //# sourceMappingURL=configured-agent-outcomes-provider.d.ts.map
@@ -11,20 +11,27 @@
11
11
  * @experimental This API is unstable and may change without notice.
12
12
  */
13
13
  import * as Effect from "effect/Effect";
14
+ import * as FileSystem from "effect/FileSystem";
14
15
  import * as Layer from "effect/Layer";
16
+ import * as Path from "effect/Path";
17
+ import * as HttpClient from "effect/unstable/http/HttpClient";
18
+ import { NativeWriteAuthority } from "@agentxm/agent-integration";
15
19
  import { ConfiguredAgentOutcomesProvider, ConfiguredAgentOutcomesUnavailable, } from "@agentxm/workspace-state";
16
- import { LifecycleFailureAdapter } from "../failure-adapter.js";
17
- import { HookManager } from "@agentxm/extension-workspace";
20
+ import { StepFailureConversion } from "../step-failure-conversion.js";
21
+ import { HookManager } from "@agentxm/extension-materialization";
18
22
  export const HookConfiguredAgentOutcomesProviderLive = Layer.effect(ConfiguredAgentOutcomesProvider, Effect.gen(function* () {
19
- const adapter = yield* LifecycleFailureAdapter;
23
+ const adapter = yield* StepFailureConversion;
20
24
  const hookManager = yield* HookManager;
25
+ // The provider's members answer with no requirements of their own, so this
26
+ // layer is the boundary that composes what the manager needs.
27
+ const managerLayer = Layer.mergeAll(Layer.succeed(FileSystem.FileSystem, yield* FileSystem.FileSystem), Layer.succeed(Path.Path, yield* Path.Path), Layer.succeed(HttpClient.HttpClient, yield* HttpClient.HttpClient), Layer.succeed(NativeWriteAuthority, yield* NativeWriteAuthority));
21
28
  const configuredAgentOutcomes = hookManager.configuredAgentOutcomes;
22
29
  if (configuredAgentOutcomes === undefined) {
23
30
  return { byExtensionType: {} };
24
31
  }
25
32
  return {
26
33
  byExtensionType: {
27
- hook: (state) => configuredAgentOutcomes(state).pipe(Effect.mapError((failure) => {
34
+ hook: (state) => configuredAgentOutcomes(state).pipe(Effect.provide(managerLayer), Effect.mapError((failure) => {
28
35
  const step = adapter.toStepFailure(failure);
29
36
  return new ConfiguredAgentOutcomesUnavailable({
30
37
  category: step.category,
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Installing hooks packages.
3
+ *
4
+ * A hook becomes observable through each agent's own hook configuration, so
5
+ * its planned artifact is the set of configured-agent outcomes, and an agent
6
+ * that cannot accept the hook blocks the closure rather than failing mid-way.
7
+ *
8
+ * @experimental This API is unstable and may change without notice.
9
+ */
10
+ import * as Effect from "effect/Effect";
11
+ import * as Option from "effect/Option";
12
+ import { HookManager } from "@agentxm/extension-materialization";
13
+ import { type Handle } from "@agentxm/extension-model/unstable/extensions";
14
+ import type { HookExtensionRef } from "@agentxm/extension-model/unstable/extensions/refs/hook";
15
+ import type { Source } from "@agentxm/extension-model/unstable/sources/types";
16
+ import type { VersionRange } from "@agentxm/extension-model/unstable/version-constraints";
17
+ import { type JobStepArtifact, type JobStepArtifactTarget, type Plan } from "@agentxm/workspace-operations";
18
+ import { type ConfiguredAgentOutcome, type HookLockEntry } from "@agentxm/workspace-state";
19
+ import type { ExtensionLifecycleFailed } from "../../errors.js";
20
+ import { type HookInstallIntent, type InstallStepRequirements, type ResolveInstallRequirements } from "../../install/vocabulary.js";
21
+ /** A hooks source after grammar parsing, before anything is discovered. */
22
+ export interface ParsedHookInstallRequest {
23
+ readonly source: Source;
24
+ readonly names: ReadonlyArray<string>;
25
+ readonly owner: Option.Option<Handle>;
26
+ readonly versionRange: Option.Option<VersionRange>;
27
+ }
28
+ /** The artifact an applied hook install reports, from its accepted lock entry. */
29
+ export declare const hookInstallArtifact: (args: {
30
+ readonly lockEntry: HookLockEntry;
31
+ readonly installedBefore: boolean;
32
+ readonly scope: JobStepArtifact["scope"];
33
+ readonly agents: ReadonlyArray<string>;
34
+ readonly targets: ReadonlyArray<JobStepArtifactTarget>;
35
+ readonly agentOutcomes?: ReadonlyArray<ConfiguredAgentOutcome>;
36
+ }) => JobStepArtifact;
37
+ /** Read the hooks source grammar: which owner, which names, which range. */
38
+ export declare const parseHookInstallRequest: (source: string) => Effect.Effect<ParsedHookInstallRequest, ExtensionLifecycleFailed, ResolveInstallRequirements>;
39
+ /** Discover the hooks packages the parsed source offers. */
40
+ export declare const discoverHookRefs: (request: ParsedHookInstallRequest) => Effect.Effect<ReadonlyArray<HookExtensionRef>, ExtensionLifecycleFailed, ResolveInstallRequirements>;
41
+ /** Settle which hooks packages this request installs, or refuse when none matched. */
42
+ export declare const finalizeHookInstallIntent: (request: ParsedHookInstallRequest, refs: ReadonlyArray<HookExtensionRef>) => Effect.Effect<HookInstallIntent, ExtensionLifecycleFailed>;
43
+ /** The closures a settled hook intent becomes. */
44
+ export declare const planHookInstall: (intent: HookInstallIntent) => Effect.Effect<Plan<InstallStepRequirements>, ExtensionLifecycleFailed, InstallStepRequirements | HookManager>;
45
+ //# sourceMappingURL=plan.d.ts.map