operon-agents-core 0.1.0-alpha.26 → 0.1.0-alpha.27
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/config/schema.js +8 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/manager.d.ts +10 -2
- package/dist/mcp/manager.js +56 -17
- package/dist/permission/auto-approver/llm-auto-approver.js +5 -4
- package/package.json +1 -1
package/dist/config/schema.js
CHANGED
|
@@ -110,6 +110,12 @@ function normalizeMcpServerKeys(value) {
|
|
|
110
110
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
111
111
|
return value;
|
|
112
112
|
const out = renameKeys(value, MCP_SNAKE_CASE_KEYS);
|
|
113
|
+
// Hosts and other agents' config formats offer a separate "sse" type; here every URL-based
|
|
114
|
+
// server goes through the one http transport.
|
|
115
|
+
for (const key of ["type", "transport"]) {
|
|
116
|
+
if (out[key] === "sse")
|
|
117
|
+
out[key] = "http";
|
|
118
|
+
}
|
|
113
119
|
const oauth = out["oauth"];
|
|
114
120
|
if (typeof oauth === "object" && oauth !== null && !Array.isArray(oauth)) {
|
|
115
121
|
out["oauth"] = renameKeys(oauth, MCP_OAUTH_SNAKE_CASE_KEYS);
|
|
@@ -148,7 +154,8 @@ const McpServerConfigObjectSchema = z.object({
|
|
|
148
154
|
}
|
|
149
155
|
}).transform(({ type, transport, ...rest }) => ({
|
|
150
156
|
...rest,
|
|
151
|
-
|
|
157
|
+
// A bare `{ url }` can only be a network server; everything else keeps the stdio default.
|
|
158
|
+
transport: transport ?? type ?? (rest.command === undefined && rest.url !== undefined ? "http" : "stdio"),
|
|
152
159
|
}));
|
|
153
160
|
export const McpServerConfigSchema = z.preprocess(normalizeMcpServerKeys, McpServerConfigObjectSchema);
|
|
154
161
|
export const HookDefConfigSchema = z.object({
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,6 @@ export { loadMarketplace, parseMarketplace, loadMarketplaceEntryDetails, parseGi
|
|
|
18
18
|
export type { Marketplace, MarketplaceEntry, LoadMarketplaceOptions, MarketplaceEntryDetails, } from "./plugins/marketplace.ts";
|
|
19
19
|
export { PluginManager, pluginsCapability, parseHooksDocument, hookDefsFromConfig, } from "./plugins/index.ts";
|
|
20
20
|
export type { PluginManagerOptions, SessionStartSkillResolver, PluginSummary, PluginInfo, PluginSource, ParsedPluginHooks, } from "./plugins/index.ts";
|
|
21
|
-
export { mcpServersCapability, createMcpServers, McpOAuthService, JsonFileStore, MemoryMcpCredentialStore, McpTransportNotPermittedError } from "./mcp/index.ts";
|
|
21
|
+
export { mcpServersCapability, createMcpServers, assertMcpTransportsPermitted, McpOAuthService, JsonFileStore, MemoryMcpCredentialStore, McpTransportNotPermittedError } from "./mcp/index.ts";
|
|
22
22
|
export type { McpServersCapabilityOptions, McpOAuthServiceOptions, McpCredentialStore, McpTransportKind, McpServersHandle, McpServerView, McpCredential, McpCredentialProvider, McpCredentialRequest } from "./mcp/index.ts";
|
|
23
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -19,5 +19,5 @@ export { loadMarketplace, parseMarketplace, loadMarketplaceEntryDetails, parseGi
|
|
|
19
19
|
export { PluginManager, pluginsCapability, parseHooksDocument, hookDefsFromConfig, } from "./plugins/index.js";
|
|
20
20
|
// The per-workspace MCP capability, exposed so `defaultCapabilities` can build it from
|
|
21
21
|
// workspace + plugin servers (it lives under the ./mcp subtree, not the main capabilities barrel).
|
|
22
|
-
export { mcpServersCapability, createMcpServers, McpOAuthService, JsonFileStore, MemoryMcpCredentialStore, McpTransportNotPermittedError } from "./mcp/index.js";
|
|
22
|
+
export { mcpServersCapability, createMcpServers, assertMcpTransportsPermitted, McpOAuthService, JsonFileStore, MemoryMcpCredentialStore, McpTransportNotPermittedError } from "./mcp/index.js";
|
|
23
23
|
//# sourceMappingURL=index.js.map
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { convertMcpContentBlock, mcpResultToContent, MCP_MAX_OUTPUT_CHARS, MCP_M
|
|
|
8
8
|
export { mcpToolProvider, wrapMcpTool } from "./provider.ts";
|
|
9
9
|
export { mcpCapability } from "./capability.ts";
|
|
10
10
|
export type { MCPCapabilityOptions } from "./capability.ts";
|
|
11
|
-
export { serverFromConfig, mcpOAuthSettings, mcpServersCapability, createMcpServers, DEFAULT_RECONNECT_POLICY, McpTransportNotPermittedError } from "./manager.ts";
|
|
11
|
+
export { serverFromConfig, mcpOAuthSettings, mcpServersCapability, createMcpServers, assertMcpTransportsPermitted, DEFAULT_RECONNECT_POLICY, McpTransportNotPermittedError } from "./manager.ts";
|
|
12
12
|
export type { McpCredential, McpCredentialProvider, McpCredentialRequest } from "./credentials.ts";
|
|
13
13
|
export type { McpServerStatus, McpTransportKind, McpServerView, McpServersHandle, McpServersCapabilityOptions, ServerFromConfigOptions, McpTransportFactory, McpStatusListener, ReconnectPolicy, KeepAlivePolicy, McpTimer, } from "./manager.ts";
|
|
14
14
|
export { createMcpAuthTool, MCP_OAUTH_AUTHORIZATION_URL_UPDATE } from "./auth-tool.ts";
|
package/dist/mcp/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { qualifyMcpToolName, sanitizeMcpNamePart, isMcpToolName } from "./tool-n
|
|
|
4
4
|
export { convertMcpContentBlock, mcpResultToContent, MCP_MAX_OUTPUT_CHARS, MCP_MAX_IMAGE_PART_BYTES } from "./output.js";
|
|
5
5
|
export { mcpToolProvider, wrapMcpTool } from "./provider.js";
|
|
6
6
|
export { mcpCapability } from "./capability.js";
|
|
7
|
-
export { serverFromConfig, mcpOAuthSettings, mcpServersCapability, createMcpServers, DEFAULT_RECONNECT_POLICY, McpTransportNotPermittedError } from "./manager.js";
|
|
7
|
+
export { serverFromConfig, mcpOAuthSettings, mcpServersCapability, createMcpServers, assertMcpTransportsPermitted, DEFAULT_RECONNECT_POLICY, McpTransportNotPermittedError } from "./manager.js";
|
|
8
8
|
export { createMcpAuthTool, MCP_OAUTH_AUTHORIZATION_URL_UPDATE } from "./auth-tool.js";
|
|
9
9
|
export { MockMCPTransport } from "./mock-transport.js";
|
|
10
10
|
export { mcpStdioTransport, mcpStreamableHttpTransport, mergeStdioEnv, isTerminalTransportError, buildMcpHttpHeaders, } from "./sdk-transport.js";
|
package/dist/mcp/manager.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { MCPTool, MCPTransport } from "./types.ts";
|
|
|
3
3
|
import type { McpOAuthClientSettings, McpOAuthService } from "./oauth/index.ts";
|
|
4
4
|
import type { Capability, ToolProvider } from "../index.ts";
|
|
5
5
|
import type { EventSink } from "../events/index.ts";
|
|
6
|
-
import type
|
|
6
|
+
import { type McpServerConfig } from "../config/schema.ts";
|
|
7
7
|
import type { McpCredential, McpCredentialProvider } from "./credentials.ts";
|
|
8
8
|
export type McpServerStatus = "pending" | "connected" | "failed" | "disabled" | "needs-auth";
|
|
9
9
|
/** How a server is reached. `stdio` is a CHILD PROCESS of the host; `http` is a network call. */
|
|
@@ -70,7 +70,7 @@ export interface ServerFromConfigOptions {
|
|
|
70
70
|
/** A provider's answer for this connect. Takes the place of the OAuth service. */
|
|
71
71
|
readonly credential?: McpCredential;
|
|
72
72
|
}
|
|
73
|
-
export declare function serverFromConfig(name: string,
|
|
73
|
+
export declare function serverFromConfig(name: string, rawConfig: McpServerConfig, opts?: ServerFromConfigOptions): TransportMCPServer;
|
|
74
74
|
/** The OAuth client/scopes a server config pins (Codex `.mcp.json` `oauth` / `scopes`). */
|
|
75
75
|
export declare function mcpOAuthSettings(config: McpServerConfig): McpOAuthClientSettings;
|
|
76
76
|
export interface McpServersCapabilityOptions {
|
|
@@ -117,6 +117,14 @@ export interface McpServersHandle {
|
|
|
117
117
|
connect(ctx: McpConnectContext): Promise<void>;
|
|
118
118
|
shutdown(): Promise<void>;
|
|
119
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Refuse, up front, any server this host does not offer a transport for.
|
|
122
|
+
*
|
|
123
|
+
* A server switched off in configuration is none of this rule's business: `enabled: false` is
|
|
124
|
+
* how one configuration file serves both a laptop and a server, and rejecting it would take
|
|
125
|
+
* that away for no gain — a disabled server spawns nothing.
|
|
126
|
+
*/
|
|
127
|
+
export declare function assertMcpTransportsPermitted(configs: Record<string, McpServerConfig>, allowed: readonly McpTransportKind[] | undefined): void;
|
|
120
128
|
/**
|
|
121
129
|
* The controller set behind a group of configured servers — buildable on its own so a HARNESS
|
|
122
130
|
* can hold one set of connections for every session it serves (`HarnessParts.mcpServers`), or a session can
|
package/dist/mcp/manager.js
CHANGED
|
@@ -3,6 +3,7 @@ import { mcpStdioTransport, mcpStreamableHttpTransport } from "./sdk-transport.j
|
|
|
3
3
|
import { mcpToolProvider } from "./provider.js";
|
|
4
4
|
import { qualifyMcpToolName } from "./tool-naming.js";
|
|
5
5
|
import { createMcpAuthTool } from "./auth-tool.js";
|
|
6
|
+
import { McpServerConfigSchema } from "../config/schema.js";
|
|
6
7
|
/**
|
|
7
8
|
* Raised when a configured server asks for a transport its host does not offer.
|
|
8
9
|
*
|
|
@@ -61,7 +62,32 @@ const REAL_TIMER = {
|
|
|
61
62
|
clearTimeout: (handle) => clearTimeout(handle),
|
|
62
63
|
};
|
|
63
64
|
const DEFAULT_CACHE_TOOLS = true;
|
|
64
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Apply the config schema to one server entry.
|
|
67
|
+
*
|
|
68
|
+
* The type says `McpServerConfig`, but hosts pass JSON from their own settings straight through
|
|
69
|
+
* (`{ command, args }`, `{ type: "http", url }`), so `transport` cannot be assumed to be set here.
|
|
70
|
+
* Parsing an already-parsed config changes nothing. An invalid entry comes back with `error` and
|
|
71
|
+
* a placeholder config, so it can fail alone instead of taking its siblings down.
|
|
72
|
+
*/
|
|
73
|
+
function normalizeServerConfig(name, raw) {
|
|
74
|
+
const parsed = McpServerConfigSchema.safeParse(raw);
|
|
75
|
+
if (parsed.success)
|
|
76
|
+
return { config: parsed.data };
|
|
77
|
+
const issues = parsed.error.issues.map((issue) => (issue.path.length > 0 ? `${issue.path.join(".")}: ${issue.message}` : issue.message));
|
|
78
|
+
const entry = (typeof raw === "object" && raw !== null ? raw : {});
|
|
79
|
+
return {
|
|
80
|
+
config: {
|
|
81
|
+
transport: entry["command"] === undefined && entry["url"] !== undefined ? "http" : "stdio",
|
|
82
|
+
...(entry["enabled"] === false ? { enabled: false } : {}),
|
|
83
|
+
},
|
|
84
|
+
error: `MCP server "${name}" has an invalid configuration: ${issues.join("; ")}`,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export function serverFromConfig(name, rawConfig, opts = {}) {
|
|
88
|
+
const { config, error } = normalizeServerConfig(name, rawConfig);
|
|
89
|
+
if (error !== undefined)
|
|
90
|
+
throw new Error(error);
|
|
65
91
|
const transport = opts.transport ?? transportFromConfig(name, config, opts.oauthService, opts.credential);
|
|
66
92
|
const filter = staticFilterFromConfig(config);
|
|
67
93
|
return new TransportMCPServer({
|
|
@@ -145,6 +171,7 @@ function isUnauthorizedLikeError(error) {
|
|
|
145
171
|
class McpServerController {
|
|
146
172
|
name;
|
|
147
173
|
config;
|
|
174
|
+
configError;
|
|
148
175
|
oauthService;
|
|
149
176
|
credentials;
|
|
150
177
|
cacheToolsList;
|
|
@@ -165,6 +192,7 @@ class McpServerController {
|
|
|
165
192
|
constructor(opts) {
|
|
166
193
|
this.name = opts.name;
|
|
167
194
|
this.config = opts.config;
|
|
195
|
+
this.configError = opts.configError;
|
|
168
196
|
this.oauthService = opts.oauthService;
|
|
169
197
|
this.credentials = opts.credentials;
|
|
170
198
|
this.cacheToolsList = opts.cacheToolsList;
|
|
@@ -211,6 +239,11 @@ class McpServerController {
|
|
|
211
239
|
return { serverName: this.name, url: this.config.url, sessionId: this.session?.sessionId ?? "" };
|
|
212
240
|
}
|
|
213
241
|
async attempt(retriedAuth = false) {
|
|
242
|
+
if (this.configError !== undefined) {
|
|
243
|
+
this.setStatus("failed", this.configError);
|
|
244
|
+
this.emitWarning(this.configError);
|
|
245
|
+
return this._status;
|
|
246
|
+
}
|
|
214
247
|
// Attempts can overlap: a manual reconnect() can fire while an in-flight attempt is still
|
|
215
248
|
// awaiting connect(). Every mutation of the shared `this.server` slot is therefore guarded
|
|
216
249
|
// by identity — an attempt only ever publishes/retracts the server IT created, never a
|
|
@@ -459,11 +492,13 @@ function keepAliveOptions(config, defaults) {
|
|
|
459
492
|
* how one configuration file serves both a laptop and a server, and rejecting it would take
|
|
460
493
|
* that away for no gain — a disabled server spawns nothing.
|
|
461
494
|
*/
|
|
462
|
-
function
|
|
495
|
+
export function assertMcpTransportsPermitted(configs, allowed) {
|
|
463
496
|
if (allowed === undefined)
|
|
464
497
|
return;
|
|
465
|
-
for (const [name,
|
|
466
|
-
|
|
498
|
+
for (const [name, raw] of Object.entries(configs)) {
|
|
499
|
+
const { config, error } = normalizeServerConfig(name, raw);
|
|
500
|
+
// An invalid entry never starts, and its transport is only a guess: it fails on its own.
|
|
501
|
+
if (error !== undefined || config.enabled === false)
|
|
467
502
|
continue;
|
|
468
503
|
if (!allowed.includes(config.transport)) {
|
|
469
504
|
throw new McpTransportNotPermittedError(name, config.transport, allowed);
|
|
@@ -483,24 +518,28 @@ function assertTransportsPermitted(configs, allowed) {
|
|
|
483
518
|
* more warning in a stream, so it is raised before a single controller exists.
|
|
484
519
|
*/
|
|
485
520
|
export function createMcpServers(configs, options = {}) {
|
|
486
|
-
|
|
521
|
+
assertMcpTransportsPermitted(configs, options.allowedTransports);
|
|
487
522
|
const listeners = new Set();
|
|
488
523
|
const notify = (view) => {
|
|
489
524
|
for (const listener of listeners)
|
|
490
525
|
listener(view);
|
|
491
526
|
};
|
|
492
|
-
const controllers = Object.entries(configs).map(([name,
|
|
493
|
-
name,
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
527
|
+
const controllers = Object.entries(configs).map(([name, raw]) => {
|
|
528
|
+
const { config, error } = normalizeServerConfig(name, raw);
|
|
529
|
+
return new McpServerController({
|
|
530
|
+
name,
|
|
531
|
+
config,
|
|
532
|
+
...(error !== undefined ? { configError: error } : {}),
|
|
533
|
+
...(options.oauthService !== undefined ? { oauthService: options.oauthService } : {}),
|
|
534
|
+
...(options.credentials !== undefined ? { credentials: options.credentials } : {}),
|
|
535
|
+
cacheToolsList: options.cacheToolsList ?? DEFAULT_CACHE_TOOLS,
|
|
536
|
+
...(options.transportFactory !== undefined ? { transportFactory: options.transportFactory } : {}),
|
|
537
|
+
...(options.reconnectPolicy !== undefined ? { reconnectPolicy: options.reconnectPolicy } : {}),
|
|
538
|
+
...keepAliveOptions(config, options.keepAlive),
|
|
539
|
+
onStatusChange: notify,
|
|
540
|
+
timer: options.timer ?? REAL_TIMER,
|
|
541
|
+
});
|
|
542
|
+
});
|
|
504
543
|
const byName = new Map(controllers.map((c) => [c.name, c]));
|
|
505
544
|
let shuttingDown;
|
|
506
545
|
const shutdown = async () => {
|
|
@@ -137,10 +137,11 @@ export class LlmAutoApprover {
|
|
|
137
137
|
const request = {
|
|
138
138
|
system: this.system(),
|
|
139
139
|
messages: [{ role: "user", content: [{ type: "text", text: userText }], timestamp: Date.now() }],
|
|
140
|
-
// No thinking
|
|
141
|
-
//
|
|
142
|
-
//
|
|
143
|
-
|
|
140
|
+
// No thinking, so tokens aren't spent reasoning. No temperature either: providers disagree
|
|
141
|
+
// on what they accept (Mistral rejects 0 without top_p 1), and a request refused here
|
|
142
|
+
// silently demotes `auto` to asking. cacheRetention enables prompt caching of the shared
|
|
143
|
+
// system + transcript prefix across stages/calls.
|
|
144
|
+
params: { maxTokens },
|
|
144
145
|
providerOptions: { cacheRetention: "long" },
|
|
145
146
|
};
|
|
146
147
|
const message = await completeWithRetry(model, request, { signal }, CLASSIFIER_RETRY_POLICY);
|