@lssm-tech/module.alpic 3.7.29

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Chaman Ventures, SASU
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @contractspec/module.alpic
2
+
3
+ Website: https://contractspec.io
4
+
5
+ **Alpic MCP and ChatGPT App hosting helpers.**
6
+
7
+ ## What It Provides
8
+
9
+ - **Layer**: module.
10
+ - **Consumers**: apps (alpic-mcp, chatgpt-app).
11
+ - `src/mcp/` contains MCP handlers, tools, prompts, and resources.
12
+ - Related ContractSpec packages include `@contractspec/lib.contracts-spec`, `@contractspec/lib.logger`, `@contractspec/tool.bun`, `@contractspec/tool.typescript`.
13
+ - `src/mcp/` contains MCP handlers, tools, prompts, and resources.
14
+
15
+ ## Installation
16
+
17
+ `npm install @contractspec/module.alpic`
18
+
19
+ or
20
+
21
+ `bun add @contractspec/module.alpic`
22
+
23
+ ## Usage
24
+
25
+ Import the root entrypoint from `@contractspec/module.alpic`, or choose a documented subpath when you only need one part of the package surface.
26
+
27
+ ## Architecture
28
+
29
+ - `src/assets` is part of the package's public or composition surface.
30
+ - `src/index.ts` is the root public barrel and package entrypoint.
31
+ - `src/mcp/` contains MCP handlers, tools, prompts, and resources.
32
+
33
+ ## Public Entry Points
34
+
35
+ - Export `.` resolves through `./src/index.ts`.
36
+
37
+ ## Local Commands
38
+
39
+ - `bun run dev` — contractspec-bun-build dev
40
+ - `bun run build` — bun run prebuild && bun run build:bundle && bun run build:types
41
+ - `bun run lint` — bun lint:fix
42
+ - `bun run lint:check` — biome check .
43
+ - `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
44
+ - `bun run typecheck` — tsc --noEmit
45
+ - `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
46
+ - `bun run publish:pkg:canary` — bun publish:pkg --tag canary
47
+ - `bun run clean` — rimraf dist .turbo
48
+ - `bun run build:bundle` — contractspec-bun-build transpile
49
+ - `bun run build:types` — contractspec-bun-build types
50
+ - `bun run prebuild` — contractspec-bun-build prebuild
51
+
52
+ ## Recent Updates
53
+
54
+ - Replace eslint+prettier by biomejs to optimize speed.
55
+ - Standardize tool naming to underscore notation.
56
+ - Add changesets and apply pending fixes.
57
+ - Add first-class transport, auth, versioning, and BYOK support across all integrations.
58
+ - Test runner.
59
+
60
+ ## Notes
61
+
62
+ - Depends on `@modelcontextprotocol/sdk` and `elysia` -- version bumps may break MCP protocol compatibility.
63
+ - Exposes external-facing endpoints; treat all inputs as untrusted.
64
+ - Changes affect MCP tool registration and ChatGPT plugin manifests.
@@ -0,0 +1 @@
1
+ export declare const AlpicFeature: import("@contractspec/lib.contracts-spec").FeatureModuleSpec;
@@ -0,0 +1,2 @@
1
+ export declare function alpicAssetPath(assetPath: string): string;
2
+ export declare function alpicAssetUrl(assetPath: string): string;
@@ -0,0 +1,3 @@
1
+ export * from './alpic.feature';
2
+ export * from './assets/paths';
3
+ export * from './mcp/create-alpic-mcp-app';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{defineFeature as Q}from"@contractspec/lib.contracts-spec/features";var d=Q({meta:{key:"modules.alpic",version:"1.0.0",title:"Alpic",description:"Alpic MCP and ChatGPT App hosting helpers",domain:"alpic",owners:["@contractspec-core"],tags:["package","modules","alpic"],stability:"experimental"}});function O(A){let y=A.trim();if(!y)return"/assets";if(y.startsWith("/assets"))return y;if(y.startsWith("/"))return`/assets${y}`;return`/assets/${y}`}function K(A){return O(A)}function k(A){let y=O(A),E=process.env.ALPIC_HOST?.trim();if(!E)return y;return`https://${E}${y}`}import{Logger as z,LogLevel as D}from"@contractspec/lib.logger";import{McpServer as F}from"@modelcontextprotocol/sdk/server/mcp.js";import{WebStandardStreamableHTTPServerTransport as M}from"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";import{randomUUID as N}from"crypto";import{Elysia as L}from"elysia";var V="alpic_ui",X="app://ui";function J(A,y={}){let E=y.assetPath??"index.html",U=K(E),_=k(E),C=y.resourceKey??V,$=y.resourceUri??X,S=y.title??"ChatGPT App UI",x=y.description??"Entry point for the ChatGPT App UI hosted on Alpic.";A.registerResource(C,$,{title:S,description:x,mimeType:"application/json"},async()=>{return{contents:[{uri:$,mimeType:"application/json",text:JSON.stringify({title:S,description:x,path:U,url:_},null,2)}]}})}import{sanitizeMcpName as Y}from"@contractspec/lib.contracts-spec/jsonschema";import*as P from"zod";var Z="alpic_ping",W=P.object({message:P.string().optional()});function w(A,y={}){let E=Y(y.name??Z),U=y.description??"Ping the MCP server and return basic Alpic info.";A.registerTool(E,{description:U,inputSchema:W},async(_)=>{let $={ok:!0,message:W.parse(_??{}).message??"pong",assetsBase:K(""),timestamp:new Date().toISOString()};return{content:[{type:"text",text:JSON.stringify($,null,2)}]}})}var l="contractspec-alpic-mcp",u="1.0.0";function r(A){if(typeof A==="boolean")return A;return process.env.ALPIC_MCP_DEBUG==="1"||process.env.CONTRACTSPEC_MCP_DEBUG==="1"}function v(A){return new z({level:A?D.DEBUG:D.INFO,environment:"production",enableTracing:!1,enableTiming:!1,enableContext:!1,enableColors:!1})}function I(A,y){let E=(U)=>U.map((_)=>typeof _==="string"?_:JSON.stringify(_)).join(" ");return{log:(...U)=>{if(!y)return;A.info(E(U))},info:(...U)=>{if(!y)return;A.info(E(U))},warn:(...U)=>{A.warn(E(U))},error:(...U)=>{A.error(E(U))},debug:(...U)=>{if(!y)return;A.debug(E(U))}}}function b(A,y){w(A,y.tool),J(A,y.ui)}function m(A,y,E){return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:y,message:E},id:null}),{status:A,headers:{"content-type":"application/json"}})}function H(A,y){let E=new F({name:A.serverName??l,version:A.serverVersion??u},{capabilities:{tools:{},resources:{},prompts:{},logging:{}}});b(E,A);let U=new M({sessionIdGenerator:y?()=>N():void 0,enableJsonResponse:A.enableJsonResponse??!0});return E.connect(U).then(()=>({server:E,transport:U}))}async function R(A){await Promise.allSettled([A.transport.close(),A.server.close()])}function q(A){return A.replace(/[^a-zA-Z0-9]+/g,"-")}function p(A){let y=r(A.enableDebugLogs),E=A.logger??v(y),U=A.stateless??!0,_=new Map,C=`alpic-mcp-handler-${q(A.path)}`;async function $(f){let c=await H(A,!1);try{return await c.transport.handleRequest(f)}finally{await R(c)}}async function S(f){let c=_.get(f);if(!c)return;_.delete(f),await R(c)}async function x(f){let c=f.headers.get("mcp-session-id"),T,j=!1;if(c){let h=_.get(c);if(!h)return m(404,-32001,"Session not found");T=h}else T=await H(A,!0),j=!0;try{let h=await T.transport.handleRequest(f),B=T.transport.sessionId;if(B&&!_.has(B))_.set(B,T);if(f.method==="DELETE"&&B)await S(B);else if(!B&&j)await R(T);return h}catch(h){if(j)await R(T);throw h}}let G=I(E,y);return new L({name:C}).all(A.path,async({request:f})=>{try{if(A.validateAuth){if(!await A.validateAuth(f))return m(401,-32002,"Unauthorized")}if(U)return await $(f);return await x(f)}catch(c){return G.error("Error handling MCP request",{path:A.path,method:f.method,error:c instanceof Error?c.stack??c.message:String(c)}),m(500,-32000,"Internal error")}})}function TA(A={}){let y=new L;return(A.basePaths??["/","/mcp"]).forEach((U)=>{y.use(p({...A,path:U}))}),y}export{p as createAlpicMcpHandler,TA as createAlpicMcpApp,k as alpicAssetUrl,K as alpicAssetPath,d as AlpicFeature};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import { Logger } from '@contractspec/lib.logger';
2
+ import { Elysia } from 'elysia';
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;
15
+ /** Validate incoming requests against an auth scheme before processing. */
16
+ validateAuth?: (request: Request) => boolean | Promise<boolean>;
17
+ /** Auth methods the MCP server requires clients to use. */
18
+ requiredAuthMethods?: string[];
19
+ }
20
+ export interface AlpicMcpHandlerOptions extends AlpicMcpAppOptions {
21
+ path: string;
22
+ }
23
+ export declare function createAlpicMcpHandler(options: AlpicMcpHandlerOptions): Elysia;
24
+ export declare function createAlpicMcpApp(options?: AlpicMcpAppOptions): Elysia;
@@ -0,0 +1,9 @@
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
+ }
9
+ export declare function registerAlpicResources(server: McpServer, config?: AlpicMcpUiConfig): void;
@@ -0,0 +1,6 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export interface AlpicMcpToolConfig {
3
+ name?: string;
4
+ description?: string;
5
+ }
6
+ export declare function registerAlpicTools(server: McpServer, config?: AlpicMcpToolConfig): void;
@@ -0,0 +1 @@
1
+ import{defineFeature as Q}from"@contractspec/lib.contracts-spec/features";var d=Q({meta:{key:"modules.alpic",version:"1.0.0",title:"Alpic",description:"Alpic MCP and ChatGPT App hosting helpers",domain:"alpic",owners:["@contractspec-core"],tags:["package","modules","alpic"],stability:"experimental"}});function O(A){let y=A.trim();if(!y)return"/assets";if(y.startsWith("/assets"))return y;if(y.startsWith("/"))return`/assets${y}`;return`/assets/${y}`}function K(A){return O(A)}function k(A){let y=O(A),E=process.env.ALPIC_HOST?.trim();if(!E)return y;return`https://${E}${y}`}import{Logger as z,LogLevel as D}from"@contractspec/lib.logger";import{McpServer as F}from"@modelcontextprotocol/sdk/server/mcp.js";import{WebStandardStreamableHTTPServerTransport as M}from"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";import{randomUUID as N}from"crypto";import{Elysia as L}from"elysia";var V="alpic_ui",X="app://ui";function J(A,y={}){let E=y.assetPath??"index.html",U=K(E),_=k(E),C=y.resourceKey??V,$=y.resourceUri??X,S=y.title??"ChatGPT App UI",x=y.description??"Entry point for the ChatGPT App UI hosted on Alpic.";A.registerResource(C,$,{title:S,description:x,mimeType:"application/json"},async()=>{return{contents:[{uri:$,mimeType:"application/json",text:JSON.stringify({title:S,description:x,path:U,url:_},null,2)}]}})}import{sanitizeMcpName as Y}from"@contractspec/lib.contracts-spec/jsonschema";import*as P from"zod";var Z="alpic_ping",W=P.object({message:P.string().optional()});function w(A,y={}){let E=Y(y.name??Z),U=y.description??"Ping the MCP server and return basic Alpic info.";A.registerTool(E,{description:U,inputSchema:W},async(_)=>{let $={ok:!0,message:W.parse(_??{}).message??"pong",assetsBase:K(""),timestamp:new Date().toISOString()};return{content:[{type:"text",text:JSON.stringify($,null,2)}]}})}var l="contractspec-alpic-mcp",u="1.0.0";function r(A){if(typeof A==="boolean")return A;return process.env.ALPIC_MCP_DEBUG==="1"||process.env.CONTRACTSPEC_MCP_DEBUG==="1"}function v(A){return new z({level:A?D.DEBUG:D.INFO,environment:"production",enableTracing:!1,enableTiming:!1,enableContext:!1,enableColors:!1})}function I(A,y){let E=(U)=>U.map((_)=>typeof _==="string"?_:JSON.stringify(_)).join(" ");return{log:(...U)=>{if(!y)return;A.info(E(U))},info:(...U)=>{if(!y)return;A.info(E(U))},warn:(...U)=>{A.warn(E(U))},error:(...U)=>{A.error(E(U))},debug:(...U)=>{if(!y)return;A.debug(E(U))}}}function b(A,y){w(A,y.tool),J(A,y.ui)}function m(A,y,E){return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:y,message:E},id:null}),{status:A,headers:{"content-type":"application/json"}})}function H(A,y){let E=new F({name:A.serverName??l,version:A.serverVersion??u},{capabilities:{tools:{},resources:{},prompts:{},logging:{}}});b(E,A);let U=new M({sessionIdGenerator:y?()=>N():void 0,enableJsonResponse:A.enableJsonResponse??!0});return E.connect(U).then(()=>({server:E,transport:U}))}async function R(A){await Promise.allSettled([A.transport.close(),A.server.close()])}function q(A){return A.replace(/[^a-zA-Z0-9]+/g,"-")}function p(A){let y=r(A.enableDebugLogs),E=A.logger??v(y),U=A.stateless??!0,_=new Map,C=`alpic-mcp-handler-${q(A.path)}`;async function $(f){let c=await H(A,!1);try{return await c.transport.handleRequest(f)}finally{await R(c)}}async function S(f){let c=_.get(f);if(!c)return;_.delete(f),await R(c)}async function x(f){let c=f.headers.get("mcp-session-id"),T,j=!1;if(c){let h=_.get(c);if(!h)return m(404,-32001,"Session not found");T=h}else T=await H(A,!0),j=!0;try{let h=await T.transport.handleRequest(f),B=T.transport.sessionId;if(B&&!_.has(B))_.set(B,T);if(f.method==="DELETE"&&B)await S(B);else if(!B&&j)await R(T);return h}catch(h){if(j)await R(T);throw h}}let G=I(E,y);return new L({name:C}).all(A.path,async({request:f})=>{try{if(A.validateAuth){if(!await A.validateAuth(f))return m(401,-32002,"Unauthorized")}if(U)return await $(f);return await x(f)}catch(c){return G.error("Error handling MCP request",{path:A.path,method:f.method,error:c instanceof Error?c.stack??c.message:String(c)}),m(500,-32000,"Internal error")}})}function TA(A={}){let y=new L;return(A.basePaths??["/","/mcp"]).forEach((U)=>{y.use(p({...A,path:U}))}),y}export{p as createAlpicMcpHandler,TA as createAlpicMcpApp,k as alpicAssetUrl,K as alpicAssetPath,d as AlpicFeature};
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@lssm-tech/module.alpic",
3
+ "version": "3.7.29",
4
+ "description": "Alpic MCP and ChatGPT App hosting helpers",
5
+ "keywords": [
6
+ "contractspec",
7
+ "alpic",
8
+ "mcp",
9
+ "chatgpt-app",
10
+ "hosting",
11
+ "typescript"
12
+ ],
13
+ "type": "module",
14
+ "types": "./dist/index.d.ts",
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
21
+ "publish:pkg:canary": "bun publish:pkg --tag canary",
22
+ "build": "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
+ "clean": "rimraf dist .turbo",
27
+ "lint": "bun lint:fix",
28
+ "lint:fix": "node ../../../scripts/biome.cjs check --write --unsafe --only=nursery/useSortedClasses . && node ../../../scripts/biome.cjs check --write .",
29
+ "lint:check": "node ../../../scripts/biome.cjs check .",
30
+ "prebuild": "contractspec-bun-build prebuild",
31
+ "typecheck": "tsc --noEmit"
32
+ },
33
+ "dependencies": {
34
+ "@contractspec/lib.contracts-spec": "6.4.0",
35
+ "@contractspec/lib.logger": "3.7.22",
36
+ "@modelcontextprotocol/sdk": "^1.29.0",
37
+ "elysia": "^1.4.28",
38
+ "zod": "^4.3.5"
39
+ },
40
+ "devDependencies": {
41
+ "@contractspec/tool.typescript": "3.7.13",
42
+ "typescript": "^5.9.3",
43
+ "@contractspec/tool.bun": "3.7.18"
44
+ },
45
+ "exports": {
46
+ ".": {
47
+ "types": "./dist/index.d.ts",
48
+ "bun": "./dist/index.js",
49
+ "node": "./dist/node/index.js",
50
+ "default": "./dist/index.js"
51
+ }
52
+ },
53
+ "publishConfig": {
54
+ "access": "public",
55
+ "exports": {
56
+ ".": {
57
+ "types": "./dist/index.d.ts",
58
+ "bun": "./dist/index.js",
59
+ "node": "./dist/node/index.js",
60
+ "default": "./dist/index.js"
61
+ }
62
+ },
63
+ "registry": "https://registry.npmjs.org"
64
+ },
65
+ "license": "MIT",
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "https://github.com/lssm-tech/contractspec.git",
69
+ "directory": "packages/modules/alpic"
70
+ },
71
+ "homepage": "https://contractspec.io"
72
+ }