@agent-vm/mcp-portal 0.0.76 → 0.0.77
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/bin/mcp-portal.js +4 -4
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +4 -4
- package/dist/index.d.ts +39 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -3
- package/dist/mcp-proxy/index.d.ts +2 -2
- package/dist/mcp-proxy/index.js +1 -1
- package/dist/{portal-core-BPSvDGvi.js → portal-core-CDuWxYvB.js} +26 -17
- package/dist/portal-core-CDuWxYvB.js.map +1 -0
- package/dist/{portal-core-CZQI7Ob6.d.ts → portal-core-CF0bfgCX.d.ts} +19 -2
- package/dist/portal-core-CF0bfgCX.d.ts.map +1 -0
- package/dist/{portal-session-DG2CUjIo.d.ts → portal-session-B7no2T4L.d.ts} +17 -2
- package/dist/{portal-session-DG2CUjIo.d.ts.map → portal-session-B7no2T4L.d.ts.map} +1 -1
- package/dist/{portal-tools-DKci1szO.js → portal-tools-CtFO3ruN.js} +25 -8
- package/dist/portal-tools-CtFO3ruN.js.map +1 -0
- package/dist/{resolve-agent-identity-FQL02YdW.d.ts → resolve-agent-identity-ChAD0AFH.d.ts} +3 -3
- package/dist/{resolve-agent-identity-FQL02YdW.d.ts.map → resolve-agent-identity-ChAD0AFH.d.ts.map} +1 -1
- package/dist/{resolve-agent-identity-DnC_Pmnh.js → resolve-agent-identity-EEpzTBFI.js} +3 -3
- package/dist/{resolve-agent-identity-DnC_Pmnh.js.map → resolve-agent-identity-EEpzTBFI.js.map} +1 -1
- package/dist/{serve-command-CV1s-Eln.js → serve-command-Dsak3REg.js} +4 -4
- package/dist/{serve-command-CV1s-Eln.js.map → serve-command-Dsak3REg.js.map} +1 -1
- package/dist/{upstream-mcp-client-runtime-DbPkS6Rk.js → upstream-mcp-client-runtime-BNF9xPCw.js} +59 -11
- package/dist/upstream-mcp-client-runtime-BNF9xPCw.js.map +1 -0
- package/dist/upstream-response-middleware-1MZnAD9C.d.ts.map +1 -1
- package/dist/{upstream-response-middleware-BjUWZ2G8.js → upstream-response-middleware-CpMgDGMh.js} +53 -2
- package/dist/upstream-response-middleware-CpMgDGMh.js.map +1 -0
- package/package.json +3 -3
- package/dist/portal-core-BPSvDGvi.js.map +0 -1
- package/dist/portal-core-CZQI7Ob6.d.ts.map +0 -1
- package/dist/portal-tools-DKci1szO.js.map +0 -1
- package/dist/upstream-mcp-client-runtime-DbPkS6Rk.js.map +0 -1
- package/dist/upstream-response-middleware-BjUWZ2G8.js.map +0 -1
package/dist/bin/mcp-portal.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { a as portalToolRecordSchema } from "../zod-schema-loader-yNekKNpm.js";
|
|
3
|
-
import { t as createUpstreamMcpClientRuntime } from "../upstream-mcp-client-runtime-
|
|
4
|
-
import { i as resolveUpstreamServers, n as createPortalCore } from "../portal-core-
|
|
3
|
+
import { t as createUpstreamMcpClientRuntime } from "../upstream-mcp-client-runtime-BNF9xPCw.js";
|
|
4
|
+
import { i as resolveUpstreamServers, n as createPortalCore } from "../portal-core-CDuWxYvB.js";
|
|
5
5
|
import { t as generateTypescriptCatalogArtifact } from "../typescript-artifact-BVLt3Ifd.js";
|
|
6
6
|
import { n as deriveAgentBearerToken, r as formatMasterKeyFingerprint, t as decodePortalMasterKey } from "../agent-bearer-token-DCtpDPCZ.js";
|
|
7
|
-
import { i as resolveAgentHmacKeys, n as createPortalApprovalVerifier, t as createPortalAgentRuntimeRecords } from "../resolve-agent-identity-
|
|
8
|
-
import { c as resolveSecretValue, i as deriveApprovalHmacKeysFromMasterKey, n as buildProfilePolicyMaps, o as parsePortalServerCliArgs, r as createServeSecretResolver, s as startPortalServer } from "../serve-command-
|
|
7
|
+
import { i as resolveAgentHmacKeys, n as createPortalApprovalVerifier, t as createPortalAgentRuntimeRecords } from "../resolve-agent-identity-EEpzTBFI.js";
|
|
8
|
+
import { c as resolveSecretValue, i as deriveApprovalHmacKeysFromMasterKey, n as buildProfilePolicyMaps, o as parsePortalServerCliArgs, r as createServeSecretResolver, s as startPortalServer } from "../serve-command-Dsak3REg.js";
|
|
9
9
|
import { t as parseHmacKeysFromEnv } from "../hmac-env-B4shpRRB.js";
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
import { loadMcpConfig, loadMcpPortalConfig } from "@agent-vm/config-contracts";
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as PortalHttpAuditEvent, n as PortalApprovalAuditEvent } from "../resolve-agent-identity-
|
|
1
|
+
import { L as PortalToolSelector } from "../portal-session-B7no2T4L.js";
|
|
2
|
+
import { f as PortalHttpAuditEvent, n as PortalApprovalAuditEvent } from "../resolve-agent-identity-ChAD0AFH.js";
|
|
3
3
|
import { McpPortalAgentConfig, McpPortalConfig, SecretValue } from "@agent-vm/config-contracts";
|
|
4
4
|
import { SecretResolver, createSecretResolver, resolveServiceAccountToken } from "@agent-vm/secret-management";
|
|
5
5
|
import { serve } from "@hono/node-server";
|
package/dist/cli/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as handlePortalServerError, i as deriveApprovalHmacKeysFromMasterKey, n as buildProfilePolicyMaps, o as parsePortalServerCliArgs, r as createServeSecretResolver, s as startPortalServer, t as applyAgentOverrides } from "../serve-command-
|
|
1
|
+
import { a as handlePortalServerError, i as deriveApprovalHmacKeysFromMasterKey, n as buildProfilePolicyMaps, o as parsePortalServerCliArgs, r as createServeSecretResolver, s as startPortalServer, t as applyAgentOverrides } from "../serve-command-Dsak3REg.js";
|
|
2
2
|
export { applyAgentOverrides, buildProfilePolicyMaps, createServeSecretResolver, deriveApprovalHmacKeysFromMasterKey, handlePortalServerError, parsePortalServerCliArgs, startPortalServer };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as PortalToolRecord, s as JsonObject } from "../catalog-types-BVuB4Ynx.js";
|
|
2
|
-
import {
|
|
3
|
-
import { A as PortalToolSuccess, C as PortalCallUpstreamTool, D as PortalToolResult, E as PortalToolHandlers, M as createPortalToolHandlers, N as portalToolInputSchemas, O as PortalToolResultMap, S as PortalBatchResult, T as PortalToolHandlerCall, _ as createPortalCore, a as PortalCore, b as PortalBatchDiagnostic, c as PortalCoreEvent, d as PortalCoreResult, f as PortalCoreRuntime, g as collectPortalCoreResult, h as PortalCoreToolName, i as PortalAuditEvent, j as PortalUpstreamEvent, k as PortalToolRuntime, l as PortalCoreItemError, m as PortalCoreToolDescriptor, n as PortalAgentScope, o as PortalCoreCollectOptions, p as PortalCoreStreamCall, r as PortalApprovalEvaluator, s as PortalCoreContentBlock, t as CreatePortalCoreProps, u as PortalCoreItemResult, v as listPortalCoreToolDescriptors, w as PortalToolFailure, x as PortalBatchError, y as PortalApprovalCall } from "../portal-core-
|
|
2
|
+
import { L as PortalToolSelector } from "../portal-session-B7no2T4L.js";
|
|
3
|
+
import { A as PortalToolSuccess, C as PortalCallUpstreamTool, D as PortalToolResult, E as PortalToolHandlers, M as createPortalToolHandlers, N as portalToolInputSchemas, O as PortalToolResultMap, S as PortalBatchResult, T as PortalToolHandlerCall, _ as createPortalCore, a as PortalCore, b as PortalBatchDiagnostic, c as PortalCoreEvent, d as PortalCoreResult, f as PortalCoreRuntime, g as collectPortalCoreResult, h as PortalCoreToolName, i as PortalAuditEvent, j as PortalUpstreamEvent, k as PortalToolRuntime, l as PortalCoreItemError, m as PortalCoreToolDescriptor, n as PortalAgentScope, o as PortalCoreCollectOptions, p as PortalCoreStreamCall, r as PortalApprovalEvaluator, s as PortalCoreContentBlock, t as CreatePortalCoreProps, u as PortalCoreItemResult, v as listPortalCoreToolDescriptors, w as PortalToolFailure, x as PortalBatchError, y as PortalApprovalCall } from "../portal-core-CF0bfgCX.js";
|
|
4
4
|
import { S as createUpstreamMcpClientRuntime, r as redactCredentialText, u as NormalizedUpstreamMcpServer } from "../upstream-response-middleware-1MZnAD9C.js";
|
|
5
5
|
import { McpConfig, SecretValue } from "@agent-vm/config-contracts";
|
|
6
6
|
|
package/dist/core/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as redactCredentialText } from "../upstream-response-middleware-
|
|
2
|
-
import { t as createUpstreamMcpClientRuntime } from "../upstream-mcp-client-runtime-
|
|
3
|
-
import { i as resolveUpstreamServers, n as createPortalCore, r as listPortalCoreToolDescriptors, t as collectPortalCoreResult } from "../portal-core-
|
|
4
|
-
import { n as portalToolInputSchemas, r as validatePortalToolArguments, t as createPortalToolHandlers } from "../portal-tools-
|
|
1
|
+
import { n as redactCredentialText } from "../upstream-response-middleware-CpMgDGMh.js";
|
|
2
|
+
import { t as createUpstreamMcpClientRuntime } from "../upstream-mcp-client-runtime-BNF9xPCw.js";
|
|
3
|
+
import { i as resolveUpstreamServers, n as createPortalCore, r as listPortalCoreToolDescriptors, t as collectPortalCoreResult } from "../portal-core-CDuWxYvB.js";
|
|
4
|
+
import { n as portalToolInputSchemas, r as validatePortalToolArguments, t as createPortalToolHandlers } from "../portal-tools-CtFO3ruN.js";
|
|
5
5
|
export { collectPortalCoreResult, createPortalCore, createPortalToolHandlers, createUpstreamMcpClientRuntime, listPortalCoreToolDescriptors, portalToolInputSchemas, redactCredentialText, resolveUpstreamServers, validatePortalToolArguments };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
import { a as safeToolMetadataSchema, c as JsonPrimitive, d as isJsonObject, f as jsonObjectSchema, i as portalToolRecordSchema, l as JsonValue, n as PortalToolRecord, o as JsonArray, p as jsonValueSchema, r as portalToolAnnotationsSchema, s as JsonObject, t as PortalToolAnnotations, u as assertJsonObject } from "./catalog-types-BVuB4Ynx.js";
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as ToolRef, B as portalAgentScopeKey, C as ToolGraph, D as ToolRelationshipType, E as ToolRelationshipEndpoint, F as PortalAgentScopeSource, I as PortalDefaultPolicy, L as PortalToolSelector, M as encodeToolRef, N as PortalAccessPolicyConfig, O as buildToolGraph, P as PortalAgentIdentity, R as ResolvedPortalAccessPolicy, S as SkillGraphInput, T as ToolRelationship, V as resolvePortalAccessPolicy, _ as ToolSchemaSummary, a as PortalSessionManagerOptions, b as summarizeJsonSchema, c as SearchIndex, d as ToolRelationshipHint, f as ToolSearchResult, g as ToolSchemaHintNext, h as ToolSchemaHint, i as PortalSessionManager, j as decodeToolRef, k as ToolIdentity, l as SearchQuery, m as ToolSafetySummary, n as PortalDiscoveryFailure, o as PortalSessionRuntime, p as createSearchIndex, r as PortalSession, s as createPortalSessionManager, t as PortalCatalogSnapshot, u as SearchResultSet, v as ToolSummary, w as ToolGraphInput, x as ScopedSkillGraphEntry, y as createToolSummary, z as createPortalAgentIdentity } from "./portal-session-B7no2T4L.js";
|
|
3
3
|
import { S as createUpstreamMcpClientRuntime, _ as UpstreamMcpProgress, a as redactThrownError, b as UpstreamToolCall, c as toRedactedJsonValue, d as RemoteUpstreamMcpServer, f as StdioUpstreamMcpServer, g as UpstreamMcpCloseErrorContext, h as UpstreamMcpClientRuntime, i as redactExactCredentialText, l as ListToolsCall, m as UpstreamMcpClientLike, n as isCredentialConfigKey, o as redactUpstreamCatalogValue, p as UpstreamListToolsResult, r as redactCredentialText, s as redactUpstreamResponse, t as RedactionOptions, u as NormalizedUpstreamMcpServer, v as UpstreamMcpRuntimeOptions, x as UpstreamToolEvent, y as UpstreamMcpTransportKind } from "./upstream-response-middleware-1MZnAD9C.js";
|
|
4
4
|
import { a as SchemaValidationUnavailableError, i as PortalValidationResult, n as InputValidationError, o as buildZodValidatorFromJsonSchema, r as InputValidationIssue, t as BuiltZodValidator } from "./zod-schema-loader-DLGQpYFD.js";
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
//#region src/upstream-mcp-errors.d.ts
|
|
7
|
+
type UpstreamMcpFailurePhase = 'call_tool' | 'connect' | 'list_tools';
|
|
8
|
+
type UpstreamMcpTransportSummary = {
|
|
9
|
+
readonly argCount: number;
|
|
10
|
+
readonly command: string;
|
|
11
|
+
readonly cwd?: string;
|
|
12
|
+
readonly kind: 'stdio';
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: Exclude<UpstreamMcpTransportKind, 'auto-http' | 'stdio'>;
|
|
15
|
+
readonly url: string;
|
|
16
|
+
};
|
|
17
|
+
interface UpstreamMcpFailureDetails {
|
|
18
|
+
readonly attemptTransport?: Exclude<UpstreamMcpTransportKind, 'auto-http'>;
|
|
19
|
+
readonly causeMessage: string;
|
|
20
|
+
readonly elapsedMs: number;
|
|
21
|
+
readonly hint?: string;
|
|
22
|
+
readonly kind: 'upstream_mcp_failed';
|
|
23
|
+
readonly namespace: string;
|
|
24
|
+
readonly operation: string;
|
|
25
|
+
readonly phase: UpstreamMcpFailurePhase;
|
|
26
|
+
readonly timeoutMs?: number;
|
|
27
|
+
readonly toolName?: string;
|
|
28
|
+
readonly transport: UpstreamMcpTransportSummary;
|
|
29
|
+
}
|
|
30
|
+
declare class UpstreamMcpError extends Error {
|
|
31
|
+
readonly details: UpstreamMcpFailureDetails;
|
|
32
|
+
constructor(details: UpstreamMcpFailureDetails);
|
|
33
|
+
}
|
|
34
|
+
declare function messageFromUnknownError(error: unknown): string;
|
|
35
|
+
declare function isUpstreamMcpError(error: unknown): error is UpstreamMcpError;
|
|
36
|
+
declare function transportSummaryFromServer(server: NormalizedUpstreamMcpServer, attemptTransport?: Exclude<UpstreamMcpTransportKind, 'auto-http'>): UpstreamMcpTransportSummary;
|
|
37
|
+
declare function createUpstreamMcpError(details: Omit<UpstreamMcpFailureDetails, 'hint' | 'kind'>): UpstreamMcpError;
|
|
38
|
+
declare function upstreamMcpFailureDetailsFromUnknown(error: unknown): UpstreamMcpFailureDetails | null;
|
|
39
|
+
declare function formatUpstreamMcpFailureMessage(details: UpstreamMcpFailureDetails): string;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { BuiltZodValidator, InputValidationError, InputValidationIssue, JsonArray, JsonObject, JsonPrimitive, JsonValue, ListToolsCall, NormalizedUpstreamMcpServer, PortalAccessPolicyConfig, PortalAgentIdentity, PortalAgentScopeSource, PortalCatalogSnapshot, PortalDefaultPolicy, PortalDiscoveryFailure, PortalSession, PortalSessionManager, PortalSessionManagerOptions, PortalSessionRuntime, PortalToolAnnotations, PortalToolRecord, PortalToolSelector, PortalValidationResult, RedactionOptions, RemoteUpstreamMcpServer, ResolvedPortalAccessPolicy, SchemaValidationUnavailableError, ScopedSkillGraphEntry, SearchIndex, SearchQuery, SearchResultSet, SkillGraphInput, StdioUpstreamMcpServer, ToolGraph, ToolGraphInput, ToolIdentity, ToolRef, ToolRelationship, ToolRelationshipEndpoint, ToolRelationshipHint, ToolRelationshipType, ToolSafetySummary, ToolSchemaHint, ToolSchemaHintNext, ToolSchemaSummary, ToolSearchResult, ToolSummary, UpstreamListToolsResult, UpstreamMcpClientLike, UpstreamMcpClientRuntime, UpstreamMcpCloseErrorContext, UpstreamMcpError, UpstreamMcpFailureDetails, UpstreamMcpFailurePhase, UpstreamMcpProgress, UpstreamMcpRuntimeOptions, UpstreamMcpTransportKind, UpstreamMcpTransportSummary, UpstreamToolCall, UpstreamToolEvent, assertJsonObject, buildToolGraph, buildZodValidatorFromJsonSchema, createPortalAgentIdentity, createPortalSessionManager, createSearchIndex, createToolSummary, createUpstreamMcpClientRuntime, createUpstreamMcpError, decodeToolRef, encodeToolRef, formatUpstreamMcpFailureMessage, isCredentialConfigKey, isJsonObject, isUpstreamMcpError, jsonObjectSchema, jsonValueSchema, messageFromUnknownError, portalAgentScopeKey, portalToolAnnotationsSchema, portalToolRecordSchema, redactCredentialText, redactExactCredentialText, redactThrownError, redactUpstreamCatalogValue, redactUpstreamResponse, resolvePortalAccessPolicy, safeToolMetadataSchema, summarizeJsonSchema, toRedactedJsonValue, transportSummaryFromServer, upstreamMcpFailureDetailsFromUnknown };
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/upstream-mcp-errors.ts"],"mappings":";;;;;;KAKY,uBAAA;AAAA,KAEA,2BAAA;EAAA,SAEA,QAAA;EAAA,SACA,OAAA;EAAA,SACA,GAAA;EAAA,SACA,IAAA;AAAA;EAAA,SAGA,IAAA,EAAM,OAAA,CAAQ,wBAAA;EAAA,SACd,GAAA;AAAA;AAAA,UAGK,yBAAA;EAAA,SACP,gBAAA,GAAmB,OAAA,CAAQ,wBAAA;EAAA,SAC3B,YAAA;EAAA,SACA,SAAA;EAAA,SACA,IAAA;EAAA,SACA,IAAA;EAAA,SACA,SAAA;EAAA,SACA,SAAA;EAAA,SACA,KAAA,EAAO,uBAAA;EAAA,SACP,SAAA;EAAA,SACA,QAAA;EAAA,SACA,SAAA,EAAW,2BAAA;AAAA;AAAA,cAGR,gBAAA,SAAyB,KAAA;EAAA,SAC5B,OAAA,EAAS,yBAAA;cAEN,OAAA,EAAS,yBAAA;AAAA;AAAA,iBAON,uBAAA,CAAwB,KAAA;AAAA,iBAUxB,kBAAA,CAAmB,KAAA,YAAiB,KAAA,IAAS,gBAAA;AAAA,iBAI7C,0BAAA,CACf,MAAA,EAAQ,2BAAA,EACR,gBAAA,GAAmB,OAAA,CAAQ,wBAAA,iBACzB,2BAAA;AAAA,iBAkCa,sBAAA,CACf,OAAA,EAAS,IAAA,CAAK,yBAAA,qBACZ,gBAAA;AAAA,iBASa,oCAAA,CACf,KAAA,YACE,yBAAA;AAAA,iBAIa,+BAAA,CAAgC,OAAA,EAAS,yBAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as portalToolRecordSchema, c as isJsonObject, i as portalToolAnnotationsSchema, l as jsonObjectSchema, n as decodeToolRef, o as safeToolMetadataSchema, r as encodeToolRef, s as assertJsonObject, t as buildZodValidatorFromJsonSchema, u as jsonValueSchema } from "./zod-schema-loader-yNekKNpm.js";
|
|
2
|
-
import { a as redactUpstreamCatalogValue, c as
|
|
3
|
-
import { i as createSearchIndex, n as createPortalSessionManager, r as buildToolGraph, t as createUpstreamMcpClientRuntime } from "./upstream-mcp-client-runtime-
|
|
4
|
-
export { assertJsonObject, buildToolGraph, buildZodValidatorFromJsonSchema, createPortalAgentIdentity, createPortalSessionManager, createSearchIndex, createToolSummary, createUpstreamMcpClientRuntime, decodeToolRef, encodeToolRef, isCredentialConfigKey, isJsonObject, jsonObjectSchema, jsonValueSchema, portalAgentScopeKey, portalToolAnnotationsSchema, portalToolRecordSchema, redactCredentialText, redactExactCredentialText, redactThrownError, redactUpstreamCatalogValue, redactUpstreamResponse, resolvePortalAccessPolicy, safeToolMetadataSchema, summarizeJsonSchema, toRedactedJsonValue };
|
|
2
|
+
import { _ as createPortalAgentIdentity, a as redactUpstreamCatalogValue, c as UpstreamMcpError, d as isUpstreamMcpError, f as messageFromUnknownError, g as summarizeJsonSchema, h as createToolSummary, i as redactThrownError, l as createUpstreamMcpError, m as upstreamMcpFailureDetailsFromUnknown, n as redactCredentialText, o as redactUpstreamResponse, p as transportSummaryFromServer, r as redactExactCredentialText, s as toRedactedJsonValue, t as isCredentialConfigKey, u as formatUpstreamMcpFailureMessage, v as portalAgentScopeKey, y as resolvePortalAccessPolicy } from "./upstream-response-middleware-CpMgDGMh.js";
|
|
3
|
+
import { i as createSearchIndex, n as createPortalSessionManager, r as buildToolGraph, t as createUpstreamMcpClientRuntime } from "./upstream-mcp-client-runtime-BNF9xPCw.js";
|
|
4
|
+
export { UpstreamMcpError, assertJsonObject, buildToolGraph, buildZodValidatorFromJsonSchema, createPortalAgentIdentity, createPortalSessionManager, createSearchIndex, createToolSummary, createUpstreamMcpClientRuntime, createUpstreamMcpError, decodeToolRef, encodeToolRef, formatUpstreamMcpFailureMessage, isCredentialConfigKey, isJsonObject, isUpstreamMcpError, jsonObjectSchema, jsonValueSchema, messageFromUnknownError, portalAgentScopeKey, portalToolAnnotationsSchema, portalToolRecordSchema, redactCredentialText, redactExactCredentialText, redactThrownError, redactUpstreamCatalogValue, redactUpstreamResponse, resolvePortalAccessPolicy, safeToolMetadataSchema, summarizeJsonSchema, toRedactedJsonValue, transportSummaryFromServer, upstreamMcpFailureDetailsFromUnknown };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as PortalCore, c as PortalCoreEvent, m as PortalCoreToolDescriptor, n as PortalAgentScope } from "../portal-core-
|
|
2
|
-
import { a as createPortalApprovalVerifier, c as PortalAgentBearerAuth, d as PortalHttpAppOptions, f as PortalHttpAuditEvent, i as createPortalAgentRuntimeRecords, l as PortalHttpAgentIdentity, n as PortalApprovalAuditEvent, o as createPortalHttpAgentResolver, p as createPortalHttpApp, r as ResolveAgentHmacKeysProps, s as resolveAgentHmacKeys, t as PortalAgentRuntimeRecord, u as PortalHttpApp } from "../resolve-agent-identity-
|
|
1
|
+
import { a as PortalCore, c as PortalCoreEvent, m as PortalCoreToolDescriptor, n as PortalAgentScope } from "../portal-core-CF0bfgCX.js";
|
|
2
|
+
import { a as createPortalApprovalVerifier, c as PortalAgentBearerAuth, d as PortalHttpAppOptions, f as PortalHttpAuditEvent, i as createPortalAgentRuntimeRecords, l as PortalHttpAgentIdentity, n as PortalApprovalAuditEvent, o as createPortalHttpAgentResolver, p as createPortalHttpApp, r as ResolveAgentHmacKeysProps, s as resolveAgentHmacKeys, t as PortalAgentRuntimeRecord, u as PortalHttpApp } from "../resolve-agent-identity-ChAD0AFH.js";
|
|
3
3
|
import { Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
4
4
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
5
|
|
package/dist/mcp-proxy/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as createPortalHttpApp, c as listPortalMcpTools, i as resolveAgentHmacKeys, l as portalMcpToolNames, n as createPortalApprovalVerifier, o as createPortalMcpServer, r as createPortalHttpAgentResolver, s as emitMcpProgress, t as createPortalAgentRuntimeRecords } from "../resolve-agent-identity-
|
|
1
|
+
import { a as createPortalHttpApp, c as listPortalMcpTools, i as resolveAgentHmacKeys, l as portalMcpToolNames, n as createPortalApprovalVerifier, o as createPortalMcpServer, r as createPortalHttpAgentResolver, s as emitMcpProgress, t as createPortalAgentRuntimeRecords } from "../resolve-agent-identity-EEpzTBFI.js";
|
|
2
2
|
export { createPortalAgentRuntimeRecords, createPortalApprovalVerifier, createPortalHttpAgentResolver, createPortalHttpApp, createPortalMcpServer, emitMcpProgress, listPortalMcpTools, portalMcpToolNames, resolveAgentHmacKeys };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { l as jsonObjectSchema } from "./zod-schema-loader-yNekKNpm.js";
|
|
2
|
-
import {
|
|
3
|
-
import { n as createPortalSessionManager } from "./upstream-mcp-client-runtime-
|
|
4
|
-
import { n as portalToolInputSchemas, t as createPortalToolHandlers } from "./portal-tools-
|
|
2
|
+
import { _ as createPortalAgentIdentity, y as resolvePortalAccessPolicy } from "./upstream-response-middleware-CpMgDGMh.js";
|
|
3
|
+
import { n as createPortalSessionManager } from "./upstream-mcp-client-runtime-BNF9xPCw.js";
|
|
4
|
+
import { n as portalToolInputSchemas, t as createPortalToolHandlers } from "./portal-tools-CtFO3ruN.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { mcpConfigToResolvedProviders } from "@agent-vm/config-contracts";
|
|
7
7
|
//#region src/core/provider-runtime.ts
|
|
@@ -43,11 +43,7 @@ const portalCallInputSchema = z.object({
|
|
|
43
43
|
portalApprovalToken: z.string().min(1).optional()
|
|
44
44
|
}).strict();
|
|
45
45
|
function diagnosticsToAuditEvents(diagnostics) {
|
|
46
|
-
return diagnostics.map((diagnostic) => ({
|
|
47
|
-
kind: diagnostic.kind,
|
|
48
|
-
message: diagnostic.message,
|
|
49
|
-
...diagnostic.namespace !== void 0 ? { namespace: diagnostic.namespace } : {}
|
|
50
|
-
}));
|
|
46
|
+
return diagnostics.map((diagnostic) => ({ ...diagnostic }));
|
|
51
47
|
}
|
|
52
48
|
function isUnknownRecord(value) {
|
|
53
49
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -104,11 +100,13 @@ function itemErrorFromPortalResult(result) {
|
|
|
104
100
|
const kind = errorRecord.kind;
|
|
105
101
|
const namespace = errorRecord.namespace;
|
|
106
102
|
const toolName = errorRecord.toolName;
|
|
103
|
+
const upstream = errorRecord.upstream;
|
|
107
104
|
return {
|
|
108
105
|
code: typeof kind === "string" ? kind : "portal_item_failed",
|
|
109
106
|
message: messageFromUnknown(result.error),
|
|
110
107
|
...typeof namespace === "string" ? { namespace } : {},
|
|
111
|
-
...typeof toolName === "string" ? { toolName } : {}
|
|
108
|
+
...typeof toolName === "string" ? { toolName } : {},
|
|
109
|
+
...upstream === void 0 ? {} : { upstream }
|
|
112
110
|
};
|
|
113
111
|
}
|
|
114
112
|
function itemResultFromPortalToolResult(requestId, result) {
|
|
@@ -146,28 +144,39 @@ function batchItemsToCoreResult(props) {
|
|
|
146
144
|
};
|
|
147
145
|
}
|
|
148
146
|
function namespaceDescription(namespaces) {
|
|
149
|
-
return namespaces.length === 0 ? "No upstream MCP namespaces are authorized for this agent scope." : `
|
|
147
|
+
return namespaces.length === 0 ? "No upstream MCP namespaces are authorized for this agent scope." : `Allowed namespaces for this agent: ${namespaces.join(", ")}.`;
|
|
148
|
+
}
|
|
149
|
+
function cloneJsonObject(value) {
|
|
150
|
+
return structuredClone(value);
|
|
151
|
+
}
|
|
152
|
+
function withListNamespaceSchemaDescription(inputSchema, namespaces) {
|
|
153
|
+
const clonedSchema = cloneJsonObject(inputSchema);
|
|
154
|
+
const requests = isUnknownRecord(clonedSchema.properties) ? clonedSchema.properties.requests : void 0;
|
|
155
|
+
const requestItems = isUnknownRecord(requests) ? requests.items : void 0;
|
|
156
|
+
const requestProperties = isUnknownRecord(requestItems) ? requestItems.properties : void 0;
|
|
157
|
+
const namespaceProperty = isUnknownRecord(requestProperties) ? requestProperties.namespaces : void 0;
|
|
158
|
+
if (isUnknownRecord(namespaceProperty)) namespaceProperty.description = namespaces.length === 0 ? "Optional namespace filter. No upstream MCP namespaces are authorized for this agent. Omit to list all currently discovered authorized namespaces." : `Optional namespace filter. Allowed namespaces for this agent: ${namespaces.join(", ")}. Omit to list all currently discovered authorized namespaces.`;
|
|
159
|
+
return clonedSchema;
|
|
150
160
|
}
|
|
151
161
|
function listPortalCoreToolDescriptors(namespaces = []) {
|
|
152
|
-
const scopeDescription = namespaceDescription(namespaces);
|
|
153
162
|
return [
|
|
154
163
|
{
|
|
155
|
-
description: `List authorized MCP namespaces and compact tool summaries. ${
|
|
156
|
-
inputSchema: portalToolInputSchemas.mcp_portal_list,
|
|
164
|
+
description: `List authorized MCP namespaces and compact tool summaries. ${namespaceDescription(namespaces)}`,
|
|
165
|
+
inputSchema: withListNamespaceSchemaDescription(portalToolInputSchemas.mcp_portal_list, namespaces),
|
|
157
166
|
name: "mcp_portal_list"
|
|
158
167
|
},
|
|
159
168
|
{
|
|
160
|
-
description:
|
|
169
|
+
description: "Search the caller scoped MCP Portal index.",
|
|
161
170
|
inputSchema: portalToolInputSchemas.mcp_portal_search,
|
|
162
171
|
name: "mcp_portal_search"
|
|
163
172
|
},
|
|
164
173
|
{
|
|
165
|
-
description:
|
|
174
|
+
description: "Describe exact MCP tool schemas and optional TypeScript/Zod helpers.",
|
|
166
175
|
inputSchema: portalToolInputSchemas.mcp_portal_describe,
|
|
167
176
|
name: "mcp_portal_describe"
|
|
168
177
|
},
|
|
169
178
|
{
|
|
170
|
-
description:
|
|
179
|
+
description: "Validate and call an authorized upstream MCP tool by namespace and toolName.",
|
|
171
180
|
inputSchema: portalToolInputSchemas.mcp_portal_call,
|
|
172
181
|
name: "mcp_portal_call"
|
|
173
182
|
}
|
|
@@ -413,4 +422,4 @@ function createPortalCore(props) {
|
|
|
413
422
|
//#endregion
|
|
414
423
|
export { resolveUpstreamServers as i, createPortalCore as n, listPortalCoreToolDescriptors as r, collectPortalCoreResult as t };
|
|
415
424
|
|
|
416
|
-
//# sourceMappingURL=portal-core-
|
|
425
|
+
//# sourceMappingURL=portal-core-CDuWxYvB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portal-core-CDuWxYvB.js","names":[],"sources":["../src/core/provider-runtime.ts","../src/core/portal-core.ts"],"sourcesContent":["import {\n\tmcpConfigToResolvedProviders,\n\ttype McpConfig,\n\ttype ResolvedMcpProvider,\n\ttype SecretValue,\n} from '@agent-vm/config-contracts';\n\nimport type { NormalizedUpstreamMcpServer } from '../upstream-mcp-client-runtime.js';\n\nexport interface ResolveUpstreamServersProps {\n\treadonly config: McpConfig;\n\treadonly resolveSecret: (secret: SecretValue) => Promise<string>;\n}\n\nasync function resolveProviderSecretRecord(\n\tsecrets: Readonly<Record<string, SecretValue>>,\n\tresolveSecret: (secret: SecretValue) => Promise<string>,\n): Promise<Readonly<Record<string, string>>> {\n\tconst resolvedEntries = await Promise.all(\n\t\tObject.entries(secrets).map(\n\t\t\tasync ([name, secret]) => [name, await resolveSecret(secret)] as const,\n\t\t),\n\t);\n\treturn Object.fromEntries(resolvedEntries);\n}\n\nasync function resolveUpstreamServer(\n\tprovider: ResolvedMcpProvider,\n\tresolveSecret: (secret: SecretValue) => Promise<string>,\n): Promise<NormalizedUpstreamMcpServer> {\n\tif (provider.transport === 'stdio') {\n\t\treturn {\n\t\t\targs: provider.args,\n\t\t\tcommand: provider.command,\n\t\t\t...(provider.cwd === undefined ? {} : { cwd: provider.cwd }),\n\t\t\tenv: await resolveProviderSecretRecord(provider.env, resolveSecret),\n\t\t\tnamespace: provider.namespace,\n\t\t\ttransport: 'stdio',\n\t\t};\n\t}\n\n\treturn {\n\t\theaders: await resolveProviderSecretRecord(provider.headers, resolveSecret),\n\t\tnamespace: provider.namespace,\n\t\ttransport: provider.transport,\n\t\turl: provider.url,\n\t};\n}\n\nexport async function resolveUpstreamServers(\n\tprops: ResolveUpstreamServersProps,\n): Promise<readonly NormalizedUpstreamMcpServer[]> {\n\treturn await Promise.all(\n\t\tmcpConfigToResolvedProviders(props.config).map(async (provider) =>\n\t\t\tresolveUpstreamServer(provider, props.resolveSecret),\n\t\t),\n\t);\n}\n","import type { Tool } from '@modelcontextprotocol/sdk/types.js';\nimport { z } from 'zod';\n\nimport { jsonObjectSchema } from '../json-schema.js';\nimport {\n\tcreatePortalAgentIdentity,\n\tresolvePortalAccessPolicy,\n\ttype PortalAccessPolicyConfig,\n\ttype PortalAgentIdentity,\n\ttype PortalAgentScopeSource,\n} from '../portal-access-policy.js';\nimport {\n\tcreatePortalSessionManager,\n\ttype PortalSessionManager,\n\ttype PortalSessionRuntime,\n} from '../portal-session.js';\nimport type { SkillGraphInput } from '../tool-graph.js';\nimport {\n\tcreatePortalToolHandlers,\n\tportalToolInputSchemas,\n\ttype PortalApprovalCall,\n\ttype PortalBatchDiagnostic,\n\ttype PortalBatchResult,\n\ttype PortalToolResult,\n\ttype PortalToolRuntime,\n} from './portal-tools.js';\n\nexport type PortalAgentScope = PortalAgentIdentity;\n\nexport type PortalCoreToolName =\n\t| 'mcp_portal_list'\n\t| 'mcp_portal_search'\n\t| 'mcp_portal_describe'\n\t| 'mcp_portal_call';\n\nexport interface PortalAuditEvent {\n\treadonly causeMessage?: string;\n\treadonly elapsedMs?: number;\n\treadonly hint?: string;\n\treadonly kind: string;\n\treadonly message: string;\n\treadonly namespace?: string;\n\treadonly operation?: string;\n\treadonly phase?: string;\n\treadonly timeoutMs?: number;\n\treadonly toolName?: string;\n\treadonly transport?: unknown;\n}\n\nexport interface PortalCoreResult {\n\treadonly auditEvents?: readonly PortalAuditEvent[];\n\treadonly content: readonly PortalCoreContentBlock[];\n\treadonly items: readonly PortalCoreItemResult[];\n\treadonly structuredContent?: unknown;\n}\n\nexport type PortalCoreItemResult =\n\t| {\n\t\t\treadonly content: readonly PortalCoreContentBlock[];\n\t\t\treadonly requestId: string;\n\t\t\treadonly status: 'success';\n\t\t\treadonly structuredContent?: unknown;\n\t }\n\t| {\n\t\t\treadonly error: PortalCoreItemError;\n\t\t\treadonly requestId: string;\n\t\t\treadonly status: 'failed';\n\t };\n\nexport interface PortalCoreItemError {\n\treadonly code: string;\n\treadonly message: string;\n\treadonly namespace?: string;\n\treadonly toolName?: string;\n\treadonly upstream?: unknown;\n}\n\nexport type PortalCoreContentBlock =\n\t| { readonly text: string; readonly type: 'text' }\n\t| { readonly type: 'json'; readonly value: unknown };\n\nexport type PortalCoreEvent =\n\t| {\n\t\t\treadonly kind: 'started';\n\t\t\treadonly toolName: PortalCoreToolName;\n\t }\n\t| {\n\t\t\treadonly kind: 'item_started';\n\t\t\treadonly namespace?: string;\n\t\t\treadonly requestId: string;\n\t\t\treadonly toolName?: string;\n\t }\n\t| {\n\t\t\treadonly kind: 'progress';\n\t\t\treadonly message?: string;\n\t\t\treadonly progress?: number;\n\t\t\treadonly requestId?: string;\n\t\t\treadonly total?: number;\n\t }\n\t| {\n\t\t\treadonly kind: 'upstream_notification';\n\t\t\treadonly method: string;\n\t\t\treadonly params: unknown;\n\t\t\treadonly requestId?: string;\n\t }\n\t| {\n\t\t\treadonly content: PortalCoreContentBlock;\n\t\t\treadonly kind: 'partial_content';\n\t\t\treadonly requestId?: string;\n\t }\n\t| {\n\t\t\treadonly kind: 'item_completed';\n\t\t\treadonly requestId: string;\n\t\t\treadonly result: Extract<PortalCoreItemResult, { readonly status: 'success' }>;\n\t }\n\t| {\n\t\t\treadonly error: PortalCoreItemError;\n\t\t\treadonly kind: 'item_failed';\n\t\t\treadonly requestId: string;\n\t }\n\t| {\n\t\t\treadonly kind: 'completed';\n\t\t\treadonly result: PortalCoreResult;\n\t }\n\t| {\n\t\t\treadonly error: unknown;\n\t\t\treadonly kind: 'failed';\n\t };\n\nexport interface PortalCoreStreamCall {\n\treadonly input: unknown;\n\treadonly scope: PortalAgentScope;\n\treadonly signal?: AbortSignal;\n\treadonly toolName: PortalCoreToolName;\n}\n\nconst maxQueuedPortalCoreEvents = 1_024;\nconst maxPortalCoreEventBytes = 256 * 1_024;\n\nexport interface PortalCoreCollectOptions {\n\treadonly onEvent?: (event: PortalCoreEvent) => Promise<void> | void;\n}\n\nexport interface PortalCoreRuntime extends PortalSessionRuntime {\n\treadonly callUpstreamTool: PortalToolRuntime['callUpstreamTool'];\n}\n\nexport type PortalApprovalEvaluator = NonNullable<PortalToolRuntime['approval']>;\n\ninterface CreatePortalCoreBaseProps {\n\treadonly accessPolicy: PortalAccessPolicyConfig;\n\treadonly catalogTtlMs: number;\n\treadonly runtime: PortalCoreRuntime;\n\treadonly skills?: readonly SkillGraphInput[];\n\treadonly upstreamNamespaces: readonly string[];\n}\n\nexport type CreatePortalCoreProps =\n\t| (CreatePortalCoreBaseProps & {\n\t\t\treadonly approval: PortalApprovalEvaluator;\n\t\t\treadonly approvalTrustBoundary?: never;\n\t })\n\t| (CreatePortalCoreBaseProps & {\n\t\t\treadonly approval?: never;\n\t\t\treadonly approvalTrustBoundary: 'openclaw-before-tool-call-hook';\n\t });\n\nexport interface PortalCore {\n\treadonly approval: {\n\t\treadonly evaluateCalls: (\n\t\t\tcalls: readonly PortalApprovalCall[],\n\t\t\tscope: PortalAgentScope,\n\t\t\tapprovalToken: string | undefined,\n\t\t) => ReturnType<PortalApprovalEvaluator>;\n\t};\n\treadonly callStream: (call: PortalCoreStreamCall) => AsyncIterable<PortalCoreEvent>;\n\treadonly close: () => Promise<void>;\n\treadonly collectPortalCoreResult: typeof collectPortalCoreResult;\n\treadonly createAgentScope: (input: {\n\t\treadonly agentId: string;\n\t\treadonly agentScopeId: string;\n\t\treadonly authSubject?: string;\n\t\treadonly sessionId?: string;\n\t\treadonly sessionKey?: string;\n\t\treadonly source: PortalAgentScopeSource;\n\t}) => PortalAgentScope;\n\treadonly describeTools: (scope: PortalAgentScope) => readonly PortalCoreToolDescriptor[];\n\treadonly invalidateAgentScope: (agentScopeId: string) => Promise<void>;\n\treadonly invalidateSession: (scope: PortalAgentScope) => Promise<void>;\n\treadonly upstreamNamespaces: readonly string[];\n}\n\nexport interface PortalCoreToolDescriptor {\n\treadonly description: string;\n\treadonly inputSchema: Tool['inputSchema'];\n\treadonly name: PortalCoreToolName;\n}\n\nconst portalCallRequestSchema = z\n\t.object({\n\t\targuments: jsonObjectSchema,\n\t\tid: z.string().min(1),\n\t\tnamespace: z.string().min(1),\n\t\ttoolName: z.string().min(1),\n\t})\n\t.strict();\nconst portalCallInputSchema = z\n\t.object({\n\t\tcalls: z.array(portalCallRequestSchema).min(1),\n\t\tportalApprovalToken: z.string().min(1).optional(),\n\t})\n\t.strict();\n\nfunction diagnosticsToAuditEvents(\n\tdiagnostics: readonly PortalBatchDiagnostic[],\n): readonly PortalAuditEvent[] {\n\treturn diagnostics.map((diagnostic) => ({ ...diagnostic }));\n}\n\nfunction isUnknownRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction errorRecordFromUnknown(error: unknown): Record<string, unknown> {\n\treturn isUnknownRecord(error) ? error : {};\n}\n\nfunction messageFromUnknown(error: unknown): string {\n\tif (error instanceof Error) {\n\t\treturn error.message;\n\t}\n\tconst record = errorRecordFromUnknown(error);\n\tconst message = record.message;\n\treturn typeof message === 'string' ? message : String(error);\n}\n\nfunction errorFromAbortSignal(signal: AbortSignal): Error {\n\tconst reason: unknown = signal.reason;\n\treturn reason instanceof Error ? reason : new Error('MCP Portal core stream aborted.');\n}\n\nfunction throwIfAborted(signal: AbortSignal | undefined): void {\n\tif (signal?.aborted) {\n\t\tthrow errorFromAbortSignal(signal);\n\t}\n}\n\nfunction assertPortalCoreEventSize(event: PortalCoreEvent): void {\n\tconst serialized = JSON.stringify(event);\n\tif (serialized === undefined) {\n\t\treturn;\n\t}\n\tconst byteLength = Buffer.byteLength(serialized, 'utf8');\n\tif (byteLength > maxPortalCoreEventBytes) {\n\t\tthrow new Error(\n\t\t\t`MCP Portal core event exceeded ${String(maxPortalCoreEventBytes)} bytes (${String(byteLength)} bytes).`,\n\t\t);\n\t}\n}\n\nfunction waitForQueuedCoreEvent(props: {\n\treadonly setNotifyQueuedEvent: (notify: (() => void) | undefined) => void;\n\treadonly signal?: AbortSignal;\n}): Promise<void> {\n\tif (props.signal === undefined) {\n\t\treturn new Promise<void>((resolve) => {\n\t\t\tprops.setNotifyQueuedEvent(resolve);\n\t\t});\n\t}\n\tconst signal = props.signal;\n\treturn new Promise<void>((resolve, reject) => {\n\t\tlet settled = false;\n\t\tconst settle = (complete: () => void): void => {\n\t\t\tif (settled) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsettled = true;\n\t\t\tsignal.removeEventListener('abort', onAbort);\n\t\t\tprops.setNotifyQueuedEvent(undefined);\n\t\t\tcomplete();\n\t\t};\n\t\tconst onNotify = (): void => {\n\t\t\tsettle(resolve);\n\t\t};\n\t\tconst onAbort = (): void => {\n\t\t\tsettle(() => reject(errorFromAbortSignal(signal)));\n\t\t};\n\t\tprops.setNotifyQueuedEvent(onNotify);\n\t\tsignal.addEventListener('abort', onAbort, { once: true });\n\t\tif (signal.aborted) {\n\t\t\tonAbort();\n\t\t}\n\t});\n}\n\nfunction itemErrorFromPortalResult(result: PortalToolResult): PortalCoreItemError {\n\tif (result.ok) {\n\t\tthrow new Error('Cannot convert successful portal result into an item error.');\n\t}\n\tconst errorRecord = errorRecordFromUnknown(result.error);\n\tconst kind = errorRecord.kind;\n\tconst namespace = errorRecord.namespace;\n\tconst toolName = errorRecord.toolName;\n\tconst upstream = errorRecord.upstream;\n\n\treturn {\n\t\tcode: typeof kind === 'string' ? kind : 'portal_item_failed',\n\t\tmessage: messageFromUnknown(result.error),\n\t\t...(typeof namespace === 'string' ? { namespace } : {}),\n\t\t...(typeof toolName === 'string' ? { toolName } : {}),\n\t\t...(upstream === undefined ? {} : { upstream }),\n\t};\n}\n\nfunction itemResultFromPortalToolResult(\n\trequestId: string,\n\tresult: PortalToolResult,\n): PortalCoreItemResult {\n\tif (!result.ok) {\n\t\treturn {\n\t\t\terror: itemErrorFromPortalResult(result),\n\t\t\trequestId,\n\t\t\tstatus: 'failed',\n\t\t};\n\t}\n\n\treturn {\n\t\tcontent: [{ type: 'json', value: result.output }],\n\t\trequestId,\n\t\tstatus: 'success',\n\t\tstructuredContent: result.output,\n\t};\n}\n\nfunction scalarBatchResultToCoreResult(batchResult: PortalBatchResult): PortalCoreResult {\n\treturn {\n\t\tauditEvents: diagnosticsToAuditEvents(batchResult.diagnostics),\n\t\tcontent: [{ type: 'json', value: batchResult }],\n\t\titems: [],\n\t\tstructuredContent: batchResult,\n\t};\n}\n\nfunction batchItemsToCoreResult(props: {\n\treadonly diagnostics: readonly PortalBatchDiagnostic[];\n\treadonly items: readonly PortalCoreItemResult[];\n}): PortalCoreResult {\n\treturn {\n\t\tauditEvents: diagnosticsToAuditEvents(props.diagnostics),\n\t\tcontent: [],\n\t\titems: props.items,\n\t};\n}\n\nfunction namespaceDescription(namespaces: readonly string[]): string {\n\treturn namespaces.length === 0\n\t\t? 'No upstream MCP namespaces are authorized for this agent scope.'\n\t\t: `Allowed namespaces for this agent: ${namespaces.join(', ')}.`;\n}\n\nfunction cloneJsonObject<TValue>(value: TValue): TValue {\n\treturn structuredClone(value);\n}\n\nfunction withListNamespaceSchemaDescription(\n\tinputSchema: Tool['inputSchema'],\n\tnamespaces: readonly string[],\n): Tool['inputSchema'] {\n\tconst clonedSchema = cloneJsonObject(inputSchema);\n\tconst requests = isUnknownRecord(clonedSchema.properties)\n\t\t? clonedSchema.properties.requests\n\t\t: undefined;\n\tconst requestItems = isUnknownRecord(requests) ? requests.items : undefined;\n\tconst requestProperties = isUnknownRecord(requestItems) ? requestItems.properties : undefined;\n\tconst namespaceProperty = isUnknownRecord(requestProperties)\n\t\t? requestProperties.namespaces\n\t\t: undefined;\n\tif (isUnknownRecord(namespaceProperty)) {\n\t\tnamespaceProperty.description =\n\t\t\tnamespaces.length === 0\n\t\t\t\t? 'Optional namespace filter. No upstream MCP namespaces are authorized for this agent. Omit to list all currently discovered authorized namespaces.'\n\t\t\t\t: `Optional namespace filter. Allowed namespaces for this agent: ${namespaces.join(', ')}. Omit to list all currently discovered authorized namespaces.`;\n\t}\n\treturn clonedSchema;\n}\n\nexport function listPortalCoreToolDescriptors(\n\tnamespaces: readonly string[] = [],\n): readonly PortalCoreToolDescriptor[] {\n\tconst scopeDescription = namespaceDescription(namespaces);\n\treturn [\n\t\t{\n\t\t\tdescription: `List authorized MCP namespaces and compact tool summaries. ${scopeDescription}`,\n\t\t\tinputSchema: withListNamespaceSchemaDescription(\n\t\t\t\tportalToolInputSchemas.mcp_portal_list,\n\t\t\t\tnamespaces,\n\t\t\t),\n\t\t\tname: 'mcp_portal_list',\n\t\t},\n\t\t{\n\t\t\tdescription: 'Search the caller scoped MCP Portal index.',\n\t\t\tinputSchema: portalToolInputSchemas.mcp_portal_search,\n\t\t\tname: 'mcp_portal_search',\n\t\t},\n\t\t{\n\t\t\tdescription: 'Describe exact MCP tool schemas and optional TypeScript/Zod helpers.',\n\t\t\tinputSchema: portalToolInputSchemas.mcp_portal_describe,\n\t\t\tname: 'mcp_portal_describe',\n\t\t},\n\t\t{\n\t\t\tdescription: 'Validate and call an authorized upstream MCP tool by namespace and toolName.',\n\t\t\tinputSchema: portalToolInputSchemas.mcp_portal_call,\n\t\t\tname: 'mcp_portal_call',\n\t\t},\n\t];\n}\n\nexport async function collectPortalCoreResult(\n\tevents: AsyncIterable<PortalCoreEvent>,\n\toptions: PortalCoreCollectOptions = {},\n): Promise<PortalCoreResult> {\n\tlet result: PortalCoreResult | undefined;\n\tfor await (const event of events) {\n\t\tawait options.onEvent?.(event);\n\t\tif (event.kind === 'completed') {\n\t\t\tresult = event.result;\n\t\t}\n\t\tif (event.kind === 'failed') {\n\t\t\tthrow event.error;\n\t\t}\n\t}\n\tif (result === undefined) {\n\t\tthrow new Error('MCP Portal core stream ended without a completed event.');\n\t}\n\treturn result;\n}\n\nasync function* scalarToolStream(props: {\n\treadonly input: unknown;\n\treadonly scope: PortalAgentScope;\n\treadonly signal?: AbortSignal;\n\treadonly sessionManager: PortalSessionManager;\n\treadonly toolName: Exclude<PortalCoreToolName, 'mcp_portal_call'>;\n\treadonly toolRuntime: PortalToolRuntime;\n}): AsyncIterable<PortalCoreEvent> {\n\tconst handlers = createPortalToolHandlers(props.toolRuntime);\n\tconst handler =\n\t\tprops.toolName === 'mcp_portal_list'\n\t\t\t? handlers.list\n\t\t\t: props.toolName === 'mcp_portal_search'\n\t\t\t\t? handlers.search\n\t\t\t\t: handlers.describe;\n\tthrowIfAborted(props.signal);\n\tconst batchResult = await handler({ identity: props.scope, input: props.input });\n\tthrowIfAborted(props.signal);\n\tyield { kind: 'completed', result: scalarBatchResultToCoreResult(batchResult) };\n}\n\nasync function* callToolStream(props: {\n\treadonly input: unknown;\n\treadonly scope: PortalAgentScope;\n\treadonly signal?: AbortSignal;\n\treadonly toolRuntime: PortalToolRuntime;\n}): AsyncIterable<PortalCoreEvent> {\n\tconst parsedInput = portalCallInputSchema.safeParse(props.input);\n\tconst queuedEvents: PortalCoreEvent[] = [];\n\tlet notifyQueuedEvent: (() => void) | undefined;\n\tlet executionDone = false;\n\tconst pushEvent = (event: PortalCoreEvent): void => {\n\t\tassertPortalCoreEventSize(event);\n\t\tif (queuedEvents.length >= maxQueuedPortalCoreEvents) {\n\t\t\tthrow new Error(`MCP Portal core event queue exceeded ${maxQueuedPortalCoreEvents} events.`);\n\t\t}\n\t\tqueuedEvents.push(event);\n\t\tnotifyQueuedEvent?.();\n\t\tnotifyQueuedEvent = undefined;\n\t};\n\tconst streamingToolRuntime: PortalToolRuntime = {\n\t\t...props.toolRuntime,\n\t\tcallUpstreamTool: async (call) => {\n\t\t\tthrowIfAborted(props.signal);\n\t\t\tpushEvent({\n\t\t\t\tkind: 'item_started',\n\t\t\t\tnamespace: call.namespace,\n\t\t\t\trequestId: call.requestId,\n\t\t\t\ttoolName: call.toolName,\n\t\t\t});\n\t\t\tpushEvent({\n\t\t\t\tkind: 'progress',\n\t\t\t\tmessage: `Calling upstream MCP tool ${call.namespace}.${call.toolName}.`,\n\t\t\t\trequestId: call.requestId,\n\t\t\t});\n\t\t\treturn await props.toolRuntime.callUpstreamTool({\n\t\t\t\t...call,\n\t\t\t\t...(props.signal !== undefined ? { signal: props.signal } : {}),\n\t\t\t\tonEvent: (event) => {\n\t\t\t\t\tif (event.kind === 'progress') {\n\t\t\t\t\t\tpushEvent({\n\t\t\t\t\t\t\tkind: 'progress',\n\t\t\t\t\t\t\t...(event.message !== undefined ? { message: event.message } : {}),\n\t\t\t\t\t\t\t...(event.progress !== undefined ? { progress: event.progress } : {}),\n\t\t\t\t\t\t\trequestId: call.requestId,\n\t\t\t\t\t\t\t...(event.total !== undefined ? { total: event.total } : {}),\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (event.kind === 'partial_content') {\n\t\t\t\t\t\tpushEvent({\n\t\t\t\t\t\t\tcontent: event.content,\n\t\t\t\t\t\t\tkind: 'partial_content',\n\t\t\t\t\t\t\trequestId: call.requestId,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tpushEvent({\n\t\t\t\t\t\tkind: 'upstream_notification',\n\t\t\t\t\t\tmethod: event.method,\n\t\t\t\t\t\tparams: event.params,\n\t\t\t\t\t\trequestId: call.requestId,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n\tconst handlers = createPortalToolHandlers(streamingToolRuntime);\n\tif (!parsedInput.success) {\n\t\tconst batchResult = await handlers.call({ identity: props.scope, input: props.input });\n\t\tyield { kind: 'completed', result: scalarBatchResultToCoreResult(batchResult) };\n\t\treturn;\n\t}\n\n\tconst itemResults: PortalCoreItemResult[] = [];\n\tconst batchResultPromise = handlers\n\t\t.call({\n\t\t\tidentity: props.scope,\n\t\t\tinput: props.input,\n\t\t})\n\t\t.finally(() => {\n\t\t\texecutionDone = true;\n\t\t\tnotifyQueuedEvent?.();\n\t\t\tnotifyQueuedEvent = undefined;\n\t\t});\n\tconst hasPendingExecutionEvents = (): boolean => !executionDone || queuedEvents.length > 0;\n\twhile (hasPendingExecutionEvents()) {\n\t\tconst event = queuedEvents.shift();\n\t\tif (event !== undefined) {\n\t\t\tyield event;\n\t\t\tcontinue;\n\t\t}\n\t\tthrowIfAborted(props.signal);\n\t\t// Streaming consumes events as they arrive; there is no parallel work to collect here.\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tawait waitForQueuedCoreEvent({\n\t\t\tsetNotifyQueuedEvent: (notify) => {\n\t\t\t\tnotifyQueuedEvent = notify;\n\t\t\t},\n\t\t\t...(props.signal !== undefined ? { signal: props.signal } : {}),\n\t\t});\n\t}\n\tconst batchResult = await batchResultPromise;\n\tthrowIfAborted(props.signal);\n\tif (batchResult.errors.length > 0) {\n\t\tyield { kind: 'completed', result: scalarBatchResultToCoreResult(batchResult) };\n\t\treturn;\n\t}\n\tfor (const request of parsedInput.data.calls) {\n\t\tconst portalResult = batchResult.results[request.id];\n\t\tconst itemResult =\n\t\t\tportalResult === undefined\n\t\t\t\t? ({\n\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\tcode: 'portal_item_missing',\n\t\t\t\t\t\t\tmessage: `MCP Portal did not return a result for request \"${request.id}\".`,\n\t\t\t\t\t\t\tnamespace: request.namespace,\n\t\t\t\t\t\t\ttoolName: request.toolName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequestId: request.id,\n\t\t\t\t\t\tstatus: 'failed',\n\t\t\t\t\t} satisfies PortalCoreItemResult)\n\t\t\t\t: itemResultFromPortalToolResult(request.id, portalResult);\n\t\titemResults.push(itemResult);\n\t\tif (itemResult.status === 'success') {\n\t\t\tyield { kind: 'item_completed', requestId: request.id, result: itemResult };\n\t\t} else {\n\t\t\tyield { error: itemResult.error, kind: 'item_failed', requestId: request.id };\n\t\t}\n\t}\n\n\tyield {\n\t\tkind: 'completed',\n\t\tresult: batchItemsToCoreResult({ diagnostics: batchResult.diagnostics, items: itemResults }),\n\t};\n}\n\nexport function createPortalCore(props: CreatePortalCoreProps): PortalCore {\n\tconst sessionManager = createPortalSessionManager({\n\t\taccessPolicy: props.accessPolicy,\n\t\tcatalogTtlMs: props.catalogTtlMs,\n\t\truntime: props.runtime,\n\t\t...(props.skills !== undefined ? { skills: props.skills } : {}),\n\t\tupstreamNamespaces: props.upstreamNamespaces,\n\t});\n\tconst createdAgentScopeIds = new Set<string>();\n\tconst approval: PortalApprovalEvaluator =\n\t\tprops.approval ??\n\t\t(() => {\n\t\t\tif (props.approvalTrustBoundary === 'openclaw-before-tool-call-hook') {\n\t\t\t\treturn { kind: 'allow' };\n\t\t\t}\n\t\t\tthrow new Error('MCP Portal approval evaluation is not configured.');\n\t\t});\n\tconst toolRuntime: PortalToolRuntime = {\n\t\tapproval,\n\t\tcallUpstreamTool: props.runtime.callUpstreamTool,\n\t\tgetSession: sessionManager.getSession,\n\t};\n\n\tasync function* callStream(call: PortalCoreStreamCall): AsyncIterable<PortalCoreEvent> {\n\t\ttry {\n\t\t\tthrowIfAborted(call.signal);\n\t\t\tyield { kind: 'started', toolName: call.toolName };\n\t\t\tthrowIfAborted(call.signal);\n\t\t\tif (call.toolName === 'mcp_portal_call') {\n\t\t\t\tyield* callToolStream({\n\t\t\t\t\tinput: call.input,\n\t\t\t\t\tscope: call.scope,\n\t\t\t\t\t...(call.signal !== undefined ? { signal: call.signal } : {}),\n\t\t\t\t\ttoolRuntime,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tyield* scalarToolStream({\n\t\t\t\tinput: call.input,\n\t\t\t\tscope: call.scope,\n\t\t\t\t...(call.signal !== undefined ? { signal: call.signal } : {}),\n\t\t\t\tsessionManager,\n\t\t\t\ttoolName: call.toolName,\n\t\t\t\ttoolRuntime,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tyield { error, kind: 'failed' };\n\t\t}\n\t}\n\n\treturn {\n\t\tapproval: {\n\t\t\tevaluateCalls: (calls, scope, approvalToken) => approval(calls, scope, approvalToken),\n\t\t},\n\t\tcallStream,\n\t\tclose: async () => {\n\t\t\tawait Promise.all(\n\t\t\t\t[...createdAgentScopeIds].map((agentScopeId) =>\n\t\t\t\t\tsessionManager.invalidateAgentScope(agentScopeId),\n\t\t\t\t),\n\t\t\t);\n\t\t},\n\t\tcollectPortalCoreResult,\n\t\tcreateAgentScope: (input) => {\n\t\t\tconst scope = createPortalAgentIdentity(input);\n\t\t\tcreatedAgentScopeIds.add(scope.agentScopeId);\n\t\t\treturn scope;\n\t\t},\n\t\tdescribeTools: (scope) => {\n\t\t\tconst policy = resolvePortalAccessPolicy({\n\t\t\t\tconfig: props.accessPolicy,\n\t\t\t\tidentity: scope,\n\t\t\t\tupstreamNamespaces: props.upstreamNamespaces,\n\t\t\t});\n\t\t\treturn listPortalCoreToolDescriptors(policy.allowedNamespaces);\n\t\t},\n\t\tinvalidateAgentScope: async (agentScopeId) => {\n\t\t\tcreatedAgentScopeIds.delete(agentScopeId);\n\t\t\tawait sessionManager.invalidateAgentScope(agentScopeId);\n\t\t},\n\t\tinvalidateSession: async (scope) => {\n\t\t\tawait sessionManager.invalidateSession(scope);\n\t\t},\n\t\tupstreamNamespaces: props.upstreamNamespaces,\n\t};\n}\n"],"mappings":";;;;;;;AAcA,eAAe,4BACd,SACA,eAC4C;CAC5C,MAAM,kBAAkB,MAAM,QAAQ,IACrC,OAAO,QAAQ,QAAQ,CAAC,IACvB,OAAO,CAAC,MAAM,YAAY,CAAC,MAAM,MAAM,cAAc,OAAO,CAAC,CAC7D,CACD;CACD,OAAO,OAAO,YAAY,gBAAgB;;AAG3C,eAAe,sBACd,UACA,eACuC;CACvC,IAAI,SAAS,cAAc,SAC1B,OAAO;EACN,MAAM,SAAS;EACf,SAAS,SAAS;EAClB,GAAI,SAAS,QAAQ,KAAA,IAAY,EAAE,GAAG,EAAE,KAAK,SAAS,K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8BALQ,0BAA0B;IACxC,QAAQ,MAAM;IACd,UAAU;IACV,oBAAoB,MAAM;IAC1B,CAC0C,CAAC,kBAAkB;;EAE/D,sBAAsB,OAAO,iBAAiB;GAC7C,qBAAqB,OAAO,aAAa;GACzC,MAAM,eAAe,qBAAqB,aAAa;;EAExD,mBAAmB,OAAO,UAAU;GACnC,MAAM,eAAe,kBAAkB,MAAM;;EAE9C,oBAAoB,MAAM;EAC1B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as PortalToolRecord, s as JsonObject } from "./catalog-types-BVuB4Ynx.js";
|
|
2
|
-
import {
|
|
2
|
+
import { F as PortalAgentScopeSource, N as PortalAccessPolicyConfig, P as PortalAgentIdentity, S as SkillGraphInput, o as PortalSessionRuntime, r as PortalSession } from "./portal-session-B7no2T4L.js";
|
|
3
3
|
import { Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
4
4
|
|
|
5
5
|
//#region src/core/portal-tools.d.ts
|
|
@@ -21,9 +21,17 @@ interface PortalBatchError {
|
|
|
21
21
|
readonly message: string;
|
|
22
22
|
}
|
|
23
23
|
interface PortalBatchDiagnostic {
|
|
24
|
+
readonly causeMessage?: string;
|
|
25
|
+
readonly elapsedMs?: number;
|
|
26
|
+
readonly hint?: string;
|
|
24
27
|
readonly kind: string;
|
|
25
28
|
readonly message: string;
|
|
26
29
|
readonly namespace?: string;
|
|
30
|
+
readonly operation?: string;
|
|
31
|
+
readonly phase?: string;
|
|
32
|
+
readonly timeoutMs?: number;
|
|
33
|
+
readonly toolName?: string;
|
|
34
|
+
readonly transport?: unknown;
|
|
27
35
|
}
|
|
28
36
|
interface PortalBatchResult {
|
|
29
37
|
readonly diagnostics: readonly PortalBatchDiagnostic[];
|
|
@@ -131,9 +139,17 @@ declare function createPortalToolHandlers(runtime: PortalToolRuntime): PortalToo
|
|
|
131
139
|
type PortalAgentScope = PortalAgentIdentity;
|
|
132
140
|
type PortalCoreToolName = 'mcp_portal_list' | 'mcp_portal_search' | 'mcp_portal_describe' | 'mcp_portal_call';
|
|
133
141
|
interface PortalAuditEvent {
|
|
142
|
+
readonly causeMessage?: string;
|
|
143
|
+
readonly elapsedMs?: number;
|
|
144
|
+
readonly hint?: string;
|
|
134
145
|
readonly kind: string;
|
|
135
146
|
readonly message: string;
|
|
136
147
|
readonly namespace?: string;
|
|
148
|
+
readonly operation?: string;
|
|
149
|
+
readonly phase?: string;
|
|
150
|
+
readonly timeoutMs?: number;
|
|
151
|
+
readonly toolName?: string;
|
|
152
|
+
readonly transport?: unknown;
|
|
137
153
|
}
|
|
138
154
|
interface PortalCoreResult {
|
|
139
155
|
readonly auditEvents?: readonly PortalAuditEvent[];
|
|
@@ -156,6 +172,7 @@ interface PortalCoreItemError {
|
|
|
156
172
|
readonly message: string;
|
|
157
173
|
readonly namespace?: string;
|
|
158
174
|
readonly toolName?: string;
|
|
175
|
+
readonly upstream?: unknown;
|
|
159
176
|
}
|
|
160
177
|
type PortalCoreContentBlock = {
|
|
161
178
|
readonly text: string;
|
|
@@ -261,4 +278,4 @@ declare function collectPortalCoreResult(events: AsyncIterable<PortalCoreEvent>,
|
|
|
261
278
|
declare function createPortalCore(props: CreatePortalCoreProps): PortalCore;
|
|
262
279
|
//#endregion
|
|
263
280
|
export { PortalToolSuccess as A, PortalCallUpstreamTool as C, PortalToolResult as D, PortalToolHandlers as E, createPortalToolHandlers as M, portalToolInputSchemas as N, PortalToolResultMap as O, PortalBatchResult as S, PortalToolHandlerCall as T, createPortalCore as _, PortalCore as a, PortalBatchDiagnostic as b, PortalCoreEvent as c, PortalCoreResult as d, PortalCoreRuntime as f, collectPortalCoreResult as g, PortalCoreToolName as h, PortalAuditEvent as i, PortalUpstreamEvent as j, PortalToolRuntime as k, PortalCoreItemError as l, PortalCoreToolDescriptor as m, PortalAgentScope as n, PortalCoreCollectOptions as o, PortalCoreStreamCall as p, PortalApprovalEvaluator as r, PortalCoreContentBlock as s, CreatePortalCoreProps as t, PortalCoreItemResult as u, listPortalCoreToolDescriptors as v, PortalToolFailure as w, PortalBatchError as x, PortalApprovalCall as y };
|
|
264
|
-
//# sourceMappingURL=portal-core-
|
|
281
|
+
//# sourceMappingURL=portal-core-CF0bfgCX.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portal-core-CF0bfgCX.d.ts","names":[],"sources":["../src/core/portal-tools.ts","../src/core/portal-core.ts"],"mappings":";;;;;UAkBiB,iBAAA;EAAA,SACP,KAAA,EAAO,QAAA,CAAS,MAAA;EAAA,SAChB,EAAA;EAAA,SACA,MAAA,EAAQ,QAAA,CAAS,MAAA;AAAA;AAAA,UAGV,iBAAA;EAAA,SACP,KAAA;EAAA,SACA,KAAA,EAAO,QAAA,CAAS,MAAA;EAAA,SAChB,EAAA;AAAA;AAAA,KAGE,gBAAA,GAAmB,iBAAA,GAAoB,iBAAA;AAAA,KACvC,mBAAA,GAAsB,QAAA,CAAS,MAAA,SAAe,gBAAA;AAAA,UAEzC,gBAAA;EAAA,SACP,EAAA;EAAA,SACA,IAAA;EAAA,SACA,OAAA;AAAA;AAAA,UAGO,qBAAA;EAAA,SACP,YAAA;EAAA,SACA,SAAA;EAAA,SACA,IAAA;EAAA,SACA,IAAA;EAAA,SACA,OAAA;EAAA,SACA,SAAA;EAAA,SACA,SAAA;EAAA,SACA,KAAA;EAAA,SACA,SAAA;EAAA,SACA,QAAA;EAAA,SACA,SAAA;AAAA;AAAA,UAGO,iBAAA;EAAA,SACP,WAAA,WAAsB,qBAAA;EAAA,SACtB,MAAA,WAAiB,gBAAA;EAAA,SACjB,EAAA;EAAA,SACA,OAAA,EAAS,mBAAA;AAAA;AAAA,UAGF,kBAAA;EAAA,SACP,SAAA,EAAW,UAAA;EAAA,SACX,EAAA;EAAA,SACA,SAAA;EAAA,SACA,IAAA,EAAM,gBAAA;EAAA,SACN,QAAA;AAAA;AAAA,cAyHG,sBAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAOI,qBAAA;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IAAA,SACA,YAAA;IAAA,SACA,WAAA;IAAA,SACA,SAAA;IAAA,SACA,UAAA;IAAA,SACA,MAAA,EAAQ,sBAAA;EAAA,MACZ,gBAAA;EAAA,SACG,aAAA,GAAgB,KAAA,EAAO,gBAAA,cAA8B,wBAAA;EAAA,SACrD,oBAAA,GAAuB,YAAA,aAAyB,OAAA;EAAA,SAChD,iBAAA,GAAoB,KAAA,EAAO,gBAAA,KAAqB,OAAA;EAAA,SAChD,kBAAA;AAAA;AAAA,UAGO,wBAAA;EAAA,SACP,WAAA;EAAA,SACA,WAAA,EAAa,IAAA;EAAA,SACb,IAAA,EAAM,kBAAA;AAAA;AAAA,iBA+LA,6BAAA,CACf,UAAA,gCACW,wBAAA;AAAA,iBA6BU,uBAAA,CACrB,MAAA,EAAQ,aAAA,CAAc,eAAA,GACtB,OAAA,GAAS,wBAAA,GACP,OAAA,CAAQ,gBAAA;AAAA,iBA8KK,gBAAA,CAAiB,KAAA,EAAO,qBAAA,GAAwB,UAAA"}
|
|
@@ -101,12 +101,18 @@ interface ToolSafetySummary {
|
|
|
101
101
|
readonly destructiveHint?: boolean;
|
|
102
102
|
readonly readOnlyHint?: boolean;
|
|
103
103
|
}
|
|
104
|
+
type ToolSchemaHintNext = 'call_ready' | 'describe_before_call';
|
|
105
|
+
interface ToolSchemaHint {
|
|
106
|
+
readonly message: string;
|
|
107
|
+
readonly next: ToolSchemaHintNext;
|
|
108
|
+
}
|
|
104
109
|
interface ToolSummary {
|
|
105
110
|
readonly description?: string;
|
|
106
111
|
readonly input: ToolSchemaSummary;
|
|
107
112
|
readonly namespace: string;
|
|
108
113
|
readonly output?: ToolSchemaSummary;
|
|
109
114
|
readonly safety: ToolSafetySummary;
|
|
115
|
+
readonly schemaHint?: ToolSchemaHint;
|
|
110
116
|
readonly title?: string;
|
|
111
117
|
readonly toolName: string;
|
|
112
118
|
readonly toolRef: string;
|
|
@@ -147,8 +153,17 @@ interface PortalCatalogSnapshot {
|
|
|
147
153
|
readonly tools: readonly PortalToolRecord[];
|
|
148
154
|
}
|
|
149
155
|
interface PortalDiscoveryFailure {
|
|
156
|
+
readonly causeMessage?: string;
|
|
157
|
+
readonly elapsedMs?: number;
|
|
158
|
+
readonly hint?: string;
|
|
159
|
+
readonly kind: string;
|
|
150
160
|
readonly message: string;
|
|
151
161
|
readonly namespace: string;
|
|
162
|
+
readonly operation?: string;
|
|
163
|
+
readonly phase?: string;
|
|
164
|
+
readonly timeoutMs?: number;
|
|
165
|
+
readonly toolName?: string;
|
|
166
|
+
readonly transport?: unknown;
|
|
152
167
|
}
|
|
153
168
|
interface PortalSession {
|
|
154
169
|
readonly catalog: PortalCatalogSnapshot;
|
|
@@ -180,5 +195,5 @@ interface PortalSessionManager {
|
|
|
180
195
|
}
|
|
181
196
|
declare function createPortalSessionManager(options: PortalSessionManagerOptions): PortalSessionManager;
|
|
182
197
|
//#endregion
|
|
183
|
-
export {
|
|
184
|
-
//# sourceMappingURL=portal-session-
|
|
198
|
+
export { ToolRef as A, portalAgentScopeKey as B, ToolGraph as C, ToolRelationshipType as D, ToolRelationshipEndpoint as E, PortalAgentScopeSource as F, PortalDefaultPolicy as I, PortalToolSelector as L, encodeToolRef as M, PortalAccessPolicyConfig as N, buildToolGraph as O, PortalAgentIdentity as P, ResolvedPortalAccessPolicy as R, SkillGraphInput as S, ToolRelationship as T, resolvePortalAccessPolicy as V, ToolSchemaSummary as _, PortalSessionManagerOptions as a, summarizeJsonSchema as b, SearchIndex as c, ToolRelationshipHint as d, ToolSearchResult as f, ToolSchemaHintNext as g, ToolSchemaHint as h, PortalSessionManager as i, decodeToolRef as j, ToolIdentity as k, SearchQuery as l, ToolSafetySummary as m, PortalDiscoveryFailure as n, PortalSessionRuntime as o, createSearchIndex as p, PortalSession as r, createPortalSessionManager as s, PortalCatalogSnapshot as t, SearchResultSet as u, ToolSummary as v, ToolGraphInput as w, ScopedSkillGraphEntry as x, createToolSummary as y, createPortalAgentIdentity as z };
|
|
199
|
+
//# sourceMappingURL=portal-session-B7no2T4L.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal-session-
|
|
1
|
+
{"version":3,"file":"portal-session-B7no2T4L.d.ts","names":[],"sources":["../src/portal-access-policy.ts","../src/tool-ref.ts","../src/tool-graph.ts","../src/tool-summary.ts","../src/search-index.ts","../src/portal-session.ts"],"mappings":";;;;;cAAM,wBAAA;AAAA,KAEM,mBAAA;EAAA,SACF,OAAA;EAAA,SAIA,YAAA;EAAA,SACA,WAAA;EAAA,SACA,SAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA,EAAQ,sBAAA;EAAA,UACP,wBAAA;AAAA;AAAA,KAGC,sBAAA;AAAA,UAEK,kBAAA;EAAA,SACP,SAAA;EAAA,SACA,QAAA;AAAA;AAAA,KAGE,mBAAA;AAAA,UAEK,wBAAA;EAAA,SACP,aAAA,GAAgB,mBAAA;EAAA,SAChB,iBAAA;EAAA,SACA,wBAAA,EAA0B,QAAA,CAAS,MAAA;EAAA,SACnC,mBAAA,GAAsB,QAAA,CAAS,MAAA,kBAAwB,kBAAA;EAAA,SACvD,kBAAA,EAAoB,QAAA,CAAS,MAAA,kBAAwB,kBAAA;AAAA;AAAA,UAG9C,0BAAA;EAAA,SACP,iBAAA;EAAA,SACA,YAAA,WAAuB,kBAAA;EAAA,SACvB,WAAA,WAAsB,kBAAA;AAAA;AAAA,iBAGhB,yBAAA,CAA0B,KAAA;EAAA,SAChC,OAAA;EAAA,SACA,YAAA;EAAA,SACA,WAAA;EAAA,SACA,SAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA,EAAQ,sBAAA;AAAA,IACd,mBAAA;AAAA,iBAmCY,mBAAA,CAAoB,QAAA,EAAU,mBAAA;AAAA,iBAc9B,yBAAA,CAA0B,KAAA;EAAA,SAChC,MAAA,EAAQ,wBAAA;EAAA,SACR,QAAA,EAAU,mBAAA;EAAA,SACV,kBAAA;AAAA,IACN,0BAAA;;;UChGa,YAAA;EAAA,SACP,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ACV,WAAA,EAAa,WAAA;AAAA;AAAA,UAGN,oBAAA;EAAA,SACP,eAAA,GAAkB,YAAA,aAAyB,OAAA;EAAA,SAC3C,YAAA,IAAgB,QAAA,aAAqB,OAAA;EAAA,SACrC,SAAA,GAAY,IAAA;IAAA,SACX,YAAA;IAAA,SACA,SAAA;EAAA,MACJ,OAAA,UAAiB,IAAA;AAAA;AAAA,UAGP,2BAAA;EAAA,SACP,YAAA,EAAc,wBAAA;EAAA,SACd,YAAA;EAAA,SACA,iBAAA,YAA6B,sBAAA;EAAA,SAC7B,GAAA;EAAA,SACA,OAAA,EAAS,oBAAA;EAAA,SACT,MAAA,YAAkB,eAAA;EAAA,SAClB,kBAAA;AAAA;AAAA,UAGO,oBAAA;EAAA,SACP,UAAA,GAAa,QAAA,EAAU,mBAAA,KAAwB,OAAA,CAAQ,aAAA;EAAA,SACvD,oBAAA,GAAuB,YAAA,aAAyB,OAAA;EAAA,SAChD,iBAAA,GAAoB,QAAA,EAAU,mBAAA,KAAwB,OAAA;AAAA;AAAA,iBA4DhD,0BAAA,CACf,OAAA,EAAS,2BAAA,GACP,oBAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { l as jsonObjectSchema, n as decodeToolRef, t as buildZodValidatorFromJsonSchema } from "./zod-schema-loader-yNekKNpm.js";
|
|
2
|
-
import {
|
|
2
|
+
import { h as createToolSummary, m as upstreamMcpFailureDetailsFromUnknown, v as portalAgentScopeKey } from "./upstream-response-middleware-CpMgDGMh.js";
|
|
3
3
|
import { t as generateTypescriptCatalogArtifact } from "./typescript-artifact-BVLt3Ifd.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
//#region src/core/portal-call-validation.ts
|
|
@@ -79,6 +79,14 @@ const callExecutionInputSchema = z.object({
|
|
|
79
79
|
calls: z.array(callRequestSchema).min(1),
|
|
80
80
|
portalApprovalToken: z.string().min(1).optional()
|
|
81
81
|
}).strict();
|
|
82
|
+
const describeBeforeCallSchemaHint = {
|
|
83
|
+
message: "Use mcp_portal_describe for exact input schema before calling.",
|
|
84
|
+
next: "describe_before_call"
|
|
85
|
+
};
|
|
86
|
+
const callReadySchemaHint = {
|
|
87
|
+
message: "Full input schema included.",
|
|
88
|
+
next: "call_ready"
|
|
89
|
+
};
|
|
82
90
|
function isToolSchemaProperties(value) {
|
|
83
91
|
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every((entry) => typeof entry === "object" && entry !== null && !Array.isArray(entry));
|
|
84
92
|
}
|
|
@@ -133,9 +141,8 @@ function itemOutput(props) {
|
|
|
133
141
|
}
|
|
134
142
|
function discoveryDiagnostics(session) {
|
|
135
143
|
return session.catalog.discoveryFailures.map((failure) => ({
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
namespace: failure.namespace
|
|
144
|
+
...failure,
|
|
145
|
+
kind: failure.kind === "upstream_mcp_failed" ? "upstream_mcp_failed" : "upstream_discovery_failed"
|
|
139
146
|
}));
|
|
140
147
|
}
|
|
141
148
|
function portalBatchResult(results, diagnostics = []) {
|
|
@@ -233,6 +240,7 @@ function describeToolOutput(props) {
|
|
|
233
240
|
annotations: props.tool.annotations ?? {},
|
|
234
241
|
namespace: props.tool.namespace,
|
|
235
242
|
related: props.includeRelated ? props.session.graph.relationships.filter((relationship) => relationship.from.toolRef === toolSummary.toolRef || relationship.to.toolRef === toolSummary.toolRef) : [],
|
|
243
|
+
schemaHint: callReadySchemaHint,
|
|
236
244
|
toolName: props.tool.toolName,
|
|
237
245
|
toolRef: toolSummary.toolRef
|
|
238
246
|
};
|
|
@@ -253,6 +261,7 @@ function searchOutputWithFullSchema(session, summary) {
|
|
|
253
261
|
input: summary.input,
|
|
254
262
|
namespace: summary.namespace,
|
|
255
263
|
safety: summary.safety,
|
|
264
|
+
schemaHint: callReadySchemaHint,
|
|
256
265
|
toolName: summary.toolName,
|
|
257
266
|
toolRef: summary.toolRef
|
|
258
267
|
};
|
|
@@ -267,6 +276,12 @@ function searchOutputWithFullSchema(session, summary) {
|
|
|
267
276
|
}
|
|
268
277
|
return result;
|
|
269
278
|
}
|
|
279
|
+
function toolSummaryWithSchemaHint(summary) {
|
|
280
|
+
return Object.assign({}, summary, { schemaHint: describeBeforeCallSchemaHint });
|
|
281
|
+
}
|
|
282
|
+
function toolSearchResultWithSchemaHint(summary) {
|
|
283
|
+
return Object.assign({}, summary, { schemaHint: describeBeforeCallSchemaHint });
|
|
284
|
+
}
|
|
270
285
|
function listRequestResult(session, request) {
|
|
271
286
|
const filteredTools = applyExactFilters(session.catalog.tools, {
|
|
272
287
|
...request.namespaces !== void 0 ? { namespaces: request.namespaces } : {},
|
|
@@ -277,7 +292,7 @@ function listRequestResult(session, request) {
|
|
|
277
292
|
error: filteredTools.error,
|
|
278
293
|
input: request
|
|
279
294
|
});
|
|
280
|
-
const page = paginate(filteredTools.tools.map((tool) => createToolSummary(tool)), request.limit, request.cursor);
|
|
295
|
+
const page = paginate(filteredTools.tools.map((tool) => toolSummaryWithSchemaHint(createToolSummary(tool))), request.limit, request.cursor);
|
|
281
296
|
return itemOutput({
|
|
282
297
|
input: request,
|
|
283
298
|
output: {
|
|
@@ -295,7 +310,7 @@ function searchRequestResult(session, request) {
|
|
|
295
310
|
});
|
|
296
311
|
return itemOutput({
|
|
297
312
|
input: request,
|
|
298
|
-
output: { tools: request.schemaDetail === "full" ? result.results.map((summary) => searchOutputWithFullSchema(session, summary)) : result.results }
|
|
313
|
+
output: { tools: request.schemaDetail === "full" ? result.results.map((summary) => searchOutputWithFullSchema(session, summary)) : result.results.map((summary) => toolSearchResultWithSchemaHint(summary)) }
|
|
299
314
|
});
|
|
300
315
|
}
|
|
301
316
|
function describeRequestResult(session, request) {
|
|
@@ -377,12 +392,14 @@ async function executePreparedPortalCall(call, identity, runtime) {
|
|
|
377
392
|
}
|
|
378
393
|
});
|
|
379
394
|
} catch (error) {
|
|
395
|
+
const upstream = upstreamMcpFailureDetailsFromUnknown(error);
|
|
380
396
|
return itemError({
|
|
381
397
|
error: {
|
|
382
398
|
kind: "upstream_call_failed",
|
|
383
399
|
message: messageFromError(error),
|
|
384
400
|
namespace: call.tool.namespace,
|
|
385
|
-
toolName: call.tool.toolName
|
|
401
|
+
toolName: call.tool.toolName,
|
|
402
|
+
...upstream === null ? {} : { upstream }
|
|
386
403
|
},
|
|
387
404
|
input
|
|
388
405
|
});
|
|
@@ -525,4 +542,4 @@ function createPortalToolHandlers(runtime) {
|
|
|
525
542
|
//#endregion
|
|
526
543
|
export { portalToolInputSchemas as n, validatePortalToolArguments as r, createPortalToolHandlers as t };
|
|
527
544
|
|
|
528
|
-
//# sourceMappingURL=portal-tools-
|
|
545
|
+
//# sourceMappingURL=portal-tools-CtFO3ruN.js.map
|