@caplets/core 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth.d.ts +14 -0
- package/dist/cli/auth.d.ts +24 -0
- package/dist/cli.d.ts +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4136 -180
- package/dist/native/options.d.ts +33 -0
- package/dist/native/remote.d.ts +46 -0
- package/dist/native/service.d.ts +7 -1
- package/dist/native.d.ts +2 -0
- package/dist/native.js +233 -2
- package/dist/{engine-Bh55p8Lm.js → options-CJEOqS87.js} +26545 -26325
- package/dist/remote-control/auth-flow.d.ts +22 -0
- package/dist/remote-control/client.d.ts +11 -0
- package/dist/remote-control/dispatch.d.ts +9 -0
- package/dist/remote-control/types.d.ts +17 -0
- package/dist/runtime.d.ts +3 -8
- package/dist/serve/http.d.ts +23 -0
- package/dist/serve/index.d.ts +14 -0
- package/dist/serve/options.d.ts +36 -0
- package/dist/serve/session.d.ts +21 -0
- package/dist/serve/stdio.d.ts +5 -0
- package/dist/server/options.d.ts +41 -0
- package/package.json +4 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type RemoteAuthFlow = {
|
|
2
|
+
id: string;
|
|
3
|
+
server: string;
|
|
4
|
+
authorizationUrl: string;
|
|
5
|
+
createdAt: number;
|
|
6
|
+
complete(callbackUrl: string): Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
export type RemoteAuthFlowStoreOptions = {
|
|
9
|
+
ttlMs?: number;
|
|
10
|
+
now?: () => number;
|
|
11
|
+
};
|
|
12
|
+
export declare class RemoteAuthFlowStore {
|
|
13
|
+
private readonly options;
|
|
14
|
+
private readonly flows;
|
|
15
|
+
constructor(options?: RemoteAuthFlowStoreOptions);
|
|
16
|
+
create(flow: Omit<RemoteAuthFlow, "id" | "createdAt">, id?: string): RemoteAuthFlow;
|
|
17
|
+
get(id: string): RemoteAuthFlow | undefined;
|
|
18
|
+
delete(id: string): void;
|
|
19
|
+
private pruneExpired;
|
|
20
|
+
private isExpired;
|
|
21
|
+
private now;
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RemoteCliCommand, RemoteCliRequest } from "./types";
|
|
2
|
+
export type RemoteControlClientOptions = {
|
|
3
|
+
baseUrl: URL;
|
|
4
|
+
requestInit: RequestInit;
|
|
5
|
+
fetch?: typeof fetch;
|
|
6
|
+
};
|
|
7
|
+
export declare class RemoteControlClient {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(options: RemoteControlClientOptions);
|
|
10
|
+
request(command: RemoteCliCommand, args: RemoteCliRequest["arguments"]): Promise<unknown>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type CapletsEngineOptions } from "../engine";
|
|
2
|
+
import type { RemoteAuthFlowStore } from "./auth-flow";
|
|
3
|
+
import type { RemoteCliRequest, RemoteCliResponse } from "./types";
|
|
4
|
+
export type RemoteControlDispatchContext = CapletsEngineOptions & {
|
|
5
|
+
projectCapletsRoot: string;
|
|
6
|
+
authFlowStore?: RemoteAuthFlowStore;
|
|
7
|
+
controlCallbackBaseUrl?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function dispatchRemoteCliRequest(request: RemoteCliRequest, context: RemoteControlDispatchContext): Promise<RemoteCliResponse>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CapletsErrorCode } from "../errors";
|
|
2
|
+
export type RemoteCliCommand = "list" | "get_caplet" | "check_backend" | "list_tools" | "search_tools" | "get_tool" | "call_tool" | "init" | "add" | "install" | "auth_login_start" | "auth_login_complete" | "auth_logout" | "auth_list";
|
|
3
|
+
export type RemoteCliRequest = {
|
|
4
|
+
command: RemoteCliCommand;
|
|
5
|
+
arguments: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
export type RemoteCliResponse = {
|
|
8
|
+
ok: true;
|
|
9
|
+
result: unknown;
|
|
10
|
+
} | {
|
|
11
|
+
ok: false;
|
|
12
|
+
error: {
|
|
13
|
+
code: CapletsErrorCode;
|
|
14
|
+
message: string;
|
|
15
|
+
nextAction?: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
1
|
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
3
|
-
import {
|
|
4
|
-
type ToolServer
|
|
2
|
+
import type { CapletsConfig } from "./config";
|
|
3
|
+
import { type ToolServer } from "./serve/session";
|
|
5
4
|
type CapletsRuntimeOptions = {
|
|
6
5
|
configPath?: string;
|
|
7
6
|
projectConfigPath?: string;
|
|
@@ -13,8 +12,7 @@ type CapletsRuntimeOptions = {
|
|
|
13
12
|
export declare class CapletsRuntime {
|
|
14
13
|
readonly server: ToolServer;
|
|
15
14
|
private readonly engine;
|
|
16
|
-
private readonly
|
|
17
|
-
private readonly unsubscribeReload;
|
|
15
|
+
private readonly session;
|
|
18
16
|
constructor(options?: CapletsRuntimeOptions);
|
|
19
17
|
connect(transport: Transport): Promise<void>;
|
|
20
18
|
scheduleReload(): void;
|
|
@@ -23,8 +21,5 @@ export declare class CapletsRuntime {
|
|
|
23
21
|
currentConfig(): CapletsConfig;
|
|
24
22
|
registeredToolIds(): string[];
|
|
25
23
|
watchedPaths(): string[];
|
|
26
|
-
private reconcileTools;
|
|
27
|
-
private registerCapletTool;
|
|
28
|
-
private handleTool;
|
|
29
24
|
}
|
|
30
25
|
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { CapletsEngine, type CapletsEngineOptions } from "../engine";
|
|
3
|
+
import { type RemoteControlDispatchContext } from "../remote-control/dispatch";
|
|
4
|
+
import { RemoteAuthFlowStore } from "../remote-control/auth-flow";
|
|
5
|
+
import type { HttpServeOptions } from "./options";
|
|
6
|
+
type HttpServeIo = {
|
|
7
|
+
writeErr?: (value: string) => void;
|
|
8
|
+
control?: Omit<RemoteControlDispatchContext, "writeErr">;
|
|
9
|
+
authFlowStore?: RemoteAuthFlowStore;
|
|
10
|
+
};
|
|
11
|
+
export type CapletsHttpApp = Hono & {
|
|
12
|
+
closeCapletsSessions: () => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
export declare function createHttpServeApp(options: HttpServeOptions, engine: CapletsEngine, io?: HttpServeIo): CapletsHttpApp;
|
|
15
|
+
export declare function serveHttp(options: HttpServeOptions, engineOptions?: CapletsEngineOptions, writeErr?: (value: string) => void): Promise<void>;
|
|
16
|
+
export declare function routePath(base: string, path: string): string;
|
|
17
|
+
export declare function servicePaths(base: string): {
|
|
18
|
+
base: string;
|
|
19
|
+
mcp: string;
|
|
20
|
+
control: string;
|
|
21
|
+
health: string;
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CapletsEngineOptions } from "../engine";
|
|
2
|
+
import { type RawServeOptions, type ServeOptions } from "./options";
|
|
3
|
+
export { serveHttp } from "./http";
|
|
4
|
+
export { resolveServeOptions } from "./options";
|
|
5
|
+
export type { HttpServeOptions, RawServeOptions, ServeOptions, StdioServeOptions } from "./options";
|
|
6
|
+
export { serveStdio } from "./stdio";
|
|
7
|
+
export type ServeCapletsOptions = {
|
|
8
|
+
raw: RawServeOptions;
|
|
9
|
+
engine?: CapletsEngineOptions;
|
|
10
|
+
env?: NodeJS.ProcessEnv;
|
|
11
|
+
writeErr?: (value: string) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare function serveCaplets(options: ServeCapletsOptions): Promise<void>;
|
|
14
|
+
export declare function serveResolvedCaplets(resolved: ServeOptions, engineOptions?: CapletsEngineOptions, writeErr?: (value: string) => void): Promise<void>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type ServeTransport = "stdio" | "http";
|
|
2
|
+
export type RawServeOptions = {
|
|
3
|
+
transport?: string;
|
|
4
|
+
host?: string;
|
|
5
|
+
port?: string | number;
|
|
6
|
+
path?: string;
|
|
7
|
+
user?: string;
|
|
8
|
+
password?: string;
|
|
9
|
+
allowUnauthenticatedHttp?: boolean;
|
|
10
|
+
trustProxy?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type StdioServeOptions = {
|
|
13
|
+
transport: "stdio";
|
|
14
|
+
};
|
|
15
|
+
export type HttpServeOptions = {
|
|
16
|
+
transport: "http";
|
|
17
|
+
host: string;
|
|
18
|
+
port: number;
|
|
19
|
+
path: string;
|
|
20
|
+
auth: HttpBasicAuthOptions;
|
|
21
|
+
warnUnauthenticatedNetwork: boolean;
|
|
22
|
+
loopback: boolean;
|
|
23
|
+
trustProxy: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type HttpBasicAuthOptions = {
|
|
26
|
+
enabled: false;
|
|
27
|
+
user: string;
|
|
28
|
+
} | {
|
|
29
|
+
enabled: true;
|
|
30
|
+
user: string;
|
|
31
|
+
password: string;
|
|
32
|
+
};
|
|
33
|
+
export type ServeOptions = StdioServeOptions | HttpServeOptions;
|
|
34
|
+
export type ServeEnv = Partial<Record<"CAPLETS_SERVER_URL" | "CAPLETS_SERVER_USER" | "CAPLETS_SERVER_PASSWORD", string>>;
|
|
35
|
+
export declare function resolveServeOptions(raw: RawServeOptions, env?: ServeEnv): ServeOptions;
|
|
36
|
+
export declare function isLoopbackHost(host: string): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
3
|
+
import type { CapletsEngine } from "../engine";
|
|
4
|
+
export type ToolServer = Pick<McpServer, "registerTool" | "connect" | "close">;
|
|
5
|
+
export type CapletsMcpSessionOptions = {
|
|
6
|
+
server?: ToolServer;
|
|
7
|
+
};
|
|
8
|
+
export declare class CapletsMcpSession {
|
|
9
|
+
private readonly engine;
|
|
10
|
+
readonly server: ToolServer;
|
|
11
|
+
private readonly tools;
|
|
12
|
+
private readonly unsubscribeReload;
|
|
13
|
+
private closed;
|
|
14
|
+
constructor(engine: CapletsEngine, options?: CapletsMcpSessionOptions);
|
|
15
|
+
connect(transport: Transport): Promise<void>;
|
|
16
|
+
registeredToolIds(): string[];
|
|
17
|
+
close(): Promise<void>;
|
|
18
|
+
private reconcileTools;
|
|
19
|
+
private registerCapletTool;
|
|
20
|
+
private handleTool;
|
|
21
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type CapletsMode = "auto" | "local" | "remote";
|
|
2
|
+
export type CapletsServerEnv = Partial<Record<"CAPLETS_MODE" | "CAPLETS_SERVER_URL" | "CAPLETS_SERVER_USER" | "CAPLETS_SERVER_PASSWORD", string>>;
|
|
3
|
+
export type CapletsModeInput = {
|
|
4
|
+
mode?: string;
|
|
5
|
+
serverUrl?: string;
|
|
6
|
+
};
|
|
7
|
+
export type CapletsServerInput = {
|
|
8
|
+
url?: string;
|
|
9
|
+
user?: string;
|
|
10
|
+
password?: string;
|
|
11
|
+
fetch?: typeof fetch;
|
|
12
|
+
};
|
|
13
|
+
export type CapletsServerAuth = {
|
|
14
|
+
enabled: false;
|
|
15
|
+
user: string;
|
|
16
|
+
} | {
|
|
17
|
+
enabled: true;
|
|
18
|
+
user: string;
|
|
19
|
+
password: string;
|
|
20
|
+
};
|
|
21
|
+
export type ResolvedCapletsServer = {
|
|
22
|
+
baseUrl: URL;
|
|
23
|
+
mcpUrl: URL;
|
|
24
|
+
controlUrl: URL;
|
|
25
|
+
healthUrl: URL;
|
|
26
|
+
auth: CapletsServerAuth;
|
|
27
|
+
requestInit: RequestInit;
|
|
28
|
+
fetch?: typeof fetch;
|
|
29
|
+
};
|
|
30
|
+
export declare function resolveCapletsMode(input?: CapletsModeInput, env?: CapletsServerEnv): {
|
|
31
|
+
mode: "local";
|
|
32
|
+
} | {
|
|
33
|
+
mode: "remote";
|
|
34
|
+
};
|
|
35
|
+
export declare function resolveCapletsServer(input?: CapletsServerInput, env?: CapletsServerEnv): ResolvedCapletsServer;
|
|
36
|
+
export declare function mcpUrlForBase(baseUrl: URL): URL;
|
|
37
|
+
export declare function controlUrlForBase(baseUrl: URL): URL;
|
|
38
|
+
export declare function healthUrlForBase(baseUrl: URL): URL;
|
|
39
|
+
export declare function appendBasePath(baseUrl: URL, path: string): URL;
|
|
40
|
+
export declare function parseServerBaseUrl(value: string): URL;
|
|
41
|
+
export declare function isLoopbackHost(host: string): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caplets/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Core runtime library for Caplets progressive disclosure gateways.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"caplets",
|
|
@@ -45,9 +45,12 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@apidevtools/swagger-parser": "^12.1.0",
|
|
48
|
+
"@hono/mcp": "^0.3.0",
|
|
49
|
+
"@hono/node-server": "^1.19.14",
|
|
48
50
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
49
51
|
"commander": "^14.0.3",
|
|
50
52
|
"graphql": "^16.14.0",
|
|
53
|
+
"hono": "^4.12.19",
|
|
51
54
|
"vfile": "^6.0.3",
|
|
52
55
|
"vfile-matter": "^5.0.1",
|
|
53
56
|
"zod": "^4.4.3"
|