@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.
- package/LICENSE +110 -0
- package/dist/src/configured-entry-resolution.d.ts +110 -0
- package/dist/src/configured-entry-resolution.js +723 -0
- package/dist/src/errors.d.ts +39 -0
- package/dist/src/errors.js +45 -0
- package/dist/src/failure-adapter.d.ts +35 -0
- package/dist/src/failure-adapter.js +23 -0
- package/dist/src/hooks/configured-agent-outcomes-provider.d.ts +18 -0
- package/dist/src/hooks/configured-agent-outcomes-provider.js +39 -0
- package/dist/src/hooks/manager.d.ts +15 -0
- package/dist/src/hooks/manager.js +751 -0
- package/dist/src/index.d.ts +38 -0
- package/dist/src/index.js +41 -0
- package/dist/src/internal/fs-helpers.d.ts +12 -0
- package/dist/src/internal/fs-helpers.js +13 -0
- package/dist/src/internal/integrity.d.ts +13 -0
- package/dist/src/internal/integrity.js +17 -0
- package/dist/src/knowledge/manager.d.ts +11 -0
- package/dist/src/knowledge/manager.js +655 -0
- package/dist/src/live.d.ts +18 -0
- package/dist/src/live.js +18 -0
- package/dist/src/mcps/manager.d.ts +16 -0
- package/dist/src/mcps/manager.js +213 -0
- package/dist/src/mcps/operations/artifact.d.ts +24 -0
- package/dist/src/mcps/operations/artifact.js +74 -0
- package/dist/src/mcps/operations/disable.d.ts +18 -0
- package/dist/src/mcps/operations/disable.js +113 -0
- package/dist/src/mcps/operations/enable.d.ts +18 -0
- package/dist/src/mcps/operations/enable.js +218 -0
- package/dist/src/mcps/operations/install.d.ts +59 -0
- package/dist/src/mcps/operations/install.js +566 -0
- package/dist/src/mcps/operations/sync-outcome.d.ts +10 -0
- package/dist/src/mcps/operations/sync-outcome.js +27 -0
- package/dist/src/mcps/operations/uninstall.d.ts +41 -0
- package/dist/src/mcps/operations/uninstall.js +189 -0
- package/dist/src/packs/dependency-resolution.d.ts +65 -0
- package/dist/src/packs/dependency-resolution.js +414 -0
- package/dist/src/packs/expansion.d.ts +59 -0
- package/dist/src/packs/expansion.js +44 -0
- package/dist/src/packs/manager.d.ts +16 -0
- package/dist/src/packs/manager.js +181 -0
- package/dist/src/packs/operations/install.d.ts +67 -0
- package/dist/src/packs/operations/install.js +156 -0
- package/dist/src/packs/resolved-dependency.d.ts +29 -0
- package/dist/src/packs/resolved-dependency.js +28 -0
- package/dist/src/registry-materialization.d.ts +52 -0
- package/dist/src/registry-materialization.js +67 -0
- package/dist/src/resolution-progress.d.ts +18 -0
- package/dist/src/resolution-progress.js +11 -0
- package/dist/src/resolution-timeout.d.ts +5 -0
- package/dist/src/resolution-timeout.js +11 -0
- package/dist/src/rules/manager.d.ts +20 -0
- package/dist/src/rules/manager.js +475 -0
- package/dist/src/skills/manager.d.ts +18 -0
- package/dist/src/skills/manager.js +346 -0
- package/dist/src/skills/materialization.d.ts +54 -0
- package/dist/src/skills/materialization.js +158 -0
- package/dist/src/skills/operations/disable.d.ts +31 -0
- package/dist/src/skills/operations/disable.js +110 -0
- package/dist/src/skills/operations/enable.d.ts +31 -0
- package/dist/src/skills/operations/enable.js +113 -0
- package/dist/src/skills/operations/install-result.d.ts +33 -0
- package/dist/src/skills/operations/install-result.js +10 -0
- package/dist/src/skills/operations/install.d.ts +67 -0
- package/dist/src/skills/operations/install.js +590 -0
- package/dist/src/skills/operations/source-hash.d.ts +2 -0
- package/dist/src/skills/operations/source-hash.js +6 -0
- package/dist/src/skills/operations/uninstall.d.ts +40 -0
- package/dist/src/skills/operations/uninstall.js +157 -0
- package/dist/src/skills/utils.d.ts +11 -0
- package/dist/src/skills/utils.js +29 -0
- package/dist/src/subagents/manager.d.ts +18 -0
- package/dist/src/subagents/manager.js +677 -0
- package/dist/src/subagents/operations/artifact.d.ts +18 -0
- package/dist/src/subagents/operations/artifact.js +43 -0
- package/dist/src/subagents/operations/disable.d.ts +32 -0
- package/dist/src/subagents/operations/disable.js +116 -0
- package/dist/src/subagents/operations/enable.d.ts +30 -0
- package/dist/src/subagents/operations/enable.js +160 -0
- package/dist/src/workflows/install-command/workflow.d.ts +57 -0
- package/dist/src/workflows/install-command/workflow.js +41 -0
- package/dist/src/workflows/uninstall-command/workflow.d.ts +42 -0
- package/dist/src/workflows/uninstall-command/workflow.js +29 -0
- package/package.json +62 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enable MCP server executor.
|
|
3
|
+
*
|
|
4
|
+
* @experimental This API is unstable and may change without notice.
|
|
5
|
+
*/
|
|
6
|
+
import * as FileSystem from "effect/FileSystem";
|
|
7
|
+
import * as Path from "effect/Path";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Option from "effect/Option";
|
|
10
|
+
import { CodingAgentRepository, syncInlineMcpServerToAgents, McpSharedTargetConflict, applyProjectionPlansWithResults, planSingletonProjection, inspectAgentMcpServer, sharedMcpTargetPolicyConflict, } from "@agentxm/extension-workspace";
|
|
11
|
+
import { normalizeHandle, parseExtensionFqnParts, } from "@agentxm/extension-model/unstable/extensions";
|
|
12
|
+
import { appendWarningsToMessage } from "@agentxm/workspace-operations";
|
|
13
|
+
import { WorkspaceMutations } from "@agentxm/workspace-state";
|
|
14
|
+
import { agentConfigTargets, mcpServerArtifact, mcpSettingsTarget } from "./artifact.js";
|
|
15
|
+
import { usableAcceptedCanonicalObservation } from "@agentxm/workspace-state";
|
|
16
|
+
import { mcpSyncWarnings, requireSuccessfulMcpSync } from "./sync-outcome.js";
|
|
17
|
+
import { isMcpServerApplicableToAgent } from "@agentxm/workspace-state";
|
|
18
|
+
import { LifecycleFailureAdapter, withAdaptedStepFailures } from "../../failure-adapter.js";
|
|
19
|
+
import { ExtensionLifecycleFailed } from "../../errors.js";
|
|
20
|
+
const enableArtifact = (args) => {
|
|
21
|
+
return mcpServerArtifact({
|
|
22
|
+
lockEntry: args.lockEntry,
|
|
23
|
+
scope: args.scope,
|
|
24
|
+
change: "updated",
|
|
25
|
+
targets: [mcpSettingsTarget(args.scope, "updated"), ...args.targets],
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
export const enableMcpServer = (op) => Effect.gen(function* () {
|
|
29
|
+
const fs = yield* FileSystem.FileSystem;
|
|
30
|
+
const path = yield* Path.Path;
|
|
31
|
+
const ws = yield* WorkspaceMutations;
|
|
32
|
+
const agentRepo = yield* CodingAgentRepository;
|
|
33
|
+
const configured = yield* ws.getConfiguredMcpServerEntries();
|
|
34
|
+
const entry = configured[op.args.serverName];
|
|
35
|
+
if (entry === undefined) {
|
|
36
|
+
return yield* new ExtensionLifecycleFailed({
|
|
37
|
+
category: "not_found",
|
|
38
|
+
detail: `MCP server "${op.args.serverName}" not found in settings`,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (entry.kind === "inline") {
|
|
42
|
+
const agentIds = yield* ws.getConfiguredAgents();
|
|
43
|
+
const outcomes = yield* ws.runTransaction({
|
|
44
|
+
transition: Effect.gen(function* () {
|
|
45
|
+
const synced = yield* syncInlineMcpServerToAgents(agentIds, {
|
|
46
|
+
workspaceRoot: ws.baseDir,
|
|
47
|
+
serverName: op.args.serverName,
|
|
48
|
+
entry: { ...entry, enabled: true },
|
|
49
|
+
scope: ws.scope,
|
|
50
|
+
}).pipe(Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path));
|
|
51
|
+
const agentOutcomes = agentIds.map((agentId, index) => ({
|
|
52
|
+
agentId,
|
|
53
|
+
outcome: synced[index] ?? {
|
|
54
|
+
_tag: "failed",
|
|
55
|
+
reason: "Agent sync returned no outcome",
|
|
56
|
+
},
|
|
57
|
+
}));
|
|
58
|
+
yield* requireSuccessfulMcpSync(op.args.serverName, agentOutcomes);
|
|
59
|
+
yield* ws.updateMcpServerEntry(op.args.serverName, (current) => ({
|
|
60
|
+
...current,
|
|
61
|
+
enabled: true,
|
|
62
|
+
}));
|
|
63
|
+
return synced;
|
|
64
|
+
}),
|
|
65
|
+
validate: () => Effect.void,
|
|
66
|
+
});
|
|
67
|
+
const identifiedOutcomes = agentIds.map((agentId, index) => ({
|
|
68
|
+
agentId,
|
|
69
|
+
outcome: outcomes[index] ?? {
|
|
70
|
+
_tag: "failed",
|
|
71
|
+
reason: "Agent sync returned no outcome",
|
|
72
|
+
},
|
|
73
|
+
}));
|
|
74
|
+
const warnings = mcpSyncWarnings(op.args.serverName, identifiedOutcomes);
|
|
75
|
+
const agentOutcomes = agentIds.flatMap((agentId, index) => {
|
|
76
|
+
const outcome = outcomes[index];
|
|
77
|
+
return outcome !== undefined && "targets" in outcome
|
|
78
|
+
? [{ agentId, targets: outcome.targets }]
|
|
79
|
+
: [];
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
result: "success",
|
|
83
|
+
message: appendWarningsToMessage(`Enabled ${op.args.serverName}`, warnings),
|
|
84
|
+
artifact: enableArtifact({
|
|
85
|
+
lockEntry: undefined,
|
|
86
|
+
scope: ws.scope,
|
|
87
|
+
targets: agentConfigTargets(agentOutcomes),
|
|
88
|
+
}),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const canonical = yield* usableAcceptedCanonicalObservation({
|
|
92
|
+
workspace: ws,
|
|
93
|
+
type: "mcp-server",
|
|
94
|
+
name: op.args.serverName,
|
|
95
|
+
});
|
|
96
|
+
if (Option.isNone(canonical)) {
|
|
97
|
+
return yield* new ExtensionLifecycleFailed({
|
|
98
|
+
category: "not_found",
|
|
99
|
+
detail: `Accepted MCP server content for "${op.args.serverName}" is not usable`,
|
|
100
|
+
suggestions: [
|
|
101
|
+
{
|
|
102
|
+
description: "Try reinstalling the MCP server.",
|
|
103
|
+
cmd: "axm mcps install <source>",
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const canonicalPath = canonical.value.observation.path;
|
|
109
|
+
const accepted = canonical.value.accepted?.extensionType === "mcp-server"
|
|
110
|
+
? canonical.value.accepted
|
|
111
|
+
: undefined;
|
|
112
|
+
const identity = canonical.value.desired.identity.startsWith("workspace:")
|
|
113
|
+
? canonical.value.desired.identity.slice("workspace:".length)
|
|
114
|
+
: canonical.value.desired.identity;
|
|
115
|
+
const trustedIdentity = parseExtensionFqnParts(identity);
|
|
116
|
+
const owner = trustedIdentity?.type === "mcp-server" ? trustedIdentity.owner : normalizeHandle("@local");
|
|
117
|
+
const resolvedVersion = accepted?.type === "registry" ? accepted.resolvedVersion : "0.0.0";
|
|
118
|
+
const agents = yield* agentRepo.getConfiguredAgents();
|
|
119
|
+
const sharedTargetConflict = sharedMcpTargetPolicyConflict({
|
|
120
|
+
entry,
|
|
121
|
+
agentIds: agents.map((agent) => agent.id),
|
|
122
|
+
scope: ws.scope,
|
|
123
|
+
});
|
|
124
|
+
if (sharedTargetConflict !== undefined) {
|
|
125
|
+
return yield* new ExtensionLifecycleFailed({
|
|
126
|
+
category: "conflict",
|
|
127
|
+
detail: sharedTargetConflict,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
const outcomes = yield* ws.runTransaction({
|
|
131
|
+
transition: Effect.gen(function* () {
|
|
132
|
+
const synced = yield* applyProjectionPlansWithResults(agents.map((agent) => planSingletonProjection({
|
|
133
|
+
unitId: "mcp-server:native-config-entry",
|
|
134
|
+
targetFile: "mcp:configured-agents",
|
|
135
|
+
contributor: op.args,
|
|
136
|
+
adapter: {
|
|
137
|
+
observe: () => Effect.succeed({
|
|
138
|
+
unitId: "mcp-server:native-config-entry",
|
|
139
|
+
path: `${agent.id}:${op.args.serverName}`,
|
|
140
|
+
present: false,
|
|
141
|
+
current: false,
|
|
142
|
+
expectedContributors: [op.args.serverName],
|
|
143
|
+
observedContributors: [],
|
|
144
|
+
}),
|
|
145
|
+
apply: () => Effect.gen(function* () {
|
|
146
|
+
if (!isMcpServerApplicableToAgent(entry, agent.id)) {
|
|
147
|
+
const inspection = yield* inspectAgentMcpServer({
|
|
148
|
+
workspaceRoot: ws.baseDir,
|
|
149
|
+
scope: ws.scope,
|
|
150
|
+
agentId: agent.id,
|
|
151
|
+
serverName: op.args.serverName,
|
|
152
|
+
entry,
|
|
153
|
+
});
|
|
154
|
+
if (inspection.status === "unmanaged") {
|
|
155
|
+
return yield* new McpSharedTargetConflict({
|
|
156
|
+
reason: `${agent.id} has an unmanaged MCP server named ${op.args.serverName}; AXM will not remove it while applying the target policy`,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return inspection.status === "drift"
|
|
160
|
+
? yield* agent.removeMcpServer({
|
|
161
|
+
workspaceRoot: ws.baseDir,
|
|
162
|
+
scope: ws.scope,
|
|
163
|
+
serverName: op.args.serverName,
|
|
164
|
+
})
|
|
165
|
+
: { _tag: "success", targets: [] };
|
|
166
|
+
}
|
|
167
|
+
return yield* agent.addMcpServer({
|
|
168
|
+
workspaceRoot: ws.baseDir,
|
|
169
|
+
scope: ws.scope,
|
|
170
|
+
serverName: op.args.serverName,
|
|
171
|
+
canonicalPath,
|
|
172
|
+
owner,
|
|
173
|
+
resolvedVersion,
|
|
174
|
+
enabled: true,
|
|
175
|
+
configValues: entry.env,
|
|
176
|
+
});
|
|
177
|
+
}).pipe(Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path)),
|
|
178
|
+
},
|
|
179
|
+
})));
|
|
180
|
+
yield* requireSuccessfulMcpSync(op.args.serverName, agents.map((agent, index) => ({
|
|
181
|
+
agentId: agent.id,
|
|
182
|
+
outcome: synced[index] ?? {
|
|
183
|
+
_tag: "failed",
|
|
184
|
+
reason: "Agent sync returned no outcome",
|
|
185
|
+
},
|
|
186
|
+
})));
|
|
187
|
+
yield* ws.updateMcpServerEntry(op.args.serverName, (current) => ({
|
|
188
|
+
...current,
|
|
189
|
+
enabled: true,
|
|
190
|
+
}));
|
|
191
|
+
return synced;
|
|
192
|
+
}).pipe(Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path)),
|
|
193
|
+
validate: () => Effect.void,
|
|
194
|
+
});
|
|
195
|
+
const warnings = mcpSyncWarnings(op.args.serverName, agents.map((agent, index) => ({
|
|
196
|
+
agentId: agent.id,
|
|
197
|
+
outcome: outcomes[index] ?? {
|
|
198
|
+
_tag: "failed",
|
|
199
|
+
reason: "Agent sync returned no outcome",
|
|
200
|
+
},
|
|
201
|
+
})));
|
|
202
|
+
const agentOutcomes = agents.flatMap((agent, index) => {
|
|
203
|
+
const outcome = outcomes[index];
|
|
204
|
+
return outcome !== undefined && "targets" in outcome
|
|
205
|
+
? [{ agentId: agent.id, targets: outcome.targets }]
|
|
206
|
+
: [];
|
|
207
|
+
});
|
|
208
|
+
return {
|
|
209
|
+
result: "success",
|
|
210
|
+
message: appendWarningsToMessage(`Enabled ${op.args.serverName}`, warnings),
|
|
211
|
+
artifact: enableArtifact({
|
|
212
|
+
lockEntry: accepted,
|
|
213
|
+
scope: ws.scope,
|
|
214
|
+
targets: agentConfigTargets(agentOutcomes),
|
|
215
|
+
}),
|
|
216
|
+
};
|
|
217
|
+
}).pipe(withAdaptedStepFailures);
|
|
218
|
+
//# sourceMappingURL=enable.js.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Install MCP server executor — orchestrates the per-server installation pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Registry-only install: fetch archive, extract to canonical path, update lockfile/settings.
|
|
5
|
+
* Simpler than skills — no agent symlinks.
|
|
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 Effect from "effect/Effect";
|
|
13
|
+
import * as Option from "effect/Option";
|
|
14
|
+
import { CodingAgentRepository } from "@agentxm/extension-workspace";
|
|
15
|
+
import type { ConfigurableAgentId } from "@agentxm/extension-model/unstable/agent-capabilities";
|
|
16
|
+
import type { StepFailure } from "@agentxm/workspace-operations";
|
|
17
|
+
import type { JobStepResult, Operation } from "@agentxm/workspace-operations";
|
|
18
|
+
import { WorkspaceMutations } from "@agentxm/workspace-state";
|
|
19
|
+
import type { McpServerExtensionRef } from "@agentxm/extension-model/unstable/extensions/refs/mcp-server";
|
|
20
|
+
import { LifecycleFailureAdapter } from "../../failure-adapter.js";
|
|
21
|
+
/**
|
|
22
|
+
* Args for the install-mcp-server operation.
|
|
23
|
+
*/
|
|
24
|
+
export type InstallMcpServerOperationArgs = {
|
|
25
|
+
readonly ref: McpServerExtensionRef;
|
|
26
|
+
readonly force: boolean;
|
|
27
|
+
/** Explicitly permit a workspace-authored relocation during reconciliation. */
|
|
28
|
+
readonly allowWorkspaceSourceTransition?: boolean;
|
|
29
|
+
readonly versionRange: Option.Option<string>;
|
|
30
|
+
/** When true, write to lockfile only (skip settings). Used for pack dependencies. */
|
|
31
|
+
readonly skipSettings: Option.Option<boolean>;
|
|
32
|
+
/** Materialize only; the enclosing authored-package transaction owns state writes. */
|
|
33
|
+
readonly skipStateWrites?: boolean;
|
|
34
|
+
/** When true, enforce strict policy for MCP sync outcomes. */
|
|
35
|
+
readonly strictAgentSync?: Option.Option<boolean>;
|
|
36
|
+
/** Resolved MCP input values from `--env KEY=VALUE` flags. */
|
|
37
|
+
readonly env?: Option.Option<Readonly<Record<string, string>>>;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the invoking surface can prompt for missing required inputs.
|
|
40
|
+
* The transport boundary resolves flag, CI, and TTY state.
|
|
41
|
+
*/
|
|
42
|
+
readonly nonInteractive: boolean;
|
|
43
|
+
/** Restrict this server to a reviewed subset of configured agents. */
|
|
44
|
+
readonly agents?: ReadonlyArray<ConfigurableAgentId>;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Add an MCP server to the workspace.
|
|
48
|
+
*
|
|
49
|
+
* @experimental This API is unstable and may change without notice.
|
|
50
|
+
*/
|
|
51
|
+
export type InstallMcpServerOperation = Operation<"install-mcp-server", InstallMcpServerOperationArgs>;
|
|
52
|
+
/**
|
|
53
|
+
* Install-mcp-server operation handler.
|
|
54
|
+
*
|
|
55
|
+
* Registry-only: fetch archive, validate integrity, extract to canonical path,
|
|
56
|
+
* then update lockfile/settings.
|
|
57
|
+
*/
|
|
58
|
+
export declare const installMcpServer: (op: InstallMcpServerOperation) => Effect.Effect<JobStepResult, StepFailure, FileSystem.FileSystem | HttpClient.HttpClient | Path.Path | WorkspaceMutations | CodingAgentRepository | LifecycleFailureAdapter>;
|
|
59
|
+
//# sourceMappingURL=install.d.ts.map
|