@lunora/mcp 1.0.0-alpha.25 → 1.0.0-alpha.250
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +120 -0
- package/README.md +202 -14
- package/dist/bin.mjs +4 -47
- package/dist/docs/index.d.mts +259 -0
- package/dist/docs/index.d.ts +259 -0
- package/dist/docs/index.mjs +1 -0
- package/dist/index.d.mts +83 -82
- package/dist/index.d.ts +83 -82
- package/dist/index.mjs +1 -5
- package/dist/node/index.d.mts +90 -0
- package/dist/node/index.d.ts +90 -0
- package/dist/node/index.mjs +1 -0
- package/dist/packem_shared/AGENT_RUN_INPUT_SCHEMA-fnFScxPw.mjs +1 -0
- package/dist/packem_shared/DEFAULT_DOCS_BASE_URL-CiHy_Dbz.mjs +4 -0
- package/dist/packem_shared/DEFAULT_MAX_REQUEST_BYTES-CbbpkHRK.mjs +1 -0
- package/dist/packem_shared/DEFAULT_SEARCH_LIMIT-CPjNPMx3.mjs +3 -0
- package/dist/packem_shared/DOCS_SERVER_NAME-Bk6vD8lk.mjs +1 -0
- package/dist/packem_shared/DOCS_URI_SCHEME-Dd_rZo2y.mjs +3 -0
- package/dist/packem_shared/LOCAL_SERVER_NAME-DfC1rbyh.mjs +1 -0
- package/dist/packem_shared/OBSERVABILITY_TOOL_DEFINITIONS-Dz7pHc8X.mjs +1 -0
- package/dist/packem_shared/READ_ONLY_TOOL_DEFINITIONS-gYI6MQSL.mjs +1 -0
- package/dist/packem_shared/compose.d-CNiBViBW.d.mts +153 -0
- package/dist/packem_shared/compose.d-CNiBViBW.d.ts +153 -0
- package/dist/packem_shared/connectStdio-Bhvmpb81.mjs +1 -0
- package/dist/packem_shared/createAuthedMcpFetchHandler-D-_8Rb95.mjs +1 -0
- package/dist/packem_shared/createLunoraMcpServer-iQFtbxDj.mjs +1 -0
- package/dist/packem_shared/createMcpFetchHandler-D3vS-kTl.mjs +1 -0
- package/dist/packem_shared/createPaidMcpServer-BMuBkZCP.mjs +1 -0
- package/dist/packem_shared/createToolServer-DV1g-DGe.mjs +1 -0
- package/dist/packem_shared/promise-memo-OqVPWoUX.mjs +1 -0
- package/dist/packem_shared/serve-stateless.d-DD5arqFx.d.mts +45 -0
- package/dist/packem_shared/serve-stateless.d-DD5arqFx.d.ts +45 -0
- package/dist/packem_shared/server.d-C7ciln6z.d.mts +152 -0
- package/dist/packem_shared/server.d-CXO7cw_h.d.ts +152 -0
- package/dist/packem_shared/toDocsSearchHits-CBLmtWXt.mjs +1 -0
- package/dist/packem_shared/tool-call-Bs-QeKp6.mjs +1 -0
- package/dist/packem_shared/tool-result-D3oW8Fxx.mjs +1 -0
- package/dist/packem_shared/tools-DiCVoZgA.mjs +2 -0
- package/dist/worker/index.d.mts +257 -0
- package/dist/worker/index.d.ts +257 -0
- package/dist/worker/index.mjs +1 -0
- package/package.json +27 -5
- package/dist/packem_shared/AGENT_RUN_INPUT_SCHEMA-DWobae3P.mjs +0 -168
- package/dist/packem_shared/READ_ONLY_TOOL_DEFINITIONS-CWb_wFd5.mjs +0 -204
- package/dist/packem_shared/connectStdio-bkJcaXYE.mjs +0 -76
- package/dist/packem_shared/createMcpFetchHandler-DfzBSLrm.mjs +0 -14
- package/dist/packem_shared/createPaidMcpServer-b-qp_aEF.mjs +0 -93
package/dist/index.d.mts
CHANGED
|
@@ -1,83 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { A as AGENT_RUN_INPUT_SCHEMA, a as AGENT_STATUS_TOOL_NAME,
|
|
2
|
+
/**
|
|
3
|
+
* `@lunora/mcp` — Model Context Protocol servers for Lunora. This entry exposes
|
|
4
|
+
* a *deployment* to AI agents; the `@lunora/mcp/docs` subpath exposes the
|
|
5
|
+
* framework's *documentation* (credential-free, and safe to host publicly).
|
|
6
|
+
*
|
|
7
|
+
* The deployment server: It registers tools for introspecting a deployment
|
|
8
|
+
* (`lunora_list_functions`, `lunora_list_tables`) and invoking its functions
|
|
9
|
+
* (`lunora_run_query`, plus `lunora_run_mutation` and `lunora_run_action` when
|
|
10
|
+
* writes are enabled), each backed by `LunoraClient` over HTTP RPC, plus
|
|
11
|
+
* `lunora_explain_error` — a credential-free read of the static error catalog
|
|
12
|
+
* (status, title, hint, matched solution) that needs no deployment at all. It also
|
|
13
|
+
* exposes the deployment's observability reads (`lunora_get_logs`,
|
|
14
|
+
* `lunora_get_issues`, `lunora_get_advisories`, `lunora_get_query_insights`,
|
|
15
|
+
* `lunora_get_migration_status`) when `allowObservability` (or the
|
|
16
|
+
* LUNORA_MCP_ALLOW_OBSERVABILITY env) is set — read-only, but they return
|
|
17
|
+
* production user data, so they are omitted entirely without it. The server is
|
|
18
|
+
* read-only by default — the write tools are exposed only when `allowWrites`
|
|
19
|
+
* (or the `LUNORA_MCP_ALLOW_WRITES` env) is set, and every run tool is
|
|
20
|
+
* allowlisted against the deployment's discovered public functions. Past that
|
|
21
|
+
* gate the two write tools run a two-step confirmation handshake: the first
|
|
22
|
+
* call writes nothing and returns the proposed action plus a self-verifying
|
|
23
|
+
* `actionDigest`, and only a second call carrying `confirmed: true` and that
|
|
24
|
+
* digest executes (see `./write-confirmation`). It can also
|
|
25
|
+
* front durable `@lunora/agent` runs as `agent_<name>` tools when `allowAgents`
|
|
26
|
+
* (or `LUNORA_MCP_ALLOW_AGENTS` + `LUNORA_MCP_AGENTS`) is set. Run the
|
|
27
|
+
* `lunora-mcp` binary (configured via the `LUNORA_URL`, `LUNORA_ADMIN_TOKEN`,
|
|
28
|
+
* and `LUNORA_MCP_ALLOW_WRITES` env vars) for the stdio transport, serve the
|
|
29
|
+
* server remotely over Streamable HTTP with `createMcpFetchHandler` (a
|
|
30
|
+
* Workers-ready `Request` → `Response` handler), or build a server
|
|
31
|
+
* programmatically with `createLunoraMcpServer` and connect any transport.
|
|
32
|
+
*
|
|
33
|
+
* A remote endpoint is reachable by anyone who knows its URL, and the tools
|
|
34
|
+
* carry the deployment's admin bearer — so for a public deployment use
|
|
35
|
+
* `createAuthedMcpFetchHandler` instead, which mounts the same server behind
|
|
36
|
+
* better-auth's MCP OAuth gate (`requireMcpAuth` from `@lunora/auth/plugins`)
|
|
37
|
+
* and can scope tool exposure to the access token's own scopes.
|
|
38
|
+
*/
|
|
39
|
+
type C as CallAgentToolOptions, type L as LunoraMcpServerOptions,
|
|
40
|
+
/**
|
|
41
|
+
* `@lunora/mcp` — Model Context Protocol servers for Lunora. This entry exposes
|
|
42
|
+
* a *deployment* to AI agents; the `@lunora/mcp/docs` subpath exposes the
|
|
43
|
+
* framework's *documentation* (credential-free, and safe to host publicly).
|
|
44
|
+
*
|
|
45
|
+
* The deployment server: It registers tools for introspecting a deployment
|
|
46
|
+
* (`lunora_list_functions`, `lunora_list_tables`) and invoking its functions
|
|
47
|
+
* (`lunora_run_query`, plus `lunora_run_mutation` and `lunora_run_action` when
|
|
48
|
+
* writes are enabled), each backed by `LunoraClient` over HTTP RPC, plus
|
|
49
|
+
* `lunora_explain_error` — a credential-free read of the static error catalog
|
|
50
|
+
* (status, title, hint, matched solution) that needs no deployment at all. It also
|
|
51
|
+
* exposes the deployment's observability reads (`lunora_get_logs`,
|
|
52
|
+
* `lunora_get_issues`, `lunora_get_advisories`, `lunora_get_query_insights`,
|
|
53
|
+
* `lunora_get_migration_status`) when `allowObservability` (or the
|
|
54
|
+
* LUNORA_MCP_ALLOW_OBSERVABILITY env) is set — read-only, but they return
|
|
55
|
+
* production user data, so they are omitted entirely without it. The server is
|
|
56
|
+
* read-only by default — the write tools are exposed only when `allowWrites`
|
|
57
|
+
* (or the `LUNORA_MCP_ALLOW_WRITES` env) is set, and every run tool is
|
|
58
|
+
* allowlisted against the deployment's discovered public functions. Past that
|
|
59
|
+
* gate the two write tools run a two-step confirmation handshake: the first
|
|
60
|
+
* call writes nothing and returns the proposed action plus a self-verifying
|
|
61
|
+
* `actionDigest`, and only a second call carrying `confirmed: true` and that
|
|
62
|
+
* digest executes (see `./write-confirmation`). It can also
|
|
63
|
+
* front durable `@lunora/agent` runs as `agent_<name>` tools when `allowAgents`
|
|
64
|
+
* (or `LUNORA_MCP_ALLOW_AGENTS` + `LUNORA_MCP_AGENTS`) is set. Run the
|
|
65
|
+
* `lunora-mcp` binary (configured via the `LUNORA_URL`, `LUNORA_ADMIN_TOKEN`,
|
|
66
|
+
* and `LUNORA_MCP_ALLOW_WRITES` env vars) for the stdio transport, serve the
|
|
67
|
+
* server remotely over Streamable HTTP with `createMcpFetchHandler` (a
|
|
68
|
+
* Workers-ready `Request` → `Response` handler), or build a server
|
|
69
|
+
* programmatically with `createLunoraMcpServer` and connect any transport.
|
|
70
|
+
*
|
|
71
|
+
* A remote endpoint is reachable by anyone who knows its URL, and the tools
|
|
72
|
+
* carry the deployment's admin bearer — so for a public deployment use
|
|
73
|
+
* `createAuthedMcpFetchHandler` instead, which mounts the same server behind
|
|
74
|
+
* better-auth's MCP OAuth gate (`requireMcpAuth` from `@lunora/auth/plugins`)
|
|
75
|
+
* and can scope tool exposure to the access token's own scopes.
|
|
76
|
+
*/
|
|
77
|
+
type M as McpAgentExposure, b as agentToolDefinitions, c as callAgentTool, d as createLunoraMcpServer, p as parseAgentsEnv } from "./packem_shared/server.d-C7ciln6z.mjs";
|
|
78
|
+
export { type AuthedMcpFetchHandlerOptions, type AuthedMcpServerOptions, type McpAccessTokenClaims, type McpAuthProtect, type McpFetchHandlerOptions, OBSERVABILITY_TOOL_DEFINITIONS, type PaidMcpChargeConfig, type PaidMcpExecutionContext, type PaidMcpFetchHandler, type PaidMcpServer, type PaidMcpServerConfig, READ_ONLY_TOOL_DEFINITIONS, type RegisterPaidToolOptions, type RegisterToolOptions, type ToolHandler, WRITE_TOOL_DEFINITIONS, callTool, createAuthedMcpFetchHandler, createMcpFetchHandler, createPaidMcpServer, mcpTokenScopes, toolDefinitions } from "./worker/index.mjs";
|
|
79
|
+
export { type M as McpServerInfo, type a as McpTool, type T as ToolDefinition, type b as ToolInputSchema, type c as ToolOutputSchema, type d as ToolResult, e as createToolServer } from "./packem_shared/compose.d-CNiBViBW.mjs";
|
|
80
|
+
export { LOCAL_SERVER_NAME, type LocalDeployment, type LocalDeploymentSource, type LocalMcpServerOptions, NO_DEPLOYMENT_MESSAGE, connectLocalStdio, connectStdio, createLocalMcpServer, localTools } from "./node/index.mjs";
|
|
81
|
+
export { D as DEFAULT_MAX_REQUEST_BYTES, type M as McpFetchHandler, type S as ServeStatelessOptions, s as serveStateless } from "./packem_shared/serve-stateless.d-DD5arqFx.mjs";
|
|
82
|
+
import '@lunora/client';
|
|
83
|
+
import '@modelcontextprotocol/sdk/server/index.js';
|
|
3
84
|
import '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
|
|
4
|
-
import { X402ChargeConfig, X402Price } from '@lunora/x402/charge';
|
|
5
|
-
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
6
|
-
interface ToolInputSchema {
|
|
7
|
-
properties: Record<string, unknown>;
|
|
8
|
-
required?: ReadonlyArray<string>;
|
|
9
|
-
type: "object";
|
|
10
|
-
}
|
|
11
|
-
interface ToolDefinition {
|
|
12
|
-
description: string;
|
|
13
|
-
inputSchema: ToolInputSchema;
|
|
14
|
-
name: string;
|
|
15
|
-
}
|
|
16
|
-
interface ToolResult {
|
|
17
|
-
content: {
|
|
18
|
-
text: string;
|
|
19
|
-
type: "text";
|
|
20
|
-
}[];
|
|
21
|
-
isError?: boolean;
|
|
22
|
-
}
|
|
23
|
-
declare const READ_ONLY_TOOL_DEFINITIONS: ReadonlyArray<ToolDefinition>;
|
|
24
|
-
declare const WRITE_TOOL_DEFINITIONS: ReadonlyArray<ToolDefinition>;
|
|
25
|
-
declare const toolDefinitions: (allowWrites: boolean) => ReadonlyArray<ToolDefinition>;
|
|
26
|
-
declare const callTool: (client: LunoraClient, name: string, input: Record<string, unknown>, allowWrites?: boolean) => Promise<ToolResult>;
|
|
27
|
-
interface McpAgentExposure {
|
|
28
|
-
description: string;
|
|
29
|
-
name: string;
|
|
30
|
-
toolName?: string;
|
|
31
|
-
}
|
|
32
|
-
declare const AGENT_STATUS_TOOL_NAME = "lunora_agent_status";
|
|
33
|
-
declare const AGENT_RUN_INPUT_SCHEMA: ToolInputSchema;
|
|
34
|
-
declare const parseAgentsEnv: (raw: string | undefined) => McpAgentExposure[];
|
|
35
|
-
declare const agentToolDefinitions: (exposures: ReadonlyArray<McpAgentExposure>, allowAgents: boolean) => ReadonlyArray<ToolDefinition>;
|
|
36
|
-
interface CallAgentToolOptions {
|
|
37
|
-
allowAgents: boolean;
|
|
38
|
-
exposures: ReadonlyArray<McpAgentExposure>;
|
|
39
|
-
maxWaitMs?: number;
|
|
40
|
-
pollIntervalMs?: number;
|
|
41
|
-
wait?: (ms: number) => Promise<void>;
|
|
42
|
-
}
|
|
43
|
-
declare const callAgentTool: (client: LunoraClient, name: string, input: Record<string, unknown>, options: CallAgentToolOptions) => Promise<ToolResult>;
|
|
44
|
-
interface LunoraMcpServerOptions {
|
|
45
|
-
agentMaxWaitMs?: number;
|
|
46
|
-
agentPollIntervalMs?: number;
|
|
47
|
-
agents?: ReadonlyArray<McpAgentExposure>;
|
|
48
|
-
allowAgents?: boolean;
|
|
49
|
-
allowWrites?: boolean;
|
|
50
|
-
client?: LunoraClient;
|
|
51
|
-
fetch?: typeof fetch;
|
|
52
|
-
token?: string;
|
|
53
|
-
url?: string;
|
|
54
|
-
}
|
|
55
|
-
declare const createLunoraMcpServer: (options: LunoraMcpServerOptions) => Server;
|
|
56
|
-
declare const connectStdio: (options: LunoraMcpServerOptions) => Promise<Server>;
|
|
57
|
-
type McpFetchHandler = (request: Request) => Promise<Response>;
|
|
58
|
-
declare const createMcpFetchHandler: (options: LunoraMcpServerOptions) => McpFetchHandler;
|
|
59
|
-
type ToolHandler = (arguments_: Record<string, unknown>) => Promise<ToolResult> | ToolResult;
|
|
60
|
-
interface RegisterToolOptions {
|
|
61
|
-
annotations?: Tool["annotations"];
|
|
62
|
-
description: string;
|
|
63
|
-
inputSchema: ToolInputSchema;
|
|
64
|
-
name: string;
|
|
65
|
-
}
|
|
66
|
-
interface RegisterPaidToolOptions extends RegisterToolOptions {
|
|
67
|
-
price: X402Price;
|
|
68
|
-
}
|
|
69
|
-
type PaidMcpChargeConfig = Omit<X402ChargeConfig, "price">;
|
|
70
|
-
interface PaidMcpServerConfig {
|
|
71
|
-
charge: PaidMcpChargeConfig;
|
|
72
|
-
serverInfo?: {
|
|
73
|
-
name: string;
|
|
74
|
-
version: string;
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
interface PaidMcpServer {
|
|
78
|
-
readonly fetchHandler: McpFetchHandler;
|
|
79
|
-
paidTool: (options: RegisterPaidToolOptions, handler: ToolHandler) => void;
|
|
80
|
-
tool: (options: RegisterToolOptions, handler: ToolHandler) => void;
|
|
81
|
-
}
|
|
82
|
-
declare const createPaidMcpServer: (config: PaidMcpServerConfig) => PaidMcpServer;
|
|
83
|
-
export { AGENT_RUN_INPUT_SCHEMA, AGENT_STATUS_TOOL_NAME, type CallAgentToolOptions, type LunoraMcpServerOptions, type McpAgentExposure, type McpFetchHandler, type PaidMcpChargeConfig, type PaidMcpServer, type PaidMcpServerConfig, READ_ONLY_TOOL_DEFINITIONS, type RegisterPaidToolOptions, type RegisterToolOptions, type ToolDefinition, type ToolHandler, type ToolInputSchema, type ToolResult, WRITE_TOOL_DEFINITIONS, agentToolDefinitions, callAgentTool, callTool, connectStdio, createLunoraMcpServer, createMcpFetchHandler, createPaidMcpServer, parseAgentsEnv, toolDefinitions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,83 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { A as AGENT_RUN_INPUT_SCHEMA, a as AGENT_STATUS_TOOL_NAME,
|
|
2
|
+
/**
|
|
3
|
+
* `@lunora/mcp` — Model Context Protocol servers for Lunora. This entry exposes
|
|
4
|
+
* a *deployment* to AI agents; the `@lunora/mcp/docs` subpath exposes the
|
|
5
|
+
* framework's *documentation* (credential-free, and safe to host publicly).
|
|
6
|
+
*
|
|
7
|
+
* The deployment server: It registers tools for introspecting a deployment
|
|
8
|
+
* (`lunora_list_functions`, `lunora_list_tables`) and invoking its functions
|
|
9
|
+
* (`lunora_run_query`, plus `lunora_run_mutation` and `lunora_run_action` when
|
|
10
|
+
* writes are enabled), each backed by `LunoraClient` over HTTP RPC, plus
|
|
11
|
+
* `lunora_explain_error` — a credential-free read of the static error catalog
|
|
12
|
+
* (status, title, hint, matched solution) that needs no deployment at all. It also
|
|
13
|
+
* exposes the deployment's observability reads (`lunora_get_logs`,
|
|
14
|
+
* `lunora_get_issues`, `lunora_get_advisories`, `lunora_get_query_insights`,
|
|
15
|
+
* `lunora_get_migration_status`) when `allowObservability` (or the
|
|
16
|
+
* LUNORA_MCP_ALLOW_OBSERVABILITY env) is set — read-only, but they return
|
|
17
|
+
* production user data, so they are omitted entirely without it. The server is
|
|
18
|
+
* read-only by default — the write tools are exposed only when `allowWrites`
|
|
19
|
+
* (or the `LUNORA_MCP_ALLOW_WRITES` env) is set, and every run tool is
|
|
20
|
+
* allowlisted against the deployment's discovered public functions. Past that
|
|
21
|
+
* gate the two write tools run a two-step confirmation handshake: the first
|
|
22
|
+
* call writes nothing and returns the proposed action plus a self-verifying
|
|
23
|
+
* `actionDigest`, and only a second call carrying `confirmed: true` and that
|
|
24
|
+
* digest executes (see `./write-confirmation`). It can also
|
|
25
|
+
* front durable `@lunora/agent` runs as `agent_<name>` tools when `allowAgents`
|
|
26
|
+
* (or `LUNORA_MCP_ALLOW_AGENTS` + `LUNORA_MCP_AGENTS`) is set. Run the
|
|
27
|
+
* `lunora-mcp` binary (configured via the `LUNORA_URL`, `LUNORA_ADMIN_TOKEN`,
|
|
28
|
+
* and `LUNORA_MCP_ALLOW_WRITES` env vars) for the stdio transport, serve the
|
|
29
|
+
* server remotely over Streamable HTTP with `createMcpFetchHandler` (a
|
|
30
|
+
* Workers-ready `Request` → `Response` handler), or build a server
|
|
31
|
+
* programmatically with `createLunoraMcpServer` and connect any transport.
|
|
32
|
+
*
|
|
33
|
+
* A remote endpoint is reachable by anyone who knows its URL, and the tools
|
|
34
|
+
* carry the deployment's admin bearer — so for a public deployment use
|
|
35
|
+
* `createAuthedMcpFetchHandler` instead, which mounts the same server behind
|
|
36
|
+
* better-auth's MCP OAuth gate (`requireMcpAuth` from `@lunora/auth/plugins`)
|
|
37
|
+
* and can scope tool exposure to the access token's own scopes.
|
|
38
|
+
*/
|
|
39
|
+
type C as CallAgentToolOptions, type L as LunoraMcpServerOptions,
|
|
40
|
+
/**
|
|
41
|
+
* `@lunora/mcp` — Model Context Protocol servers for Lunora. This entry exposes
|
|
42
|
+
* a *deployment* to AI agents; the `@lunora/mcp/docs` subpath exposes the
|
|
43
|
+
* framework's *documentation* (credential-free, and safe to host publicly).
|
|
44
|
+
*
|
|
45
|
+
* The deployment server: It registers tools for introspecting a deployment
|
|
46
|
+
* (`lunora_list_functions`, `lunora_list_tables`) and invoking its functions
|
|
47
|
+
* (`lunora_run_query`, plus `lunora_run_mutation` and `lunora_run_action` when
|
|
48
|
+
* writes are enabled), each backed by `LunoraClient` over HTTP RPC, plus
|
|
49
|
+
* `lunora_explain_error` — a credential-free read of the static error catalog
|
|
50
|
+
* (status, title, hint, matched solution) that needs no deployment at all. It also
|
|
51
|
+
* exposes the deployment's observability reads (`lunora_get_logs`,
|
|
52
|
+
* `lunora_get_issues`, `lunora_get_advisories`, `lunora_get_query_insights`,
|
|
53
|
+
* `lunora_get_migration_status`) when `allowObservability` (or the
|
|
54
|
+
* LUNORA_MCP_ALLOW_OBSERVABILITY env) is set — read-only, but they return
|
|
55
|
+
* production user data, so they are omitted entirely without it. The server is
|
|
56
|
+
* read-only by default — the write tools are exposed only when `allowWrites`
|
|
57
|
+
* (or the `LUNORA_MCP_ALLOW_WRITES` env) is set, and every run tool is
|
|
58
|
+
* allowlisted against the deployment's discovered public functions. Past that
|
|
59
|
+
* gate the two write tools run a two-step confirmation handshake: the first
|
|
60
|
+
* call writes nothing and returns the proposed action plus a self-verifying
|
|
61
|
+
* `actionDigest`, and only a second call carrying `confirmed: true` and that
|
|
62
|
+
* digest executes (see `./write-confirmation`). It can also
|
|
63
|
+
* front durable `@lunora/agent` runs as `agent_<name>` tools when `allowAgents`
|
|
64
|
+
* (or `LUNORA_MCP_ALLOW_AGENTS` + `LUNORA_MCP_AGENTS`) is set. Run the
|
|
65
|
+
* `lunora-mcp` binary (configured via the `LUNORA_URL`, `LUNORA_ADMIN_TOKEN`,
|
|
66
|
+
* and `LUNORA_MCP_ALLOW_WRITES` env vars) for the stdio transport, serve the
|
|
67
|
+
* server remotely over Streamable HTTP with `createMcpFetchHandler` (a
|
|
68
|
+
* Workers-ready `Request` → `Response` handler), or build a server
|
|
69
|
+
* programmatically with `createLunoraMcpServer` and connect any transport.
|
|
70
|
+
*
|
|
71
|
+
* A remote endpoint is reachable by anyone who knows its URL, and the tools
|
|
72
|
+
* carry the deployment's admin bearer — so for a public deployment use
|
|
73
|
+
* `createAuthedMcpFetchHandler` instead, which mounts the same server behind
|
|
74
|
+
* better-auth's MCP OAuth gate (`requireMcpAuth` from `@lunora/auth/plugins`)
|
|
75
|
+
* and can scope tool exposure to the access token's own scopes.
|
|
76
|
+
*/
|
|
77
|
+
type M as McpAgentExposure, b as agentToolDefinitions, c as callAgentTool, d as createLunoraMcpServer, p as parseAgentsEnv } from "./packem_shared/server.d-CXO7cw_h.js";
|
|
78
|
+
export { type AuthedMcpFetchHandlerOptions, type AuthedMcpServerOptions, type McpAccessTokenClaims, type McpAuthProtect, type McpFetchHandlerOptions, OBSERVABILITY_TOOL_DEFINITIONS, type PaidMcpChargeConfig, type PaidMcpExecutionContext, type PaidMcpFetchHandler, type PaidMcpServer, type PaidMcpServerConfig, READ_ONLY_TOOL_DEFINITIONS, type RegisterPaidToolOptions, type RegisterToolOptions, type ToolHandler, WRITE_TOOL_DEFINITIONS, callTool, createAuthedMcpFetchHandler, createMcpFetchHandler, createPaidMcpServer, mcpTokenScopes, toolDefinitions } from "./worker/index.js";
|
|
79
|
+
export { type M as McpServerInfo, type a as McpTool, type T as ToolDefinition, type b as ToolInputSchema, type c as ToolOutputSchema, type d as ToolResult, e as createToolServer } from "./packem_shared/compose.d-CNiBViBW.js";
|
|
80
|
+
export { LOCAL_SERVER_NAME, type LocalDeployment, type LocalDeploymentSource, type LocalMcpServerOptions, NO_DEPLOYMENT_MESSAGE, connectLocalStdio, connectStdio, createLocalMcpServer, localTools } from "./node/index.js";
|
|
81
|
+
export { D as DEFAULT_MAX_REQUEST_BYTES, type M as McpFetchHandler, type S as ServeStatelessOptions, s as serveStateless } from "./packem_shared/serve-stateless.d-DD5arqFx.js";
|
|
82
|
+
import '@lunora/client';
|
|
83
|
+
import '@modelcontextprotocol/sdk/server/index.js';
|
|
3
84
|
import '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
|
|
4
|
-
import { X402ChargeConfig, X402Price } from '@lunora/x402/charge';
|
|
5
|
-
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
6
|
-
interface ToolInputSchema {
|
|
7
|
-
properties: Record<string, unknown>;
|
|
8
|
-
required?: ReadonlyArray<string>;
|
|
9
|
-
type: "object";
|
|
10
|
-
}
|
|
11
|
-
interface ToolDefinition {
|
|
12
|
-
description: string;
|
|
13
|
-
inputSchema: ToolInputSchema;
|
|
14
|
-
name: string;
|
|
15
|
-
}
|
|
16
|
-
interface ToolResult {
|
|
17
|
-
content: {
|
|
18
|
-
text: string;
|
|
19
|
-
type: "text";
|
|
20
|
-
}[];
|
|
21
|
-
isError?: boolean;
|
|
22
|
-
}
|
|
23
|
-
declare const READ_ONLY_TOOL_DEFINITIONS: ReadonlyArray<ToolDefinition>;
|
|
24
|
-
declare const WRITE_TOOL_DEFINITIONS: ReadonlyArray<ToolDefinition>;
|
|
25
|
-
declare const toolDefinitions: (allowWrites: boolean) => ReadonlyArray<ToolDefinition>;
|
|
26
|
-
declare const callTool: (client: LunoraClient, name: string, input: Record<string, unknown>, allowWrites?: boolean) => Promise<ToolResult>;
|
|
27
|
-
interface McpAgentExposure {
|
|
28
|
-
description: string;
|
|
29
|
-
name: string;
|
|
30
|
-
toolName?: string;
|
|
31
|
-
}
|
|
32
|
-
declare const AGENT_STATUS_TOOL_NAME = "lunora_agent_status";
|
|
33
|
-
declare const AGENT_RUN_INPUT_SCHEMA: ToolInputSchema;
|
|
34
|
-
declare const parseAgentsEnv: (raw: string | undefined) => McpAgentExposure[];
|
|
35
|
-
declare const agentToolDefinitions: (exposures: ReadonlyArray<McpAgentExposure>, allowAgents: boolean) => ReadonlyArray<ToolDefinition>;
|
|
36
|
-
interface CallAgentToolOptions {
|
|
37
|
-
allowAgents: boolean;
|
|
38
|
-
exposures: ReadonlyArray<McpAgentExposure>;
|
|
39
|
-
maxWaitMs?: number;
|
|
40
|
-
pollIntervalMs?: number;
|
|
41
|
-
wait?: (ms: number) => Promise<void>;
|
|
42
|
-
}
|
|
43
|
-
declare const callAgentTool: (client: LunoraClient, name: string, input: Record<string, unknown>, options: CallAgentToolOptions) => Promise<ToolResult>;
|
|
44
|
-
interface LunoraMcpServerOptions {
|
|
45
|
-
agentMaxWaitMs?: number;
|
|
46
|
-
agentPollIntervalMs?: number;
|
|
47
|
-
agents?: ReadonlyArray<McpAgentExposure>;
|
|
48
|
-
allowAgents?: boolean;
|
|
49
|
-
allowWrites?: boolean;
|
|
50
|
-
client?: LunoraClient;
|
|
51
|
-
fetch?: typeof fetch;
|
|
52
|
-
token?: string;
|
|
53
|
-
url?: string;
|
|
54
|
-
}
|
|
55
|
-
declare const createLunoraMcpServer: (options: LunoraMcpServerOptions) => Server;
|
|
56
|
-
declare const connectStdio: (options: LunoraMcpServerOptions) => Promise<Server>;
|
|
57
|
-
type McpFetchHandler = (request: Request) => Promise<Response>;
|
|
58
|
-
declare const createMcpFetchHandler: (options: LunoraMcpServerOptions) => McpFetchHandler;
|
|
59
|
-
type ToolHandler = (arguments_: Record<string, unknown>) => Promise<ToolResult> | ToolResult;
|
|
60
|
-
interface RegisterToolOptions {
|
|
61
|
-
annotations?: Tool["annotations"];
|
|
62
|
-
description: string;
|
|
63
|
-
inputSchema: ToolInputSchema;
|
|
64
|
-
name: string;
|
|
65
|
-
}
|
|
66
|
-
interface RegisterPaidToolOptions extends RegisterToolOptions {
|
|
67
|
-
price: X402Price;
|
|
68
|
-
}
|
|
69
|
-
type PaidMcpChargeConfig = Omit<X402ChargeConfig, "price">;
|
|
70
|
-
interface PaidMcpServerConfig {
|
|
71
|
-
charge: PaidMcpChargeConfig;
|
|
72
|
-
serverInfo?: {
|
|
73
|
-
name: string;
|
|
74
|
-
version: string;
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
interface PaidMcpServer {
|
|
78
|
-
readonly fetchHandler: McpFetchHandler;
|
|
79
|
-
paidTool: (options: RegisterPaidToolOptions, handler: ToolHandler) => void;
|
|
80
|
-
tool: (options: RegisterToolOptions, handler: ToolHandler) => void;
|
|
81
|
-
}
|
|
82
|
-
declare const createPaidMcpServer: (config: PaidMcpServerConfig) => PaidMcpServer;
|
|
83
|
-
export { AGENT_RUN_INPUT_SCHEMA, AGENT_STATUS_TOOL_NAME, type CallAgentToolOptions, type LunoraMcpServerOptions, type McpAgentExposure, type McpFetchHandler, type PaidMcpChargeConfig, type PaidMcpServer, type PaidMcpServerConfig, READ_ONLY_TOOL_DEFINITIONS, type RegisterPaidToolOptions, type RegisterToolOptions, type ToolDefinition, type ToolHandler, type ToolInputSchema, type ToolResult, WRITE_TOOL_DEFINITIONS, agentToolDefinitions, callAgentTool, callTool, connectStdio, createLunoraMcpServer, createMcpFetchHandler, createPaidMcpServer, parseAgentsEnv, toolDefinitions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { createMcpFetchHandler } from './packem_shared/createMcpFetchHandler-DfzBSLrm.mjs';
|
|
3
|
-
export { createPaidMcpServer } from './packem_shared/createPaidMcpServer-b-qp_aEF.mjs';
|
|
4
|
-
export { connectStdio, createLunoraMcpServer } from './packem_shared/connectStdio-bkJcaXYE.mjs';
|
|
5
|
-
export { READ_ONLY_TOOL_DEFINITIONS, WRITE_TOOL_DEFINITIONS, callTool, toolDefinitions } from './packem_shared/READ_ONLY_TOOL_DEFINITIONS-CWb_wFd5.mjs';
|
|
1
|
+
import{AGENT_RUN_INPUT_SCHEMA as r,AGENT_STATUS_TOOL_NAME as t,agentToolDefinitions as c,callAgentTool as a,parseAgentsEnv as T}from"./packem_shared/AGENT_RUN_INPUT_SCHEMA-fnFScxPw.mjs";import{createAuthedMcpFetchHandler as S,mcpTokenScopes as _}from"./packem_shared/createAuthedMcpFetchHandler-D-_8Rb95.mjs";import{createToolServer as l}from"./packem_shared/createToolServer-DV1g-DGe.mjs";import{createMcpFetchHandler as O}from"./packem_shared/createMcpFetchHandler-D3vS-kTl.mjs";import{LOCAL_SERVER_NAME as N,NO_DEPLOYMENT_MESSAGE as f,connectLocalStdio as s,createLocalMcpServer as I,localTools as L}from"./packem_shared/LOCAL_SERVER_NAME-DfC1rbyh.mjs";import{createPaidMcpServer as x}from"./packem_shared/createPaidMcpServer-BMuBkZCP.mjs";import{createLunoraMcpServer as i}from"./packem_shared/createLunoraMcpServer-iQFtbxDj.mjs";import{default as R}from"./packem_shared/connectStdio-Bhvmpb81.mjs";import{R as v,W as F,c as U,t as Y}from"./packem_shared/tools-DiCVoZgA.mjs";import{DEFAULT_MAX_REQUEST_BYTES as h,serveStateless as u}from"./packem_shared/DEFAULT_MAX_REQUEST_BYTES-CbbpkHRK.mjs";import{OBSERVABILITY_TOOL_DEFINITIONS as G}from"./packem_shared/OBSERVABILITY_TOOL_DEFINITIONS-Dz7pHc8X.mjs";export{r as AGENT_RUN_INPUT_SCHEMA,t as AGENT_STATUS_TOOL_NAME,h as DEFAULT_MAX_REQUEST_BYTES,N as LOCAL_SERVER_NAME,f as NO_DEPLOYMENT_MESSAGE,G as OBSERVABILITY_TOOL_DEFINITIONS,v as READ_ONLY_TOOL_DEFINITIONS,F as WRITE_TOOL_DEFINITIONS,c as agentToolDefinitions,a as callAgentTool,U as callTool,s as connectLocalStdio,R as connectStdio,S as createAuthedMcpFetchHandler,I as createLocalMcpServer,i as createLunoraMcpServer,O as createMcpFetchHandler,x as createPaidMcpServer,l as createToolServer,L as localTools,_ as mcpTokenScopes,T as parseAgentsEnv,u as serveStateless,Y as toolDefinitions};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { LunoraClient } from '@lunora/client';
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { a as McpTool } from "../packem_shared/compose.d-CNiBViBW.mjs";
|
|
4
|
+
import { L as LunoraMcpServerOptions } from "../packem_shared/server.d-C7ciln6z.mjs";
|
|
5
|
+
export { d as createLunoraMcpServer } from "../packem_shared/server.d-C7ciln6z.mjs";
|
|
6
|
+
/** A Lunora deployment the tools dispatch against. */
|
|
7
|
+
interface LocalDeployment {
|
|
8
|
+
token?: string;
|
|
9
|
+
url: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Where the deployment comes from: a fixed value, or a function consulted on
|
|
13
|
+
* every tool call.
|
|
14
|
+
*
|
|
15
|
+
* The resolver form exists because an editor spawns this server when the
|
|
16
|
+
* project opens — routinely *before* `lunora dev` is running, and it keeps the
|
|
17
|
+
* process alive across every restart afterwards. A URL captured once at startup
|
|
18
|
+
* would therefore be absent for the entire first session and stale after the
|
|
19
|
+
* first restart.
|
|
20
|
+
*/
|
|
21
|
+
type LocalDeploymentSource = (() => LocalDeployment | undefined) | LocalDeployment;
|
|
22
|
+
interface LocalMcpServerOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Expose the deployment write tools (`lunora_run_mutation` /
|
|
25
|
+
* `lunora_run_action`). Defaults to `false` — the same fail-closed default
|
|
26
|
+
* as the remote server. Locally the blast radius is dev data rather than
|
|
27
|
+
* production, but a mutation is still a side effect an agent should be
|
|
28
|
+
* granted deliberately.
|
|
29
|
+
*/
|
|
30
|
+
allowWrites?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The Lunora deployment (usually the running dev server) to expose. Omit to
|
|
33
|
+
* leave the deployment tools out entirely.
|
|
34
|
+
*/
|
|
35
|
+
deployment?: LocalDeploymentSource;
|
|
36
|
+
/** Docs site origin backing the documentation tools; `false` omits them. */
|
|
37
|
+
docs?: false | {
|
|
38
|
+
baseUrl?: string;
|
|
39
|
+
};
|
|
40
|
+
/** Extra tools to compose in, e.g. the CLI's local dev-server tools. */
|
|
41
|
+
extraTools?: ReadonlyArray<McpTool>;
|
|
42
|
+
/** `fetch` implementation; defaults to the ambient global. */
|
|
43
|
+
fetch?: typeof fetch;
|
|
44
|
+
/** Version reported in the MCP handshake — the host CLI's, not this package's. */
|
|
45
|
+
version?: string;
|
|
46
|
+
}
|
|
47
|
+
/** Server identity advertised in the MCP `initialize` handshake. */
|
|
48
|
+
declare const LOCAL_SERVER_NAME = "lunora";
|
|
49
|
+
/** Shown when a deployment tool is called and no dev server can be found. */
|
|
50
|
+
declare const NO_DEPLOYMENT_MESSAGE = "no Lunora dev server is running for this project — start one with `lunora dev`, then call this tool again (call lunora_dev_status to check).";
|
|
51
|
+
/**
|
|
52
|
+
* Assemble the tool list, in the order it is advertised: docs first (the
|
|
53
|
+
* surface that always works), then the caller's extras, then the error catalog
|
|
54
|
+
* (compiled in, so it needs no deployment either), then the deployment tools.
|
|
55
|
+
* Order also decides precedence — `createToolServer` keeps the first
|
|
56
|
+
* registration of a duplicated name.
|
|
57
|
+
*
|
|
58
|
+
* `clientFor` is the shared client cache built once by
|
|
59
|
+
* {@link createLocalMcpServer} and threaded into both the tool and resource
|
|
60
|
+
* surfaces. Exported (and called directly by tests) without going through
|
|
61
|
+
* `createLocalMcpServer`, so a caller that omits it gets a private,
|
|
62
|
+
* call-scoped cache — same shape as before this surface was shared, just
|
|
63
|
+
* without the cross-surface sharing that only matters once a resource
|
|
64
|
+
* surface exists alongside it.
|
|
65
|
+
*/
|
|
66
|
+
declare const localTools: (options: LocalMcpServerOptions, clientFor?: (deployment: LocalDeployment) => LunoraClient) => ReadonlyArray<McpTool>;
|
|
67
|
+
/** Build the composed local server without connecting a transport. */
|
|
68
|
+
declare const createLocalMcpServer: (options?: LocalMcpServerOptions) => Server;
|
|
69
|
+
/**
|
|
70
|
+
* Build the composed local server and connect it over stdio — the transport an
|
|
71
|
+
* MCP client uses when it spawns `lunora mcp serve`. Resolves once connected;
|
|
72
|
+
* the process then stays alive serving requests.
|
|
73
|
+
*/
|
|
74
|
+
declare const connectLocalStdio: (options?: LocalMcpServerOptions) => Promise<Server>;
|
|
75
|
+
/**
|
|
76
|
+
* Build the server and connect it over stdio — the transport MCP clients use
|
|
77
|
+
* when they spawn the `lunora-mcp` binary. Resolves once the transport is
|
|
78
|
+
* connected; the process then stays alive serving requests.
|
|
79
|
+
*
|
|
80
|
+
* Lives apart from `server.ts` so the Worker entry's module graph never pulls
|
|
81
|
+
* in the stdio transport (and its `node:process` import).
|
|
82
|
+
*/
|
|
83
|
+
declare const connectStdio: (options: LunoraMcpServerOptions) => Promise<Server>;
|
|
84
|
+
export { LOCAL_SERVER_NAME,
|
|
85
|
+
/** Node-only entry: the stdio transport and the local/deployment servers. */
|
|
86
|
+
type LocalDeployment,
|
|
87
|
+
/** Node-only entry: the stdio transport and the local/deployment servers. */
|
|
88
|
+
type LocalDeploymentSource,
|
|
89
|
+
/** Node-only entry: the stdio transport and the local/deployment servers. */
|
|
90
|
+
type LocalMcpServerOptions, type LunoraMcpServerOptions, NO_DEPLOYMENT_MESSAGE, connectLocalStdio, connectStdio, createLocalMcpServer, localTools };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { LunoraClient } from '@lunora/client';
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { a as McpTool } from "../packem_shared/compose.d-CNiBViBW.js";
|
|
4
|
+
import { L as LunoraMcpServerOptions } from "../packem_shared/server.d-CXO7cw_h.js";
|
|
5
|
+
export { d as createLunoraMcpServer } from "../packem_shared/server.d-CXO7cw_h.js";
|
|
6
|
+
/** A Lunora deployment the tools dispatch against. */
|
|
7
|
+
interface LocalDeployment {
|
|
8
|
+
token?: string;
|
|
9
|
+
url: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Where the deployment comes from: a fixed value, or a function consulted on
|
|
13
|
+
* every tool call.
|
|
14
|
+
*
|
|
15
|
+
* The resolver form exists because an editor spawns this server when the
|
|
16
|
+
* project opens — routinely *before* `lunora dev` is running, and it keeps the
|
|
17
|
+
* process alive across every restart afterwards. A URL captured once at startup
|
|
18
|
+
* would therefore be absent for the entire first session and stale after the
|
|
19
|
+
* first restart.
|
|
20
|
+
*/
|
|
21
|
+
type LocalDeploymentSource = (() => LocalDeployment | undefined) | LocalDeployment;
|
|
22
|
+
interface LocalMcpServerOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Expose the deployment write tools (`lunora_run_mutation` /
|
|
25
|
+
* `lunora_run_action`). Defaults to `false` — the same fail-closed default
|
|
26
|
+
* as the remote server. Locally the blast radius is dev data rather than
|
|
27
|
+
* production, but a mutation is still a side effect an agent should be
|
|
28
|
+
* granted deliberately.
|
|
29
|
+
*/
|
|
30
|
+
allowWrites?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The Lunora deployment (usually the running dev server) to expose. Omit to
|
|
33
|
+
* leave the deployment tools out entirely.
|
|
34
|
+
*/
|
|
35
|
+
deployment?: LocalDeploymentSource;
|
|
36
|
+
/** Docs site origin backing the documentation tools; `false` omits them. */
|
|
37
|
+
docs?: false | {
|
|
38
|
+
baseUrl?: string;
|
|
39
|
+
};
|
|
40
|
+
/** Extra tools to compose in, e.g. the CLI's local dev-server tools. */
|
|
41
|
+
extraTools?: ReadonlyArray<McpTool>;
|
|
42
|
+
/** `fetch` implementation; defaults to the ambient global. */
|
|
43
|
+
fetch?: typeof fetch;
|
|
44
|
+
/** Version reported in the MCP handshake — the host CLI's, not this package's. */
|
|
45
|
+
version?: string;
|
|
46
|
+
}
|
|
47
|
+
/** Server identity advertised in the MCP `initialize` handshake. */
|
|
48
|
+
declare const LOCAL_SERVER_NAME = "lunora";
|
|
49
|
+
/** Shown when a deployment tool is called and no dev server can be found. */
|
|
50
|
+
declare const NO_DEPLOYMENT_MESSAGE = "no Lunora dev server is running for this project — start one with `lunora dev`, then call this tool again (call lunora_dev_status to check).";
|
|
51
|
+
/**
|
|
52
|
+
* Assemble the tool list, in the order it is advertised: docs first (the
|
|
53
|
+
* surface that always works), then the caller's extras, then the error catalog
|
|
54
|
+
* (compiled in, so it needs no deployment either), then the deployment tools.
|
|
55
|
+
* Order also decides precedence — `createToolServer` keeps the first
|
|
56
|
+
* registration of a duplicated name.
|
|
57
|
+
*
|
|
58
|
+
* `clientFor` is the shared client cache built once by
|
|
59
|
+
* {@link createLocalMcpServer} and threaded into both the tool and resource
|
|
60
|
+
* surfaces. Exported (and called directly by tests) without going through
|
|
61
|
+
* `createLocalMcpServer`, so a caller that omits it gets a private,
|
|
62
|
+
* call-scoped cache — same shape as before this surface was shared, just
|
|
63
|
+
* without the cross-surface sharing that only matters once a resource
|
|
64
|
+
* surface exists alongside it.
|
|
65
|
+
*/
|
|
66
|
+
declare const localTools: (options: LocalMcpServerOptions, clientFor?: (deployment: LocalDeployment) => LunoraClient) => ReadonlyArray<McpTool>;
|
|
67
|
+
/** Build the composed local server without connecting a transport. */
|
|
68
|
+
declare const createLocalMcpServer: (options?: LocalMcpServerOptions) => Server;
|
|
69
|
+
/**
|
|
70
|
+
* Build the composed local server and connect it over stdio — the transport an
|
|
71
|
+
* MCP client uses when it spawns `lunora mcp serve`. Resolves once connected;
|
|
72
|
+
* the process then stays alive serving requests.
|
|
73
|
+
*/
|
|
74
|
+
declare const connectLocalStdio: (options?: LocalMcpServerOptions) => Promise<Server>;
|
|
75
|
+
/**
|
|
76
|
+
* Build the server and connect it over stdio — the transport MCP clients use
|
|
77
|
+
* when they spawn the `lunora-mcp` binary. Resolves once the transport is
|
|
78
|
+
* connected; the process then stays alive serving requests.
|
|
79
|
+
*
|
|
80
|
+
* Lives apart from `server.ts` so the Worker entry's module graph never pulls
|
|
81
|
+
* in the stdio transport (and its `node:process` import).
|
|
82
|
+
*/
|
|
83
|
+
declare const connectStdio: (options: LunoraMcpServerOptions) => Promise<Server>;
|
|
84
|
+
export { LOCAL_SERVER_NAME,
|
|
85
|
+
/** Node-only entry: the stdio transport and the local/deployment servers. */
|
|
86
|
+
type LocalDeployment,
|
|
87
|
+
/** Node-only entry: the stdio transport and the local/deployment servers. */
|
|
88
|
+
type LocalDeploymentSource,
|
|
89
|
+
/** Node-only entry: the stdio transport and the local/deployment servers. */
|
|
90
|
+
type LocalMcpServerOptions, type LunoraMcpServerOptions, NO_DEPLOYMENT_MESSAGE, connectLocalStdio, connectStdio, createLocalMcpServer, localTools };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LOCAL_SERVER_NAME as r,NO_DEPLOYMENT_MESSAGE as c,connectLocalStdio as t,createLocalMcpServer as a,localTools as E}from"../packem_shared/LOCAL_SERVER_NAME-DfC1rbyh.mjs";import{createLunoraMcpServer as l}from"../packem_shared/createLunoraMcpServer-iQFtbxDj.mjs";import{default as n}from"../packem_shared/connectStdio-Bhvmpb81.mjs";export{r as LOCAL_SERVER_NAME,c as NO_DEPLOYMENT_MESSAGE,t as connectLocalStdio,n as connectStdio,a as createLocalMcpServer,l as createLunoraMcpServer,E as localTools};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as u,a as O}from"./tool-result-D3oW8Fxx.mjs";const b="agents:agentRun",A="agents:agentThread",R="agents:agentMessages",p="lunora_agent_status",_=new Set(["awaiting_input","cancelled","error","idle"]),U=6e4,H=600,P={properties:{prompt:{description:"The task or message for the agent.",type:"string"},threadKey:{description:"Reuse to continue a conversation; omit to start a new thread.",type:"string"},title:{description:"Optional thread title (first run only).",type:"string"}},required:["prompt"],type:"object"},x={properties:{threadKey:{description:"The thread key returned by an agent tool call.",type:"string"}},required:["threadKey"],type:"object"},g=t=>t.toolName??`agent_${t.name}`,K=t=>{if(t===void 0)return[];const n=[];for(const e of t.split(";")){const r=e.trim();if(r.length===0)continue;const o=r.indexOf(":");if(o<=0)continue;const a=r.slice(0,o).trim(),s=r.slice(o+1).trim();a.length===0||s.length===0||n.push({description:s,name:a})}return n},D={destructiveHint:!1,idempotentHint:!0,openWorldHint:!0,readOnlyHint:!0},G=(t,n)=>n!==!0||t.length===0?[]:[...t.map(r=>({annotations:{destructiveHint:!0,idempotentHint:!1,openWorldHint:!0,readOnlyHint:!1,title:`Run the ${r.name} agent (starts a durable run)`},description:`${r.description} Starts a durable agent run and returns its final answer.`,inputSchema:P,name:g(r)})),{annotations:{...D,title:"Check a durable agent run"},description:"Check the status of a durable agent run (and its answer if finished) by its threadKey.",inputSchema:x,name:p}],q=(t,n)=>t===p||n.some(e=>g(e)===t),I=()=>`mcp-${crypto.randomUUID()}`,d=t=>({__lunoraRef:t}),L=async t=>{await new Promise(n=>{setTimeout(n,t)})},i=t=>({content:[{text:JSON.stringify(t,void 0,2),type:"text"}]}),l=(t,n)=>{const e=t[n];return typeof e=="string"&&e.length>0?e:void 0},T=t=>{for(let n=t.length-1;n>=0;n-=1){const e=t[n],r=e?.toolCalls,o=Array.isArray(r)&&r.length>0;if(e?.role==="assistant"&&!o)return typeof e.content=="string"?e.content:""}return""},w=t=>t!==null&&typeof t=="object"&&typeof t.status=="string"?t.status:"unknown",E=async(t,n,e,r)=>{const o=await t.query(d(R),{key:n});if(e==="error"){const a=r!==null&&typeof r=="object"?r.error:void 0;return i({error:typeof a=="string"?a:"the agent run failed",status:e,threadKey:n})}return i(e==="awaiting_input"?{hint:"This run is paused on a human-in-the-loop decision: a tool approval, or a secret the owner has to supply. Answer it in the app that owns the agent; MCP cannot answer it. Poll lunora_agent_status with this threadKey afterwards.",status:e,text:T(o),threadKey:n}:{status:e,text:T(o),threadKey:n})},k=async(t,n)=>{const e=l(n,"threadKey");if(e===void 0)return u("BAD_REQUEST",'"threadKey" is required and must be a non-empty string');const r=await t.query(d(A),{key:e}),o=w(r);return _.has(o)?E(t,e,o,r):i({status:o==="unknown"?"running":o,threadKey:e})},W=async(t,n,e,r)=>{try{if(r.allowAgents!==!0)return u("FORBIDDEN",`tool "${n}" is disabled: agent tools are off. Enable them with the LUNORA_MCP_ALLOW_AGENTS env var.`);if(n===p)return await k(t,e);const o=r.exposures.find(c=>g(c)===n);if(o===void 0)return u("NOT_FOUND",`agent tool "${n}" is not exposed by this MCP server`);const a=l(e,"prompt");if(a===void 0)return u("BAD_REQUEST",'"prompt" is required and must be a non-empty string');const s=l(e,"threadKey")??I(),h=l(e,"title"),{id:N}=await t.mutation(d(b),{agent:o.name,input:a,threadKey:s,...h===void 0?{}:{title:h}}),f=r.pollIntervalMs??H,S=r.maxWaitMs??U,v=r.wait??L,M=Math.max(1,Math.ceil(S/f));for(let c=0;c<M;c+=1){const y=await t.query(d(A),{key:s}),m=w(y);if(_.has(m))return await E(t,s,m,y);await v(f)}return i({hint:"call lunora_agent_status with this threadKey to poll for the answer",runId:N,status:"running",threadKey:s})}catch(o){return O(o)}};export{P as AGENT_RUN_INPUT_SCHEMA,p as AGENT_STATUS_TOOL_NAME,G as agentToolDefinitions,W as callAgentTool,T as finalAnswer,q as isAgentToolName,K as parseAgentsEnv};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{toDocsSearchHits as h}from"./toDocsSearchHits-CBLmtWXt.mjs";const f="https://lunora.sh",u=1e4,m=t=>t.endsWith("/")?t.slice(0,-1):t,p="\\",g=(t,n,i)=>{for(let s=i;s<t.length;s+=1)if(t[s]===n&&t[s-1]!==p)return s;return-1},d=t=>t.replaceAll(String.raw`\[`,"[").replaceAll(String.raw`\]`,"]").replaceAll(String.raw`\(`,"(").replaceAll(String.raw`\)`,")"),S=t=>{const n=t.trim();if(!n.startsWith("- ["))return;const i=n.lastIndexOf("](");if(i===-1)return;const s=g(n,")",i+2);if(s===-1)return;const o=d(n.slice(3,i).trim()),c=d(n.slice(i+2,s).trim());if(o.length===0||c.length===0)return;const e=n.slice(s+1).trim(),r=e.startsWith(":")?e.slice(1).trim():"";return r.length>0?{description:r,title:o,url:c}:{title:o,url:c}},x=t=>{if(!t.endsWith(")"))return t;const n=t.lastIndexOf(" (");if(n===-1)return t;const i=t.slice(n+2,-1);return i.startsWith("/")||i.startsWith("http")?t.slice(0,n).trim():t},y=(t,n)=>{for(const i of t.split(`
|
|
2
|
+
`)){if(i.startsWith("# "))return x(i.slice(2).trim());if(i.trim().length>0)break}return n},b=t=>{if(!t.startsWith("# "))return t;const n=t.indexOf(`
|
|
3
|
+
`);return n===-1?"":t.slice(n+1).trimStart()},A=(t={})=>{const n=m(t.baseUrl??f),i=t.fetch??globalThis.fetch,s=t.timeoutMs??u,o=async e=>{try{const r=await i(`${n}${e}`,{headers:{accept:"text/plain, application/json"},signal:AbortSignal.timeout(s)});return r.ok?{body:await r.text()}:{missing:!0}}catch(r){return{unreachable:r instanceof Error?r.message:String(r)}}},c=(e,r)=>{if("unreachable"in e)throw new Error(`could not reach the documentation site at ${n}${r}: ${e.unreachable}`);return"missing"in e?void 0:e.body};return{getPage:async e=>{const r=c(await o(`/llms.mdx${e}`),`/llms.mdx${e}`);if(!(r===void 0||r.trim().length===0))return{content:b(r),title:y(r,e),url:e}},listPages:async()=>{const e=c(await o("/llms.txt"),"/llms.txt");if(e===void 0)return[];const r=[];for(const l of e.split(`
|
|
4
|
+
`)){const a=S(l);a!==void 0&&r.push(a)}return r},search:async e=>{const r=`/api/search?query=${encodeURIComponent(e)}`,l=c(await o(r),r);if(l===void 0)return[];let a;try{a=JSON.parse(l)}catch{return[]}return Array.isArray(a)?h(a):[]}}};export{f as DEFAULT_DOCS_BASE_URL,A as createRemoteDocsIndex,S as parseIndexLine};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{WebStandardStreamableHTTPServerTransport as y}from"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";const u=128*1024,p=e=>e!==void 0&&Number.isSafeInteger(e)&&e>=0?e:u,l=async(e,t)=>{if(!e.body)return"";const r=e.body.getReader(),s=new TextDecoder;let n=0,o="";for(;;){const{done:i,value:a}=await r.read();if(i)break;if(a){if(n+=a.byteLength,n>t){r.cancel().catch(()=>{});return}o+=s.decode(a,{stream:!0})}}return o+s.decode()},d=(e,t,r)=>Response.json({error:{code:t,message:r},id:null,jsonrpc:"2.0"},{status:e}),c=()=>d(400,-32600,"batched requests are not supported: send one JSON-RPC message per request"),f=async(e,t)=>{if(e.method!=="POST")return{parsedBody:void 0};const r=p(t),s={response:d(413,-32600,`request body exceeds ${String(r)} bytes`)},n=Number(e.headers.get("content-length"));if(Number.isFinite(n)&&n>r)return s;const o=await l(e,r);if(o===void 0)return s;try{return{parsedBody:JSON.parse(o)}}catch{return{response:d(400,-32700,"parse error: body is not valid JSON")}}},b=async(e,t)=>{if(e.method!=="POST")return{parsedBody:t?.parsedBody};if(t?.parsedBody!==void 0)return Array.isArray(t.parsedBody)?{response:c()}:{parsedBody:t.parsedBody};const r=await f(e,t?.maxRequestBytes);return"response"in r?r:Array.isArray(r.parsedBody)?{response:c()}:r},B=async(e,t,r)=>{const s=await b(t,r);if("response"in s)return s.response;const n=new y({enableJsonResponse:!0,sessionIdGenerator:void 0});try{return await e.connect(n),await n.handleRequest(t,{authInfo:r?.authInfo,parsedBody:s.parsedBody})}finally{n.close().catch(()=>{}),e.close().catch(()=>{})}};export{u as DEFAULT_MAX_REQUEST_BYTES,f as readScreenedBody,B as serveStateless};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{LunoraError as u}from"@lunora/errors";import{e as l}from"./tool-result-D3oW8Fxx.mjs";const m=10,g=50,S="docs",i=500,E={properties:{limit:{description:`Maximum hits to return (default ${String(m)}, max ${String(g)})`,type:"number"},query:{description:'Search terms, e.g. "shardBy" or "optimistic updates"',type:"string"}},required:["query"],type:"object"},O={properties:{url:{description:'Site-relative page URL from a search hit, e.g. "/docs/sharding"',type:"string"}},required:["url"],type:"object"},T={properties:{},type:"object"},a={destructiveHint:!1,idempotentHint:!0,openWorldHint:!0,readOnlyHint:!0},_={annotations:{...a,title:"Search the Lunora documentation"},description:"Search the Lunora documentation and return matching pages and sections. Use this before writing Lunora code (schema, queries, mutations, actions, sharding, .global(), client hooks) so the answer reflects the framework's current API rather than a guess. Follow a hit with lunora_get_doc to read the full page.",inputSchema:E,name:"lunora_search_docs"},p={annotations:{...a,title:"Read a Lunora documentation page"},description:"Return one Lunora documentation page in full, as Markdown. Takes the `url` of a lunora_search_docs hit or a lunora_list_docs entry.",inputSchema:O,name:"lunora_get_doc"},f={annotations:{...a,title:"List the Lunora documentation pages"},description:"List every Lunora documentation page with its title and description. Prefer lunora_search_docs when you know what you're looking for.",inputSchema:T,name:"lunora_list_docs"},L=[_,p,f],s=n=>({content:[{text:JSON.stringify(n,void 0,2),type:"text"}]}),d=512,h=(n,t)=>{const e=n[t];if(typeof e!="string"||e.trim().length===0)throw new u("BAD_REQUEST",`"${t}" is required and must be a non-empty string`);if(e.length>d)throw new u("BAD_REQUEST",`"${t}" must be at most ${String(d)} characters`);return e.trim()},y=n=>{const t=typeof n=="string"?Number(n):n;return typeof t!="number"||!Number.isFinite(t)?m:Math.min(g,Math.max(1,Math.floor(t)))},N=(n,t)=>{let e;try{e=decodeURIComponent(n)}catch{throw new RangeError(`"url" contains a malformed percent-escape: ${t}`)}if(e.includes("%")||e.includes("\\"))throw new RangeError(`"url" must not contain ".." or encoded segments: ${t}`);for(const o of e.split("/"))if(o===".."||o===".")throw new RangeError(`"url" must not contain ".." or encoded segments: ${t}`)},I=n=>{let t=n.trim().replaceAll("\\","/");if(t.startsWith("http://")||t.startsWith("https://")){const e=t.slice(t.indexOf("//")+2),o=e.indexOf("/");t=o===-1?"/":e.slice(o)}for(const e of["?","#"]){const o=t.indexOf(e);o!==-1&&(t=t.slice(0,o))}for(;t.endsWith("/")&&t.length>1;)t=t.slice(0,-1);return t.startsWith("/")||(t=t.startsWith("docs/")?`/${t}`:`/${S}/${t}`),N(t,n),t},D=n=>[{definition:_,handle:async t=>{const e=h(t,"query"),o=y(t.limit),c=(await n.search(e)).slice(0,o);return c.length===0?s({hits:[],note:`no documentation matched "${e}" — try fewer or more general terms, or lunora_list_docs to browse`}):s({hits:c})}},{definition:p,handle:async t=>{let e;try{e=I(h(t,"url"))}catch(r){if(r instanceof RangeError)return l("BAD_REQUEST",r.message);throw r}const o=await n.getPage(e);return o===void 0?l("NOT_FOUND",`documentation page not found: ${e}. Use lunora_search_docs or lunora_list_docs to find a valid url.`):{content:[{text:`# ${o.title} (${o.url})
|
|
2
|
+
|
|
3
|
+
${o.content}`,type:"text"}]}}},{definition:f,handle:async()=>{const t=await n.listPages();return t.length>i?s({note:`showing the first ${String(i)} of ${String(t.length)} pages — use lunora_search_docs to find the rest`,pages:t.slice(0,i)}):s(t)}}];export{m as DEFAULT_SEARCH_LIMIT,L as DOCS_TOOL_DEFINITIONS,g as MAX_SEARCH_LIMIT,D as docsTools,I as normalizeDocUrl};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createToolServer as o}from"./createToolServer-DV1g-DGe.mjs";import{serveStateless as s}from"./DEFAULT_MAX_REQUEST_BYTES-CbbpkHRK.mjs";import{DEFAULT_MAX_REQUEST_BYTES as i}from"./DEFAULT_MAX_REQUEST_BYTES-CbbpkHRK.mjs";import{docsResources as t}from"./DOCS_URI_SCHEME-Dd_rZo2y.mjs";import{docsTools as c}from"./DEFAULT_SEARCH_LIMIT-CPjNPMx3.mjs";const m="lunora-docs",n=e=>({name:m,version:e??"0.0.0"}),a=e=>o(n(e.version),c(e.index),t(e.index)),v=e=>r=>s(a(e),r,{maxRequestBytes:e.maxRequestBytes});export{i as DEFAULT_MAX_REQUEST_BYTES,m as DOCS_SERVER_NAME,v as createDocsMcpFetchHandler,a as createDocsMcpServer};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{normalizeDocUrl as s}from"./DEFAULT_SEARCH_LIMIT-CPjNPMx3.mjs";const e="lunora-docs:",n=t=>`${e}${t}`,c=t=>t.startsWith(e)?t.slice(e.length):void 0,d=t=>({list:async()=>(await t.listPages()).map(o=>({...o.description===void 0?{}:{description:o.description},mimeType:"text/markdown",name:o.title,uri:n(o.url)})),read:async i=>{const o=c(i);if(o===void 0)return;const r=await t.getPage(s(o));return r===void 0?void 0:{mimeType:"text/markdown",text:`# ${r.title} (${r.url})
|
|
2
|
+
|
|
3
|
+
${r.content}`}}});export{e as DOCS_URI_SCHEME,d as docsResources,c as fromDocsUri,n as toDocsUri};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraClient as f}from"@lunora/client";import{StdioServerTransport as m}from"@modelcontextprotocol/sdk/server/stdio.js";import{e as p}from"./promise-memo-OqVPWoUX.mjs";import{createToolServer as v}from"./createToolServer-DV1g-DGe.mjs";import{createRemoteDocsIndex as h}from"./DEFAULT_DOCS_BASE_URL-CiHy_Dbz.mjs";import{docsResources as E}from"./DOCS_URI_SCHEME-Dd_rZo2y.mjs";import{docsTools as R}from"./DEFAULT_SEARCH_LIMIT-CPjNPMx3.mjs";import{E as O,a as y,t as T,b as _,c as S}from"./tools-DiCVoZgA.mjs";import{e as P}from"./tool-result-D3oW8Fxx.mjs";const l=e=>e.docs===!1?void 0:h({...e.docs?.baseUrl===void 0?{}:{baseUrl:e.docs.baseUrl},...e.fetch===void 0?{}:{fetch:e.fetch}}),C="lunora",N="no Lunora dev server is running for this project — start one with `lunora dev`, then call this tool again (call lunora_dev_status to check).",g=8,d=e=>{const n=new Map;return t=>{const r=JSON.stringify([t.url,t.token??""]),c=n.get(r);if(c!==void 0)return c;const o=new f({fetch:e,url:t.url});return t.token!==void 0&&t.token.length>0&&o.setAuthToken(t.token),p(n,g),n.set(r,o),o}},i=e=>e?.token!==void 0&&e.token.length>0,A=(e,n,t)=>{const r=typeof e=="function"?e:()=>e;return T(n,i(r())).filter(c=>!_.has(c.name)).map(c=>({definition:c,handle:async o=>{const s=r();return s===void 0?P("NO_DEPLOYMENT",N):S(t(s),c.name,o,n,i(s))}}))},I=()=>O.map(e=>({definition:e,handle:n=>Promise.resolve(y(e.name,n))})),k="lunora-spec:openrpc",w="lunora-spec:openapi",a=[{description:"The deployment's generated OpenRPC 1.x document — every RPC function's path, kind, and argument schema in one read, instead of list_functions plus one get_function_schema call per function.",fetch:async e=>e.fetchOpenRpc(),name:"OpenRPC specification",uri:k},{description:"The deployment's generated OpenAPI 3.1 document.",fetch:async e=>e.fetchOpenApi(),name:"OpenAPI specification",uri:w}],L=(e,n)=>{const t=typeof e=="function"?e:()=>e,r=async c=>{const o=t();if(o!==void 0)try{return await c.fetch(n(o))}catch{return}};return{list:async()=>(await Promise.all(a.map(async o=>await r(o)===void 0?void 0:{description:o.description,mimeType:"application/json",name:o.name,uri:o.uri}))).filter(o=>o!==void 0),read:async c=>{const o=a.find(u=>u.uri===c);if(o===void 0)return;const s=await r(o);return s===void 0?void 0:{mimeType:"application/json",text:JSON.stringify(s,void 0,2)}}}},x=e=>({list:async()=>(await Promise.all(e.map(async t=>t.list()))).flat(),read:async n=>{for(const t of e){const r=await t.read(n);if(r!==void 0)return r}}}),M=(e,n)=>{const t=[],r=l(e);return r!==void 0&&t.push(...R(r)),t.push(...e.extraTools??[],...I()),e.deployment!==void 0&&t.push(...A(e.deployment,e.allowWrites??!1,n??d(e.fetch))),t},U=(e={})=>{const n=l(e),t=[];n!==void 0&&t.push(E(n));const r=d(e.fetch);return e.deployment!==void 0&&t.push(L(e.deployment,r)),v({name:C,version:e.version??"0.0.0"},M(e,r),t.length===0?void 0:x(t))},V=async(e={})=>{const n=U(e);return await n.connect(new m),n};export{C as LOCAL_SERVER_NAME,N as NO_DEPLOYMENT_MESSAGE,w as OPENAPI_RESOURCE_URI,k as OPENRPC_RESOURCE_URI,V as connectLocalStdio,U as createLocalMcpServer,M as localTools};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as A}from"@lunora/errors";import{ADMIN_FUNCTIONS as d}from"@lunora/shard-engine";import{w as p,o as l}from"./tool-result-D3oW8Fxx.mjs";const u={destructiveHint:!1,idempotentHint:!0,openWorldHint:!0,readOnlyHint:!0},I=50,b=500,v=["1m","5m","15m","1h"],w=["open","resolved","ignored"],E=["trace","debug","log","info","warn","error","fatal"],g={description:"Shard to read from on a .shardBy()-partitioned deployment. Omit for the default (unsharded) shard — these reads are PER-SHARD, not deployment-wide.",type:"string"},y={description:`Maximum rows to return (default ${I.toString()}, clamped to ${b.toString()}).`,type:"number"},O=e=>{const r=typeof e=="number"?e:Number.NaN;return Number.isFinite(r)?Math.max(1,Math.min(Math.floor(r),b)):I},_=(e,r)=>r.includes(e)?e:void 0,T=e=>typeof e=="string"&&e.length>0?e:void 0,N={properties:{level:{description:`Keep only entries at this severity. One of: ${E.join(", ")}.`,type:"string"},limit:y,shardKey:g},type:"object"},R={properties:{functionPathPrefix:{description:'Keep only Issues whose function path starts with this, e.g. "messages:".',type:"string"},limit:y,shardKey:g,status:{description:`Triage status to keep. One of: ${w.join(", ")}. Default: all.`,type:"string"}},type:"object"},P={properties:{limit:y,shardKey:g},type:"object"},U={properties:{limit:y,range:{description:`Time window to report over. One of: ${v.join(", ")}. Default: 15m.`,type:"string"},shardKey:g},type:"object"},L={properties:{shardKey:g},type:"object"},M={properties:{dropped:{description:"Entries the shard's in-memory ring EVICTED before this read — they are gone and cannot be fetched. Non-zero means `entries` + `total` describe only the newest slice of what the deployment logged.",type:"number"},entries:{description:"Recent log entries, NEWEST FIRST: { level, message, timestamp, functionPath?, fields? }.",type:"array"},total:{description:"Entries still in the ring matching `level`, before `limit` narrowed them. NOT the number of lines logged — see `dropped`.",type:"number"}},required:["dropped","entries","total"],type:"object"},H={properties:{issues:{description:"Grouped error Issues, newest first: { hash, title, count, status, functionPath, lastSeen, … }.",type:"array"}},required:["issues"],type:"object"},k={properties:{advisories:{description:"Schema/query advisories: { id, level, title, detail, … }.",type:"array"},total:{description:"Advisories available before `limit` narrowed them.",type:"number"}},required:["advisories","total"],type:"object"},j={properties:{buckets:{description:"Combined throughput/latency series across the range.",type:"array"},capped:{description:"True when the deployment's tracked-statement cap was reached, so coverage is partial.",type:"boolean"},entries:{description:"Per-statement activity in the range, hottest first.",type:"array"},total:{description:"Statements available before `limit` narrowed them.",type:"number"},trackedStatements:{description:"Distinct statements the deployment is tracking.",type:"number"}},required:["entries","buckets"],type:"object"},q={properties:{migrations:{description:"Every declared migration with its applied/pending state.",type:"array"}},required:["migrations"],type:"object"},C=[{annotations:{...u,title:"Read recent logs"},description:"Read the deployment's recent log entries (newest first) after running a function, to see what it printed and where it failed. In-memory and per-shard: resets when the shard hibernates.",inputSchema:N,name:"lunora_get_logs",outputSchema:p(M)},{annotations:{...u,title:"List grouped error Issues"},description:"List errors grouped into Issues by fingerprint, with occurrence counts and triage status — the first call when asking what is currently broken, rather than reading raw logs.",inputSchema:R,name:"lunora_get_issues",outputSchema:p(H)},{annotations:{...u,title:"List schema and query advisories"},description:"List the deployment's schema/query advisories (missing indexes, unsafe policies, and similar lints) before or after changing the schema.",inputSchema:P,name:"lunora_get_advisories",outputSchema:p(k)},{annotations:{...u,title:"Read query insights"},description:"Read per-statement execution counts and latency over a recent time window, to find which query is slow or hot before optimizing one.",inputSchema:U,name:"lunora_get_query_insights",outputSchema:p(j)},{annotations:{...u,title:"Read migration status"},description:"Read which migrations have been applied and which are pending, to check whether a schema change has actually landed on the deployment.",inputSchema:L,name:"lunora_get_migration_status",outputSchema:p(q)}],K=new Set(C.map(e=>e.name)),h=async(e,r,s,n)=>{const a={__lunoraRef:r};return e.query(a,s,{...n===void 0?{}:{shardKey:n}})},m=(e,r)=>{const s=e?.[r];return Array.isArray(s)?s:[]},V=async(e,r,s)=>{const n=T(s.shardKey),a=O(s.limit);switch(r){case"lunora_get_advisories":{const t=await h(e,d.getAdvisories,{},n),i=m(t,"advisories");return l({advisories:i.slice(0,a),total:i.length})}case"lunora_get_issues":{const t=_(s.status,w),i=T(s.functionPathPrefix),o=await h(e,d.getIssues,{limit:a,...t===void 0?{}:{status:t},...i===void 0?{}:{functionPathPrefix:i}},n);return l({issues:m(o,"issues")})}case"lunora_get_logs":{const t=_(s.level,E),i=await h(e,d.getLogs,{},n),o=m(i,"entries").filter(S=>t===void 0||S.level===t),{dropped:c}=i??{};return l({dropped:typeof c=="number"?c:0,entries:o.slice(0,a),total:o.length})}case"lunora_get_migration_status":{const t=await h(e,d.migrationStatus,{},n);return l({migrations:m(t,"migrations")})}case"lunora_get_query_insights":{const t=_(s.range,v),i=await h(e,d.getQueryInsights,{...t===void 0?{}:{range:t}},n),o=m(i,"entries"),{buckets:c,capped:S,trackedStatements:f}=i??{};return l({buckets:Array.isArray(c)?c:[],capped:S===!0,entries:o.slice(0,a),total:o.length,trackedStatements:typeof f=="number"?f:o.length})}default:throw new A("INTERNAL",`unknown observability tool: ${r}`)}};export{I as DEFAULT_LIMIT,b as MAX_LIMIT,C as OBSERVABILITY_TOOL_DEFINITIONS,K as OBSERVABILITY_TOOL_NAMES,V as callObservabilityTool};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{D as E,O as _,R as o,e as s,S,W as a,d as D,c as N,s as A,t as R}from"./tools-DiCVoZgA.mjs";import{OBSERVABILITY_TOOL_DEFINITIONS as r}from"./OBSERVABILITY_TOOL_DEFINITIONS-Dz7pHc8X.mjs";import"./tool-result-D3oW8Fxx.mjs";export{E as DATA_READ_SCOPE,_ as OBSERVABILITY_SCOPE,r as OBSERVABILITY_TOOL_DEFINITIONS,o as READ_ONLY_TOOL_DEFINITIONS,s as ROW_READ_TOOL_DEFINITIONS,S as SCOPED_GATES,a as WRITE_TOOL_DEFINITIONS,D as WRITE_TOOL_NAMES,N as callTool,A as scopeForTool,R as toolDefinitions};
|