@contractspec/module.alpic 1.57.0 → 1.59.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.
@@ -1,6 +1,3 @@
1
- //#region src/assets/paths.d.ts
2
- declare function alpicAssetPath(assetPath: string): string;
3
- declare function alpicAssetUrl(assetPath: string): string;
4
- //#endregion
5
- export { alpicAssetPath, alpicAssetUrl };
1
+ export declare function alpicAssetPath(assetPath: string): string;
2
+ export declare function alpicAssetUrl(assetPath: string): string;
6
3
  //# sourceMappingURL=paths.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"paths.d.ts","names":[],"sources":["../../src/assets/paths.ts"],"mappings":";iBAUgB,cAAA,CAAe,SAAA;AAAA,iBAIf,aAAA,CAAc,SAAA"}
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/assets/paths.ts"],"names":[],"mappings":"AAUA,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAKvD"}
@@ -0,0 +1,174 @@
1
+ // src/assets/paths.ts
2
+ var ASSETS_BASE = "/assets";
3
+ function normalizeAssetPath(assetPath) {
4
+ const trimmed = assetPath.trim();
5
+ if (!trimmed)
6
+ return ASSETS_BASE;
7
+ if (trimmed.startsWith(ASSETS_BASE))
8
+ return trimmed;
9
+ if (trimmed.startsWith("/"))
10
+ return `${ASSETS_BASE}${trimmed}`;
11
+ return `${ASSETS_BASE}/${trimmed}`;
12
+ }
13
+ function alpicAssetPath(assetPath) {
14
+ return normalizeAssetPath(assetPath);
15
+ }
16
+ function alpicAssetUrl(assetPath) {
17
+ const path = normalizeAssetPath(assetPath);
18
+ const host = process.env.ALPIC_HOST?.trim();
19
+ if (!host)
20
+ return path;
21
+ return `https://${host}${path}`;
22
+ }
23
+ // src/mcp/create-alpic-mcp-app.ts
24
+ import { Elysia } from "elysia";
25
+ import { mcp } from "elysia-mcp";
26
+ import { Logger, LogLevel } from "@contractspec/lib.logger";
27
+
28
+ // src/mcp/resources.ts
29
+ var defaultResourceKey = "alpic_ui";
30
+ var defaultResourceUri = "app://ui";
31
+ function registerAlpicResources(server, config = {}) {
32
+ const assetPath = config.assetPath ?? "index.html";
33
+ const path = alpicAssetPath(assetPath);
34
+ const url = alpicAssetUrl(assetPath);
35
+ const resourceKey = config.resourceKey ?? defaultResourceKey;
36
+ const resourceUri = config.resourceUri ?? defaultResourceUri;
37
+ const title = config.title ?? "ChatGPT App UI";
38
+ const description = config.description ?? "Entry point for the ChatGPT App UI hosted on Alpic.";
39
+ server.registerResource(resourceKey, resourceUri, {
40
+ title,
41
+ description,
42
+ mimeType: "application/json"
43
+ }, async () => {
44
+ const payload = {
45
+ title,
46
+ description,
47
+ path,
48
+ url
49
+ };
50
+ return {
51
+ contents: [
52
+ {
53
+ uri: resourceUri,
54
+ mimeType: "application/json",
55
+ text: JSON.stringify(payload, null, 2)
56
+ }
57
+ ]
58
+ };
59
+ });
60
+ }
61
+
62
+ // src/mcp/tools.ts
63
+ import * as z from "zod";
64
+ var defaultToolName = "alpic.ping";
65
+ function registerAlpicTools(server, config = {}) {
66
+ const toolName = config.name ?? defaultToolName;
67
+ const description = config.description ?? "Ping the MCP server and return basic Alpic info.";
68
+ const inputSchema = z.object({
69
+ message: z.string().optional()
70
+ });
71
+ server.registerTool(toolName, { description, inputSchema }, async (args) => {
72
+ const payload = {
73
+ ok: true,
74
+ message: args.message ?? "pong",
75
+ assetsBase: alpicAssetPath(""),
76
+ timestamp: new Date().toISOString()
77
+ };
78
+ return {
79
+ content: [
80
+ {
81
+ type: "text",
82
+ text: JSON.stringify(payload, null, 2)
83
+ }
84
+ ]
85
+ };
86
+ });
87
+ }
88
+
89
+ // src/mcp/create-alpic-mcp-app.ts
90
+ var defaultServerName = "contractspec-alpic-mcp";
91
+ var defaultServerVersion = "1.0.0";
92
+ function resolveDebugFlag(explicit) {
93
+ if (typeof explicit === "boolean")
94
+ return explicit;
95
+ return process.env.ALPIC_MCP_DEBUG === "1" || process.env.CONTRACTSPEC_MCP_DEBUG === "1";
96
+ }
97
+ function createDefaultLogger(debug) {
98
+ return new Logger({
99
+ level: debug ? LogLevel.DEBUG : LogLevel.INFO,
100
+ environment: "development",
101
+ enableTracing: false,
102
+ enableTiming: false,
103
+ enableContext: false,
104
+ enableColors: true
105
+ });
106
+ }
107
+ function createConsoleLikeLogger(logger, debug) {
108
+ const toMessage = (args) => args.map((item) => typeof item === "string" ? item : JSON.stringify(item)).join(" ");
109
+ return {
110
+ log: (...args) => {
111
+ if (!debug)
112
+ return;
113
+ logger.info(toMessage(args));
114
+ },
115
+ info: (...args) => {
116
+ if (!debug)
117
+ return;
118
+ logger.info(toMessage(args));
119
+ },
120
+ warn: (...args) => {
121
+ logger.warn(toMessage(args));
122
+ },
123
+ error: (...args) => {
124
+ logger.error(toMessage(args));
125
+ },
126
+ debug: (...args) => {
127
+ if (!debug)
128
+ return;
129
+ logger.debug(toMessage(args));
130
+ }
131
+ };
132
+ }
133
+ function setupMcpServer(server, options) {
134
+ registerAlpicTools(server, options.tool);
135
+ registerAlpicResources(server, options.ui);
136
+ }
137
+ function createAlpicMcpHandler(options) {
138
+ const debug = resolveDebugFlag(options.enableDebugLogs);
139
+ const logger = options.logger ?? createDefaultLogger(debug);
140
+ return mcp({
141
+ basePath: options.path,
142
+ logger: createConsoleLikeLogger(logger, debug),
143
+ serverInfo: {
144
+ name: options.serverName ?? defaultServerName,
145
+ version: options.serverVersion ?? defaultServerVersion
146
+ },
147
+ stateless: options.stateless ?? true,
148
+ enableJsonResponse: options.enableJsonResponse ?? true,
149
+ capabilities: {
150
+ tools: {},
151
+ resources: {},
152
+ prompts: {},
153
+ logging: {}
154
+ },
155
+ setupServer: (server) => setupMcpServer(server, options)
156
+ });
157
+ }
158
+ function createAlpicMcpApp(options = {}) {
159
+ const app = new Elysia;
160
+ const basePaths = options.basePaths ?? ["/", "/mcp"];
161
+ basePaths.forEach((path) => {
162
+ app.use(createAlpicMcpHandler({
163
+ ...options,
164
+ path
165
+ }));
166
+ });
167
+ return app;
168
+ }
169
+ export {
170
+ createAlpicMcpHandler,
171
+ createAlpicMcpApp,
172
+ alpicAssetUrl,
173
+ alpicAssetPath
174
+ };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { alpicAssetPath, alpicAssetUrl } from "./assets/paths.js";
2
- import { AlpicMcpAppOptions, AlpicMcpHandlerOptions, createAlpicMcpApp, createAlpicMcpHandler } from "./mcp/create-alpic-mcp-app.js";
3
- export { AlpicMcpAppOptions, AlpicMcpHandlerOptions, alpicAssetPath, alpicAssetUrl, createAlpicMcpApp, createAlpicMcpHandler };
1
+ export * from './assets/paths';
2
+ export * from './mcp/create-alpic-mcp-app';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,175 @@
1
- import { alpicAssetPath, alpicAssetUrl } from "./assets/paths.js";
2
- import { createAlpicMcpApp, createAlpicMcpHandler } from "./mcp/create-alpic-mcp-app.js";
1
+ // @bun
2
+ // src/assets/paths.ts
3
+ var ASSETS_BASE = "/assets";
4
+ function normalizeAssetPath(assetPath) {
5
+ const trimmed = assetPath.trim();
6
+ if (!trimmed)
7
+ return ASSETS_BASE;
8
+ if (trimmed.startsWith(ASSETS_BASE))
9
+ return trimmed;
10
+ if (trimmed.startsWith("/"))
11
+ return `${ASSETS_BASE}${trimmed}`;
12
+ return `${ASSETS_BASE}/${trimmed}`;
13
+ }
14
+ function alpicAssetPath(assetPath) {
15
+ return normalizeAssetPath(assetPath);
16
+ }
17
+ function alpicAssetUrl(assetPath) {
18
+ const path = normalizeAssetPath(assetPath);
19
+ const host = process.env.ALPIC_HOST?.trim();
20
+ if (!host)
21
+ return path;
22
+ return `https://${host}${path}`;
23
+ }
24
+ // src/mcp/create-alpic-mcp-app.ts
25
+ import { Elysia } from "elysia";
26
+ import { mcp } from "elysia-mcp";
27
+ import { Logger, LogLevel } from "@contractspec/lib.logger";
3
28
 
4
- export { alpicAssetPath, alpicAssetUrl, createAlpicMcpApp, createAlpicMcpHandler };
29
+ // src/mcp/resources.ts
30
+ var defaultResourceKey = "alpic_ui";
31
+ var defaultResourceUri = "app://ui";
32
+ function registerAlpicResources(server, config = {}) {
33
+ const assetPath = config.assetPath ?? "index.html";
34
+ const path = alpicAssetPath(assetPath);
35
+ const url = alpicAssetUrl(assetPath);
36
+ const resourceKey = config.resourceKey ?? defaultResourceKey;
37
+ const resourceUri = config.resourceUri ?? defaultResourceUri;
38
+ const title = config.title ?? "ChatGPT App UI";
39
+ const description = config.description ?? "Entry point for the ChatGPT App UI hosted on Alpic.";
40
+ server.registerResource(resourceKey, resourceUri, {
41
+ title,
42
+ description,
43
+ mimeType: "application/json"
44
+ }, async () => {
45
+ const payload = {
46
+ title,
47
+ description,
48
+ path,
49
+ url
50
+ };
51
+ return {
52
+ contents: [
53
+ {
54
+ uri: resourceUri,
55
+ mimeType: "application/json",
56
+ text: JSON.stringify(payload, null, 2)
57
+ }
58
+ ]
59
+ };
60
+ });
61
+ }
62
+
63
+ // src/mcp/tools.ts
64
+ import * as z from "zod";
65
+ var defaultToolName = "alpic.ping";
66
+ function registerAlpicTools(server, config = {}) {
67
+ const toolName = config.name ?? defaultToolName;
68
+ const description = config.description ?? "Ping the MCP server and return basic Alpic info.";
69
+ const inputSchema = z.object({
70
+ message: z.string().optional()
71
+ });
72
+ server.registerTool(toolName, { description, inputSchema }, async (args) => {
73
+ const payload = {
74
+ ok: true,
75
+ message: args.message ?? "pong",
76
+ assetsBase: alpicAssetPath(""),
77
+ timestamp: new Date().toISOString()
78
+ };
79
+ return {
80
+ content: [
81
+ {
82
+ type: "text",
83
+ text: JSON.stringify(payload, null, 2)
84
+ }
85
+ ]
86
+ };
87
+ });
88
+ }
89
+
90
+ // src/mcp/create-alpic-mcp-app.ts
91
+ var defaultServerName = "contractspec-alpic-mcp";
92
+ var defaultServerVersion = "1.0.0";
93
+ function resolveDebugFlag(explicit) {
94
+ if (typeof explicit === "boolean")
95
+ return explicit;
96
+ return process.env.ALPIC_MCP_DEBUG === "1" || process.env.CONTRACTSPEC_MCP_DEBUG === "1";
97
+ }
98
+ function createDefaultLogger(debug) {
99
+ return new Logger({
100
+ level: debug ? LogLevel.DEBUG : LogLevel.INFO,
101
+ environment: "development",
102
+ enableTracing: false,
103
+ enableTiming: false,
104
+ enableContext: false,
105
+ enableColors: true
106
+ });
107
+ }
108
+ function createConsoleLikeLogger(logger, debug) {
109
+ const toMessage = (args) => args.map((item) => typeof item === "string" ? item : JSON.stringify(item)).join(" ");
110
+ return {
111
+ log: (...args) => {
112
+ if (!debug)
113
+ return;
114
+ logger.info(toMessage(args));
115
+ },
116
+ info: (...args) => {
117
+ if (!debug)
118
+ return;
119
+ logger.info(toMessage(args));
120
+ },
121
+ warn: (...args) => {
122
+ logger.warn(toMessage(args));
123
+ },
124
+ error: (...args) => {
125
+ logger.error(toMessage(args));
126
+ },
127
+ debug: (...args) => {
128
+ if (!debug)
129
+ return;
130
+ logger.debug(toMessage(args));
131
+ }
132
+ };
133
+ }
134
+ function setupMcpServer(server, options) {
135
+ registerAlpicTools(server, options.tool);
136
+ registerAlpicResources(server, options.ui);
137
+ }
138
+ function createAlpicMcpHandler(options) {
139
+ const debug = resolveDebugFlag(options.enableDebugLogs);
140
+ const logger = options.logger ?? createDefaultLogger(debug);
141
+ return mcp({
142
+ basePath: options.path,
143
+ logger: createConsoleLikeLogger(logger, debug),
144
+ serverInfo: {
145
+ name: options.serverName ?? defaultServerName,
146
+ version: options.serverVersion ?? defaultServerVersion
147
+ },
148
+ stateless: options.stateless ?? true,
149
+ enableJsonResponse: options.enableJsonResponse ?? true,
150
+ capabilities: {
151
+ tools: {},
152
+ resources: {},
153
+ prompts: {},
154
+ logging: {}
155
+ },
156
+ setupServer: (server) => setupMcpServer(server, options)
157
+ });
158
+ }
159
+ function createAlpicMcpApp(options = {}) {
160
+ const app = new Elysia;
161
+ const basePaths = options.basePaths ?? ["/", "/mcp"];
162
+ basePaths.forEach((path) => {
163
+ app.use(createAlpicMcpHandler({
164
+ ...options,
165
+ path
166
+ }));
167
+ });
168
+ return app;
169
+ }
170
+ export {
171
+ createAlpicMcpHandler,
172
+ createAlpicMcpApp,
173
+ alpicAssetUrl,
174
+ alpicAssetPath
175
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=alpic-mcp.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alpic-mcp.test.d.ts","sourceRoot":"","sources":["../../src/mcp/alpic-mcp.test.ts"],"names":[],"mappings":""}
@@ -1,118 +1,113 @@
1
- import { AlpicMcpUiConfig } from "./resources.js";
2
- import { AlpicMcpToolConfig } from "./tools.js";
3
- import { Elysia } from "elysia";
4
- import { Logger } from "@contractspec/lib.logger";
5
- import * as _modelcontextprotocol_sdk_types_js0 from "@modelcontextprotocol/sdk/types.js";
6
-
7
- //#region src/mcp/create-alpic-mcp-app.d.ts
8
- interface AlpicMcpAppOptions {
9
- serverName?: string;
10
- serverVersion?: string;
11
- basePaths?: string[];
12
- stateless?: boolean;
13
- enableJsonResponse?: boolean;
14
- enableDebugLogs?: boolean;
15
- ui?: AlpicMcpUiConfig;
16
- tool?: AlpicMcpToolConfig;
17
- logger?: Logger;
1
+ import { Elysia } from 'elysia';
2
+ import { Logger } from '@contractspec/lib.logger';
3
+ import { type AlpicMcpUiConfig } from './resources';
4
+ import { type AlpicMcpToolConfig } from './tools';
5
+ export interface AlpicMcpAppOptions {
6
+ serverName?: string;
7
+ serverVersion?: string;
8
+ basePaths?: string[];
9
+ stateless?: boolean;
10
+ enableJsonResponse?: boolean;
11
+ enableDebugLogs?: boolean;
12
+ ui?: AlpicMcpUiConfig;
13
+ tool?: AlpicMcpToolConfig;
14
+ logger?: Logger;
18
15
  }
19
- interface AlpicMcpHandlerOptions extends AlpicMcpAppOptions {
20
- path: string;
16
+ export interface AlpicMcpHandlerOptions extends AlpicMcpAppOptions {
17
+ path: string;
21
18
  }
22
- declare function createAlpicMcpHandler(options: AlpicMcpHandlerOptions): Elysia<"", {
23
- decorator: {};
24
- store: {
25
- authInfo: AuthInfo | undefined;
26
- };
27
- derive: {};
28
- resolve: {};
19
+ export declare function createAlpicMcpHandler(options: AlpicMcpHandlerOptions): Elysia<"", {
20
+ decorator: {};
21
+ store: {
22
+ authInfo: AuthInfo | undefined;
23
+ };
24
+ derive: {};
25
+ resolve: {};
29
26
  }, {
30
- typebox: {};
31
- error: {};
27
+ typebox: {};
28
+ error: {};
32
29
  }, {
33
- schema: {};
34
- standaloneSchema: {};
35
- macro: {};
36
- macroFn: {};
37
- parser: {};
38
- response: {};
30
+ schema: {};
31
+ standaloneSchema: {};
32
+ macro: {};
33
+ macroFn: {};
34
+ parser: {};
35
+ response: {};
39
36
  }, {
40
- [x: string]: {
41
- "*": {
42
- [x: string]: {
43
- body: unknown;
44
- params: {
45
- "*": string;
46
- } & {};
47
- query: unknown;
48
- headers: unknown;
49
- response: {
50
- 200: {} | {
51
- jsonrpc: string;
52
- error: {
53
- code: _modelcontextprotocol_sdk_types_js0.ErrorCode;
54
- message: string;
55
- data: string;
37
+ [x: string]: {
38
+ "*": {
39
+ [x: string]: {
40
+ body: unknown;
41
+ params: {
42
+ "*": string;
43
+ } & {};
44
+ query: unknown;
45
+ headers: unknown;
46
+ response: {
47
+ 200: {} | {
48
+ jsonrpc: string;
49
+ error: {
50
+ code: import("@modelcontextprotocol/sdk/types.js").ErrorCode;
51
+ message: string;
52
+ data: string;
53
+ };
54
+ id: null;
55
+ };
56
+ 422: {
57
+ type: "validation";
58
+ on: string;
59
+ summary?: string;
60
+ message?: string;
61
+ found?: unknown;
62
+ property?: string;
63
+ expected?: string;
64
+ };
65
+ };
56
66
  };
57
- id: null;
58
- };
59
- 422: {
60
- type: "validation";
61
- on: string;
62
- summary?: string;
63
- message?: string;
64
- found?: unknown;
65
- property?: string;
66
- expected?: string;
67
- };
68
67
  };
69
- };
70
68
  };
71
- };
72
69
  } & {
73
- [x: string]: {
74
70
  [x: string]: {
75
- body: unknown;
76
- params: {};
77
- query: unknown;
78
- headers: unknown;
79
- response: {
80
- 200: {} | {
81
- jsonrpc: string;
82
- error: {
83
- code: _modelcontextprotocol_sdk_types_js0.ErrorCode;
84
- message: string;
85
- data: string;
86
- };
87
- id: null;
71
+ [x: string]: {
72
+ body: unknown;
73
+ params: {};
74
+ query: unknown;
75
+ headers: unknown;
76
+ response: {
77
+ 200: {} | {
78
+ jsonrpc: string;
79
+ error: {
80
+ code: import("@modelcontextprotocol/sdk/types.js").ErrorCode;
81
+ message: string;
82
+ data: string;
83
+ };
84
+ id: null;
85
+ };
86
+ };
88
87
  };
89
- };
90
88
  };
91
- };
92
89
  }, {
93
- derive: {};
94
- resolve: {};
95
- schema: {};
96
- standaloneSchema: {};
97
- response: {};
90
+ derive: {};
91
+ resolve: {};
92
+ schema: {};
93
+ standaloneSchema: {};
94
+ response: {};
98
95
  }, {
99
- derive: {};
100
- resolve: {};
101
- schema: {};
102
- standaloneSchema: {};
103
- response: {
104
- 200: {} | {
105
- jsonrpc: string;
106
- error: {
107
- code: _modelcontextprotocol_sdk_types_js0.ErrorCode;
108
- message: string;
109
- data: string;
110
- };
111
- id: null;
96
+ derive: {};
97
+ resolve: {};
98
+ schema: {};
99
+ standaloneSchema: {};
100
+ response: {
101
+ 200: {} | {
102
+ jsonrpc: string;
103
+ error: {
104
+ code: import("@modelcontextprotocol/sdk/types.js").ErrorCode;
105
+ message: string;
106
+ data: string;
107
+ };
108
+ id: null;
109
+ };
112
110
  };
113
- };
114
111
  }>;
115
- declare function createAlpicMcpApp(options?: AlpicMcpAppOptions): Elysia;
116
- //#endregion
117
- export { AlpicMcpAppOptions, AlpicMcpHandlerOptions, createAlpicMcpApp, createAlpicMcpHandler };
112
+ export declare function createAlpicMcpApp(options?: AlpicMcpAppOptions): Elysia;
118
113
  //# sourceMappingURL=create-alpic-mcp-app.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-alpic-mcp-app.d.ts","names":[],"sources":["../../src/mcp/create-alpic-mcp-app.ts"],"mappings":";;;;;;;UAOiB,kBAAA;EACf,UAAA;EACA,aAAA;EACA,SAAA;EACA,SAAA;EACA,kBAAA;EACA,eAAA;EACA,EAAA,GAAK,gBAAA;EACL,IAAA,GAAO,kBAAA;EACP,MAAA,GAAS,MAAA;AAAA;AAAA,UAGM,sBAAA,SAA+B,kBAAA;EAC9C,IAAA;AAAA;AAAA,iBA+Dc,qBAAA,CAAsB,OAAA,EAAS,sBAAA,GAAsB,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuBrD,iBAAA,CAAkB,OAAA,GAAS,kBAAA,GAA0B,MAAA"}
1
+ {"version":3,"file":"create-alpic-mcp-app.d.ts","sourceRoot":"","sources":["../../src/mcp/create-alpic-mcp-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,MAAM,EAAY,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,KAAK,gBAAgB,EAA0B,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,SAAS,CAAC;AAEtE,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,EAAE,CAAC,EAAE,gBAAgB,CAAC;IACtB,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,IAAI,EAAE,MAAM,CAAC;CACd;AA8DD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAsC2yL,CAAC;+BAAuB,CAAC;6BAAqB,CAAC;gCAAyB,CAAC;gCAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAjBj9L;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB,GAAG,MAAM,CAc1E"}
@@ -1,11 +1,10 @@
1
- //#region src/mcp/resources.d.ts
2
- interface AlpicMcpUiConfig {
3
- resourceKey?: string;
4
- resourceUri?: string;
5
- title?: string;
6
- description?: string;
7
- assetPath?: string;
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export interface AlpicMcpUiConfig {
3
+ resourceKey?: string;
4
+ resourceUri?: string;
5
+ title?: string;
6
+ description?: string;
7
+ assetPath?: string;
8
8
  }
9
- //#endregion
10
- export { AlpicMcpUiConfig };
9
+ export declare function registerAlpicResources(server: McpServer, config?: AlpicMcpUiConfig): void;
11
10
  //# sourceMappingURL=resources.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resources.d.ts","names":[],"sources":["../../src/mcp/resources.ts"],"mappings":";UAGiB,gBAAA;EACf,WAAA;EACA,WAAA;EACA,KAAA;EACA,WAAA;EACA,SAAA;AAAA"}
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/mcp/resources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,SAAS,EACjB,MAAM,GAAE,gBAAqB,GAC5B,IAAI,CAqCN"}
@@ -1,8 +1,7 @@
1
- //#region src/mcp/tools.d.ts
2
- interface AlpicMcpToolConfig {
3
- name?: string;
4
- description?: string;
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export interface AlpicMcpToolConfig {
3
+ name?: string;
4
+ description?: string;
5
5
  }
6
- //#endregion
7
- export { AlpicMcpToolConfig };
6
+ export declare function registerAlpicTools(server: McpServer, config?: AlpicMcpToolConfig): void;
8
7
  //# sourceMappingURL=tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","names":[],"sources":["../../src/mcp/tools.ts"],"mappings":";UAIiB,kBAAA;EACf,IAAA;EACA,WAAA;AAAA"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAID,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,EACjB,MAAM,GAAE,kBAAuB,GAC9B,IAAI,CAyBN"}
@@ -0,0 +1,174 @@
1
+ // src/assets/paths.ts
2
+ var ASSETS_BASE = "/assets";
3
+ function normalizeAssetPath(assetPath) {
4
+ const trimmed = assetPath.trim();
5
+ if (!trimmed)
6
+ return ASSETS_BASE;
7
+ if (trimmed.startsWith(ASSETS_BASE))
8
+ return trimmed;
9
+ if (trimmed.startsWith("/"))
10
+ return `${ASSETS_BASE}${trimmed}`;
11
+ return `${ASSETS_BASE}/${trimmed}`;
12
+ }
13
+ function alpicAssetPath(assetPath) {
14
+ return normalizeAssetPath(assetPath);
15
+ }
16
+ function alpicAssetUrl(assetPath) {
17
+ const path = normalizeAssetPath(assetPath);
18
+ const host = process.env.ALPIC_HOST?.trim();
19
+ if (!host)
20
+ return path;
21
+ return `https://${host}${path}`;
22
+ }
23
+ // src/mcp/create-alpic-mcp-app.ts
24
+ import { Elysia } from "elysia";
25
+ import { mcp } from "elysia-mcp";
26
+ import { Logger, LogLevel } from "@contractspec/lib.logger";
27
+
28
+ // src/mcp/resources.ts
29
+ var defaultResourceKey = "alpic_ui";
30
+ var defaultResourceUri = "app://ui";
31
+ function registerAlpicResources(server, config = {}) {
32
+ const assetPath = config.assetPath ?? "index.html";
33
+ const path = alpicAssetPath(assetPath);
34
+ const url = alpicAssetUrl(assetPath);
35
+ const resourceKey = config.resourceKey ?? defaultResourceKey;
36
+ const resourceUri = config.resourceUri ?? defaultResourceUri;
37
+ const title = config.title ?? "ChatGPT App UI";
38
+ const description = config.description ?? "Entry point for the ChatGPT App UI hosted on Alpic.";
39
+ server.registerResource(resourceKey, resourceUri, {
40
+ title,
41
+ description,
42
+ mimeType: "application/json"
43
+ }, async () => {
44
+ const payload = {
45
+ title,
46
+ description,
47
+ path,
48
+ url
49
+ };
50
+ return {
51
+ contents: [
52
+ {
53
+ uri: resourceUri,
54
+ mimeType: "application/json",
55
+ text: JSON.stringify(payload, null, 2)
56
+ }
57
+ ]
58
+ };
59
+ });
60
+ }
61
+
62
+ // src/mcp/tools.ts
63
+ import * as z from "zod";
64
+ var defaultToolName = "alpic.ping";
65
+ function registerAlpicTools(server, config = {}) {
66
+ const toolName = config.name ?? defaultToolName;
67
+ const description = config.description ?? "Ping the MCP server and return basic Alpic info.";
68
+ const inputSchema = z.object({
69
+ message: z.string().optional()
70
+ });
71
+ server.registerTool(toolName, { description, inputSchema }, async (args) => {
72
+ const payload = {
73
+ ok: true,
74
+ message: args.message ?? "pong",
75
+ assetsBase: alpicAssetPath(""),
76
+ timestamp: new Date().toISOString()
77
+ };
78
+ return {
79
+ content: [
80
+ {
81
+ type: "text",
82
+ text: JSON.stringify(payload, null, 2)
83
+ }
84
+ ]
85
+ };
86
+ });
87
+ }
88
+
89
+ // src/mcp/create-alpic-mcp-app.ts
90
+ var defaultServerName = "contractspec-alpic-mcp";
91
+ var defaultServerVersion = "1.0.0";
92
+ function resolveDebugFlag(explicit) {
93
+ if (typeof explicit === "boolean")
94
+ return explicit;
95
+ return process.env.ALPIC_MCP_DEBUG === "1" || process.env.CONTRACTSPEC_MCP_DEBUG === "1";
96
+ }
97
+ function createDefaultLogger(debug) {
98
+ return new Logger({
99
+ level: debug ? LogLevel.DEBUG : LogLevel.INFO,
100
+ environment: "development",
101
+ enableTracing: false,
102
+ enableTiming: false,
103
+ enableContext: false,
104
+ enableColors: true
105
+ });
106
+ }
107
+ function createConsoleLikeLogger(logger, debug) {
108
+ const toMessage = (args) => args.map((item) => typeof item === "string" ? item : JSON.stringify(item)).join(" ");
109
+ return {
110
+ log: (...args) => {
111
+ if (!debug)
112
+ return;
113
+ logger.info(toMessage(args));
114
+ },
115
+ info: (...args) => {
116
+ if (!debug)
117
+ return;
118
+ logger.info(toMessage(args));
119
+ },
120
+ warn: (...args) => {
121
+ logger.warn(toMessage(args));
122
+ },
123
+ error: (...args) => {
124
+ logger.error(toMessage(args));
125
+ },
126
+ debug: (...args) => {
127
+ if (!debug)
128
+ return;
129
+ logger.debug(toMessage(args));
130
+ }
131
+ };
132
+ }
133
+ function setupMcpServer(server, options) {
134
+ registerAlpicTools(server, options.tool);
135
+ registerAlpicResources(server, options.ui);
136
+ }
137
+ function createAlpicMcpHandler(options) {
138
+ const debug = resolveDebugFlag(options.enableDebugLogs);
139
+ const logger = options.logger ?? createDefaultLogger(debug);
140
+ return mcp({
141
+ basePath: options.path,
142
+ logger: createConsoleLikeLogger(logger, debug),
143
+ serverInfo: {
144
+ name: options.serverName ?? defaultServerName,
145
+ version: options.serverVersion ?? defaultServerVersion
146
+ },
147
+ stateless: options.stateless ?? true,
148
+ enableJsonResponse: options.enableJsonResponse ?? true,
149
+ capabilities: {
150
+ tools: {},
151
+ resources: {},
152
+ prompts: {},
153
+ logging: {}
154
+ },
155
+ setupServer: (server) => setupMcpServer(server, options)
156
+ });
157
+ }
158
+ function createAlpicMcpApp(options = {}) {
159
+ const app = new Elysia;
160
+ const basePaths = options.basePaths ?? ["/", "/mcp"];
161
+ basePaths.forEach((path) => {
162
+ app.use(createAlpicMcpHandler({
163
+ ...options,
164
+ path
165
+ }));
166
+ });
167
+ return app;
168
+ }
169
+ export {
170
+ createAlpicMcpHandler,
171
+ createAlpicMcpApp,
172
+ alpicAssetUrl,
173
+ alpicAssetPath
174
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/module.alpic",
3
- "version": "1.57.0",
3
+ "version": "1.59.0",
4
4
  "description": "Alpic MCP and ChatGPT App hosting helpers",
5
5
  "keywords": [
6
6
  "contractspec",
@@ -19,37 +19,42 @@
19
19
  "scripts": {
20
20
  "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
21
21
  "publish:pkg:canary": "bun publish:pkg --tag canary",
22
- "build": "bun build:types && bun build:bundle",
23
- "build:bundle": "tsdown",
24
- "build:types": "tsc --noEmit",
25
- "dev": "bun build:bundle --watch",
22
+ "build": "bun run prebuild && bun run build:bundle && bun run build:types",
23
+ "build:bundle": "contractspec-bun-build transpile",
24
+ "build:types": "contractspec-bun-build types",
25
+ "dev": "contractspec-bun-build dev",
26
26
  "clean": "rimraf dist .turbo",
27
27
  "lint": "bun lint:fix",
28
28
  "lint:fix": "eslint src --fix",
29
- "lint:check": "eslint src"
29
+ "lint:check": "eslint src",
30
+ "prebuild": "contractspec-bun-build prebuild",
31
+ "typecheck": "tsc --noEmit"
30
32
  },
31
33
  "dependencies": {
32
- "@contractspec/lib.logger": "1.57.0",
34
+ "@contractspec/lib.logger": "1.59.0",
33
35
  "@modelcontextprotocol/sdk": "^1.26.0",
34
36
  "elysia": "^1.4.21",
35
37
  "elysia-mcp": "^0.1.0",
36
38
  "zod": "^4.3.5"
37
39
  },
38
40
  "devDependencies": {
39
- "@contractspec/tool.tsdown": "1.57.0",
40
- "@contractspec/tool.typescript": "1.57.0",
41
- "tsdown": "^0.20.3",
42
- "typescript": "^5.9.3"
41
+ "@contractspec/tool.typescript": "1.59.0",
42
+ "typescript": "^5.9.3",
43
+ "@contractspec/tool.bun": "1.58.0"
43
44
  },
44
45
  "exports": {
45
- ".": "./dist/index.js",
46
- "./*": "./*"
46
+ ".": "./src/index.ts"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public",
50
50
  "exports": {
51
- ".": "./dist/index.js",
52
- "./*": "./*"
51
+ ".": {
52
+ "types": "./dist/index.d.ts",
53
+ "bun": "./dist/index.js",
54
+ "node": "./dist/node/index.mjs",
55
+ "browser": "./dist/browser/index.js",
56
+ "default": "./dist/index.js"
57
+ }
53
58
  },
54
59
  "registry": "https://registry.npmjs.org/"
55
60
  },
@@ -1,22 +0,0 @@
1
- //#region src/assets/paths.ts
2
- const ASSETS_BASE = "/assets";
3
- function normalizeAssetPath(assetPath) {
4
- const trimmed = assetPath.trim();
5
- if (!trimmed) return ASSETS_BASE;
6
- if (trimmed.startsWith(ASSETS_BASE)) return trimmed;
7
- if (trimmed.startsWith("/")) return `${ASSETS_BASE}${trimmed}`;
8
- return `${ASSETS_BASE}/${trimmed}`;
9
- }
10
- function alpicAssetPath(assetPath) {
11
- return normalizeAssetPath(assetPath);
12
- }
13
- function alpicAssetUrl(assetPath) {
14
- const path = normalizeAssetPath(assetPath);
15
- const host = process.env.ALPIC_HOST?.trim();
16
- if (!host) return path;
17
- return `https://${host}${path}`;
18
- }
19
-
20
- //#endregion
21
- export { alpicAssetPath, alpicAssetUrl };
22
- //# sourceMappingURL=paths.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"paths.js","names":[],"sources":["../../src/assets/paths.ts"],"sourcesContent":["const ASSETS_BASE = '/assets';\n\nfunction normalizeAssetPath(assetPath: string): string {\n const trimmed = assetPath.trim();\n if (!trimmed) return ASSETS_BASE;\n if (trimmed.startsWith(ASSETS_BASE)) return trimmed;\n if (trimmed.startsWith('/')) return `${ASSETS_BASE}${trimmed}`;\n return `${ASSETS_BASE}/${trimmed}`;\n}\n\nexport function alpicAssetPath(assetPath: string): string {\n return normalizeAssetPath(assetPath);\n}\n\nexport function alpicAssetUrl(assetPath: string): string {\n const path = normalizeAssetPath(assetPath);\n const host = process.env.ALPIC_HOST?.trim();\n if (!host) return path;\n return `https://${host}${path}`;\n}\n"],"mappings":";AAAA,MAAM,cAAc;AAEpB,SAAS,mBAAmB,WAA2B;CACrD,MAAM,UAAU,UAAU,MAAM;AAChC,KAAI,CAAC,QAAS,QAAO;AACrB,KAAI,QAAQ,WAAW,YAAY,CAAE,QAAO;AAC5C,KAAI,QAAQ,WAAW,IAAI,CAAE,QAAO,GAAG,cAAc;AACrD,QAAO,GAAG,YAAY,GAAG;;AAG3B,SAAgB,eAAe,WAA2B;AACxD,QAAO,mBAAmB,UAAU;;AAGtC,SAAgB,cAAc,WAA2B;CACvD,MAAM,OAAO,mBAAmB,UAAU;CAC1C,MAAM,OAAO,QAAQ,IAAI,YAAY,MAAM;AAC3C,KAAI,CAAC,KAAM,QAAO;AAClB,QAAO,WAAW,OAAO"}
@@ -1,85 +0,0 @@
1
- import { registerAlpicResources } from "./resources.js";
2
- import { registerAlpicTools } from "./tools.js";
3
- import { Elysia } from "elysia";
4
- import { mcp } from "elysia-mcp";
5
- import { LogLevel, Logger } from "@contractspec/lib.logger";
6
-
7
- //#region src/mcp/create-alpic-mcp-app.ts
8
- const defaultServerName = "contractspec-alpic-mcp";
9
- const defaultServerVersion = "1.0.0";
10
- function resolveDebugFlag(explicit) {
11
- if (typeof explicit === "boolean") return explicit;
12
- return process.env.ALPIC_MCP_DEBUG === "1" || process.env.CONTRACTSPEC_MCP_DEBUG === "1";
13
- }
14
- function createDefaultLogger(debug) {
15
- return new Logger({
16
- level: debug ? LogLevel.DEBUG : LogLevel.INFO,
17
- environment: process.env.NODE_ENV || "development",
18
- enableTracing: false,
19
- enableTiming: false,
20
- enableContext: false,
21
- enableColors: process.env.NODE_ENV !== "production"
22
- });
23
- }
24
- function createConsoleLikeLogger(logger, debug) {
25
- const toMessage = (args) => args.map((item) => typeof item === "string" ? item : JSON.stringify(item)).join(" ");
26
- return {
27
- log: (...args) => {
28
- if (!debug) return;
29
- logger.info(toMessage(args));
30
- },
31
- info: (...args) => {
32
- if (!debug) return;
33
- logger.info(toMessage(args));
34
- },
35
- warn: (...args) => {
36
- logger.warn(toMessage(args));
37
- },
38
- error: (...args) => {
39
- logger.error(toMessage(args));
40
- },
41
- debug: (...args) => {
42
- if (!debug) return;
43
- logger.debug(toMessage(args));
44
- }
45
- };
46
- }
47
- function setupMcpServer(server, options) {
48
- registerAlpicTools(server, options.tool);
49
- registerAlpicResources(server, options.ui);
50
- }
51
- function createAlpicMcpHandler(options) {
52
- const debug = resolveDebugFlag(options.enableDebugLogs);
53
- const logger = options.logger ?? createDefaultLogger(debug);
54
- return mcp({
55
- basePath: options.path,
56
- logger: createConsoleLikeLogger(logger, debug),
57
- serverInfo: {
58
- name: options.serverName ?? defaultServerName,
59
- version: options.serverVersion ?? defaultServerVersion
60
- },
61
- stateless: options.stateless ?? true,
62
- enableJsonResponse: options.enableJsonResponse ?? true,
63
- capabilities: {
64
- tools: {},
65
- resources: {},
66
- prompts: {},
67
- logging: {}
68
- },
69
- setupServer: (server) => setupMcpServer(server, options)
70
- });
71
- }
72
- function createAlpicMcpApp(options = {}) {
73
- const app = new Elysia();
74
- (options.basePaths ?? ["/", "/mcp"]).forEach((path) => {
75
- app.use(createAlpicMcpHandler({
76
- ...options,
77
- path
78
- }));
79
- });
80
- return app;
81
- }
82
-
83
- //#endregion
84
- export { createAlpicMcpApp, createAlpicMcpHandler };
85
- //# sourceMappingURL=create-alpic-mcp-app.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-alpic-mcp-app.js","names":[],"sources":["../../src/mcp/create-alpic-mcp-app.ts"],"sourcesContent":["import { Elysia } from 'elysia';\nimport { mcp } from 'elysia-mcp';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { Logger, LogLevel } from '@contractspec/lib.logger';\nimport { type AlpicMcpUiConfig, registerAlpicResources } from './resources';\nimport { type AlpicMcpToolConfig, registerAlpicTools } from './tools';\n\nexport interface AlpicMcpAppOptions {\n serverName?: string;\n serverVersion?: string;\n basePaths?: string[];\n stateless?: boolean;\n enableJsonResponse?: boolean;\n enableDebugLogs?: boolean;\n ui?: AlpicMcpUiConfig;\n tool?: AlpicMcpToolConfig;\n logger?: Logger;\n}\n\nexport interface AlpicMcpHandlerOptions extends AlpicMcpAppOptions {\n path: string;\n}\n\nconst defaultServerName = 'contractspec-alpic-mcp';\nconst defaultServerVersion = '1.0.0';\n\nfunction resolveDebugFlag(explicit?: boolean): boolean {\n if (typeof explicit === 'boolean') return explicit;\n return (\n process.env.ALPIC_MCP_DEBUG === '1' ||\n process.env.CONTRACTSPEC_MCP_DEBUG === '1'\n );\n}\n\nfunction createDefaultLogger(debug: boolean): Logger {\n return new Logger({\n level: debug ? LogLevel.DEBUG : LogLevel.INFO,\n environment:\n (process.env.NODE_ENV as 'production' | 'development' | 'test') ||\n 'development',\n enableTracing: false,\n enableTiming: false,\n enableContext: false,\n enableColors: process.env.NODE_ENV !== 'production',\n });\n}\n\nfunction createConsoleLikeLogger(logger: Logger, debug: boolean) {\n const toMessage = (args: unknown[]) =>\n args\n .map((item) => (typeof item === 'string' ? item : JSON.stringify(item)))\n .join(' ');\n\n return {\n log: (...args: unknown[]) => {\n if (!debug) return;\n logger.info(toMessage(args));\n },\n info: (...args: unknown[]) => {\n if (!debug) return;\n logger.info(toMessage(args));\n },\n warn: (...args: unknown[]) => {\n logger.warn(toMessage(args));\n },\n error: (...args: unknown[]) => {\n logger.error(toMessage(args));\n },\n debug: (...args: unknown[]) => {\n if (!debug) return;\n logger.debug(toMessage(args));\n },\n };\n}\n\nfunction setupMcpServer(\n server: McpServer,\n options: AlpicMcpHandlerOptions\n): void {\n registerAlpicTools(server, options.tool);\n registerAlpicResources(server, options.ui);\n}\n\nexport function createAlpicMcpHandler(options: AlpicMcpHandlerOptions) {\n const debug = resolveDebugFlag(options.enableDebugLogs);\n const logger = options.logger ?? createDefaultLogger(debug);\n\n return mcp({\n basePath: options.path,\n logger: createConsoleLikeLogger(logger, debug),\n serverInfo: {\n name: options.serverName ?? defaultServerName,\n version: options.serverVersion ?? defaultServerVersion,\n },\n stateless: options.stateless ?? true,\n enableJsonResponse: options.enableJsonResponse ?? true,\n capabilities: {\n tools: {},\n resources: {},\n prompts: {},\n logging: {},\n },\n setupServer: (server) => setupMcpServer(server, options),\n });\n}\n\nexport function createAlpicMcpApp(options: AlpicMcpAppOptions = {}): Elysia {\n const app = new Elysia();\n const basePaths = options.basePaths ?? ['/', '/mcp'];\n\n basePaths.forEach((path) => {\n app.use(\n createAlpicMcpHandler({\n ...options,\n path,\n })\n );\n });\n\n return app;\n}\n"],"mappings":";;;;;;;AAuBA,MAAM,oBAAoB;AAC1B,MAAM,uBAAuB;AAE7B,SAAS,iBAAiB,UAA6B;AACrD,KAAI,OAAO,aAAa,UAAW,QAAO;AAC1C,QACE,QAAQ,IAAI,oBAAoB,OAChC,QAAQ,IAAI,2BAA2B;;AAI3C,SAAS,oBAAoB,OAAwB;AACnD,QAAO,IAAI,OAAO;EAChB,OAAO,QAAQ,SAAS,QAAQ,SAAS;EACzC,aACG,QAAQ,IAAI,YACb;EACF,eAAe;EACf,cAAc;EACd,eAAe;EACf,cAAc,QAAQ,IAAI,aAAa;EACxC,CAAC;;AAGJ,SAAS,wBAAwB,QAAgB,OAAgB;CAC/D,MAAM,aAAa,SACjB,KACG,KAAK,SAAU,OAAO,SAAS,WAAW,OAAO,KAAK,UAAU,KAAK,CAAE,CACvE,KAAK,IAAI;AAEd,QAAO;EACL,MAAM,GAAG,SAAoB;AAC3B,OAAI,CAAC,MAAO;AACZ,UAAO,KAAK,UAAU,KAAK,CAAC;;EAE9B,OAAO,GAAG,SAAoB;AAC5B,OAAI,CAAC,MAAO;AACZ,UAAO,KAAK,UAAU,KAAK,CAAC;;EAE9B,OAAO,GAAG,SAAoB;AAC5B,UAAO,KAAK,UAAU,KAAK,CAAC;;EAE9B,QAAQ,GAAG,SAAoB;AAC7B,UAAO,MAAM,UAAU,KAAK,CAAC;;EAE/B,QAAQ,GAAG,SAAoB;AAC7B,OAAI,CAAC,MAAO;AACZ,UAAO,MAAM,UAAU,KAAK,CAAC;;EAEhC;;AAGH,SAAS,eACP,QACA,SACM;AACN,oBAAmB,QAAQ,QAAQ,KAAK;AACxC,wBAAuB,QAAQ,QAAQ,GAAG;;AAG5C,SAAgB,sBAAsB,SAAiC;CACrE,MAAM,QAAQ,iBAAiB,QAAQ,gBAAgB;CACvD,MAAM,SAAS,QAAQ,UAAU,oBAAoB,MAAM;AAE3D,QAAO,IAAI;EACT,UAAU,QAAQ;EAClB,QAAQ,wBAAwB,QAAQ,MAAM;EAC9C,YAAY;GACV,MAAM,QAAQ,cAAc;GAC5B,SAAS,QAAQ,iBAAiB;GACnC;EACD,WAAW,QAAQ,aAAa;EAChC,oBAAoB,QAAQ,sBAAsB;EAClD,cAAc;GACZ,OAAO,EAAE;GACT,WAAW,EAAE;GACb,SAAS,EAAE;GACX,SAAS,EAAE;GACZ;EACD,cAAc,WAAW,eAAe,QAAQ,QAAQ;EACzD,CAAC;;AAGJ,SAAgB,kBAAkB,UAA8B,EAAE,EAAU;CAC1E,MAAM,MAAM,IAAI,QAAQ;AAGxB,EAFkB,QAAQ,aAAa,CAAC,KAAK,OAAO,EAE1C,SAAS,SAAS;AAC1B,MAAI,IACF,sBAAsB;GACpB,GAAG;GACH;GACD,CAAC,CACH;GACD;AAEF,QAAO"}
@@ -1,35 +0,0 @@
1
- import { alpicAssetPath, alpicAssetUrl } from "../assets/paths.js";
2
-
3
- //#region src/mcp/resources.ts
4
- const defaultResourceKey = "alpic_ui";
5
- const defaultResourceUri = "app://ui";
6
- function registerAlpicResources(server, config = {}) {
7
- const assetPath = config.assetPath ?? "index.html";
8
- const path = alpicAssetPath(assetPath);
9
- const url = alpicAssetUrl(assetPath);
10
- const resourceKey = config.resourceKey ?? defaultResourceKey;
11
- const resourceUri = config.resourceUri ?? defaultResourceUri;
12
- const title = config.title ?? "ChatGPT App UI";
13
- const description = config.description ?? "Entry point for the ChatGPT App UI hosted on Alpic.";
14
- server.registerResource(resourceKey, resourceUri, {
15
- title,
16
- description,
17
- mimeType: "application/json"
18
- }, async () => {
19
- const payload = {
20
- title,
21
- description,
22
- path,
23
- url
24
- };
25
- return { contents: [{
26
- uri: resourceUri,
27
- mimeType: "application/json",
28
- text: JSON.stringify(payload, null, 2)
29
- }] };
30
- });
31
- }
32
-
33
- //#endregion
34
- export { registerAlpicResources };
35
- //# sourceMappingURL=resources.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resources.js","names":[],"sources":["../../src/mcp/resources.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { alpicAssetPath, alpicAssetUrl } from '../assets/paths';\n\nexport interface AlpicMcpUiConfig {\n resourceKey?: string;\n resourceUri?: string;\n title?: string;\n description?: string;\n assetPath?: string;\n}\n\nconst defaultResourceKey = 'alpic_ui';\nconst defaultResourceUri = 'app://ui';\n\nexport function registerAlpicResources(\n server: McpServer,\n config: AlpicMcpUiConfig = {}\n): void {\n const assetPath = config.assetPath ?? 'index.html';\n const path = alpicAssetPath(assetPath);\n const url = alpicAssetUrl(assetPath);\n const resourceKey = config.resourceKey ?? defaultResourceKey;\n const resourceUri = config.resourceUri ?? defaultResourceUri;\n const title = config.title ?? 'ChatGPT App UI';\n const description =\n config.description ?? 'Entry point for the ChatGPT App UI hosted on Alpic.';\n\n server.registerResource(\n resourceKey,\n resourceUri,\n {\n title,\n description,\n mimeType: 'application/json',\n },\n async () => {\n const payload = {\n title,\n description,\n path,\n url,\n };\n\n return {\n contents: [\n {\n uri: resourceUri,\n mimeType: 'application/json',\n text: JSON.stringify(payload, null, 2),\n },\n ],\n };\n }\n );\n}\n"],"mappings":";;;AAWA,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAE3B,SAAgB,uBACd,QACA,SAA2B,EAAE,EACvB;CACN,MAAM,YAAY,OAAO,aAAa;CACtC,MAAM,OAAO,eAAe,UAAU;CACtC,MAAM,MAAM,cAAc,UAAU;CACpC,MAAM,cAAc,OAAO,eAAe;CAC1C,MAAM,cAAc,OAAO,eAAe;CAC1C,MAAM,QAAQ,OAAO,SAAS;CAC9B,MAAM,cACJ,OAAO,eAAe;AAExB,QAAO,iBACL,aACA,aACA;EACE;EACA;EACA,UAAU;EACX,EACD,YAAY;EACV,MAAM,UAAU;GACd;GACA;GACA;GACA;GACD;AAED,SAAO,EACL,UAAU,CACR;GACE,KAAK;GACL,UAAU;GACV,MAAM,KAAK,UAAU,SAAS,MAAM,EAAE;GACvC,CACF,EACF;GAEJ"}
package/dist/mcp/tools.js DELETED
@@ -1,29 +0,0 @@
1
- import { alpicAssetPath } from "../assets/paths.js";
2
- import * as z from "zod";
3
-
4
- //#region src/mcp/tools.ts
5
- const defaultToolName = "alpic.ping";
6
- function registerAlpicTools(server, config = {}) {
7
- const toolName = config.name ?? defaultToolName;
8
- const description = config.description ?? "Ping the MCP server and return basic Alpic info.";
9
- const inputSchema = z.object({ message: z.string().optional() });
10
- server.registerTool(toolName, {
11
- description,
12
- inputSchema
13
- }, async (args) => {
14
- const payload = {
15
- ok: true,
16
- message: args.message ?? "pong",
17
- assetsBase: alpicAssetPath(""),
18
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
19
- };
20
- return { content: [{
21
- type: "text",
22
- text: JSON.stringify(payload, null, 2)
23
- }] };
24
- });
25
- }
26
-
27
- //#endregion
28
- export { registerAlpicTools };
29
- //# sourceMappingURL=tools.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.js","names":[],"sources":["../../src/mcp/tools.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport * as z from 'zod';\nimport { alpicAssetPath } from '../assets/paths';\n\nexport interface AlpicMcpToolConfig {\n name?: string;\n description?: string;\n}\n\nconst defaultToolName = 'alpic.ping';\n\nexport function registerAlpicTools(\n server: McpServer,\n config: AlpicMcpToolConfig = {}\n): void {\n const toolName = config.name ?? defaultToolName;\n const description =\n config.description ?? 'Ping the MCP server and return basic Alpic info.';\n const inputSchema = z.object({\n message: z.string().optional(),\n });\n\n server.registerTool(toolName, { description, inputSchema }, async (args) => {\n const payload = {\n ok: true,\n message: args.message ?? 'pong',\n assetsBase: alpicAssetPath(''),\n timestamp: new Date().toISOString(),\n };\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(payload, null, 2),\n },\n ],\n };\n });\n}\n"],"mappings":";;;;AASA,MAAM,kBAAkB;AAExB,SAAgB,mBACd,QACA,SAA6B,EAAE,EACzB;CACN,MAAM,WAAW,OAAO,QAAQ;CAChC,MAAM,cACJ,OAAO,eAAe;CACxB,MAAM,cAAc,EAAE,OAAO,EAC3B,SAAS,EAAE,QAAQ,CAAC,UAAU,EAC/B,CAAC;AAEF,QAAO,aAAa,UAAU;EAAE;EAAa;EAAa,EAAE,OAAO,SAAS;EAC1E,MAAM,UAAU;GACd,IAAI;GACJ,SAAS,KAAK,WAAW;GACzB,YAAY,eAAe,GAAG;GAC9B,4BAAW,IAAI,MAAM,EAAC,aAAa;GACpC;AAED,SAAO,EACL,SAAS,CACP;GACE,MAAM;GACN,MAAM,KAAK,UAAU,SAAS,MAAM,EAAE;GACvC,CACF,EACF;GACD"}