@lssm-tech/module.alpic 3.7.29 → 5.0.1
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/README.md +7 -7
- package/package.json +87 -20
- package/dist/alpic.feature.d.ts +0 -1
- package/dist/assets/paths.d.ts +0 -2
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -2
- package/dist/mcp/alpic-mcp.test.d.ts +0 -1
- package/dist/mcp/create-alpic-mcp-app.d.ts +0 -24
- package/dist/mcp/resources.d.ts +0 -9
- package/dist/mcp/tools.d.ts +0 -6
- package/dist/node/index.js +0 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @lssm-tech/module.alpic
|
|
2
2
|
|
|
3
3
|
Website: https://contractspec.io
|
|
4
4
|
|
|
@@ -9,20 +9,20 @@ Website: https://contractspec.io
|
|
|
9
9
|
- **Layer**: module.
|
|
10
10
|
- **Consumers**: apps (alpic-mcp, chatgpt-app).
|
|
11
11
|
- `src/mcp/` contains MCP handlers, tools, prompts, and resources.
|
|
12
|
-
- Related ContractSpec packages include `@
|
|
12
|
+
- Related ContractSpec packages include `@lssm-tech/lib.contracts-spec`, `@lssm-tech/lib.logger`, `@lssm-tech/tool.bun`, `@lssm-tech/tool.typescript`.
|
|
13
13
|
- `src/mcp/` contains MCP handlers, tools, prompts, and resources.
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
|
-
`npm install @
|
|
17
|
+
`npm install @lssm-tech/module.alpic`
|
|
18
18
|
|
|
19
19
|
or
|
|
20
20
|
|
|
21
|
-
`bun add @
|
|
21
|
+
`bun add @lssm-tech/module.alpic`
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
|
-
Import the root entrypoint from `@
|
|
25
|
+
Import the root entrypoint from `@lssm-tech/module.alpic`, or choose a documented subpath when you only need one part of the package surface.
|
|
26
26
|
|
|
27
27
|
## Architecture
|
|
28
28
|
|
|
@@ -37,11 +37,11 @@ Import the root entrypoint from `@contractspec/module.alpic`, or choose a docume
|
|
|
37
37
|
## Local Commands
|
|
38
38
|
|
|
39
39
|
- `bun run dev` — contractspec-bun-build dev
|
|
40
|
-
- `bun run build` — bun
|
|
40
|
+
- `bun run build` — contractspec-bun-build build
|
|
41
41
|
- `bun run lint` — bun lint:fix
|
|
42
42
|
- `bun run lint:check` — biome check .
|
|
43
43
|
- `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
|
|
44
|
-
- `bun run typecheck` —
|
|
44
|
+
- `bun run typecheck` — tsgo --noEmit
|
|
45
45
|
- `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
|
|
46
46
|
- `bun run publish:pkg:canary` — bun publish:pkg --tag canary
|
|
47
47
|
- `bun run clean` — rimraf dist .turbo
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm-tech/module.alpic",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Alpic MCP and ChatGPT App hosting helpers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contractspec",
|
|
@@ -13,13 +13,12 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"files": [
|
|
16
|
-
"
|
|
17
|
-
"README.md"
|
|
16
|
+
"package.json"
|
|
18
17
|
],
|
|
19
18
|
"scripts": {
|
|
20
19
|
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
21
20
|
"publish:pkg:canary": "bun publish:pkg --tag canary",
|
|
22
|
-
"build": "bun
|
|
21
|
+
"build": "contractspec-bun-build build",
|
|
23
22
|
"build:bundle": "contractspec-bun-build transpile",
|
|
24
23
|
"build:types": "contractspec-bun-build types",
|
|
25
24
|
"dev": "contractspec-bun-build dev",
|
|
@@ -28,33 +27,30 @@
|
|
|
28
27
|
"lint:fix": "node ../../../scripts/biome.cjs check --write --unsafe --only=nursery/useSortedClasses . && node ../../../scripts/biome.cjs check --write .",
|
|
29
28
|
"lint:check": "node ../../../scripts/biome.cjs check .",
|
|
30
29
|
"prebuild": "contractspec-bun-build prebuild",
|
|
31
|
-
"typecheck": "
|
|
30
|
+
"typecheck": "tsgo --noEmit"
|
|
32
31
|
},
|
|
33
32
|
"dependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"
|
|
38
|
-
"
|
|
33
|
+
"@lssm-tech/lib.contracts-spec": "workspace:^",
|
|
34
|
+
"@lssm-tech/lib.crypto-utils": "workspace:^",
|
|
35
|
+
"@lssm-tech/lib.logger": "workspace:^",
|
|
36
|
+
"@modelcontextprotocol/sdk": "catalog:ai",
|
|
37
|
+
"elysia": "catalog:server",
|
|
38
|
+
"zod": "catalog:"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"typescript": "
|
|
43
|
-
"@
|
|
41
|
+
"@lssm-tech/tool.typescript": "workspace:*",
|
|
42
|
+
"typescript": "catalog:",
|
|
43
|
+
"@lssm-tech/tool.bun": "workspace:*"
|
|
44
44
|
},
|
|
45
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
|
-
}
|
|
46
|
+
".": "./src/index.ts"
|
|
52
47
|
},
|
|
53
48
|
"publishConfig": {
|
|
54
49
|
"access": "public",
|
|
55
50
|
"exports": {
|
|
56
51
|
".": {
|
|
57
52
|
"types": "./dist/index.d.ts",
|
|
53
|
+
"browser": "./dist/browser/index.js",
|
|
58
54
|
"bun": "./dist/index.js",
|
|
59
55
|
"node": "./dist/node/index.js",
|
|
60
56
|
"default": "./dist/index.js"
|
|
@@ -68,5 +64,76 @@
|
|
|
68
64
|
"url": "https://github.com/lssm-tech/contractspec.git",
|
|
69
65
|
"directory": "packages/modules/alpic"
|
|
70
66
|
},
|
|
71
|
-
"homepage": "https://contractspec.io"
|
|
67
|
+
"homepage": "https://contractspec.io",
|
|
68
|
+
"contractspec": {
|
|
69
|
+
"catalog": {
|
|
70
|
+
"family": "solutions",
|
|
71
|
+
"kind": "module",
|
|
72
|
+
"status": "active",
|
|
73
|
+
"adoptionMode": "adoptable",
|
|
74
|
+
"stability": "stable",
|
|
75
|
+
"platforms": [
|
|
76
|
+
"server"
|
|
77
|
+
],
|
|
78
|
+
"runtimes": [
|
|
79
|
+
"node"
|
|
80
|
+
],
|
|
81
|
+
"entrypoints": [
|
|
82
|
+
"."
|
|
83
|
+
],
|
|
84
|
+
"documentation": [
|
|
85
|
+
{
|
|
86
|
+
"title": "Module Alpic documentation",
|
|
87
|
+
"url": "https://www.npmjs.com/package/%40lssm-tech%2Fmodule.alpic",
|
|
88
|
+
"kind": "readme"
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"examples": [],
|
|
92
|
+
"replacements": [],
|
|
93
|
+
"capabilities": [
|
|
94
|
+
{
|
|
95
|
+
"id": "package.lssm.tech.module.alpic",
|
|
96
|
+
"title": "Module Alpic",
|
|
97
|
+
"description": "Alpic MCP and ChatGPT App hosting helpers",
|
|
98
|
+
"status": "active",
|
|
99
|
+
"useCases": [
|
|
100
|
+
"Adopt alpic mcp and chatgpt app hosting helpers"
|
|
101
|
+
],
|
|
102
|
+
"aliases": [
|
|
103
|
+
"contractspec",
|
|
104
|
+
"alpic",
|
|
105
|
+
"mcp",
|
|
106
|
+
"chatgpt-app",
|
|
107
|
+
"hosting",
|
|
108
|
+
"typescript",
|
|
109
|
+
"module"
|
|
110
|
+
],
|
|
111
|
+
"pythonEquivalents": [],
|
|
112
|
+
"canonicalImports": [
|
|
113
|
+
{
|
|
114
|
+
"from": "@lssm-tech/module.alpic",
|
|
115
|
+
"symbols": []
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
"constraints": {
|
|
119
|
+
"platforms": [
|
|
120
|
+
"server"
|
|
121
|
+
],
|
|
122
|
+
"runtimes": [
|
|
123
|
+
"node"
|
|
124
|
+
],
|
|
125
|
+
"avoidWhen": [
|
|
126
|
+
"The @lssm-tech/module.alpic package constraints do not match the target runtime or platform."
|
|
127
|
+
],
|
|
128
|
+
"requires": [
|
|
129
|
+
"TypeScript"
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
"alternatives": [],
|
|
133
|
+
"relationships": [],
|
|
134
|
+
"resolutionPriority": 50
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
}
|
|
72
139
|
}
|
package/dist/alpic.feature.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const AlpicFeature: import("@contractspec/lib.contracts-spec").FeatureModuleSpec;
|
package/dist/assets/paths.d.ts
DELETED
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
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;
|
package/dist/mcp/resources.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
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;
|
package/dist/mcp/tools.d.ts
DELETED
package/dist/node/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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};
|