@@ -19,6 +19,7 @@ import { D1PublicRepository } from './server/repositories/d1/d1-public-repositor
1919import type { AgentRepository } from './server/repositories/agent-repository' ;
2020import type { PublicRepository } from './server/repositories/public-repository' ;
2121import { serveDynamicPublicPage } from './server/public/response' ;
22+ import { machineAgentSkill } from './data/agentOnboarding' ;
2223
2324interface ExecutionContextLike {
2425 waitUntil ( promise : Promise < unknown > ) : void ;
@@ -45,11 +46,14 @@ function denyAllRobots(): Response {
4546 } ) ;
4647}
4748
48- function preserveMachineGuideEncoding ( request : Request , response : Response ) : Response {
49- if ( new URL ( request . url ) . pathname !== '/skill.md' ) return response ;
50- const encodedResponse = new Response ( response . body , response ) ;
51- encodedResponse . headers . set ( 'content-type' , 'text/markdown; charset=utf-8' ) ;
52- return encodedResponse ;
49+ function machineGuideResponse ( method : string ) : Response {
50+ return new Response ( method === 'HEAD' ? null : machineAgentSkill , {
51+ headers : {
52+ 'cache-control' : 'no-store, no-transform' ,
53+ 'content-type' : 'text/markdown; charset=utf-8' ,
54+ 'x-content-type-options' : 'nosniff' ,
55+ } ,
56+ } ) ;
5357}
5458
5559async function startStagingOAuth ( request : Request , env : OrbitBindings ) : Promise < Response > {
@@ -89,6 +93,12 @@ export async function handleWorkerRequest(
8993 if ( url . pathname === '/healthz' ) {
9094 return Response . json ( { ok : true , service : 'orbit-v6' , environment : env . ORBIT_ENVIRONMENT } ) ;
9195 }
96+ if (
97+ url . pathname === '/skill.md'
98+ && ( request . method === 'GET' || request . method === 'HEAD' )
99+ ) {
100+ return machineGuideResponse ( request . method ) ;
101+ }
92102 if ( url . pathname . startsWith ( '/v1/' ) ) {
93103 const response = await servePublicRead ( request , env , async ( ) => {
94104 const testNow = env . ORBIT_ENVIRONMENT === 'test'
@@ -125,7 +135,7 @@ export async function handleWorkerRequest(
125135 dependencies . agentRepository ?? new D1AgentRepository ( env . DB ) ,
126136 ) ;
127137 if ( publicPage ) return publicPage ;
128- return preserveMachineGuideEncoding ( request , await env . ASSETS . fetch ( request ) ) ;
138+ return await env . ASSETS . fetch ( request ) ;
129139 } , env . ORBIT_ENVIRONMENT ) ;
130140 return protectFromIndexing ( response , env ) ;
131141}
0 commit comments