@xenosystem/agent-interface-host 0.1.120 → 0.1.122
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/pluginMcp/PluginMcpManagerService.d.ts +40 -3
- package/dist/pluginMcp/PluginMcpManagerService.d.ts.map +1 -1
- package/dist/pluginMcp/PluginMcpManagerService.js +66 -15
- package/dist/pluginMcp/PluginMcpManagerService.js.map +1 -1
- package/dist/workspace/WorkspaceHostService.d.ts +8 -1
- package/dist/workspace/WorkspaceHostService.d.ts.map +1 -1
- package/dist/workspace/WorkspaceHostService.js +39 -1
- package/dist/workspace/WorkspaceHostService.js.map +1 -1
- package/package.json +8 -7
|
@@ -39,8 +39,38 @@ export declare function approvedComposerMcpServerRecord(input: ComposerMcpServer
|
|
|
39
39
|
/** The trust verdict the host derives for a stored record — exported so a composer can test its registration. */
|
|
40
40
|
export declare function mcpServerRecordTrust(record: HubMcpServerRecord): HubMcpServerSummary['trust'];
|
|
41
41
|
export declare function createResultPreview(result: unknown, title: string, source?: HubMcpResultPreviewMetadata['source']): HubMcpResultPreview;
|
|
42
|
+
/**
|
|
43
|
+
* Where the plugin/MCP store lives. The host is the `extensions` area's owner (XENO LOCAL HOME - SPEC.md section 5):
|
|
44
|
+
* installed plugins in data, MCP definitions and approvals in config, the approval audit log in data.
|
|
45
|
+
*/
|
|
46
|
+
export interface PluginMcpStoreLocation {
|
|
47
|
+
/** The SDK plugin host's directory: installed plugins, plugins.json, trust.json, events.jsonl. */
|
|
48
|
+
pluginDir: string;
|
|
49
|
+
/** servers.json and sdk-approvals.json. */
|
|
50
|
+
mcpConfigDir: string;
|
|
51
|
+
/** approvals.jsonl, the approval audit history. */
|
|
52
|
+
mcpDataDir: string;
|
|
53
|
+
/** Paths a plugin's sandbox may never reach (the person's SSH keys, XENO secrets). */
|
|
54
|
+
protectedPaths: string[];
|
|
55
|
+
/** `extensions`: the primitives layout; `legacy`: the pre-0.3 `~/.xeno/{plugins,mcp}` store. */
|
|
56
|
+
layout: 'extensions' | 'legacy';
|
|
57
|
+
}
|
|
58
|
+
/** The pre-0.3 store under one base (`~/.xeno`); also how tests isolate a store in a temp folder. */
|
|
59
|
+
export declare function legacyPluginMcpStore(baseDir: string, protectedPaths?: string[]): PluginMcpStoreLocation;
|
|
60
|
+
/** The store in the `extensions` area of a XENO layout. */
|
|
61
|
+
export declare function extensionsPluginMcpStore(roots: {
|
|
62
|
+
data: string;
|
|
63
|
+
config: string;
|
|
64
|
+
secrets: string;
|
|
65
|
+
}, protectedPaths?: string[]): PluginMcpStoreLocation;
|
|
66
|
+
/**
|
|
67
|
+
* Which store to use (the 3-release legacy read fallback, XENO LOCAL HOME - SPEC.md section 11.2): the extensions store
|
|
68
|
+
* once it holds anything, or when nothing exists anywhere; the legacy store while it is the only one with data, so a
|
|
69
|
+
* person who has not run `xeno-home migrate` keeps their plugins and MCP servers. Never both at once.
|
|
70
|
+
*/
|
|
71
|
+
export declare function choosePluginMcpStore(extensions: PluginMcpStoreLocation, legacy: PluginMcpStoreLocation): PluginMcpStoreLocation;
|
|
42
72
|
export declare class PluginMcpManagerService {
|
|
43
|
-
|
|
73
|
+
readonly location: PluginMcpStoreLocation;
|
|
44
74
|
private readonly pluginDir;
|
|
45
75
|
private readonly pluginEventLogPath;
|
|
46
76
|
private readonly pluginTrustPath;
|
|
@@ -53,7 +83,8 @@ export declare class PluginMcpManagerService {
|
|
|
53
83
|
private mcpUnsubscribe;
|
|
54
84
|
private pluginEvents;
|
|
55
85
|
private activePluginsHydrated;
|
|
56
|
-
|
|
86
|
+
/** A string is the legacy layout at that base (`~/.xeno`, or a test's temp folder). */
|
|
87
|
+
constructor(location: PluginMcpStoreLocation | string);
|
|
57
88
|
snapshot(request?: PluginMcpSnapshotRequest): Promise<HubPluginMcpSnapshot>;
|
|
58
89
|
installPlugin(request: InstallPluginRequest): Promise<{
|
|
59
90
|
success: boolean;
|
|
@@ -199,6 +230,12 @@ export declare class PluginMcpManagerService {
|
|
|
199
230
|
private recordPluginEvent;
|
|
200
231
|
private appendMcpApproval;
|
|
201
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* The store for a person's home: the `extensions` area of their XENO layout (from the primitives resolver), or the
|
|
235
|
+
* legacy `~/.xeno` store while it is the only one holding data. The home is needed only for that legacy fallback and
|
|
236
|
+
* for `~/.ssh`, which a plugin's sandbox may never reach.
|
|
237
|
+
*/
|
|
238
|
+
export declare function pluginMcpStoreFor(home: string, env?: Readonly<Record<string, string | undefined>>): PluginMcpStoreLocation;
|
|
202
239
|
/**
|
|
203
240
|
* The one instance in this process. The SDK lane registers plugin and MCP tools from it, and the
|
|
204
241
|
* host's `pluginMcp.*` methods manage it, so both must be the same object: a second instance over
|
|
@@ -210,6 +247,6 @@ export declare function getPluginMcpManagerService(): PluginMcpManagerService;
|
|
|
210
247
|
* host composed for an isolated home never reads or writes the real one. Lazy: nothing is created
|
|
211
248
|
* until something asks. One composition per process in production, so it never moves there.
|
|
212
249
|
*/
|
|
213
|
-
export declare function configurePluginMcpManagerService(
|
|
250
|
+
export declare function configurePluginMcpManagerService(location: PluginMcpStoreLocation | string): void;
|
|
214
251
|
export {};
|
|
215
252
|
//# sourceMappingURL=PluginMcpManagerService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginMcpManagerService.d.ts","sourceRoot":"","sources":["../../src/pluginMcp/PluginMcpManagerService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PluginMcpManagerService.d.ts","sourceRoot":"","sources":["../../src/pluginMcp/PluginMcpManagerService.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAOV,cAAc,EAOf,MAAM,uBAAuB,CAAA;AAE9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAEtE,OAAO,KAAK,EACV,kBAA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AAC,gBAAgB;IAaxB,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,iBAAiB;CAQ1B;AAMD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAe,GAAG,sBAAsB,CAQvI;AAQD;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI,uBAAuB,CAQpE;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,sBAAsB,GAAG,MAAM,GAAG,IAAI,CAEhG"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'fs';
|
|
2
2
|
import { createHash } from 'crypto';
|
|
3
3
|
import { homedir } from 'os';
|
|
4
|
+
import { createDirs } from '@xenosystem/primitives/dirs';
|
|
4
5
|
import { dirname, join, resolve } from 'path';
|
|
5
6
|
import { capabilityMcpServerConfig, CAPABILITY_MCP_SERVER_NAME } from './capabilityMcpRegistration.js';
|
|
6
7
|
import { createScopeAcl, estimateTokens, normalizeSearchText, stableDocumentId } from '../agentSearch/searchUtils.js';
|
|
@@ -761,8 +762,38 @@ function redactPreviewValue(value, path = '') {
|
|
|
761
762
|
}
|
|
762
763
|
return { value: out, fields };
|
|
763
764
|
}
|
|
765
|
+
/** The pre-0.3 store under one base (`~/.xeno`); also how tests isolate a store in a temp folder. */
|
|
766
|
+
export function legacyPluginMcpStore(baseDir, protectedPaths = []) {
|
|
767
|
+
return {
|
|
768
|
+
pluginDir: join(baseDir, 'plugins'),
|
|
769
|
+
mcpConfigDir: join(baseDir, 'mcp'),
|
|
770
|
+
mcpDataDir: join(baseDir, 'mcp'),
|
|
771
|
+
protectedPaths: [...protectedPaths, join(baseDir, 'credentials.json')],
|
|
772
|
+
layout: 'legacy',
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
/** The store in the `extensions` area of a XENO layout. */
|
|
776
|
+
export function extensionsPluginMcpStore(roots, protectedPaths = []) {
|
|
777
|
+
return {
|
|
778
|
+
pluginDir: join(roots.data, 'extensions', 'plugins'),
|
|
779
|
+
mcpConfigDir: join(roots.config, 'extensions', 'mcp'),
|
|
780
|
+
mcpDataDir: join(roots.data, 'extensions', 'mcp'),
|
|
781
|
+
protectedPaths: [...protectedPaths, roots.secrets],
|
|
782
|
+
layout: 'extensions',
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
const storeHasData = (location) => [join(location.pluginDir, 'plugins.json'), join(location.pluginDir, 'trust.json'), join(location.mcpConfigDir, 'servers.json'), join(location.mcpConfigDir, 'sdk-approvals.json')]
|
|
786
|
+
.some((file) => existsSync(file));
|
|
787
|
+
/**
|
|
788
|
+
* Which store to use (the 3-release legacy read fallback, XENO LOCAL HOME - SPEC.md section 11.2): the extensions store
|
|
789
|
+
* once it holds anything, or when nothing exists anywhere; the legacy store while it is the only one with data, so a
|
|
790
|
+
* person who has not run `xeno-home migrate` keeps their plugins and MCP servers. Never both at once.
|
|
791
|
+
*/
|
|
792
|
+
export function choosePluginMcpStore(extensions, legacy) {
|
|
793
|
+
return !storeHasData(extensions) && storeHasData(legacy) ? legacy : extensions;
|
|
794
|
+
}
|
|
764
795
|
export class PluginMcpManagerService {
|
|
765
|
-
|
|
796
|
+
location;
|
|
766
797
|
pluginDir;
|
|
767
798
|
pluginEventLogPath;
|
|
768
799
|
pluginTrustPath;
|
|
@@ -775,18 +806,20 @@ export class PluginMcpManagerService {
|
|
|
775
806
|
mcpUnsubscribe = null;
|
|
776
807
|
pluginEvents = [];
|
|
777
808
|
activePluginsHydrated = false;
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
this.
|
|
809
|
+
/** A string is the legacy layout at that base (`~/.xeno`, or a test's temp folder). */
|
|
810
|
+
constructor(location) {
|
|
811
|
+
this.location = typeof location === 'string' ? legacyPluginMcpStore(location) : location;
|
|
812
|
+
this.pluginDir = this.location.pluginDir;
|
|
781
813
|
this.pluginEventLogPath = join(this.pluginDir, 'events.jsonl');
|
|
782
814
|
this.pluginTrustPath = join(this.pluginDir, 'trust.json');
|
|
783
|
-
this.mcpDir =
|
|
815
|
+
this.mcpDir = this.location.mcpConfigDir;
|
|
784
816
|
this.mcpServersPath = join(this.mcpDir, 'servers.json');
|
|
785
817
|
// A separate file: an older host rewrites servers.json from known fields and would drop it.
|
|
786
818
|
this.sdkApprovalsPath = join(this.mcpDir, 'sdk-approvals.json');
|
|
787
|
-
this.mcpApprovalsPath = join(this.
|
|
819
|
+
this.mcpApprovalsPath = join(this.location.mcpDataDir, 'approvals.jsonl');
|
|
788
820
|
ensureDir(this.pluginDir);
|
|
789
821
|
ensureDir(this.mcpDir);
|
|
822
|
+
ensureDir(this.location.mcpDataDir);
|
|
790
823
|
this.pluginEvents = this.loadPluginEvents();
|
|
791
824
|
}
|
|
792
825
|
async snapshot(request = {}) {
|
|
@@ -1679,7 +1712,7 @@ export class PluginMcpManagerService {
|
|
|
1679
1712
|
sandbox: {
|
|
1680
1713
|
enabled: true,
|
|
1681
1714
|
executionTimeout: 30_000,
|
|
1682
|
-
blockedPaths: [
|
|
1715
|
+
blockedPaths: [...this.location.protectedPaths],
|
|
1683
1716
|
},
|
|
1684
1717
|
});
|
|
1685
1718
|
this.pluginHost.events.onAny((event) => this.recordPluginEvent(event));
|
|
@@ -2082,18 +2115,36 @@ export class PluginMcpManagerService {
|
|
|
2082
2115
|
}
|
|
2083
2116
|
}
|
|
2084
2117
|
let singleton = null;
|
|
2085
|
-
let
|
|
2086
|
-
let
|
|
2118
|
+
let singletonKey;
|
|
2119
|
+
let configuredLocation;
|
|
2120
|
+
/**
|
|
2121
|
+
* The store for a person's home: the `extensions` area of their XENO layout (from the primitives resolver), or the
|
|
2122
|
+
* legacy `~/.xeno` store while it is the only one holding data. The home is needed only for that legacy fallback and
|
|
2123
|
+
* for `~/.ssh`, which a plugin's sandbox may never reach.
|
|
2124
|
+
*/
|
|
2125
|
+
export function pluginMcpStoreFor(home, env = process.env) {
|
|
2126
|
+
const dirs = createDirs({ home, env });
|
|
2127
|
+
const ssh = join(home, '.ssh');
|
|
2128
|
+
return choosePluginMcpStore(extensionsPluginMcpStore({ data: dirs.root('data'), config: dirs.root('config'), secrets: dirs.root('secrets') }, [ssh]),
|
|
2129
|
+
// xeno-dirs-allow: the legacy read fallback of XENO LOCAL HOME - SPEC.md section 11.2, read until migrated
|
|
2130
|
+
legacyPluginMcpStore(join(home, '.xeno'), [ssh]));
|
|
2131
|
+
}
|
|
2132
|
+
/** When no composition configured a store: this process's own home. */
|
|
2133
|
+
function defaultPluginMcpStore() {
|
|
2134
|
+
// xeno-dirs-allow: only the legacy fallback and ~/.ssh need the home; the layout itself comes from createDirs
|
|
2135
|
+
return pluginMcpStoreFor(homedir());
|
|
2136
|
+
}
|
|
2087
2137
|
/**
|
|
2088
2138
|
* The one instance in this process. The SDK lane registers plugin and MCP tools from it, and the
|
|
2089
2139
|
* host's `pluginMcp.*` methods manage it, so both must be the same object: a second instance over
|
|
2090
2140
|
* the same files would hold its own MCP connections and event cache.
|
|
2091
2141
|
*/
|
|
2092
2142
|
export function getPluginMcpManagerService() {
|
|
2093
|
-
const
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2143
|
+
const location = configuredLocation ?? defaultPluginMcpStore();
|
|
2144
|
+
const key = JSON.stringify(location);
|
|
2145
|
+
if (!singleton || singletonKey !== key) {
|
|
2146
|
+
singleton = new PluginMcpManagerService(location);
|
|
2147
|
+
singletonKey = key;
|
|
2097
2148
|
}
|
|
2098
2149
|
return singleton;
|
|
2099
2150
|
}
|
|
@@ -2102,7 +2153,7 @@ export function getPluginMcpManagerService() {
|
|
|
2102
2153
|
* host composed for an isolated home never reads or writes the real one. Lazy: nothing is created
|
|
2103
2154
|
* until something asks. One composition per process in production, so it never moves there.
|
|
2104
2155
|
*/
|
|
2105
|
-
export function configurePluginMcpManagerService(
|
|
2106
|
-
|
|
2156
|
+
export function configurePluginMcpManagerService(location) {
|
|
2157
|
+
configuredLocation = typeof location === 'string' ? legacyPluginMcpStore(location) : location;
|
|
2107
2158
|
}
|
|
2108
2159
|
//# sourceMappingURL=PluginMcpManagerService.js.map
|